BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Macros
macros.h File Reference
#include <BALL/CONFIG/config.h>
#include <BALL/COMMON/constants.h>
#include <BALL/COMMON/rtti.h>
#include <math.h>
#include <typeinfo>

Go to the source code of this file.

Macros

#define BALL_MAX(a, b)   (((a) < (b)) ? (b) : (a))
 
#define BALL_MAX3(x, y, z)   ((x) > (y) ? BALL_MAX(x, z) : BALL_MAX(y, z))
 
#define BALL_MIN(a, b)   (((a) > (b)) ? (b) : (a))
 
#define BALL_MIN3(x, y, z)   ((x) < (y) ? BALL_MIN(x, z) : BALL_MIN(y, z))
 
#define BALL_ABS(x)   (((x) >= 0) ? (x) : -(x))
 
#define BALL_SGN(x)   (((x) < 0) ? -1 : ((x) == 0) ? 0 : 1)
 
#define BALL_ODD(x)   (((x) % 2)!=0)
 
#define BALL_INT_ODD(x)   (((x) & 0x1) == 1)
 
#define BALL_INT_EVEN(x)   (((x) & 0x1) == 0)
 
#define BALL_REAL_ROUND   BALL::Maths::round
 
#define BALL_REAL_EQUAL(x, y, e)   (fabs((x) - (y)) <= e)
 
#define BALL_REAL_NOT_EQUAL(x, y, e)   (fabs((x) - (y)) > e)
 
#define BALL_REAL_LESS(x, y, e)   (((x) - (y)) < -e)
 
#define BALL_REAL_LESS_OR_EQUAL(x, y, e)   (((x) - (y)) <= e)
 
#define BALL_REAL_GREATER(x, y, e)   (((x) - (y)) > e)
 
#define BALL_REAL_GREATER_OR_EQUAL(x, y, e)   (((x) - (y)) >= -e)
 
#define BALL_REAL_ABS(x)   fabs(x)
 
#define BALL_REAL_SGN(x)   BALL_SGN(x)
 
#define BALL_REAL_ODD(x)   (((x) % 2) != 0)
 
#define BALL_REAL_EVEN(x)   (((x) % 2) == 0)
 
#define BALL_REAL_FLOOR(x)   (long)((x) > 0 ? (x): ((x) == (long)(x) ? (x) : (x) - 1))
 
#define BALL_REAL_CEILING(x)   (long)((x) < 0 ? (x): ((x) == (long)(x) ? (x) : (x) + 1))
 
#define BALL_REAL_ROUND_INT(x)   ((x) > 0 ? (int)(x + 0.5) : -(int)(0.5 - x))
 
#define BALL_CHAR_BITS   BALL_CHAR_SIZE * 8
 
#define BALL_CHAR_MASK   BALL_CHAR_BITS - 1
 
#define BALL_CHAR_SHIFT   ((BALL_CHAR_BITS == 8) ? 3 : (BALL_CHAR_BITS == 16) ? 4 : 5)
 
#define BALL_CHAR_ALL_BITS_SET   ((BALL_CHAR_BITS == 8) ? 0xFF : (BALL_CHAR_BITS == 16) ? 0xFFFF : 0xFFFFFFFF)
 
#define BALL_CHAR_ALL_BITS_CLEARED   ((BALL_CHAR_BITS == 8) ? 0x00 : (BALL_CHAR_BITS == 16) ? 0x0000 : 0x00000000)
 
#define BALL_NUMBER_OF_BYTES(bits)   (((bits) + BALL_CHAR_MASK) >> BALL_CHAR_SHIFT)
 
#define BALL_SIZEOF_ARRAY(a)   (sizeof(a) / sizeof(*(a)))
 
#define BALL_BITARRAY_SIZE(number_of_bits)   (((number_of_bits - 1) >> BALL_CHAR_SHIFT) + 1)
 
#define BALL_BITARRAY_CLEAR_BIT(array, x)   ((array)[(x) >> BALL_CHAR_SHIFT] &= ~(1 << ((x) & BALL_CHAR_MASK)))
 
#define BALL_BITARRAY_SET_BIT(array, x)   ((array)[(x) >> BALL_CHAR_SHIFT] |= (1 << ((x) & BALL_CHAR_MASK)))
 
#define BALL_BITARRAY_TOGGLE_BIT(array, x)   ((array)[(x) >> BALL_CHAR_SHIFT] ^= (1 << ((x) & BALL_CHAR_MASK)))
 
#define BALL_BITARRAY_IS_BIT_SET(array, x)   (((array)[(x) >> BALL_CHAR_SHIFT] & (1 << ((x) & BALL_CHAR_MASK))) != 0)
 
#define BALL_BIT(bit)   (1 << (bit))
 
#define BALL_BIT_SET(bitset, bit)   ((bitset) |= (1 << (bit)))
 
#define BALL_BIT_SET_ALL(bitset)   ((bitset) = -1)
 
#define BALL_BIT_SET_ALL_TO(bitset, bit)   ((bitset) |= ~(-1 << (bit + 1)))
 
#define BALL_BIT_SET_ALL_FROM(bitset, bit)   ((bitset) |= (-1 << (bit)))
 
#define BALL_BIT_CLEAR(bitset, bit)   ((bitset) &= ~(1 << (bit)))
 
#define BALL_BIT_CLEAR_ALL(bitset)   ((bitset) = 0)
 
#define BALL_BIT_CLEAR_ALL_TO(bitset, bit)   ((bitset) &= (-1 << (bit + 1)))
 
#define BALL_BIT_CLEAR_ALL_FROM(bitset, bit)   ((bitset) &= ~(-1 << (bit)))
 
#define BALL_BIT_IS_SET(bitset, bit)   ((bitset) & (1 << (bit)))
 
#define BALL_BIT_IS_CLEARED(bitset, bit)   !((bitset) & (1 << (bit)))
 
#define BALL_ANGLE_RADIAN_TO_DEGREE(rad_angle)   (180.0 / ::BALL::Constants::PI * (rad_angle))
 
#define BALL_ANGLE_DEGREE_TO_RADIAN(deg_angle)   (::BALL::Constants::PI / 180.0 * (deg_angle))
 
#define BALL_OFFSET_OF(struct_name, struct_var_name)   ((long)&(((struct_name*)0)->struct_var_name))
 
#define BALL_DUMP_DEPTH(os, depth)   for (dump_indent_depth_ = 0; dump_indent_depth_ < depth; ++dump_indent_depth_) { os << " "; }
 
#define BALL_DUMP_STREAM_PREFIX(os)   Size dump_indent_depth_ = 0;
 
#define BALL_DUMP_HEADER(os, cl, ob)   os << "Object: " << (void *)ob << " is instance of class: " << streamClassName(typeid(*ob)) << std::endl;
 
#define BALL_DUMP_CLASS_HEADER(os, cl, ob)   os << "Object: " << (void *)ob << " is instance of class: " << #cl << ::std::endl;
 
#define BALL_DUMP_STREAM_SUFFIX(os)
 

Macro Definition Documentation

#define BALL_ABS (   x)    (((x) >= 0) ? (x) : -(x))

Definition at line 27 of file macros.h.

#define BALL_ANGLE_DEGREE_TO_RADIAN (   deg_angle)    (::BALL::Constants::PI / 180.0 * (deg_angle))

Definition at line 79 of file macros.h.

#define BALL_ANGLE_RADIAN_TO_DEGREE (   rad_angle)    (180.0 / ::BALL::Constants::PI * (rad_angle))

Definition at line 78 of file macros.h.

#define BALL_BIT (   bit)    (1 << (bit))

Definition at line 66 of file macros.h.

#define BALL_BIT_CLEAR (   bitset,
  bit 
)    ((bitset) &= ~(1 << (bit)))

Definition at line 71 of file macros.h.

#define BALL_BIT_CLEAR_ALL (   bitset)    ((bitset) = 0)

Definition at line 72 of file macros.h.

#define BALL_BIT_CLEAR_ALL_FROM (   bitset,
  bit 
)    ((bitset) &= ~(-1 << (bit)))

Definition at line 74 of file macros.h.

#define BALL_BIT_CLEAR_ALL_TO (   bitset,
  bit 
)    ((bitset) &= (-1 << (bit + 1)))

Definition at line 73 of file macros.h.

#define BALL_BIT_IS_CLEARED (   bitset,
  bit 
)    !((bitset) & (1 << (bit)))

Definition at line 76 of file macros.h.

#define BALL_BIT_IS_SET (   bitset,
  bit 
)    ((bitset) & (1 << (bit)))

Definition at line 75 of file macros.h.

#define BALL_BIT_SET (   bitset,
  bit 
)    ((bitset) |= (1 << (bit)))

Definition at line 67 of file macros.h.

#define BALL_BIT_SET_ALL (   bitset)    ((bitset) = -1)

Definition at line 68 of file macros.h.

#define BALL_BIT_SET_ALL_FROM (   bitset,
  bit 
)    ((bitset) |= (-1 << (bit)))

Definition at line 70 of file macros.h.

#define BALL_BIT_SET_ALL_TO (   bitset,
  bit 
)    ((bitset) |= ~(-1 << (bit + 1)))

Definition at line 69 of file macros.h.

#define BALL_BITARRAY_CLEAR_BIT (   array,
 
)    ((array)[(x) >> BALL_CHAR_SHIFT] &= ~(1 << ((x) & BALL_CHAR_MASK)))

Definition at line 61 of file macros.h.

#define BALL_BITARRAY_IS_BIT_SET (   array,
 
)    (((array)[(x) >> BALL_CHAR_SHIFT] & (1 << ((x) & BALL_CHAR_MASK))) != 0)

Definition at line 64 of file macros.h.

#define BALL_BITARRAY_SET_BIT (   array,
 
)    ((array)[(x) >> BALL_CHAR_SHIFT] |= (1 << ((x) & BALL_CHAR_MASK)))

Definition at line 62 of file macros.h.

#define BALL_BITARRAY_SIZE (   number_of_bits)    (((number_of_bits - 1) >> BALL_CHAR_SHIFT) + 1)

Definition at line 60 of file macros.h.

#define BALL_BITARRAY_TOGGLE_BIT (   array,
 
)    ((array)[(x) >> BALL_CHAR_SHIFT] ^= (1 << ((x) & BALL_CHAR_MASK)))

Definition at line 63 of file macros.h.

#define BALL_CHAR_ALL_BITS_CLEARED   ((BALL_CHAR_BITS == 8) ? 0x00 : (BALL_CHAR_BITS == 16) ? 0x0000 : 0x00000000)

Definition at line 55 of file macros.h.

#define BALL_CHAR_ALL_BITS_SET   ((BALL_CHAR_BITS == 8) ? 0xFF : (BALL_CHAR_BITS == 16) ? 0xFFFF : 0xFFFFFFFF)

Definition at line 54 of file macros.h.

#define BALL_CHAR_BITS   BALL_CHAR_SIZE * 8

Definition at line 51 of file macros.h.

#define BALL_CHAR_MASK   BALL_CHAR_BITS - 1

Definition at line 52 of file macros.h.

#define BALL_CHAR_SHIFT   ((BALL_CHAR_BITS == 8) ? 3 : (BALL_CHAR_BITS == 16) ? 4 : 5)

Definition at line 53 of file macros.h.

#define BALL_DUMP_CLASS_HEADER (   os,
  cl,
  ob 
)    os << "Object: " << (void *)ob << " is instance of class: " << #cl << ::std::endl;

Definition at line 87 of file macros.h.

#define BALL_DUMP_DEPTH (   os,
  depth 
)    for (dump_indent_depth_ = 0; dump_indent_depth_ < depth; ++dump_indent_depth_) { os << " "; }

Definition at line 83 of file macros.h.

#define BALL_DUMP_HEADER (   os,
  cl,
  ob 
)    os << "Object: " << (void *)ob << " is instance of class: " << streamClassName(typeid(*ob)) << std::endl;

Definition at line 86 of file macros.h.

#define BALL_DUMP_STREAM_PREFIX (   os)    Size dump_indent_depth_ = 0;

Definition at line 84 of file macros.h.

#define BALL_DUMP_STREAM_SUFFIX (   os)

Definition at line 88 of file macros.h.

#define BALL_INT_EVEN (   x)    (((x) & 0x1) == 0)

Definition at line 32 of file macros.h.

#define BALL_INT_ODD (   x)    (((x) & 0x1) == 1)

Definition at line 31 of file macros.h.

#define BALL_MAX (   a,
 
)    (((a) < (b)) ? (b) : (a))

Definition at line 23 of file macros.h.

#define BALL_MAX3 (   x,
  y,
 
)    ((x) > (y) ? BALL_MAX(x, z) : BALL_MAX(y, z))

Definition at line 24 of file macros.h.

#define BALL_MIN (   a,
 
)    (((a) > (b)) ? (b) : (a))

Definition at line 25 of file macros.h.

#define BALL_MIN3 (   x,
  y,
 
)    ((x) < (y) ? BALL_MIN(x, z) : BALL_MIN(y, z))

Definition at line 26 of file macros.h.

#define BALL_NUMBER_OF_BYTES (   bits)    (((bits) + BALL_CHAR_MASK) >> BALL_CHAR_SHIFT)

Definition at line 56 of file macros.h.

#define BALL_ODD (   x)    (((x) % 2)!=0)

Definition at line 29 of file macros.h.

#define BALL_OFFSET_OF (   struct_name,
  struct_var_name 
)    ((long)&(((struct_name*)0)->struct_var_name))

Definition at line 81 of file macros.h.

#define BALL_REAL_ABS (   x)    fabs(x)

Definition at line 41 of file macros.h.

#define BALL_REAL_CEILING (   x)    (long)((x) < 0 ? (x): ((x) == (long)(x) ? (x) : (x) + 1))

Definition at line 46 of file macros.h.

#define BALL_REAL_EQUAL (   x,
  y,
 
)    (fabs((x) - (y)) <= e)

Definition at line 35 of file macros.h.

#define BALL_REAL_EVEN (   x)    (((x) % 2) == 0)

Definition at line 44 of file macros.h.

#define BALL_REAL_FLOOR (   x)    (long)((x) > 0 ? (x): ((x) == (long)(x) ? (x) : (x) - 1))

Definition at line 45 of file macros.h.

#define BALL_REAL_GREATER (   x,
  y,
 
)    (((x) - (y)) > e)

Definition at line 39 of file macros.h.

#define BALL_REAL_GREATER_OR_EQUAL (   x,
  y,
 
)    (((x) - (y)) >= -e)

Definition at line 40 of file macros.h.

#define BALL_REAL_LESS (   x,
  y,
 
)    (((x) - (y)) < -e)

Definition at line 37 of file macros.h.

#define BALL_REAL_LESS_OR_EQUAL (   x,
  y,
 
)    (((x) - (y)) <= e)

Definition at line 38 of file macros.h.

#define BALL_REAL_NOT_EQUAL (   x,
  y,
 
)    (fabs((x) - (y)) > e)

Definition at line 36 of file macros.h.

#define BALL_REAL_ODD (   x)    (((x) % 2) != 0)

Definition at line 43 of file macros.h.

#define BALL_REAL_ROUND   BALL::Maths::round

Definition at line 34 of file macros.h.

#define BALL_REAL_ROUND_INT (   x)    ((x) > 0 ? (int)(x + 0.5) : -(int)(0.5 - x))

Definition at line 47 of file macros.h.

#define BALL_REAL_SGN (   x)    BALL_SGN(x)

Definition at line 42 of file macros.h.

#define BALL_SGN (   x)    (((x) < 0) ? -1 : ((x) == 0) ? 0 : 1)

Definition at line 28 of file macros.h.

#define BALL_SIZEOF_ARRAY (   a)    (sizeof(a) / sizeof(*(a)))

Definition at line 58 of file macros.h.