]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/locotype.cpp
Add some utility functions for interfacing with hardware
[r2c2.git] / source / libmarklin / locotype.cpp
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2009  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #include "locotype.h"
9
10 using namespace std;
11
12 namespace Marklin {
13
14 LocoType::LocoType(unsigned an):
15         VehicleType(an)
16 { }
17
18 unsigned LocoType::get_max_function() const
19 {
20         if(funcs.empty())
21                 return 0;
22         return (--funcs.end())->first;
23 }
24
25
26 LocoType::Loader::Loader(LocoType &lt):
27         VehicleType::Loader(lt)
28 {
29         add("function", &Loader::function);
30 }
31
32 void LocoType::Loader::function(unsigned i, const string &f)
33 {
34         static_cast<LocoType &>(obj).funcs[i] = f;
35 }
36
37 } // namespace Marklin