ServiceInterface.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 ServiceInterface.cpp
00024  * @Description Support ServiceInterface implementation
00025  * @Status Work in Progress
00026  * @Version $Id: ServiceInterface.cpp 1 2011-03-04 18:13:18Z jreis $
00027  * @Maintainer nmsra (nmsra@mega.ist.utl.pt)
00028  */
00029 
00030 
00031 #include "config.h"
00032 
00033 #include "ServiceInterface.hpp"
00034 
00035 
00036 #include <Exception.hpp>
00037 
00038 #include <DataFactory.hpp>
00039 
00040 #include <XmlCharData.hpp>
00041 #include <XmlElement.hpp>
00042 #include <XmlElementVector.hpp>
00043 
00044 #include <sstream>
00045 #include <iostream>
00046 
00047 using namespace mermaid::support::service;
00048 using mermaid::support::data::DataFactory;
00049 using mermaid::support::errorhandling::Exception;
00050 using boost::shared_ptr;
00051 
00052 using mermaid::support::xml::XmlCharData;
00053 using mermaid::support::xml::XmlElement;
00054 using mermaid::support::xml::XmlElementVector;
00055 
00056 
00057 
00058 ServiceInterface::ServiceInterface (shared_ptr<ServiceInterfaceDescription> interfaceDescription)
00059 {
00060   validHandler_ = false;
00061   interfaceDescription_ = interfaceDescription;
00062 }; // ServiceInterface()
00063 
00064 shared_ptr<ServiceInterfaceDescription> ServiceInterface::getServiceInterfaceDescription()
00065 {
00066   return interfaceDescription_;
00067 };
00068 
00069 void ServiceInterface::setHandlerMethod (shared_ptr<ServiceInterfaceHandlerMethodBase> handlerMethod)
00070 {
00071   handlerMethod_ = handlerMethod;
00072   validHandler_ = true;
00073 }; // setHandler()
00074 
00075 // shared_ptr<ServiceInterfaceHandlerMethodBase> ServiceInterface::getHandler()
00076 // {
00077 //     if(validHandler_ == false)
00078 //     {
00079 //         throw Exception("ServiceInterface: no handler defined for service interface: " + interfaceDescription_->getServiceInterfaceName());
00080 //     }
00081 //
00082 //     return handlerMethod_;
00083 // }; // getHandler()
00084 
00085 shared_ptr<ServiceReply> ServiceInterface::processServiceRequest (shared_ptr<ServiceRequest> request)
00086 {
00087   if (validHandler_ == false) {
00088     throw Exception ("ServiceInterface::processServiceRequest : no valid handler");
00089   }
00090   
00091   shared_ptr<ServiceReply> reply (new ServiceReply (request));
00092   handlerMethod_->callHandler (request, reply);
00093   
00094   return reply;
00095 }; // processServiceRequest()
Generated on Fri Mar 4 22:14:58 2011 for MeRMaID::support by  doxygen 1.6.3