ServiceDeploymentConfiguration.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright 2007, 2008, 2009, 2010, 2011 Instituto de Sistemas e Robotica, Instituto Superior Tecnico
00003 
00004 This file is part of MeRMaID.
00005 
00006 MeRMaID is free software: you can redistribute it and/or modify
00007 it under the terms of the GNU Lesser General Public License as published by
00008 the Free Software Foundation, either version 3 of the License, or
00009 (at your option) any later version.
00010 
00011 MeRMaID is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU Lesser General Public License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public License
00017 along with MeRMaID.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 
00022 /**
00023  * @Filename ServiceDeploymentConfiguration.cpp
00024  * @Description Implementation of the ServiceDeploymentConfiguration class
00025  * @Status Implementing
00026  * @Version $Id: ServiceDeploymentConfiguration.cpp 1 2011-03-04 18:13:18Z jreis $
00027  * @Maintainer Marco Barbosa (mafb@isr.ist.utl.pt)
00028  */
00029 
00030 #include "config.h"
00031 
00032 #include "ServiceDeploymentConfiguration.hpp"
00033 
00034 #include <XmlCharData.hpp>
00035 #include <XmlElementVector.hpp>
00036 #include <Exception.hpp>
00037 
00038 
00039 #include <iostream>
00040 #include <sstream>
00041 
00042 using namespace mermaid::mermaidloader;
00043 
00044 using std::string;
00045 using mermaid::support::xml::XmlCharData;
00046 using mermaid::support::xml::XmlElementVector;
00047 using mermaid::support::errorhandling::Exception;
00048 
00049 
00050 ServiceDeploymentConfiguration::ServiceDeploymentConfiguration (shared_ptr<XmlElement> xml)
00051 {
00052   //std::cerr << "ServiceDeploymentConfiguration : " << (string)*xml << std::endl;
00053   
00054   XmlElementVector children = xml->getChildrenElements();
00055   
00056   {
00057     shared_ptr<XmlElement> headerElement = children.getFirstElementWithName ("header-file");
00058     
00059     if (headerElement == false) {
00060       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have a  header-file node");
00061     }
00062     
00063     shared_ptr<XmlCharData> headerCharData = headerElement->getFirstNonBlankCharData();
00064     
00065     if (headerCharData == false) {
00066       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have character data for the header-file node");
00067     }
00068     
00069     _headerFilename = (string) * headerCharData;
00070     
00071   }
00072   
00073   
00074   {
00075     shared_ptr<XmlElement> namespaceElement = children.getFirstElementWithName ("namespace");
00076     
00077     if (namespaceElement == false) {
00078       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have a  namespace node");
00079     }
00080     
00081     shared_ptr<XmlCharData> namespaceCharData = namespaceElement->getFirstNonBlankCharData();
00082     
00083     if (namespaceCharData == false) {
00084       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have character data for the namespace node");
00085     }
00086     
00087     _namespace = (string) * namespaceCharData;
00088     
00089   }
00090   
00091   
00092   {
00093     shared_ptr<XmlElement> classElement = children.getFirstElementWithName ("class-name");
00094     
00095     if (classElement == false) {
00096       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have a  class-name node");
00097     }
00098     
00099     shared_ptr<XmlCharData> classCharData = classElement->getFirstNonBlankCharData();
00100     
00101     if (classCharData == false) {
00102       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have character data for the class-name node");
00103     }
00104     
00105     _className = (string) * classCharData;
00106     
00107   }
00108   
00109   {
00110     shared_ptr<XmlElement> entityElement = children.getFirstElementWithName ("entity-name");
00111     
00112     if (entityElement == false) {
00113       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have a  entity-name node");
00114     }
00115     
00116     shared_ptr<XmlCharData> entityCharData = entityElement->getFirstNonBlankCharData();
00117     
00118     if (entityCharData == false) {
00119       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have character data for the entity-name node");
00120     }
00121     
00122     _entityName = (string) * entityCharData;
00123     
00124   }
00125   
00126   {
00127     shared_ptr<XmlElement> instanceElement = children.getFirstElementWithName ("instance-name");
00128     
00129     if (instanceElement == false) {
00130       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have a  instance-name node");
00131     }
00132     
00133     shared_ptr<XmlCharData> instanceCharData = instanceElement->getFirstNonBlankCharData();
00134     
00135     if (instanceCharData == false) {
00136       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have character data for the instance-name node");
00137     }
00138     
00139     _instanceName = (string) * instanceCharData;
00140     
00141   }
00142   
00143   
00144   {
00145     shared_ptr<XmlElement> configurationElement = children.getFirstElementWithName ("configuration-file");
00146     
00147     if (configurationElement == false) {
00148       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have a  configuration-file node");
00149     }
00150     
00151     shared_ptr<XmlCharData> configurationCharData = configurationElement->getFirstNonBlankCharData();
00152     
00153     if (configurationCharData == false) {
00154       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have character data for the configuration-file node");
00155     }
00156     
00157     _configurationFilename = (string) * configurationCharData;
00158     
00159   }
00160   
00161   {
00162     shared_ptr<XmlElement> aonameElement = children.getFirstElementWithName ("active-object-name");
00163     
00164     if (aonameElement == false) {
00165       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have an  active-object-name node");
00166     }
00167     
00168     shared_ptr<XmlCharData> aonameCharData = aonameElement->getFirstNonBlankCharData();
00169     
00170     if (aonameCharData == false) {
00171       throw Exception ("ServiceDeploymentConfiguration::ServiceDeploymentConfiguration : XML configuration element does not have character data for the active-object-name node");
00172     }
00173     
00174     _activeObjectName = (string) * aonameCharData;
00175     
00176   }
00177   
00178 }; // ServiceDeploymentConfiguration(shared_ptr<XmlElement> xml);
00179 
00180 std::string ServiceDeploymentConfiguration::getServiceHeaderFilename()
00181 {
00182   return std::string (_headerFilename);
00183 }; // ServiceDeploymentConfiguration::getHeaderFilename()
00184 
00185 std::string ServiceDeploymentConfiguration::getServiceNamespace()
00186 {
00187   return std::string (_namespace);
00188 }; // ServiceDeploymentConfiguration::getNamespace()
00189 
00190 std::string ServiceDeploymentConfiguration::getServiceClassName()
00191 {
00192   return std::string (_className);
00193 }; // ServiceDeploymentConfiguration::getServiceClassName()
00194 
00195 std::string ServiceDeploymentConfiguration::getServiceEntityName()
00196 {
00197   return std::string (_entityName);
00198 } // ServiceDeploymentConfiguration::getServiceEntityName()
00199 
00200 std::string ServiceDeploymentConfiguration::getServiceInstanceName()
00201 {
00202   return std::string (_instanceName);
00203 } // ServiceDeploymentConfiguration::getServiceInstanceName()
00204 
00205 
00206 std::string ServiceDeploymentConfiguration::getServiceConfigurationFilename()
00207 {
00208   return std::string (_configurationFilename);
00209 }; // ServiceDeploymentConfiguration::getServiceDeploymentConfigurationFilename()
00210 
00211 
00212 std::string ServiceDeploymentConfiguration::getServiceActiveObjectName()
00213 {
00214   return std::string (_activeObjectName);
00215 }; // ServiceDeploymentConfiguration::getServiceActiveObjectName()
Generated on Fri Mar 4 22:14:58 2011 for MeRMaID::support by  doxygen 1.6.3