00001
00002
00003
00004 #ifndef __ENTITY_H__
00005 #define __ENTITY_H__
00006
00007 #include <string>
00008 #include <boost/signals.hpp>
00009
00010 namespace ircpp {
00011 class session;
00012 class user;
00013 class channel;
00014 class message;
00015
00036 class entity
00037 {
00038
00039 public:
00040
00041 explicit entity(session& parent, bool temporary = false);
00042 entity(session& parent, const std::string& name, bool temporary = false);
00043 explicit entity(const entity& parent, bool temporary = false);
00044 virtual ~entity();
00045
00046
00047 const std::string& nick() const;
00048 const std::string& name() const;
00049 const session& parent() const;
00050
00051
00059 virtual bool is_user() const =0;
00067 virtual bool is_channel() const =0;
00068
00069 const user& to_user() const;
00070 const channel& to_channel() const;
00071
00072 user& to_user_internal();
00073 channel& to_channel_internal();
00074
00075
00076 bool is_temporary() const;
00077
00078
00079 void nick(const std::string& nick);
00080 void name(const std::string& name);
00081
00082
00083 bool cmd_privmsg(const std::string& text) const;
00084 bool cmd_notice(const std::string& text) const;
00085 bool cmd_mode(const std::string& modestring) const;
00086 bool cmd_ctcp(const std::string& command, const std::string& text = "") const;
00087 bool cmd_action(const std::string& text) const;
00088
00089
00090 entity& operator=(const entity& from);
00091 virtual bool operator==(const entity& rhs) const;
00092 virtual bool operator==(const std::string& rhs) const;
00093 virtual bool operator!=(const entity& rhs) const;
00094 virtual bool operator!=(const std::string& rhs) const;
00095 virtual bool operator<(const entity& rhs) const;
00096 virtual operator bool () const =0;
00097
00098
00108 mutable boost::signal1<void, entity&> sig_deletable;
00113 mutable boost::signal1<void, entity&> sig_deleting;
00114
00115
00119 mutable boost::signal1<void, const message&> sig_privmsg_msg;
00123 mutable boost::signal1<void, const message&> sig_notice_msg;
00127 mutable boost::signal1<void, const message&> sig_ctcp_msg;
00128
00129
00130 protected:
00131 session& s;
00132 std::string _name;
00133 bool _temporary;
00134 boost::signals::connection deletable_connection;
00135 };
00136
00137 }
00138
00139 #endif