KatanaNativeInterface  $VERSION$
kmlFactories.h
Go to the documentation of this file.
1 
2 #ifndef KMLFACTORIES_H
3 #define KMLFACTORIES_H
4 
5 #include "common/exception.h"
6 
7 #include "KNI/kmlBase.h"
8 #include "KNI/kmlMotBase.h"
9 #include "KNI/kmlSctBase.h"
10 
11 #include <string>
12 #include <fstream>
13 
18 
23 public:
25  Exception("ConfigFile is not open or other failure", -41) {}
26 };
27 
32 public:
33  ConfigFileSectionNotFoundException(const std::string & attribute) throw ():
34  Exception("Could not find section '" + attribute + "' in configfile", -42) {}
35 };
36 
41 public:
42  ConfigFileSubsectionNotFoundException(const std::string & attribute) throw ():
43  Exception("Could not find subsection '" + attribute + "' in configfile", -43) {}
44 };
45 
50 public:
51  ConfigFileEntryNotFoundException(const std::string & attribute) throw ():
52  Exception("Could not find entry '" + attribute + "' in configfile", -44) {}
53 };
54 
59 public:
60  ConfigFileSyntaxErrorException(const std::string & line) throw ():
61  Exception("Syntax error in this line: '" + line + "'", -45) {}
62 };
63 
67 
68 
69 namespace KNI {
70 
76  private:
77  std::ifstream _configfile;
78  void _readEntry(char* dest, int destsz, const char* section, const char* subsection, const char* entry);
79  public:
80 
81  kmlFactory();
82 
83  bool openFile(const char* filepath) {
84  _configfile.open(filepath);
85  return _configfile.fail() ? false : true;
86  }
87 #ifdef _UNICODE
88  bool openFile(const wchar_t* filepath) {
89  _configfile.open(filepath);
90  return _configfile.fail() ? false : true;
91  }
92 #endif
93 
94  TKatGNL getGNL();
95  TKatMOT getMOT();
96  TKatSCT getSCT();
97  TKatEFF getEFF();
98  TMotDesc* getMotDesc(short count);
99  TSctDesc* getSctDesc(short count);
100 
101  TMotCLB getMotCLB(short number);
102  TMotSCP getMotSCP(short number);
103  TMotDYL getMotDYL(short number);
106  int getType();
107 
108  TMotInit getMotInit(short number);
109 
110  void getGripperParameters(bool& isPresent, int& openEncoders, int& closeEncoders);
111  };
112 
113 
114 
115 }
116 
117 #endif