2 #include "tao/CSD_Framework/CSD_Strategy_Repository.h"
5 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
7 TAO_CSD_Strategy_Repository::TAO_CSD_Strategy_Repository() :
8 strategy_list_head_ (0)
13 TAO_CSD_Strategy_Repository::~TAO_CSD_Strategy_Repository()
15 delete this->strategy_list_head_
;
19 TAO_CSD_Strategy_Repository::init(int, ACE_TCHAR
**)
21 static int initialized
= 0;
23 // Only allow initialization once.
28 this->strategy_list_head_
= 0;
32 CSD_Framework::Strategy_ptr
33 TAO_CSD_Strategy_Repository::find (const ACE_CString
& name
)
35 if (this->strategy_list_head_
!= 0)
37 Strategy_Node
*node
= this->strategy_list_head_
->find(name
);
39 return CSD_Framework::Strategy::_duplicate (node
->strategy_
.in());
42 return CSD_Framework::Strategy::_nil();
47 TAO_CSD_Strategy_Repository::add_strategy (const ACE_CString
& name
,
48 CSD_Framework::Strategy_ptr strat
)
50 Strategy_Node
*node
= 0;
51 ACE_NEW_RETURN (node
, Strategy_Node(name
,strat
),-1);
52 if (this->strategy_list_head_
== 0)
53 this->strategy_list_head_
= node
;
55 this->strategy_list_head_
->add_node(node
);
57 if (TAO_debug_level
> 3)
59 TAOLIB_DEBUG ((LM_DEBUG
,
60 ACE_TEXT("Strategy_Repository::add_strategy for %C\n"),
66 TAO_CSD_Strategy_Repository::Strategy_Node::Strategy_Node (const ACE_CString
& name
,
67 CSD_Framework::Strategy_ptr strat
)
69 strategy_(CSD_Framework::Strategy::_duplicate(strat
)),
74 TAO_CSD_Strategy_Repository::Strategy_Node::~Strategy_Node ()
81 TAO_CSD_Strategy_Repository::Strategy_Node::add_node(Strategy_Node
*node
)
84 this->next_
->add_node(node
);
89 TAO_CSD_Strategy_Repository::Strategy_Node
*
90 TAO_CSD_Strategy_Repository::Strategy_Node::find(const ACE_CString
&name
)
92 if (this->poa_name_
== name
)
95 return this->next_
->find(name
);
100 /////////////////////////////////////////////////////////////////////
102 ACE_FACTORY_DEFINE (TAO_CSD_FW
, TAO_CSD_Strategy_Repository
)
103 ACE_STATIC_SVC_DEFINE (TAO_CSD_Strategy_Repository
,
104 ACE_TEXT ("TAO_CSD_Strategy_Repository"),
106 &ACE_SVC_NAME (TAO_CSD_Strategy_Repository
),
107 ACE_Service_Type::DELETE_THIS
108 | ACE_Service_Type::DELETE_OBJ
,
110 TAO_END_VERSIONED_NAMESPACE_DECL