OpenDaVINCI  4.15.3
opendavinci.h
Go to the documentation of this file.
1 
20 #ifndef OPENDAVINCI_CORE_PLATFORM_H_
21 #define OPENDAVINCI_CORE_PLATFORM_H_
22 
27 #ifdef _WIN32
28  // Disable warning "__declspec(nothrow)..."
29  #pragma warning( disable : 4290 )
30  // Disable warning "Possible loss of precision"
31  #pragma warning( disable : 4244 )
32  // Disable warning "DLL interface..."
33  #pragma warning( disable : 4251 )
34  // Disable warning "this pointer during initialization..."
35  #pragma warning( disable : 4355 )
36  // Disable warning "'dynamic_cast' for polymorphic type..."
37  #pragma warning( disable : 4541 )
38  // Disable warning "Not all control paths..."
39  #pragma warning( disable : 4715 )
40  // Disable warning "C++ exceptio specification ignored..."
41  #pragma warning( disable : 4290 )
42  // Disable warning "Missing dllimport for std::exception..."
43  #pragma warning( disable : 4275 )
44  // Disable warning "new behavior: elements of array will be default initialized..."
45  #pragma warning( disable : 4351 )
46 
47  // Link to ws2_32.lib to get symbol "htonl and ntohl".
48  #pragma comment(lib, "ws2_32.lib")
49 
50  // Define Windows 7.
51  #ifndef _WIN32_WINNT
52  #define _WIN32_WINNT 0x0601
53  #endif
54  #define WIN32_LEAN_AND_MEAN
55 
56  #ifdef OPENDAVINCI_SHARED
57  #ifdef OPENDAVINCI_EXPORTS
58  #define OPENDAVINCI_API __declspec(dllexport)
59  #else
60  #define OPENDAVINCI_API __declspec(dllimport)
61  #endif
62  #else
63  // In the case of static linking:
64  #define OPENDAVINCI_API
65  #endif
66 #else // Not _WIN32 (i.e. LINUX or something else)
67  #define OPENDAVINCI_API
68 #endif // _WIN32
69 
71 
72 /**************************************************************************************/
73 
74 #ifndef WIN32
75  #include <arpa/inet.h> // for htonl etc
76  #include <stddef.h> // for NULL
77  #include <stdint.h> // for uint32_t etc
78  #include <unistd.h> // for unlink
79 
80  // Use regular unlink.
81  #define UNLINK unlink
82 #elif WIN32
83  // Unlink causes an error under Windows.
84  #define UNLINK _unlink
85 
87  #include <basetsd.h>
88  #include <Winsock2.h>
89  #include <ws2tcpip.h>
90 #endif
91 
92 /**************************************************************************************/
93 
94 // Type convention software-wide.
95 namespace odcore {
96  enum TYPE_ {
97  BOOL_=0,
99  UINT8_T, // same as unsigned char
101  UINT16_T, // same as unsigned short
102  INT16_T, // same as short
105  UINT64_T, // same as unsigned long
106  INT64_T, // same as long
113  // non-primitive types //
121  // delta values //
201  NO_OP=255
202  };
203 }
204 
205 /* This macro eases the declaration of exceptions. */
206 #define OPENDAVINCI_CORE_DECLARE_EXCEPTION(ExceptionName) class OPENDAVINCI_API ExceptionName : public Exceptions { public: ExceptionName(const string &exceptionMessage, const string &fileName, const uint32_t &lineNumber) : Exceptions(exceptionMessage, fileName, lineNumber) {}; const string getExceptionName() const { return "" #ExceptionName ""; } };
207 
208 /* This macro eases the usage of exceptions. */
209 #define OPENDAVINCI_CORE_THROW_EXCEPTION(ExceptionClass, ExceptionMessage) do { throw odcore::exceptions::ExceptionClass(ExceptionMessage, "", 0); } while (false)
210 
211 /* This macro eases the usage of freeing a pointer. */
212 #define OPENDAVINCI_CORE_FREE_POINTER(ptr) do { if (ptr != NULL) { free(ptr); }; ptr = NULL; } while (false)
213 
214 /* This macro eases the usage of deleting a pointer. */
215 #define OPENDAVINCI_CORE_DELETE_POINTER(ptr) do { if (ptr != NULL) { delete(ptr); }; ptr = NULL; } while (false)
216 
217 /* This macro eases the usage of deleting an array. */
218 #define OPENDAVINCI_CORE_DELETE_ARRAY(ptr) do { if (ptr != NULL) { delete [] (ptr); }; ptr = NULL; } while (false)
219 
220 /* This macro eases the usage of logging. */
221 #define CLOG if (odcore::base::module::AbstractCIDModule::isVerbose()) std::clog
222 #define CLOG1 if (odcore::base::module::AbstractCIDModule::getVerbosity() == 1) std::clog
223 #define CLOG2 if ((odcore::base::module::AbstractCIDModule::getVerbosity() <= 2) && (odcore::base::module::AbstractCIDModule::getVerbosity() >= 1)) std::clog
224 #define CLOG3 if ((odcore::base::module::AbstractCIDModule::getVerbosity() <= 3) && (odcore::base::module::AbstractCIDModule::getVerbosity() >= 1)) std::clog
225 
226 #endif // OPENDAVINCI_CORE_PLATFORM_H_
Definition: opendavinci.h:188
Definition: opendavinci.h:129
Definition: opendavinci.h:174
Definition: opendavinci.h:152
Definition: opendavinci.h:105
Definition: opendavinci.h:119
Definition: opendavinci.h:141
Definition: opendavinci.h:108
Definition: opendavinci.h:196
Definition: opendavinci.h:156
Definition: opendavinci.h:147
Definition: opendavinci.h:137
Definition: opendavinci.h:195
Definition: opendavinci.h:139
Definition: opendavinci.h:127
Definition: opendavinci.h:171
Definition: opendavinci.h:168
Definition: opendavinci.h:192
Definition: opendavinci.h:199
Definition: opendavinci.h:150
Definition: opendavinci.h:106
Definition: opendavinci.h:176
Definition: opendavinci.h:117
Definition: opendavinci.h:157
Definition: opendavinci.h:124
Definition: opendavinci.h:102
Definition: opendavinci.h:107
Definition: opendavinci.h:148
Definition: opendavinci.h:125
Definition: opendavinci.h:198
Definition: opendavinci.h:118
Definition: opendavinci.h:170
Definition: opendavinci.h:179
Definition: opendavinci.h:131
Definition: opendavinci.h:190
Definition: opendavinci.h:130
Definition: opendavinci.h:163
Definition: opendavinci.h:126
Definition: opendavinci.h:158
Definition: opendavinci.h:184
Definition: opendavinci.h:155
Definition: opendavinci.h:101
Definition: opendavinci.h:116
Definition: opendavinci.h:166
Definition: opendavinci.h:146
Definition: opendavinci.h:110
Definition: opendavinci.h:143
Definition: opendavinci.h:172
Definition: opendavinci.h:144
TYPE_
Definition: opendavinci.h:96
Definition: opendavinci.h:162
Definition: opendavinci.h:167
Definition: opendavinci.h:134
Definition: opendavinci.h:177
Definition: opendavinci.h:180
Definition: opendavinci.h:159
Definition: opendavinci.h:133
Definition: opendavinci.h:100
Definition: opendavinci.h:98
Definition: opendavinci.h:164
Definition: opendavinci.h:138
Definition: opendavinci.h:123
Definition: opendavinci.h:175
Definition: opendavinci.h:186
Definition: opendavinci.h:111
Definition: opendavinci.h:142
Definition: opendavinci.h:165
Definition: opendavinci.h:145
Definition: opendavinci.h:151
Definition: opendavinci.h:99
Definition: opendavinci.h:183
Definition: opendavinci.h:201
Definition: opendavinci.h:128
Definition: opendavinci.h:104
Definition: opendavinci.h:135
Definition: opendavinci.h:115
Definition: opendavinci.h:193
Definition: opendavinci.h:153
Definition: opendavinci.h:169
Definition: opendavinci.h:178
Definition: opendavinci.h:181
Definition: opendavinci.h:97
Definition: opendavinci.h:109
Definition: opendavinci.h:191
Definition: opendavinci.h:103
Definition: opendavinci.h:154
Definition: opendavinci.h:136
Definition: opendavinci.h:140
Definition: opendavinci.h:161
Definition: opendavinci.h:185
Definition: opendavinci.h:187