ServiceI.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: The SourceWorks  Tue Sep 7 00:55:18 CEST 2010  ServiceI.cpp
00003 
00004                         ServiceI.cpp -  description
00005                            -------------------
00006     begin                : Tue September 07 2010
00007     copyright            : (C) 2010 The SourceWorks
00008     email                : peter@thesourceworks.com
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 
00039 // -*- C++ -*-
00040 //
00041 // $Id$
00042 
00043 // ****  Code generated by the The ACE ORB (TAO) IDL Compiler ****
00044 // TAO and the TAO IDL Compiler have been developed by:
00045 //       Center for Distributed Object Computing
00046 //       Washington University
00047 //       St. Louis, MO
00048 //       USA
00049 //       http://www.cs.wustl.edu/~schmidt/doc-center.html
00050 // and
00051 //       Distributed Object Computing Laboratory
00052 //       University of California at Irvine
00053 //       Irvine, CA
00054 //       USA
00055 //       http://doc.ece.uci.edu/
00056 // and
00057 //       Institute for Software Integrated Systems
00058 //       Vanderbilt University
00059 //       Nashville, TN
00060 //       USA
00061 //       http://www.isis.vanderbilt.edu/
00062 //
00063 // Information about TAO is available at:
00064 //     http://www.cs.wustl.edu/~schmidt/TAO.html
00065 
00066 // TAO_IDL - Generated from 
00067 // ../../../ACE_wrappers/TAO/TAO_IDL/be/be_codegen.cpp:1196
00068 
00069 #include "ServiceI.h"
00070 
00071 using namespace RTT;
00072 using namespace RTT::detail;
00073 
00074 // Implementation skeleton constructor
00075 RTT_corba_CService_i::RTT_corba_CService_i ( RTT::Service::shared_ptr service, PortableServer::POA_ptr poa)
00076     : RTT_corba_CConfigurationInterface_i( service.get(), PortableServer::POA::_duplicate( poa) ), 
00077       RTT_corba_COperationInterface_i( service.get(), PortableServer::POA::_duplicate( poa) ),
00078       RTT::corba::CDataFlowInterface_i( service.get(), PortableServer::POA::_duplicate( poa) ),
00079       mpoa(poa), mservice(service)
00080 {
00081 }
00082 
00083 // Implementation skeleton destructor
00084 RTT_corba_CService_i::~RTT_corba_CService_i (void)
00085 {
00086 }
00087 
00088 PortableServer::POA_ptr RTT_corba_CService_i::_default_POA()
00089 {
00090     return PortableServer::POA::_duplicate(mpoa);
00091 }
00092 
00093 char * RTT_corba_CService_i::getName (
00094     void)
00095 {
00096     return CORBA::string_dup( mservice->getName().c_str() );
00097 }
00098 
00099 char * RTT_corba_CService_i::getServiceDescription (
00100     void)
00101 {
00102     return CORBA::string_dup( mservice->doc().c_str() );
00103 }
00104 
00105 ::RTT::corba::CService::CProviderNames * RTT_corba_CService_i::getProviderNames (
00106     void)
00107 {
00108     Service::ProviderNames names = mservice->getProviderNames();
00109     ::RTT::corba::CService::CProviderNames_var result = new ::RTT::corba::CService::CProviderNames();
00110     result->length( names.size() );
00111     for (unsigned int i=0; i != names.size(); ++i )
00112         result[i] = CORBA::string_dup( names[i].c_str() );
00113 
00114     return result._retn();
00115 }
00116 
00117 ::RTT::corba::CService_ptr RTT_corba_CService_i::getService (
00118     const char * service_name)
00119 {
00120     Service::shared_ptr provider = mservice->getService(service_name);
00121     if ( !provider )
00122         return RTT::corba::CService::_nil();
00123 
00124     // check for existing service
00125     for(Servants::iterator it = mservs.begin(); it != mservs.end(); ++it) {
00126         CORBA::String_var sname = it->first->getName();
00127         if ( sname.in() == service_name )
00128                 return  RTT::corba::CService::_duplicate( it->first.in() );
00129     }
00130     // not found: new service
00131     
00132     RTT_corba_CService_i* serv_i;
00133     RTT::corba::CService_var serv;
00134     serv_i = new RTT_corba_CService_i( provider, mpoa );
00135     serv = serv_i->activate_this();
00136     mservs.push_back( std::pair<RTT::corba::CService_var,PortableServer::ServantBase_var>( RTT::corba::CService::_duplicate(serv.in()), serv_i ) );
00137     //CService_i::registerServant(serv, mtask->provides(service_name));
00138     return RTT::corba::CService::_duplicate( serv.in() );
00139 }
00140 
00141 ::CORBA::Boolean RTT_corba_CService_i::hasService (
00142     const char * name)
00143 {
00144     return mservice->hasService( name );
00145 }


rtt
Author(s): RTT Developers
autogenerated on Mon Oct 6 2014 03:13:40