ServiceRequest.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 ServiceRequest.cpp
00024  * @Description ServiceRequest implementation
00025  * @Status Work in Progress
00026  * @Version $Id: ServiceRequest.cpp 1 2011-03-04 18:13:18Z jreis $
00027  * @Maintainer
00028  */
00029 
00030 #include "config.h"
00031 
00032 #include "ServiceRequest.hpp"
00033 
00034 #include "EntityDescriptionRepository.hpp"
00035 #include "Service.hpp"
00036 #include "ServiceInterfaceDescription.hpp"
00037 #include "ServiceInstanceDescription.hpp"
00038 #include "ServiceTypeDescription.hpp"
00039 
00040 #include <DataFactory.hpp>
00041 #include <Exception.hpp>
00042 
00043 
00044 using namespace mermaid::support::service;
00045 
00046 using mermaid::support::data::DataFactory;
00047 using mermaid::support::errorhandling::Exception;
00048 
00049 
00050 ServiceRequest::ServiceRequest()
00051 {
00052   throw Exception ("ServiceRequest::ServiceRequest()");
00053 };
00054 
00055 ServiceRequest::ServiceRequest (std::string requesterEntityName, std::string requesterServiceName, std::string targetEntityName, std::string targetServiceName, std::string targetServiceInterfaceName, int requestId)
00056 {
00057   requesterEntityName_ = requesterEntityName;
00058   requesterServiceName_ = requesterServiceName;
00059   targetEntityName_ = targetEntityName;
00060   targetServiceName_ = targetServiceName;
00061   targetServiceInterfaceName_ = targetServiceInterfaceName;
00062   requestId_ = requestId;
00063   
00064   std::string inputDataName = EntityDescriptionRepository::getInstance()->getEntityDescription (targetEntityName_)->getServiceInstanceDescription (targetServiceName_)->getServiceTypeDescriptionWithInterfaceName (targetServiceInterfaceName_)->getServiceInterfaceDescription (targetServiceInterfaceName_)->getServiceInterfaceInputDataName();
00065   
00066   requestDataBox_ = DataFactory::buildDataBox (inputDataName);
00067   //setRequestDataStructure(serviceDescription->getServiceInterface(targetServiceInterfaceName)->getInputDataStructureName());
00068 }; // ServiceRequest()
00069 
00070 ServiceRequest::ServiceRequest (const ServiceRequest &sar)
00071 {
00072   throw Exception ("ServiceRequest(const ServiceRequest &sar)");
00073 }; // copy constructor
00074 
00075 ServiceRequest& ServiceRequest::operator= (const ServiceRequest & sar)
00076 {
00077   throw Exception ("ServiceRequest::operator=(const ServiceRequest &sar)");
00078 }; // assignment operator
00079 
00080 std::string ServiceRequest::getRequesterEntityName()
00081 {
00082   return requesterEntityName_;
00083 }; // getRequesterEntityName()
00084 
00085 std::string ServiceRequest::getRequesterServiceName()
00086 {
00087   return requesterServiceName_;
00088 }; // getRequesterServiceName()
00089 
00090 std::string ServiceRequest::getTargetEntityName()
00091 {
00092   return targetEntityName_;
00093 }; // getTargetEntityName()
00094 
00095 std::string ServiceRequest::getTargetServiceName()
00096 {
00097   return targetServiceName_;
00098 }; // getTargetServiceName()
00099 
00100 std::string ServiceRequest::getTargetServiceInterfaceName()
00101 {
00102   return targetServiceInterfaceName_;
00103 }; // getTargetServiceInterfaceName()
00104 
00105 int ServiceRequest::getRequestId()
00106 {
00107   return requestId_;
00108 }; // getRequestId()
00109 
00110 shared_ptr<DataBox> ServiceRequest::getRequestDataBox()
00111 {
00112   if (requestDataBox_ == false) {
00113     throw Exception ("ServiceRequest::getRequestDataBox() : request data box is not valid");
00114   }
00115   return requestDataBox_;
00116 }; // getRequestData()
00117 
00118 void ServiceRequest::setRequestDataBox (shared_ptr<DataBox> dataBox)
00119 {
00120   requestDataBox_ = dataBox;
00121 }; // setRequestDataBox
00122 
00123 ServiceRequestState& ServiceRequest::getState()
00124 {
00125   return state_;
00126 }; // getState()
00127 
00128 void ServiceRequest::notifySent()
00129 {
00130   state_.notifySent();
00131 }; // notifySent()
00132 
00133 void ServiceRequest::notifyReplyReceived()
00134 {
00135   state_.notifyReplyReceived();
00136 }; // notifyReplyReceived()
Generated on Fri Mar 4 22:14:58 2011 for MeRMaID::support by  doxygen 1.6.3