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