diff options
Diffstat (limited to 'modules/CIAO/tools/Config_Handlers/Package_Handlers')
20 files changed, 2300 insertions, 0 deletions
diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/CAD_Handler.cpp b/modules/CIAO/tools/Config_Handlers/Package_Handlers/CAD_Handler.cpp new file mode 100644 index 00000000000..ec3bb20e539 --- /dev/null +++ b/modules/CIAO/tools/Config_Handlers/Package_Handlers/CAD_Handler.cpp @@ -0,0 +1,271 @@ +// $Id$ + +#include "Package_Handlers/CAD_Handler.h" +#include "Basic_Deployment_Data.hpp" +#include "cid.hpp" +#include "ciao/DeploymentC.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 + { + namespace + { + struct SPE_Handler + { + static void handle_spe (const SubcomponentPortEndpoint &desc, + ::Deployment::SubcomponentPortEndpoint &toconfig) + { + CIAO_TRACE("SPE_Handler::get_spe"); + + toconfig.portName = desc.portName ().c_str (); + + ACE_CString str (desc.instance ().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) + { + CIAO_TRACE("SPE_Handler::get_spe - reverse"); + ACE_CString str; + SID_Handler::IDREF.find_ref (src.instanceRef, str); + + return SubcomponentPortEndpoint (src.portName.in (), + str.c_str ()); + } + }; + + typedef Sequence_Handler < SubcomponentPortEndpoint, + ::Deployment::SubcomponentPortEndpoints, + ::Deployment::SubcomponentPortEndpoint, + SPE_Handler::handle_spe > SPE_Functor; + + struct ACD_Handler + { + static void handle_acd (const AssemblyConnectionDescription &desc, + ::Deployment::AssemblyConnectionDescription &toconfig) + { + CIAO_TRACE("ACD_Handler::get_acd"); + + toconfig.name = 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) + { + CIAO_TRACE("ACD_Handler::get_acd - reverse"); + + AssemblyConnectionDescription retval (src.name.in ()); + + 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])); + + return retval; + } + }; + + typedef Sequence_Handler < AssemblyConnectionDescription, + ::Deployment::AssemblyConnectionDescriptions, + ::Deployment::AssemblyConnectionDescription, + ACD_Handler::handle_acd > ACD_Functor; + + + struct SPR_Handler + { + static void handle_spr (const SubcomponentPropertyReference &desc, + ::Deployment::SubcomponentPropertyReference &toconfig) + { + CIAO_TRACE("SPR_Handler::get_spr"); + + toconfig.propertyName = desc.propertyName ().c_str (); + + ACE_CString str (desc.instance ().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) + { + CIAO_TRACE("SPR_HAndler::get_spr - reverse"); + ACE_CString str; + SID_Handler::IDREF.find_ref (src.instanceRef, str); + + return SubcomponentPropertyReference (src.propertyName.in (), + str.c_str ()); + } + + }; + + typedef Sequence_Handler < SubcomponentPropertyReference, + ::Deployment::SubcomponentPropertyReferences, + ::Deployment::SubcomponentPropertyReference, + SPR_Handler::handle_spr > SPR_Functor; + + struct APM_Handler + { + static void handle_apm (const AssemblyPropertyMapping &desc, + ::Deployment::AssemblyPropertyMapping &toconfig) + { + CIAO_TRACE("APM_Handler::get_apm"); + + toconfig.name = desc.name ().c_str (); + toconfig.externalName = 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) + { + CIAO_TRACE("APM_Handler::get_apm - reverse"); + + AssemblyPropertyMapping retval (src.name.in (), + src.externalName.in ()); + + for (CORBA::ULong i = 0; i < src.delegatesTo.length (); ++i) + retval.add_delegatesTo (SPR_Handler::get_spr (src.delegatesTo[i])); + + 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) + { + CIAO_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) + { + CIAO_TRACE("CAD_Handler::component_assem_descr - reverse"); + + ComponentAssemblyDescription retval; + + 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])); + + 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/tools/Config_Handlers/Package_Handlers/CAD_Handler.h b/modules/CIAO/tools/Config_Handlers/Package_Handlers/CAD_Handler.h new file mode 100644 index 00000000000..b4c0b790fc0 --- /dev/null +++ b/modules/CIAO/tools/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 "Utils/XML_Helper.h" +#include "ciao/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/tools/Config_Handlers/Package_Handlers/CID_Handler.cpp b/modules/CIAO/tools/Config_Handlers/Package_Handlers/CID_Handler.cpp new file mode 100644 index 00000000000..d5e39d485da --- /dev/null +++ b/modules/CIAO/tools/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 "ciao/Deployment_DataC.h" +#include "Utils/XML_Helper.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) + { + CIAO_TRACE ("Capability_Handler::get_capability"); + + toconfig.name = 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) + { + CIAO_TRACE ("Capability_Handler::get_capability - reverse"); + + Capability retval (src.name.in ()); + + for (CORBA::ULong i = 0; i < src.resourceType.length (); ++i) + retval.add_resourceType (src.resourceType[i]); + + for (CORBA::ULong i = 0; i < src.property.length (); ++i) + retval.add_property (SatisfierProperty_Handler::get_sat_property (src.property[i])); + + 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) + { + CIAO_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 (), + "Unknown ResourceUsageKind."); + break; + } + } + + if (desc.resourcePort_p ()) + toconfig.resourcePort = desc.resourcePort ().c_str (); + + if (desc.componentPort_p ()) + toconfig.componentPort = desc.componentPort ().c_str (); + + toconfig.resourceType = desc.resourceType ().c_str (); + toconfig.name = 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) + { + CIAO_TRACE ("IR_Handler::get_ir - reverse"); + + ImplementationRequirement retval (src.resourceType.in (), + 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 (src.name.in (), + "Unknown ResourceUsageKind."); + break; + } + + retval.resourcePort (src.resourcePort.in ()); + + retval.componentPort (src.componentPort.in ()); + + for (CORBA::ULong i = 0; i < src.property.length (); ++i) + retval.add_property (Property_Handler::get_property (src.property[i])); + + 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) + { + CIAO_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) + { + CIAO_TRACE ("MID_Handler::get_mid - reverse"); + + MonolithicImplementationDescription retval; + + 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])); + + 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) + { + CIAO_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 = cid->label ().c_str (); + + if (cid->UUID_p ()) + toconfig.UUID = 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 ("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 = 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) + { + CIAO_TRACE ("CID_Handler::component_impl_descr - reverse"); + + ComponentImplementationDescription retval; + + retval.label (src.label.in ()); + retval.UUID (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")); + + 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])); + } + + return retval; + } + + ComponentImplementationDescription * + CID_Handler::resolve_cid (const char *uri) + { + CIAO_TRACE ("CID_Handler::resolve_cid"); + + xercesc::DOMDocument *dom = XML_HELPER->create_dom (uri); + + if (!dom) + throw Parse_Error ("Unable to create DOM for CID"); + + try { + return new ComponentImplementationDescription + (componentImplementationDescription (dom)); + } + catch (...) { + throw Parse_Error ("Unable to create XSC structure for CID"); + } + } + } + + } +} diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/CID_Handler.h b/modules/CIAO/tools/Config_Handlers/Package_Handlers/CID_Handler.h new file mode 100644 index 00000000000..ef1263ad139 --- /dev/null +++ b/modules/CIAO/tools/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 char *uri); + }; + } + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_PACKAGING_CID_HANDLER_H*/ diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/CPD_Handler.cpp b/modules/CIAO/tools/Config_Handlers/Package_Handlers/CPD_Handler.cpp new file mode 100644 index 00000000000..a45c92e8465 --- /dev/null +++ b/modules/CIAO/tools/Config_Handlers/Package_Handlers/CPD_Handler.cpp @@ -0,0 +1,162 @@ +// $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 "ciao/Deployment_Packaging_DataC.h" +#include "Deployment.hpp" +#include "Utils/Exceptions.h" +#include "Property_Handler.h" + +namespace CIAO +{ + namespace Config_Handlers + { + namespace Packaging + { + namespace + { + struct PCI_Handler + { + static void handle_pci (const PackagedComponentImplementation &desc, + ::Deployment::PackagedComponentImplementation &toconfig) + { + CIAO_TRACE ("PCI_Handler::get_pci"); + toconfig.name = desc.name ().c_str (); + + CID_Handler::component_impl_descr (desc.referencedImplementation (), + toconfig.referencedImplementation); + } + + static PackagedComponentImplementation + get_pci (const ::Deployment::PackagedComponentImplementation &src) + { + CIAO_TRACE ("PCI_Handler::get_pci - reverse"); + return PackagedComponentImplementation (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) + { + CIAO_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 = cpd->label ().c_str (); + + if (cpd->UUID_p ()) + toconfig.UUID = 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) + { + CIAO_TRACE ("CPD_Handler::component_package_descr - reverse"); + ComponentPackageDescription toconfig; + + if (src.label.in () != 0) + toconfig.label (src.label.in ()); + + if (src.UUID.in () != 0) + toconfig.UUID (src.UUID.in ()); + + { + toconfig.realizes + (Comp_Intf_Descr_Handler::comp_intf_descr (src.realizes)); + } + + 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])); + } + + return toconfig; + } + + ComponentPackageDescription * CPD_Handler::resolve_cpd (const char *uri) + { + CIAO_TRACE ("CPD_Handler::resolve_cpd"); + if (!XML_HELPER->is_initialized ()) + return 0; + + xercesc::DOMDocument* dom = + XML_HELPER->create_dom (uri); + + if (!dom) + throw Parse_Error ("Unable to create DOM for component package description"); + + try { + //ACE_ERROR ((LM_ERROR, "Creating new CPD XSC Object\n")); + return new ComponentPackageDescription (componentPackageDescription (dom)); + } + catch (...) { + throw Parse_Error ("Unable to create XSC structure for CID"); + } + } + } + + + } +} diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/CPD_Handler.h b/modules/CIAO/tools/Config_Handlers/Package_Handlers/CPD_Handler.h new file mode 100644 index 00000000000..9535d24eef2 --- /dev/null +++ b/modules/CIAO/tools/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 "Utils/XML_Helper.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 char *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/tools/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.cpp b/modules/CIAO/tools/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.cpp new file mode 100644 index 00000000000..801519dc987 --- /dev/null +++ b/modules/CIAO/tools/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.cpp @@ -0,0 +1,165 @@ +// $Id$ +#include "Comp_Intf_Descr_Handler.h" + +#include "Utils/XML_Helper.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 "tools/Config_Handlers/CPD_Handler.h" +#include "ciao/CIAO_common.h" +namespace CIAO +{ + namespace Config_Handlers + { + namespace Packaging + { + struct Comp_Prop_Handler + { + static void handle_cpd (const ComponentPropertyDescription &desc, + ::Deployment::ComponentPropertyDescription &toconfig) + { + CIAO_TRACE ("Comp_Prop_Handler::get_cpd"); + + toconfig.name = desc.name ().c_str (); + DataType_Handler::data_type (desc.type (), + toconfig.type); + } + + static ComponentPropertyDescription + get_cpd (const ::Deployment::ComponentPropertyDescription &src) + { + CIAO_TRACE ("Comp_Prop_Handler::get_cpd - reverse"); + + return ComponentPropertyDescription (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) + { + CIAO_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 = cid->label ().c_str (); + + if (cid->UUID_p ()) + toconfig.UUID = cid->UUID ().c_str (); + + // MAJO: SpecificType should be required. + if (cid->specificType_p ()) + toconfig.specificType = 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) + { + CIAO_TRACE ("Comp_Intf_Descr_Handler::comp_intf_descr - reverse"); + ComponentInterfaceDescription retval; + + retval.label (src.label.in ()); + retval.UUID (src.UUID.in ()); + retval.specificType (src.specificType.in ()); + + for (CORBA::ULong i = 0; i < src.supportedType.length (); ++i) + retval.add_supportedType (src.supportedType[i]); + + for (CORBA::ULong i = 0; i < src.idlFile.length (); ++i) + retval.add_idlFile (src.idlFile[i]); + + 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])); + + return retval; + } + + ComponentInterfaceDescription * + Comp_Intf_Descr_Handler::resolve_cid (const char *uri) + { + CIAO_TRACE ("Comp_Intf_Descr_Handler::resolve_cid"); + + xercesc::DOMDocument *dom = XML_HELPER->create_dom (uri); + + if (!dom) + throw Parse_Error ("Unable to create DOM for Component Interface Description."); + + try { + return new ComponentInterfaceDescription + (componentInterfaceDescription (dom)); + } + catch (...) { + throw Parse_Error ("Unable to create XSC structure for Component Interface Description"); + } + } + } + }} diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.h b/modules/CIAO/tools/Config_Handlers/Package_Handlers/Comp_Intf_Descr_Handler.h new file mode 100644 index 00000000000..e4eb2b0af58 --- /dev/null +++ b/modules/CIAO/tools/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 "Utils/XML_Helper.h" +#include "ciao/DeploymentC.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 char *uri); + }; + } + } +} + +#include /**/ "ace/post.h" + +#endif /* CIAO_PACKAGING_COMP_INTF_DESCR_HANDLER_H */ diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/IAD_Handler.cpp b/modules/CIAO/tools/Config_Handlers/Package_Handlers/IAD_Handler.cpp new file mode 100644 index 00000000000..61c85827472 --- /dev/null +++ b/modules/CIAO/tools/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 "Utils/XML_Helper.h" + +#include "Deployment.hpp" +#include "ciao/CIAO_common.h" + +namespace CIAO +{ + namespace Config_Handlers + { + namespace Packaging + { + + void + IAD_Handler::impl_artifact_descr (const ImplementationArtifactDescription &desc, + ::Deployment::ImplementationArtifactDescription &toconfig) + { + CIAO_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 = iad->label ().c_str (); + + if (iad->UUID_p ()) + toconfig.UUID = 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) + { + CIAO_TRACE ("IAD_Handler::impl_artifact_descr - reverse"); + ImplementationArtifactDescription retval; + + retval.label (src.label.in ()); + retval.UUID (src.UUID.in ()); + + for (CORBA::ULong i = 0; i < src.location.length (); ++i) + retval.add_location (src.location[i]); + + 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])); + + return retval; + } + + ImplementationArtifactDescription * IAD_Handler::resolve_iad (const char *uri) + { + CIAO_TRACE ("IAD_Handler::resolve_iad"); + + xercesc::DOMDocument *dom = XML_HELPER->create_dom (uri); + + if (!dom) + throw Parse_Error ("Unable to create DOM for IAD"); + + try { + return new ImplementationArtifactDescription + (implementationArtifactDescription (dom)); + } + catch (...) { + throw Parse_Error ("Unable to create XSC structure for IAD"); + } + } + + } + } +} diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/IAD_Handler.h b/modules/CIAO/tools/Config_Handlers/Package_Handlers/IAD_Handler.h new file mode 100644 index 00000000000..869dbe25a8a --- /dev/null +++ b/modules/CIAO/tools/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 char *uri); + }; + } + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_CONFIG_HANDLERS_STD_IAD_HANDLER_H*/ diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/NIA_Handler.h b/modules/CIAO/tools/Config_Handlers/Package_Handlers/NIA_Handler.h new file mode 100644 index 00000000000..2c4db4eddf2 --- /dev/null +++ b/modules/CIAO/tools/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 "ciao/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 = desc.name ().c_str (); + IAD_Handler::impl_artifact_descr (desc.referencedArtifact (), + toconfig.referencedArtifact); + } + + + static NamedImplementationArtifact + get_nia (const ::Deployment::NamedImplementationArtifact &src) + { + return NamedImplementationArtifact (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/tools/Config_Handlers/Package_Handlers/PCD_Handler.cpp b/modules/CIAO/tools/Config_Handlers/Package_Handlers/PCD_Handler.cpp new file mode 100644 index 00000000000..6f0faebd255 --- /dev/null +++ b/modules/CIAO/tools/Config_Handlers/Package_Handlers/PCD_Handler.cpp @@ -0,0 +1,165 @@ +// $Id$ +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "ciao/CIAO_common.h" +#include "ciao/Deployment_Packaging_DataC.h" +#include "Utils/XML_Helper.h" +#include "Utils/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> + +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->create_dom (uri); + + if (dom == 0) + { + std::string error ("Unable to open file: "); + error += uri; + throw Parse_Error (error); + } + + XStr root = dom->getDocumentElement ()->getTagName (); + + if (root == XStr ("Deployment:topLevelPackageDescription")) + { + PackageConfiguration foo; + TopLevelPackageDescription tpd (foo); + + tpd = topLevelPackageDescription (dom); + + PCD_Handler::package_config (tpd.package (), + toconfig); + + } + else if (root == XStr ("Deployment:packageConfiguration")) + { + PackageConfiguration pcd; + pcd = 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 ("Invalid file passed to package_config, had base"); + } + } + + void + PCD_Handler::package_config (const PackageConfiguration &desc, + ::Deployment::PackageConfiguration &toconfig) + { + CIAO_TRACE ("PCD_Handler::package_config"); + std::auto_ptr < PackageConfiguration > xsc_pcd; + + const PackageConfiguration *pcd; + + if (desc.href_p ()) + { + // Take ownership of the resolved pcd + xsc_pcd.reset (PCD_Handler:: resolve_package_config (desc.href ().c_str ())); + pcd = xsc_pcd.get (); + } + else + pcd = &desc; + + if (pcd->label_p ()) + toconfig.label = + pcd->label ().c_str (); + + if (pcd->UUID_p ()) + toconfig.UUID = + 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) + { + CIAO_TRACE ("PCD_Handler::package_config - reverse"); + PackageConfiguration pcd = PackageConfiguration (); + + if (src.label.in () != 0) + pcd.label (src.label.in ()); + + if (src.UUID.in () != 0) + pcd.UUID (src.UUID.in ()); + + if (src.basePackage.length () > 0) + { + ACE_DEBUG ((LM_DEBUG, "5\n")); + pcd.basePackage (CPD_Handler::component_package_descr (src.basePackage[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])); + + return pcd; + + } + + PackageConfiguration * PCD_Handler::resolve_package_config (const char *uri) + { + xercesc::DOMDocument* dom = + XML_HELPER->create_dom (uri); + + if (!dom) + throw Parse_Error ("Unable to create DOM for PackageConfiguration"); + + try { + return new PackageConfiguration (packageConfiguration (dom)); + } + catch (...) { + throw Parse_Error ("Unable to create XSC structure for PackageConfiguration"); + } + + } + + + } + } +} diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/PCD_Handler.h b/modules/CIAO/tools/Config_Handlers/Package_Handlers/PCD_Handler.h new file mode 100644 index 00000000000..be92a6871c0 --- /dev/null +++ b/modules/CIAO/tools/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 char *uri); + }; + } + + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_CONFIG_HANDLERS_STD_PCD_HANDLER_H*/ diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/PC_Intf.cpp b/modules/CIAO/tools/Config_Handlers/Package_Handlers/PC_Intf.cpp new file mode 100644 index 00000000000..e265295d040 --- /dev/null +++ b/modules/CIAO/tools/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 "ciao/CIAO_common.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) + { + CIAO_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/tools/Config_Handlers/Package_Handlers/PC_Intf.h b/modules/CIAO/tools/Config_Handlers/Package_Handlers/PC_Intf.h new file mode 100644 index 00000000000..c15ae0389b9 --- /dev/null +++ b/modules/CIAO/tools/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/tools/Config_Handlers/Package_Handlers/Package_Handlers.mpc b/modules/CIAO/tools/Config_Handlers/Package_Handlers/Package_Handlers.mpc new file mode 100644 index 00000000000..7f4b68c5247 --- /dev/null +++ b/modules/CIAO/tools/Config_Handlers/Package_Handlers/Package_Handlers.mpc @@ -0,0 +1,54 @@ +// $Id$ + +project (Package_Config_Handlers) : acelib, ciao_deployment_stub, ciao_config_handlers_base { + sharedname = Package_Config_Handlers + dynamicflags = PACKAGING_HANDLERS_BUILD_DLL + avoids += ace_for_tao + + includes += $(CIAO_ROOT)/ciao + + after += XSC_Config_Handlers_Common \ + XSC_Config_Handlers \ + XSC_DynAny_Handler \ + XSC_XML_Handlers \ + CIAO_XML_Utils \ + CIAO_Events_Handlers + + libs += XSC_Config_Handlers_Common \ + XSC_Config_Handlers \ + XSC_DynAny_Handler \ + XSC_XML_Handlers \ + CIAO_XML_Utils \ + CIAO_Events_Handlers RT_CCM_Config_Handlers + + 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 + } + +} + +project (Package_Config_Handlers_Tests) : ciao_component_dnc, ciao_config_handlers, ifr_client { + exename = test + macros += XML_USE_PTHREADS + avoids += ace_for_tao + + Source_Files { + test.cpp + } +} diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/Packaging_Handlers_Export.h b/modules/CIAO/tools/Config_Handlers/Package_Handlers/Packaging_Handlers_Export.h new file mode 100644 index 00000000000..86193a1a664 --- /dev/null +++ b/modules/CIAO/tools/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/tools/Config_Handlers/Package_Handlers/SID_Handler.cpp b/modules/CIAO/tools/Config_Handlers/Package_Handlers/SID_Handler.cpp new file mode 100644 index 00000000000..34eadf9ea32 --- /dev/null +++ b/modules/CIAO/tools/Config_Handlers/Package_Handlers/SID_Handler.cpp @@ -0,0 +1,140 @@ +// $Id$ +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "Package_Handlers/SID_Handler.h" +#include "cid.hpp" +#include "ciao/DeploymentC.h" +#include "Package_Handlers/CPD_Handler.h" +#include "Package_Handlers/PCD_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) + { + CIAO_TRACE ("SID_Handler::sub_comp_inst_descr"); + toconfig.name = 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 = + desc.referencedPackage ().requiredUUID ().c_str (); + + if (desc.referencedPackage ().requiredName_p ()) + toconfig.referencedPackage[0].requiredName = + desc.referencedPackage ().requiredName ().c_str (); + + toconfig.referencedPackage[0].requiredType = + desc.referencedPackage ().requiredType ().c_str (); + } + + 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_CString str (desc.id ().c_str ()); + SID_Handler::IDREF.bind_next_available (str); + } + else + ACE_ERROR ((LM_ERROR, "Warning: SID With Name %s has no ID\n", + desc.name ().c_str ())); + + } + + SubcomponentInstantiationDescription + SID_Handler::sub_comp_inst_descr (const Deployment::SubcomponentInstantiationDescription &src) + { + CIAO_TRACE ("SID_Handler::sub_comp_inst_descr - reverse"); + SubcomponentInstantiationDescription retval (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; + + for (CORBA::ULong i = 0; i < src.importedPackage[0].location.length (); ++i) + ci.add_location (src.importedPackage[0].location[i]); + + retval.importedPackage (ci); + } + else if (src.referencedPackage.length () == 1) + { + ComponentPackageReference cpr (src.referencedPackage[0].requiredType.in ()); + cpr.requiredUUID (src.referencedPackage[0].requiredUUID.in ()); + cpr.requiredName (src.referencedPackage[0].requiredName.in ()); + + retval.referencedPackage (cpr); + } + + 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])); + + // @@MAJO This is not a good way of binding reverse IDREFS. + std::auto_ptr <ACE_Utils::UUID> safe_uuid ( + ACE_Utils::UUID_GENERATOR::instance ()->generateUUID ()); + ACE_CString uuid ( 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/tools/Config_Handlers/Package_Handlers/SID_Handler.h b/modules/CIAO/tools/Config_Handlers/Package_Handlers/SID_Handler.h new file mode 100644 index 00000000000..1bcb73e751e --- /dev/null +++ b/modules/CIAO/tools/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 "Utils/XML_Helper.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 */ diff --git a/modules/CIAO/tools/Config_Handlers/Package_Handlers/test.cpp b/modules/CIAO/tools/Config_Handlers/Package_Handlers/test.cpp new file mode 100644 index 00000000000..7ab76020dd9 --- /dev/null +++ b/modules/CIAO/tools/Config_Handlers/Package_Handlers/test.cpp @@ -0,0 +1,113 @@ +// $Id$ + +#include <iostream> + +#include "Deployment.hpp" +#include "PCD_Handler.h" +#include "ciao/Deployment_Packaging_DataC.h" +#include "SID_Handler.h" +#include "ace/Get_Opt.h" +#include "Utils/XML_Helper.h" +#include "tao/ORB.h" +#include "Utils/Exceptions.h" + +static const char *input_file = "BasicSP.cdp"; + + +static int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "i:"); + + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'i': + input_file = get_opts.opt_arg (); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-i <input file> " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command-line + return 0; +} + +// Check to see if SRD was imported. +void check_srd (const Deployment::DeploymentPlan &); + +using namespace CIAO::Config_Handlers; + + +int main (int argc, char *argv[]) +{ + try + { + + if (parse_args (argc, argv) != 0) + return 1; + + // Initialize an ORB so Any will work + CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv, ""); + ACE_UNUSED_ARG (orb); + + + if (xercesc::DOMDocument *doc = XML_HELPER->create_dom (input_file)) + { + + ::Deployment::PackageConfiguration idl_pc; + { + // //Read in the XSC type structure from the DOMDocument + //PackageConfiguration pc = packageConfiguration (doc); + //std::cerr << "XML to XSC conversion succeeded. Converting to IDL...\n"; + + //Convert the XSC to an IDL datatype + Packaging::PCD_Handler::package_config (input_file, idl_pc); + std::cout << "Instance document import succeeded. Dumping contents to file\n"; + } + + // Clear SID_Handler's IDREF Table + Packaging::SID_Handler::IDREF.unbind_refs (); + + std::cerr << "Performing IDL->XSC transformation...\n"; + + PackageConfiguration out_pc (Packaging::PCD_Handler::package_config (idl_pc)); + + //Create a new DOMDocument for writing the XSC into XML + xercesc::DOMDocument* the_xsc (XML_HELPER->create_dom("Deployment:packageConfiguration", + "http://www.omg.org/Deployment")); + + //Serialize the XSC into a DOMDocument + packageConfiguration(out_pc, the_xsc); + + + //Write it to test.xml + XML_HELPER->write_DOM(the_xsc, "test.xml"); + + //Cleanliness is next to Godliness + delete doc; + } + + std::cout << "Test completed!\n"; + } + catch (CIAO::Config_Handlers::Plan_Error &excep) + { + std::cerr << "Plan Error exception caught: " << excep.reason_ << std::endl; + } + catch (CIAO::Config_Handlers::Config_Error &excep) + { + std::cerr << "Config Error " << excep.name_ << ": " << excep.error_ << std::endl; + } + + + return 0; +} + + |