Wiselib
wiselib.testing/util/wisebed_node_api/sensors/sensor_encoding.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  ** This file is part of the generic algorithm library Wiselib.           **
00003  ** Copyright (C) 2008,2009 by the Wisebed (www.wisebed.eu) project.      **
00004  **                                                                       **
00005  ** The Wiselib is free software: you can redistribute it and/or modify   **
00006  ** it under the terms of the GNU Lesser General Public License as        **
00007  ** published by the Free Software Foundation, either version 3 of the    **
00008  ** License, or (at your option) any later version.                       **
00009  **                                                                       **
00010  ** The Wiselib is distributed in the hope that it will be useful,        **
00011  ** but WITHOUT ANY WARRANTY; without even the implied warranty of        **
00012  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         **
00013  ** GNU Lesser General Public License for more details.                   **
00014  **                                                                       **
00015  ** You should have received a copy of the GNU Lesser General Public      **
00016  ** License along with the Wiselib.                                       **
00017  ** If not, see <http://www.gnu.org/licenses/>.                           **
00018  ***************************************************************************/
00019 
00020 #ifndef __UTIL_WISEBED_NODE_API_SENSOR_ENCODING_H
00021 #define __UTIL_WISEBED_NODE_API_SENSOR_ENCODING_H
00022 
00023 #include "util/serialization/simple_types.h"
00024 
00025 namespace wiselib
00026 {
00027 
00028    enum SensorEncodings
00029    {
00030       UNKNOWN_ENCODING = 0xff,
00031       BOOL             = 0x01,
00032       UINT8            = 0x02,
00033       INT8             = 0x03,
00034       UINT16           = 0x04,
00035       INT16            = 0x05,
00036       UINT32           = 0x06,
00037       INT32            = 0x07,
00038       UINT64           = 0x08,
00039       INT64            = 0x09,
00040       STRING           = 0x0a,
00041       DOUBLE           = 0x0b,
00042    };
00043    // -----------------------------------------------------------------------
00044    template<typename Type_P>
00045    class SensorEncoding
00046    {
00047    public:
00048       static uint8_t encoding()
00049       { return UNKNOWN_ENCODING; }
00050    };
00051    // -----------------------------------------------------------------------
00052    template<> class SensorEncoding<bool>
00053    {
00054    public:
00055       static uint8_t encoding()
00056       { return BOOL; }
00057    };
00058    // -----------------------------------------------------------------------
00059    template<> class SensorEncoding<uint8_t>
00060    {
00061    public:
00062       static uint8_t encoding()
00063       { return UINT8; }
00064    };
00065    // -----------------------------------------------------------------------
00066    template<> class SensorEncoding<int8_t>
00067    {
00068    public:
00069       static uint8_t encoding()
00070       { return INT8; }
00071    };
00072    // -----------------------------------------------------------------------
00073    template<> class SensorEncoding<uint16_t>
00074    {
00075    public:
00076       static uint8_t encoding()
00077       { return UINT16; }
00078    };
00079    // -----------------------------------------------------------------------
00080    template<> class SensorEncoding<int16_t>
00081    {
00082    public:
00083       static uint8_t encoding()
00084       { return INT16; }
00085    };
00086    // -----------------------------------------------------------------------
00087    template<> class SensorEncoding<uint32_t>
00088    {
00089    public:
00090       static uint8_t encoding()
00091       { return UINT32; }
00092    };
00093    // -----------------------------------------------------------------------
00094    template<> class SensorEncoding<int32_t>
00095    {
00096    public:
00097       static uint8_t encoding()
00098       { return INT32; }
00099    };
00100    // -----------------------------------------------------------------------
00101    template<> class SensorEncoding<uint64_t>
00102    {
00103    public:
00104       static uint8_t encoding()
00105       { return UINT64; }
00106    };
00107    // -----------------------------------------------------------------------
00108    template<> class SensorEncoding<int64_t>
00109    {
00110    public:
00111       static uint8_t encoding()
00112       { return INT64; }
00113    };
00114    // -----------------------------------------------------------------------
00115    template<> class SensorEncoding<double>
00116    {
00117    public:
00118       static uint8_t encoding()
00119       { return DOUBLE; }
00120    };
00121    // -----------------------------------------------------------------------
00122    template<> class SensorEncoding<char*>
00123    {
00124    public:
00125       static uint8_t encoding()
00126       { return STRING; }
00127    };
00128 }
00129 #endif   /* _SENSOR_ENCODING_H */
00130 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines