DataSource.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon May 10 19:10:37 CEST 2004 DataSource.cxx
3 
4  DataSource.cxx - description
5  -------------------
6  begin : Mon May 10 2004
7  copyright : (C) 2004 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 #include "DataSource.hpp"
38 #include "../types/TypeInfoName.hpp"
39 
40 #include "rtt-config.h"
41 #include "../types/Types.hpp"
42 #include "../types/TypeTransporter.hpp"
43 
44 namespace RTT {
45  namespace base {
46  std::ostream& operator<<(std::ostream& os, DataSourceBase::shared_ptr mobj)
47  {
48  return mobj->getTypeInfo()->write( os, mobj );
49  }
50 
52  {
53  p->ref();
54  }
55 
57  {
58  p->deref();
59  }
60 
61  }
62 
63  using namespace detail;
64  using namespace std;
65 
67  const char* bad_assignment::what() const throw() { return "Bad DataSource assignment: incompatible types."; }
68 
70  dsb->ref();
71  return DataSourceBase::shared_ptr(dsb);
72  }
73 
75  dsb->ref();
76  return DataSourceBase::const_ptr(dsb);
77  }
78 
79  DataSourceBase::DataSourceBase() : refcount(0) { }
80  void DataSourceBase::ref() const { refcount.inc(); }
81  void DataSourceBase::deref() const { if ( refcount.dec_and_test() ) delete this; }
82 
84  {
85  }
86 
88  {
89  }
90 
91  std::ostream& DataSourceBase::write(std::ostream& os)
92  {
93  DataSourceBase::shared_ptr mobj(this);
94  return mobj->getTypeInfo()->write( os, mobj );
95  }
96 
97 
99  {
100  DataSourceBase::shared_ptr mobj(this);
101  return mobj->getTypeInfo()->toString( mobj );
102  }
103 
105  return false;
106  }
107 
109  return false;
110  }
111 
113  {}
114 
116  { return 0; }
118  { return 0; }
119 
121  return 0;
122  }
123 
124  DataSourceBase::shared_ptr DataSourceBase::getMember( const std::string& part_name ) {
125  if ( part_name.empty() )
126  return DataSourceBase::shared_ptr(this);
127  return getTypeInfo()->getMember( this, part_name );
128  }
129 
131  return getTypeInfo()->getMember( this, part_id );
132  }
133 
134  vector<string> DataSourceBase::getMemberNames() const {
135  return getTypeInfo()->getMemberNames();
136  }
137 
139  return this;
140  }
141 
142  namespace internal {
143 
145 
148  const std::string& DataSourceTypeInfo<UnknownType>::getQualifier() { return noqual; }
150  if (!TypeInfoObject)
151  TypeInfoObject = new TypeInfo("unknown_t");
152  return TypeInfoObject;
153  }
154 
155  const std::string DataSourceTypeInfo<UnknownType>::noqual("");
156  const std::string DataSourceTypeInfo<UnknownType>::cqual(" const");
157  const std::string DataSourceTypeInfo<UnknownType>::refqual(" &");
158  const std::string DataSourceTypeInfo<UnknownType>::crefqual(" const&");
159  const std::string DataSourceTypeInfo<UnknownType>::ptrqual(" *");
160  const std::string DataSourceTypeInfo<UnknownType>::cptrqual(" const*");
161 
162  // (void) type info
164  const std::string DataSourceTypeInfo<void>::tname("void");
165 
166  const std::string& DataSourceTypeInfo<void>::getType() { return tname; }
167  const std::string& DataSourceTypeInfo<void>::getTypeName() { return tname; }
168  const std::string& DataSourceTypeInfo<void>::getQualifier() { return DataSourceTypeInfo<UnknownType>::noqual; }
170  if (!TypeInfoObject)
172  return TypeInfoObject;
173  }
174  }
175 }
176 
virtual void const * getRawConstPointer()
Definition: DataSource.cpp:117
const std::string & getTypeName() const
Definition: TypeInfo.hpp:83
virtual std::vector< std::string > getMemberNames() const
Definition: DataSource.cpp:134
The base class for all internal data representations.
std::ostream & write(std::ostream &os)
Definition: DataSource.cpp:91
static shared_ptr stack_shared_ptr(DataSourceBase *dsb)
Definition: DataSource.cpp:69
virtual ActionInterface * updateAction(DataSourceBase *other)
Definition: DataSource.cpp:120
void RTT_API intrusive_ptr_add_ref(ChannelElementBase *e)
Definition: mystd.hpp:163
virtual const types::TypeInfo * getTypeInfo() const =0
virtual void * getRawPointer()
Definition: DataSource.cpp:115
virtual const char * what() const
Definition: DataSource.cpp:67
virtual bool isAssignable() const
Definition: DataSource.cpp:104
virtual bool update(DataSourceBase *other)
Definition: DataSource.cpp:108
std::vector< std::string > getMemberNames() const
Definition: TypeInfo.hpp:324
bool dec_and_test()
Definition: Atomic.hpp:104
base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item, const std::string &name) const
Definition: TypeInfo.hpp:336
RTT_API std::ostream & operator<<(std::ostream &os, DataSourceBase::shared_ptr dsb)
Definition: DataSource.cpp:46
static const std::string & getTypeName()
Based on the software pattern &#39;command&#39;, this interface allows execution of action objects...
static const_ptr stack_const_ptr(const DataSourceBase *dsb)
Definition: DataSource.cpp:74
virtual shared_ptr getMember(const std::string &member_name)
Definition: DataSource.cpp:124
boost::intrusive_ptr< const DataSourceBase > const_ptr
static const types::TypeInfo * getTypeInfo()
void RTT_API intrusive_ptr_release(ChannelElementBase *e)
static const std::string & getQualifier()
static const std::string & getType()
boost::intrusive_ptr< DataSourceBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
virtual shared_ptr getParent()
Definition: DataSource.cpp:138


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:32