1 //=============================================================================
5 * @author Source code used in TAO has been modified and adapted from the codeprovided in the book
6 * @author "Advanced CORBA Programming with C++" by MichiHenning and Steve Vinoski. Copyright 1999. Addison-Wesley
8 * @author MA.Modified for TAO by Mike Moran <mm4@cs.wustl.edu>
10 //=============================================================================
25 class Controller_impl
;
27 class Thermometer_impl
: public virtual POA_CCS::Thermometer
{
30 virtual CCS::ModelType
model();
31 virtual CCS::AssetType
asset_num();
32 virtual CCS::TempType
temperature();
33 virtual CCS::LocType
location();
34 virtual void location(const char * loc
);
36 // Constructor and destructor
37 Thermometer_impl(CCS::AssetType anum
, const char * location
);
38 virtual ~Thermometer_impl();
40 static Controller_impl
* m_ctrl
; // My controller
43 const CCS::AssetType m_anum
; // My asset number
47 CCS::ModelType
get_model();
48 CCS::TempType
get_temp();
49 CCS::LocType
get_loc();
50 void set_loc(const char * new_loc
);
52 // Copy and assignment not supported
53 Thermometer_impl(const Thermometer_impl
&);
54 void operator=(const Thermometer_impl
&);
57 class Thermostat_impl
:
58 public virtual POA_CCS::Thermostat
,
59 public virtual Thermometer_impl
{
62 virtual CCS::TempType
get_nominal();
63 virtual CCS::TempType
set_nominal(CCS::TempType new_temp
);
65 // Constructor and destructor
68 const char * location
,
69 CCS::TempType nominal_temp
71 virtual ~Thermostat_impl() {}
75 CCS::TempType
get_nominal_temp();
76 CCS::TempType
set_nominal_temp(CCS::TempType new_temp
);
78 // Copy and assignment not supported
79 Thermostat_impl(const Thermostat_impl
&);
80 void operator=(const Thermostat_impl
&);
83 class Controller_impl
: public virtual POA_CCS::Controller
{
86 virtual CCS::Controller::ThermometerSeq
* list();
87 virtual void find(CCS::Controller::SearchSeq
& slist
);
88 virtual void change(const CCS::Controller::ThermostatSeq
& tlist
,
91 // Constructor and destructor
93 virtual ~Controller_impl() {}
95 // Helper functions to allow thermometers and
96 // thermostats to add themselves to the m_assets map
97 // and to remove themselves again.
98 void add_impl(CCS::AssetType anum
, Thermometer_impl
* tip
);
99 void remove_impl(CCS::AssetType anum
);
102 // Map of known servants
103 typedef map
<CCS::AssetType
, Thermometer_impl
*> AssetMap
;
106 // Copy and assignment not supported
107 Controller_impl(const Controller_impl
&);
108 void operator=(const Controller_impl
&);
110 // Function object for the find_if algorithm to search for
111 // devices by location and model string.
115 CCS::Controller::SearchCriterion sc
,
117 ) : m_sc(sc
), m_str(str
) {}
119 pair
<const CCS::AssetType
, Thermometer_impl
*> & p
) const
122 case CCS::Controller::LOCATION
:
123 return strcmp(p
.second
->location(), m_str
) == 0;
125 case CCS::Controller::MODEL
:
126 return strcmp(p
.second
->model(), m_str
) == 0;
129 assert(0); // Precondition violation
131 return 0; // Stops compiler warning
134 CCS::Controller::SearchCriterion m_sc
;