diff options
Diffstat (limited to 'modules/CIAO/DAnCE/Config_Handlers/Package_Handlers')
19 files changed, 2176 insertions, 0 deletions
diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CAD_Handler.cpp b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CAD_Handler.cpp new file mode 100644 index 00000000000..cd58f3e08bb --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CAD_Handler.cpp @@ -0,0 +1,271 @@ +// $Id$ + +#include "tao/AnyTypeCode/TypeCode.h" +#include "Package_Handlers/CAD_Handler.h" +#include "Basic_Deployment_Data.hpp" +#include "cid.hpp" +#include "DAnCE/Deployment/Deployment_Packaging_DataC.h" +#include "Req_Handler.h" +#include "CEPE_Handler.h" +#include "ERE_Handler.h" +#include "Utils/Exceptions.h" + +#include "Package_Handlers/SID_Handler.h" + +namespace CIAO +{ + namespace Config_Handlers + { + namespace Packaging + { + struct Packaging_Handlers_Export SPE_Handler + { + static void handle_spe (const SubcomponentPortEndpoint &desc, + ::Deployment::SubcomponentPortEndpoint &toconfig) + { + DANCE_TRACE("SPE_Handler::get_spe"); + + toconfig.portName = ACE_TEXT_ALWAYS_CHAR ( desc.portName ().c_str ()); + + ACE_TString str (desc.instance ().idref ().id ().c_str ()); + CORBA::ULong pos (0); + + SID_Handler::IDREF.find_ref (str, pos); + toconfig.instanceRef = pos; + } + + static SubcomponentPortEndpoint + get_spe (const ::Deployment::SubcomponentPortEndpoint &src) + { + DANCE_TRACE("SPE_Handler::get_spe - reverse"); + ACE_TString str; + SID_Handler::IDREF.find_ref (src.instanceRef, str); + + IdRef xid; + xid.idref (str.c_str ()); + + return SubcomponentPortEndpoint (ACE_TEXT_CHAR_TO_TCHAR (src.portName.in ()), + xid); + } + }; + + typedef Sequence_Handler < SubcomponentPortEndpoint, + ::Deployment::SubcomponentPortEndpoints, + ::Deployment::SubcomponentPortEndpoint, + SPE_Handler::handle_spe > SPE_Functor; + + struct Packaging_Handlers_Export ACD_Handler + { + static void handle_acd (const AssemblyConnectionDescription &desc, + ::Deployment::AssemblyConnectionDescription &toconfig) + { + DANCE_TRACE("ACD_Handler::get_acd"); + + toconfig.name = ACE_TEXT_ALWAYS_CHAR ( desc.name ().c_str ()); + + toconfig.deployRequirement.length (desc.count_deployRequirement ()); + std::for_each (desc.begin_deployRequirement (), + desc.end_deployRequirement (), + Requirement_Functor (toconfig.deployRequirement)); + + toconfig.internalEndpoint.length (desc.count_internalEndpoint ()); + SEQ_HAND_GCC_BUG_WORKAROUND (SPE_Handler::handle_spe, + (*desc.begin_internalEndpoint ()), + toconfig.internalEndpoint); + std::for_each (desc.begin_internalEndpoint (), + desc.end_internalEndpoint (), + SPE_Functor (toconfig.internalEndpoint)); + + toconfig.externalEndpoint.length (desc.count_externalEndpoint ()); + std::for_each (desc.begin_externalEndpoint (), + desc.end_externalEndpoint (), + CEPE_Functor (toconfig.externalEndpoint)); + + toconfig.externalReference.length (desc.count_externalReference ()); + std::for_each (desc.begin_externalReference (), + desc.end_externalReference (), + ERE_Functor (toconfig.externalReference)); + + } + + static AssemblyConnectionDescription + get_acd (const ::Deployment::AssemblyConnectionDescription &src) + { + DANCE_TRACE("ACD_Handler::get_acd - reverse"); + + AssemblyConnectionDescription retval (ACE_TEXT_CHAR_TO_TCHAR (src.name.in ())); +#if 0 + for (CORBA::ULong i = 0; i < src.deployRequirement.length (); ++i) + retval.add_deployRequirement (Req_Handler::get_requirement (src.deployRequirement[i])); + + for (CORBA::ULong i = 0; i < src.internalEndpoint.length (); ++i) + retval.add_internalEndpoint + (SPE_Handler::get_spe (src.internalEndpoint[i])); + + for (CORBA::ULong i = 0; i < src.externalEndpoint.length (); ++i) + retval.add_externalEndpoint + (CEPE_Handler::external_port_endpoint (src.externalEndpoint[i])); + + for (CORBA::ULong i = 0; i < src.externalReference.length (); ++i) + retval.add_externalReference + (ERE_Handler::external_ref_endpoint (src.externalReference[i])); +#endif + return retval; + } + }; + + typedef Sequence_Handler < AssemblyConnectionDescription, + ::Deployment::AssemblyConnectionDescriptions, + ::Deployment::AssemblyConnectionDescription, + ACD_Handler::handle_acd > ACD_Functor; + + + struct Packaging_Handlers_Export SPR_Handler + { + static void handle_spr (const SubcomponentPropertyReference &desc, + ::Deployment::SubcomponentPropertyReference &toconfig) + { + DANCE_TRACE("SPR_Handler::get_spr"); + + toconfig.propertyName = ACE_TEXT_ALWAYS_CHAR ( desc.propertyName ().c_str ()); + + ACE_TString str (desc.instance ().idref ().id ().c_str ()); + CORBA::ULong pos (0); + + SID_Handler::IDREF.find_ref (str, pos); + toconfig.instanceRef = pos; + + } + + static SubcomponentPropertyReference + get_spr (const ::Deployment::SubcomponentPropertyReference &src) + { + DANCE_TRACE("SPR_HAndler::get_spr - reverse"); + ACE_TString str; + SID_Handler::IDREF.find_ref (src.instanceRef, str); + + IdRef xid; + xid.idref (str.c_str ()); + return SubcomponentPropertyReference (ACE_TEXT_CHAR_TO_TCHAR (src.propertyName.in ()), + xid); + } + + }; + + typedef Sequence_Handler < SubcomponentPropertyReference, + ::Deployment::SubcomponentPropertyReferences, + ::Deployment::SubcomponentPropertyReference, + SPR_Handler::handle_spr > SPR_Functor; + + struct Packaging_Handlers_Export APM_Handler + { + static void handle_apm (const AssemblyPropertyMapping &desc, + ::Deployment::AssemblyPropertyMapping &toconfig) + { + DANCE_TRACE("APM_Handler::get_apm"); + + toconfig.name = ACE_TEXT_ALWAYS_CHAR ( desc.name ().c_str ()); + toconfig.externalName = ACE_TEXT_ALWAYS_CHAR ( desc.externalName ().c_str ()); + + toconfig.delegatesTo.length (desc.count_delegatesTo ()); + SEQ_HAND_GCC_BUG_WORKAROUND (SPR_Handler::handle_spr, + (*desc.begin_delegatesTo ()), + toconfig.delegatesTo); + std::for_each (desc.begin_delegatesTo (), + desc.end_delegatesTo (), + SPR_Functor (toconfig.delegatesTo)); + } + + static AssemblyPropertyMapping + get_apm (const ::Deployment::AssemblyPropertyMapping &src) + { + DANCE_TRACE("APM_Handler::get_apm - reverse"); + + AssemblyPropertyMapping retval (ACE_TEXT_CHAR_TO_TCHAR (src.name.in ()), + ACE_TEXT_CHAR_TO_TCHAR (src.externalName.in ())); +#if 0 + for (CORBA::ULong i = 0; i < src.delegatesTo.length (); ++i) + retval.add_delegatesTo (SPR_Handler::get_spr (src.delegatesTo[i])); +#endif + return retval; + } + }; + + typedef Sequence_Handler < AssemblyPropertyMapping, + ::Deployment::AssemblyPropertyMappings, + ::Deployment::AssemblyPropertyMapping, + APM_Handler::handle_apm > APM_Functor; + + void + CAD_Handler::component_assem_descr (const ComponentAssemblyDescription &desc, + ::Deployment::ComponentAssemblyDescription &toconfig) + { + DANCE_TRACE("CAD_Handler::component_assem_descr"); + + toconfig.instance.length (desc.count_instance ()); + std::for_each (desc.begin_instance (), + desc.end_instance (), + SID_Functor (toconfig.instance)); + + /* @@ MAJO: Implement Locality */ + + toconfig.connection.length (desc.count_connection ()); + SEQ_HAND_GCC_BUG_WORKAROUND (ACD_Handler::handle_acd, + (*desc.begin_connection ()), + toconfig.connection); + std::for_each (desc.begin_connection (), + desc.end_connection (), + ACD_Functor (toconfig.connection)); + + toconfig.externalProperty.length (desc.count_externalProperty ()); + SEQ_HAND_GCC_BUG_WORKAROUND (APM_Handler::handle_apm, + (*desc.begin_externalProperty ()), + toconfig.externalProperty); + std::for_each (desc.begin_externalProperty (), + desc.end_externalProperty (), + APM_Functor (toconfig.externalProperty)); + } + + ComponentAssemblyDescription + CAD_Handler::component_assem_descr (const ::Deployment::ComponentAssemblyDescription &/*src*/) + { + DANCE_TRACE("CAD_Handler::component_assem_descr - reverse"); + + ComponentAssemblyDescription retval; +#if 0 + for (CORBA::ULong i = 0; i < src.instance.length (); ++i) + retval.add_instance + (SID_Handler::sub_comp_inst_descr (src.instance[i])); + + for (CORBA::ULong i = 0; i < src.connection.length (); ++i) + retval.add_connection (ACD_Handler::get_acd (src.connection[i])); + + for (CORBA::ULong i = 0; i < src.externalProperty.length (); ++i) + retval.add_externalProperty (APM_Handler::get_apm (src.externalProperty[i])); +#endif + return retval; + + } + + ComponentAssemblyDescription * + CAD_Handler::resolve_cad (const char *) + { + /* xercesc::DOMDocument *dom = + this->xml_helper_->create_dom (uri); + + if (!dom) + throw Parse_Error ("Unable to create DOM for CAD"); + + try { + return new ComponentAssemblyDescription + (componentAssemblyDescription (dom)); + } + catch (...) { + throw Parse_Error ("Unable to create XSC structure for CAD"); + */ + return 0; + } + } + } +} + diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CAD_Handler.h b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CAD_Handler.h new file mode 100644 index 00000000000..b42f13dcdc3 --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CAD_Handler.h @@ -0,0 +1,59 @@ +/** + * @file CAD_Handler.h + * @author William Otte <wotte@dre.vanderbilt.edu> + * + * $Id$ + */ + +#ifndef CIAO_PACKAGING_CAD_HANDLER_H +#define CIAO_PACKAGING_CAD_HANDLER_H + +#include /**/ "ace/pre.h" + +#include "XML_Typedefs.h" +#include "DAnCE/Deployment/DeploymentC.h" +#include "Package_Handlers/Packaging_Handlers_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace Deployment +{ + struct ComponentAssemblyDescription; +} + +namespace CIAO +{ + namespace Config_Handlers + { + class ComponentAssemblyDescription; + + namespace Packaging + { + + /** + * @class CAD_Handler + * + * @brief Handler class for ComponentAssemblyDescription. + */ + class Packaging_Handlers_Export CAD_Handler + { + public: + static void component_assem_descr (const ComponentAssemblyDescription &desc, + ::Deployment::ComponentAssemblyDescription &toconfig); + + static ComponentAssemblyDescription + component_assem_descr (const ::Deployment::ComponentAssemblyDescription &src); + + private: + static ComponentAssemblyDescription * resolve_cad (const char *uri); + }; + + } + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_PACKAGING_CAD_HANDLER_H */ + diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CID_Handler.cpp b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CID_Handler.cpp new file mode 100644 index 00000000000..4be49ae2bcb --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CID_Handler.cpp @@ -0,0 +1,390 @@ +// $Id$ +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "Package_Handlers/CID_Handler.h" +#include "Package_Handlers/CPD_Handler.h" +#include "Package_Handlers/IAD_Handler.h" +#include "Package_Handlers/CAD_Handler.h" +#include "Package_Handlers/Comp_Intf_Descr_Handler.h" +#include "Package_Handlers/NIA_Handler.h" +#include "SatisfierProperty_Handler.h" +#include "Req_Handler.h" + +#include "Basic_Deployment_Data.hpp" +#include "DAnCE/Deployment/Deployment_DataC.h" +#include "XML_Typedefs.h" +#include "Utils/Exceptions.h" + +#include "Deployment.hpp" +#include "Property_Handler.h" + + +namespace CIAO +{ + namespace Config_Handlers + { + namespace Packaging + { + + IDREF_Base<CORBA::ULong> CID_Handler::IDREF; + + struct Capability_Handler + { + static void handle_capability (const Capability &desc, + ::Deployment::Capability &toconfig) + { + DANCE_TRACE ("Capability_Handler::get_capability"); + + toconfig.name = ACE_TEXT_ALWAYS_CHAR ( desc.name ().c_str ()); + + toconfig.resourceType.length (desc.count_resourceType ()); + std::for_each (desc.begin_resourceType (), + desc.end_resourceType (), + String_Seq_Functor (toconfig.resourceType)); + + toconfig.property.length (desc.count_property ()); + std::for_each (desc.begin_property (), + desc.end_property (), + SatisfierProperty_Functor (toconfig.property)); + } + + static Capability get_capability (const ::Deployment::Capability &src) + { + DANCE_TRACE ("Capability_Handler::get_capability - reverse"); + + Capability retval (ACE_TEXT_CHAR_TO_TCHAR (src.name.in ())); +#if 0 + for (CORBA::ULong i = 0; i < src.resourceType.length (); ++i) + retval.add_resourceType (src.resourceType[i].in ()); + + for (CORBA::ULong i = 0; i < src.property.length (); ++i) + retval.add_property (SatisfierProperty_Handler::get_sat_property (src.property[i])); +#endif + return retval; + } + }; + + typedef Sequence_Handler < Capability, + ::Deployment::Capabilities, + ::Deployment::Capability, + Capability_Handler::handle_capability > Capability_Functor; + + struct IR_Handler + { + static void handle_ir (const ImplementationRequirement &desc, + ::Deployment::ImplementationRequirement &toconfig) + { + DANCE_TRACE ("IR_Handler::get_ir"); + + if (desc.resourceUsage_p ()) + { + switch (desc.resourceUsage ().integral ()) + { + case ResourceUsageKind::None_l: + toconfig.resourceUsage = Deployment::None; + break; + + case ResourceUsageKind::InstanceUsesResource_l: + toconfig.resourceUsage = Deployment::InstanceUsesResource; + break; + + case ResourceUsageKind::ResourceUsesInstance_l: + toconfig.resourceUsage = Deployment::ResourceUsesInstance; + break; + + case ResourceUsageKind::PortUsesResource_l: + toconfig.resourceUsage = Deployment::PortUsesResource; + break; + + case ResourceUsageKind::ResourceUsesPort_l: + toconfig.resourceUsage = Deployment::ResourceUsesPort; + break; + + default: + throw Config_Error (desc.name (), + ACE_TEXT ("Unknown ResourceUsageKind.")); + break; + } + } + + if (desc.resourcePort_p ()) + toconfig.resourcePort = ACE_TEXT_ALWAYS_CHAR ( desc.resourcePort ().c_str ()); + + if (desc.componentPort_p ()) + toconfig.componentPort = ACE_TEXT_ALWAYS_CHAR ( desc.componentPort ().c_str ()); + + toconfig.resourceType = ACE_TEXT_ALWAYS_CHAR ( desc.resourceType ().c_str ()); + toconfig.name = ACE_TEXT_ALWAYS_CHAR ( desc.name ().c_str ()); + + std::for_each (desc.begin_property (), + desc.end_property (), + Property_Functor (toconfig.property )); + } + + static ImplementationRequirement + get_ir (const ::Deployment::ImplementationRequirement &src) + { + DANCE_TRACE ("IR_Handler::get_ir - reverse"); + + ImplementationRequirement retval (ACE_TEXT_CHAR_TO_TCHAR (src.resourceType.in ()), + ACE_TEXT_CHAR_TO_TCHAR (src.name.in ())); + + if (src.resourceUsage.length () == 1) + switch (src.resourceUsage[0]) + { + case Deployment::None: + retval.resourceUsage (ResourceUsageKind::None); + break; + + case Deployment::InstanceUsesResource: + retval.resourceUsage (ResourceUsageKind::InstanceUsesResource); + break; + + case Deployment::ResourceUsesInstance: + retval.resourceUsage (ResourceUsageKind::ResourceUsesInstance); + break; + + case Deployment::PortUsesResource: + retval.resourceUsage (ResourceUsageKind::PortUsesResource); + break; + + case Deployment::ResourceUsesPort: + retval.resourceUsage (ResourceUsageKind::ResourceUsesPort); + break; + + default: + throw Config_Error (ACE_TEXT_CHAR_TO_TCHAR (src.name.in ()), + ACE_TEXT ("Unknown ResourceUsageKind.")); + break; + } + + retval.resourcePort (ACE_TEXT_CHAR_TO_TCHAR (src.resourcePort.in ())); + + retval.componentPort (ACE_TEXT_CHAR_TO_TCHAR (src.componentPort.in ())); +#if 0 + for (CORBA::ULong i = 0; i < src.property.length (); ++i) + retval.add_property (Property_Handler::get_property (src.property[i])); +#endif + return retval; + } + }; + + typedef Sequence_Handler < ImplementationRequirement, + ::Deployment::ImplementationRequirements, + ::Deployment::ImplementationRequirement, + IR_Handler::handle_ir > IR_Functor; + + struct MID_Handler + { + static void handle_mid (const MonolithicImplementationDescription &desc, + ::Deployment::MonolithicImplementationDescription &toconfig) + { + DANCE_TRACE ("MID_Handler::get_mid"); + + toconfig.nodeExecParameter.length (desc.count_nodeExecParameter ()); + std::for_each (desc.begin_nodeExecParameter (), + desc.end_nodeExecParameter (), + Property_Functor (toconfig.nodeExecParameter)); + + toconfig.componentExecParameter.length (desc.count_componentExecParameter ()); + std::for_each (desc.begin_componentExecParameter (), + desc.end_componentExecParameter (), + Property_Functor (toconfig.componentExecParameter)); + + toconfig.deployRequirement.length (desc.count_deployRequirement ()); + while (0) + { + IR_Handler::handle_ir (*(*desc.begin_deployRequirement ()), + toconfig.deployRequirement[0]); + } + std::for_each (desc.begin_deployRequirement (), + desc.end_deployRequirement (), + IR_Functor (toconfig.deployRequirement)); + + toconfig.primaryArtifact.length (desc.count_primaryArtifact ()); + SEQ_HAND_GCC_BUG_WORKAROUND (NIA_Handler::handle_nia, + (*desc.begin_primaryArtifact ()), + toconfig.primaryArtifact); + std::for_each (desc.begin_primaryArtifact (), + desc.end_primaryArtifact (), + NIA_Functor (toconfig.primaryArtifact)); + } + + static MonolithicImplementationDescription + get_mid (const ::Deployment::MonolithicImplementationDescription &/*src*/) + { + DANCE_TRACE ("MID_Handler::get_mid - reverse"); + + MonolithicImplementationDescription retval; +#if 0 + for (CORBA::ULong i = 0; i < src.nodeExecParameter.length (); ++i) + retval.add_nodeExecParameter + (Property_Handler::get_property (src.nodeExecParameter[i])); + + for (CORBA::ULong i = 0; i < src.componentExecParameter.length (); ++i) + retval.add_componentExecParameter + (Property_Handler::get_property (src.componentExecParameter[i])); + + for (CORBA::ULong i = 0; i < src.deployRequirement.length (); ++i) + retval.add_deployRequirement + (IR_Handler::get_ir (src.deployRequirement[i])); + + for (CORBA::ULong i = 0; i < src.primaryArtifact.length (); ++i) + retval.add_primaryArtifact + (NIA_Handler::get_nia (src.primaryArtifact[i])); +#endif + return retval; + } + + }; + + typedef Sequence_Handler < MonolithicImplementationDescription, + ::Deployment::MonolithicImplementationDescriptions, + ::Deployment::MonolithicImplementationDescription, + MID_Handler::handle_mid > MID_Functor; + + + + void + CID_Handler::component_impl_descr ( + const ComponentImplementationDescription &desc, + ::Deployment::ComponentImplementationDescription &toconfig) + { + DANCE_TRACE ("CID_Handler::component_impl_descr"); + + const ComponentImplementationDescription *cid = 0; + std::auto_ptr <ComponentImplementationDescription> xsc_cid; + + if (desc.href_p ()) + { + xsc_cid.reset (CID_Handler::resolve_cid ((desc.href ().c_str ()))); + cid = xsc_cid.get (); + } + else + cid = &desc; + + if (cid->label_p ()) + toconfig.label = ACE_TEXT_ALWAYS_CHAR ( cid->label ().c_str ()); + + if (cid->UUID_p ()) + toconfig.UUID = ACE_TEXT_ALWAYS_CHAR ( cid->UUID ().c_str ()); + + if (cid->implements_p ()) + { // MAJO: We should be able to assume this exists, fix broken interpeters.. + Comp_Intf_Descr_Handler::comp_intf_descr (cid->implements (), + toconfig.implements); + } + + if (cid->assemblyImpl_p ()) + { + toconfig.assemblyImpl.length (1); + CAD_Handler::component_assem_descr (cid->assemblyImpl (), + toconfig.assemblyImpl[0]); + } + else if (cid->monolithicImpl_p ()) + { + toconfig.monolithicImpl.length (1); + MID_Handler::handle_mid (cid->monolithicImpl (), + toconfig.monolithicImpl[0]); + } + else + throw Plan_Error (ACE_TEXT ("ComponentImplementationDescription must have either assemblyImpl or monolithicImpl")); + + // configProperty + toconfig.configProperty.length (cid->count_configProperty ()); + std::for_each (cid->begin_configProperty (), + cid->end_configProperty (), + Property_Functor (toconfig.configProperty)); + + // capability + toconfig.capability.length (cid->count_capability ()); + SEQ_HAND_GCC_BUG_WORKAROUND (Capability_Handler::handle_capability, + (*cid->begin_capability ()), + toconfig.capability); + std::for_each (cid->begin_capability (), + cid->end_capability (), + Capability_Functor (toconfig.capability)); + + // dependsOn + toconfig.dependsOn.length (cid->count_dependsOn ()); + CORBA::ULong pos = 0; + for (ComponentImplementationDescription::dependsOn_const_iterator i = cid->begin_dependsOn (); + i != cid->end_dependsOn (); + ++i) + toconfig.dependsOn[pos++].requiredType = ACE_TEXT_ALWAYS_CHAR ( (*i)->requiredType ().c_str ()); + + // infoProperty + toconfig.infoProperty.length (cid->count_infoProperty ()); + std::for_each (cid->begin_infoProperty (), + cid->end_infoProperty (), + Property_Functor (toconfig.infoProperty)); + + } + + ComponentImplementationDescription + CID_Handler::component_impl_descr (const Deployment::ComponentImplementationDescription& src) + { + DANCE_TRACE ("CID_Handler::component_impl_descr - reverse"); + + ComponentImplementationDescription retval; + + retval.label (ACE_TEXT_CHAR_TO_TCHAR (src.label.in ())); + retval.UUID (ACE_TEXT_CHAR_TO_TCHAR (src.UUID.in ())); + + { + retval.implements (Comp_Intf_Descr_Handler::comp_intf_descr (src.implements)); + } + + if (src.assemblyImpl.length () == 1) + { + retval.assemblyImpl (CAD_Handler::component_assem_descr (src.assemblyImpl[0])); + } + else if (src.monolithicImpl.length () == 1) + { + retval.monolithicImpl (MID_Handler::get_mid (src.monolithicImpl[0])); + } + else + ACE_DEBUG ((LM_WARNING, "Warning: ComponentImplementationDescription lacks " + "either a required assemblyImpl or monolithicImpl, or has too many")); +#if 0 + for (CORBA::ULong i = 0; i < src.configProperty.length (); ++i) + { + retval.add_configProperty ( + Property_Handler::get_property (src.configProperty[i])); + } + + for (CORBA::ULong i = 0; i < src.dependsOn.length (); ++i) + { + retval.add_dependsOn (ImplementationDependency (src.dependsOn[i].requiredType.in ())); + } + + for (CORBA::ULong i = 0; i < src.infoProperty.length (); ++i) + { + retval.add_infoProperty ( + Property_Handler::get_property (src.infoProperty[i])); + } +#endif + return retval; + } + + ComponentImplementationDescription * + CID_Handler::resolve_cid (const ACE_TCHAR *uri) + { + DANCE_TRACE ("CID_Handler::resolve_cid"); + + xercesc::DOMDocument *dom = XML_Helper::XML_HELPER.create_dom (uri); + + if (!dom) + throw Parse_Error (ACE_TEXT ("Unable to create DOM for CID")); + + try { + return new ComponentImplementationDescription + (reader::componentImplementationDescription (dom)); + } + catch (...) { + throw Parse_Error (ACE_TEXT ("Unable to create XSC structure for CID")); + } + } + } + + } +} diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CID_Handler.h b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CID_Handler.h new file mode 100644 index 00000000000..d00304d8cfe --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CID_Handler.h @@ -0,0 +1,67 @@ +/** + * @file CID_Handler.h + * + * $Id$ + * + * @author William Otte <wotte@dre.vanderbilt.edu + */ + +#ifndef CIAO_PACKAGING_CID_HANDLER_H +#define CIAO_PACKAGING_CID_HANDLER_H + +#include /**/ "ace/pre.h" + +#include "IDREF_Base.h" +#include "Package_Handlers/Packaging_Handlers_Export.h" +#include "tao/Basic_Types.h" + +namespace Deployment +{ + struct ComponentImplementationDescription; +} + + +namespace CIAO +{ + namespace Config_Handlers + { + class ComponentImplementationDescription; + + namespace Packaging + { + + /** + * @class CID_Handler + * + * @brief Handler class for <CCMComponentImplementationDescription> types. + * + * This class defines handler methods to map values from + * XSC objects, parsed from the descriptor files, to the + * corresponding CORBA IDL type for the schema element. + * + */ + class Packaging_Handlers_Export CID_Handler + { + + public: + /// Maps the values from the XSC object + /// <ComponentImplementationDescription> to the CORBA IDL type + /// <Deployment::ComponentImplementationDescription>. + static void component_impl_descr (const ComponentImplementationDescription &desc, + ::Deployment::ComponentImplementationDescription &toconfig); + + static IDREF_Base<CORBA::ULong> IDREF; + + static ComponentImplementationDescription + component_impl_descr (const Deployment::ComponentImplementationDescription& src); + + private: + + static ComponentImplementationDescription * resolve_cid (const ACE_TCHAR *uri); + }; + } + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_PACKAGING_CID_HANDLER_H*/ diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CPD_Handler.cpp b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CPD_Handler.cpp new file mode 100644 index 00000000000..ba2c14309b2 --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CPD_Handler.cpp @@ -0,0 +1,160 @@ +// $Id$ +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "Package_Handlers/CPD_Handler.h" +#include "Package_Handlers/CID_Handler.h" +#include "Package_Handlers/Comp_Intf_Descr_Handler.h" +#include "Basic_Deployment_Data.hpp" +#include "DAnCE/Deployment/Deployment_Packaging_DataC.h" +#include "Deployment.hpp" +#include "Utils/Exceptions.h" +#include "Property_Handler.h" + +namespace CIAO +{ + namespace Config_Handlers + { + namespace Packaging + { + struct Packaging_Handlers_Export PCI_Handler + { + static void handle_pci (const PackagedComponentImplementation &desc, + ::Deployment::PackagedComponentImplementation &toconfig) + { + DANCE_TRACE ("PCI_Handler::get_pci"); + toconfig.name = ACE_TEXT_ALWAYS_CHAR (desc.name ().c_str ()); + + CID_Handler::component_impl_descr (desc.referencedImplementation (), + toconfig.referencedImplementation); + } + + static PackagedComponentImplementation + get_pci (const ::Deployment::PackagedComponentImplementation &src) + { + DANCE_TRACE ("PCI_Handler::get_pci - reverse"); + return PackagedComponentImplementation (ACE_TEXT_CHAR_TO_TCHAR (src.name.in ()), + CID_Handler::component_impl_descr (src.referencedImplementation)); + } + }; + + typedef Sequence_Handler < PackagedComponentImplementation, + ::Deployment::PackagedComponentImplementations, + ::Deployment::PackagedComponentImplementation, + PCI_Handler::handle_pci > PCI_Functor; + + + void + CPD_Handler::handle_component_package_descr (const ComponentPackageDescription &desc, + ::Deployment::ComponentPackageDescription &toconfig) + { + DANCE_TRACE ("CPD_Handler::component_package_descr"); + + auto_ptr < ComponentPackageDescription > xsc_cpd; + const ComponentPackageDescription *cpd = 0; + + if (desc.href_p ()) + { + xsc_cpd.reset (CPD_Handler::resolve_cpd (desc.href ().c_str ())); + cpd = xsc_cpd.get (); + } + else + cpd = &desc; + + if (cpd->label_p ()) + toconfig.label = ACE_TEXT_ALWAYS_CHAR (cpd->label ().c_str ()); + + if (cpd->UUID_p ()) + toconfig.UUID = ACE_TEXT_ALWAYS_CHAR (cpd->UUID ().c_str ()); + + // CID + if (cpd->realizes_p ()) + Comp_Intf_Descr_Handler::comp_intf_descr (cpd->realizes (), + toconfig.realizes); + + // Config Properties + toconfig.configProperty.length (desc.count_configProperty ()); + std::for_each (cpd->begin_infoProperty (), + cpd->end_infoProperty (), + Property_Functor (toconfig.configProperty)); + + // ACE_ERROR ((LM_ERROR, "***** Count of PCIs is %i\n", + // cpd->count_implementation ())); + + // Packaged Component Implementations + toconfig.implementation.length ( cpd->count_implementation ()); + SEQ_HAND_GCC_BUG_WORKAROUND (PCI_Handler::handle_pci, + (*cpd->begin_implementation ()), + toconfig.implementation); + std::for_each (cpd->begin_implementation (), + cpd->end_implementation (), + PCI_Functor (toconfig.implementation)); + + // Info Properties + toconfig.infoProperty.length (cpd->count_infoProperty ()); + std::for_each (cpd->begin_infoProperty (), + cpd->end_infoProperty (), + Property_Functor (toconfig.infoProperty)); + } + + ComponentPackageDescription + CPD_Handler::component_package_descr (const Deployment::ComponentPackageDescription& src) + { + DANCE_TRACE ("CPD_Handler::component_package_descr - reverse"); + ComponentPackageDescription toconfig; + + if (src.label.in () != 0) + toconfig.label (ACE_TEXT_CHAR_TO_TCHAR (src.label.in ())); + + if (src.UUID.in () != 0) + toconfig.UUID (ACE_TEXT_CHAR_TO_TCHAR (src.UUID.in ())); + + { + toconfig.realizes + (Comp_Intf_Descr_Handler::comp_intf_descr (src.realizes)); + } +#if 0 + for (size_t i = 0; i < src.configProperty.length (); ++i) + { + toconfig.add_configProperty ( + Property_Handler::get_property (src.configProperty[i])); + } + + { // Packaged Component Implementations + for (size_t i = 0; i < src.implementation.length (); ++i) + toconfig.add_implementation ( + PCI_Handler::get_pci (src.implementation[i])); + } + + for (size_t i = 0; i < src.infoProperty.length (); ++i) + { + toconfig.add_infoProperty ( + Property_Handler::get_property (src.infoProperty[i])); + } +#endif + return toconfig; + } + + ComponentPackageDescription * CPD_Handler::resolve_cpd (const ACE_TCHAR *uri) + { + DANCE_TRACE ("CPD_Handler::resolve_cpd"); + if (!XML_Helper::XML_HELPER.is_initialized ()) + return 0; + + xercesc::DOMDocument* dom = + XML_Helper::XML_HELPER.create_dom (uri); + + if (!dom) + throw Parse_Error (ACE_TEXT ("Unable to create DOM for component package description")); + + try { + //ACE_ERROR ((LM_ERROR, "Creating new CPD XSC Object\n")); + return new ComponentPackageDescription (reader::componentPackageDescription (dom)); + } + catch (...) { + throw Parse_Error (ACE_TEXT ("Unable to create XSC structure for CID")); + } + } + } + + + } +} diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CPD_Handler.h b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CPD_Handler.h new file mode 100644 index 00000000000..049b2a72cb2 --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/CPD_Handler.h @@ -0,0 +1,74 @@ +//================================================ +/** + * @file CPD_Handler.h + * + * $Id$ + * + * @author Ming Xiong <mxiong@dre.vanderbilt.edu> + */ +//================================================ + +#ifndef CIAO_CONFIG_HANDLERS_STD_CPD_HANDLER_H +#define CIAO_CONFIG_HANDLERS_STD_CPD_HANDLER_H + +#include /**/ "ace/pre.h" + +#include <memory> +#include "XML_Typedefs.h" +#include "Utils/Functors.h" +#include "Package_Handlers/Packaging_Handlers_Export.h" + +namespace Deployment +{ + struct ComponentPackageDescription; + class ComponentPackageDescriptions; +} + +namespace CIAO +{ + namespace Config_Handlers + { + class ComponentPackageDescription; + + namespace Packaging + { + + /* + * @class CPD_Handler + * + * @brief Handler class for <CCMComponentPackageDescription> types. + * + * This class defines handler methods to map values from + * XSC objects, parsed from the descriptor files, to the + * corresponding CORBA IDL type for the schema element. + * + */ + class Packaging_Handlers_Export CPD_Handler + { + + public: + /// Maps the values from the XSC object + /// <ComponentPackageDescription> to the CORBA IDL type + /// <Deployment::ComponentPackageDescription>. + static void handle_component_package_descr (const ComponentPackageDescription &desc, + ::Deployment::ComponentPackageDescription &toconfig); + + static ComponentPackageDescription + component_package_descr (const Deployment::ComponentPackageDescription& src); + private: + static ComponentPackageDescription * resolve_cpd (const ACE_TCHAR *uri); + + }; + + typedef Sequence_Handler < ComponentPackageDescription, + ::Deployment::ComponentPackageDescriptions, + ::Deployment::ComponentPackageDescription, + CPD_Handler::handle_component_package_descr > CPD_Functor; + + } + + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_CONFIG_HANDLERS_CPD_HANDLER_H*/ diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.cpp b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.cpp new file mode 100644 index 00000000000..c4f6058505e --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.cpp @@ -0,0 +1,165 @@ +// $Id$ +#include "tao/AnyTypeCode/TypeCode.h" +#include "Comp_Intf_Descr_Handler.h" +#include "XML_Typedefs.h" +#include "Utils/Exceptions.h" +#include "Utils/Functors.h" +#include "DataType_Handler.h" +#include "Property_Handler.h" +#include "Deployment.hpp" +#include "Package_Handlers/CPD_Handler.h" +#include "Config_Handlers/CPD_Handler.h" +#include "DAnCE/Logger/Log_Macros.h" +namespace CIAO +{ + namespace Config_Handlers + { + namespace Packaging + { + struct Comp_Prop_Handler + { + static void handle_cpd (const ComponentPropertyDescription &desc, + ::Deployment::ComponentPropertyDescription &toconfig) + { + DANCE_TRACE ("Comp_Prop_Handler::get_cpd"); + + toconfig.name = ACE_TEXT_ALWAYS_CHAR (desc.name ().c_str ()); + DataType_Handler::data_type (desc.type (), + toconfig.type); + } + + static ComponentPropertyDescription + get_cpd (const ::Deployment::ComponentPropertyDescription &src) + { + DANCE_TRACE ("Comp_Prop_Handler::get_cpd - reverse"); + + return ComponentPropertyDescription (ACE_TEXT_CHAR_TO_TCHAR (src.name.in ()), + DataType_Handler::data_type (src.type)); + } + + }; + + typedef Sequence_Handler < ComponentPropertyDescription, + ::Deployment::ComponentPropertyDescriptions, + ::Deployment::ComponentPropertyDescription, + Comp_Prop_Handler::handle_cpd > Comp_Prop_Functor; + + + void + Comp_Intf_Descr_Handler::comp_intf_descr ( + const ComponentInterfaceDescription &desc, + ::Deployment::ComponentInterfaceDescription &toconfig) + { + DANCE_TRACE ("Comp_Intf_Descr_Handler::comp_intf_descr"); + + const ComponentInterfaceDescription *cid = 0; + std::auto_ptr <ComponentInterfaceDescription> safe_cid; + + if (desc.href_p ()) + { + safe_cid.reset (Comp_Intf_Descr_Handler::resolve_cid (desc.href ().c_str ())); + cid = safe_cid.get (); + } + else + cid = &desc; + + if (cid->label_p ()) + toconfig.label = ACE_TEXT_ALWAYS_CHAR (cid->label ().c_str ()); + + if (cid->UUID_p ()) + toconfig.UUID = ACE_TEXT_ALWAYS_CHAR (cid->UUID ().c_str ()); + + // MAJO: SpecificType should be required. + if (cid->specificType_p ()) + toconfig.specificType = ACE_TEXT_ALWAYS_CHAR (cid->specificType ().c_str ()); + + toconfig.supportedType.length (cid->count_supportedType ()); + std::for_each (cid->begin_supportedType (), + cid->end_supportedType (), + String_Seq_Functor (toconfig.supportedType)); + + toconfig.idlFile.length (cid->count_idlFile ()); + std::for_each (cid->begin_idlFile (), + cid->end_idlFile (), + String_Seq_Functor (toconfig.idlFile)); + + toconfig.configProperty.length (cid->count_configProperty ()); + std::for_each (cid->begin_configProperty (), + cid->end_configProperty (), + Property_Functor (toconfig.configProperty)); + + toconfig.port.length (cid->count_port ()); + std::for_each (cid->begin_port (), + cid->end_port (), + CIAO::Config_Handlers::CPD_Functor (toconfig.port)); + + toconfig.property.length (cid->count_property ()); + SEQ_HAND_GCC_BUG_WORKAROUND (Comp_Prop_Handler::handle_cpd, + (*cid->begin_property ()), + toconfig.property); + std::for_each (cid->begin_property (), + cid->end_property (), + Comp_Prop_Functor (toconfig.property)); + + toconfig.infoProperty.length (cid->count_infoProperty ()); + std::for_each (cid->begin_infoProperty (), + cid->end_infoProperty (), + Property_Functor (toconfig.infoProperty)); + } + + + ComponentInterfaceDescription + Comp_Intf_Descr_Handler::comp_intf_descr ( + const ::Deployment::ComponentInterfaceDescription &src) + { + DANCE_TRACE ("Comp_Intf_Descr_Handler::comp_intf_descr - reverse"); + ComponentInterfaceDescription retval; + + retval.label (ACE_TEXT_CHAR_TO_TCHAR (src.label.in ())); + retval.UUID (ACE_TEXT_CHAR_TO_TCHAR (src.UUID.in ())); + retval.specificType (ACE_TEXT_CHAR_TO_TCHAR (src.specificType.in ())); +#if 0 + for (CORBA::ULong i = 0; i < src.supportedType.length (); ++i) + retval.add_supportedType (src.supportedType[i].in ()); + + for (CORBA::ULong i = 0; i < src.idlFile.length (); ++i) + retval.add_idlFile (src.idlFile[i].in ()); + + for (CORBA::ULong i = 0; i < src.configProperty.length (); ++i) + retval.add_configProperty ( + Property_Handler::get_property (src.configProperty[i])); + + for (CORBA::ULong i = 0; i < src.port.length (); ++i) + retval.add_port + (CIAO::Config_Handlers::CPD_Handler::component_port_description (src.port[i])); + + for (CORBA::ULong i = 0; i < src.property.length (); ++i) + retval.add_property (Comp_Prop_Handler::get_cpd (src.property[i])); + + for (CORBA::ULong i = 0; i < src.infoProperty.length (); ++i) + retval.add_infoProperty ( + Property_Handler::get_property (src.infoProperty[i])); +#endif + return retval; + } + + ComponentInterfaceDescription * + Comp_Intf_Descr_Handler::resolve_cid (const ACE_TCHAR *uri) + { + DANCE_TRACE ("Comp_Intf_Descr_Handler::resolve_cid"); + + xercesc::DOMDocument *dom = XML_Helper::XML_HELPER.create_dom (uri); + + if (!dom) + throw Parse_Error (ACE_TEXT ("Unable to create DOM for Component Interface Description.")); + + try { + return new ComponentInterfaceDescription + (reader::componentInterfaceDescription (dom)); + } + catch (...) { + throw Parse_Error (ACE_TEXT ("Unable to create XSC structure for Component Interface Description")); + } + } + } + }} diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.h b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.h new file mode 100644 index 00000000000..4655edfa97b --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.h @@ -0,0 +1,54 @@ +/** + * @file Comp_Intf_Descr_Handler.h + * @author William Otte <wotte@dre.vanderbilt.edu> + * + * $Id$ + */ + +#ifndef CIAO_PACKAGING_COMP_INTF_DESCR_HANDLER_H +#define CIAO_PACKAGING_COMP_INTF_DESCR_HANDLER_H + +#include /**/ "ace/pre.h" + +#include "XML_Typedefs.h" +#include "DAnCE/Deployment/Deployment_Packaging_DataC.h" +#include "Package_Handlers/Packaging_Handlers_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +namespace CIAO +{ + namespace Config_Handlers + { + class ComponentInterfaceDescription; + + namespace Packaging + { + + /** + * @class Comp_Intf_Descr_Handler + * + * @brief Handler class for ComponentInterfaceDescription. + */ + class Packaging_Handlers_Export Comp_Intf_Descr_Handler + { + public: + static void comp_intf_descr (const ComponentInterfaceDescription &descr, + ::Deployment::ComponentInterfaceDescription &toconfig); + + static ComponentInterfaceDescription + comp_intf_descr (const ::Deployment::ComponentInterfaceDescription &src); + + private: + static ComponentInterfaceDescription *resolve_cid (const ACE_TCHAR *uri); + }; + } + } +} + +#include /**/ "ace/post.h" + +#endif /* CIAO_PACKAGING_COMP_INTF_DESCR_HANDLER_H */ diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/IAD_Handler.cpp b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/IAD_Handler.cpp new file mode 100644 index 00000000000..99fe7fe2ade --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/IAD_Handler.cpp @@ -0,0 +1,124 @@ +// $Id$ +#include "Package_Handlers/IAD_Handler.h" +#include "Package_Handlers/NIA_Handler.h" +#include "Basic_Deployment_Data.hpp" +#include "Property_Handler.h" +#include "Req_Handler.h" +#include "Utils/Functors.h" +#include "Utils/Exceptions.h" +#include "XML_Typedefs.h" + +#include "Deployment.hpp" +#include "DAnCE/Logger/Log_Macros.h" + +namespace CIAO +{ + namespace Config_Handlers + { + namespace Packaging + { + + void + IAD_Handler::impl_artifact_descr (const ImplementationArtifactDescription &desc, + ::Deployment::ImplementationArtifactDescription &toconfig) + { + DANCE_TRACE ("IAD_Handler::impl_artifact_descr"); + + const ImplementationArtifactDescription *iad = 0; + std::auto_ptr <ImplementationArtifactDescription> safe_iad; + + if (desc.href_p ()) + { + safe_iad.reset (IAD_Handler::resolve_iad (desc.href ().c_str ())); + iad = safe_iad.get (); + } + else + iad = &desc; + + + if (iad->label_p ()) + toconfig.label = ACE_TEXT_ALWAYS_CHAR ( iad->label ().c_str ()); + + if (iad->UUID_p ()) + toconfig.UUID = ACE_TEXT_ALWAYS_CHAR (iad->UUID ().c_str ()); + + toconfig.location.length (iad->count_location ()); + std::for_each (iad->begin_location (), + iad->end_location (), + String_Seq_Functor (toconfig.location)); + + toconfig.dependsOn.length (iad->count_dependsOn ()); + SEQ_HAND_GCC_BUG_WORKAROUND (NIA_Handler::handle_nia, + (*desc.begin_dependsOn ()), + toconfig.dependsOn); + std::for_each (iad->begin_dependsOn (), + iad->end_dependsOn (), + NIA_Functor (toconfig.dependsOn)); + + toconfig.execParameter.length (iad->count_execParameter ()); + std::for_each (iad->begin_execParameter (), + iad->end_execParameter (), + Property_Functor (toconfig.execParameter)); + + toconfig.infoProperty.length (iad->count_infoProperty ()); + std::for_each (iad->begin_infoProperty (), + iad->end_infoProperty (), + Property_Functor (toconfig.infoProperty)); + + toconfig.deployRequirement.length (iad->count_deployRequirement ()); + std::for_each (iad->begin_deployRequirement (), + iad->end_deployRequirement (), + Requirement_Functor (toconfig.deployRequirement )); + } + + ImplementationArtifactDescription + IAD_Handler::impl_artifact_descr (const ::Deployment::ImplementationArtifactDescription &src) + { + DANCE_TRACE ("IAD_Handler::impl_artifact_descr - reverse"); + ImplementationArtifactDescription retval; + + retval.label (ACE_TEXT_CHAR_TO_TCHAR (src.label.in ())); + retval.UUID (ACE_TEXT_CHAR_TO_TCHAR (src.UUID.in ())); +#if 0 + for (CORBA::ULong i = 0; i < src.location.length (); ++i) + retval.add_location (src.location[i].in ()); + + for (CORBA::ULong i = 0; i < src.dependsOn.length (); ++i) + retval.add_dependsOn (NIA_Handler::get_nia (src.dependsOn[i])); + + for (CORBA::ULong i = 0; i < src.execParameter.length (); ++i) + retval.add_execParameter + (Property_Handler::get_property (src.execParameter[i])); + + for (CORBA::ULong i = 0; i < src.infoProperty.length (); ++i) + retval.add_infoProperty + (Property_Handler::get_property ( src.infoProperty[i])); + + for (CORBA::ULong i = 0; i < src.deployRequirement.length (); ++i) + retval.add_deployRequirement + (Req_Handler::get_requirement (src.deployRequirement[i])); +#endif + return retval; + } + + ImplementationArtifactDescription * IAD_Handler::resolve_iad (const ACE_TCHAR *uri) + { + DANCE_TRACE ("IAD_Handler::resolve_iad"); + + xercesc::DOMDocument *dom = XML_Helper::XML_HELPER.create_dom (uri); + + if (!dom) + throw Parse_Error (ACE_TEXT ("Unable to create DOM for IAD")); + + try { + return new ImplementationArtifactDescription + (reader::implementationArtifactDescription (dom)); + } + catch (...) { + throw Parse_Error (ACE_TEXT ("Unable to create XSC structure for IAD")); + } + } + + } + } +} diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/IAD_Handler.h b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/IAD_Handler.h new file mode 100644 index 00000000000..89fdab073bf --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/IAD_Handler.h @@ -0,0 +1,66 @@ +//================================================ +/** + * @file IAD_Handler.h + * + * $Id$ + * + * @author William Otte <wotte@dre.vanderbilt.edu> + */ +//================================================ + +#ifndef CIAO_CONFIG_HANDLERS_STD_IAD_HANDLER_H +#define CIAO_CONFIG_HANDLERS_STD_IAD_HANDLER_H + +#include /**/ "ace/pre.h" + +#include "Package_Handlers/Packaging_Handlers_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace Deployment +{ + struct ImplementationArtifactDescription; + struct ImplementationArtifactDescriptions; +} + +namespace CIAO +{ + namespace Config_Handlers + { + class ImplementationArtifactDescription; + namespace Packaging + { + /* + * @class IAD_Handler + * + * @brief Handler class for <CCMImplementationArtifactDescription> types. + * + * This class defines handler methods to map values from + * XSC objects, parsed from the descriptor files, to the + * corresponding CORBA IDL type for the schema element. + * + */ + class Packaging_Handlers_Export IAD_Handler + { + public: + /// Maps the values from the XSC object + /// <ImplementationArtifactDescription> to the CORBA IDL type + /// <Deployment::ImplementationArtifactDescription>. + static void + impl_artifact_descr (const ImplementationArtifactDescription &desc, + ::Deployment::ImplementationArtifactDescription &toconfig); + + + static ImplementationArtifactDescription + impl_artifact_descr (const Deployment::ImplementationArtifactDescription& src); + + static ImplementationArtifactDescription * resolve_iad (const ACE_TCHAR *uri); + }; + } + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_CONFIG_HANDLERS_STD_IAD_HANDLER_H*/ diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/NIA_Handler.h b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/NIA_Handler.h new file mode 100644 index 00000000000..923104dc27b --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/NIA_Handler.h @@ -0,0 +1,65 @@ +/** + * @file NIA_Handler.h + * @author William Otte <wotte@dre.vanderbilt.edu> + * $Id$ + */ + +#ifndef CIAO_PACKAGING_NIA_HANDLER_H +#define CIAO_PACKAGING_NIA_HANDLER_H + +#include /**/ "ace/pre.h" +#include "Package_Handlers/Packaging_Handlers_Export.h" +#include "Utils/Functors.h" +#include "DAnCE/Deployment/Deployment_Packaging_DataC.h" +#include "iad.hpp" + +namespace Deployment +{ + struct NamedImplementationArtifact; + class NamedImplementationArtifacts; +} + +namespace CIAO +{ + namespace Config_Handlers + { + class NamedImplementationArtifact; + + namespace Packaging + { + /** + * @class NIA_Handler + * @brief Handler class for NamedImplementationArtifact types. + */ + class Packaging_Handlers_Export NIA_Handler + { + public: + static void handle_nia (const NamedImplementationArtifact &desc, + ::Deployment::NamedImplementationArtifact &toconfig) + { + toconfig.name = ACE_TEXT_ALWAYS_CHAR (desc.name ().c_str ()); + IAD_Handler::impl_artifact_descr (desc.referencedArtifact (), + toconfig.referencedArtifact); + } + + + static NamedImplementationArtifact + get_nia (const ::Deployment::NamedImplementationArtifact &src) + { + return NamedImplementationArtifact (ACE_TEXT_CHAR_TO_TCHAR (src.name.in ()), + IAD_Handler::impl_artifact_descr (src.referencedArtifact)); + } + + }; + + typedef Sequence_Handler < NamedImplementationArtifact, + ::Deployment::NamedImplementationArtifacts, + ::Deployment::NamedImplementationArtifact, + NIA_Handler::handle_nia > NIA_Functor; + } + } +} + +#include /**/ "ace/post.h" + +#endif /* CIAO_PACKAGING_NIA_HANDLER_H */ diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PCD_Handler.cpp b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PCD_Handler.cpp new file mode 100644 index 00000000000..791f153d126 --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PCD_Handler.cpp @@ -0,0 +1,165 @@ +// $Id$ +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "DAnCE/Logger/Log_Macros.h" +#include "DAnCE/Deployment/Deployment_Packaging_DataC.h" +#include "XML_Typedefs.h" +#include "XML/XercesString.h" +#include "Utils/Exceptions.h" +#include "Package_Handlers/PCD_Handler.h" +#include "Package_Handlers/CPD_Handler.h" +#include "toplevel.hpp" +#include "Deployment.hpp" +#include "Property_Handler.h" +#include "Req_Handler.h" + +#include <memory> + +using CIAO::XML::XStr; + +namespace CIAO +{ + namespace Config_Handlers + { + namespace Packaging + { + void + PCD_Handler::package_config (const ACE_TCHAR *uri, + ::Deployment::PackageConfiguration &toconfig) + { + XERCES_CPP_NAMESPACE::DOMDocument *dom = XML_Helper::XML_HELPER.create_dom (uri); + + if (dom == 0) + { + std::basic_string<ACE_TCHAR> error (ACE_TEXT ("Unable to open file: ")); + error += uri; + throw Parse_Error (error); + } + + XStr root = dom->getDocumentElement ()->getTagName (); + + if (root == XStr (ACE_TEXT ("Deployment:topLevelPackageDescription"))) + { + TopLevelPackageDescription tpd; + + tpd = reader::topLevelPackageDescription (dom); + + PCD_Handler::package_config (*(*tpd.begin_package ()), + toconfig); + } + else if (root == XStr (ACE_TEXT ("Deployment:packageConfiguration"))) + { + PackageConfiguration pcd; + pcd = reader::packageConfiguration (dom); + PCD_Handler::package_config (pcd, toconfig); + } + else + { + std::string error ("Invliad file passed to package_config, has base "); + + char *croot = xercesc::XMLString::transcode (root); + + error += croot; + + delete [] croot; + + throw Plan_Error (ACE_TEXT ("Invalid file passed to package_config, had base")); + } + } + + void + PCD_Handler::package_config (const PackageConfiguration &desc, + ::Deployment::PackageConfiguration &toconfig) + { + DANCE_TRACE ("PCD_Handler::package_config"); + std::auto_ptr < PackageConfiguration > xsc_pcd; + + const PackageConfiguration *pcd; + + if (desc.contentLocation_p ()) + { + // Take ownership of the resolved pcd + xsc_pcd.reset (PCD_Handler::resolve_package_config (desc.contentLocation ().c_str ())); + pcd = xsc_pcd.get (); + } + else + pcd = &desc; + + if (pcd->label_p ()) + toconfig.label = + ACE_TEXT_ALWAYS_CHAR (pcd->label ().c_str ()); + + if (pcd->UUID_p ()) + toconfig.UUID = + ACE_TEXT_ALWAYS_CHAR (pcd->UUID ().c_str ()); + + if (pcd->basePackage_p ()) + { + toconfig.basePackage.length (1); + CPD_Handler::handle_component_package_descr (pcd->basePackage (), + toconfig.basePackage [0]); + } + + // @@ MAJO: Support other elements present here. + + toconfig.configProperty.length (desc.count_configProperty ()); + std::for_each (desc.begin_configProperty (), + desc.end_configProperty (), + Property_Functor (toconfig.configProperty)); + + toconfig.selectRequirement.length (desc.count_selectRequirement ()); + std::for_each (desc.begin_selectRequirement (), + desc.end_selectRequirement (), + Requirement_Functor (toconfig.selectRequirement)); + + } + + PackageConfiguration + PCD_Handler::package_config (const Deployment::PackageConfiguration& src) + { + DANCE_TRACE ("PCD_Handler::package_config - reverse"); + PackageConfiguration pcd = PackageConfiguration (); + + if (src.label.in () != 0) + pcd.label (ACE_TEXT_CHAR_TO_TCHAR (src.label.in ())); + + if (src.UUID.in () != 0) + pcd.UUID (ACE_TEXT_CHAR_TO_TCHAR (src.UUID.in ())); + + if (src.basePackage.length () > 0) + { + ACE_DEBUG ((LM_DEBUG, "5\n")); + pcd.basePackage (CPD_Handler::component_package_descr (src.basePackage[0])); + } +#if 0 + // @@ MAJO: Support other elements present here. + for (CORBA::ULong i = 0; i < src.configProperty.length (); ++i) + pcd.add_configProperty (Property_Handler::get_property (src.configProperty[i])); + + for (CORBA::ULong i = 0; i < src.selectRequirement.length (); ++i) + pcd.add_selectRequirement (Req_Handler::get_requirement (src.selectRequirement[i])); +#endif + return pcd; + + } + + PackageConfiguration * PCD_Handler::resolve_package_config (const ACE_TCHAR *uri) + { + xercesc::DOMDocument* dom = + XML_Helper::XML_HELPER.create_dom (uri); + + if (!dom) + throw Parse_Error (ACE_TEXT ("Unable to create DOM for PackageConfiguration")); + + try { + return new PackageConfiguration (reader::packageConfiguration (dom)); + } + catch (...) { + throw Parse_Error (ACE_TEXT ("Unable to create XSC structure for PackageConfiguration")); + } + + } + + + } + } +} diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PCD_Handler.h b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PCD_Handler.h new file mode 100644 index 00000000000..b1a0c377d9d --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PCD_Handler.h @@ -0,0 +1,69 @@ +//================================================ +/** + * @file PCD_Handler.h + * + * $Id$ + * + * @author William Otte <wotte@dre.vanderbilt.edu> + */ +//================================================ + +#ifndef CIAO_CONFIG_HANDLERS_PCD_HANDLER_H +#define CIAO_CONFIG_HANDLERS_PCD_HANDLER_H + +#include /**/ "ace/pre.h" + +#include "Packaging_Handlers_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace Deployment +{ + struct PackageConfiguration; +} + +namespace CIAO +{ + namespace Config_Handlers + { + class PackageConfiguration; + + namespace Packaging + { + /* + * @class PCD_Handler + * + * @brief Handler class for <CCMPackageConfiguration> types. + * + * This class defines handler methods to map values from + * XSC objects, parsed from the descriptor files, to the + * corresponding CORBA IDL type for the schema element. + * + */ + class Packaging_Handlers_Export PCD_Handler + { + + public: + static void package_config (const ACE_TCHAR *uri, + ::Deployment::PackageConfiguration &toconfig); + + /// Maps the values from the XSC object + /// <PackageConfiguration> to the CORBA IDL type + /// <Deployment::PackageConfiguration>. + static void package_config (const PackageConfiguration &desc, + ::Deployment::PackageConfiguration &toconfig); + + static PackageConfiguration package_config (const Deployment::PackageConfiguration& src); + + private: + static PackageConfiguration *resolve_package_config (const ACE_TCHAR *uri); + }; + } + + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_CONFIG_HANDLERS_STD_PCD_HANDLER_H*/ diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PC_Intf.cpp b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PC_Intf.cpp new file mode 100644 index 00000000000..5bddb09af60 --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PC_Intf.cpp @@ -0,0 +1,75 @@ +// $Id$ + +#include "STD_PC_Intf.h" +#include "Utils/XML_Helper.h" +#include "Deployment.hpp" +#include "STD_PCD_Handler.h" +#include "ciao/Packaging_DataC.h" +#include "DAnCE/Logger/Log_Macros.h" + +namespace CIAO +{ + namespace Config_Handlers + { + STD_PC_Intf::STD_PC_Intf (const char *file) + { + if (!this->prepare_PC (file)) + throw; + } + + bool + STD_PC_Intf::prepare_PC (const char *file) + { + DANCE_TRACE("STD_PC_Intf::prepare_PC"); + + ACE_Auto_Ptr<XML_Helper> helper (new XML_Helper); + + if (!helper->is_initialized ()) + return false; + + // parse the .pcd (PackageConfigurationDescription) file + xercesc::DOMDocument *dom = + helper->create_dom (file); + + if (!dom) + return false; + + + PackageConfiguration pc = + packageConfiguration (dom); + + + Deployment::PackageConfiguration idl_pc; + + + STD_PCD_Handler pcd_handler (helper.get ()); + + pcd_handler.package_config (pc, + idl_pc); + + + Deployment::PackageConfiguration *p_idl_pc = + new Deployment::PackageConfiguration (idl_pc); + + // let ACE_Auto_Ptr take over + this->idl_pc_.reset (p_idl_pc); + + if (this->idl_pc_.get ()) + return true; + + return false; + } + + ::Deployment::PackageConfiguration const * + STD_PC_Intf::get_PC (void) const + { + return this->idl_pc_.get (); + } + + ::Deployment::PackageConfiguration * + STD_PC_Intf::get_PC (void) + { + return this->idl_pc_.release (); + } + } +} diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PC_Intf.h b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PC_Intf.h new file mode 100644 index 00000000000..c15ae0389b9 --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/PC_Intf.h @@ -0,0 +1,58 @@ +//============================================================== +/** + * @file PC_Intf.h + * + * $Id$ + * + * @author Ming Xiong <mxiong@dre.vanderbilt.edu> + */ +//================================================================ + +#ifndef CIAO_CONFIG_STD_PC_INTF_H +#define CIAO_CONFIG_STD_PC_INTF_H +#include /**/ "ace/pre.h" + +#include "Config_Handlers_Export.h" + +#include "ace/Auto_Ptr.h" + + +namespace Deployment +{ + struct PackageConfiguration ; +} + +namespace CIAO +{ + namespace Config_Handlers + { + /* + * @class PC_Intf + * + * @brief Wrapper class for PackageConfiguration extraction + * + * This class defines wrapper functions for extracting + * PackageConfiguration IDL structures from XSC structures. + * It serves as the public interface used by application + * developers. + * + */ + class Config_Handlers_Export STD_PC_Intf + { + public: + STD_PC_Intf (const char *file); + + ::Deployment::PackageConfiguration const *get_PC (void) const; + ::Deployment::PackageConfiguration *get_PC (void); + + protected: + bool prepare_PC (const char *file); + + private: + ACE_Auto_Ptr< ::Deployment::PackageConfiguration> idl_pc_; + }; + } +} + +#include /**/ "ace/post.h" +#endif /*CIAO_CONFIG_STD_PC_INTF_H*/ diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Package_Handlers.mpc b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Package_Handlers.mpc new file mode 100644 index 00000000000..d631343c9e5 --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Package_Handlers.mpc @@ -0,0 +1,43 @@ +// $Id$ + +project (Package_Config_Handlers) : acelib, dance_deployment_stub, dance_config_handlers_base, dance, typecodefactory, dance_output { + sharedname = Package_Config_Handlers + dynamicflags = PACKAGING_HANDLERS_BUILD_DLL + + includes += $(CIAO_ROOT)/ciao + libpaths += $(CIAO_ROOT)/bin + + after += XSC_Config_Handlers_Common \ + XSC_Config_Handlers \ + XSC_DynAny_Handler \ + XSC_XML_Handlers \ + CIAO_XML_Utils \ + + libs += XSC_Config_Handlers_Common \ + XSC_Config_Handlers \ + XSC_DynAny_Handler \ + XSC_XML_Handlers \ + CIAO_XML_Utils \ + + Source_files { + CAD_Handler.cpp + CID_Handler.cpp + Comp_Intf_Descr_Handler.cpp + CPD_Handler.cpp + IAD_Handler.cpp + PCD_Handler.cpp + SID_Handler.cpp + } + + Header_Files { + CAD_Handler.h + CID_Handler.h + Comp_Intf_Descr_Handler.h + CPD_Handler.h + IAD_Handler.h + PCD_Handler.h + SID_Handler.h + } + +} + diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Packaging_Handlers_Export.h b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Packaging_Handlers_Export.h new file mode 100644 index 00000000000..86193a1a664 --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/Packaging_Handlers_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl Packaging_Handlers +// ------------------------------ +#ifndef PACKAGING_HANDLERS_EXPORT_H +#define PACKAGING_HANDLERS_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (PACKAGING_HANDLERS_HAS_DLL) +# define PACKAGING_HANDLERS_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && PACKAGING_HANDLERS_HAS_DLL */ + +#if !defined (PACKAGING_HANDLERS_HAS_DLL) +# define PACKAGING_HANDLERS_HAS_DLL 1 +#endif /* ! PACKAGING_HANDLERS_HAS_DLL */ + +#if defined (PACKAGING_HANDLERS_HAS_DLL) && (PACKAGING_HANDLERS_HAS_DLL == 1) +# if defined (PACKAGING_HANDLERS_BUILD_DLL) +# define Packaging_Handlers_Export ACE_Proper_Export_Flag +# define PACKAGING_HANDLERS_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define PACKAGING_HANDLERS_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* PACKAGING_HANDLERS_BUILD_DLL */ +# define Packaging_Handlers_Export ACE_Proper_Import_Flag +# define PACKAGING_HANDLERS_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define PACKAGING_HANDLERS_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* PACKAGING_HANDLERS_BUILD_DLL */ +#else /* PACKAGING_HANDLERS_HAS_DLL == 1 */ +# define Packaging_Handlers_Export +# define PACKAGING_HANDLERS_SINGLETON_DECLARATION(T) +# define PACKAGING_HANDLERS_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* PACKAGING_HANDLERS_HAS_DLL == 1 */ + +// Set PACKAGING_HANDLERS_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (PACKAGING_HANDLERS_NTRACE) +# if (ACE_NTRACE == 1) +# define PACKAGING_HANDLERS_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define PACKAGING_HANDLERS_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !PACKAGING_HANDLERS_NTRACE */ + +#if (PACKAGING_HANDLERS_NTRACE == 1) +# define PACKAGING_HANDLERS_TRACE(X) +#else /* (PACKAGING_HANDLERS_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define PACKAGING_HANDLERS_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (PACKAGING_HANDLERS_NTRACE == 1) */ + +#endif /* PACKAGING_HANDLERS_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/SID_Handler.cpp b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/SID_Handler.cpp new file mode 100644 index 00000000000..f19aa3ef4bb --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/SID_Handler.cpp @@ -0,0 +1,142 @@ +// $Id$ +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "Package_Handlers/SID_Handler.h" +#include "cid.hpp" +#include "DAnCE/Deployment/DeploymentC.h" +#include "Package_Handlers/CPD_Handler.h" +#include "Package_Handlers/PCD_Handler.h" +#include "Package_Handlers/Comp_Intf_Descr_Handler.h" +#include "Req_Handler.h" +#include "Property_Handler.h" + +#include "ace/UUID.h" + +namespace CIAO +{ + namespace Config_Handlers + { + namespace Packaging + { + IDREF_Base<CORBA::ULong> SID_Handler::IDREF; + + void + SID_Handler::handle_sub_comp_inst_descr (const SubcomponentInstantiationDescription &desc, + ::Deployment::SubcomponentInstantiationDescription &toconfig) + { + DANCE_TRACE ("SID_Handler::sub_comp_inst_descr"); + toconfig.name = ACE_TEXT_ALWAYS_CHAR (desc.name ().c_str ()); + + if (desc.basePackage_p ()) + { + toconfig.basePackage.length (1); + CPD_Handler::handle_component_package_descr (desc.basePackage (), + toconfig.basePackage[0]); + } + else if (desc.specializedConfig_p ()) + { + toconfig.specializedConfig.length (1); + PCD_Handler::package_config (desc.specializedConfig (), + toconfig.specializedConfig[0]); + } + else if (desc.importedPackage_p ()) + { + toconfig.importedPackage.length (1); + toconfig.importedPackage[0].location.length (desc.importedPackage ().count_location ()); + + std::for_each (desc.importedPackage ().begin_location (), + desc.importedPackage ().end_location (), + String_Seq_Functor (toconfig.importedPackage[0].location)); + } + else if (desc.referencedPackage_p ()) + { + toconfig.referencedPackage.length (1); + + if (desc.referencedPackage ().requiredUUID_p ()) + toconfig.referencedPackage[0].requiredUUID = + ACE_TEXT_ALWAYS_CHAR (desc.referencedPackage ().requiredUUID ().c_str ()); + + if (desc.referencedPackage ().requiredName_p ()) + toconfig.referencedPackage[0].requiredName = + ACE_TEXT_ALWAYS_CHAR (desc.referencedPackage ().requiredName ().c_str ()); + + Comp_Intf_Descr_Handler::comp_intf_descr (desc.referencedPackage ().requiredType (), + toconfig.referencedPackage[0].requiredType); + + } + + toconfig.selectRequirement.length (desc.count_selectRequirement ()); + std::for_each (desc.begin_selectRequirement (), + desc.end_selectRequirement (), + Requirement_Functor (toconfig.selectRequirement)); + + toconfig.configProperty.length (desc.count_configProperty ()); + std::for_each (desc.begin_configProperty (), + desc.end_configProperty (), + Property_Functor (toconfig.configProperty)); + + if (desc.id_p ()) + { + ACE_TString str (desc.id ().c_str ()); + SID_Handler::IDREF.bind_next_available (str); + } + else + ACE_ERROR ((LM_ERROR, ACE_TEXT ("Warning: SID With Name %s has no ID\n"), + desc.name ().c_str ())); + + } + + SubcomponentInstantiationDescription + SID_Handler::sub_comp_inst_descr (const Deployment::SubcomponentInstantiationDescription &src) + { + DANCE_TRACE ("SID_Handler::sub_comp_inst_descr - reverse"); + SubcomponentInstantiationDescription retval (ACE_TEXT_CHAR_TO_TCHAR (src.name.in ())); + + if (src.basePackage.length () == 1) + retval.basePackage + (CPD_Handler::component_package_descr (src.basePackage[0])); + else if (src.specializedConfig.length () == 1) + retval.specializedConfig + (PCD_Handler::package_config (src.specializedConfig[0])); + else if (src.importedPackage.length () == 1) + { + ComponentPackageImport ci; +#if 0 + for (CORBA::ULong i = 0; i < src.importedPackage[0].location.length (); ++i) + ci.add_location (src.importedPackage[0].location[i].in ()); +#endif + retval.importedPackage (ci); + } + else if (src.referencedPackage.length () == 1) + { + ComponentPackageReference cpr (Comp_Intf_Descr_Handler::comp_intf_descr (src.referencedPackage[0].requiredType)); + cpr.requiredUUID (ACE_TEXT_CHAR_TO_TCHAR (src.referencedPackage[0].requiredUUID.in ())); + cpr.requiredName (ACE_TEXT_CHAR_TO_TCHAR (src.referencedPackage[0].requiredName.in ())); + + retval.referencedPackage (cpr); + } +#if 0 + for (CORBA::ULong i = 0; i < src.selectRequirement.length (); ++i) + retval.add_selectRequirement + (Req_Handler::get_requirement (src.selectRequirement[i])); + + for (CORBA::ULong i = 0; i < src.configProperty.length (); ++i) + retval.add_configProperty + (Property_Handler::get_property (src.configProperty[i])); +#endif + // @@MAJO This is not a good way of binding reverse IDREFS. + std::auto_ptr <ACE_Utils::UUID> safe_uuid ( + ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID ()); + ACE_TString uuid ( ACE_TEXT_CHAR_TO_TCHAR (safe_uuid->to_string ()->c_str ())); + + // ACE_ERROR ((LM_ERROR, "*** Binding to %s\n", + // uuid.c_str ())); + + SID_Handler::IDREF.bind_next_available (uuid); + + return retval; + } + + } + } +} + diff --git a/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/SID_Handler.h b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/SID_Handler.h new file mode 100644 index 00000000000..2083b91b9b6 --- /dev/null +++ b/modules/CIAO/DAnCE/Config_Handlers/Package_Handlers/SID_Handler.h @@ -0,0 +1,71 @@ +/** + * @file SID_Handler.h + * @author William Otte <wotte@dre.vanderbilt.edu> + * + * $Id$ + */ + + +#ifndef CIAO_PACKAGING_SID_HANDLER_H +#define CIAO_PACKAGING_SID_HANDLER_H + +#include /**/ "ace/pre.h" + +#include "XML_Typedefs.h" +#include "Utils/Functors.h" +#include "IDREF_Base.h" +#include "Package_Handlers/Packaging_Handlers_Export.h" + +namespace Deployment +{ + struct SubcomponentInstantiationDescription; + class SubcomponentInstantiationDescriptions; +} + +namespace CIAO +{ + namespace Config_Handlers + { + class SubcomponentInstantiationDescription; + + namespace Packaging + { + /** + * @class SID_Handler + * @brief Handler class for SubcomponentInstantiationDescription + */ + class Packaging_Handlers_Export SID_Handler + { + SID_Handler (XML_Helper *xml_helper) + : xml_helper_ (xml_helper) + { + + } + + public: + static void handle_sub_comp_inst_descr (const SubcomponentInstantiationDescription &desc, + ::Deployment::SubcomponentInstantiationDescription &toconfig); + + static SubcomponentInstantiationDescription + sub_comp_inst_descr (const ::Deployment::SubcomponentInstantiationDescription &src); + + static IDREF_Base< CORBA::ULong > IDREF; + + private: + static SubcomponentInstantiationDescription *resolve_sid (const char *uri); + + XML_Helper *xml_helper_; + + }; + + typedef Sequence_Handler < SubcomponentInstantiationDescription, + ::Deployment::SubcomponentInstantiationDescriptions, + ::Deployment::SubcomponentInstantiationDescription, + SID_Handler::handle_sub_comp_inst_descr > SID_Functor; + + } + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_PACKAGING_SID_HANDLER_H */ |