1 #include "Service_Config_Stream_DLL.h"
2 #include "ace/Service_Repository.h"
3 #include "ace/Service_Types.h"
7 Test_Task::open (void *)
10 ACE_TEXT ("opening %s\n"),
11 this->name () ? this->name () : ACE_TEXT ("task")));
16 Test_Task::close (u_long
)
19 ACE_TEXT ("closing %s\n"),
20 this->name () ? this->name () : ACE_TEXT ("task")));
25 Test_Task::init (int, ACE_TCHAR
*[])
28 ACE_TEXT ("initializing %s\n"),
29 this->name () ? this->name () : ACE_TEXT ("task")));
38 ACE_TEXT ("finalizing %s\n"),
39 this->name () ? this->name () : ACE_TEXT ("task")));
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 ();
65 return new MT_Module (ACE_TEXT ("Device_Adapter"),
66 new Test_Task
, new Test_Task
);
72 return new MT_Module (ACE_TEXT ("Event_Analyzer"),
73 new Test_Task
, new Test_Task
);
79 return new MT_Module (ACE_TEXT ("Multicast_Router"),
80 new Test_Task
, new Test_Task
);
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
)
99 Stream_Order_Test::init (int argc
, ACE_TCHAR
*argv
[])
102 ACE_ERROR_RETURN ((LM_ERROR
,
103 ACE_TEXT ("Stream_Order_Test needs at least 1 arg\n")),
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 ());
111 if (-1 == str
->top (m
))
112 ACE_ERROR_RETURN ((LM_ERROR
,
113 ACE_TEXT ("Cannot get module %p\n"),
116 // Walk down the stream and compare module names. Note we start from the
117 // top, i.e., the last module pushed.
119 for (int i
= 1; i
< argc
; ++i
)
123 ACE_ERROR ((LM_ERROR
,
124 ACE_TEXT ("Ran out of modules at layer %d\n"),
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 ()));
137 ACE_DEBUG ((LM_DEBUG
,
138 ACE_TEXT ("Layer %d: found module %s, correct\n"),
143 return error
? -1 : 0;