diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2010-08-12 19:20:12 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2010-08-12 19:20:12 +0000 |
commit | 7196bd773a68121753eea41af8fd6c9c5d09fee6 (patch) | |
tree | 122401d7dce833e85d29fb8abc5e9a5b56f409b6 | |
parent | c04c4c05c46442762fd88b9412ab6fd1b104f47e (diff) | |
download | ATCD-7196bd773a68121753eea41af8fd6c9c5d09fee6.tar.gz |
Thu Aug 12 19:19:00 UTC 2010 William R. Otte <wotte@dre.vanderbilt.edu>
* DAnCE/Config_Handlers/DD_Handler.h:
* DAnCE/Config_Handlers/DD_Handler.cpp:
* DAnCE/Config_Handlers/XML_File_Intf.h:
* DAnCE/Config_Handlers/XML_File_Intf.cpp:
Added domain parsing to the XML_File_Intf.
* DAnCE/TargetManager/DomainDataManager.cpp:
Transition to XML_File_Intf instead of using DD_Handler
directly.
-rw-r--r-- | CIAO/ChangeLog | 14 | ||||
-rw-r--r-- | CIAO/DAnCE/Config_Handlers/DD_Handler.cpp | 45 | ||||
-rw-r--r-- | CIAO/DAnCE/Config_Handlers/DD_Handler.h | 14 | ||||
-rw-r--r-- | CIAO/DAnCE/Config_Handlers/XML_File_Intf.cpp | 102 | ||||
-rw-r--r-- | CIAO/DAnCE/Config_Handlers/XML_File_Intf.h | 9 | ||||
-rw-r--r-- | CIAO/DAnCE/TargetManager/DomainDataManager.cpp | 8 |
6 files changed, 153 insertions, 39 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 4858252529b..e1aeb1195fc 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,17 @@ +Thu Aug 12 19:19:00 UTC 2010 William R. Otte <wotte@dre.vanderbilt.edu> + + * DAnCE/Config_Handlers/DD_Handler.h: + * DAnCE/Config_Handlers/DD_Handler.cpp: + * DAnCE/Config_Handlers/XML_File_Intf.h: + * DAnCE/Config_Handlers/XML_File_Intf.cpp: + + Added domain parsing to the XML_File_Intf. + + * DAnCE/TargetManager/DomainDataManager.cpp: + + Transition to XML_File_Intf instead of using DD_Handler + directly. + Thu Aug 12 14:04:30 UTC 2010 Adam Mitz <mitza@ociweb.com> * docs/fm/CIAO.htm: diff --git a/CIAO/DAnCE/Config_Handlers/DD_Handler.cpp b/CIAO/DAnCE/Config_Handlers/DD_Handler.cpp index 81ec2526fc1..7d2b32abfca 100644 --- a/CIAO/DAnCE/Config_Handlers/DD_Handler.cpp +++ b/CIAO/DAnCE/Config_Handlers/DD_Handler.cpp @@ -14,9 +14,10 @@ namespace CIAO { namespace Config_Handlers { + /* DD_Handler::DD_Handler (const ACE_TCHAR *file) : idl_domain_(0), - domain_ (0), + domain_ptr_ (0), retval_ (false) { DANCE_TRACE("DP_PCD_Handler::constructor"); @@ -32,15 +33,17 @@ namespace CIAO // Domain d = domain (dom); - this->domain_.reset (dm); + this->domain_ptr_.reset (dm); if (!this->build_domain ()) throw NoDomain (); } + */ DD_Handler::DD_Handler (Domain *dmn): idl_domain_(0), - domain_(dmn), + domain_ptr_ (dmn), + domain_ (*dmn), retval_(false) { DANCE_TRACE("DP_PCD_Handler::constructor - Domain"); @@ -48,14 +51,26 @@ namespace CIAO throw NoDomain (); } + DD_Handler::DD_Handler (Domain &dmn): + idl_domain_(0), + domain_ (dmn), + retval_(false) + { + DANCE_TRACE("DP_PCD_Handler::constructor - Domain"); + if(!this->build_domain ()) + throw NoDomain (); + } + + /* DD_Handler::DD_Handler (::Deployment::Domain *dmn): idl_domain_(dmn), - domain_(0), + domain_ptr_ (dmn), retval_(false) { if(!this->build_xsc()) throw NoDomain (); } + */ DD_Handler::~DD_Handler (void) { @@ -69,21 +84,21 @@ namespace CIAO // Read in the name // Check if the label is there or not - if (domain_->label_p ()) + if (domain_.label_p ()) this->idl_domain_->label = - CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (domain_->label ().c_str ())); + CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (domain_.label ().c_str ())); - if (domain_->UUID_p ()) + if (domain_.UUID_p ()) this->idl_domain_->UUID = - CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (domain_->UUID ().c_str ())); + CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (domain_.UUID ().c_str ())); - CORBA::ULong len = domain_->count_node (); + CORBA::ULong len = domain_.count_node (); this->idl_domain_->node.length (len); //Resource _resource; int i =0; - for (Domain::node_const_iterator iter = domain_->begin_node (); - iter != domain_->end_node (); + for (Domain::node_const_iterator iter = domain_.begin_node (); + iter != domain_.end_node (); ++iter,++i ) { @@ -191,21 +206,21 @@ namespace CIAO Domain const * DD_Handler::domain_xsc () const { - if(!this->domain_.get()) + if(!this->domain_ptr_.get()) throw NoDomain (); //else - return this->domain_.get(); + return this->domain_ptr_.get(); } Domain * DD_Handler::domain_xsc () { - if(!this->domain_.get()) + if(!this->domain_ptr_.get()) throw NoDomain (); //else - return this->domain_.release(); + return this->domain_ptr_.release(); } } } diff --git a/CIAO/DAnCE/Config_Handlers/DD_Handler.h b/CIAO/DAnCE/Config_Handlers/DD_Handler.h index f3a9e0c60c9..126f9779c9a 100644 --- a/CIAO/DAnCE/Config_Handlers/DD_Handler.h +++ b/CIAO/DAnCE/Config_Handlers/DD_Handler.h @@ -44,20 +44,13 @@ class Config_Handlers_Export DD_Handler public: class NoDomain {}; -/** -* @param file The file to be read -*/ -DD_Handler (const ACE_TCHAR *file); /** * @param dmn The Domain structure */ DD_Handler(Domain *dmn); -/** -* @param dmn The Deployment::Domain structure -*/ -DD_Handler(::Deployment::Domain *dmn); +DD_Handler(Domain &dmn); /** */ @@ -102,8 +95,9 @@ bool build_xsc (); auto_ptr < ::Deployment::Domain > idl_domain_; /// The XSC Domain structure -auto_ptr <Domain> domain_; - +auto_ptr <Domain> domain_ptr_; + + Domain &domain_; /// The return value used bool retval_; }; diff --git a/CIAO/DAnCE/Config_Handlers/XML_File_Intf.cpp b/CIAO/DAnCE/Config_Handlers/XML_File_Intf.cpp index db43e300fd3..1e16b5570a8 100644 --- a/CIAO/DAnCE/Config_Handlers/XML_File_Intf.cpp +++ b/CIAO/DAnCE/Config_Handlers/XML_File_Intf.cpp @@ -4,9 +4,11 @@ #include "XML_Typedefs.h" #include "Deployment.hpp" #include "DP_Handler.h" +#include "DD_Handler.h" #include "Common.h" #include "DAnCE/Deployment/Deployment_DataC.h" +#include "DAnCE/Deployment/Deployment_TargetDataC.h" #include "DAnCE/Logger/Log_Macros.h" namespace CIAO @@ -25,37 +27,37 @@ namespace CIAO } bool - XML_File_Intf::read_process_file (const ACE_TCHAR *file) + XML_File_Intf::read_process_plan (const ACE_TCHAR *file) { - DANCE_TRACE("XML_File_Intf::read_process_file"); + DANCE_TRACE("XML_File_Intf::read_process_plan"); try { if (!XML_Helper::XML_HELPER.is_initialized ()) return false; - DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_file - ") + DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ") ACE_TEXT ("Constructing DOM\n"))); XERCES_CPP_NAMESPACE::DOMDocument *dom = XML_Helper::XML_HELPER.create_dom ((file)); if (dom == 0) { - DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::read_process_file - ") + DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ") ACE_TEXT ("Failed to open file %s\n"), file)); return false; } XERCES_CPP_NAMESPACE::DOMElement *foo = dom->getDocumentElement (); - DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_file - ") + DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ") ACE_TEXT ("DOMElement pointer: %u\n"), foo)); - DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_file - ") + DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ") ACE_TEXT ("Parsing XML file with XSC\n"))); deploymentPlan dp = CIAO::Config_Handlers::reader::DeploymentPlan (dom); - DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_file - ") + DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_plan - ") ACE_TEXT ("Processing using config handlers\n"))); DP_Handler dp_handler (dp); @@ -87,11 +89,74 @@ namespace CIAO return false; } + bool + XML_File_Intf::read_process_domain (const ACE_TCHAR *file) + { + DANCE_TRACE("XML_File_Intf::read_process_domain"); + + try + { + if (!XML_Helper::XML_HELPER.is_initialized ()) + return false; + + DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_domain - ") + ACE_TEXT ("Constructing DOM\n"))); + XERCES_CPP_NAMESPACE::DOMDocument *dom = + XML_Helper::XML_HELPER.create_dom ((file)); + + if (dom == 0) + { + DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::read_process_domain - ") + ACE_TEXT ("Failed to open file %s\n"), file)); + return false; + } + + XERCES_CPP_NAMESPACE::DOMElement *foo = dom->getDocumentElement (); + DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_domain - ") + ACE_TEXT ("DOMElement pointer: %u\n"), foo)); + + DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_domain - ") + ACE_TEXT ("Parsing XML file with XSC\n"))); + Domain dp = + CIAO::Config_Handlers::reader::domain (dom); + + DANCE_DEBUG (6, (LM_TRACE, DLINFO ACE_TEXT ("XML_File_Intf::read_process_domain - ") + ACE_TEXT ("Processing using config handlers\n"))); + DD_Handler dp_handler (dp); + + this->idl_domain_.reset (dp_handler.domain_idl ()); + + if (this->idl_domain_.get ()) + return true; + } + catch (CORBA::Exception &ex) + { + DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::caught - ") + ACE_TEXT ("CORBA Exception whilst parsing XML into IDL\n"), + ex._info ().c_str ())); + throw Config_Error (this->file_, + ex._info ().c_str ()); + } + catch (Config_Error &ex) + { + throw ex; + } + catch (...) + { + DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("XML_File_Intf::caught - ") + ACE_TEXT ("Unexpected exception whilst parsing XML into IDL.\n"))); + throw Config_Error (this->file_, + ACE_TEXT ("Unexpected C++ exception whilst parsing XML")); + } + + return false; + } + ::Deployment::DeploymentPlan const * XML_File_Intf::get_plan (void) { DANCE_TRACE("get_plan"); - if (this->idl_dp_.get () == 0 && !this->read_process_file (this->file_.c_str ())) + if (this->idl_dp_.get () == 0 && !this->read_process_plan (this->file_.c_str ())) return 0; return this->idl_dp_.get (); @@ -101,11 +166,30 @@ namespace CIAO XML_File_Intf::release_plan (void) { DANCE_TRACE("XML_File_Intf::get_plan"); - if (this->idl_dp_.get () == 0 && !this->read_process_file (this->file_.c_str ())) + if (this->idl_dp_.get () == 0 && !this->read_process_plan (this->file_.c_str ())) return 0; return this->idl_dp_.release (); } + ::Deployment::Domain const * + XML_File_Intf::get_domain (void) + { + DANCE_TRACE("get_domain"); + if (this->idl_domain_.get () == 0 && !this->read_process_domain (this->file_.c_str ())) + return 0; + + return this->idl_domain_.get (); + } + + ::Deployment::Domain * + XML_File_Intf::release_domain (void) + { + DANCE_TRACE("XML_File_Intf::get_domain"); + if (this->idl_domain_.get () == 0 && !this->read_process_domain (this->file_.c_str ())) + return 0; + return this->idl_domain_.release (); + } + void XML_File_Intf::add_search_path (const ACE_TCHAR *environment, const ACE_TCHAR *relpath) diff --git a/CIAO/DAnCE/Config_Handlers/XML_File_Intf.h b/CIAO/DAnCE/Config_Handlers/XML_File_Intf.h index 04baef8c58a..e35690df593 100644 --- a/CIAO/DAnCE/Config_Handlers/XML_File_Intf.h +++ b/CIAO/DAnCE/Config_Handlers/XML_File_Intf.h @@ -25,6 +25,7 @@ namespace Deployment { struct DeploymentPlan; + struct Domain; } namespace CIAO @@ -41,16 +42,22 @@ namespace CIAO ::Deployment::DeploymentPlan const *get_plan (void); ::Deployment::DeploymentPlan *release_plan (void); + ::Deployment::Domain const *get_domain (void); + ::Deployment::Domain *release_domain (void); + void add_search_path (const ACE_TCHAR *environment, const ACE_TCHAR *relpath); protected: + + bool read_process_plan (const ACE_TCHAR *file); - bool read_process_file (const ACE_TCHAR *file); + bool read_process_domain (const ACE_TCHAR *file); private: std::basic_string <ACE_TCHAR> file_; ACE_Auto_Ptr< ::Deployment::DeploymentPlan> idl_dp_; + ACE_Auto_Ptr< ::Deployment::Domain> idl_domain_; }; } } diff --git a/CIAO/DAnCE/TargetManager/DomainDataManager.cpp b/CIAO/DAnCE/TargetManager/DomainDataManager.cpp index 40583ea0e82..95a70d337be 100644 --- a/CIAO/DAnCE/TargetManager/DomainDataManager.cpp +++ b/CIAO/DAnCE/TargetManager/DomainDataManager.cpp @@ -2,7 +2,7 @@ #include "DomainDataManager.h" #include "Deployment/Deployment_NodeManagerC.h" -#include "Config_Handlers/DD_Handler.h" +#include "Config_Handlers/XML_File_Intf.h" #include "DAnCE/Logger/Log_Macros.h" #ifdef GEN_OSTREAM_OPS @@ -23,9 +23,9 @@ DAnCE::DomainDataManager::init (CORBA::ORB_ptr orb, DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("DAnCE::DomainDataManager::init - ") ACE_TEXT ("Parsing initial domain from file %s\n"), domain_name)); - - CIAO::Config_Handlers::DD_Handler dd (domain_name); - ::Deployment::Domain* dmn = dd.domain_idl (); + + CIAO::Config_Handlers::XML_File_Intf intf (domain_name); + ::Deployment::Domain* dmn = intf.release_domain (); DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT ("DAnCE::DomainDataManager::init - ") ACE_TEXT ("Initial domain successfully parsed\n"))); |