Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

Observer.hpp

Go to the documentation of this file.
00001 // vim:sw=2:ts=8
00017 #ifndef OBSERVER__HPP
00018 #define OBSERVER__HPP
00019 
00020 #include "def_graph.hpp"
00021 
00022 
00023 namespace gns {
00024 
00025 
00026   class Subject;
00027 
00028 
00042   class Item
00043   {
00044     public:
00045       int type;  
00046       Node node; 
00047       Edge edge; 
00050       Item() { type = 0; }
00052       Item(const Item &item)
00053       {
00054           this->type = item.type;
00055           if( type == 1 ) this->node = item.node;
00056           else if( type == 2 ) this->edge = item.edge;
00057       }
00059       Item(Node n) { this->type = 1; this->node = n; }
00061       Item(Edge e) { this->type = 2; this->edge = e; }
00062   };
00063 
00064 
00073   class Message
00074   {
00075     public:
00076       const static long new_node        = 0x0010; 
00077       const static long del_node        = 0x0011; 
00078       const static long del_node_done   = 0x0012; 
00079       const static long new_edge        = 0x0020; 
00080       const static long del_edge        = 0x0021; 
00081       const static long del_edge_done   = 0x0022; 
00082       const static long begin_edit_seq  = 0x0030; 
00083       const static long end_edit_seq    = 0x0031; 
00084       const static long node_id_changed = 0x0040; 
00085       const static long edge_id_changed = 0x0041; 
00086   };
00087 
00088 
00143   class Observer
00144   {
00145     public:
00147       Observer() {};
00149       virtual ~Observer() {};
00151       virtual void update(Subject *sub, long msg, Item item) =0;
00152   };
00153 
00154 }
00155 
00157 std::ostream& operator<< (std::ostream& ost, gns::Item& i);
00158 
00159 
00160 #endif

Generated on Sun Nov 5 12:05:19 2006 for Graph by  doxygen 1.4.1