00001 #ifndef CONFIGURATION_H_
00002 #define CONFIGURATION_H_
00003
00004 #include "ibrcommon/data/ConfigFile.h"
00005 #include "core/Node.h"
00006 #include "routing/StaticRoutingExtension.h"
00007 #include "ibrcommon/Exceptions.h"
00008 #include "ibrcommon/net/NetInterface.h"
00009
00010 using namespace dtn::net;
00011 using namespace dtn::core;
00012 using namespace dtn::data;
00013
00014 namespace dtn
00015 {
00016 namespace daemon
00017 {
00021 class Configuration
00022 {
00023 private:
00024 Configuration();
00025 virtual ~Configuration();
00026
00027 public:
00028 class NetConfig
00029 {
00030 public:
00031 enum NetType
00032 {
00033 NETWORK_UNKNOWN = 0,
00034 NETWORK_TCP = 1,
00035 NETWORK_UDP = 2,
00036 NETWORK_HTTP = 3
00037 };
00038
00039 NetConfig(std::string name, NetType type, const std::string &address, int port, bool discovery = true);
00040 NetConfig(std::string name, NetType type, const ibrcommon::NetInterface &iface, int port, bool discovery = true);
00041 ~NetConfig();
00042
00043 std::string name;
00044 NetType type;
00045 ibrcommon::NetInterface interface;
00046 std::string address;
00047 int port;
00048 bool discovery;
00049 };
00050
00051 class ParameterNotSetException : ibrcommon::Exception
00052 {
00053 };
00054
00055 class ParameterNotFoundException : ibrcommon::Exception
00056 {
00057 };
00058
00059 static Configuration &getInstance();
00060
00064 void load();
00065 void load(string filename);
00066
00067 void params(int argc, char *argv[]);
00068
00072 string getNodename();
00073
00077 std::list<NetConfig> getInterfaces();
00078
00079 std::string getDiscoveryAddress();
00080 int getDiscoveryPort();
00081
00082 Configuration::NetConfig getAPIInterface();
00083
00087 list<Node> getStaticNodes();
00088
00092 list<dtn::routing::StaticRoutingExtension::StaticRoute> getStaticRoutes();
00093
00094 int getTimezone();
00095
00096 ibrcommon::File getPath(string name);
00097
00098 unsigned int getUID();
00099 unsigned int getGID();
00100
00101 bool doDiscovery();
00102 bool doAPI();
00103
00104 std::string version();
00105
00106 string getNotifyCommand();
00107
00108 enum RoutingExtension
00109 {
00110 DEFAULT_ROUTING = 0,
00111 EPIDEMIC_ROUTING = 1
00112 };
00113
00117 RoutingExtension getRoutingExtension();
00118
00123 bool doForwarding();
00124
00128 bool useStatLogger();
00129
00133 ibrcommon::File getStatLogfile();
00134
00138 std::string getStatLogType();
00139
00143 unsigned int getStatLogInterval();
00144
00148 std::string getStatAddress();
00149
00153 unsigned int getStatPort();
00154
00158 int getDebugLevel() const;
00159
00163 bool doDebug() const;
00164
00169 bool beQuiet() const;
00170
00176 size_t getLimit(std::string);
00177
00178 private:
00179 ibrcommon::ConfigFile _conf;
00180
00181 string _filename;
00182 ibrcommon::NetInterface _default_net;
00183 bool _use_default_net;
00184 bool _doapi;
00185 bool _dodiscovery;
00186 int _debuglevel;
00187 bool _debug;
00188 bool _quiet;
00189 };
00190 }
00191 }
00192
00193 #endif