diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2000-07-15 02:39:40 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2000-07-15 02:39:40 +0000 |
commit | f466ed7c5e171ee417f0a24bdd509653ae088706 (patch) | |
tree | 0c7a86d6d7498e00534a35a57409bbc63c6f916b | |
parent | 40bf5df0519a3e637c02e02a1bda110212f0c50f (diff) | |
download | ATCD-f466ed7c5e171ee417f0a24bdd509653ae088706.tar.gz |
ChangeLogTag:Fri Jul 14 19:31:39 2000 Eric Ding <qnd1@cs.wustl.edu>
-rw-r--r-- | TAO/ChangeLogs/ChangeLog-02a | 8 | ||||
-rw-r--r-- | TAO/examples/Advanced/ch_18/Makefile | 7 | ||||
-rw-r--r-- | TAO/examples/Advanced/ch_18/client.cpp | 8 | ||||
-rw-r--r-- | TAO/examples/Advanced/ch_18/server.cpp | 579 | ||||
-rw-r--r-- | TAO/examples/Advanced/ch_18/server.h | 2 |
5 files changed, 300 insertions, 304 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index b1505b7fe4e..3f153097178 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,9 @@ +Fri Jul 14 21:37:16 2000 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * examples/Advanced/ch_18: Added a number of minor fixes so that + this code compiles on Linux with GCC 2.95.2. Thanks to Craig + Rodrigues <crodrigu@bbn.com> for contributing this. + Fri Jul 14 12:05:13 2000 Ossama Othman <ossama@uci.edu> * docs/releasenotes/index.html: @@ -1865,7 +1871,7 @@ Tue Jun 20 11:50:50 2000 Balachandran Natarajan <bala@cs.wustl.edu> * tao/IOP.pidl: Added some definitions from FT_CORBA spec that have been defined in the IOP module. -Tue Jun 20 00:25:51 2000 Craig Rodrigues <crodrigu@bbn.com> +Tue Jun 20 00:25:51 2000 Craig Rodrigues <crodrigu@bbn.com>h * orbsvcs/tests/AVStreams/mpeg/source/client/Makefile * orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Makefile diff --git a/TAO/examples/Advanced/ch_18/Makefile b/TAO/examples/Advanced/ch_18/Makefile index 60ad2943f87..25a16ac49a6 100644 --- a/TAO/examples/Advanced/ch_18/Makefile +++ b/TAO/examples/Advanced/ch_18/Makefile @@ -72,15 +72,10 @@ CPPFLAGS += -I$(TAO_ROOT)/orbsvcs .PRECIOUS: CCSS.cpp CCSS.i CCSS.h .PRECIOUS: CCSS_T.cpp CCSS_T.i CCSS_T.h -override TAO_IDLFLAGS += -hc .hh -hs S.hh -hT S_T.hh \ - -cs C.cc -ci C.i \ - -ss S.cc -sT S_T.cc +override TAO_IDLFLAGS += -So CCFLAGS += -fimplicit-templates -frtti -O0 $(IDL_SRC): CCS.idl - $(TAO_ROOT)/TAO_IDL/tao_idl CCS.idl -hc .h -hs S.h -hT S_T.h \ - -cs C.cpp \ - -ss S.cpp -sT S_T.cpp server: $(addprefix $(VDIR),$(SIMPLE_SVR_OBJS)) $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK) diff --git a/TAO/examples/Advanced/ch_18/client.cpp b/TAO/examples/Advanced/ch_18/client.cpp index bdf1db1f6b6..a3976e1b387 100644 --- a/TAO/examples/Advanced/ch_18/client.cpp +++ b/TAO/examples/Advanced/ch_18/client.cpp @@ -17,9 +17,7 @@ // // ============================================================================ - - -#include "CCS.h" // ORB-specific +#include "CCSC.h" // ORB-specific #include <orbsvcs/CosNamingC.h> // #include <iostream.h> // #include <fstream.h> @@ -104,7 +102,7 @@ resolve_name( // Generic ostream inserter for exceptions. Inserts the exception // name, if available, and the repository ID otherwise. -//#if 0 // This inserter may or may not be needed for your ORB. +#if 0 // This inserter is not be needed for TAO. static ostream & operator<<(ostream & os, const CORBA::Exception & e) @@ -121,7 +119,7 @@ operator<<(ostream & os, const CORBA::Exception & e) return os; } -//#endif +#endif //---------------------------------------------------------------- diff --git a/TAO/examples/Advanced/ch_18/server.cpp b/TAO/examples/Advanced/ch_18/server.cpp index 31d900de995..ee0be193ec3 100644 --- a/TAO/examples/Advanced/ch_18/server.cpp +++ b/TAO/examples/Advanced/ch_18/server.cpp @@ -34,37 +34,37 @@ const char * Controller_oid = "Controller"; template<class T> typename T::_ptr_type -resolve_init(CORBA::ORB_ptr orb, const char * id) -{ - CORBA::Object_var obj; - try { - obj = orb->resolve_initial_references(id); - } - catch (const CORBA::ORB::InvalidName & e) { - throw; - } - catch (const CORBA::Exception & e) { - cerr << "Cannot get initial reference for " - << id << ": " << e << endl; - throw 0; - } - assert(!CORBA::is_nil(obj.in())); - - typename T::_var_type ref; - try { - ref = T::_narrow(obj.in()); - } - catch (const CORBA::Exception & e) { - cerr << "Cannot narrow reference for " - << id << ": " << e << endl; - throw 0; - } - if (CORBA::is_nil(ref.in())) { - cerr << "Incorrect type of reference for " - << id << endl; - throw 0; - } - return ref._retn(); +resolve_init (CORBA::ORB_ptr orb, const char * id) +{ + CORBA::Object_var obj; + try { + obj = orb->resolve_initial_references (id); + } + catch (const CORBA::ORB::InvalidName & e) { + throw; + } + catch (const CORBA::Exception & e) { + cerr << "Cannot get initial reference for " + << id << ": " << e << endl; + throw 0; + } + assert (!CORBA::is_nil (obj.in ())); + + typename T::_var_type ref; + try { + ref = T::_narrow (obj.in ()); + } + catch (const CORBA::Exception & e) { + cerr << "Cannot narrow reference for " + << id << ": " << e << endl; + throw 0; + } + if (CORBA::is_nil (ref.in ())) { + cerr << "Incorrect type of reference for " + << id << endl; + throw 0; + } + return ref._retn (); } //---------------------------------------------------------------- @@ -72,52 +72,52 @@ resolve_init(CORBA::ORB_ptr orb, const char * id) // Generic ostream inserter for exceptions. Inserts the exception // name, if available, and the repository ID otherwise. -//#if 0 // This inserter may or may not be needed for your ORB. +#if 0 // This inserter is not needed for TAO. static ostream & -operator<<(ostream & os, const CORBA::Exception & e) +operator<< (ostream & os, const CORBA::Exception & e) { - CORBA::Any tmp; - tmp <<= e; + CORBA::Any tmp; + tmp <<= e; - CORBA::TypeCode_var tc = tmp.type(); - const char * p = tc->name(); - if (*p != '\0') - os << p; - else - os << tc->id(); - return os; + CORBA::TypeCode_var tc = tmp.type (); + const char * p = tc->name (); + if (*p != '\0') + os << p; + else + os << tc->id (); + return os; } -//#endif +#endif //---------------------------------------------------------------- // Helper function to create object references. static CCS::Thermometer_ptr -make_dref(PortableServer::POA_ptr poa, CCS::AssetType anum) -{ - // Convert asset number to OID. - ostrstream ostr; - ostr << anum << ends; - char * anum_str = ostr.str(); - PortableServer::ObjectId_var oid - = PortableServer::string_to_ObjectId(anum_str); - delete[] anum_str; - - // Look at the model via the network to determine - // the repository ID. - char buf[32]; - assert(ICP_get(anum, "model", buf, sizeof(buf)) == 0); - const char * rep_id = strcmp(buf, "Sens-A-Temp") == 0 - ? "IDL:acme.com/CCS/Thermometer:1.0" - : "IDL:acme.com/CCS/Thermostat:1.0"; - - // Make a new reference. - CORBA::Object_var obj - = poa->create_reference_with_id(oid.in(), rep_id); - return CCS::Thermometer::_narrow(obj.in()); +make_dref (PortableServer::POA_ptr poa, CCS::AssetType anum) +{ + // Convert asset number to OID. + ostrstream ostr; + ostr << anum << ends; + char * anum_str = ostr.str (); + PortableServer::ObjectId_var oid + = PortableServer::string_to_ObjectId (anum_str); + delete[] anum_str; + + // Look at the model via the network to determine + // the repository ID. + char buf[32]; + assert (ICP_get (anum, "model", buf, sizeof (buf)) == 0); + const char * rep_id = strcmp (buf, "Sens-A-Temp") == 0 + ? "IDL:acme.com/CCS/Thermometer:1.0" + : "IDL:acme.com/CCS/Thermostat:1.0"; + + // Make a new reference. + CORBA::Object_var obj + = poa->create_reference_with_id (oid.in (), rep_id); + return CCS::Thermometer::_narrow (obj.in ()); } //---------------------------------------------------------------- @@ -128,115 +128,115 @@ Controller_impl * Thermometer_impl::m_ctrl; // static member CCS::ModelType Thermometer_impl:: -get_model() +get_model () { - char buf[32]; - assert(ICP_get(m_anum, "model", buf, sizeof(buf)) == 0); - return CORBA::string_dup(buf); + char buf[32]; + assert (ICP_get (m_anum, "model", buf, sizeof (buf)) == 0); + return CORBA::string_dup (buf); } // Helper function to read the temperature from a device. CCS::TempType Thermometer_impl:: -get_temp() +get_temp () { - short temp; - assert(ICP_get(m_anum, "temperature", &temp, sizeof(temp)) == 0); - return temp; + short temp; + assert (ICP_get (m_anum, "temperature", &temp, sizeof (temp)) == 0); + return temp; } // Helper function to read the location from a device. CCS::LocType Thermometer_impl:: -get_loc() +get_loc () { - char buf[32]; - assert(ICP_get(m_anum, "location", buf, sizeof(buf)) == 0); - return CORBA::string_dup(buf); + char buf[32]; + assert (ICP_get (m_anum, "location", buf, sizeof (buf)) == 0); + return CORBA::string_dup (buf); } // Helper function to set the location of a device. void Thermometer_impl:: -set_loc(const char * loc) +set_loc (const char * loc) { - assert(ICP_set(m_anum, "location", loc) == 0); + assert (ICP_set (m_anum, "location", loc) == 0); } // Constructor. Thermometer_impl:: -Thermometer_impl(CCS::AssetType anum) : m_anum(anum) +Thermometer_impl (CCS::AssetType anum) : m_anum (anum) { - m_ctrl->add_impl(anum, this); // Add self to controller's set + m_ctrl->add_impl (anum, this); // Add self to controller's set } // Destructor. Thermometer_impl:: -~Thermometer_impl() +~Thermometer_impl () { - if (m_ctrl->exists(m_anum)) - m_ctrl->add_impl(m_anum, 0); // Clear servant pointer + if (m_ctrl->exists (m_anum)) + m_ctrl->add_impl (m_anum, 0); // Clear servant pointer } // IDL model attribute. CCS::ModelType Thermometer_impl:: -model() throw(CORBA::SystemException) +model () throw (CORBA::SystemException) { - return get_model(); + return get_model (); } // IDL asset_num attribute. CCS::AssetType Thermometer_impl:: -asset_num() throw(CORBA::SystemException) +asset_num () throw (CORBA::SystemException) { - return m_anum; + return m_anum; } // IDL temperature attribute. CCS::TempType Thermometer_impl:: -temperature() throw(CORBA::SystemException) +temperature () throw (CORBA::SystemException) { - return get_temp(); + return get_temp (); } // IDL location attribute accessor. CCS::LocType Thermometer_impl:: -location() throw(CORBA::SystemException) +location () throw (CORBA::SystemException) { - return get_loc(); + return get_loc (); } // IDL remove operation. void Thermometer_impl:: -remove() throw(CORBA::SystemException) +remove () throw (CORBA::SystemException) { - m_ctrl->remove_impl(m_anum); - assert(ICP_offline(m_anum) == 0); - //delete this; + m_ctrl->remove_impl (m_anum); + assert (ICP_offline (m_anum) == 0); + //delete this; } // IDL location attribute modifier. void Thermometer_impl:: -location(const char *loc) throw(CORBA::SystemException) +location (const char *loc) throw (CORBA::SystemException) { - set_loc(loc); + set_loc (loc); } //---------------------------------------------------------------- @@ -245,87 +245,87 @@ location(const char *loc) throw(CORBA::SystemException) CCS::TempType Thermostat_impl:: -get_nominal_temp() +get_nominal_temp () { - short temp; - assert(ICP_get(m_anum, "nominal_temp", &temp, sizeof(temp)) == 0); - return temp; + short temp; + assert (ICP_get (m_anum, "nominal_temp", &temp, sizeof (temp)) == 0); + return temp; } // Helper function to set a thermostat's nominal temperature. CCS::TempType Thermostat_impl:: -set_nominal_temp(CCS::TempType new_temp) -throw(CCS::Thermostat::BadTemp) -{ - short old_temp; - - // We need to return the previous nominal temperature, - // so we first read the current nominal temperature before - // changing it. - assert( - ICP_get( - m_anum, "nominal_temp", &old_temp, sizeof(old_temp) - ) == 0 - ); - - // Now set the nominal temperature to the new value. - if (ICP_set(m_anum, "nominal_temp", &new_temp) != 0) { - - // If ICP_set() failed, read this thermostat's minimum - // and maximum so we can initialize the BadTemp exception. - CCS::Thermostat::BtData btd; - ICP_get( - m_anum, "MIN_TEMP", - &btd.min_permitted, sizeof(btd.min_permitted) - ); - ICP_get( - m_anum, "MAX_TEMP", - &btd.max_permitted, sizeof(btd.max_permitted) - ); - btd.requested = new_temp; - btd.error_msg = CORBA::string_dup( - new_temp > btd.max_permitted ? "Too hot" : "Too cold" - ); - throw CCS::Thermostat::BadTemp(btd); - } - return old_temp; +set_nominal_temp (CCS::TempType new_temp) +throw (CCS::Thermostat::BadTemp) +{ + short old_temp; + + // We need to return the previous nominal temperature, + // so we first read the current nominal temperature before + // changing it. + assert ( + ICP_get ( + m_anum, "nominal_temp", &old_temp, sizeof (old_temp) + ) == 0 + ); + + // Now set the nominal temperature to the new value. + if (ICP_set (m_anum, "nominal_temp", &new_temp) != 0) { + + // If ICP_set () failed, read this thermostat's minimum + // and maximum so we can initialize the BadTemp exception. + CCS::Thermostat::BtData btd; + ICP_get ( + m_anum, "MIN_TEMP", + &btd.min_permitted, sizeof (btd.min_permitted) + ); + ICP_get ( + m_anum, "MAX_TEMP", + &btd.max_permitted, sizeof (btd.max_permitted) + ); + btd.requested = new_temp; + btd.error_msg = CORBA::string_dup ( + new_temp > btd.max_permitted ? "Too hot" : "Too cold" + ); + throw CCS::Thermostat::BadTemp (btd); + } + return old_temp; } // Constructor. Thermostat_impl:: -Thermostat_impl(CCS::AssetType anum) : Thermometer_impl(anum) +Thermostat_impl (CCS::AssetType anum) : Thermometer_impl (anum) { - // Intentionally empty. + // Intentionally empty. } // Destructor. Thermostat_impl:: -~Thermostat_impl() +~Thermostat_impl () { - // Intentionally empty. + // Intentionally empty. } // IDL get_nominal operation. CCS::TempType Thermostat_impl:: -get_nominal() throw(CORBA::SystemException) +get_nominal () throw (CORBA::SystemException) { - return get_nominal_temp(); + return get_nominal_temp (); } // IDL set_nominal operation. CCS::TempType Thermostat_impl:: -set_nominal(CCS::TempType new_temp) -throw(CORBA::SystemException, CCS::Thermostat::BadTemp) +set_nominal (CCS::TempType new_temp) +throw (CORBA::SystemException, CCS::Thermostat::BadTemp) { - return set_nominal_temp(new_temp); + return set_nominal_temp (new_temp); } //---------------------------------------------------------------- @@ -334,47 +334,47 @@ throw(CORBA::SystemException, CCS::Thermostat::BadTemp) void Controller_impl:: -add_impl(CCS::AssetType anum, Thermometer_impl * tip) +add_impl (CCS::AssetType anum, Thermometer_impl * tip) { - m_assets[anum] = tip; + m_assets[anum] = tip; } // Helper function to remove an entry from the asset map. void Controller_impl:: -remove_impl(CCS::AssetType anum) +remove_impl (CCS::AssetType anum) { - m_assets.erase(anum); + m_assets.erase (anum); } // Helper function to locate a servant in the asset map. bool Controller_impl:: -exists(CCS::AssetType anum) +exists (CCS::AssetType anum) { - return m_assets.find(anum) != m_assets.end(); + return m_assets.find (anum) != m_assets.end (); } // Constructor Controller_impl:: -Controller_impl( +Controller_impl ( PortableServer::POA_ptr poa, const char * asset_file -) throw(int) : m_poa(PortableServer::POA::_duplicate(poa)), - m_asset_file(asset_file) +) throw (int) : m_poa (PortableServer::POA::_duplicate (poa)), + m_asset_file (asset_file) { - fstream afile(m_asset_file.in(), ios::in|ios::out, 0666); + fstream afile (m_asset_file.in (), ios::in|ios::out, 0666); if (!afile) { - cerr << "Cannot open " << m_asset_file.in() << endl; + cerr << "Cannot open " << m_asset_file.in () << endl; throw 0; } CCS::AssetType anum; while (afile >> anum) m_assets[anum] = 0; - //afile.close(); + //afile.close (); //if (!afile) { // cerr << "Cannot close " << m_asset_file << endl; // throw 0; @@ -384,122 +384,122 @@ Controller_impl( // Destructor Controller_impl:: -~Controller_impl() +~Controller_impl () { // Write out the current set of asset numbers // and clean up all servant instances. - ofstream afile(m_asset_file.in()); + ofstream afile (m_asset_file.in ()); if (!afile) { - cerr << "Cannot open " << m_asset_file.in() << endl; - assert(0); + cerr << "Cannot open " << m_asset_file.in () << endl; + assert (0); } AssetMap::iterator i; - for (i = m_assets.begin(); i != m_assets.end(); i++) { + for (i = m_assets.begin (); i != m_assets.end (); i++) { afile << i->first << endl; if (!afile) { - cerr << "Cannot update " << m_asset_file.in() << endl; - assert(0); + cerr << "Cannot update " << m_asset_file.in () << endl; + assert (0); } delete i->second; } - //afile.close(); + //afile.close (); //if (!afile) { // cerr << "Cannot close " << m_asset_file << endl; - // assert(0); + // assert (0); //} } CCS::Thermometer_ptr Controller_impl:: -create_thermometer(CCS::AssetType anum, const char * loc) -throw(CORBA::SystemException, CCS::Controller::DuplicateAsset) +create_thermometer (CCS::AssetType anum, const char * loc) +throw (CORBA::SystemException, CCS::Controller::DuplicateAsset) { if (anum % 2 == 0) - throw CORBA::BAD_PARAM(); // Thermometers have odd numbers - if (exists(anum)) - throw CCS::Controller::DuplicateAsset(); + throw CORBA::BAD_PARAM (); // Thermometers have odd numbers + if (exists (anum)) + throw CCS::Controller::DuplicateAsset (); - assert(ICP_online(anum) == 0); - assert(ICP_set(anum, "location", loc) == 0); - add_impl(anum, 0); - return make_dref(m_poa.in(), anum); + assert (ICP_online (anum) == 0); + assert (ICP_set (anum, "location", loc) == 0); + add_impl (anum, 0); + return make_dref (m_poa.in (), anum); } CCS::Thermostat_ptr Controller_impl:: -create_thermostat( +create_thermostat ( CCS::AssetType anum, const char* loc, CCS::TempType temp) -throw( +throw ( CORBA::SystemException, CCS::Controller::DuplicateAsset, CCS::Thermostat::BadTemp) { if (anum % 2 != 0) - throw CORBA::BAD_PARAM(); // Thermostats have even numbers - if (exists(anum)) - throw CCS::Controller::DuplicateAsset(); + throw CORBA::BAD_PARAM (); // Thermostats have even numbers + if (exists (anum)) + throw CCS::Controller::DuplicateAsset (); - assert(ICP_online(anum) == 0); - assert(ICP_set(anum, "location", loc) == 0); + assert (ICP_online (anum) == 0); + assert (ICP_set (anum, "location", loc) == 0); // Set the nominal temperature. - if (ICP_set(anum, "nominal_temp", &temp) != 0) { + if (ICP_set (anum, "nominal_temp", &temp) != 0) { - // If ICP_set() failed, read this thermostat's minimum + // If ICP_set () failed, read this thermostat's minimum // and maximum so we can initialize the BadTemp exception. CCS::Thermostat::BtData btd; - ICP_get( + ICP_get ( anum, "MIN_TEMP", - &btd.min_permitted, sizeof(btd.min_permitted) + &btd.min_permitted, sizeof (btd.min_permitted) ); - ICP_get( + ICP_get ( anum, "MAX_TEMP", - &btd.max_permitted, sizeof(btd.max_permitted) + &btd.max_permitted, sizeof (btd.max_permitted) ); btd.requested = temp; - btd.error_msg = CORBA::string_dup( + btd.error_msg = CORBA::string_dup ( temp > btd.max_permitted ? "Too hot" : "Too cold" ); - ICP_offline(anum); - throw CCS::Thermostat::BadTemp(btd); + ICP_offline (anum); + throw CCS::Thermostat::BadTemp (btd); } - add_impl(anum, 0); - CORBA::Object_var obj = make_dref(m_poa.in(), anum); - return CCS::Thermostat::_narrow(obj.in()); + add_impl (anum, 0); + CORBA::Object_var obj = make_dref (m_poa.in (), anum); + return CCS::Thermostat::_narrow (obj.in ()); } // IDL list operation. CCS::Controller::ThermometerSeq * Controller_impl:: -list() throw(CORBA::SystemException) +list () throw (CORBA::SystemException) { // Create a new thermometer sequence. Because we know // the number of elements we will put onto the sequence, // we use the maximum constructor. CCS::Controller::ThermometerSeq_var listv - = new CCS::Controller::ThermometerSeq(m_assets.size()); - listv->length(m_assets.size()); + = new CCS::Controller::ThermometerSeq (m_assets.size ()); + listv->length (m_assets.size ()); // Loop over the m_assets set and create a // reference for each device. CORBA::ULong count = 0; AssetMap::iterator i; - for (i = m_assets.begin(); i != m_assets.end(); i++) - listv[count++] = make_dref(m_poa.in(), i->first); - return listv._retn(); + for (i = m_assets.begin (); i != m_assets.end (); i++) + listv[count++] = make_dref (m_poa.in (), i->first); + return listv._retn (); } // IDL change operation. void Controller_impl:: -change( +change ( const CCS::Controller::ThermostatSeq & tlist, CORBA::Short delta -) throw(CORBA::SystemException, CCS::Controller::EChange) +) throw (CORBA::SystemException, CCS::Controller::EChange) { CCS::Controller::EChange ec; // Just in case we need it @@ -507,30 +507,30 @@ change( // directly, so for each thermostat, we read the nominal // temperature, add the delta value to it, and write // it back again. - for (CORBA::ULong i = 0; i < tlist.length(); i++) { - if (CORBA::is_nil(tlist[i])) + for (CORBA::ULong i = 0; i < tlist.length (); i++) { + if (CORBA::is_nil (tlist[i])) continue; // Skip nil references // Read nominal temp and update it. - CCS::TempType tnom = tlist[i]->get_nominal(); + CCS::TempType tnom = tlist[i]->get_nominal (); tnom += delta; try { - tlist[i]->set_nominal(tnom); + tlist[i]->set_nominal (tnom); } catch (const CCS::Thermostat::BadTemp &bt) { // If the update failed because the temperature // is out of range, we add the thermostat's info // to the errors sequence. - CORBA::ULong len = ec.errors.length(); - ec.errors.length(len + 1); - ec.errors[len].tmstat_ref = tlist[i]; + CORBA::ULong len = ec.errors.length (); + ec.errors.length (len + 1); + ec.errors[len].tmstat_ref = tlist[i].in (); ec.errors[len].info = bt.details; } } // If we encountered errors in the above loop, // we will have added elements to the errors sequence. - if (ec.errors.length() != 0) + if (ec.errors.length () != 0) throw ec; } @@ -538,61 +538,61 @@ change( void Controller_impl:: -find(CCS::Controller::SearchSeq & slist) -throw(CORBA::SystemException) +find (CCS::Controller::SearchSeq & slist) +throw (CORBA::SystemException) { // Loop over input list and lookup each device. - CORBA::ULong listlen = slist.length(); + CORBA::ULong listlen = slist.length (); for (CORBA::ULong i = 0; i < listlen; i++) { AssetMap::iterator where; // Iterator for asset set int num_found = 0; // Num matched per iteration // Assume we will not find a matching device. - slist[i].device = CCS::Thermometer::_nil(); + slist[i].device = CCS::Thermometer::_nil (); // Work out whether we are searching by asset, // model, or location. - CCS::Controller::SearchCriterion sc = slist[i].key._d(); + CCS::Controller::SearchCriterion sc = slist[i].key._d (); if (sc == CCS::Controller::ASSET) { // Search for matching asset number. - where = m_assets.find(slist[i].key.asset_num()); - if (where != m_assets.end()) - slist[i].device = make_dref(m_poa.in(), where->first); + where = m_assets.find (slist[i].key.asset_num ()); + if (where != m_assets.end ()) + slist[i].device = make_dref (m_poa.in (), where->first); } else { // Search for model or location string. const char *search_str; if (sc == CCS::Controller::LOCATION) - search_str = slist[i].key.loc(); + search_str = slist[i].key.loc (); else - search_str = slist[i].key.model_desc(); + search_str = slist[i].key.model_desc (); // Find first matching device (if any). - where = find_if( - m_assets.begin(), m_assets.end(), - StrFinder(sc, search_str) + where = find_if ( + m_assets.begin (), m_assets.end (), + StrFinder (sc, search_str) ); // While there are matches... - while (where != m_assets.end()) { + while (where != m_assets.end ()) { if (num_found == 0) { // First match overwrites reference // in search record. - slist[i].device = make_dref(m_poa.in(), where->first); + slist[i].device = make_dref (m_poa.in (), where->first); } else { // Further matches each append a new // element to the search sequence. - CORBA::ULong len = slist.length(); - slist.length(len + 1); + CORBA::ULong len = slist.length (); + slist.length (len + 1); slist[len].key = slist[i].key; - slist[len].device = make_dref(m_poa.in(), where->first); + slist[len].device = make_dref (m_poa.in (), where->first); } num_found++; // Find next matching device with this key. - where = find_if( - ++where, m_assets.end(), - StrFinder(sc, search_str) + where = find_if ( + ++where, m_assets.end (), + StrFinder (sc, search_str) ); } } @@ -602,80 +602,79 @@ throw(CORBA::SystemException) //---------------------------------------------------------------- DeviceLocator_impl:: -DeviceLocator_impl(Controller_impl * ctrl) : m_ctrl(ctrl) +DeviceLocator_impl (Controller_impl * ctrl) : m_ctrl (ctrl) { // Intentionally empty } PortableServer::Servant DeviceLocator_impl:: -preinvoke( +preinvoke ( const PortableServer::ObjectId & oid, PortableServer::POA_ptr /* poa */, const char * operation, void * & /* cookie */, - CORBA_Environment & -) throw(CORBA::SystemException, PortableServer::ForwardRequest) +) throw (CORBA::SystemException, PortableServer::ForwardRequest) { // Convert object id into asset number. CORBA::String_var oid_string; try { - oid_string = PortableServer::ObjectId_to_string(oid); + oid_string = PortableServer::ObjectId_to_string (oid); } catch (const CORBA::BAD_PARAM &) { - throw CORBA::OBJECT_NOT_EXIST(); + throw CORBA::OBJECT_NOT_EXIST (); } - if (strcmp(oid_string.in(), Controller_oid) == 0) + if (strcmp (oid_string.in (), Controller_oid) == 0) return m_ctrl; - istrstream istr(oid_string.in()); + istrstream istr (oid_string.in ()); CCS::AssetType anum; istr >> anum; - if (istr.fail()) - throw CORBA::OBJECT_NOT_EXIST(); + if (istr.fail ()) + throw CORBA::OBJECT_NOT_EXIST (); // Check whether the device is known. - if (!m_ctrl->exists(anum)) - throw CORBA::OBJECT_NOT_EXIST(); + if (!m_ctrl->exists (anum)) + throw CORBA::OBJECT_NOT_EXIST (); // Look at the object map to find out whether // we have a servant in memory. Thermometer_impl * servant; - ActiveObjectMap::iterator servant_pos = m_aom.find(anum); - if (servant_pos == m_aom.end()) { + ActiveObjectMap::iterator servant_pos = m_aom.find (anum); + if (servant_pos == m_aom.end ()) { // No servant in memory. If evictor queue is full, // evict servant at head of queue. - if (m_eq.size() == MAX_EQ_SIZE) { - servant = m_eq.back(); - m_aom.erase(servant->m_anum); - m_eq.pop_back(); + if (m_eq.size () == MAX_EQ_SIZE) { + servant = m_eq.back (); + m_aom.erase (servant->m_anum); + m_eq.pop_back (); delete servant; } // Instantiate correct type of servant. char buf[32]; - assert(ICP_get(anum, "model", buf, sizeof(buf)) == 0); - if (strcmp(buf, "Sens-A-Temp") == 0) - servant = new Thermometer_impl(anum); + assert (ICP_get (anum, "model", buf, sizeof (buf)) == 0); + if (strcmp (buf, "Sens-A-Temp") == 0) + servant = new Thermometer_impl (anum); else - servant = new Thermostat_impl(anum); + servant = new Thermostat_impl (anum); } else { // Servant already in memory. - servant = *(servant_pos->second); // Remember servant - m_eq.erase(servant_pos->second); // Remove from queue + servant = * (servant_pos->second); // Remember servant + m_eq.erase (servant_pos->second); // Remove from queue // If operation is "remove", also remove entry from // active object map -- the object is about to be deleted. - if (strcmp(operation, "remove") == 0) - m_aom.erase(servant_pos); + if (strcmp (operation, "remove") == 0) + m_aom.erase (servant_pos); } // We found a servant, or just instantiated it. // If the operation is not a remove, move // the servant to the tail of the evictor queue // and update its queue position in the map. - if (strcmp(operation, "remove") != 0) { - m_eq.push_front(servant); - m_aom[anum] = m_eq.begin(); + if (strcmp (operation, "remove") != 0) { + m_eq.push_front (servant); + m_aom[anum] = m_eq.begin (); } return servant; @@ -684,106 +683,106 @@ preinvoke( //---------------------------------------------------------------- int -main(int argc, char * argv[]) +main (int argc, char * argv[]) { CORBA::ORB_var orb; try { // Initialize orb - orb = CORBA::ORB_init(argc, argv); + orb = CORBA::ORB_init (argc, argv); // Get reference to Root POA. CORBA::Object_var obj - = orb->resolve_initial_references("RootPOA"); + = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa - = PortableServer::POA::_narrow(obj.in()); + = PortableServer::POA::_narrow (obj.in ()); // Get POA manager - PortableServer::POAManager_var poa_mgr = poa->the_POAManager(); + PortableServer::POAManager_var poa_mgr = poa->the_POAManager (); // Create a policy list. We use persistent objects with // user-assigned IDs, and explicit activation. CORBA::PolicyList policy_list; - policy_list.length(6); - policy_list[0] = poa->create_lifespan_policy( + policy_list.length (6); + policy_list[0] = poa->create_lifespan_policy ( PortableServer::TRANSIENT // REVISIT ); - policy_list[1] = poa->create_id_assignment_policy( + policy_list[1] = poa->create_id_assignment_policy ( PortableServer::USER_ID ); - policy_list[2] = poa->create_implicit_activation_policy( + policy_list[2] = poa->create_implicit_activation_policy ( PortableServer::NO_IMPLICIT_ACTIVATION ); - policy_list[3] = poa->create_request_processing_policy( + policy_list[3] = poa->create_request_processing_policy ( PortableServer::USE_SERVANT_MANAGER ); - policy_list[4] = poa->create_servant_retention_policy( + policy_list[4] = poa->create_servant_retention_policy ( PortableServer::NON_RETAIN ); - policy_list[5] = poa->create_thread_policy( + policy_list[5] = poa->create_thread_policy ( PortableServer::SINGLE_THREAD_MODEL ); // Create a POA for all CCS elements. PortableServer::POA_var ccs_poa - = poa->create_POA("CCS_POA", poa_mgr.in(), policy_list); + = poa->create_POA ("CCS_POA", poa_mgr.in (), policy_list); // Create a controller and set static m_ctrl member // for thermostats and thermometers. - Controller_impl ctrl_servant(ccs_poa.in(), "/tmp/CCS_assets"); + Controller_impl ctrl_servant (ccs_poa.in (), "/tmp/CCS_assets"); Thermometer_impl::m_ctrl = &ctrl_servant; // Create a reference for the controller and // create the corresponding CORBA object. PortableServer::ObjectId_var oid - = PortableServer::string_to_ObjectId(Controller_oid); + = PortableServer::string_to_ObjectId (Controller_oid); CORBA::Object_var ctrl - = ccs_poa->create_reference_with_id( - oid.in(), "IDL:acme.com/CCS/Controller:1.0" + = ccs_poa->create_reference_with_id ( + oid.in (), "IDL:acme.com/CCS/Controller:1.0" ); // Get reference to initial naming context. CosNaming::NamingContext_var inc - = resolve_init<CosNaming::NamingContext>( - orb.in(), "NameService" + = resolve_init<CosNaming::NamingContext> ( + orb.in (), "NameService" ); // Attempt to create CCS context. CosNaming::Name n; - n.length(1); - n[0].id = CORBA::string_dup("CCS"); + n.length (1); + n[0].id = CORBA::string_dup ("CCS"); try { CosNaming::NamingContext_var nc - = inc->bind_new_context(n); + = inc->bind_new_context (n); } catch (const CosNaming::NamingContext::AlreadyBound &) { // Fine, CCS context already exists. } // Force binding of controller reference to make // sure it is always up-to-date. - n.length(2); - n[1].id = CORBA::string_dup("Controller"); - inc->rebind(n, ctrl.in()); + n.length (2); + n[1].id = CORBA::string_dup ("Controller"); + inc->rebind (n, ctrl.in ()); // Instantiate the servant locator for devices. PortableServer::ServantManager_var locator = new DeviceLocator_impl (&ctrl_servant); // Set servant locator. - ccs_poa->set_servant_manager(locator.in()); + ccs_poa->set_servant_manager (locator.in ()); // Activate the POA manager. - poa_mgr->activate(); + poa_mgr->activate (); // Accept requests - orb->run(); + orb->run (); } catch (const CORBA::Exception & e) { cerr << "Uncaught CORBA exception: " << e << endl; return 1; } catch (...) { - assert(0); // Uncaught exception, dump core + assert (0); // Uncaught exception, dump core } return 0; } diff --git a/TAO/examples/Advanced/ch_18/server.h b/TAO/examples/Advanced/ch_18/server.h index 5bada662495..55aeba8dad6 100644 --- a/TAO/examples/Advanced/ch_18/server.h +++ b/TAO/examples/Advanced/ch_18/server.h @@ -205,7 +205,6 @@ public: PortableServer::POA_ptr poa, const char * operation, void * & cookie, - CORBA_Environment & ) throw( CORBA::SystemException, PortableServer::ForwardRequest); @@ -216,7 +215,6 @@ public: const char * /* operation */, void * /* cookie */, PortableServer::Servant /* servant */, - CORBA_Environment & ) throw(CORBA::SystemException) {} private: |