graph_analysis
TransactionObserver.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_TRANSACTION_OBSERVER_HPP__
2 #define GRAPH_ANALYSIS_TRANSACTION_OBSERVER_HPP__
3 
4 #include "BaseGraphObserver.hpp"
5 #include <boost/pointer_cast.hpp>
6 #include <boost/shared_ptr.hpp>
7 
8 namespace graph_analysis
9 {
10 
12 {
16 
17  ObserverEvent();
18  ObserverEvent( GraphElement::Ptr element, GraphId origin, EventType event );
19 
24  bool match( const ObserverEvent& other ) const;
25 };
26 
57 {
58 public:
59  typedef shared_ptr<TransactionObserver> Ptr;
60 
61  static TransactionObserver::Ptr getInstance( BaseGraphObserver::Ptr &observer );
62 
66  explicit TransactionObserver( BaseGraphObserver::Ptr &observer );
67  virtual ~TransactionObserver();
68 
69  virtual void notify(const Vertex::Ptr& vertex, const EventType& event,
70  const GraphId& origin);
71  virtual void notify(const Edge::Ptr& edge, const EventType& event,
72  const GraphId& origin);
73  virtual void notify( const TransactionType& event, const GraphId& origin );
74 
77  bool inTransaction();
78 
79 private:
80  void addEvent( ObserverEvent event );
81  void emitEvent( ObserverEvent event );
82 
83  std::vector<ObserverEvent> mEvents;
84  BaseGraphObserver::Ptr mpObserver;
85  int mTransactionLevel;
86 
87 };
88 }
89 
90 #endif
shared_ptr< BaseGraphObserver > Ptr
Definition: BaseGraphObserver.hpp:39
A transaction observer.
Definition: TransactionObserver.hpp:56
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
Definition: TransactionObserver.hpp:11
TransactionType
Transaction events These events are triggers for the notification system to allow transactions to be ...
Definition: BaseGraphObserver.hpp:27
ObserverEvent()
Definition: TransactionObserver.cpp:5
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
GraphElement::Ptr element
Definition: TransactionObserver.hpp:13
shared_ptr< TransactionObserver > Ptr
Definition: TransactionObserver.hpp:59
shared_ptr< GraphElement > Ptr
Definition: GraphElement.hpp:46
EventType event
Definition: TransactionObserver.hpp:15
Virtual interface class for observing a base graph.
Definition: BaseGraphObserver.hpp:36
bool match(const ObserverEvent &other) const
return true if a match is found between two events
Definition: TransactionObserver.cpp:12
GraphId origin
Definition: TransactionObserver.hpp:14
EventType
Types of events for the observer. Example: notify(vertex, EVENT_TYPE_ADDED, ...) is called whenever a...
Definition: BaseGraphObserver.hpp:15
uint32_t GraphId
Definition: GraphElement.hpp:22