1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
// $Id$
#include "Command_Builder.h"
#include "ace/Arg_Shifter.h"
#include "ace/Get_Opt.h"
#include "Command.h"
#include "Command_Factory.h"
#include "Name.h"
TAO_Notify_Tests_Command_Builder::TAO_Notify_Tests_Command_Builder (void)
:start_command_ (0)
{
}
TAO_Notify_Tests_Command_Builder::~TAO_Notify_Tests_Command_Builder ()
{
}
int
TAO_Notify_Tests_Command_Builder::init (int argc, ACE_TCHAR *argv[])
{
ACE_Arg_Shifter arg_shifter (argc, argv);
ACE_CString current_arg;
TAO_Notify_Tests_Command_Factory* factory = 0;
if (arg_shifter.is_anything_left ())
{
current_arg = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
arg_shifter.consume_arg ();
// obtain the factory
if (this->factory_map_.find (current_arg, factory) == -1)
ACE_DEBUG ((LM_DEBUG, "NS Command: %s not recognized!\n", current_arg.c_str ()));
else
{
TAO_Notify_Tests_Command* new_command = factory->create ();
new_command->init (arg_shifter);
if (this->start_command_ == 0)
{
this->start_command_ = new_command;
this->last_command_ = new_command;
}
else
{
// linked list
this->last_command_->next (new_command);
this->last_command_ = new_command;
}
}
}
return 0;
}
int
TAO_Notify_Tests_Command_Builder::fini (void)
{
return 0;
}
void
TAO_Notify_Tests_Command_Builder::_register (ACE_CString command_factory_name, TAO_Notify_Tests_Command_Factory* command_factory)
{
if (this->factory_map_.bind (command_factory_name, command_factory) == -1)
ACE_DEBUG ((LM_DEBUG, "Failed to register command factory for %s\n", command_factory_name.c_str ()));
else
ACE_DEBUG ((LM_DEBUG, "Registered command factory for %s\n", command_factory_name.c_str ()));
}
void
TAO_Notify_Tests_Command_Builder::execute (void)
{
if (this->start_command_)
this->start_command_->execute ();
}
ACE_STATIC_SVC_DEFINE(TAO_Notify_Tests_Command_Builder,
TAO_Notify_Tests_Name::command_builder,
ACE_SVC_OBJ_T,
&ACE_SVC_NAME (TAO_Notify_Tests_Command_Builder),
ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
0)
ACE_FACTORY_DEFINE (TAO_NOTIFY_TEST, TAO_Notify_Tests_Command_Builder)
ACE_STATIC_SVC_REQUIRE (TAO_Notify_Tests_Command_Builder)
|