00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef NETWORK_H
00017 #define NETWORK_H
00018
00019 #ifndef USE_PCH
00020 #include <string>
00021 #include <vector>
00022 #include <cassert>
00023 #include <boost/shared_ptr.hpp>
00024 #endif
00025
00026 #include "Server.h"
00027 #include "Target.h"
00028
00029 class PersistXML;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class Network {
00040 public:
00041 typedef std::vector<boost::shared_ptr<Server> > servers_type;
00042
00043 private:
00044 std::string M_name;
00045 std::string M_domain;
00046 servers_type M_servers;
00047 target_lookup_map_type M_targets;
00048 bool M_private;
00049
00050 public:
00051
00052 Network(void) : M_private(false)
00053 { Dout(dc::objects, "Constructing Network()"); }
00054
00055
00056 Network(std::string const& name, bool priv = false) : M_name(name), M_private(priv)
00057 { Dout(dc::objects, "Constructing Network(\"" << name << "\", " << priv << ")"); }
00058
00059
00060 Network(std::string const& name, std::string const& domain, bool priv = false) :
00061 M_name(name), M_domain(domain), M_private(priv)
00062 { Dout(dc::objects, "Constructing Network(\"" << name << "\", \"" << domain << "\", " << priv << ")"); }
00063
00064 #ifdef CDWDEBUG
00065
00066 ~Network() { Dout(dc::objects, "Destructing Network " << *this); }
00067
00068
00069 Network(Network const& network) :
00070 M_name(network.M_name),
00071 M_domain(network.M_domain),
00072 M_servers(network.M_servers),
00073 M_targets(network.M_targets),
00074 M_private(network.M_private)
00075 { Dout(dc::objects, "Copy-constructing Network from " << network); }
00076 #endif
00077
00078
00079 std::string const& name(void) const { return M_name; }
00080
00081
00082 bool has_domain(void) const { return !M_domain.empty(); }
00083
00084
00085 std::string const& domain(void) const { assert(has_domain()); return M_domain; }
00086
00087
00088 servers_type const& servers(void) const { return M_servers; }
00089
00090
00091 servers_type& servers(void) { return M_servers; }
00092
00093
00094 target_lookup_map_type const& targets(void) const { ASSERT(!M_private); return M_targets; }
00095
00096
00097 target_lookup_map_type& targets(void) { ASSERT(!M_private); return M_targets; }
00098
00099
00100 bool is_private(void) const { return M_private; }
00101
00102
00103
00104
00105
00106 typedef uint32_t who_flags_type;
00107
00108 struct WhoMap { char who_flag; who_flags_type mask; };
00109
00110 typedef std::vector<WhoMap> who_flag_vector_type;
00111
00112 private:
00113 who_flag_vector_type M_who_flag_vector;
00114
00115 public:
00116
00117 void init_who_flag_table(std::string const& umodes, std::string prefix);
00118
00119
00120 char flag_to_char(who_flags_type maskbit) const;
00121
00122
00123 who_flags_type char_to_flag(char who_flag) const;
00124
00125 void serialize(PersistXML& xml);
00126 };
00127
00128 #endif // NETWORK_H