CPN
Computational Process Networks
QueueDatatypes.h
Go to the documentation of this file.
1 //=============================================================================
2 // Computational Process Networks class library
3 // Copyright (C) 1997-2006 Gregory E. Allen and The University of Texas
4 //
5 // This library is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
14 //
15 // The GNU Public License is available in the file LICENSE, or you
16 // can write to the Free Software Foundation, Inc., 59 Temple Place -
17 // Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
18 // World Wide Web at http://www.fsf.org.
19 //=============================================================================
25 #ifndef CPN_QUEUEDATATYPES_H
26 #define CPN_QUEUEDATATYPES_H
27 #pragma once
28 
29 #include <cpn/common.h>
30 #include <stdint.h>
31 #include <typeinfo>
32 #include <complex>
33 #include <string>
34 
35 namespace CPN {
36 
37  bool TypeCompatable(const std::string &type1, const std::string &type2);
38 
39  template<class type>
40  std::string TypeName() {
41  return typeid(type).name();
42  }
43 
44  // this function is so that void has a size of 1
45  template<class type>
46  unsigned GetTypeSize() {
47  return sizeof(type);
48  }
49 
50  // We want void to be of indetermiante type for the queue
51  template<>
52  inline unsigned GetTypeSize<void>() { return 1; }
53 
54 
55 #define REGISTER_TYPE(type, name) \
56  template<> inline std::string TypeName<type>() { return std::string(name); }
57 #define REGISTER_TYPE_NAME(type) REGISTER_TYPE(type, #type)
58 
59  REGISTER_TYPE_NAME(void);
60  REGISTER_TYPE_NAME(int8_t);
61  REGISTER_TYPE_NAME(uint8_t);
62  REGISTER_TYPE_NAME(int16_t);
63  REGISTER_TYPE_NAME(uint16_t);
64  REGISTER_TYPE_NAME(int32_t);
65  REGISTER_TYPE_NAME(uint32_t);
66  REGISTER_TYPE_NAME(int64_t);
67  REGISTER_TYPE_NAME(uint64_t);
68  REGISTER_TYPE_NAME(float);
69  REGISTER_TYPE_NAME(double);
70  REGISTER_TYPE_NAME(long double);
71 
72  REGISTER_TYPE(std::complex<int8_t>, "complex<int8_t>");
73  REGISTER_TYPE(std::complex<uint8_t>, "complex<uint8_t>");
74  REGISTER_TYPE(std::complex<int16_t>, "complex<int16_t>");
75  REGISTER_TYPE(std::complex<uint16_t>, "complex<uint16_t>");
76  REGISTER_TYPE(std::complex<int32_t>, "complex<int32_t>");
77  REGISTER_TYPE(std::complex<uint32_t>, "complex<uint32_t>");
78  REGISTER_TYPE(std::complex<int64_t>, "complex<int64_t>");
79  REGISTER_TYPE(std::complex<uint64_t>, "complex<uint64_t>");
80  REGISTER_TYPE(std::complex<float>, "complex<float>");
81  REGISTER_TYPE(std::complex<double>, "complex<double>");
82  REGISTER_TYPE(std::complex<long double>, "complex<long double>");
83 
84 #undef REGISTER_TYPE_NAME
85 #undef REGISTER_TYPE
86 
87 }
88 
89 #endif
90 
REGISTER_TYPE(std::complex< int8_t >,"complex<int8_t>")
std::string TypeName()
REGISTER_TYPE_NAME(void)
unsigned GetTypeSize()
unsigned GetTypeSize< void >()
bool TypeCompatable(const std::string &type1, const std::string &type2)