Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / orbsvcs / LifeCycle_Service / Criteria_Evaluator.cpp
blob65c02ac3e62f80d05bbd878db895fc5f001bdd38
2 //=============================================================================
3 /**
4 * @file Criteria_Evaluator.cpp
6 * An Evaluator for the CosLifeCycle Criteria
8 * @author Michael Kircher (mk1@cs.wustl.edu)
9 */
10 //=============================================================================
13 #include "Criteria_Evaluator.h"
14 #include "ace/OS_NS_string.h"
17 Criteria_Evaluator::Criteria_Evaluator (const CosLifeCycle::Criteria &criteria)
18 : criteria_ (criteria)
22 Criteria_Evaluator::~Criteria_Evaluator ()
26 const LifeCycleService::Criteria_Evaluator::SeqNamedValuePair *
27 Criteria_Evaluator::getInitialization ()
29 const LifeCycleService::Criteria_Evaluator::SeqNamedValuePair *sequence_ptr = 0;
31 CORBA::Any_ptr any_ptr =
32 this->getCriteriaMember ("initialization");
34 if (any_ptr == 0)
35 throw LifeCycleService::Criteria_Evaluator::NotAvailable(
36 "No initialization member found.\n");
38 *any_ptr >>= sequence_ptr;
40 return sequence_ptr;
43 char *
44 Criteria_Evaluator::getFilter ()
46 const char* string;
47 CORBA::Any value;
48 CORBA::Any_ptr any_ptr = this->getCriteriaMember ("filter");
50 if (any_ptr == 0)
51 throw LifeCycleService::Criteria_Evaluator::NotAvailable(
52 "No filter member found.\n");
53 *any_ptr >>= string;
54 return CORBA::string_dup (string);
57 CORBA::Any *
58 Criteria_Evaluator::getCriteriaMember (const char *member_name)
60 if (!ACE_OS::strcmp(member_name, "initialization")
61 && !ACE_OS::strcmp(member_name, "filter")
62 && !ACE_OS::strcmp(member_name, "logical location")
63 && !ACE_OS::strcmp(member_name, "preferences"))
64 return 0;
66 for (u_int i = 0;
67 i < criteria_.length();
68 i++)
69 if (ACE_OS::strcmp (member_name,
70 criteria_[i].name) == 0)
72 CORBA::Any_ptr value_ptr;
74 // @@ We should use ACE_NEW_THROW_EX + ACE_CHECK_RETURN here.
75 ACE_NEW_RETURN (value_ptr,
76 CORBA::Any(criteria_[i].value),
77 0);
78 return value_ptr;
81 return 0;