1 //=============================================================================
3 * @file Servant_Manager.h
5 * Helper class for <ServantActivator_i> and <ServantLoactor_i>.
7 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
9 //=============================================================================
11 #ifndef SERVANT_MANAGER_H
12 #define SERVANT_MANAGER_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"
22 #include "ace/SString.h"
24 #if !defined (ACE_LACKS_PRAGMA_ONCE)
26 #endif /* ACE_LACKS_PRAGMA_ONCE */
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
38 class ServantManager_i
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
);
48 ServantManager_i (CORBA::ORB_ptr orb
);
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?
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
77 void destroy_servant (PortableServer::Servant servant
,
78 const PortableServer::ObjectId
&oid
);
82 * Parse the string to obtain the DLL name and the factory function
83 * symbol that we will used to dynamically obtain the servant
86 void parse_string (const ACE_TCHAR
*s
);
88 /// A reference to the ORB.
91 /// The name of the dll containing the servant.
94 /// The symbol which on getting invoked will give us the servant
96 ACE_TString create_symbol_
;
98 typedef ACE_Hash_Map_Manager_Ex
<PortableServer::ObjectId
,
101 ACE_Equal_To
<PortableServer::ObjectId
>,
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 */