IBR-DTNSuite  0.8
daemon/src/core/Event.h
Go to the documentation of this file.
00001 /*
00002  * Event.h
00003  *
00004  *  Created on: 05.03.2009
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef EVENT_H_
00009 #define EVENT_H_
00010 
00011 #include "core/EventReceiver.h"
00012 #include <ibrcommon/thread/Mutex.h>
00013 #include <ibrcommon/thread/Conditional.h>
00014 
00015 namespace dtn
00016 {
00017         namespace core
00018         {
00019                 class Event
00020                 {
00021                 public:
00022                         virtual ~Event() = 0;
00023                         virtual const std::string getName() const = 0;
00024 
00025                         virtual std::string toString() const = 0;
00026 
00027                         void set_ref_count(size_t c);
00028                         bool decrement_ref_count();
00029 
00030                         const int prio;
00031 
00032                 protected:
00033                         Event(int prio = 0);
00034                         static void raiseEvent(Event *evt, bool block_until_processed = false);
00035 
00036                 private:
00037                         ibrcommon::Conditional _ref_count_mutex;
00038                         size_t _ref_count;
00039 
00040                         // mark the event for auto deletion if the last reference is gone
00041                         bool _auto_delete;
00042 
00043                         // mark the event as processed
00044                         bool _processed;
00045                 };
00046         }
00047 }
00048 
00049 #endif /* EVENT_H_ */