00001 /*************************************************************************** 00002 tag: Tinne De Laet 2007 VectorTemplateComposition.hpp 00003 2007 Ruben Smits 00004 VectorTemplateComposition.hpp - description 00005 00006 *************************************************************************** 00007 * This library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public * 00009 * License as published by the Free Software Foundation; * 00010 * version 2 of the License. * 00011 * * 00012 * As a special exception, you may use this file as part of a free * 00013 * software library without restriction. Specifically, if other files * 00014 * instantiate templates or use macros or inline functions from this * 00015 * file, or you compile this file and link it with other files to * 00016 * produce an executable, this file does not by itself cause the * 00017 * resulting executable to be covered by the GNU General Public * 00018 * License. This exception does not however invalidate any other * 00019 * reasons why the executable file might be covered by the GNU General * 00020 * Public License. * 00021 * * 00022 * This library is distributed in the hope that it will be useful, * 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00025 * Lesser General Public License for more details. * 00026 * * 00027 * You should have received a copy of the GNU General Public * 00028 * License along with this library; if not, write to the Free Software * 00029 * Foundation, Inc., 59 Temple Place, * 00030 * Suite 330, Boston, MA 02111-1307 USA * 00031 * * 00032 ***************************************************************************/ 00033 00034 #ifndef STD_VECTOR_TEMPLATE_TYPE_INFO_HPP 00035 #define STD_VECTOR_TEMPLATE_TYPE_INFO_HPP 00036 00037 #include "../Property.hpp" 00038 #include "../PropertyBag.hpp" 00039 #include "SequenceTypeInfo.hpp" 00040 #include "Types.hpp" 00041 #include "../Logger.hpp" 00042 #include "../internal/DataSources.hpp" 00043 #include <vector> 00044 #include "VectorTemplateComposition.hpp" 00045 00046 namespace RTT 00047 { 00048 namespace types { 00049 00054 template <typename T, bool has_ostream = false> 00055 struct StdVectorTemplateTypeInfo 00056 : public SequenceTypeInfo<std::vector<T>, has_ostream> 00057 { 00058 StdVectorTemplateTypeInfo<T, has_ostream>( std::string name ) 00059 : SequenceTypeInfo<std::vector<T>, has_ostream >(name) 00060 { 00061 } 00062 00064 virtual bool composeType( base::DataSourceBase::shared_ptr dssource, base::DataSourceBase::shared_ptr dsresult) const 00065 { 00066 const internal::DataSource<PropertyBag>* pb = dynamic_cast< const internal::DataSource<PropertyBag>* > (dssource.get() ); 00067 if ( !pb ) 00068 return false; 00069 internal::AssignableDataSource<std::vector<T> >::shared_ptr ads = boost::dynamic_pointer_cast< internal::AssignableDataSource<std::vector<T> > >( dsresult ); 00070 if ( !ads ) 00071 return false; 00072 00073 PropertyBag const& source = pb->rvalue(); 00074 internal::AssignableDataSource<std::vector<T> >::reference_t result = ads->set(); 00075 00076 return composeTemplateProperty(source, result) || SequenceTypeInfo<std::vector<T>, has_ostream>::composeType(dssource, dsresult); 00077 } 00078 00079 }; 00080 } 00081 } 00082 00083 #endif 00084