diff options
author | sjiang <sjiang@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-09-23 04:30:02 +0000 |
---|---|---|
committer | sjiang <sjiang@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-09-23 04:30:02 +0000 |
commit | 010d7ecc66edcbe1d0df7ba30cc32cfb67b89466 (patch) | |
tree | 2635b852456ef2901d92377070121573ee3248fb | |
parent | 5413ef1b936f21c56153ff9f35d840dfda1d6832 (diff) | |
download | ATCD-010d7ecc66edcbe1d0df7ba30cc32cfb67b89466.tar.gz |
ChangeLog Tag: Sat Sep 23 04:07:59 UTC 2006 Shanshan Jiang <shanshan.jiang@vanderbilt.edu>
-rw-r--r-- | CIAO/DAnCE/Plan_Generator/PCVisitor.cpp | 270 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Generator/PCVisitor.h | 128 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Generator/PCVisitorBase.cpp | 28 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Generator/PCVisitorBase.h | 172 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Generator/PCVisitorBase.inl | 155 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Generator/Plan_Generator.mpc | 24 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl.cpp | 143 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl.h | 78 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl_Export.h | 58 |
9 files changed, 1056 insertions, 0 deletions
diff --git a/CIAO/DAnCE/Plan_Generator/PCVisitor.cpp b/CIAO/DAnCE/Plan_Generator/PCVisitor.cpp new file mode 100644 index 00000000000..39bbb9bb434 --- /dev/null +++ b/CIAO/DAnCE/Plan_Generator/PCVisitor.cpp @@ -0,0 +1,270 @@ +/* -*- C++ -*- */ + +//======================================================================== +/* + * @file PCVisitor.cpp + * + * $Id$ + * + * This file contains the implementation of the PackageConfiguration + * Visitor class PCVisitor which derives from PCVisitorBase. Each + * Visit function focuses on the functionality necessary to process + * the PackageConfiguration element which is passed to it as an argument + * and on dispatching the next sequence of calls in the correct order! + * + * This implementation takes a PackageConfiguration and tries to modify + * a DeploymentPlan bases on it by expanding the latter in width and depth + * simultaneously. At each level of the PackageConfiguration the + * PCVisitor first expands the DeploymentPlan vertically at the + * corrsponding level and then dispatches the children of the current + * PackageConfiguration element. This in turn might and most probably + * will cause another vertical expansion of the DeploymentPlan, however + * for a different element. This effect is produced due to the flattened + * structure of the DeploymentPlan. + * + * @author Stoyan Paunov <spaunov@isis.vanderbilt.edu> + * Shanshan Jiang <shanshan.jiang@vanderbilt.edu> + */ +//======================================================================== + +#include "PCVisitorBase.h" +#include "PCVisitor.h" + +//Constructor +PCVisitor::PCVisitor (Deployment::DeploymentPlan &plan, + Deployment::PackageConfiguration &pc, + bool modify) + : PCVisitorBase (), + plan_ (plan), + pc_ (pc), + modify_ (modify), + last_impl_index_ (-1) +{ +} + +//entry point for the protected visitor to get it do start +//the visitation process +int PCVisitor::Visit () +{ + Accept (*this, this->pc_); + return last_impl_index_; +} + +// A whole slew of overloaded routines for different IDL +// data types part of the PackageConfiguration. + +void PCVisitor::Visit (Deployment::PackageConfiguration &pc) +{ + //visit the ComponentPackageDescription + if (pc.basePackage.length ()) + { + //currently no support for that anywhere + //for (size_t r = 0; r = pc.selectRequirement.length (); ++r); + + Accept (*this, pc.basePackage); + } + else + ACE_DEBUG ((LM_WARNING, + "[PCVisitor - PackageConfiguration] We currently " + "do NOT support package references, specializedConfigs", + "or imports!\n")); +} + +//ComponentPackageDescription descendents + +void PCVisitor::Visit (Deployment::ComponentPackageDescription &cpd) +{ + Accept (*this, cpd.realizes); + //for (size_t impl = 0; impl < cpd.implementation.length (); ++impl) + Accept (*this, cpd.implementation[0]); +} + + +void PCVisitor::Visit (Deployment::ComponentInterfaceDescription &) +{ + //Might want to populate this too once PICML starts supporting it +} + + +void PCVisitor::Visit (Deployment::PackagedComponentImplementation &pci) +{ + Accept (*this, pci.referencedImplementation); +} + + +void PCVisitor::Visit (Deployment::ComponentImplementationDescription &cid) +{ + if (cid.assemblyImpl.length ()) + Accept (*this, cid.assemblyImpl); + else + //;//Do nothing - monolithic component deployment not supported + Accept (*this, cid.monolithicImpl); +} + + +void PCVisitor::Visit (Deployment::ComponentAssemblyDescription &cad) +{ + //visit the SubcomponentInstantiationDescription + Accept (*this, cad.instance); + //visit the connections + Accept (*this, cad.connection); +} + + +void PCVisitor::Visit (Deployment::SubcomponentInstantiationDescription &sid) +{ + //visit the ComponentPackageDescription (again) + if (sid.basePackage.length ()) + { + Accept (*this, sid.basePackage); + } + else + ACE_DEBUG ((LM_WARNING, + "[PCVisitor - SubcomponentInstantiationDescription] ", + "We currently do NOT support package references, ", + "specializedConfigs or imports!\n")); +} + + +void PCVisitor::Visit (Deployment::MonolithicImplementationDescription &mid) +{ + if (!modify_) + { + //increase the implementation length by one + size_t impl_len = plan_.implementation.length (); + last_impl_index_ = impl_len; + plan_.implementation.length (impl_len + 1); + } + + //visit the NamedImplementationArtifacts + Accept (*this, mid.primaryArtifact); +} + + +void PCVisitor::Visit (Deployment::NamedImplementationArtifact &nia) +{ + if (!modify_) + { + //increase the artifact length by one + size_t arti_len = plan_.artifact.length (); + plan_.artifact.length (arti_len + 1); + + //set the name + plan_.artifact[arti_len].name = nia.name; + + //set the artifactRef of implementation + size_t last_mdd = plan_.implementation.length () - 1; + Deployment::MonolithicDeploymentDescription& mdd = plan_.implementation[last_mdd]; + size_t ref_len = mdd.artifactRef.length (); + mdd.artifactRef.length (ref_len + 1); + mdd.artifactRef[ref_len] = arti_len; + } + + //visit the actual ImplementationArtifactDescriptor + Accept (*this, nia.referencedArtifact); +} + + +void PCVisitor::Visit (Deployment::ImplementationArtifactDescription &iad) +{ + if (!modify_) + { + size_t last_arti = plan_.artifact.length (); + Deployment::ArtifactDeploymentDescription& add = plan_.artifact[last_arti - 1]; + + //set the location + size_t plan_loc_len = add.location.length (); + size_t num_loc = iad.location.length (); + for (size_t i = 0; i < num_loc; ++i) + { + add.location.length (plan_loc_len + 1); + add.location[plan_loc_len] = iad.location[i]; + ++plan_loc_len; + } + + //set the execParameter + update_execParameter (iad, add); + } + + else + { + size_t num_arti = plan_.artifact.length (); + for (size_t i = 0; i < num_arti; ++i) + { + if (ACE_OS::strstr (iad.location[0], plan_.artifact[i].location[0])) + plan_.artifact[i].location[0] = iad.location[0]; + } + } +} + + +//ComponentPackageReference descendents + +void PCVisitor::Visit (Deployment::ComponentPackageReference &) +{ + //not implemented +} + + +//properties + +void PCVisitor::Visit (Deployment::AssemblyPropertyMapping &) +{ +} + + +void PCVisitor::Visit (Deployment::Property &) +{ +} + + +//requirements & capabilities + +void PCVisitor::Visit (Deployment::Requirement &) +{ +} + + +void PCVisitor::Visit (Deployment::Capability &) +{ +} + + +void PCVisitor::Visit (Deployment::ImplementationRequirement &) +{ +} + + +void PCVisitor::Visit (Deployment::ImplementationDependency &) +{ +} + +//ports and connections + +void PCVisitor::Visit (Deployment::AssemblyConnectionDescription &) +{ +} + + +void PCVisitor::Visit (Deployment::SubcomponentPortEndpoint &) +{ +} + + +void PCVisitor::Visit (Deployment::ComponentExternalPortEndpoint &) +{ +} + +void PCVisitor:: +update_execParameter (Deployment::ImplementationArtifactDescription& iad, + Deployment::ArtifactDeploymentDescription& add) +{ + size_t num_execP = iad.execParameter.length (); + size_t execP_len = add.execParameter.length (); + for (size_t j = 0; j < num_execP; ++j) + { + add.execParameter.length (execP_len + 1); + add.execParameter[execP_len] = iad.execParameter[j]; + ++execP_len; + } +} diff --git a/CIAO/DAnCE/Plan_Generator/PCVisitor.h b/CIAO/DAnCE/Plan_Generator/PCVisitor.h new file mode 100644 index 00000000000..6242089ecb4 --- /dev/null +++ b/CIAO/DAnCE/Plan_Generator/PCVisitor.h @@ -0,0 +1,128 @@ +/* -*- C++ -*- */ + +//======================================================================== +/** + * file PCVisitor.h + * + * $Id$ + * + * This file contains a number of Visitor classes which are used to + * traverse the PackageConfiguration element defined in the + * PackagingData.idl + * + * author Stoyan Paunov <spaunov@isis.vanderbilt.edu> + * Shanshan Jiang <shanshan.jiang@vanderbilt.edu> + */ +//======================================================================== + +#ifndef PC_VISITOR_H +#define PC_VISITOR_H + +#include /**/ "ace/pre.h" +#include "PCVisitorBase.h" //for the base visitor + +//=========================================================================== +/** + * class PCVisitor + * + * This class is is the actual implementation for the PackageConfiguration + * Visitor. It derives from PCVisitorBase and overloads the functions which + * deal with single elements. Sequences are handled in the base class. + */ +//=========================================================================== + + +class PCVisitor : public PCVisitorBase +{ +public: + //constructor + PCVisitor (Deployment::DeploymentPlan &plan, + Deployment::PackageConfiguration &pc, + bool modify); + + ///Entry point to protected Visitor functions + int Visit (); + +protected: + /// A whole slew of overloaded routines for different IDL + /// data types part of the PackageConfiguration. + + virtual + void Visit (Deployment::PackageConfiguration &pc); + + //ComponentPackageDescription descendents + virtual + void Visit (Deployment::ComponentPackageDescription &cpd); + + virtual + void Visit (Deployment::ComponentInterfaceDescription &cid); + + virtual + void Visit (Deployment::PackagedComponentImplementation &pci); + + virtual + void Visit (Deployment::ComponentImplementationDescription &cid); + + virtual + void Visit (Deployment::ComponentAssemblyDescription &cad); + + virtual + void Visit (Deployment::SubcomponentInstantiationDescription &sid); + + virtual + void Visit (Deployment::MonolithicImplementationDescription &mid); + + virtual + void Visit (Deployment::NamedImplementationArtifact &nia); + + virtual + void Visit (Deployment::ImplementationArtifactDescription &iad); + + //ComponentPackageReference descendents + virtual + void Visit (Deployment::ComponentPackageReference &cpr); + + //properties + virtual + void Visit (Deployment::AssemblyPropertyMapping &apm); + + virtual + void Visit (Deployment::Property &property); + + //requirements & capabilities + virtual + void Visit (Deployment::Requirement &requirement); + + virtual + void Visit (Deployment::Capability &capability); + + virtual + void Visit (Deployment::ImplementationRequirement &ir); + + virtual + void Visit (Deployment::ImplementationDependency &id); + + //ports and connections + virtual + void Visit (Deployment::AssemblyConnectionDescription &acd); + + virtual + void Visit (Deployment::SubcomponentPortEndpoint &spe); + + virtual + void Visit (Deployment::ComponentExternalPortEndpoint &cepe); + +protected: + void update_execParameter (Deployment::ImplementationArtifactDescription& iad, + Deployment::ArtifactDeploymentDescription& add); + +private: + Deployment::DeploymentPlan& plan_; + Deployment::PackageConfiguration& pc_; + size_t last_impl_index_; + bool modify_; +}; + +#include /**/ "ace/post.h" + +#endif /* PC_VISITOR_H */ diff --git a/CIAO/DAnCE/Plan_Generator/PCVisitorBase.cpp b/CIAO/DAnCE/Plan_Generator/PCVisitorBase.cpp new file mode 100644 index 00000000000..c8ffc983095 --- /dev/null +++ b/CIAO/DAnCE/Plan_Generator/PCVisitorBase.cpp @@ -0,0 +1,28 @@ +/* -*- C++ -*- */ + +//======================================================================== +/* + * file PCVisitorBase.cpp + * + * $Id$ + * + * This file is a dummy which either includes the PCVisitorBase.inl or + * is ignored. + * + * author Stoyan Paunov <spaunov@isis.vanderbilt.edu> + */ +//======================================================================== + +#include "PCVisitorBase.h" + +PCVisitorBase::PCVisitorBase (void) +{ +} + +PCVisitorBase::~PCVisitorBase (void) +{ +} + +#if !defined (__ACE_INLINE__) +#include "PCVisitorBase.inl" +#endif /* __ACE_INLINE__ */ diff --git a/CIAO/DAnCE/Plan_Generator/PCVisitorBase.h b/CIAO/DAnCE/Plan_Generator/PCVisitorBase.h new file mode 100644 index 00000000000..bd68eb18ca5 --- /dev/null +++ b/CIAO/DAnCE/Plan_Generator/PCVisitorBase.h @@ -0,0 +1,172 @@ +/* -*- C++ -*- */ + +//======================================================================== +/** + * file PCVisitorBase.h + * + * $Id$ + * + * This file contains the virtual base class for the PackageConfiguration + * Visitor which is used to traverse the PackageConfiguration element + * defined in the PackagingData.idl. The PackageConfiguration has a + * number of sequence elements. This class actually implements the + * operations which involve sequences and delegates the calls to + * the operations which handle single elements from the sequence type. + * + * author Stoyan Paunov <spaunov@isis.vanderbilt.edu> + */ +//======================================================================== + +#ifndef PC_VISITOR_BASE_H +#define PC_VISITOR_BASE_H + +#include /**/ "ace/pre.h" +#include "ciao/DeploymentC.h" + +//======================================================================== +/** + * class PCVisitorBase + * + * This class is a virtual base class for the PackageConfiguration Visitor + * The operation which deal with sequences are implemented here by means + * of the visit_sequence function above, in order to make the logic of + * derived classes easier to write. Writers of derived classes need only + * overload the functions which deal with single elements. Sequences are + * always handled here. + */ +//======================================================================== + + +class PCVisitorBase +{ +public: + //constructor + PCVisitorBase (void); + + //destructor + virtual + ~PCVisitorBase (void); + + ///function what dispatches sequences + template <typename SEQ> + friend void visit_sequence (SEQ &seq, PCVisitorBase& v); + + /// A whole slew of overloaded routines for different IDL + /// data types part of the PackageConfiguration. + + virtual + void Visit (Deployment::PackageConfiguration &pc) = 0; + void Visit (Deployment::PackageConfigurations &pcs); + + //ComponentPackageDescription descendents + virtual + void Visit (Deployment::ComponentPackageDescription &cpd) = 0; + void Visit (Deployment::ComponentPackageDescriptions &cpds); + + virtual + void Visit (Deployment::ComponentInterfaceDescription &cid) = 0; + //void Visit (Deployment::ComponentInterfaceDescriptions &cids); + + virtual + void Visit (Deployment::PackagedComponentImplementation &pci) = 0; + void Visit (Deployment::PackagedComponentImplementations &pcis); + + virtual + void Visit (Deployment::ComponentImplementationDescription &cid) = 0; + //void Visit (Deployment::ComponentImplementationDescriptions &cids); + + virtual + void Visit (Deployment::ComponentAssemblyDescription &cad) = 0; + void Visit (Deployment::ComponentAssemblyDescriptions &cads); + + virtual + void Visit (Deployment::SubcomponentInstantiationDescription &sid) = 0; + void Visit (Deployment::SubcomponentInstantiationDescriptions &sids); + + virtual + void Visit (Deployment::MonolithicImplementationDescription &mid) = 0; + void Visit (Deployment::MonolithicImplementationDescriptions &mids); + + virtual + void Visit (Deployment::NamedImplementationArtifact &nia) = 0; + void Visit (Deployment::NamedImplementationArtifacts &nias); + + virtual + void Visit (Deployment::ImplementationArtifactDescription &iad) = 0; + //void Visit (Deployment::ImplementationArtifactDescriptions &iads); + + //ComponentPackageReference descendents + virtual + void Visit (Deployment::ComponentPackageReference &cpr) = 0; + void Visit (Deployment::ComponentPackageReferences &cprs); + + //properties + virtual + void Visit (Deployment::AssemblyPropertyMapping &apm) = 0; + void Visit (Deployment::AssemblyPropertyMappings &apms); + + virtual + void Visit (Deployment::Property &property) = 0; + void Visit (Deployment::Properties &properties); + + //requirements & capabilities + virtual + void Visit (Deployment::Requirement &requirement) = 0; + void Visit (Deployment::Requirements &requirements); + + virtual + void Visit (Deployment::Capability &capability) = 0; + void Visit (Deployment::Capabilities &capabilities); + + virtual + void Visit (Deployment::ImplementationRequirement &ir) = 0; + void Visit (Deployment::ImplementationRequirements &irs); + + virtual + void Visit (Deployment::ImplementationDependency &id) = 0; + void Visit (Deployment::ImplementationDependencies &ids); + + //ports and connections + virtual + void Visit (Deployment::AssemblyConnectionDescription &acd) = 0; + void Visit (Deployment::AssemblyConnectionDescriptions &acds); + + virtual + void Visit (Deployment::SubcomponentPortEndpoint &spe) = 0; + void Visit (Deployment::SubcomponentPortEndpoints &spes); + + virtual + void Visit (Deployment::ComponentExternalPortEndpoint &cepe) = 0; + void Visit (Deployment::ComponentExternalPortEndpoints &cepes); +}; + +template <typename T> +void Accept (PCVisitorBase &v, T& element_to_visit) +{ + v.Visit (element_to_visit); +} + +/** + * function - visit_sequence + * + * This function is used to handle sequences of elements where each + * element takes the form of a Visitor Node. + */ +template <typename SEQ> +void visit_sequence (SEQ &seq, PCVisitorBase& v) +{ + const CORBA::ULong size = seq.length (); + + for (CORBA::ULong i = 0; i < size; ++i) + { + Accept(v, seq[i]); + } +} + +#if defined (__ACE_INLINE__) +#include "PCVisitorBase.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* PC_VISITOR_BASE_H */ diff --git a/CIAO/DAnCE/Plan_Generator/PCVisitorBase.inl b/CIAO/DAnCE/Plan_Generator/PCVisitorBase.inl new file mode 100644 index 00000000000..955aefb7c4e --- /dev/null +++ b/CIAO/DAnCE/Plan_Generator/PCVisitorBase.inl @@ -0,0 +1,155 @@ +/* -*- C++ -*- */ + +//======================================================================== +/* + * file PCVisitorBase.inl + * + * $Id$ + * + * This file contains the implementation of the sequence-based + * PackageConfiguration Visitor functions. By implementing these + * we relieve developers of derived classes of the burden of handling + * the correct traversal of sequence-based elements. This implementation + * used the visit_sequence templatized function to do the heavy lifting. + * + * author Stoyan Paunov <spaunov@isis.vanderbilt.edu> + */ +//======================================================================== + + +/// A whole slew of overloaded routines for different IDL +/// data types part of the PackageConfiguration. + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::PackageConfigurations &pcs) +{ + visit_sequence (pcs, *this); +} + +//ComponentPackageDescription descendents + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ComponentPackageDescriptions &cpds) +{ + visit_sequence (cpds, *this); +} + +//NOT a member of Deployment + +//ACE_INLINE void PCVisitorBase::Visit +// (Deployment::ComponentInterfaceDescriptions &cids) +//{ +// visit_sequence (cids, *this); +//} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::PackagedComponentImplementations &pcis) +{ + visit_sequence (pcis, *this); +} + +//NOT a member of Deployment + +//ACE_INLINE void PCVisitorBase::Visit +// (Deployment::ComponentImplementationDescriptions &cids) +//{ +// visit_sequence (cids, *this); +//} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ComponentAssemblyDescriptions &cads) +{ + visit_sequence (cads, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::SubcomponentInstantiationDescriptions &sids) +{ + visit_sequence (sids, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::MonolithicImplementationDescriptions &mids) +{ + visit_sequence (mids, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::NamedImplementationArtifacts &nias) +{ + visit_sequence (nias, *this); +} + +//ACE_INLINE void PCVisitorBase::Visit +// (Deployment::ImplementationArtifactDescriptions &iads) +//{ +// visit_sequence (iads, *this); +//} + +//ComponentPackageReference descendents + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ComponentPackageReferences &cprs) +{ + visit_sequence (cprs, *this); +} + +//properties + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::AssemblyPropertyMappings &apms) +{ + visit_sequence (apms, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::Properties &properties) +{ + visit_sequence (properties, *this); +} + +//requirements & capabilities + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::Requirements &requirements) +{ + visit_sequence (requirements, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::Capabilities &capabilities) +{ + visit_sequence (capabilities, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ImplementationRequirements &irs) +{ + visit_sequence (irs, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ImplementationDependencies &ids) +{ + visit_sequence (ids, *this); +} + +//ports and connections + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::AssemblyConnectionDescriptions &acds) +{ + visit_sequence (acds, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::SubcomponentPortEndpoints &spes) +{ + visit_sequence (spes, *this); +} + +ACE_INLINE void PCVisitorBase::Visit +(Deployment::ComponentExternalPortEndpoints &cepes) +{ + visit_sequence (cepes, *this); +} diff --git a/CIAO/DAnCE/Plan_Generator/Plan_Generator.mpc b/CIAO/DAnCE/Plan_Generator/Plan_Generator.mpc new file mode 100644 index 00000000000..77640087acb --- /dev/null +++ b/CIAO/DAnCE/Plan_Generator/Plan_Generator.mpc @@ -0,0 +1,24 @@ +// -*- MPC -*- +//$Id$ + +project (Plan_Generator): ciao_component_dnc { + sharedname = Plan_Generator + requires += RepositoryManager + after += RepositoryManager + + dynamicflags = PLAN_GENERATOR_IMPL_BUILD_DLL + + Source_Files { + Plan_Generator_Impl.cpp + PCVisitorBase.cpp + PCVisitor.cpp + } + + Header_Files { + Plan_Generator_Impl.h + PCVisitor.h + PCVisitorBase.h + Plan_Generator_Impl_Export.h + } +} + diff --git a/CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl.cpp b/CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl.cpp new file mode 100644 index 00000000000..4e744179cbd --- /dev/null +++ b/CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl.cpp @@ -0,0 +1,143 @@ +/** + * $Id$ + * @file Plan_Generator_Impl.cpp + * @author Shanshan Jiang <shanshan.jiang@vanderbilt.edu> + */ + +#include "Plan_Generator_Impl.h" +#include "orbsvcs/CosNamingC.h" +#include "PCVisitor.h" +#include "PCVisitorBase.h" + +namespace CIAO +{ + namespace Plan_Generator + { + static CORBA::Object_ptr + fetch_reference_naming (CORBA::ORB_ptr orb, + const char *repoman_name = 0 + ACE_ENV_ARG_DECL) + { + CORBA::Object_var tmp = + orb->resolve_initial_references ("NameService" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CosNaming::NamingContext_var pns = + CosNaming::NamingContext::_narrow (tmp.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CosNaming::Name name (1); + name.length (1); + + name[0].id = CORBA::string_dup (repoman_name); + + return pns->resolve (name + ACE_ENV_ARG_PARAMETER); + } + + Plan_Generator_i::Plan_Generator_i () + : rm_ () + { + } + + bool + Plan_Generator_i::init (CORBA::ORB_ptr orb, + bool rm_use_naming, + const char *rm_name) + { + CORBA::Object_var obj; + + if (rm_use_naming) + { + obj = fetch_reference_naming (orb, rm_name ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { + obj = orb->string_to_object (rm_name ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + this->rm_ = Deployment::RepositoryManager::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (this->rm_.in ())) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) CIAO_PlanGenerator: nil Repository" + " Manager reference, narrow failed\n")); + return false; + } + + return true; + } + + bool + Plan_Generator_i::generate_plan (Deployment::DeploymentPlan &plan, + const char *package_uri, + bool use_package_name) + { + + ::Deployment::PackageConfiguration_var pc; + + ACE_TCHAR package[PACKAGE_NAME_LEN]; + + size_t length = ACE_OS::strlen (package_uri); + + size_t pos1 = 0; + size_t pos2 = ACE_OS::strcspn (package_uri + pos1, "+"); + + while (pos1 < length) + { + ACE_OS::strsncpy (package, package_uri + pos1, pos2 + 1); + + if (use_package_name) + { + pc = this->rm_->findPackageByName (package); + + PCVisitor pcv (plan, *pc, true); + pcv.Visit (); + } + else + { + CORBA::StringSeq_var seq = this->rm_->findNamesByType (package); + + for (size_t i = 0; i < seq->length (); ++i) + { + pc = this->rm_->findPackageByName (seq[i]); + + PCVisitor pcv (plan, *pc, true); + pcv.Visit (); + } + } + + pos1 += pos2 + 1; + pos2 = ACE_OS::strcspn (package_uri + pos1, "+"); + } + + return true; + } + + bool + Plan_Generator_i::generate_plan (Deployment::DeploymentPlan &plan, + const char *specific_type, + int &index) + { + ::Deployment::PackageConfiguration_var pc; + + CORBA::StringSeq_var seq = rm_->findNamesByType (specific_type); + for (size_t i = 0; i < seq->length (); ++i) + { + pc = rm_->findPackageByName (seq[i]); + + PCVisitor pcv (plan, *pc, false); + index = pcv.Visit (); + } + + return true; + } + + } +} diff --git a/CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl.h b/CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl.h new file mode 100644 index 00000000000..78acb005d72 --- /dev/null +++ b/CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl.h @@ -0,0 +1,78 @@ +/** + * $Id$ + * @file Plan_Generator_Impl.h + * @author Shanshan Jiang <shanshan.jiang@vanderbilt.edu> + * + * Contains the Plan_Generator_i class, which can be used to generate/modify + * DeploymentPlans. + */ + +#ifndef PLAN_GENERATOR_IMPL_H +#define PLAN_GENERATOR_IMPL_H + +#include "ciao/RepositoryManagerC.h" +#include "Plan_Generator_Impl_Export.h" + +namespace CIAO +{ + namespace Plan_Generator + { + const size_t PACKAGE_NAME_LEN = 1024; + + /** + * @class Plan_Generator_i + * @brief This class generates or modifies deployment plans. + */ + class Plan_Generator_Impl_Export Plan_Generator_i + { + public: + Plan_Generator_i (); + + /** + * @fn init + * @brief Get the proper Repoman, using naming service or ior file. + * @param orb + * @param rm_use_naming Whether use naming service or not. + * @param rm_name The name of the Repoman. + * @returns a boolean denoting if this operation is successful or not. + */ + bool init (CORBA::ORB_ptr orb, + bool rm_use_naming = 0, + const char *rm_name = 0); + + /** + * @fn generate_plan + * @brief Use the package name(s) or type(s) to get the PackageConfiguration + * provided by Repoman; and then use the PackageConfiguration to + * modify the location of all the artifacts in DeploymentPlan. + * @param plan A DeploymentPlan that need to be updated. + * @param package_uri The package name(s) or type(s). + * @param use_package_name Use package name(s) or type(s). + * @returns a boolean denoting if this operation is successful or not. + */ + bool generate_plan (Deployment::DeploymentPlan &plan, + const char *package_uri, + bool use_package_name); + + /** + * @fn generate_plan + * @brief Use the specific type of a package to get the PackageConfiguration + * provided by Repoman; and then use the PackageConfiguration to + * generate the implementation and artifact fields in DeploymentPlan. + * @param plan A DeploymentPlan that need to be updated. + * @param package_uri The package specific type. + * @param index The index of the newly generated implementation and artifact fields. + * @returns a boolean denoting if this operation is successful or not. + */ + bool generate_plan (Deployment::DeploymentPlan &plan, + const char *specific_type, + int &index); + + private: + Deployment::RepositoryManager_var rm_; + }; + + } +} + +#endif /* PLAN_GENERATOR_IMPL_H */ diff --git a/CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl_Export.h b/CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl_Export.h new file mode 100644 index 00000000000..fd120ff7b73 --- /dev/null +++ b/CIAO/DAnCE/Plan_Generator/Plan_Generator_Impl_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl Plan_Generator_Impl +// ------------------------------ +#ifndef PLAN_GENERATOR_IMPL_EXPORT_H +#define PLAN_GENERATOR_IMPL_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (PLAN_GENERATOR_IMPL_HAS_DLL) +# define PLAN_GENERATOR_IMPL_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && PLAN_GENERATOR_IMPL_HAS_DLL */ + +#if !defined (PLAN_GENERATOR_IMPL_HAS_DLL) +# define PLAN_GENERATOR_IMPL_HAS_DLL 1 +#endif /* ! PLAN_GENERATOR_IMPL_HAS_DLL */ + +#if defined (PLAN_GENERATOR_IMPL_HAS_DLL) && (PLAN_GENERATOR_IMPL_HAS_DLL == 1) +# if defined (PLAN_GENERATOR_IMPL_BUILD_DLL) +# define Plan_Generator_Impl_Export ACE_Proper_Export_Flag +# define PLAN_GENERATOR_IMPL_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define PLAN_GENERATOR_IMPL_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* PLAN_GENERATOR_IMPL_BUILD_DLL */ +# define Plan_Generator_Impl_Export ACE_Proper_Import_Flag +# define PLAN_GENERATOR_IMPL_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define PLAN_GENERATOR_IMPL_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* PLAN_GENERATOR_IMPL_BUILD_DLL */ +#else /* PLAN_GENERATOR_IMPL_HAS_DLL == 1 */ +# define Plan_Generator_Impl_Export +# define PLAN_GENERATOR_IMPL_SINGLETON_DECLARATION(T) +# define PLAN_GENERATOR_IMPL_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* PLAN_GENERATOR_IMPL_HAS_DLL == 1 */ + +// Set PLAN_GENERATOR_IMPL_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (PLAN_GENERATOR_IMPL_NTRACE) +# if (ACE_NTRACE == 1) +# define PLAN_GENERATOR_IMPL_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define PLAN_GENERATOR_IMPL_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !PLAN_GENERATOR_IMPL_NTRACE */ + +#if (PLAN_GENERATOR_IMPL_NTRACE == 1) +# define PLAN_GENERATOR_IMPL_TRACE(X) +#else /* (PLAN_GENERATOR_IMPL_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define PLAN_GENERATOR_IMPL_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (PLAN_GENERATOR_IMPL_NTRACE == 1) */ + +#endif /* PLAN_GENERATOR_IMPL_EXPORT_H */ + +// End of auto generated file. |