Added: dSpaceSetSublevel/dSpaceGetSublevel and possibility to collide a space as...
[ode.git] / ode / src / odetls.h
blob22535ed8eda4cf0af05556be8af10a22c413640c
1 /*************************************************************************
2 * *
3 * Thread local storage access stub for Open Dynamics Engine, *
4 * Copyright (C) 2008 Oleh Derevenko. All rights reserved. *
5 * Email: odar@eleks.com (change all "a" to "e") *
6 * *
7 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
8 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
9 * *
10 * *
11 * This library is free software; you can redistribute it and/or *
12 * modify it under the terms of EITHER: *
13 * (1) The GNU Lesser General Public License as published by the Free *
14 * Software Foundation; either version 2.1 of the License, or (at *
15 * your option) any later version. The text of the GNU Lesser *
16 * General Public License is included with this library in the *
17 * file LICENSE.TXT. *
18 * (2) The BSD-style license that is included with this library in *
19 * the file LICENSE-BSD.TXT. *
20 * *
21 * This library is distributed in the hope that it will be useful, *
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
24 * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
25 * *
26 *************************************************************************/
30 ODE Thread Local Storage access stub interface.
35 #ifndef _ODE_ODETLS_H_
36 #define _ODE_ODETLS_H_
39 #include "odeou.h"
42 #if dTLS_ENABLED
45 struct TrimeshCollidersCache;
47 enum EODETLSITEM
49 OTI_DATA_ALLOCATION_FLAGS,
50 OTI_TRIMESH_TRIMESH_COLLIDER_CACHE,
51 OTI_TRIMESH_COLLISION_LIBRARY_DATA,
53 OTI__MAX,
57 class COdeTls
59 public:
60 enum // Initialize() flags
62 MANUAL_DATA_CLEANUP = 0x00000001,
65 static bool Initialize(unsigned uFlags=0);
66 static void Finalize();
68 static void CleanupForThread();
70 public:
71 static unsigned GetDataAllocationFlags()
73 // Must be a safe call as it is used to test if TLS slot is allocated at all
74 return (unsigned)(size_t)CThreadLocalStorage::GetStorageValue(m_htkStorageKey, OTI_DATA_ALLOCATION_FLAGS);
77 static void SignalDataAllocationFlags(unsigned uFlagsMask)
79 unsigned uCurrentFlags = (unsigned)(size_t)CThreadLocalStorage::UnsafeGetStorageValue(m_htkStorageKey, OTI_DATA_ALLOCATION_FLAGS);
80 CThreadLocalStorage::UnsafeSetStorageValue(m_htkStorageKey, OTI_DATA_ALLOCATION_FLAGS, (tlsvaluetype)(uCurrentFlags | uFlagsMask));
83 static void DropDataAllocationFlags(unsigned uFlagsMask)
85 unsigned uCurrentFlags = (unsigned)(size_t)CThreadLocalStorage::UnsafeGetStorageValue(m_htkStorageKey, OTI_DATA_ALLOCATION_FLAGS);
86 CThreadLocalStorage::UnsafeSetStorageValue(m_htkStorageKey, OTI_DATA_ALLOCATION_FLAGS, (tlsvaluetype)(uCurrentFlags & ~uFlagsMask));
89 static TrimeshCollidersCache *GetTrimeshCollidersCache()
91 return (TrimeshCollidersCache *)CThreadLocalStorage::UnsafeGetStorageValue(m_htkStorageKey, OTI_TRIMESH_TRIMESH_COLLIDER_CACHE);
94 static void *GetTrimeshCollisionLibraryData()
96 return (void *)CThreadLocalStorage::UnsafeGetStorageValue(m_htkStorageKey, OTI_TRIMESH_COLLISION_LIBRARY_DATA);
99 public:
100 static bool AssignDataAllocationFlags(unsigned uInitializationFlags);
102 static bool AssignTrimeshCollidersCache(TrimeshCollidersCache *pccInstance);
103 static void DestroyTrimeshCollidersCache();
105 static bool AssignTrimeshCollisionLibraryData(void *pv_DataInstance);
106 static void DestroyTrimeshCollisionLibraryData();
108 private:
109 static void FreeTrimeshCollidersCache(TrimeshCollidersCache *pccCacheInstance);
110 static void FreeTrimeshCollisionLibraryData(void *pv_DataInstance);
112 private:
113 static void _OU_CONVENTION_CALLBACK FreeTrimeshCollidersCache_Callback(tlsvaluetype vValueData);
114 static void _OU_CONVENTION_CALLBACK FreeTrimeshCollisionLibraryData_Callback(tlsvaluetype vValueData);
116 private:
117 static HTLSKEY m_htkStorageKey;
121 #endif // dTLS_ENABLED
124 #endif // _ODE_ODETLS_H_