Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / LifeCycle_Service / Criteria_Evaluator.cpp
blobecc9e69a0f2f5751cb62b01a7310f0a79359adeb
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"
18 Criteria_Evaluator::Criteria_Evaluator (const CosLifeCycle::Criteria &criteria)
19 : criteria_ (criteria)
23 Criteria_Evaluator::~Criteria_Evaluator ()
27 const LifeCycleService::Criteria_Evaluator::SeqNamedValuePair *
28 Criteria_Evaluator::getInitialization (void)
30 const LifeCycleService::Criteria_Evaluator::SeqNamedValuePair *sequence_ptr = 0;
32 CORBA::Any_ptr any_ptr =
33 this->getCriteriaMember ("initialization");
35 if (any_ptr == 0)
36 throw LifeCycleService::Criteria_Evaluator::NotAvailable(
37 "No initialization member found.\n");
39 *any_ptr >>= sequence_ptr;
41 return sequence_ptr;
44 char *
45 Criteria_Evaluator::getFilter (void)
47 const char* string;
48 CORBA::Any value;
49 CORBA::Any_ptr any_ptr = this->getCriteriaMember ("filter");
51 if (any_ptr == 0)
52 throw LifeCycleService::Criteria_Evaluator::NotAvailable(
53 "No filter member found.\n");
54 *any_ptr >>= string;
55 return CORBA::string_dup (string);
58 CORBA::Any *
59 Criteria_Evaluator::getCriteriaMember (const char *member_name)
61 if (!ACE_OS::strcmp(member_name, "initialization")
62 && !ACE_OS::strcmp(member_name, "filter")
63 && !ACE_OS::strcmp(member_name, "logical location")
64 && !ACE_OS::strcmp(member_name, "preferences"))
65 return 0;
67 for (u_int i = 0;
68 i < criteria_.length();
69 i++)
70 if (ACE_OS::strcmp (member_name,
71 criteria_[i].name) == 0)
73 CORBA::Any_ptr value_ptr;
75 // @@ We should use ACE_NEW_THROW_EX + ACE_CHECK_RETURN here.
76 ACE_NEW_RETURN (value_ptr,
77 CORBA::Any(criteria_[i].value),
78 0);
79 return value_ptr;
82 return 0;