diff options
Diffstat (limited to 'TAO/CIAO/tools/Config_Handlers/IDD_Handler.cpp')
-rw-r--r-- | TAO/CIAO/tools/Config_Handlers/IDD_Handler.cpp | 215 |
1 files changed, 111 insertions, 104 deletions
diff --git a/TAO/CIAO/tools/Config_Handlers/IDD_Handler.cpp b/TAO/CIAO/tools/Config_Handlers/IDD_Handler.cpp index 5f1978d41b9..3a1995ceed8 100644 --- a/TAO/CIAO/tools/Config_Handlers/IDD_Handler.cpp +++ b/TAO/CIAO/tools/Config_Handlers/IDD_Handler.cpp @@ -1,5 +1,6 @@ // $Id$ +#include "ace/UUID.h" #include "IDD_Handler.h" #include "IRDD_Handler.h" #include "MDD_Handler.h" @@ -17,13 +18,14 @@ namespace CIAO void IDD_Handler::instance_deployment_descrs ( - const DeploymentPlan &src, - Deployment::InstanceDeploymentDescriptions& dest) + const DeploymentPlan &src, + Deployment::InstanceDeploymentDescriptions& dest) throw (Config_Error) { + CIAO_TRACE("IDD_Handler::instance_deployment_descrs"); DeploymentPlan::instance_const_iterator idd_e = src.end_instance (); - + CORBA::ULong pos = 0; dest.length (src.count_instance ()); for (DeploymentPlan::instance_const_iterator idd_b = @@ -31,124 +33,129 @@ namespace CIAO idd_b != idd_e; ++idd_b) { - IDD_Handler::instance_deployment_descr ((*idd_b), - dest[pos], pos); - pos++; + IDD_Handler::instance_deployment_descr ((*idd_b), + dest[pos], pos); + pos++; } } void IDD_Handler::instance_deployment_descr ( - const InstanceDeploymentDescription& src, - Deployment::InstanceDeploymentDescription& dest, - CORBA::ULong pos) + const InstanceDeploymentDescription& src, + Deployment::InstanceDeploymentDescription& dest, + CORBA::ULong pos) throw (Config_Error) { + CIAO_TRACE("IDD_Handler::instance_deployment_descr"); try - { - dest.name = src.name ().c_str (); - dest.node = src.node ().c_str (); - - if (src.id_p ()) - { - ACE_CString cstr (src.id ().c_str ()); - IDD_Handler::IDREF.bind_ref (cstr, pos); - } - else - { - ACE_DEBUG((LM_ERROR, - "(%P|%t) Warning: IDD %s has no idref \n", - src.name ().c_str ())); - } - - // We know there should be only one element + { + dest.name = src.name ().c_str (); + dest.node = src.node ().c_str (); + + if (src.id_p ()) + { + ACE_CString cstr (src.id ().c_str ()); + IDD_Handler::IDREF.bind_ref (cstr, pos); + } + else + { + ACE_DEBUG((LM_ERROR, + "(%P|%t) Warning: IDD %s has no idref \n", + src.name ().c_str ())); + } + + // We know there should be only one element dest.source.length (1); - dest.source [0] = - src.source ().c_str (); - - CORBA::ULong tmp = 0; - MDD_Handler::IDREF.find_ref - (ACE_CString (src.implementation ().id ().c_str ()), tmp); - - dest.implementationRef = tmp; - - InstanceDeploymentDescription::configProperty_const_iterator pend = - src.end_configProperty (); - - CORBA::ULong pos = 0; + dest.source [0] = + src.source ().c_str (); + + CORBA::ULong tmp = 0; + MDD_Handler::IDREF.find_ref + (ACE_CString (src.implementation ().id ().c_str ()), tmp); + + dest.implementationRef = tmp; + dest.configProperty.length (src.count_configProperty ()); - for (InstanceDeploymentDescription::configProperty_const_iterator pstart = - src.begin_configProperty (); - pstart != pend; - ++pstart) - { - Property_Handler::get_property (*pstart, - dest.configProperty[pos++]); - } - - if (src.deployedResource_p ()) - { - dest.deployedResource.length (1); - IRDD_Handler::instance_resource_deployment_descr (src.deployedResource (), - dest.deployedResource[0]); - } - - if (src.deployedSharedResource_p ()) - { - dest.deployedSharedResource.length (1); - IRDD_Handler::instance_resource_deployment_descr (src.deployedSharedResource (), - dest.deployedSharedResource[0]); - } - - } + std::for_each (src.begin_configProperty (), + src.end_configProperty (), + Property_Functor (dest.configProperty)); + + if (src.deployedResource_p ()) + { + dest.deployedResource.length (1); + IRDD_Handler::instance_resource_deployment_descr (src.deployedResource (), + dest.deployedResource[0]); + } + + if (src.deployedSharedResource_p ()) + { + dest.deployedSharedResource.length (1); + IRDD_Handler::instance_resource_deployment_descr (src.deployedSharedResource (), + dest.deployedSharedResource[0]); + } + + } catch (Config_Error &ex) - { - ex.name_ = src.name () + ":" + ex.name_; - throw ex; - } + { + ex.name_ = src.name () + ":" + ex.name_; + throw ex; + } // Done! } - + InstanceDeploymentDescription IDD_Handler::instance_deployment_descr ( - const Deployment::InstanceDeploymentDescription& src) + const Deployment::InstanceDeploymentDescription& src) throw (Config_Error) { - - //Get all the string/IDREFs - XMLSchema::string < ACE_TCHAR > name ((src.name)); - XMLSchema::string < ACE_TCHAR > node ((src.node)); - XMLSchema::string < ACE_TCHAR > source ((src.source[0])); - ACE_CString temp; - MDD_Handler::IDREF.find_ref(src.implementationRef, temp); - XMLSchema::IDREF< ACE_TCHAR > implementation ((temp.c_str())); - - // Instantiate the IDD - InstanceDeploymentDescription idd (name, node, source, implementation); - - //Get and store the configProperty(s) - size_t total = src.configProperty.length(); - for(size_t j = 0; j < total; j++) - { - idd.add_configProperty( - Property_Handler::get_property ( - src.configProperty[j])); - } - - //Check if there is a deployedResource, if so store - if(src.deployedResource.length() != 0) - idd.deployedResource( - IRDD_Handler::instance_resource_deployment_descr( - src.deployedResource[0])); - - //Check if there is a deployedSharedResource, if so store it - if(src.deployedSharedResource.length() != 0) - idd. deployedSharedResource( - IRDD_Handler::instance_resource_deployment_descr( - src.deployedSharedResource[0])); - - return idd; - } + CIAO_TRACE("IDD_Handler::instance_deployment_descr - reverse"); + //Get all the string/IDREFs + XMLSchema::string < ACE_TCHAR > name ((src.name)); + XMLSchema::string < ACE_TCHAR > node ((src.node)); + XMLSchema::string < ACE_TCHAR > source ((src.source[0])); + ACE_CString temp; + MDD_Handler::IDREF.find_ref(src.implementationRef, temp); + XMLSchema::IDREF< ACE_TCHAR > implementation ((temp.c_str())); + + // Instantiate the IDD + InstanceDeploymentDescription idd (name, node, source, implementation); + + //Get and store the configProperty(s) + size_t total = src.configProperty.length(); + for(size_t j = 0; j < total; j++) + { + idd.add_configProperty( + Property_Handler::get_property ( + src.configProperty[j])); + } + + //Check if there is a deployedResource, if so store + if(src.deployedResource.length() != 0) + idd.deployedResource( + IRDD_Handler::instance_resource_deployment_descr( + src.deployedResource[0])); + + //Check if there is a deployedSharedResource, if so store it + if(src.deployedSharedResource.length() != 0) + idd. deployedSharedResource( + IRDD_Handler::instance_resource_deployment_descr( + src.deployedSharedResource[0])); + + // Generate a UUID to use for the IDREF. + ACE_Utils::UUID uuid; + ACE_Utils::UUID_GENERATOR::instance ()->generateUUID (uuid); + ACE_CString idd_id ("_"); + idd_id += *uuid.to_string (); + + XMLSchema::ID< ACE_TCHAR > xml_id (idd_id.c_str ()); + + // Bind the ref and set it in the IDD + IDD_Handler::IDREF.bind_next_available (idd_id); + + idd.id (xml_id); + + return idd; + } } } |