SMIL  0.9.1
DTypes.hpp
1 /*
2  * Copyright (c) 2011-2016, Matthieu FAESSEL and ARMINES
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Matthieu FAESSEL, or ARMINES nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 
30 #ifndef _D_TYPES_HPP
31 #define _D_TYPES_HPP
32 
33 #ifndef _MSC_VER
34 #include <stdint.h>
35 #endif // _MSC_VER
36 #include <limits>
37 
38 #include "Core/include/private/DMemory.hpp"
39 
40 #include <sstream>
41 
42 using namespace std;
43 
44 namespace smil
45 {
46  typedef int INT;
47  typedef long LONG;
48  typedef unsigned int UINT;
49  typedef unsigned long ULONG;
50  typedef unsigned char UINT8;
51  typedef unsigned short UINT16;
52  typedef unsigned int UINT32;
53 #ifdef _MSC_VER
54  typedef unsigned __int64 UINT64;
55 #else
56  typedef uint64_t UINT64;
57 #endif
58 
59  // typedef unsigned char __attribute__ ((vector_size (16))) alUINT8;
60 
61  // Why this directive for msvc (windows) ?
62  //#ifndef _MSC_VER
63  typedef signed char INT8;
64  //#endif // _MSC_VER
65  typedef short INT16;
66  typedef int INT32;
67 
68 
69  #ifndef CHAR_BIT
70  #define CHAR_BIT 8
71  #endif
72 
73  enum DType
74  {
75  DtUINT8, DtUINT16, DtUINT32, DtUINT64, DtINT, DtUINT
76  };
77 
78 
79  template <class T>
80  struct ImDtTypes
81  {
82  typedef T pixelType;
83  typedef pixelType *lineType;
84 #ifndef SWIG
85  typedef pixelType * __restrict restrictLineType;
86 #endif // SWIG
87  typedef lineType *sliceType;
88  typedef sliceType *volType;
89 
90  typedef std::vector<T, Allocator<T> > vectorType;
91 // typedef std::vector<T> vectorType;
92  typedef std::vector< vectorType > matrixType;
93 
94  typedef double floatType;
95 
96  static inline pixelType min() { return numeric_limits<T>::min(); }
97  static inline pixelType max() { return numeric_limits<T>::max(); }
98  static inline size_t cardinal() { return max()-min()+1; }
99  static inline lineType createLine(size_t lineLen) { return createAlignedBuffer<T>(lineLen); }
100  static inline void deleteLine(lineType line) { deleteAlignedBuffer<T>(line); }
101  static inline size_t ptrOffset(lineType p, size_t n=SIMD_VEC_SIZE) { return ((size_t)p) & (n-1); }
102  static inline std::string toString(const T &val)
103  {
104  stringstream str;
105  str << double(val);
106  return str.str();
107  }
108  };
109 
110 
111 
112  template <class T>
113  inline const char *getDataTypeAsString(T * /*val*/ =(T*)NULL)
114  {
115  return "Unknown";
116  }
117 
118 
119  #define DECL_DATA_TYPE_STR(_type) \
120  template <> \
121  inline const char *getDataTypeAsString(_type *) { return #_type; }
122 
123  DECL_DATA_TYPE_STR(UINT8)
124  DECL_DATA_TYPE_STR(UINT16)
125  DECL_DATA_TYPE_STR(INT8)
126  DECL_DATA_TYPE_STR(INT16)
127  DECL_DATA_TYPE_STR(int)
128  DECL_DATA_TYPE_STR(float)
129  DECL_DATA_TYPE_STR(double)
130 
131 } // namespace smil
132 
133 
134 #endif // _D_TYPES_HPP
Author Vincent Morard Date : 7 march 2011 See : Morard V. and Dokladal P. and Decenciere E...
Definition: DApplyThreshold.hpp:36
Definition: DTypes.hpp:80