PersistenceUpdater.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
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 // Forward declaration
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   /// Persisted topic data structure
00058   typedef struct TopicStrt <QosSeq, ACE_CString> Topic;
00059 
00060   /// Persisted participant data structure
00061   typedef struct ParticipantStrt <QosSeq> Participant;
00062 
00063   /// Persisted actor data structure
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   /// Service object initialization
00076   virtual int init(int argc, ACE_TCHAR *argv[]);
00077 
00078   /// ACE_Task_Base finish method
00079   virtual int fini();
00080 
00081   /// ACE_Task_Base start method
00082   virtual int svc();
00083 
00084   /// Request an image refresh to be sent upstream.
00085   /// This is currently done synchronously.
00086   /// TBD: Move to an asynchronous model
00087   virtual void requestImage();
00088 
00089   /// Add topic to be persisted.
00090   virtual void create(const UTopic& topic);
00091 
00092   /// Add participant to be persisted.
00093   virtual void create(const UParticipant& participant);
00094 
00095   /// Add DataReader to be persisted.
00096   virtual void create(const URActor& actor);
00097 
00098   /// Add DataWriter to be persisted.
00099   virtual void create(const UWActor& actor);
00100 
00101   /// Add ownership data to be persisted.
00102   virtual void create(const OwnershipData& data);
00103 
00104   /// Persist updated Qos parameters for a Participant.
00105   virtual void update(const IdPath& id, const DDS::DomainParticipantQos& qos);
00106 
00107   /// Persist updated Qos parameters for a Topic.
00108   virtual void update(const IdPath& id, const DDS::TopicQos&             qos);
00109 
00110   /// Persist updated Qos parameters for a DataWriter.
00111   virtual void update(const IdPath& id, const DDS::DataWriterQos&        qos);
00112 
00113   /// Persist updated Qos parameters for a Publisher.
00114   virtual void update(const IdPath& id, const DDS::PublisherQos&         qos);
00115 
00116   /// Persist updated Qos parameters for a DataReader.
00117   virtual void update(const IdPath& id, const DDS::DataReaderQos&        qos);
00118 
00119   /// Persist updated Qos parameters for a Subscriber.
00120   virtual void update(const IdPath& id, const DDS::SubscriberQos&        qos);
00121 
00122   /// Persist updated subscription exprParams.
00123   virtual void update(const IdPath& id, const DDS::StringSeq&     exprParams);
00124 
00125   /// Remove an entity (but not children) from persistence.
00126   virtual void destroy(const IdPath& id, ItemType type, ActorType actor);
00127 
00128   /// Update Last Participant Id for repo
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   /// Persisted Topics
00143   TopicIndex *topic_index_;
00144 
00145   /// Persisted Participants
00146   ParticipantIndex *participant_index_;
00147 
00148   /// Persisted Readers and Writers
00149   ActorIndex *actor_index_;
00150 
00151   /// What the last participant id is/was
00152   PartIdType* last_part_id_;
00153 };
00154 
00155 } // End of namespace Update
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 /* ACE_HAS_BROKEN_STATIC_CONSTRUCTORS */
00179 
00180 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00181 
00182 #endif /* PERSISTENCE_UPDATER_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1