PersistenceUpdater.h
Go to the documentation of this file.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 #include "dds/DCPS/unique_ptr.h"
00016
00017 #include "ace/Task.h"
00018 #include "ace/Hash_Map_With_Allocator_T.h"
00019 #include "ace/Malloc_T.h"
00020 #include "ace/MMAP_Memory_Pool.h"
00021 #include "ace/Service_Object.h"
00022 #include "ace/Service_Config.h"
00023
00024 #include <string>
00025
00026 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00027
00028 namespace Update {
00029
00030
00031 class Manager;
00032
00033 class OpenDDS_InfoRepoLib_Export PersistenceUpdater : public Updater, public ACE_Task_Base {
00034 public:
00035 class IdType_ExtId {
00036 public:
00037 IdType_ExtId();
00038
00039 IdType_ExtId(IdType id);
00040
00041 IdType_ExtId(const IdType_ExtId& ext);
00042
00043 void operator= (const IdType_ExtId& ext);
00044
00045 bool operator== (const IdType_ExtId& ext) const;
00046
00047 unsigned long hash() const;
00048
00049 private:
00050 IdType id_;
00051 };
00052
00053 public:
00054 typedef ACE_Allocator_Adapter <ACE_Malloc <ACE_MMAP_MEMORY_POOL
00055 , TAO_SYNCH_MUTEX> > ALLOCATOR;
00056
00057
00058 typedef struct TopicStrt <QosSeq, ACE_CString> Topic;
00059
00060
00061 typedef struct ParticipantStrt <QosSeq> Participant;
00062
00063
00064 typedef struct ActorStrt <QosSeq, QosSeq, ACE_CString,
00065 BinSeq, ContentSubscriptionBin> RWActor;
00066
00067 typedef ACE_Hash_Map_With_Allocator<IdType_ExtId, Topic*> TopicIndex;
00068 typedef ACE_Hash_Map_With_Allocator<IdType_ExtId, Participant*> ParticipantIndex;
00069 typedef ACE_Hash_Map_With_Allocator<IdType_ExtId, RWActor*> ActorIndex;
00070
00071 public:
00072 PersistenceUpdater();
00073 virtual ~PersistenceUpdater();
00074
00075
00076 virtual int init(int argc, ACE_TCHAR *argv[]);
00077
00078
00079 virtual int fini();
00080
00081
00082 virtual int svc();
00083
00084
00085
00086
00087 virtual void requestImage();
00088
00089
00090 virtual void create(const UTopic& topic);
00091
00092
00093 virtual void create(const UParticipant& participant);
00094
00095
00096 virtual void create(const URActor& actor);
00097
00098
00099 virtual void create(const UWActor& actor);
00100
00101
00102 virtual void create(const OwnershipData& data);
00103
00104
00105 virtual void update(const IdPath& id, const DDS::DomainParticipantQos& qos);
00106
00107
00108 virtual void update(const IdPath& id, const DDS::TopicQos& qos);
00109
00110
00111 virtual void update(const IdPath& id, const DDS::DataWriterQos& qos);
00112
00113
00114 virtual void update(const IdPath& id, const DDS::PublisherQos& qos);
00115
00116
00117 virtual void update(const IdPath& id, const DDS::DataReaderQos& qos);
00118
00119
00120 virtual void update(const IdPath& id, const DDS::SubscriberQos& qos);
00121
00122
00123 virtual void update(const IdPath& id, const DDS::StringSeq& exprParams);
00124
00125
00126 virtual void destroy(const IdPath& id, ItemType type, ActorType actor);
00127
00128
00129 virtual void updateLastPartId(PartIdType partId);
00130
00131 private:
00132 int parse(int argc, ACE_TCHAR *argv[]);
00133 void storeUpdate(const ACE_Message_Block& data, BinSeq& storage);
00134
00135 ACE_TString persistence_file_;
00136 bool reset_;
00137
00138 Manager *um_;
00139
00140 OpenDDS::DCPS::unique_ptr<ALLOCATOR> allocator_;
00141
00142
00143 TopicIndex *topic_index_;
00144
00145
00146 ParticipantIndex *participant_index_;
00147
00148
00149 ActorIndex *actor_index_;
00150
00151
00152 PartIdType* last_part_id_;
00153 };
00154
00155 }
00156
00157 typedef Update::PersistenceUpdater PersistenceUpdaterSvc;
00158
00159 ACE_STATIC_SVC_DECLARE(PersistenceUpdaterSvc)
00160
00161 ACE_FACTORY_DECLARE(ACE_Local_Service, PersistenceUpdaterSvc)
00162
00163 class OpenDDS_InfoRepoLib_Export PersistenceUpdaterSvc_Loader {
00164 public:
00165 static int init();
00166 };
00167
00168 #if defined(ACE_HAS_BROKEN_STATIC_CONSTRUCTORS)
00169
00170 typedef int (*PersistenceUpdaterSvc_Loader)();
00171
00172 static UpdateManagerSvc_Loader load = &UpdateManagerSvc_Loader::init;
00173
00174 #else
00175
00176 static int load = PersistenceUpdaterSvc_Loader::init();
00177
00178 #endif
00179
00180 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00181
00182 #endif