1 #include "Service_Config_Stream_DLL.h"
2 #include "ace/Service_Repository.h"
3 #include "ace/Service_Types.h"
8 Test_Task::open (void *)
11 ACE_TEXT ("opening %s\n"),
12 this->name () ? this->name () : ACE_TEXT ("task")));
17 Test_Task::close (u_long
)
20 ACE_TEXT ("closing %s\n"),
21 this->name () ? this->name () : ACE_TEXT ("task")));
26 Test_Task::init (int, ACE_TCHAR
*[])
29 ACE_TEXT ("initializing %s\n"),
30 this->name () ? this->name () : ACE_TEXT ("task")));
39 ACE_TEXT ("finalizing %s\n"),
40 this->name () ? this->name () : ACE_TEXT ("task")));
44 // Factories used to control configuration.
46 ACE_FACTORY_DECLARE (Service_Config_Stream_DLL
, Test_Task
)
47 ACE_FACTORY_DEFINE (Service_Config_Stream_DLL
, Test_Task
)
49 // Dynamically linked functions used to control configuration.
51 extern "C" Service_Config_Stream_DLL_Export MT_Stream
*make_stream (void);
52 extern "C" Service_Config_Stream_DLL_Export MT_Module
*make_da (void);
53 extern "C" Service_Config_Stream_DLL_Export MT_Module
*make_ea (void);
54 extern "C" Service_Config_Stream_DLL_Export MT_Module
*make_mr (void);
55 extern "C" Service_Config_Stream_DLL_Export MT_Module
*make_close (void);
66 return new MT_Module (ACE_TEXT ("Device_Adapter"),
67 new Test_Task
, new Test_Task
);
73 return new MT_Module (ACE_TEXT ("Event_Analyzer"),
74 new Test_Task
, new Test_Task
);
80 return new MT_Module (ACE_TEXT ("Multicast_Router"),
81 new Test_Task
, new Test_Task
);
87 return new MT_Module (ACE_TEXT ("Close_Test_Module"),
88 new Test_Task
, new Test_Task
);
92 // Task to verify the order and operation of the stream assembly
93 // Command line args give the stream name (to look it up) and the names
94 // of the tasks that should be there, from head to tail.
96 ACE_FACTORY_DECLARE (Service_Config_Stream_DLL
, Stream_Order_Test
)
97 ACE_FACTORY_DEFINE (Service_Config_Stream_DLL
, Stream_Order_Test
)
100 Stream_Order_Test::init (int argc
, ACE_TCHAR
*argv
[])
103 ACE_ERROR_RETURN ((LM_ERROR
,
104 ACE_TEXT ("Stream_Order_Test needs at least 1 arg\n")),
106 const ACE_Service_Type
*st
= 0;
107 if (ACE_Service_Repository::instance ()->find (argv
[0], &st
, false) == -1)
108 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("Cannot find %s\n"), argv
[0]), -1);
109 const ACE_Service_Type_Impl
*st_impl
= st
->type ();
110 MT_Stream
*str
= reinterpret_cast<MT_Stream
*>(st_impl
->object ());
112 if (-1 == str
->top (m
))
113 ACE_ERROR_RETURN ((LM_ERROR
,
114 ACE_TEXT ("Cannot get module %p\n"),
117 // Walk down the stream and compare module names. Note we start from the
118 // top, i.e., the last module pushed.
120 for (int i
= 1; i
< argc
; ++i
)
124 ACE_ERROR ((LM_ERROR
,
125 ACE_TEXT ("Ran out of modules at layer %d\n"),
129 if (ACE_OS::strcmp (argv
[i
], m
->name ()) != 0)
131 ACE_ERROR ((LM_ERROR
,
132 ACE_TEXT ("Layer %d: expected module %s, found %s\n"),
134 argv
[i
], m
->name ()));
138 ACE_DEBUG ((LM_DEBUG
,
139 ACE_TEXT ("Layer %d: found module %s, correct\n"),
144 return error
? -1 : 0;