fp@1835: /***************************************************************************** fp@1835: * fp@1835: * $Id$ fp@1835: * fp@1835: * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH fp@1835: * fp@1835: * This file is part of the IgH EtherCAT Master. fp@1835: * fp@1835: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1835: * modify it under the terms of the GNU General Public License version 2, as fp@1835: * published by the Free Software Foundation. fp@1835: * fp@1835: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1835: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1835: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1835: * Public License for more details. fp@1835: * fp@1835: * You should have received a copy of the GNU General Public License along fp@1835: * with the IgH EtherCAT Master; if not, write to the Free Software fp@1835: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@1835: * fp@1835: * --- fp@1835: * fp@1835: * The license mentioned above concerns the source code only. Using the fp@1835: * EtherCAT technology and brand is only permitted in compliance with the fp@1835: * industrial property and similar rights of Beckhoff Automation GmbH. fp@1835: * fp@1835: ****************************************************************************/ fp@1835: fp@1835: #ifndef __DATATYPEHANDLER_H__ fp@1835: #define __DATATYPEHANDLER_H__ fp@1835: fp@1835: /****************************************************************************/ fp@1835: fp@1835: #include fp@1835: #include fp@1835: #include fp@1835: #include fp@1835: fp@1835: /****************************************************************************/ fp@1835: fp@1835: class DataTypeHandler fp@1835: { fp@1835: public: fp@1835: DataTypeHandler(); fp@1835: fp@1835: protected: fp@1835: struct DataType { fp@1835: const char *name; fp@1835: uint16_t code; fp@1835: size_t byteSize; fp@1835: }; fp@1835: fp@1868: static std::string typeInfo(); fp@1868: fp@1835: static const DataType *findDataType(const std::string &); fp@1835: static const DataType *findDataType(uint16_t); fp@1835: static size_t interpretAsType(const DataType *, const std::string &, fp@1835: void *, size_t); fp@1835: fp@1835: class SizeException: fp@1835: public std::runtime_error fp@1835: { fp@1835: public: fp@1835: SizeException(const std::string &msg): fp@1835: runtime_error(msg) {} fp@1835: }; fp@1835: fp@1835: static void outputData(std::ostream &, const DataType *, fp@1835: void *, size_t); fp@1835: static void printRawData(ostream &, const uint8_t *, size_t); fp@1835: fp@1835: private: fp@1835: static const DataType dataTypes[]; fp@1835: }; fp@1835: fp@1835: /****************************************************************************/ fp@1835: fp@1835: #endif