ALBA
Macros | Typedefs | Functions | Variables
albaDefines.h File Reference
#include <mutex>
#include <string.h>
#include <typeinfo>
#include <iosfwd>
#include <sstream>
#include "albaConfigure.h"
#include "albaIncludeWX.h"
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 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,
  y 
)    ( (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 48 of file albaDefines.h.

◆ MAX

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

Definition at line 51 of file albaDefines.h.

◆ round

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

Definition at line 54 of file albaDefines.h.

◆ ID_NO_EVENT

#define ID_NO_EVENT   0

Definition at line 74 of file albaDefines.h.

◆ ALBA_STRING_BUFFER_SIZE

#define ALBA_STRING_BUFFER_SIZE   2048

Definition at line 80 of file albaDefines.h.

◆ vtkDEL

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

Delete a VTK object.

Definition at line 122 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 125 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 128 of file albaDefines.h.

◆ albaDEL

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

Delete a ALBA object.

Definition at line 131 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 134 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:62
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 139 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:139

Macro used by albaObjects for RTTI information.

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

Definition at line 165 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 179 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:179
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 196 of file albaDefines.h.

◆ IsALBAType

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

Shortcut for type checking.

Definition at line 212 of file albaDefines.h.

◆ albaEventMacro

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

The ids of the events are static: add them to MAIN_EVENT_ID in albaDecl.h.

Use mmuIdFactory only for ids that are really dynamic, see its comment. albaEventMacro is an handy shortcut to send an Event.

Definition at line 218 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:70

Helper macro used for testing.

Definition at line 221 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 231 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 242 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 252 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 261 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 270 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 281 of file albaDefines.h.

Typedef Documentation

◆ albaTimeStamp

typedef double albaTimeStamp

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

Definition at line 60 of file albaDefines.h.

◆ albaID

typedef long albaID

type for IDs inside ALBA

Todo:
to be changed to support 64bit IDs

Definition at line 61 of file albaDefines.h.

◆ albaTypeID

typedef std::type_info albaTypeID

type for albaObject's class type IDs

Definition at line 62 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 67 of file albaDefines.h.

◆ ALBA_OK

ALBA_OK = 0

◆ ALBA_ERROR

ALBA_ERROR

Definition at line 70 of file albaDefines.h.

Referenced by albaTimeMap< T >::RemoveItem().

◆ ALBA_WAIT

ALBA_WAIT

Definition at line 71 of file albaDefines.h.