DataSourceTypeInfo.hpp

00001 /***************************************************************************
00002   tag: Peter Soetens  Sat May 7 12:56:52 CEST 2005  DataSourceTypeInfo.hpp
00003 
00004                         DataSourceTypeInfo.hpp -  description
00005                            -------------------
00006     begin                : Sat May 07 2005
00007     copyright            : (C) 2005 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 
00038 
00039 #ifndef DATASOURCE_TYPE_INFO_HPP
00040 #define DATASOURCE_TYPE_INFO_HPP
00041 
00042 #include <string>
00043 #include <typeinfo>
00044 #include "rtt-config.h"
00045 
00046 namespace RTT
00047 {
00048     class TypeInfo;
00049 
00050     namespace detail {
00051 
00052         struct RTT_API UnknownType {};
00053 
00054         template< class T>
00055         struct DataSourceTypeInfo;
00056 
00062         template<>
00063         struct RTT_API DataSourceTypeInfo<UnknownType> {
00064             typedef UnknownType value_type;
00065             typedef DataSourceTypeInfo<UnknownType> value_type_info;
00066 
00067             static TypeInfo* TypeInfoObject;
00068 
00069             static const std::string noqual;
00070             static const std::string cqual;
00071             static const std::string refqual;
00072             static const std::string crefqual;
00073             static const std::string ptrqual;
00074             static const std::string cptrqual;
00075             static const std::string& getType();
00076             static const std::string& getQualifier();
00077             // we drop the const qualifier in this specialisation, since it is
00078             // not registered in the type repository (which returns a non const in type() )
00079             static TypeInfo* getTypeInfo();
00080         };
00081 
00086         template< class T>
00087         struct DataSourceTypeInfo<const T&> {
00088             typedef T value_type;
00089             typedef DataSourceTypeInfo<T> value_type_info;
00090             static const std::string& getType()  { return DataSourceTypeInfo< T >::getType(); }
00091             static const std::string& getQualifier() { return DataSourceTypeInfo<UnknownType>::crefqual; }
00092             static const TypeInfo* getTypeInfo() { return DataSourceTypeInfo< T >::getTypeInfo(); }
00093         };
00094 
00095         template< class T>
00096         struct DataSourceTypeInfo<T&> {
00097             typedef T value_type;
00098             typedef DataSourceTypeInfo<T> value_type_info;
00099             static const std::string& getType()  { return DataSourceTypeInfo< T >::getType(); }
00100             static const std::string& getQualifier() { return DataSourceTypeInfo<UnknownType>::refqual; }
00101             static const TypeInfo* getTypeInfo() { return DataSourceTypeInfo< T >::getTypeInfo(); }
00102         };
00103 
00104         template< class T>
00105         struct DataSourceTypeInfo<const T> {
00106             typedef T value_type;
00107             typedef DataSourceTypeInfo<T> value_type_info;
00108             static const std::string& getType()  { return DataSourceTypeInfo< T >::getType(); }
00109             static const std::string& getQualifier() { return DataSourceTypeInfo<UnknownType>::cqual; }
00110             static const TypeInfo* getTypeInfo() { return DataSourceTypeInfo< T >::getTypeInfo(); }
00111         };
00112 
00113         template< class T>
00114         struct DataSourceTypeInfo<T*> {
00115             typedef T value_type;
00116             typedef DataSourceTypeInfo<T> value_type_info;
00117             static const std::string& getType()  { return DataSourceTypeInfo< T >::getType(); }
00118             static const std::string& getQualifier() { return DataSourceTypeInfo<UnknownType>::ptrqual; }
00119             static const TypeInfo* getTypeInfo() { return DataSourceTypeInfo< T >::getTypeInfo(); }
00120         };
00121 
00122         template< class T>
00123         struct DataSourceTypeInfo<const T*> {
00124             typedef T value_type;
00125             typedef DataSourceTypeInfo<T> value_type_info;
00126             static const std::string& getType()  { return DataSourceTypeInfo< T >::getType(); }
00127             static const std::string& getQualifier() { return DataSourceTypeInfo<UnknownType>::cptrqual; }
00128             static const TypeInfo* getTypeInfo() { return DataSourceTypeInfo< T >::getTypeInfo(); }
00129         };
00130 
00137         template< class T>
00138         struct DataSourceTypeInfo {
00139             typedef T value_type;
00140             typedef DataSourceTypeInfo<T> value_type_info;
00141 
00146             static TypeInfo* TypeInfoObject;
00147 
00151             static const std::string& getType();
00152 
00156             static const std::string& getQualifier();
00157 
00161             static const TypeInfo* getTypeInfo();
00162         };
00163 
00167         template<>
00168         class RTT_API DataSourceTypeInfo<void> {
00169             static const std::string tname;
00170         public:
00171             typedef void value_type;
00172             typedef DataSourceTypeInfo<void> value_type_info;
00173 
00178             static TypeInfo* TypeInfoObject;
00179 
00183             static const std::string& getType();
00184 
00188             static const std::string& getQualifier();
00189 
00193             static const TypeInfo* getTypeInfo();
00194         };
00195     }
00196 
00197 }
00198 
00199 #endif
00200 
00201 #include "DataSourceTypeInfo.inl"
Generated on Thu Dec 23 13:22:37 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3