DataSource.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Peter Soetens  Mon May 10 19:10:37 CEST 2004  DataSource.cxx
00003 
00004                         DataSource.cxx -  description
00005                            -------------------
00006     begin                : Mon May 10 2004
00007     copyright            : (C) 2004 Peter Soetens
00008     email                : peter.soetens@mech.kuleuven.ac.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 #include "DataSource.hpp"
00038 #include "../types/TypeInfoName.hpp"
00039 
00040 #include "rtt-config.h"
00041 #include "../types/Types.hpp"
00042 #include "../types/TypeTransporter.hpp"
00043 
00044 namespace RTT {
00045     namespace base {
00046         std::ostream& operator<<(std::ostream& os, DataSourceBase::shared_ptr mobj)
00047         {
00048             return mobj->getTypeInfo()->write( os, mobj );
00049         }
00050 
00051         void intrusive_ptr_add_ref(const RTT::base::DataSourceBase* p )
00052         {
00053             p->ref();
00054         }
00055 
00056         void intrusive_ptr_release(const RTT::base::DataSourceBase* p )
00057         {
00058             p->deref();
00059         };
00060 
00061     }
00062 
00063     using namespace detail;
00064     using namespace std;
00065 
00066     bad_assignment::~bad_assignment() throw() {}
00067     const char* bad_assignment::what() const throw() { return "Bad DataSource assignment: incompatible types."; }
00068 
00069     DataSourceBase::shared_ptr DataSourceBase::stack_shared_ptr(DataSourceBase* dsb) {
00070         dsb->ref();
00071         return DataSourceBase::shared_ptr(dsb);
00072     }
00073 
00074     DataSourceBase::const_ptr DataSourceBase::stack_const_ptr(DataSourceBase const* dsb) {
00075         dsb->ref();
00076         return DataSourceBase::const_ptr(dsb);
00077     }
00078 
00079     DataSourceBase::DataSourceBase() : refcount(0) {  }
00080     void DataSourceBase::ref() const { refcount.inc(); }
00081     void DataSourceBase::deref() const { if ( refcount.dec_and_test() ) delete this; }
00082 
00083     DataSourceBase::~DataSourceBase()
00084     {
00085     }
00086 
00087     void DataSourceBase::reset()
00088     {
00089     }
00090 
00091     std::ostream& DataSourceBase::write(std::ostream& os)
00092     {
00093         DataSourceBase::shared_ptr mobj(this);
00094         return mobj->getTypeInfo()->write( os, mobj );
00095     }
00096 
00097 
00098     std::string DataSourceBase::toString()
00099     {
00100         DataSourceBase::shared_ptr mobj(this);
00101         return mobj->getTypeInfo()->toString( mobj );
00102     }
00103 
00104     bool DataSourceBase::isAssignable() const {
00105         return false;
00106     }
00107 
00108     bool DataSourceBase::update( DataSourceBase* ) {
00109         return false;
00110     }
00111 
00112     void DataSourceBase::updated()
00113     {}
00114 
00115     void* DataSourceBase::getRawPointer()
00116     { return 0; }
00117     void const* DataSourceBase::getRawConstPointer()
00118     { return 0; }
00119 
00120     ActionInterface* DataSourceBase::updateAction( DataSourceBase* ) {
00121         return 0;
00122     }
00123 
00124     DataSourceBase::shared_ptr DataSourceBase::getMember( const std::string& part_name ) {
00125         if ( part_name.empty() )
00126             return DataSourceBase::shared_ptr(this);
00127         return getTypeInfo()->getMember( this, part_name );
00128     }
00129 
00130     DataSourceBase::shared_ptr DataSourceBase::getMember( DataSourceBase::shared_ptr part_id, DataSourceBase::shared_ptr offset) {
00131         return getTypeInfo()->getMember( this, part_id );
00132     }
00133 
00134     vector<string> DataSourceBase::getMemberNames() const {
00135         return getTypeInfo()->getMemberNames();
00136     }
00137 
00138     DataSourceBase::shared_ptr DataSourceBase::getParent()  {
00139         return this;
00140     }
00141 
00142     namespace internal {
00143 
00144         TypeInfo* DataSourceTypeInfo<detail::UnknownType>::TypeInfoObject = 0;
00145 
00146         const std::string& DataSourceTypeInfo<UnknownType>::getType() { return getTypeInfo()->getTypeName(); }
00147         const std::string& DataSourceTypeInfo<UnknownType>::getTypeName() { return getTypeInfo()->getTypeName(); }
00148         const std::string& DataSourceTypeInfo<UnknownType>::getQualifier() { return noqual; }
00149         TypeInfo* DataSourceTypeInfo<UnknownType>::getTypeInfo() {
00150             if (!TypeInfoObject)
00151                 TypeInfoObject = new TypeInfo("unknown_t");
00152             return TypeInfoObject;
00153         }
00154 
00155         const std::string DataSourceTypeInfo<UnknownType>::noqual("");
00156         const std::string DataSourceTypeInfo<UnknownType>::cqual(" const");
00157         const std::string DataSourceTypeInfo<UnknownType>::refqual(" &");
00158         const std::string DataSourceTypeInfo<UnknownType>::crefqual(" const&");
00159         const std::string DataSourceTypeInfo<UnknownType>::ptrqual(" *");
00160         const std::string DataSourceTypeInfo<UnknownType>::cptrqual(" const*");
00161 
00162         // (void) type info
00163         TypeInfo* DataSourceTypeInfo<void>::TypeInfoObject = 0;
00164         const std::string DataSourceTypeInfo<void>::tname("void");
00165 
00166         const std::string& DataSourceTypeInfo<void>::getType() { return tname; }
00167         const std::string& DataSourceTypeInfo<void>::getTypeName() { return tname; }
00168         const std::string& DataSourceTypeInfo<void>::getQualifier() { return DataSourceTypeInfo<UnknownType>::noqual; }
00169         const TypeInfo* DataSourceTypeInfo<void>::getTypeInfo() {
00170             if (!TypeInfoObject)
00171                 return DataSourceTypeInfo<UnknownType>::getTypeInfo();
00172             return TypeInfoObject;
00173         }
00174     }
00175 }
00176 


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