1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#ifndef TOOLS_H
#define TOOLS_H
//----------------------------------------------------------------------------
/**
* Disables the copy constructor and assignment operator,
* so the object cannot be copied.
*/
#define REFERENCE_OBJECT(O) \
private: \
O(const O &other); \
O &operator=(const O &other)
//----------------------------------------------------------------------------
#define STATE_OBJECT(O) \
REFERENCE_OBJECT(O); \
public: \
static inline O *getInstance() { return &sm_instance; } \
private: \
static O sm_instance
//----------------------------------------------------------------------------
#define STRATEGY_OBJECT(O) STATE_OBJECT(O)
//----------------------------------------------------------------------------
#define SINGLETON_OBJECT(O) STATE_OBJECT(O)
//----------------------------------------------------------------------------
#define DECLARE_PIMPL \
private: \
class PImpl; \
PImpl *m_pImpl
//----------------------------------------------------------------------------
#if defined __GNUC__ && ! defined __LINT__
#define MIN(X, Y) ((X) <? (Y))
#define MAX(X, Y) ((X) >? (Y))
#else
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
#endif //!__GNUC__
//----------------------------------------------------------------------------
#define ZAP_POINTER(p) delete p; p = NULL;
#define ZAP_ARRAY(a) delete [] a; a = NULL;
//----------------------------------------------------------------------------
/**
* A wrapper for rand(), implemented as described
* in the NOTES section of "man 3 rand".
*
* @return A random number inside of the interval [0, limit).
*/
int myRand(int limit);
#endif //TOOLS_H
|