Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / tests / Service_Config_Stream_DLL.cpp
blob4b65e329d849ffce525ce2f98b61b62be17cca8c
1 #include "Service_Config_Stream_DLL.h"
2 #include "ace/Service_Repository.h"
3 #include "ace/Service_Types.h"
6 int
7 Test_Task::open (void *)
9 ACE_DEBUG ((LM_DEBUG,
10 ACE_TEXT ("opening %s\n"),
11 this->name () ? this->name () : ACE_TEXT ("task")));
12 return 0;
15 int
16 Test_Task::close (u_long)
18 ACE_DEBUG ((LM_DEBUG,
19 ACE_TEXT ("closing %s\n"),
20 this->name () ? this->name () : ACE_TEXT ("task")));
21 return 0;
24 int
25 Test_Task::init (int, ACE_TCHAR *[])
27 ACE_DEBUG ((LM_DEBUG,
28 ACE_TEXT ("initializing %s\n"),
29 this->name () ? this->name () : ACE_TEXT ("task")));
31 return 0;
34 int
35 Test_Task::fini ()
37 ACE_DEBUG ((LM_DEBUG,
38 ACE_TEXT ("finalizing %s\n"),
39 this->name () ? this->name () : ACE_TEXT ("task")));
40 return 0;
43 // Factories used to control configuration.
45 ACE_FACTORY_DECLARE (Service_Config_Stream_DLL, Test_Task)
46 ACE_FACTORY_DEFINE (Service_Config_Stream_DLL, Test_Task)
48 // Dynamically linked functions used to control configuration.
50 extern "C" Service_Config_Stream_DLL_Export MT_Stream *make_stream ();
51 extern "C" Service_Config_Stream_DLL_Export MT_Module *make_da ();
52 extern "C" Service_Config_Stream_DLL_Export MT_Module *make_ea ();
53 extern "C" Service_Config_Stream_DLL_Export MT_Module *make_mr ();
54 extern "C" Service_Config_Stream_DLL_Export MT_Module *make_close ();
56 MT_Stream *
57 make_stream ()
59 return new MT_Stream;
62 MT_Module *
63 make_da ()
65 return new MT_Module (ACE_TEXT ("Device_Adapter"),
66 new Test_Task, new Test_Task);
69 MT_Module *
70 make_ea ()
72 return new MT_Module (ACE_TEXT ("Event_Analyzer"),
73 new Test_Task, new Test_Task);
76 MT_Module *
77 make_mr ()
79 return new MT_Module (ACE_TEXT ("Multicast_Router"),
80 new Test_Task, new Test_Task);
83 MT_Module *
84 make_close ()
86 return new MT_Module (ACE_TEXT ("Close_Test_Module"),
87 new Test_Task, new Test_Task);
91 // Task to verify the order and operation of the stream assembly
92 // Command line args give the stream name (to look it up) and the names
93 // of the tasks that should be there, from head to tail.
95 ACE_FACTORY_DECLARE (Service_Config_Stream_DLL, Stream_Order_Test)
96 ACE_FACTORY_DEFINE (Service_Config_Stream_DLL, Stream_Order_Test)
98 int
99 Stream_Order_Test::init (int argc, ACE_TCHAR *argv[])
101 if (argc < 1)
102 ACE_ERROR_RETURN ((LM_ERROR,
103 ACE_TEXT ("Stream_Order_Test needs at least 1 arg\n")),
104 -1);
105 const ACE_Service_Type *st = 0;
106 if (ACE_Service_Repository::instance ()->find (argv[0], &st, false) == -1)
107 ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Cannot find %s\n"), argv[0]), -1);
108 const ACE_Service_Type_Impl *st_impl = st->type ();
109 MT_Stream *str = reinterpret_cast<MT_Stream *>(st_impl->object ());
110 MT_Module *m = 0;
111 if (-1 == str->top (m))
112 ACE_ERROR_RETURN ((LM_ERROR,
113 ACE_TEXT ("Cannot get module %p\n"),
114 ACE_TEXT ("top")),
115 -1);
116 // Walk down the stream and compare module names. Note we start from the
117 // top, i.e., the last module pushed.
118 bool error = false;
119 for (int i = 1; i < argc; ++i)
121 if (m == 0)
123 ACE_ERROR ((LM_ERROR,
124 ACE_TEXT ("Ran out of modules at layer %d\n"),
125 i));
126 continue;
128 if (ACE_OS::strcmp (argv[i], m->name ()) != 0)
130 ACE_ERROR ((LM_ERROR,
131 ACE_TEXT ("Layer %d: expected module %s, found %s\n"),
133 argv[i], m->name ()));
134 error = true;
136 else
137 ACE_DEBUG ((LM_DEBUG,
138 ACE_TEXT ("Layer %d: found module %s, correct\n"),
140 m->name ()));
141 m = m->next ();
143 return error ? -1 : 0;