Actin  Version 5.5.5
Software for Robotics Simulation and Control
ecMacros.h File Reference

Macros and C-style general functions. More...

#include "ecConstants.h"
#include <ecboost/current_function.hpp>
#include "ecPrint.h"
Include dependency graph for ecMacros.h:

Go to the source code of this file.

Namespaces

 Ec
 Energid common namespace.
 

Macros

#define NULLFILE   "/dev/null"
 
#define Ec_UNUSED(x)   (void)x
 mark variable as unused to avoid compiler warnings
 
#define EcSTRINGIFY(A)   #A
 Convert any macro parameter into a string (including type names).
 
#define EcTRAP()
 traps the process in the debugger
 
#define EC_OVERRIDE   override
 Add wrapper around c++11 override keyword.
 
#define EC_FINAL   final
 Add wrapper around c++11 final keyword.
 
#define WIDTHBYTES(bits)   (((bits) + 31) / 32 * 4)
 
#define EcWRITEBIN(value, stream)   Ec::writeBinary(value, stream)
 
#define EcREADBIN(value, stream)   Ec::readBinary(value, stream)
 
#define EC_STD_MAP_AT(map, key, null)   map.at(key)
 
#define ECXMLOBJECT_CLONE(EcCls)
 Provide a convenience declaration and definition of clone() More...
 
#define ECXMLOBJECT_EQUALITY(EcCls)
 Provide a convenience declaration and definition of equality(const EcXmlObject*) More...
 
#define ECXMLOBJECT_NEWOBJECT(EcCls)
 Provide a convenience declaration and definition of newObject() More...
 
#define ECXML_XMLOBJECTCREATOR(EcCls)
 Provide a convenience declaration and definition of xmlObjectCreator() More...
 
#define ECXML_DECLARE_TOKENS
 
#define ECXML_DEFINE_TOKENS(EcCls, EcClsToken)
 Provide a convenience token definition method. More...
 
#define ECXML_REGISTER_COMPONENT_CREATOR(EcCls)   registerComponentCreator(EcCls::classToken(),EcCls::xmlObjectCreator)
 Convenience macro for registering this class within a container.
 
#define ECDECLARE_BIGFOUR(EcCls)
 
#define ECXMLOBJECT_PUREVIRTUAL(cls)
 
#define ECXMLOBJECT(cls)
 
#define EC_XMLOBJECT_PLUGIN_DECLARE(cls)
 
#define EC_XMLOBJECT_PLUGIN_DEFINE(cls, token)
 
#define EC_XMLOBJECT_PLUGIN_ACCESSORS(cls)
 
#define EcU32FORMATSPECIFIER   "%u"
 define format specifiers
 
#define EC_VXWORKS_DKM_ENTRY_POINT(name)
 Special VxWorks defines.
 

Functions

template<class Type >
void EcDELETE (Type &x)
 
template<class Type >
void EcARRAYDELETE (Type &x)
 
template<class Type >
void EcSWAP (Type &xx, Type &yy)
 
EC_STABLE_FOUNDCORE_DECL void EcSLEEPMS (EcU32 ms)
 
template<typename T >
EcBoolean Ec::writeBinary (const T &value, std::ostream &ofs)
 
template<typename T >
EcBoolean Ec::readBinary (T &value, std::istream &ifs)
 
EC_STABLE_FOUNDCORE_DECL EcBoolean EcMKDIR (const EcString &dirname)
 
EC_STABLE_FOUNDCORE_DECL EcBoolean EcExtractFilename (const EcString &directoryPlusFilename, EcString &filenameOnly)
 
EC_STABLE_FOUNDCORE_DECL EcBoolean EcFILEEXISTS (const EcString &directoryPlusFilename)
 see if a file exists
 
EC_STABLE_FOUNDCORE_DECL EcString EcINT2STRING (int integer, EcU32 radix=10U)
 convert an integer to a string
 
EC_STABLE_FOUNDCORE_DECL EcString EcINT2STRING (long int integer, EcU32 radix=10U)
 convert an integer to a string
 
EC_STABLE_FOUNDCORE_DECL EcString EcINT2STRING (long long int integer, EcU32 radix=10U)
 convert an integer to a string
 
EC_STABLE_FOUNDCORE_DECL EcString EcINT2STRING (unsigned integer, EcU32 radix=10U)
 convert an integer to a string
 
EC_STABLE_FOUNDCORE_DECL EcString EcINT2STRING (unsigned long integer, EcU32 radix=10U)
 convert an integer to a string
 
EC_STABLE_FOUNDCORE_DECL EcString EcINT2STRING (unsigned long long integer, EcU32 radix=10U)
 convert an integer to a string
 
EC_STABLE_FOUNDCORE_DECL EcString EcDOUBLE2STRING (const EcReal value)
 convert a double to a string
 
EC_STABLE_FOUNDCORE_DECL EcReal EcSTRING2DOUBLE (const EcString &valueString)
 Convert a string to a double.
 
EC_STABLE_FOUNDCORE_DECL EcWString EcSTRING2WSTRING (const EcString &str)
 Convert a string to a wide string.
 

Detailed Description

Macros and C-style general functions.

Definition in file ecMacros.h.

Macro Definition Documentation

#define EC_XMLOBJECT_PLUGIN_ACCESSORS (   cls)
Value:
extern "C" EC_DECL_EXPORTS const EcToken* getClassToken(EcU16); \
extern "C" EC_DECL_EXPORTS EcXmlObjectCreator getCreator(EcU16); \
const EcToken* getClassToken \
( \
EcU16 index \
) \
{ \
static const EcToken emptyString; \
return index == 0 ? &cls::classToken() : &emptyString; \
} \
EcXmlObjectCreator getCreator \
( \
EcU16 index \
) \
{ \
return index == 0 ? cls::xmlObjectCreator : 0; \
} \
ecboost::uint16_t EcU16
16-bit unsigned integer
Definition: ecTypes.h:47
EcXmlObject *(* EcXmlObjectCreator)()
type definition of an expression element creator function
Definition: ecXmlObject.h:134
#define EC_DECL_EXPORTS
exports storage-class modifier
Definition: ecConfig.h:90
An EcString-like class that holds a tag and a namespace.
Definition: ecToken.h:41

XML object class token and creator method accessors for the dynamic link library loading mechanism. This macro can be used to define accessors for an xml object plugin class if it is the only one in the project It should appear in the .cpp file for the xmlobject plugin class.

Parameters
clsClass name of the xml object plugin

Definition at line 367 of file ecMacros.h.

#define EC_XMLOBJECT_PLUGIN_DECLARE (   cls)
Value:
public: \
protected: \
virtual EcXmlObject* libraryAttribute() EC_OVERRIDE; \
EcXmlString m_LibraryAttribute; \
#define ECXML_XMLOBJECTCREATOR(EcCls)
Provide a convenience declaration and definition of xmlObjectCreator()
Definition: ecMacros.h:279
#define EC_OVERRIDE
Add wrapper around c++11 override keyword.
Definition: ecMacros.h:40
A base class for xml objects.
Definition: ecXmlObject.h:23
#define ECXMLOBJECT(cls)
Definition: ecMacros.h:334

XML object plugin definitions to enable the dynamic link library loading mechanism. This macro needs to appear in the .h file for the xmlobject plugin class.

Parameters
clsClass name of the xml object plugin
Examples:
ecCirclePathExampleDirection.cpp, ecCirclePathExampleDirectionEditor.cpp, ecTimedWaitExampleDirection.cpp, and ecTimedWaitExampleDirectionEditor.cpp.

Definition at line 344 of file ecMacros.h.

#define EC_XMLOBJECT_PLUGIN_DEFINE (   cls,
  token 
)
Value:
ECXML_DEFINE_TOKENS(cls, token) \
EcXmlObject* cls::libraryAttribute() \
{\
m_LibraryAttribute = EC_CMAKE_DEF_PLUGIN_LIBRARY_NAME; \
return &m_LibraryAttribute;\
}\
#define ECXML_DEFINE_TOKENS(EcCls, EcClsToken)
Provide a convenience token definition method.
Definition: ecMacros.h:296

XML object methods and symbols for the dynamic link library loading mechanism. This macro needs to appear in the .cpp file for the xmlobject plugin class.

Parameters
clsClass name of the xml object plugin
Examples:
ecCirclePathExampleDirection.cpp, ecCirclePathExampleDirectionEditor.cpp, ecCustomTypeLink.cpp, ecTimedWaitExampleDirection.cpp, and ecTimedWaitExampleDirectionEditor.cpp.

Definition at line 355 of file ecMacros.h.

#define ECDECLARE_BIGFOUR (   EcCls)
Value:
EcCls(); \
virtual ~EcCls(); \
EcCls(const EcCls&); \
EcCls& operator=(const EcCls&); \
EcBoolean operator==(const EcCls&) const
EcBoolean EC_STABLE_XML_DECL operator==(const EcString &left, const EcToken &right)
overload of operator== to compare EcString with EcToken
Definition: ecToken.h:244
bool EcBoolean
Boolean (0 or 1)
Definition: ecTypes.h:21

Convenience macro for declaring the 'Big Four'. Actually it is 'Big Five'. This macro declares a constructor, destructor, copy constructor, equal operator, and equality operator The copy constructor and equal operator execute a deep copy unless otherwise noted in the header file of the class.

Definition at line 312 of file ecMacros.h.

#define ECXML_DECLARE_TOKENS
Value:
virtual const EcToken& token() const EC_OVERRIDE \
{ \
return classToken(); \
} \
static const EcToken& classToken()
#define EC_OVERRIDE
Add wrapper around c++11 override keyword.
Definition: ecMacros.h:40
An EcString-like class that holds a tag and a namespace.
Definition: ecToken.h:41

Provide a convenience declaration and definition of token() and classToken() This macro is split into two sections to keep from having to include the class tokens header file in the header.

Definition at line 288 of file ecMacros.h.

#define ECXML_DEFINE_TOKENS (   EcCls,
  EcClsToken 
)
Value:
const EcToken& EcCls::classToken() \
{ \
return EcClsToken; \
}
An EcString-like class that holds a tag and a namespace.
Definition: ecToken.h:41

Provide a convenience token definition method.

Definition at line 296 of file ecMacros.h.

#define ECXML_XMLOBJECTCREATOR (   EcCls)
Value:
static EcXmlObject* xmlObjectCreator() \
{ \
return new EcCls(); \
}
A base class for xml objects.
Definition: ecXmlObject.h:23

Provide a convenience declaration and definition of xmlObjectCreator()

Definition at line 279 of file ecMacros.h.

#define ECXMLOBJECT (   cls)
Value:
#define ECXMLOBJECT_CLONE(EcCls)
Provide a convenience declaration and definition of clone()
Definition: ecMacros.h:252
#define ECDECLARE_BIGFOUR(EcCls)
Definition: ecMacros.h:312
#define ECXMLOBJECT_EQUALITY(EcCls)
Provide a convenience declaration and definition of equality(const EcXmlObject*)
Definition: ecMacros.h:259
#define ECXMLOBJECT_NEWOBJECT(EcCls)
Provide a convenience declaration and definition of newObject()
Definition: ecMacros.h:272
#define ECXML_DECLARE_TOKENS
Definition: ecMacros.h:288

Convenience macro for declaring methods required to make a derived EcXmlObject concrete by calling the following macros in order: ECDECLARE_BIGFOUR(EcCls), ECXMLOBJECT_CLONE(EcCls), ECXMLOBJECT_EQUALITY(EcCls), ECXMLOBJECT_NEWOBJECT(EcCls), and ECXML_DECLARE_TOKENS

Definition at line 334 of file ecMacros.h.

#define ECXMLOBJECT_CLONE (   EcCls)
Value:
virtual EcXmlObject* clone() const EC_OVERRIDE\
{ \
return new EcCls(*this); \
}
#define EC_OVERRIDE
Add wrapper around c++11 override keyword.
Definition: ecMacros.h:40
A base class for xml objects.
Definition: ecXmlObject.h:23

Provide a convenience declaration and definition of clone()

Definition at line 252 of file ecMacros.h.

#define ECXMLOBJECT_EQUALITY (   EcCls)
Value:
virtual EcBoolean equality(const EcXmlObject* other) const EC_OVERRIDE\
{ \
EcBoolean retVal=EcTrue; \
const EcCls* cast = dynamic_cast<const EcCls*>(other); \
if(!cast || !(*this==*cast)) \
{ \
retVal=EcFalse; \
} \
return retVal; \
}
#define EC_OVERRIDE
Add wrapper around c++11 override keyword.
Definition: ecMacros.h:40
const EcBoolean EcTrue
gives a representation of true
Definition: ecConstants.h:19
A base class for xml objects.
Definition: ecXmlObject.h:23
bool EcBoolean
Boolean (0 or 1)
Definition: ecTypes.h:21
const EcBoolean EcFalse
gives a representation of false
Definition: ecConstants.h:22

Provide a convenience declaration and definition of equality(const EcXmlObject*)

Definition at line 259 of file ecMacros.h.

#define ECXMLOBJECT_NEWOBJECT (   EcCls)
Value:
virtual EcXmlObject* newObject() const EC_OVERRIDE \
{ \
return new EcCls(); \
}
#define EC_OVERRIDE
Add wrapper around c++11 override keyword.
Definition: ecMacros.h:40
A base class for xml objects.
Definition: ecXmlObject.h:23

Provide a convenience declaration and definition of newObject()

Definition at line 272 of file ecMacros.h.

#define ECXMLOBJECT_PUREVIRTUAL (   cls)
Value:
#define ECDECLARE_BIGFOUR(EcCls)
Definition: ecMacros.h:312
#define ECXMLOBJECT_EQUALITY(EcCls)
Provide a convenience declaration and definition of equality(const EcXmlObject*)
Definition: ecMacros.h:259

Convenience macro for declaring methods required to make a derived EcXmlObject pure virtual class by calling the following macros in order: ECDECLARE_BIGFOUR(EcCls) and ECXMLOBJECT_EQUALITY(EcCls)

Definition at line 324 of file ecMacros.h.

#define WIDTHBYTES (   bits)    (((bits) + 31) / 32 * 4)

used for DWORD alignment

Parameters
bitsinteger number of bits

Definition at line 111 of file ecMacros.h.

Function Documentation

template<class Type >
void EcARRAYDELETE ( Type &  x)
inline

array deletes the object at the pointer and sets the pointer to zero.

Template Parameters
Type
Parameters
x

Definition at line 74 of file ecMacros.h.

References EcSWAP().

Referenced by EcDELETE().

template<class Type >
void EcDELETE ( Type &  x)
inline

deletes the object at the pointer and sets the pointer to zero.

Template Parameters
Type
Parameters
x
Examples:
ecCollisionAvoidanceExample.cpp.

Definition at line 55 of file ecMacros.h.

References EcARRAYDELETE().

EC_STABLE_FOUNDCORE_DECL EcBoolean EcExtractFilename ( const EcString directoryPlusFilename,
EcString filenameOnly 
)

extract just a filename from a path plus filename

Parameters
[in]directoryPlusFilenamethe full path to the file
[in,out]filenameOnlythe file name
Returns
Return true if the file name was extracted

Referenced by Ec::readBinary().

EC_STABLE_FOUNDCORE_DECL EcBoolean EcMKDIR ( const EcString dirname)

make a directory.

Parameters
dirnamethe directory name
Returns
Returns true for success
Examples:
ecProgrammaticConstructionMain.cpp.

Referenced by Ec::readBinary().

EC_STABLE_FOUNDCORE_DECL void EcSLEEPMS ( EcU32  ms)

sleep, in integer milleseconds

Parameters
mstime in milleseconds
Examples:
ecCollisionAvoidanceExample.cpp.

Referenced by EcSWAP().

template<class Type >
void EcSWAP ( Type &  xx,
Type &  yy 
)
inline

swap any type

Template Parameters
Type
Parameters
xx
yy

Definition at line 92 of file ecMacros.h.

References EC_STABLE_FOUNDCORE_DECL, and EcSLEEPMS().

Referenced by EcARRAYDELETE(), and EcMath::sortDescending().