Orocos Real-Time Toolkit  2.9.0
StdVectorTemplateTypeInfo.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Tinne De Laet 2007 VectorTemplateComposition.hpp
3  2007 Ruben Smits
4  VectorTemplateComposition.hpp - description
5 
6  ***************************************************************************
7  * This library is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU General Public *
9  * License as published by the Free Software Foundation; *
10  * version 2 of the License. *
11  * *
12  * As a special exception, you may use this file as part of a free *
13  * software library without restriction. Specifically, if other files *
14  * instantiate templates or use macros or inline functions from this *
15  * file, or you compile this file and link it with other files to *
16  * produce an executable, this file does not by itself cause the *
17  * resulting executable to be covered by the GNU General Public *
18  * License. This exception does not however invalidate any other *
19  * reasons why the executable file might be covered by the GNU General *
20  * Public License. *
21  * *
22  * This library is distributed in the hope that it will be useful, *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
25  * Lesser General Public License for more details. *
26  * *
27  * You should have received a copy of the GNU General Public *
28  * License along with this library; if not, write to the Free Software *
29  * Foundation, Inc., 59 Temple Place, *
30  * Suite 330, Boston, MA 02111-1307 USA *
31  * *
32  ***************************************************************************/
33 
34 #ifndef STD_VECTOR_TEMPLATE_TYPE_INFO_HPP
35 #define STD_VECTOR_TEMPLATE_TYPE_INFO_HPP
36 
37 #include "../Property.hpp"
38 #include "../PropertyBag.hpp"
39 #include "SequenceTypeInfo.hpp"
40 #include "Types.hpp"
41 #include "../Logger.hpp"
42 #include "../internal/DataSources.hpp"
43 #include <vector>
45 
46 namespace RTT
47 {
48  namespace types {
49 
54  template <typename T, bool has_ostream = false>
55  struct StdVectorTemplateTypeInfo
56  : public SequenceTypeInfo<std::vector<T>, has_ostream>
57  {
59  : SequenceTypeInfo<std::vector<T>, has_ostream >(name)
60  {
61  }
62 
65  {
66  const internal::DataSource<PropertyBag>* pb = dynamic_cast< const internal::DataSource<PropertyBag>* > (dssource.get() );
67  if ( !pb )
68  return false;
69  internal::AssignableDataSource<std::vector<T> >::shared_ptr ads = boost::dynamic_pointer_cast< internal::AssignableDataSource<std::vector<T> > >( dsresult );
70  if ( !ads )
71  return false;
72 
73  PropertyBag const& source = pb->rvalue();
74  internal::AssignableDataSource<std::vector<T> >::reference_t result = ads->set();
75 
76  return composeTemplateProperty(source, result) || SequenceTypeInfo<std::vector<T>, has_ostream>::composeType(dssource, dsresult);
77  }
78 
79  };
80  }
81 }
82 
83 #endif
84 
DataSource is a base class representing a generic way to read data of type T.
Definition: DataSource.hpp:94
Template class for std::vector<T> typekits, providing a alternative demarshalling function for proper...
virtual void set(param_t t)=0
Set this DataSource with a value.
A container for holding references to properties.
Definition: PropertyBag.hpp:96
virtual const_reference_t rvalue() const =0
Get a const reference to the value of this DataSource.
virtual bool composeType(base::DataSourceBase::shared_ptr dssource, base::DataSourceBase::shared_ptr dsresult) const
Override default in order to take legacy formats into account.
A DataSource which has set() methods.
Definition: DataSource.hpp:184
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:52
Old-style SequenceTypeInfo which offers type info for sequences which can be sent over flow ports...
bool composeTemplateProperty(const PropertyBag &bag, T &result)