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

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

#include "ecConstants.h"
#include <boost/current_function.hpp>
#include "ecPrint.h"

Go to the source code of this file.

Namespaces

 Ec
 Energid common namespace.
 

Macros

#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 WIDTHBYTES(bits)   (((bits) + 31) / 32 * 4)
 
#define EcWRITEBIN(value, stream)   Ec::writeBinary(value, stream)
 
#define EcREADBIN(value, stream)   Ec::readBinary(value, stream)
 
#define EcPRINTA(type, ...)   Ec::Print::instance().write(type, __VA_ARGS__)
 General print statement. Always available. More...
 
#define EcPRINT(...)   EcPRINTA(Ec::Print::PrintNone, __VA_ARGS__)
 EcPRINT - General print statement. Always available.
 
#define EcFATAL(...)   EcPRINTA(Ec::Print::PrintFatal, __VA_ARGS__)
 EcFATAL - Fatal message. Display and exit.
 
#define EcERROR(...)   EcPRINTA(Ec::Print::PrintError, __VA_ARGS__)
 EcERROR - Error message. Display and exit.
 
#define EcWARN(...)   EcPRINTA(Ec::Print::PrintWarning, __VA_ARGS__)
 EcWARN - Warning message. Display and continue.
 
#define EcINFO(...)
 EcINFO - Informational message. On with _DEBUG.
 
#define EcTRACE(...)
 EcTRACE - Verbose messaging. On with _DEBUG.
 
#define EcCurrentFunction   BOOST_CURRENT_FUNCTION
 boost current function
 
#define EcPrint(x)   Ec::Print::instance().ostream(Ec::Print::Print##x, EcCurrentFunction)
 Provide a convenient, C++ stream style method of printing.
 
#define EC_IF_PRINT_LEVEL(lvl)   if(Ec::Print::lvl >= Ec::Print::instance().printLevel())
 If statement to detect print level.
 
#define EC_ADD_PRINT_HANDLE(x)   Ec::Print::instance().addStreamHandle(&x)
 Adds a print stream handle.
 
#define EC_REMOVE_PRINT_HANDLE(x)   Ec::Print::instance().removeStreamHandle(&x)
 Removes a print stream handle.
 
#define EcENTRYCOUNT   Ec::Print::ScopedPrint::getCount()
 Get the entry count: More...
 
#define EcENTRYFUNC   Ec::Print::ScopedPrint::getFunc()
 Get the current function name: More...
 
#define EcENTRYEXIT(msg)   Ec::Print::ScopedPrint _Ecee(EcCurrentFunction, msg)
 Set an entry exit message.
 
#define EcOPENOUTPUTFILE(fn)   Ec::Print::instance().setOutputFile(fn)
 open the ouput file
 
#define EcCLOSEOUTPUTFILE()
 close the ouput file. No-op
 
#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; \
} \
EcXmlObject *(* EcXmlObjectCreator)()
type definition of an expression element creator function
Definition: ecXmlObject.h:132
#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
boost::uint16_t EcU16
16-bit unsigned integer
Definition: ecTypes.h:47

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 453 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:365
#define EC_OVERRIDE
Add wrapper around c++11 override keyword.
Definition: ecMacros.h:36
A base class for xml objects.
Definition: ecXmlObject.h:23
#define ECXMLOBJECT(cls)
Definition: ecMacros.h:420

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, ecExampleIoModule.cpp, ecTimedWaitExampleDirection.cpp, and ecTimedWaitExampleDirectionEditor.cpp.

Definition at line 430 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:382

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, ecExampleIoModule.cpp, ecTimedWaitExampleDirection.cpp, and ecTimedWaitExampleDirectionEditor.cpp.

Definition at line 441 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 398 of file ecMacros.h.

#define EcENTRYCOUNT   Ec::Print::ScopedPrint::getCount()

Get the entry count:

Returns the 'depth' of tracing

Returns
EcSizeT Number of levels - used for print indentation.

Definition at line 211 of file ecMacros.h.

#define EcENTRYFUNC   Ec::Print::ScopedPrint::getFunc()

Get the current function name:

Retrieves the name of the current function.

Returns
const char* const Function name

Definition at line 214 of file ecMacros.h.

#define EcPRINTA (   type,
  ... 
)    Ec::Print::instance().write(type, __VA_ARGS__)

General print statement. Always available.

Macros to determine what messages get printed. Macros are used to remove the overhead of calling an empty function when not enabled. In addition, the 'EcSetEntryExit(EcBoolean)' routine can be used at runtime in Debug mode to turn scope-level tracing on or off. It has no effect in Release mode.

Definition at line 145 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:36
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 374 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 382 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 365 of file ecMacros.h.

#define ECXMLOBJECT (   cls)
Value:
#define ECXMLOBJECT_CLONE(EcCls)
Provide a convenience declaration and definition of clone()
Definition: ecMacros.h:338
#define ECDECLARE_BIGFOUR(EcCls)
Definition: ecMacros.h:398
#define ECXMLOBJECT_EQUALITY(EcCls)
Provide a convenience declaration and definition of equality(const EcXmlObject*)
Definition: ecMacros.h:345
#define ECXMLOBJECT_NEWOBJECT(EcCls)
Provide a convenience declaration and definition of newObject()
Definition: ecMacros.h:358
#define ECXML_DECLARE_TOKENS
Definition: ecMacros.h:374

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 420 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:36
A base class for xml objects.
Definition: ecXmlObject.h:23

Provide a convenience declaration and definition of clone()

Definition at line 338 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:36
const EcBoolean EcTrue
gives a representation of true
Definition: ecConstants.h:23
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:26

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

Definition at line 345 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:36
A base class for xml objects.
Definition: ecXmlObject.h:23

Provide a convenience declaration and definition of newObject()

Definition at line 358 of file ecMacros.h.

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

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 410 of file ecMacros.h.

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

used for DWORD alignment

Parameters
bitsinteger number of bits

Definition at line 100 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 63 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:
ecXmlMain.cpp.

Definition at line 44 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
EC_STABLE_FOUNDCORE_DECL EcBoolean EcMKDIR ( const EcString dirname)

make a directory.

Parameters
dirnamethe directory name
Returns
Returns true for success
Examples:
ecProgrammaticConstructionMain.cpp.
EC_STABLE_FOUNDCORE_DECL void EcSLEEPMS ( EcU32  ms)

sleep, in integer milleseconds

Parameters
mstime in milleseconds
Examples:
ecPositionControlMain.cpp, ecProfilingMain.cpp, ecQuickStartMain.cpp, ecRemoteCommandExampleMain.cpp, ecStatedSystemMain.cpp, and ecVelocityControlMain.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 81 of file ecMacros.h.

References EC_STABLE_FOUNDCORE_DECL, and EcSLEEPMS().

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

Created by Energid Technologies www.energid.com
Copyright © 2016 Energid. All trademarks mentioned in this document are property of their respective owners.