ALBA
Macros | Typedefs | Functions | Variables
albaDefines.h File Reference
#include "albaConfigure.h"
#include "albaIncludeWX.h"
#include <string.h>
#include <typeinfo>
#include <iosfwd>
#include <sstream>
Include dependency graph for albaDefines.h:

Go to the source code of this file.

Macros

#define MIN(x, y)   ( (x) < (y) ? (x) : (y) )
 
#define MAX(x, y)   ( (x) > (y) ? (x) : (y) )
 
#define round(x)   (x<0?ceil((x)-0.5):floor((x)+0.5))
 
#define ID_NO_EVENT   0
 
#define ALBA_STRING_BUFFER_SIZE   2048
 
#define vtkDEL(a)   do{if (a) { a->Delete(); a = NULL; }}while(0)
 
#define vtkNEW(a)   a=a->New()
 
#define albaNEW(a)   do{a=a->New();a->Register(this);}while(0)
 
#define albaDEL(a)   do{if (a) { a->Delete(); a = NULL;}}while(0)
 
#define cppDEL(a)   do{if (a) { delete a; a = NULL;}}while(0)
 
#define albaAbstractTypeMacro(thisClass, superclass)
 
#define albaTypeMacro(thisClass, superclass)
 
#define albaCxxAbstractTypeMacro(thisClass)
 
#define albaCxxTypeMacro(thisClass)
 
#define IsALBAType(type_name)   IsA(type_name::GetStaticTypeId())
 
#define ALBA_ID_IMP(idname)   const albaID idname = mmuIdFactory::GetNextId(#idname);
 
#define ALBA_ID_DEC(idname)   static const albaID idname;
 
#define ALBA_ID_GLOBAL(idname)   extern const albaID idname;
 
#define ALBA_ID_CLASS_DEC(baseClass)   static const albaID BaseID;
 
#define ALBA_ID_CLASS_IMP(baseClass, num)   const albaID baseClass::BaseID = mmuIdFactory::AllocIdGroup("#baseClass::BaseID",num);
 
#define ALBA_ID_LOC(name, idname)   static const albaID name=mmuIdFactory::GetId(#idname);
 
#define albaGetEventClassId(event, baseClass)   (event->GetID()-baseClass::BaseID)
 
#define albaGetEventGroupId(event, baseID)   (event->GetID()-baseID)
 
#define albaEvalGroupId(baseClass, id)   (baseClass::BaseID+id)
 
#define albaEventMacro(e)   if (m_Listener) {m_Listener->OnEvent(&e);}
 
#define ALBA_TEST(a)
 
#define albaWarningMacro(x)
 
#define albaErrorMacro(x)
 
#define albaWarningMessageMacro(x)
 
#define albaErrorMessageMacro(x)
 
#define albaMessageMacro(x)
 
#define ALBA_PRINT_MACRO(format, buffer, size)
 

Typedefs

typedef double albaTimeStamp
 
typedef long albaID
 
typedef std::type_info albaTypeID
 

Functions

ALBA_EXPORT void albaLogMessage (const char *format,...)
 
ALBA_EXPORT void albaWarningMessage (const char *format,...)
 
ALBA_EXPORT void albaErrorMessage (const char *format,...)
 
ALBA_EXPORT void albaMessage (const char *format,...)
 
ALBA_EXPORT bool albaEquals (double x, double y)
 
ALBA_EXPORT bool albaFloatEquals (float x, float y)
 
ALBA_EXPORT double albaRoundToPrecision (double val, unsigned prec)
 
ALBA_EXPORT bool albaIsLittleEndian (void)
 
ALBA_EXPORT void albaSleep (int msec)
 

Variables

enum ALBA_EXPORT ALBA_RETURN_VALUES_ID
 
 ALBA_OK = 0
 
 ALBA_ERROR
 
 ALBA_WAIT
 

Macro Definition Documentation

◆ MIN

#define MIN (   x,
 
)    ( (x) < (y) ? (x) : (y) )

Standard macros and constants for the ALBA library.

This file include all the standard macros and constants used inside the ALBA library.

Definition at line 45 of file albaDefines.h.

◆ MAX

#define MAX (   x,
 
)    ( (x) > (y) ? (x) : (y) )

Definition at line 48 of file albaDefines.h.

◆ round

#define round (   x)    (x<0?ceil((x)-0.5):floor((x)+0.5))

Definition at line 51 of file albaDefines.h.

◆ ID_NO_EVENT

#define ID_NO_EVENT   0

Definition at line 71 of file albaDefines.h.

◆ ALBA_STRING_BUFFER_SIZE

#define ALBA_STRING_BUFFER_SIZE   2048

Definition at line 77 of file albaDefines.h.

◆ vtkDEL

#define vtkDEL (   a)    do{if (a) { a->Delete(); a = NULL; }}while(0)

Delete a VTK object.

Definition at line 119 of file albaDefines.h.

◆ vtkNEW

#define vtkNEW (   a)    a=a->New()

Allocate a new VTK object: don't worry, New is a static member function!

Definition at line 122 of file albaDefines.h.

◆ albaNEW

#define albaNEW (   a)    do{a=a->New();a->Register(this);}while(0)

Allocate a new ALBA object: don't worry, New is a static member function!

Definition at line 125 of file albaDefines.h.

◆ albaDEL

#define albaDEL (   a)    do{if (a) { a->Delete(); a = NULL;}}while(0)

Delete a ALBA object.

Definition at line 128 of file albaDefines.h.

◆ cppDEL

#define cppDEL (   a)    do{if (a) { delete a; a = NULL;}}while(0)

delete a new() allocated object

Definition at line 131 of file albaDefines.h.

◆ albaAbstractTypeMacro

#define albaAbstractTypeMacro (   thisClass,
  superclass 
)
Value:
public: \ \
typedef superclass Superclass; \ \
static const albaTypeID &GetStaticTypeId(); \ \
virtual const albaTypeID &GetTypeId() const; \ \
static const char *GetStaticTypeName(); \ \
virtual const char *GetTypeName() const; \ \
static bool IsStaticType(const char *type); \ \
static bool IsStaticType(const albaTypeID &type); \ \
virtual bool IsA(const char *type) const; \ \
virtual bool IsA(const albaTypeID &type) const; \ \
static thisClass* SafeDownCast(albaObject *o);
std::type_info albaTypeID
type for albaObject's class type IDs
Definition: albaDefines.h:59
Abstract superclass for all ALBA classes implementing RTTI APIs.
Definition: albaObject.h:38

Macro used by albaObjects for RTTI information.

This macro must be placed in the class definition public section.

Definition at line 136 of file albaDefines.h.

◆ albaTypeMacro

#define albaTypeMacro (   thisClass,
  superclass 
)
Value:
albaAbstractTypeMacro(thisClass,superclass); \ \
static albaObject *NewObject(); \ \
virtual albaObject *NewObjectInstance() const; \ \
thisClass *NewInstance() const; \ \
static thisClass *New();
#define albaAbstractTypeMacro(thisClass, superclass)
Macro used by albaObjects for RTTI information.
Definition: albaDefines.h:136

Macro used by albaObjects for RTTI information.

This macro must be placed in the class definition public section.

Definition at line 162 of file albaDefines.h.

◆ albaCxxAbstractTypeMacro

#define albaCxxAbstractTypeMacro (   thisClass)
Value:
const albaTypeID &thisClass::GetStaticTypeId() {return typeid(thisClass);} \
const albaTypeID &thisClass::GetTypeId() const {return typeid(thisClass);} \
const char *thisClass::GetStaticTypeName() {return #thisClass;} \
const char *thisClass::GetTypeName() const {return #thisClass;} \
bool thisClass::IsStaticType(const char *type) \
{ return ( strcmp(#thisClass,type)==0 ) ? true : Superclass::IsStaticType(type); } \
bool thisClass::IsStaticType(const albaTypeID &type) \
{ return ( type==typeid(thisClass) ? true : Superclass::IsStaticType(type) ); } \
bool thisClass::IsA(const char *type) const {return IsStaticType(type);} \
bool thisClass::IsA(const albaTypeID &type) const {return IsStaticType(type);} \
thisClass* thisClass::SafeDownCast(albaObject *o) \
{ try { return dynamic_cast<thisClass *>(o); } catch (std::bad_cast) { return NULL;} }

Macro used by albaObjects for RTTI information.

This macor must be placed in the .cpp file.

Definition at line 176 of file albaDefines.h.

◆ albaCxxTypeMacro

#define albaCxxTypeMacro (   thisClass)
Value:
albaObject *thisClass::NewObject() \
{ \
thisClass *obj = new thisClass; \
if (obj) obj->m_HeapFlag=true; \
return obj; \
} \
albaObject *thisClass::NewObjectInstance() const \
{ return NewObject(); } \
thisClass *thisClass::New() \
{ return (thisClass *)NewObject(); } \
thisClass *thisClass::NewInstance() const \
{ return (thisClass *)NewObjectInstance(); }
#define albaCxxAbstractTypeMacro(thisClass)
Macro used by albaObjects for RTTI information.
Definition: albaDefines.h:176
bool m_HeapFlag
Internally used to mark objects created on the Heap with New()
Definition: albaObject.h:90

Macro used by albaObjects for RTTI information.

This macro must be placed in the .cpp file.

Definition at line 193 of file albaDefines.h.

◆ IsALBAType

#define IsALBAType (   type_name)    IsA(type_name::GetStaticTypeId())

Shortcut for type checking.

Definition at line 209 of file albaDefines.h.

◆ ALBA_ID_IMP

#define ALBA_ID_IMP (   idname)    const albaID idname = mmuIdFactory::GetNextId(#idname);

This macros is used to declare a new Id and should be placed in a .h file.

Definition at line 212 of file albaDefines.h.

◆ ALBA_ID_DEC

#define ALBA_ID_DEC (   idname)    static const albaID idname;

This macros is used to define a new Id and should be placed in a .cpp file.

Definition at line 214 of file albaDefines.h.

◆ ALBA_ID_GLOBAL

#define ALBA_ID_GLOBAL (   idname)    extern const albaID idname;

This macros is used to declare a new global Id and should be placed in a .h file.

Definition at line 216 of file albaDefines.h.

◆ ALBA_ID_CLASS_DEC

#define ALBA_ID_CLASS_DEC (   baseClass)    static const albaID BaseID;

This macro is used to define a group of IDs and should be placed in a .h file.

Ids declaration with ALBA_ID_DEC. This macro is used to declare the base ID of a group of ids.

Definition at line 223 of file albaDefines.h.

◆ ALBA_ID_CLASS_IMP

#define ALBA_ID_CLASS_IMP (   baseClass,
  num 
)    const albaID baseClass::BaseID = mmuIdFactory::AllocIdGroup("#baseClass::BaseID",num);

This macro is used to define the base ID of a group of ids.

Definition at line 225 of file albaDefines.h.

◆ ALBA_ID_LOC

#define ALBA_ID_LOC (   name,
  idname 
)    static const albaID name=mmuIdFactory::GetId(#idname);

Definition at line 227 of file albaDefines.h.

◆ albaGetEventClassId

#define albaGetEventClassId (   event,
  baseClass 
)    (event->GetID()-baseClass::BaseID)

These macros are used to retrieve the base ID of a group of events.

Definition at line 230 of file albaDefines.h.

◆ albaGetEventGroupId

#define albaGetEventGroupId (   event,
  baseID 
)    (event->GetID()-baseID)

Definition at line 231 of file albaDefines.h.

◆ albaEvalGroupId

#define albaEvalGroupId (   baseClass,
  id 
)    (baseClass::BaseID+id)

Definition at line 232 of file albaDefines.h.

◆ albaEventMacro

#define albaEventMacro (   e)    if (m_Listener) {m_Listener->OnEvent(&e);}

albaEventMacro is an handy shortcut to send an Event.

Definition at line 235 of file albaDefines.h.

◆ ALBA_TEST

#define ALBA_TEST (   a)
Value:
if (!(a)) \
{ \
std::cerr << "Test failed at line " \
<< __LINE__ << " : " << #a << std::endl; \
return ALBA_ERROR; \
}
ALBA_ERROR
Definition: albaDefines.h:67

Helper macro used for testing.

Definition at line 238 of file albaDefines.h.

◆ albaWarningMacro

#define albaWarningMacro (   x)
Value:
{ \
std::stringstream msg; \
msg << "Warning in: " __FILE__ ", line " << __LINE__ << "\n" x \
<< "\n"; \
albaLogMessage(msg.str().c_str());\
}

Macro for printing Warning messages in log area.

This macro also displays line at which error was printed.

Definition at line 248 of file albaDefines.h.

◆ albaErrorMacro

#define albaErrorMacro (   x)
Value:
{ \
std::stringstream msg; \
msg << "Error in: " __FILE__ ", line " << __LINE__ << "\n" x \
<< "\n"; \
albaLogMessage(msg.str().c_str());\
}

Macro for printing Error messages in log area.

This macro also displays line at which error was printed.

Definition at line 259 of file albaDefines.h.

◆ albaWarningMessageMacro

#define albaWarningMessageMacro (   x)
Value:
{ \
std::stringstream msg; \
msg << x << "\n"; \
albaWarningMessage(msg.str().c_str());\
}

Macro for displaying Warning messages.

Definition at line 269 of file albaDefines.h.

◆ albaErrorMessageMacro

#define albaErrorMessageMacro (   x)
Value:
{ \
std::stringstream msg; \
msg << x << "\n"; \
albaErrorMessage(msg.str().c_str());\
}

Macro for displaying Error messages.

Definition at line 278 of file albaDefines.h.

◆ albaMessageMacro

#define albaMessageMacro (   x)
Value:
{ \
std::stringstream msg; \
msg << x << "\n"; \
albaMessage(msg.str().c_str());\
}

Macro for displaying messages.

Definition at line 287 of file albaDefines.h.

◆ ALBA_PRINT_MACRO

#define ALBA_PRINT_MACRO (   format,
  buffer,
  size 
)
Value:
va_list argptr; \
va_start(argptr, format); \
vsnprintf(buffer,(const size_t)size, format, argptr); \
va_end(argptr);

Macro for formatted printing to string (adapted from wxWidgets IMPLEMENT_LOG_FUNCTION) To use it you will need to include <stdio.h>, <stdarg.h> and <varargs.h> This is less safe since it can't limit output string size.

Definition at line 298 of file albaDefines.h.

Typedef Documentation

◆ albaTimeStamp

typedef double albaTimeStamp

type for time varying data timestamps (not for pipelines timestamps!)

Definition at line 57 of file albaDefines.h.

◆ albaID

typedef long albaID

type for IDs inside ALBA

Todo:
to be changed to support 64bit IDs

Definition at line 58 of file albaDefines.h.

◆ albaTypeID

typedef std::type_info albaTypeID

type for albaObject's class type IDs

Definition at line 59 of file albaDefines.h.

Function Documentation

◆ albaLogMessage()

ALBA_EXPORT void albaLogMessage ( const char *  format,
  ... 
)

write a message in the log area

Referenced by albaGizmoSlice::SetModalityToGlobal().

◆ albaWarningMessage()

ALBA_EXPORT void albaWarningMessage ( const char *  format,
  ... 
)

open a warning dialog and write a message

◆ albaErrorMessage()

ALBA_EXPORT void albaErrorMessage ( const char *  format,
  ... 
)

open an error dialog and write a message

◆ albaMessage()

ALBA_EXPORT void albaMessage ( const char *  format,
  ... 
)

open a message dialog and write a message

◆ albaEquals()

ALBA_EXPORT bool albaEquals ( double  x,
double  y 
)

reliable comparison test for floating point numbers.

Extracted from article: "Work Around Floating-Point Accuracy/Comparison Problems" Article ID: Q69333 of MSDN library

Referenced by albaMatrix::SetTimeStamp(), and albaTransformBase::SetTimeStamp().

◆ albaFloatEquals()

ALBA_EXPORT bool albaFloatEquals ( float  x,
float  y 
)

◆ albaRoundToPrecision()

ALBA_EXPORT double albaRoundToPrecision ( double  val,
unsigned  prec 
)

retrieve the double value with the desired precision

◆ albaIsLittleEndian()

ALBA_EXPORT bool albaIsLittleEndian ( void  )

return true if it's little endian

◆ albaSleep()

ALBA_EXPORT void albaSleep ( int  msec)

wait for given milliseconds

Variable Documentation

◆ ALBA_RETURN_VALUES_ID

enum ALBA_EXPORT ALBA_RETURN_VALUES_ID

Definition at line 64 of file albaDefines.h.

◆ ALBA_OK

ALBA_OK = 0

◆ ALBA_ERROR

ALBA_ERROR

◆ ALBA_WAIT

ALBA_WAIT

Definition at line 68 of file albaDefines.h.