00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef CHANNEL_H
00017 #define CHANNEL_H
00018
00019 #ifndef USE_PCH
00020 #include "debug.h"
00021 #include <map>
00022 #include <boost/noncopyable.hpp>
00023 #endif
00024
00025 #include "Target.h"
00026 #include "IdentityReference.h"
00027 #include "Member.h"
00028 #include "Network.h"
00029
00030 class MessageIn;
00031
00032
00033
00034
00035 class Channel : public Target, public IdentityReference, public boost::noncopyable {
00036 public:
00037
00038 typedef std::map<std::string, Member> members_type;
00039
00040 private:
00041 members_type M_members;
00042 bool M_received_names;
00043 time_t M_creation_time;
00044 std::string M_key;
00045
00046 private:
00047
00048 friend boost::shared_ptr<Channel> Target::add_channel(Identity& identity, std::string const& channel_name);
00049
00050 Channel(Identity& identity, std::string const& target_name, Network& network) :
00051 Target(&network), IdentityReference(&identity),
00052 M_received_names(false), M_creation_time(0)
00053 {
00054 ASSERT(!network.is_private());
00055 Dout(dc::objects, "Constructing Channel(" << identity << ", \"" << target_name << "\", " << network << ") " << static_cast<IdentityReference&>(*this));
00056 }
00057 public:
00058
00059 Channel(Identity& identity, std::string const& target_name, Network& private_network, int) :
00060 Target(&private_network), IdentityReference(&identity),
00061 M_received_names(true), M_creation_time(0)
00062 {
00063 ASSERT(private_network.is_private());
00064 Dout(dc::objects, "Constructing private Channel(" << identity << ", \"" << target_name << "\", " << private_network << ") " <<
00065 static_cast<IdentityReference&>(*this));
00066 }
00067 #ifdef CWDEBUG
00068
00069 ~Channel() { Dout(dc::objects, "Destructing Channel " << *this); }
00070 #endif
00071 virtual void new_client_message_received(ClientMessageIn const& msg);
00072 virtual void new_server_message_received(ServerMessageIn const& msg);
00073
00074 virtual std::string in_name(ClientSession const&) const { return "FIXME"; }
00075 virtual std::string in_name(ServerSession const&) const { return "FIXME"; }
00076 virtual std::string out_name(ClientSession const&) const { return "FIXME"; }
00077 virtual std::string out_name(ServerSession const&) const { return "FIXME"; }
00078
00079
00080 members_type& members(void) { return M_members; }
00081
00082 members_type const& members(void) const { return M_members; }
00083
00084 void sub_joined_nick(boost::shared_ptr<Nick> nick);
00085
00086
00087 void set_received_names(void) { M_received_names = true; }
00088
00089
00090 void reset_received_names(void) { M_received_names = false; }
00091
00092
00093 void set_creation_time(time_t creation_time) { M_creation_time = creation_time; }
00094
00095
00096 bool received_names(void) const { return M_received_names; }
00097
00098
00099 time_t creation_time(void) const { return M_creation_time; }
00100
00101
00102 bool has_key(void) const { return !M_key.empty(); }
00103
00104
00105 std::string const& key(void) const { return M_key; }
00106 };
00107
00108 #endif // CHANNEL_H