00001
00002
00003
00004
00005
00006
00007
00008 #ifndef PERSISTENCE_UPDATER_H
00009 #define PERSISTENCE_UPDATER_H
00010
00011 #include "inforepo_export.h"
00012 #include "Updater.h"
00013
00014 #include "dds/DdsDcpsInfoUtilsC.h"
00015
00016 #include "ace/Task.h"
00017 #include "ace/Hash_Map_With_Allocator_T.h"
00018 #include "ace/Malloc_T.h"
00019 #include "ace/MMAP_Memory_Pool.h"
00020 #include "ace/Service_Object.h"
00021 #include "ace/Service_Config.h"
00022
00023 #include <string>
00024
00025 namespace Update {
00026
00027
00028 class Manager;
00029
00030 class OpenDDS_InfoRepoLib_Export PersistenceUpdater : public Updater, public ACE_Task_Base {
00031 public:
00032 class IdType_ExtId {
00033 public:
00034 IdType_ExtId();
00035
00036 IdType_ExtId(IdType id);
00037
00038 IdType_ExtId(const IdType_ExtId& ext);
00039
00040 void operator= (const IdType_ExtId& ext);
00041
00042 bool operator== (const IdType_ExtId& ext) const;
00043
00044 unsigned long hash() const;
00045
00046 private:
00047 IdType id_;
00048 };
00049
00050 public:
00051 typedef ACE_Allocator_Adapter <ACE_Malloc <ACE_MMAP_MEMORY_POOL
00052 , TAO_SYNCH_MUTEX> > ALLOCATOR;
00053
00054
00055 typedef struct TopicStrt <QosSeq, ACE_CString> Topic;
00056 typedef struct ParticipantStrt <QosSeq> Participant;
00057 typedef struct ActorStrt <QosSeq, QosSeq, ACE_CString,
00058 BinSeq, ContentSubscriptionBin> RWActor;
00059
00060 typedef ACE_Hash_Map_With_Allocator<IdType_ExtId, Topic*> TopicIndex;
00061 typedef ACE_Hash_Map_With_Allocator<IdType_ExtId, Participant*> ParticipantIndex;
00062 typedef ACE_Hash_Map_With_Allocator<IdType_ExtId, RWActor*> ActorIndex;
00063
00064 public:
00065 PersistenceUpdater();
00066 virtual ~PersistenceUpdater();
00067
00068
00069 virtual int init(int argc, ACE_TCHAR *argv[]);
00070
00071
00072 virtual int fini();
00073 virtual int svc();
00074
00075
00076
00077
00078 virtual void requestImage();
00079
00080
00081 virtual void create(const UTopic& topic);
00082 virtual void create(const UParticipant& participant);
00083 virtual void create(const URActor& actor);
00084 virtual void create(const UWActor& actor);
00085 virtual void create(const OwnershipData& data);
00086
00087
00088 virtual void update(const IdPath& id, const DDS::DomainParticipantQos& qos);
00089 virtual void update(const IdPath& id, const DDS::TopicQos& qos);
00090 virtual void update(const IdPath& id, const DDS::DataWriterQos& qos);
00091 virtual void update(const IdPath& id, const DDS::PublisherQos& qos);
00092 virtual void update(const IdPath& id, const DDS::DataReaderQos& qos);
00093 virtual void update(const IdPath& id, const DDS::SubscriberQos& qos);
00094 virtual void update(const IdPath& id, const DDS::StringSeq& exprParams);
00095
00096
00097 virtual void destroy(const IdPath& id, ItemType type, ActorType actor);
00098
00099 private:
00100 int parse(int argc, ACE_TCHAR *argv[]);
00101 void storeUpdate(const ACE_Message_Block& data, BinSeq& storage);
00102
00103 ACE_TString persistence_file_;
00104 bool reset_;
00105
00106 Manager *um_;
00107
00108 ALLOCATOR *allocator_;
00109
00110 TopicIndex *topic_index_;
00111 ParticipantIndex *participant_index_;
00112 ActorIndex *actor_index_;
00113 };
00114
00115 }
00116
00117 typedef Update::PersistenceUpdater PersistenceUpdaterSvc;
00118
00119 ACE_STATIC_SVC_DECLARE(PersistenceUpdaterSvc)
00120
00121 ACE_FACTORY_DECLARE(ACE_Local_Service, PersistenceUpdaterSvc)
00122
00123 class OpenDDS_InfoRepoLib_Export PersistenceUpdaterSvc_Loader {
00124 public:
00125 static int init();
00126 };
00127
00128 #if defined(ACE_HAS_BROKEN_STATIC_CONSTRUCTORS)
00129
00130 typedef int (*PersistenceUpdaterSvc_Loader)();
00131
00132 static UpdateManagerSvc_Loader load = &UpdateManagerSvc_Loader::init;
00133
00134 #else
00135
00136 static int load = PersistenceUpdaterSvc_Loader::init();
00137
00138 #endif
00139
00140 #endif