Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / Locator_Repository.h
blob0785ea4ccf73015a86de573dd531f5b31eb82723
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Locator_Repository.h
7 * This class implements the Repository for the Implementation Repository.
9 * @author Darrell Brunsch <brunsch@cs.wustl.edu>
10 * @author Priyanka Gontla <gontla_p@ociweb.com>
12 //=============================================================================
14 #ifndef LOCATOR_REPOSITORY_H
15 #define LOCATOR_REPOSITORY_H
17 #include "Server_Info.h"
18 #include "Activator_Info.h"
19 #include "Locator_Options.h"
20 #include "ImR_LocatorC.h"
22 #include "tao/IORTable/IORTable.h"
23 #include "tao/PortableServer/PortableServer.h"
24 #include "orbsvcs/IOR_Multicast.h"
26 #include "ace/Hash_Map_Manager.h"
27 #include "ace/Configuration.h"
28 #include <memory>
29 #include "ace/Reactor.h"
31 #if !defined (ACE_LACKS_PRAGMA_ONCE)
32 # pragma once
33 #endif /* ACE_LACKS_PRAGMA_ONCE */
35 class ImR_Locator_i;
37 /**
38 * @class Locator_Repository
40 * @brief Database containing all ImR persistent information.
43 class Locator_Repository
45 public:
46 typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
47 Server_Info_Ptr,
48 ACE_Hash<ACE_CString>,
49 ACE_Equal_To<ACE_CString>,
50 ACE_Null_Mutex> SIMap;
52 typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
53 Activator_Info_Ptr,
54 ACE_Hash<ACE_CString>,
55 ACE_Equal_To<ACE_CString>,
56 ACE_Null_Mutex> AIMap;
58 Locator_Repository(const Options& opts, CORBA::ORB_ptr orb);
60 virtual ~Locator_Repository();
62 virtual void shutdown ();
64 int unregister_if_address_reused (const ACE_CString& fqname,
65 const char* partial_ior,
66 ImR_Locator_i* imr_locator);
68 /// Add a new server to the Repository
69 int add_server (const ACE_CString& fqname,
70 const ImplementationRepository::StartupOptions &options);
72 int add_server (const ACE_CString& fqname,
73 const ACE_CString& partial_ior,
74 const ACE_CString& ior,
75 ImplementationRepository::ServerObject_ptr svrobj);
76 int add_server_i (Server_Info *si);
78 /// create new records for POAs that share a server instance. This is
79 /// a two step process, first the base POA must be registered then a
80 /// list of peers may be added.
81 int link_peers (Server_Info_Ptr base,
82 const CORBA::StringSeq peers);
84 /// Add a new activator to the Repository
85 int add_activator (const ACE_CString& name,
86 const CORBA::Long token,
87 const ACE_CString& ior = ACE_CString(""),
88 ImplementationRepository::Activator_ptr act =
89 ImplementationRepository::Activator::_nil()
92 /// Update the associated information.
93 int update_server (const Server_Info_Ptr& info);
94 /// Update the associated information.
95 int update_activator (const Activator_Info_Ptr& info);
97 /// Update the peer's access state
98 virtual void notify_remote_access (const char *id,
99 ImplementationRepository::AAM_Status state);
101 /// Returns information related to startup.
102 Server_Info_Ptr get_active_server (const ACE_CString& name, int pid = 0);
104 /// Returns information related to startup.
105 Activator_Info_Ptr get_activator (const ACE_CString& name);
107 bool has_activator(const ACE_CString& name);
109 /// Removes the server from the Repository.
110 int remove_server (const ACE_CString& name,
111 ImR_Locator_i* imr_locator);
112 /// Removes the activator from the Repository.
113 int remove_activator (const ACE_CString& name);
115 /// Returns the internal hash map containing the server information.
116 SIMap& servers();
117 const SIMap& servers() const;
118 /// Returns the internal hash map containing the activator information.
119 AIMap& activators();
120 const AIMap& activators() const;
122 /// Indicate the persistence mode for the repository
123 virtual const ACE_TCHAR* repo_mode() const = 0;
125 /// Convert to lower case
126 static ACE_CString lcase (const ACE_CString& s);
128 /// Initialize the repo
129 int init(PortableServer::POA_ptr root_poa,
130 PortableServer::POA_ptr imr_poa,
131 const char* this_ior);
133 /// Indicate if multicast should be used
134 bool multicast() const;
136 /// report the ImR Locator's IOR
137 virtual int report_ior (PortableServer::POA_ptr imr_poa);
139 protected:
140 /// perform repo mode specific initialization
141 virtual int init_repo (PortableServer::POA_ptr imr_poa) = 0;
143 /// perform sync of repo with backing store
144 /// defaults to no-op, only shared backing stores
145 /// need to sync
146 virtual int sync_load ();
148 /// perform server persistent update
149 virtual int persistent_update (const Server_Info_Ptr& info, bool add) = 0;
151 /// perform activator persistent update
152 virtual int persistent_update (const Activator_Info_Ptr& info, bool add) = 0;
154 /// perform persistent remove
155 virtual int persistent_remove (const ACE_CString& name, bool activator) = 0;
157 /// recover the ImR Locator's IOR from the persisted file
158 virtual int recover_ior ();
160 int setup_multicast (ACE_Reactor* reactor, const char* imr_ior);
161 void teardown_multicast ();
163 bool registered () const;
165 const Options& opts_;
166 TAO_IOR_Multicast ior_multicast_;
167 const CORBA::ORB_var orb_;
168 CORBA::String_var imr_ior_;
170 private:
171 Server_Info_Ptr find_by_poa (const ACE_CString &name);
173 bool registered_;
174 /// The in-memory list of the server information.
175 SIMap server_infos_;
176 /// The in-memory list of the activator information.
177 AIMap activator_infos_;
181 * @class No_Backing_Store
183 * @brief Null implementation, used when persistence isn't desired
186 class No_Backing_Store : public Locator_Repository
188 public:
189 No_Backing_Store(const Options& opts,
190 CORBA::ORB_ptr orb);
192 virtual ~No_Backing_Store();
194 /// indicate the persistence mode for the repository
195 virtual const ACE_TCHAR* repo_mode() const;
197 private:
198 /// perform repo mode specific initialization (no-op)
199 virtual int init_repo(PortableServer::POA_ptr imr_poa);
201 /// perform server persistent update (no-op)
202 virtual int persistent_update(const Server_Info_Ptr& info, bool add);
204 /// perform activator persistent update (no-op)
205 virtual int persistent_update(const Activator_Info_Ptr& info, bool add);
207 /// perform persistent remove (no-op)
208 virtual int persistent_remove(const ACE_CString& name, bool activator);
211 #endif /* LOCATOR_REPOSITORY_H */