Comment remaining unsolved bug.
[ardour.git] / libs / backends / wavesaudio / wavesapi / BasicTypes / WUTypes.h
1 /*
2     Copyright (C) 2014 Waves Audio Ltd.
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __WUTypes_h__
21         #define __WUTypes_h__
22
23 /* Copy to include:
24 #include "BasicTypes/WUTypes.h"
25 */
26
27 #include "WavesPublicAPI/WTErr.h"
28 #include "WavesPublicAPI/wstdint.h"
29 #include "BasicTypes/WUDefines.h"
30 #include "BasicTypes/WCFourCC.h"        // declares WTFourCharCode & WCFourCC
31 #include "BasicTypes/WUComPtr.h"        // Communication Ptr for x64 compatibility
32 #include "WCFixedString.h"
33 #include <ctime>
34 #include <vector>
35 /********************************************************************************
36     Atoms
37 *********************************************************************************/
38
39 #define WTSInt64    "WTSInt64 is obsolete, please use int64_t instead";
40 #define WTUInt64    "WTUInt64 is obsolete, please use uint64_t instead";
41 #define WTSInt32    "WTSInt32 is obsolete, please use int32_t instead";
42 #define WTUInt32    "WTUInt32 is obsolete, please use uint32_t instead";
43 #define WTSInt16    "WTSInt16 is obsolete, please use int16_t instead";
44 #define WTUInt16    "WTUInt16 is obsolete, please use uint16_t instead";
45 #define WTSInt8     "WTSInt8 is obsolete, please use int8_t instead";
46 #define WTUInt8     "WTUInt8 is obsolete, please use uint8_t instead";
47 #define WTFloat32   "WTFloat32 is obsolete, please use float instead";
48 #define WTByte      "WTByte is obsolete, please use uint8_t instead";
49
50 /********************************************************************************
51     Consts
52 *********************************************************************************/
53 //#define PI 3.1415926535897 // ... Was moved to WUMathConsts.h under the name kPI
54 const uint32_t kDefaultCircleSlices = 100;
55
56
57 /********************************************************************************
58     Utilities
59 *********************************************************************************/
60
61 // SCOPED_ENUM is a macro that defines an enum inside a class with a given name, thus declaring the enum values
62 // inside a named scope. This allows declaring:
63 //      SCOPED_ENUM(SomeType)
64 //      {
65 //          Val1,
66 //          Val2,
67 //          Val3
68 //      }
69 //      SCOPED_ENUM_END
70 // And then you can reference SomeType::Val1, SomeType::Val2, SomeType::Val3 for the various values, unlike
71 // a regular enum on which Val1, Val2 and Val3 would become global names.
72 // Additionally, you get SomeType::Type to specify the type of the whole enum in case you want to transfer it to
73 // a function.
74 // Don't forget to close the enum with SCOPED_ENUM_END, otherwise you'll get bogus compilation errors.
75 // This requirement can probably be removed some day, but it will make the SCOPED_ENUM macro much less readable...
76 #define SCOPED_ENUM(name) \
77 class name \
78 { \
79 public: enum Type
80
81 #define SCOPED_ENUM_END ;};
82
83
84 //********************************************************************************
85 //    Files
86
87 //! file (and resource container) opening permissions
88 // Note: When opening with eFMWriteOnly on existing file, writing to the file will append, not overwrite, Shai, 9/8/2007.
89 enum    WEPermitions{ eFMReadOnly, eFMWriteOnly, eFMReadWrite};
90
91 // File cursor positions
92 enum    WEPositionMode{eFMFileBegin, eFMFileCurrent, eFMFileEnd};
93
94 // File creation types
95 enum    WECreateFlags {
96         eFMCreateFile_DontOverrideIfAlreadyExists,      // Create a new file , If the file exists leaves the existing data intact
97         eFMCreateFile_FailIfAlreadyExists,                      // Attempt to create a new file, if file already exists - fail.
98         eFMCreateFile_OverrideIfAlreadyExists       // Create a new file , If the file exists, overwrite the file and clear the existing data
99 };
100
101
102 enum WEFoldersDomain{
103         eSystemDomain,
104         eLocalDomain,
105         eUserDomain,
106
107         eNumberOfFoldersDomains
108 };
109 enum WEArchBits{
110     e32Bits,
111     e64Bits,
112     eNumberOfArchBits
113 };
114
115 enum WESystemFolders{
116         eSystemFolder,
117         eDesktopFolder,
118         ePreferencesFolder,
119         eWavesPreferencesFolder, //deprecated use eWavesPreferencesFolder2
120         eTemporaryFolder,
121         eTrashFolder,
122         eCurrentFolder,
123         eRootFolder,
124         eLibrariesFolder,
125         eAudioComponentsFolder, // MacOS only
126         eCacheFolder,
127         eWavesCacheFolder,
128         eAppDataFolder,
129         eWavesAppDataFolder,
130         eSharedUserDataFolder,
131         eWavesSharedUserDataFolder,
132         eWavesScanViewFolder,
133
134         eWavesPreferencesFolder2, // Mac: "/Users/username/Library/Preferences/Waves Audio"
135                               // Win: "C:\Users\username\AppData\Roaming\Waves Audio\Preferences"
136
137         eNumberOfSystemFolders
138 };
139
140 //********************************************************************************
141 //    Process
142
143 #ifdef __APPLE__
144         typedef uint32_t WTProcessID; // actually pid_t which is __darwin_pid_t which is __uint32_t
145 #endif
146 #ifdef PLATFORM_WINDOWS
147         typedef int             WTProcessID;
148 #endif
149 #ifdef __linux__
150         typedef uint32_t WTProcessID;
151 #endif
152
153 enum WEManagerInitOptions
154 {
155     eUnknown_ManagerInitOption,
156     eMacOS_Carbon_Runtime,
157     eMacOS_Cocoa_Runtime,
158     eLinuxOS_gtk_Runtime,
159     eLinuxOS_X_Runtime,
160     eWindowsOS_GoodOld_Runtime,         // good old windows API
161     eWindowsOS_DotNET_Runtime,
162     eVerticalFliped_Graphics,
163     eInit_RM,
164     eInit_GMConfig,
165     eInit_PVM,
166     eInit_UM,
167     eInit_BKG
168 };
169 #ifdef __APPLE__
170     #if __LP64__ || NS_BUILD_32_LIKE_64 // in 64bit (or when NS_BUILD_32_LIKE_64 is specified) we decline Carbon implementation.
171         const WEManagerInitOptions eDefaultRuntime = eMacOS_Cocoa_Runtime;
172     #else
173         const WEManagerInitOptions eDefaultRuntime = eMacOS_Carbon_Runtime;
174     #endif
175 #endif
176 #ifdef PLATFORM_WINDOWS
177     const WEManagerInitOptions eDefaultRuntime = eWindowsOS_GoodOld_Runtime;
178 #endif
179 #ifdef __linux__
180     const WEManagerInitOptions eDefaultRuntime = eLinuxOS_gtk_Runtime;
181 #endif
182
183
184 //********************************************************************************
185 //    Files
186
187 const uint32_t kMaxPathLength = 1023;      // maximum length of a path
188 const uint32_t kMaxFileNameLength = 255;    // maximum length of a file name including extension
189 typedef WCFixedString<kMaxPathLength> WTPathString;
190 typedef WCFixedString<kMaxFileNameLength> WTFileNameString;
191
192 typedef uint64_t WTFileSize;
193 const WTFileSize kIllegalFileSize = (WTFileSize)-1;
194
195 typedef off_t WTFileOffset;
196
197 typedef std::time_t WTFileTime;
198 const WTFileTime kIllegalFileTime = (WTFileTime)-1;
199
200 typedef struct WTPathType* WTPathRef;                           // represents a path, path need not exists
201 typedef struct WTOpenFileType* WTOpenFileRef;           // represents a real, open file
202 typedef struct WTNativeDLLRefType* WTNativeDLLRef;      // define WTNativeDLLRef as a unique type CFBundleRef on Mac, HINSTANCE on Windows
203 const WTNativeDLLRef kIllegalNativeDLLRef = 0;
204 //********************************************************************************
205 //    Resources
206
207 const size_t kMaxResTypeLength = 31;
208 typedef WCFixedString31 WTResType;
209 typedef short       WTResID;
210 const   WTResID     kIllegalResID = -1;
211
212
213 typedef struct WTResContainerType*                      WTResContainerRef;
214 typedef struct WTResourceType*                                  WTResRef;
215 const WTResContainerRef kIllegalContainerRef = 0;
216 const WTResRef kIllegalResourceRef = 0;
217
218 #ifdef __APPLE__
219         typedef struct WTNativeResourceType*    WTNativeResourceRef;    // for use when need to have access to the native resource without going though resource manager caching anf conversion.
220     const WTNativeResourceRef           kIllegalNativeResourceRef = 0;
221 #endif
222 #ifdef PLATFORM_WINDOWS
223         typedef struct WTNativeResourceType*    WTNativeResourceRef; //HGLOBAL  // for use when need to have access to the native resource without going though resource manager caching anf conversion.
224     const WTNativeResourceRef           kIllegalNativeResourceRef = 0;
225 #endif
226 #ifdef __linux__
227 typedef void*                                   WTNativeResourceRef;   // WTOpenFileRef // for use when need to have access to the native resource without going though resource manager caching anf conversion.
228     const WTNativeResourceRef           kIllegalNativeResourceRef = 0;
229 #endif
230
231 //********************************************************************************
232 //    OpenGL
233
234 typedef struct WCOGLContext*                    WCOGLContextRef;
235 typedef struct WCOGLTexture*                    WCOGLTextureRef;
236 typedef struct WSPluginView*            WCPluginViewRef;
237 typedef struct WSMenu*                  WCMenuRef;
238 typedef struct WCPluginNativeView*      WCPluginNativeViewRef;
239
240 const WCOGLContextRef kIllegalOGLContextRef = 0;
241 const WCOGLTextureRef kIllegalOGLTextureRef = 0;
242 const WCPluginViewRef kIllegalPluginViewRef = 0;
243 const WCMenuRef kIllegalWCMenuRef = 0;
244
245 const intptr_t kIllegalTexturesMaster = -1;
246
247
248 typedef unsigned int WTTextureRef;
249 const WTTextureRef kIllegalTextureRef = 0;
250
251 // type for storing pointer to functions. Used to avoid warning such as "C++ forbids conversion between pointer to function and pointer to object"
252 typedef void (*DUMMY_FUNC_PTR)(void);
253
254 // type for a generic callback function with one parameter
255 typedef intptr_t (*CALLBACK_1_PARAM_FUNC_PTR)(intptr_t);
256
257 //////////////////////////////////////////////////////////////
258 // Timer
259 typedef intptr_t WTTimerRef;
260 const WTTimerRef kIllegalTimerRef = 0;
261 typedef void (*WTTimerCallback)(intptr_t);
262
263 // generic type for OS native pointer
264 typedef void* WTPtr;
265
266 #endif //__WUTypes_h__