KatanaNativeInterface
$VERSION$
|
00001 00002 #ifndef KMLFACTORIES_H 00003 #define KMLFACTORIES_H 00004 00005 #include "common/exception.h" 00006 00007 #include "KNI/kmlBase.h" 00008 #include "KNI/kmlMotBase.h" 00009 #include "KNI/kmlSctBase.h" 00010 00011 #include <string> 00012 #include <fstream> 00013 00018 00022 class ConfigFileStateException : public Exception { 00023 public: 00024 ConfigFileStateException() throw (): 00025 Exception("ConfigFile is not open or other failure", -41) {} 00026 }; 00027 00031 class ConfigFileSectionNotFoundException : public Exception { 00032 public: 00033 ConfigFileSectionNotFoundException(const std::string & attribute) throw (): 00034 Exception("Could not find section '" + attribute + "' in configfile", -42) {} 00035 }; 00036 00040 class ConfigFileSubsectionNotFoundException : public Exception { 00041 public: 00042 ConfigFileSubsectionNotFoundException(const std::string & attribute) throw (): 00043 Exception("Could not find subsection '" + attribute + "' in configfile", -43) {} 00044 }; 00045 00049 class ConfigFileEntryNotFoundException : public Exception { 00050 public: 00051 ConfigFileEntryNotFoundException(const std::string & attribute) throw (): 00052 Exception("Could not find entry '" + attribute + "' in configfile", -44) {} 00053 }; 00054 00058 class ConfigFileSyntaxErrorException : public Exception { 00059 public: 00060 ConfigFileSyntaxErrorException(const std::string & line) throw (): 00061 Exception("Syntax error in this line: '" + line + "'", -45) {} 00062 }; 00063 00067 00068 00069 namespace KNI { 00070 00075 class DLLDIR kmlFactory { 00076 private: 00077 std::ifstream _configfile; 00078 void _readEntry(char* dest, int destsz, const char* section, const char* subsection, const char* entry); 00079 public: 00080 00081 kmlFactory(); 00082 00083 bool openFile(const char* filepath) { 00084 _configfile.open(filepath); 00085 return _configfile.fail() ? false : true; 00086 } 00087 #ifdef _UNICODE 00088 bool openFile(const wchar_t* filepath) { 00089 _configfile.open(filepath); 00090 return _configfile.fail() ? false : true; 00091 } 00092 #endif 00093 00094 TKatGNL getGNL(); 00095 TKatMOT getMOT(); 00096 TKatSCT getSCT(); 00097 TKatEFF getEFF(); 00098 TMotDesc* getMotDesc(short count); 00099 TSctDesc* getSctDesc(short count); 00100 00101 TMotCLB getMotCLB(short number); 00102 TMotSCP getMotSCP(short number); 00103 TMotDYL getMotDYL(short number); 00106 int getType(); 00107 00108 TMotInit getMotInit(short number); 00109 00110 void getGripperParameters(bool& isPresent, int& openEncoders, int& closeEncoders); 00111 }; 00112 00113 00114 00115 } 00116 00117 #endif