Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

RtcConfig.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00021 #ifndef __RtcConfig_h__
00022 #define __RtcConfig_h__
00023 
00024 #include <string>
00025 #include <map>
00026 #include <vector>
00027 #include <list>
00028 #include <fstream>
00029 #include "rtm/RTC.h"
00030 
00031 
00032 namespace RTM
00033 {
00034   
00035   using namespace std;
00036   
00037 #ifdef ORB_IS_OMNIORB
00038   static const char* config_map[][3] = 
00039         {{"IIOPAddrPort", "-ORBendpoint", "iiop://"},
00040          {"", "", ""},
00041          {"NameServer", "-ORBInitRef", "NameService=corbaname::"},
00042          {0,0,0}};
00043 #endif // omniORB
00044   
00045 #ifdef ORB_IS_MICO
00046   static const char* config_map[][3] = 
00047         {{"NameServer", "-ORBNamingAddr", ""},
00048          {"IIOPAddrPort", "-ORBIIOPAddr", "inet:"},
00049          {"", "", ""},
00050          {0,0,0}};
00051 #endif // MICO
00052   
00053   static const char* config_file_path[] = 
00054         {"./rtc.conf",
00055          "/etc/rtc.conf",
00056          "/etc/rtc/rtc.conf",
00057          "/usr/local/etc/rtc.conf",
00058          NULL};
00059   
00060   static const char* config_file_env = "RTC_CONFIG";
00061 
00083   class RtcConfig
00084   {
00085   public:
00101         RtcConfig(): m_DebugMode(false){};
00102 
00124         RtcConfig(int argc, char** argv);
00125 
00137         virtual ~RtcConfig();
00138         
00160         bool initConfig(int argc, char** argv);
00161         
00179         char** getOrbInitArgv() const
00180         {
00181           for (int i = 0; i < m_Argc; i++) cerr << m_Argv[i] << endl;
00182           return m_Argv;
00183         };
00184         
00200         int getOrbInitArgc() const {return m_Argc;};
00201         
00217         string getNameServer() const {return m_NameServer;};
00218         
00235         list<string>& getComponentLoadPath() {return m_ComponentLoadPath;};
00236         
00244         string getBinName() const {return m_BinName;};
00245         
00253         string getOSname() const {return m_OSname;};
00254         
00262         string getHostname() const {return m_Hostname;};
00263         
00271         string getOSrelease() const {return m_OSrelease;};
00272         
00280         string getOSversion() const {return m_OSversion;};
00281         
00289         string getArch() const {return m_Arch;};
00290         
00298         string getPid() const {return m_Pid;};
00299 
00300         string getLogFileName();
00301         string getErrorLogFileName();
00302         int getLogLevel();
00303         
00304   protected:
00312         bool parseCommandArgs(int argc, char** argv);
00313         
00321         bool findConfigFile();
00322         
00330         bool parseConfigFile();
00331         
00339         bool collectSysInfo();
00340         
00348         void printUsage(char* arg);
00349         
00357         void argsToArgv();
00358 
00366         bool fileExist(const char *filename);
00374         bool split(const string& input, const string& delimiter, list<string>& results);
00375   private:
00383         string m_BinName;
00384         string m_ArgConfigFile;
00385         string m_ConfigFile;
00386         map<string, string> m_Config;
00387         vector<string> m_Args;
00388         char** m_Argv;
00389         int m_Argc;
00390         string m_NameServer;
00391         std::list<string> m_ComponentLoadPath;
00392         string m_OSname;
00393         string m_Hostname;
00394         string m_OSrelease;
00395         string m_OSversion;
00396         string m_Arch;
00397         string m_Pid;
00398         bool m_DebugMode;
00399   };
00400   
00401 }; // end of namespace RTM
00402 
00403 #endif // end of __RtcConfig_h__

Generated on Thu Dec 16 15:29:18 2004 for OpenRTM by doxygen 1.3.6