00001 /* 00002 * $Id: ConfigException.cpp 61 2008-01-14 17:38:19Z phbaer $ 00003 * 00004 * Copyright 2008 Carpe Noctem, Distributed Systems Group, 00005 * University of Kassel. All right reserved. 00006 * 00007 * The code is licensed under the Carpe Noctem Userfriendly BSD-Based 00008 * License (CNUBBL). Redistribution and use in source and binary forms, 00009 * with or without modification, are permitted provided that the 00010 * conditions of the CNUBBL are met. 00011 * 00012 * You should have received a copy of the CNUBBL along with this 00013 * software. The license is also available on our website: 00014 * http://carpenoctem.das-lab.net/license.txt 00015 */ 00016 00017 #ifndef CASTOR_SYSTEMCONFIG_H 00018 #define CASTOR_SYSTEMCONFIG_H 1 00019 00020 #include <map> 00021 #include <string> 00022 00023 #include <boost/thread/mutex.hpp> 00024 #include <boost/filesystem.hpp> 00025 00026 #include "Configuration.h" 00027 00028 namespace castor { 00029 00030 class SystemConfig; 00031 00032 typedef boost::shared_ptr<SystemConfig> SystemConfigPtr; 00033 00034 class SystemConfig { 00035 00036 protected: 00037 00038 SystemConfig() {ownRobotID=0;} 00039 00040 static bool initialized; 00041 00042 static boost::mutex mutex; 00043 00044 static SystemConfigPtr instance; 00045 00046 static boost::filesystem::path rootPath; 00047 static boost::filesystem::path libPath; 00048 static boost::filesystem::path logPath; 00049 static boost::filesystem::path configPath; 00050 00051 static std::string hostname; 00052 00053 static std::map<std::string, boost::shared_ptr<Configuration> > configs; 00054 00055 static const char NODE_NAME_SEPERATOR = '_'; 00056 static int ownRobotID; 00057 00058 public: 00059 00060 static SystemConfigPtr getInstance(); 00061 00062 static std::string robotNodeName(const std::string& nodeName); 00063 //static void splitRobotNodeName(const std::string& name, std::string* robotName, std::string* nodeName); 00064 static int GetOwnRobotID(); 00065 static std::string getHostname(); 00066 00067 Configuration *operator[] (const std::string s); 00068 00069 std::string getRootPath(); 00070 std::string getLibPath(); 00071 std::string getLogPath(); 00072 std::string getConfigPath(); 00073 }; 00074 }; 00075 00076 #endif /* CASTOR_SYSTEMCONFIG_H */