Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | Related Pages

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 <pthread.h>
00027 #include <string>
00028 
00029 namespace rlog
00030 {
00031     class RLogNode;
00032 
00045     struct RLogData
00046     {
00047         struct PublishLoc *publisher;
00049         time_t time;
00051         const char *msg; 
00052 
00053         // track which nodes have seen this message, to avoid getting
00054         // duplicates.  It would be nice if we could enforce this via the node
00055         // structure instead, but that is much harder.
00056         std::set< RLogNode * > seen;
00057     };
00058 
00059     // documentation in implementation file
00060     class RLogNode
00061     {
00062     public:
00063         RLogNode();
00064         virtual ~RLogNode();
00065 
00066         // remove this node from the subscription network
00067         virtual void clear();
00068 
00069         virtual void publish( const RLogData &data );
00070 
00071         // primary interface
00072         virtual void addPublisher( RLogNode * );
00073         virtual void dropPublisher( RLogNode *, bool callbacks=true );
00074 
00075         bool enabled() const;
00076 
00077         // used internally - see documentation
00078         virtual void addSubscriber( RLogNode * );
00079         virtual void dropSubscriber( RLogNode * );
00080 
00081         virtual void isInterested( RLogNode *node, bool isInterested );
00082 
00083     protected:
00084         // called by RLogNode when enable state changed.
00085         virtual void enabled(bool newState);
00086 
00088         std::list< RLogNode * > publishers;
00089 
00091         std::list< RLogNode * > subscribers;
00092 
00094         std::list< RLogNode * > interestList;
00095 
00096         pthread_mutex_t mutex;
00097     };
00098 }
00099 
00100 #endif
00101 

Generated on Sun Mar 14 14:49:50 2004 for rlog by doxygen 1.3.2