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

RtcConfig.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00019 /*
00020  * $Log: RtcConfig.h,v $
00021  * Revision 1.2  2005/05/16 06:05:48  n-ando
00022  * - RtcConfig class was DLL exported for Windows port.
00023  *
00024  * Revision 1.1.1.1  2005/05/12 09:06:18  n-ando
00025  * Public release.
00026  *
00027  *
00028  */
00029 
00030 #ifndef RtcConfig_h
00031 #define RtcConfig_h
00032 
00033 #include <string>
00034 #include <map>
00035 #include <vector>
00036 #include <list>
00037 #include <fstream>
00038 #include "rtm/RTC.h"
00039 
00040 
00041 namespace RTM
00042 {
00043   
00044   using namespace std;
00045   
00046 #ifdef ORB_IS_OMNIORB
00047   static const char* config_map[][3] = 
00048         {{"IIOPAddrPort", "-ORBendPoint", "giop:tcp:"},
00049          {"", "", ""},
00050          {"NameServer", "-ORBInitRef", "NameService=corbaname::"},
00051          {0,0,0}};
00052 #endif // omniORB
00053   
00054 #ifdef ORB_IS_MICO
00055   static const char* config_map[][3] = 
00056         {{"NameServer", "-ORBNamingAddr", ""},
00057          {"IIOPAddrPort", "-ORBIIOPAddr", "inet:"},
00058          {"", "", ""},
00059          {0,0,0}};
00060 #endif // MICO
00061   
00062   static const char* config_file_path[] = 
00063         {"./rtc.conf",
00064          "/etc/rtc.conf",
00065          "/etc/rtc/rtc.conf",
00066          "/usr/local/etc/rtc.conf",
00067          NULL};
00068   
00069   static const char* config_file_env = "RTC_CONFIG";
00070 
00092   class EXPORTS RtcConfig
00093   {
00094   public:
00110         RtcConfig(): m_DebugMode(false){};
00111 
00133         RtcConfig(int argc, char** argv);
00134 
00146         virtual ~RtcConfig();
00147         
00169         bool initConfig(int argc, char** argv);
00170         
00188         char** getOrbInitArgv() const
00189         {
00190           //      for (int i = 0; i < m_Argc; i++) cerr << m_Argv[i] << endl;
00191           return m_Argv;
00192         };
00193         
00209         int getOrbInitArgc() const {return m_Argc;};
00210         
00226         string getNameServer() const {return m_NameServer;};
00227         
00244         list<string>& getComponentLoadPath() {return m_ComponentLoadPath;};
00245         
00253         string getBinName() const {return m_BinName;};
00254         
00262         string getOSname() const {return m_OSname;};
00263         
00271         string getHostname() const {return m_Hostname;};
00272         
00280         string getOSrelease() const {return m_OSrelease;};
00281         
00289         string getOSversion() const {return m_OSversion;};
00290         
00298         string getArch() const {return m_Arch;};
00299         
00307         string getPid() const {return m_Pid;};
00308 
00309         string getLogFileName();
00310         string getErrorLogFileName();
00311         int getLogLevel();
00312         int getLogLock();
00313         std::string getLogTimeFormat();
00314         
00315   protected:
00323         bool parseCommandArgs(int argc, char** argv);
00324         
00332         bool findConfigFile();
00333         
00341         bool parseConfigFile();
00342         
00350         bool collectSysInfo();
00351         
00359         void printUsage(char* arg);
00360         
00368         void argsToArgv();
00369 
00377         bool fileExist(const char *filename);
00385         bool split(const string& input, const string& delimiter, list<string>& results);
00386   private:
00394         string m_BinName;
00395         string m_ArgConfigFile;
00396         string m_ConfigFile;
00397         map<string, string> m_Config;
00398         vector<string> m_Args;
00399         char** m_Argv;
00400         int m_Argc;
00401         string m_NameServer;
00402         std::list<string> m_ComponentLoadPath;
00403         string m_OSname;
00404         string m_Hostname;
00405         string m_OSrelease;
00406         string m_OSversion;
00407         string m_Arch;
00408         string m_Pid;
00409         bool m_DebugMode;
00410   };
00411   
00412 }; // end of namespace RTM
00413 
00414 #endif // end of __RtcConfig_h__

Generated on Sat Oct 28 02:28:13 2006 for OpenRTM by  doxygen 1.4.1