system.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2009 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 
00033 #pragma once
00034 
00035 
00036 #include "../api_core.h"
00037 #include "../Text/string_types.h"
00038 #include <vector>
00039 
00042 struct CL_API_CORE CL_PreallocatedMemory
00043 {
00044         int dummy;
00045 };
00046 
00047 class CL_Mutex;
00048 
00052 class CL_API_CORE CL_System
00053 {
00056 
00057 public:
00059         static unsigned int get_time();
00060 
00062         static bool detect_mmx();
00063 
00065         static bool detect_3dnow();
00066 
00068         static bool detect_ext_3dnow();
00069 
00071         static CL_Mutex *get_sharedptr_mutex();
00072 
00074         static int get_num_cores();
00075 
00076 
00080 
00081 public:
00083         static int capture_stack_trace(int frames_to_skip, int max_frames, void **out_frames, unsigned int *out_hash = 0);
00084 
00086 
00087         static std::vector<CL_String> get_stack_frames_text(void **frames, int num_frames);
00088 
00090         static void sleep(int millis);
00091 
00094 
00100         static CL_String get_exe_path();
00101 
00103         template<typename T>
00104         static void call_constructor(T *memory)
00105         {
00106                 new ((CL_PreallocatedMemory *) memory) T;
00107         }
00108 
00109         template<typename T, typename P1>
00110         static void call_constructor(T *memory, P1 p1)
00111         {
00112                 new ((CL_PreallocatedMemory *) memory) T(p1);
00113         }
00114 
00115         template<typename T, typename P1, typename P2>
00116         static void call_constructor(T *memory, P1 p1, P2 p2)
00117         {
00118                 new ((CL_PreallocatedMemory *) memory) T(p1, p2);
00119         }
00120 
00121         template<typename T, typename P1, typename P2, typename P3>
00122         static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3)
00123         {
00124                 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3);
00125         }
00126 
00127         template<typename T, typename P1, typename P2, typename P3, typename P4>
00128         static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4)
00129         {
00130                 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4);
00131         }
00132 
00133         template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5>
00134         static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
00135         {
00136                 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4, p5);
00137         }
00138 
00139         template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00140         static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
00141         {
00142                 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4, p5, p6);
00143         }
00144 
00145         template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
00146         static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7)
00147         {
00148                 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4, p5, p6, p7);
00149         }
00150 
00152         template<typename T>
00153         static void call_destructor(T *memory)
00154         {
00155                 memory->~T();
00156         }
00157 
00158         static void alloc_thread_temp_pool();
00159 
00160         static void free_thread_temp_pool();
00161 
00162 
00166 
00167 private:
00169 };
00170 
00171 

Generated on Thu Dec 3 02:39:32 2009 for ClanLib by  doxygen 1.4.6