RLogNode.h

00001 /*****************************************************************************
00002  * Author:   Valient Gough <vgough@pobox.com>
00003  *
00004  *****************************************************************************
00005  * Copyright (c) 2003, Valient Gough
00006  *
00007  * This library is free software; you can distribute it and/or modify it under
00008  * the terms of the GNU Lesser General Public License (LGPL), as published by
00009  * the Free Software Foundation; either version 2.1 of the License, or (at your
00010  * option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE.  See the LGPL in the file COPYING for more
00015  * details.
00016  *
00017  */
00018                                                                                                 
00019 
00020 #ifndef _RLogNode_incl_
00021 #define _RLogNode_incl_
00022 
00023 #include <list>
00024 #include <set>
00025 #include <time.h>
00026 #include <string>
00027 
00028 #include <rlog/common.h>
00029 #include <rlog/Mutex.h>
00030 
00031 namespace rlog
00032 {
00033     class RLOG_DECL RLogNode;
00034 
00047     struct RLOG_DECL RLogData
00048     {
00049         struct PublishLoc *publisher;
00051         time_t time;
00053         const char *msg; 
00054 
00055         // track which nodes have seen this message, to avoid getting
00056         // duplicates.  It would be nice if we could enforce this via the node
00057         // structure instead, but that is much harder.
00058         std::set< RLogNode * > seen;
00059     };
00060 
00061     // documentation in implementation file
00062     class RLogNode
00063     {
00064     public:
00065         RLogNode();
00066         virtual ~RLogNode();
00067 
00068         // remove this node from the subscription network
00069         virtual void clear();
00070 
00071         virtual void publish( const RLogData &data );
00072 
00073         // primary interface
00074         virtual void addPublisher( RLogNode * );
00075         virtual void dropPublisher( RLogNode *, bool callbacks=true );
00076 
00077         bool enabled() const;
00078 
00079         // used internally - see documentation
00080         virtual void addSubscriber( RLogNode * );
00081         virtual void dropSubscriber( RLogNode * );
00082 
00083         virtual void isInterested( RLogNode *node, bool isInterested );
00084 
00085     protected:
00086         // called by RLogNode when enable state changed.
00087         virtual void setEnabled(bool newState);
00088 
00090         std::list< RLogNode * > publishers;
00091 
00093         std::list< RLogNode * > subscribers;
00094 
00096         std::list< RLogNode * > interestList;
00097 
00098         Mutex mutex;
00099     };
00100 }
00101 
00102 #endif
00103 

Generated on Mon Nov 20 22:57:44 2006 for rlog by  doxygen 1.5.0