=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / tests / ORB_Local_Config / Service_Dependency / Service_Config_DLL.cpp
blob77c4ceb3290ba28bedf46bbef79a645b6930661f
1 // -*- C++ -*-
2 #include "Service_Config_DLL.h"
3 #include "ace/Service_Config.h"
4 #include "ace/OS_NS_stdio.h"
5 #include "ace/OS_NS_string.h"
7 static ACE_THR_FUNC_RETURN
8 invoke_service_config (void *arg)
10 const ACE_TCHAR *directive = reinterpret_cast<const ACE_TCHAR *> (arg);
13 // Process a Service Configurator directive in the current thread.
14 if (ACE_Service_Config::process_directive (directive) != 0)
15 ACE_ERROR ((LM_ERROR,
16 ACE_TEXT ("(%P|%t) Service_Config_DLL::svc() - ")
17 ACE_TEXT ("process_directive() failed for:\n")
18 ACE_TEXT ("\"%s\"\n"),
19 directive));
21 return 0;
24 Service_Config_DLL::Service_Config_DLL ()
26 ACE_OS::memset (this->directive_[0], 0, BUFSIZ * sizeof (ACE_TCHAR));
27 ACE_OS::memset (this->directive_[1], 0, BUFSIZ * sizeof (ACE_TCHAR));
30 int
31 Service_Config_DLL::init (int argc, ACE_TCHAR *argv[])
33 if (argc == 2)
35 ACE_DEBUG ((LM_DEBUG,
36 ACE_TEXT ("Loading Test_Object_%s and Test_Object_%s\n"),
37 argv[0],
38 argv[1]));
40 ACE_OS::sprintf (this->directive_[0],
41 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
42 ACE_TEXT ("dynamic Test_Object_%s Service_Object * Service_Config_Dependent_DLL:_make_Service_Config_DLL() \"Test_Object_%s\""),
43 #else
44 ACE_TEXT ("<?xml version='1.0'?> <dynamic id='Test_Object_%s' type='service_object'> <initializer init='_make_Service_Config_DLL' path='Service_Config_Dependent_DLL' params='Test_Object_%s'/> </dynamic>"),
45 #endif
46 argv[0],
47 argv[0]);
49 ACE_OS::sprintf (this->directive_[1],
50 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
51 ACE_TEXT ("dynamic Test_Object_%s Service_Object * Service_Config_Dependent_DLL:_make_Service_Config_DLL() \"Test_Object_%s\""),
52 #else
53 ACE_TEXT ("<?xml version='1.0'?> <dynamic id='Test_Object_%s' type='service_object'> <initializer init='_make_Service_Config_DLL' path='Service_Config_Dependent_DLL' params='Test_Object_%s'/> </dynamic>"),
54 #endif
56 argv[1],
57 argv[1]);
59 if (ACE_Service_Config::process_directive (this->directive_[0]) != 0)
60 ACE_ERROR ((LM_ERROR,
61 ACE_TEXT ("(%P|%t) Service_Config_DLL::init() - ")
62 ACE_TEXT ("process_directive() failed for:\n")
63 ACE_TEXT ("\"%s\"\n"),
64 this->directive_[0]));
66 #if defined (ACE_HAS_THREADS)
68 // Become an Active Object if more than one argument passed.
69 // Two arguments indicate two "test objects" to be dynamically
70 // loaded.
71 return this->activate ();
73 #endif /* ACE_HAS_THREADS */
76 else if (argc == 1)
78 ACE_DEBUG ((LM_DEBUG,
79 ACE_TEXT ("Service_Config_DLL::init () - %s\n"),
80 argv[0]));
82 else
84 ACE_ERROR_RETURN ((LM_ERROR,
85 ACE_TEXT ("(%P|%t) Incorrect number of arguments ")
86 ACE_TEXT ("(%d) passed to Service_Config_DLL::init ()"),
87 argc),
88 -1);
91 return 0;
94 int
95 Service_Config_DLL::fini ()
97 return 0;
101 Service_Config_DLL::svc ()
103 if (ACE_Thread_Manager::instance ()->spawn (invoke_service_config,
104 this->directive_[1]) == -1)
105 ACE_ERROR_RETURN ((LM_ERROR,
106 ACE_TEXT ("(%P|%t) Unable to spawn thread to ")
107 ACE_TEXT ("invoke Service Configurator.\n")),
108 -1);
110 return 0;
113 // The same class (Service_Config_DLL) is used to implement each of the
114 // Service Objects whose service descriptors are defined below.
116 // -----------------------------------------------------------------
118 ACE_STATIC_SVC_DEFINE (Test_Object_1,
119 ACE_TEXT ("Test_Object_1"),
120 ACE_SVC_OBJ_T,
121 &ACE_SVC_NAME (Service_Config_DLL),
122 ACE_Service_Type::DELETE_THIS
123 | ACE_Service_Type::DELETE_OBJ,
126 // -----------------------------------------------------------------
128 ACE_STATIC_SVC_DEFINE (Test_Object_2,
129 ACE_TEXT ("Test_Object_2"),
130 ACE_SVC_OBJ_T,
131 &ACE_SVC_NAME (Service_Config_DLL),
132 ACE_Service_Type::DELETE_THIS
133 | ACE_Service_Type::DELETE_OBJ,
136 // -----------------------------------------------------------------
138 ACE_STATIC_SVC_DEFINE (Test_Object_3,
139 ACE_TEXT ("Test_Object_3"),
140 ACE_SVC_OBJ_T,
141 &ACE_SVC_NAME (Service_Config_DLL),
142 ACE_Service_Type::DELETE_THIS
143 | ACE_Service_Type::DELETE_OBJ,
146 // -----------------------------------------------------------------
148 ACE_STATIC_SVC_DEFINE (Test_Object_4,
149 ACE_TEXT ("Test_Object_4"),
150 ACE_SVC_OBJ_T,
151 &ACE_SVC_NAME (Service_Config_DLL),
152 ACE_Service_Type::DELETE_THIS
153 | ACE_Service_Type::DELETE_OBJ,
156 // -----------------------------------------------------------------
158 ACE_STATIC_SVC_DEFINE (Test_Object_5,
159 ACE_TEXT ("Test_Object_5"),
160 ACE_SVC_OBJ_T,
161 &ACE_SVC_NAME (Service_Config_DLL),
162 ACE_Service_Type::DELETE_THIS
163 | ACE_Service_Type::DELETE_OBJ,
166 // -----------------------------------------------------------------
168 ACE_STATIC_SVC_DEFINE (Test_Object_6,
169 ACE_TEXT ("Test_Object_6"),
170 ACE_SVC_OBJ_T,
171 &ACE_SVC_NAME (Service_Config_DLL),
172 ACE_Service_Type::DELETE_THIS
173 | ACE_Service_Type::DELETE_OBJ,
176 // -----------------------------------------------------------------
178 ACE_STATIC_SVC_DEFINE (Final_Object,
179 ACE_TEXT ("Final_Object"),
180 ACE_SVC_OBJ_T,
181 &ACE_SVC_NAME (Service_Config_DLL),
182 ACE_Service_Type::DELETE_THIS
183 | ACE_Service_Type::DELETE_OBJ,
186 // -----------------------------------------------------------------
188 // Same factory is used for all service descriptors defined above.
189 ACE_FACTORY_DEFINE (Service_Config_DLL, Service_Config_DLL)