Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / POA / On_Demand_Loading / Servant_Manager.h
blob8aca1431706e2effc40713795c13451dbd8a8a84
1 //=============================================================================
2 /**
3 * @file Servant_Manager.h
5 * Helper class for <ServantActivator_i> and <ServantLoactor_i>.
7 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
8 */
9 //=============================================================================
11 #ifndef SERVANT_MANAGER_H
12 #define SERVANT_MANAGER_H
14 #include "ace/DLL.h"
15 #include "ace/Containers.h"
17 #include "tao/PortableServer/PortableServer.h"
18 #include "tao/PortableServer/Servant_Base.h"
19 #include "tao/PortableServer/Active_Object_Map.h"
21 #include "tao/ORB.h"
22 #include "ace/SString.h"
24 #if !defined (ACE_LACKS_PRAGMA_ONCE)
25 # pragma once
26 #endif /* ACE_LACKS_PRAGMA_ONCE */
28 /**
29 * @class ServantManager_i
31 * @brief This class is the helper class for the ServantActivator_i and
32 * ServantLocator_i classes.
34 * The methods provided by this class are used by the ServantActivator_i
35 * and ServantLocator_i classes. This class contains the common methods
36 * needed by them.
38 class ServantManager_i
40 public:
41 /// This typedef is used to typecast the void* obtained when finding
42 /// a symbol in the DLL.
43 typedef PortableServer::Servant
44 (*SERVANT_FACTORY) (CORBA::ORB_ptr orb,
45 PortableServer::POA_ptr poa);
47 /// Initialization.
48 ServantManager_i (CORBA::ORB_ptr orb);
50 /// Destruction.
51 ~ServantManager_i ();
53 /**
54 * Returns an ObjectId when given an DLL name and the factory method
55 * to be invoked in the DLL. The application developer can initialise the
56 * ServantActivator object by providing the dllname and the factory function.
58 PortableServer::ObjectId_var create_dll_object_id (const char *libname,
59 const char *factory_function);
61 // @@ *done*Kirthika, please explain what this function is USED for, i.e.,
62 // who calls it and why?
64 /**
65 * Obtains a servant on activation by linking and loading the
66 * appropriate DLL and creating the servant object. The <str>
67 * argument is the ObjectId that contains the servant DLL name and
68 * the factory function name. The <long> argument is an
69 * servant-specific argument needed to create the servant for this
70 * particular use-case.
72 PortableServer::Servant obtain_servant (const ACE_TCHAR *str,
73 PortableServer::POA_ptr poa);
75 /// The servant is destroyed and the DLL that was dynamically linked
76 /// is closed.
77 void destroy_servant (PortableServer::Servant servant,
78 const PortableServer::ObjectId &oid);
80 private:
81 /**
82 * Parse the string to obtain the DLL name and the factory function
83 * symbol that we will used to dynamically obtain the servant
84 * pointer.
86 void parse_string (const ACE_TCHAR *s);
88 /// A reference to the ORB.
89 CORBA::ORB_var orb_;
91 /// The name of the dll containing the servant.
92 ACE_TString dllname_;
94 /// The symbol which on getting invoked will give us the servant
95 /// pointer.
96 ACE_TString create_symbol_;
98 typedef ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId,
99 ACE_DLL *,
100 TAO_ObjectId_Hash,
101 ACE_Equal_To<PortableServer::ObjectId>,
102 ACE_Null_Mutex>
103 SERVANT_MAP;
106 * This is the hash map object. The hash map is used to provide
107 * an quick access to the dll object associated with every servant
108 * using the unique ObjectId as key.
110 SERVANT_MAP servant_map_;
112 #endif /* SERVANT_MANAGER_H */