/home/matthew/data/programming/current/libircpp/entity.h

00001 /* 
00002  * libircpp++ entity.h
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                 /* Interface functions */
00039                 public:
00040                         /* Constructors and destructors */
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                         /* Data access functions */
00047                         const std::string& nick() const; /* nick() and name() return the same thing */
00048                         const std::string& name() const; 
00049                         const session& parent() const;
00050 
00051                         /* Type determination functions */
00059                         virtual bool is_user() const =0;
00067                         virtual bool is_channel() const =0;
00068                         /* Type conversion functions */
00069                         const user& to_user() const;
00070                         const channel& to_channel() const;
00071                         /* Type conversion functions (internal) */
00072                         user& to_user_internal();
00073                         channel& to_channel_internal();
00074 
00075                         /* Misc functions */
00076                         bool is_temporary() const;
00077 
00078                         /* Data setting functions */
00079                         void nick(const std::string& nick);
00080                         void name(const std::string& name);
00081 
00082                         /* Command functions */
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                         /* Operators */
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                 /* Signals */
00108                         mutable boost::signal1<void, entity&> sig_deletable;
00113                         mutable boost::signal1<void, entity&> sig_deleting;
00114                         /* Note, most of these signals are invoked by the session, to save every channel
00115                          * comparing every message against itself */
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                 /* Private data */
00130                 protected:
00131                         session& s;
00132                         std::string _name;
00133                         bool _temporary;
00134                         boost::signals::connection deletable_connection;
00135         };
00136 
00137 } /* namespace ircpp */
00138 
00139 #endif /* __ENTITY_H__ */

Generated on Sat Oct 13 23:35:40 2007 for libircpp by  doxygen 1.5.3