PageRenderTime 31ms CodeModel.GetById 19ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/src/FreeImage/Source/DeprecationManager/DeprecationMgr.h

https://bitbucket.org/cabalistic/ogredeps/
C++ Header | 83 lines | 46 code | 14 blank | 23 comment | 3 complexity | 44252a50c77d8850d9d62387e8085e38 MD5 | raw file
 1// ==========================================================
 2// Deprecation Manager
 3//
 4// Design and implementation by
 5// - Noel Llopis (Game Programming Gems II)
 6//
 7// This file is part of FreeImage 3
 8//
 9// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
10// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
11// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
12// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
13// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
14// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
15// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
16// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
17// THIS DISCLAIMER.
18//
19// Use at your own risk!
20// ==========================================================
21
22#ifndef DEPRECATIONMGR_H
23#define DEPRECATIONMGR_H
24
25#ifdef _MSC_VER 
26#pragma warning(disable : 4786 )  // identifier was truncated to 'number' characters
27#endif 
28
29#include "Utilities.h"
30
31// ==========================================================
32
33#if !defined(_M_X64) && defined(_MSC_VER)
34	#define DEPRECATE(a,b) \
35	{ \
36		void *fptr;	\
37		_asm { mov fptr, ebp }	\
38		DeprecationMgr::GetInstance()->AddDeprecatedFunction(a, b, fptr); \
39	}
40
41#elif defined(__i386__) && defined(__GNUC__)
42	#define DEPRECATE(a,b) \
43	{ \
44		void *fptr;	\
45		__asm__("movl %%ebp, %0" : "=m" (fptr));	\
46		DeprecationMgr::GetInstance()->AddDeprecatedFunction(a, b, fptr); \
47	}
48
49#else
50	// default fallback case, which does not use the ebp register's content
51	#define DEPRECATE(a,b) \
52	{ \
53		void *fptr = NULL;	\
54		DeprecationMgr::GetInstance()->AddDeprecatedFunction(a, b, fptr); \
55	}
56#endif
57
58// ==========================================================
59
60class DeprecationMgr {
61#if (_MSC_VER == 1100) // VC 5.0 need to look into the docs for the compiler for the value of each version
62public:
63#else
64private:
65#endif
66
67	struct DeprecatedFunction {
68		const char *old_function_name;
69		const char *new_function_name;
70		std::set<int> called_from;
71	};
72
73	std::map<const char *, DeprecatedFunction> m_functions;
74
75public:
76	DeprecationMgr();
77	~DeprecationMgr();
78
79	static DeprecationMgr * GetInstance ( void );
80	void AddDeprecatedFunction(const char *old_function_name, const char *new_function_name, const void *frame_ptr);
81};
82
83#endif //DEPRECATIONMGR_H