OperationsI.h

00001 /***************************************************************************
00002   tag: Peter Soetens  Mon Jun 26 13:25:58 CEST 2006  ExecutionI.h
00003 
00004                         ExecutionI.h -  description
00005                            -------------------
00006     begin                : Mon June 26 2006
00007     copyright            : (C) 2006 Peter Soetens
00008     email                : peter.soetens@fmtc.be
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 // be/be_codegen.cpp:859
00068 
00069 // must be outside of #ifdef macro.
00070 #include "../rtt-config.h"
00071 #include "corba.h"
00072 #include "../DataSource.hpp"
00073 
00074 #ifndef INCLUDE_EXECUTIONI_H_
00075 #define INCLUDE_EXECUTIONI_H_
00076 
00077 #include "OperationsC.h"
00078 #ifdef CORBA_IS_TAO
00079 #include "OperationsS.h"
00080 #endif
00081 #include "CorbaConversion.hpp"
00082 #include "AnyDataSource.hpp"
00083 #include "../DispatchInterface.hpp"
00084 #include "../Logger.hpp"
00085 #include "../MethodC.hpp"
00086 #include "../DataSources.hpp"
00087 
00088 namespace RTT
00089 {
00090     class CommandC;
00091 }
00092 
00093 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00094 #pragma once
00095 #endif /* ACE_LACKS_PRAGMA_ONCE */
00096 
00100 class  Orocos_AnyExpression_i
00101   : public virtual POA_RTT::Corba::Expression,
00102     public virtual PortableServer::RefCountServantBase
00103 {
00104 protected:
00105     RTT::DataSourceBase::shared_ptr morig;
00106     CORBA::Any_var last_value;
00107     PortableServer::POA_var mpoa;
00108 public:
00109     typedef RTT::DataSourceBase::const_ptr SourceType;
00110     typedef CORBA::Any                             ResultType;
00111 
00112     virtual void copy( RTT::DataSourceBase::shared_ptr new_ds ) {
00113         morig = new_ds;
00114     }
00115 
00116   // Constructor
00117   Orocos_AnyExpression_i (RTT::DataSourceBase::shared_ptr orig, PortableServer::POA_ptr the_poa)
00118       : morig( orig ), last_value( (CORBA::Any_ptr)morig->createBlob(ORO_CORBA_PROTOCOL_ID) ) // create default Any.
00119         , mpoa( PortableServer::POA::_duplicate(the_poa) )
00120     {}
00121 
00122     PortableServer::POA_ptr _default_POA()
00123     {
00124         return PortableServer::POA::_duplicate(mpoa);
00125     }
00126 
00127   // Destructor
00128     virtual ~Orocos_AnyExpression_i (void) {}
00129 
00130   virtual
00131   CORBA::Any* value (
00132 
00133     )
00134     ACE_THROW_SPEC ((
00135       CORBA::SystemException
00136       )) {
00137       return new CORBA::Any( last_value.in() );
00138   }
00139 
00140   virtual
00141   CORBA::Boolean evaluate (
00142 
00143     )
00144     ACE_THROW_SPEC ((
00145       CORBA::SystemException
00146       )) {
00147       last_value = (CORBA::Any_ptr)morig->getBlob(ORO_CORBA_PROTOCOL_ID);
00148       bool result = true;
00149       // if it is a bool, update result and return it, otherwise, just return true:
00150       RTT::AnyConversion<bool>::update( last_value.in(), result );
00151       return result;
00152   }
00153 
00154   virtual
00155   CORBA::Any * get (
00156 
00157     )
00158     ACE_THROW_SPEC ((
00159       CORBA::SystemException
00160       )) {
00161       return (CORBA::Any*)morig->getBlob(ORO_CORBA_PROTOCOL_ID);
00162   }
00163 
00164   virtual
00165   char * getType (
00166 
00167     )
00168     ACE_THROW_SPEC ((
00169       CORBA::SystemException
00170       )) {
00171       return CORBA::string_dup( morig->getType().c_str() );
00172   }
00173 
00174   virtual
00175   char * toString (
00176 
00177     )
00178     ACE_THROW_SPEC ((
00179       CORBA::SystemException
00180       )) {
00181       std::string result = morig->toString();
00182       return CORBA::string_dup( result.c_str() );
00183   }
00184 
00185 
00186   virtual
00187   char * getTypeName (
00188 
00189     )
00190     ACE_THROW_SPEC ((
00191       CORBA::SystemException
00192       )) {
00193       return CORBA::string_dup( morig->getTypeName().c_str() );
00194   }
00195 
00196   virtual void destroyExpression()
00197     ACE_THROW_SPEC ((
00198       CORBA::SystemException
00199     ))
00200  {
00201   }
00202 
00203 };
00204 
00205 
00206 class  Orocos_AnyAssignableExpression_i
00207     : public Orocos_AnyExpression_i,
00208       public virtual POA_RTT::Corba::AssignableExpression
00209 {
00210     RTT::DataSourceBase::shared_ptr mset;
00211 public:
00212 
00213     virtual void copy( RTT::DataSourceBase::shared_ptr new_ds ) {
00214         mset = new_ds;
00215         morig = new_ds;
00216     }
00217 
00218   // Constructor
00219   Orocos_AnyAssignableExpression_i (RTT::DataSourceBase::shared_ptr orig, PortableServer::POA_ptr the_poa)
00220       : Orocos_AnyExpression_i(orig, the_poa), mset( orig )
00221    {}
00222 
00223   // Destructor
00224     virtual ~Orocos_AnyAssignableExpression_i (void) {}
00225 
00226   virtual
00227   CORBA::Boolean set (
00228       const ::CORBA::Any & value
00229     )
00230     ACE_THROW_SPEC ((
00231       CORBA::SystemException
00232       )) {
00233       if ( mset->updateBlob(ORO_CORBA_PROTOCOL_ID, &value ) == false) {
00234 #if CORBA_IS_TAO
00235           CORBA::TypeCode_ptr tc = value.type(); // may leak.
00236 #else
00237           CORBA::TypeCode_var tc = value.type(); // does not compile in TAO, probably a bug in TAO API.
00238 #endif
00239           RTT::log(RTT::Error) << "Failed to update Assignable Expression of type "<< mset->getTypeName()
00240                   << " with Any (Type id:" << tc->id() << " Type name:"<< tc->name() <<")"<<RTT::endlog();
00241           return false;
00242       }
00243       return true;
00244   }
00245 
00246   virtual
00247   CORBA::Boolean fromString (
00248       const char* value
00249     )
00250     ACE_THROW_SPEC ((
00251       CORBA::SystemException
00252       )) {
00253 
00254       if ( !mset->getTypeInfo()->fromString( value, mset ) ) {
00255           RTT::log(RTT::Error) << "Corba::AssignableExpression: Could not assign string to "<<mset->getType() <<"." <<RTT::endlog()
00256                                <<" Tried to assign as "<< RTT::DataSource<ResultType>::GetType() << " to native type "<< RTT::DataSource<SourceType>::GetType()<< RTT::endlog();
00257           return false;
00258       }
00259       return true;
00260   }
00261 
00262 };
00263 
00264 
00265 class  Orocos_Action_i
00266     : public virtual POA_RTT::Corba::Action,
00267       public virtual PortableServer::RefCountServantBase
00268 {
00269     RTT::MethodC morig;
00270     RTT::CommandInterface* mcom;
00271     PortableServer::POA_var mpoa;
00272 public:
00273   //Constructor
00274   Orocos_Action_i ( RTT::MethodC* orig, RTT::CommandInterface* com, PortableServer::POA_ptr the_poa );
00275 
00276     PortableServer::POA_ptr _default_POA()
00277     {
00278         return PortableServer::POA::_duplicate(mpoa);
00279     }
00280 
00281   //Destructor
00282     virtual ~Orocos_Action_i (void);
00283 
00284   virtual
00285   CORBA::Boolean execute (
00286 
00287     )
00288     ACE_THROW_SPEC ((
00289       CORBA::SystemException
00290       ));
00291 
00292   virtual
00293   CORBA::Boolean executeAny (
00294       const ::RTT::Corba::AnyArguments& args
00295     )
00296     ACE_THROW_SPEC ((
00297       CORBA::SystemException
00298     ,::RTT::Corba::WrongNumbArgException
00299     ,::RTT::Corba::WrongTypeArgException
00300     ));
00301 
00302   virtual
00303   void reset (
00304 
00305     )
00306     ACE_THROW_SPEC ((
00307       CORBA::SystemException
00308       ));
00309 
00310   virtual void destroyAction()
00311     ACE_THROW_SPEC ((
00312       CORBA::SystemException
00313     ))
00314  {
00315   }
00316 
00317 };
00318 
00319 class  Orocos_AnyMethod_i
00320     : public virtual Orocos_AnyExpression_i,
00321       public virtual POA_RTT::Corba::Method
00322 {
00323 protected:
00324     RTT::MethodC mmethodc;
00325 
00326 public:
00327     virtual void copy( RTT::DataSourceBase::shared_ptr new_ds ) {
00328         morig = new_ds;
00329     }
00330 
00331   //Constructor
00332   Orocos_AnyMethod_i (RTT::MethodC orig, RTT::DataSourceBase::shared_ptr datas, PortableServer::POA_ptr the_poa )
00333       : Orocos_AnyExpression_i( datas, the_poa ), mmethodc(orig)
00334     {}
00335 
00336   //Destructor
00337     virtual ~Orocos_AnyMethod_i (void) {}
00338 
00339   virtual
00340   CORBA::Boolean execute (
00341 
00342     )
00343     ACE_THROW_SPEC ((
00344       CORBA::SystemException
00345       )) {
00346       return this->evaluate();
00347   }
00348 
00349   CORBA::Boolean executeAny (
00350       const ::RTT::Corba::AnyArguments& args
00351     )
00352     ACE_THROW_SPEC ((
00353       CORBA::SystemException
00354     ,::RTT::Corba::WrongNumbArgException
00355     ,::RTT::Corba::WrongTypeArgException
00356       )) {
00357       RTT::MethodC mgen = mmethodc;
00358     try {
00359         for (size_t i =0; i != args.length(); ++i)
00360             mgen.arg( RTT::DataSourceBase::shared_ptr( new RTT::Corba::AnyDataSource( new CORBA::Any( args[i] ) )));
00361         // if not ready, not enough args were given, *guess* a one off error in the exception :-(
00362         if ( !mgen.ready() )
00363             throw ::RTT::Corba::WrongNumbArgException( args.length()+1, args.length() );
00364         morig = mgen.getDataSource();
00365         return this->evaluate();
00366     } catch ( RTT::wrong_number_of_args_exception& wna ) {
00367         throw ::RTT::Corba::WrongNumbArgException( wna.wanted, wna.received );
00368     } catch ( RTT::wrong_types_of_args_exception& wta ) {
00369         throw ::RTT::Corba::WrongTypeArgException( wta.whicharg, wta.expected_.c_str(), wta.received_.c_str() );
00370     }
00371     return false;
00372   }
00373 
00374   virtual
00375   void reset(
00376 
00377     )
00378     ACE_THROW_SPEC ((
00379       CORBA::SystemException
00380       )) {
00381       this->morig->reset();
00382   }
00383 
00384   virtual void destroyAction()
00385     ACE_THROW_SPEC ((
00386       CORBA::SystemException
00387     ))
00388  {
00389   }
00390 
00391 };
00392 
00393 
00394 class  Orocos_Command_i
00395     : public virtual POA_RTT::Corba::Command,
00396       public virtual PortableServer::RefCountServantBase
00397 {
00398 protected:
00399     RTT::CommandC* morig;
00400     RTT::CommandC* mcomm;
00401     PortableServer::POA_var mpoa;
00402 public:
00403   //Constructor
00410   Orocos_Command_i (RTT::CommandC& orig,RTT::CommandC& c, PortableServer::POA_ptr the_poa);
00411 
00415   Orocos_Command_i (RTT::DispatchInterface::shared_ptr orig, PortableServer::POA_ptr the_poa);
00416 
00417     PortableServer::POA_ptr _default_POA()
00418     {
00419         return PortableServer::POA::_duplicate(mpoa);
00420     }
00421 
00422   //Destructor
00423   virtual ~Orocos_Command_i (void);
00424 
00425   virtual
00426   CORBA::Boolean execute (
00427 
00428     )
00429     ACE_THROW_SPEC ((
00430       CORBA::SystemException
00431     ));
00432 
00433   virtual
00434   CORBA::Boolean executeAny (
00435       const ::RTT::Corba::AnyArguments& args
00436     )
00437     ACE_THROW_SPEC ((
00438       CORBA::SystemException
00439     ,::RTT::Corba::WrongNumbArgException
00440     ,::RTT::Corba::WrongTypeArgException
00441     ));
00442 
00443   virtual
00444   CORBA::Boolean sent (
00445 
00446     )
00447     ACE_THROW_SPEC ((
00448       CORBA::SystemException
00449     ));
00450 
00451   virtual
00452   CORBA::Boolean accepted (
00453 
00454     )
00455     ACE_THROW_SPEC ((
00456       CORBA::SystemException
00457     ));
00458 
00459   virtual
00460   CORBA::Boolean executed (
00461 
00462     )
00463     ACE_THROW_SPEC ((
00464       CORBA::SystemException
00465     ));
00466 
00467   virtual
00468   CORBA::Boolean valid (
00469 
00470     )
00471     ACE_THROW_SPEC ((
00472       CORBA::SystemException
00473     ));
00474 
00475   virtual
00476   CORBA::Boolean done (
00477 
00478     )
00479     ACE_THROW_SPEC ((
00480       CORBA::SystemException
00481     ));
00482 
00483   virtual
00484   void reset (
00485 
00486     )
00487     ACE_THROW_SPEC ((
00488       CORBA::SystemException
00489     ));
00490 
00491   virtual void destroyCommand()
00492     ACE_THROW_SPEC ((
00493       CORBA::SystemException
00494     ));
00495 };
00496 
00497 #endif /* INCLUDE_EXPRESSIONI_H_  */
00498 
Generated on Thu Dec 23 13:22:37 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3