3 #include "ace/Get_Opt.h"
4 #include "POA_Holder.h"
6 #include "Thread_Task.h"
17 ACTIVITY::instance()->builder (this);
20 Builder::~Builder(void)
25 Builder::init (int argc
, ACE_TCHAR
*argv
[])
27 ACE_Arg_Shifter
arg_shifter (argc
, argv
);
29 const ACE_TCHAR
* current_arg
= 0;
35 while (arg_shifter
.is_anything_left ())
37 if (0 != (current_arg
= arg_shifter
.get_the_parameter (ACE_TEXT("-TaskCount"))))
39 task_count_
= ACE_OS::atoi (current_arg
);
40 ACE_NEW_RETURN (task_list_
, Periodic_Task
*[task_count_
], -1);
41 ACE_OS::memset (this->task_list_
,
43 this->task_count_
* sizeof (this->task_list_
[0]));
44 arg_shifter
.consume_arg ();
46 if (0 != (current_arg
= arg_shifter
.get_the_parameter (ACE_TEXT("-JobCount"))))
48 job_count_
= ACE_OS::atoi (current_arg
);
49 ACE_NEW_RETURN (job_list_
, Job_i
*[job_count_
], -1);
50 ACE_OS::memset (this->job_list_
,
52 this->job_count_
* sizeof (this->job_list_
[0]));
53 arg_shifter
.consume_arg ();
55 if (0 != (current_arg
= arg_shifter
.get_the_parameter (ACE_TEXT("-POACount"))))
57 poa_count_
= ACE_OS::atoi (current_arg
);
58 ACE_NEW_RETURN (poa_list_
, POA_Holder
*[poa_count_
], -1);
59 ACE_OS::memset (this->poa_list_
,
61 this->poa_count_
* sizeof (this->poa_list_
[0]));
62 arg_shifter
.consume_arg ();
64 else if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-ThreadTask")) == 0)
66 if (task_count
< this->task_count_
)
68 arg_shifter
.consume_arg ();
70 Periodic_Task
*task
= 0;
72 ACE_NEW_RETURN (task
, Thread_Task (), -1);
74 if (task
->init_task (arg_shifter
) == -1)
77 task_list_
[task_count
++] = task
;
82 else if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-Job")) == 0)
84 if (job_count
< this->job_count_
)
86 arg_shifter
.consume_arg ();
90 ACE_NEW_RETURN (job
, Job_i (), -1);
92 if (job
->init (arg_shifter
) == -1)
95 this->job_list_
[job_count
++] = job
;
100 else if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-POA")) == 0)
102 if (poa_count
< this->poa_count_
)
104 arg_shifter
.consume_arg ();
106 POA_Holder
*poa_holder
= 0;
108 ACE_NEW_RETURN (poa_holder
, POA_Holder (), -1);
110 if (poa_holder
->init (arg_shifter
) == -1)
116 this->poa_list_
[poa_count
++] = poa_holder
;
123 arg_shifter
.ignore_arg ();
133 // It's only a hack for proper cleanup of this badly designed test.
134 static bool already_cleaned
= false;
140 for (count
= 0; count
< this->task_count_
; ++count
)
141 delete this->task_list_
[count
];
142 delete [] this->task_list_
;
144 delete [] this->job_list_
;
146 for (count
= 0; count
< this->poa_count_
; ++count
)
147 delete this->poa_list_
[count
];
148 delete [] this->poa_list_
;
150 already_cleaned
= true;
156 Builder::poa_list (POA_LIST
& poa_list
)
158 poa_list
= poa_list_
;
163 Builder::task_list (TASK_LIST
& task_list
)
165 task_list
= task_list_
;
170 Builder::job_list (JOB_LIST
& job_list
)
172 job_list
= job_list_
;
177 ACE_STATIC_SVC_DEFINE(Builder
,
178 ACE_TEXT ("Builder"),
180 &ACE_SVC_NAME (Builder
),
181 ACE_Service_Type::DELETE_THIS
| ACE_Service_Type::DELETE_OBJ
,
184 ACE_FACTORY_DEFINE (ACE_Local_Service
, Builder
)