MOOS 0.2375
Classes | Defines | Typedefs | Functions
/home/toby/moos-ivp/MOOS-2375-Oct0611/Core/MOOSGenLib/MOOSGenLibGlobalHelper.h File Reference
#include <string>
#include <list>
#include <vector>
#include <sstream>
#include <algorithm>
Include dependency graph for MOOSGenLibGlobalHelper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  static_caster< D >
struct  dynamic_caster< D >

Defines

#define PI   3.141592653589
#define MOOSHERE   MOOSFormat("File %s Line %d", __FILE__,__LINE__).c_str()
#define UNUSED_PARAMETER(a)

Typedefs

typedef std::list< std::string > STRING_LIST

Functions

size_t MOOSStrFind (const std::string &sSource, const std::string &sToken, bool bInsensitive=false)
bool MOOSGetValueFromToken (STRING_LIST &sParams, const std::string &sToken, std::string &sVal)
bool MOOSValFromString (std::string &sVal, const std::string &sStr, const std::string &sTk, bool bInsensitive=false)
bool MOOSValFromString (double &dfVal, const std::string &sStr, const std::string &sTk, bool bInsensitive=false)
bool MOOSValFromString (float &fVal, const std::string &sStr, const std::string &sTk, bool bInsensitive=false)
bool MOOSValFromString (long &nVal, const std::string &sStr, const std::string &sTk, bool bInsensitive=false)
bool MOOSValFromString (int &nVal, const std::string &sStr, const std::string &sTk, bool bInsensitive=false)
bool MOOSValFromString (bool &bVal, const std::string &sStr, const std::string &sTk, bool bInsensitive=false)
bool MOOSValFromString (unsigned int &nVal, const std::string &sStr, const std::string &sTk, bool bInsensitive=false)
bool MOOSValFromString (std::vector< double > &dfValVec, int &nRows, int &nCols, const std::string &sStr, const std::string &sToken, bool bInsensitive=false)
bool MOOSValFromString (std::vector< unsigned int > &nValVec, int &nRows, int &nCols, const std::string &sStr, const std::string &sToken, bool bInsensitive=false)
bool MOOSValFromString (long long &nVal, const std::string &sStr, const std::string &sTk, bool bInsensitive=false)
bool MOOSVectorFromString (const std::string &sStr, std::vector< double > &dfVecVal, int &nRows, int &nCols)
bool MOOSVectorFromString (const std::string &sStr, std::vector< float > &fValVec, int &nRows, int &nCols)
bool MOOSVectorFromString (const std::string &sStr, std::vector< unsigned int > &dfVecVal, int &nRows, int &nCols)
bool GetNextAlogLineByMessageName (std::istream &Input, const std::string &sMessageName, double &dfTime, std::string &sSource, std::string &sPayload)
std::string DoubleVector2String (const std::vector< double > &V)
std::stringstream & Write (std::stringstream &os, const std::vector< double > &Vec)
std::stringstream & Write (std::stringstream &os, const std::vector< int > &Vec)
std::string MOOSChomp (std::string &sStr, const std::string &sTk=",", bool bInsensitive=false)
void MOOSRemoveChars (std::string &sStr, const std::string &sTok)
void MOOSToUpper (std::string &str)
void MOOSTrimWhiteSpace (std::string &str)
bool MOOSIsNumeric (std::string str)
bool MOOSStrCmp (std::string s1, std::string s2)
bool MOOSWildCmp (const std::string &sPattern, const std::string &sString)
double GetMOOSSkew ()
void SetMOOSSkew (double dfSkew)
bool SetMOOSTimeWarp (double dfWarp)
double GetMOOSTimeWarp ()
void MOOSPause (int nMS, bool bApplyTimeWarping=true)
double MOOSTime (bool bApplyTimeWarping=true)
bool SetWin32HighPrecisionTiming (bool bEnable)
double HPMOOSTime (bool bApplyTimeWarping=true)
double MOOSLocalTime (bool bApplyTimeWarping=true)
int MOOSGetch ()
void MOOSTrace (std::string Str)
void MOOSTrace (const char *FmtStr,...)
std::string MOOSFormat (const char *FmtStr,...)
void InhibitMOOSTraceInThisThread (bool bInhibit=true)
bool MOOSFail (const char *FmtStr,...)
std::string MOOSGetTimeStampString ()
std::string MOOSGetDate ()
void Progress (double dfPC)
std::string MOOSThirdPartyActuationString (double *pdfRudder, double *pdfElevator, double *pdfThrust)
std::string MOOSThirdPartyStatusString (std::string sStatusCommand)
double MOOS_ANGLE_WRAP (double dfAng)
double MOOSDeg2Rad (double dfDeg)
double MOOSRad2Deg (double dfRad)
bool MOOSAbsLimit (double &dfVal, double dfLimit)
double MOOSWhiteNoise (double Sigma)
double MOOSNormalInv (double dfArea)
int MOOSDiscreteUniform (int nMin, int nMax)
double MOOSUniformRandom (double dfMin, double dfMax)
template<class T >
const T & MOOSClamp (const T &val, const T &min, const T &max)
bool GetDirectoryContents (const std::string &sPath, std::list< std::string > &sContents, bool bFiles=true)
bool MOOSCreateDirectory (const std::string &sDirectory)
bool MOOSFileParts (std::string sFullPath, std::string &sPath, std::string &sFile, std::string &sExtension)
template<class T >
SwapByteOrder (const T &v)
bool IsLittleEndian ()
template<class T >
std::string & MOOSAddValToString (std::string &sIn, const std::string &sTok, const T &Val)

Detailed Description

Definition in file MOOSGenLibGlobalHelper.h.


Define Documentation

#define MOOSHERE   MOOSFormat("File %s Line %d", __FILE__,__LINE__).c_str()

useful macro for debugging prints line and file

Definition at line 184 of file MOOSGenLibGlobalHelper.h.

#define PI   3.141592653589

Definition at line 38 of file MOOSGenLibGlobalHelper.h.

#define UNUSED_PARAMETER (   a)

Definition at line 304 of file MOOSGenLibGlobalHelper.h.


Typedef Documentation

typedef std::list<std::string> STRING_LIST

Definition at line 52 of file MOOSGenLibGlobalHelper.h.


Function Documentation

std::string DoubleVector2String ( const std::vector< double > &  V)

write a std::vector<double> to a string (using MOOS Notation)

formats a vector of doubles into standard MOOS format

Definition at line 1326 of file MOOSGenLibGlobalHelper.cpp.

bool GetDirectoryContents ( const std::string &  sPath,
std::list< std::string > &  sContents,
bool  bFiles 
)

fills in a string list of all regular files found in specfied path if bFiles==true only files are returned, if bFiles = false only directories are returned

returns a string list of directories or files in a specified location exludes . and ..

splits a fully qualified path into parts -path, filestem and extension

Definition at line 1382 of file MOOSGenLibGlobalHelper.cpp.

double GetMOOSSkew ( )

generic timing functions

return the offset between DB time and client time

Definition at line 109 of file MOOSGenLibGlobalHelper.cpp.

double GetMOOSTimeWarp ( )

return the current time warp factor

Definition at line 238 of file MOOSGenLibGlobalHelper.cpp.

bool GetNextAlogLineByMessageName ( std::istream &  Input,
const std::string &  sMessageName,
double &  dfTime,
std::string &  sSource,
std::string &  sPayload 
)

Definition at line 702 of file MOOSGenLibGlobalHelper.cpp.

double HPMOOSTime ( bool  bApplyTimeWarping = true)

return high precision timestamp - time since unix in seconds only has high precision in win32

Definition at line 228 of file MOOSGenLibGlobalHelper.cpp.

void InhibitMOOSTraceInThisThread ( bool  bInhibit = true)

Inhibit (enable) MOOSTracing in the calling thread

Definition at line 1067 of file MOOSGenLibGlobalHelper.cpp.

bool IsLittleEndian ( )

returns true if current machine is little end in

returns true if architecture is LittleEndian (true for x86 Architectures) Note after first call it remembers answer in a static so v. littel overhead in calling this function frequently

Definition at line 119 of file MOOSGenLibGlobalHelper.cpp.

double MOOS_ANGLE_WRAP ( double  dfAng)

Bound angle to +/-PI

Definition at line 734 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSAbsLimit ( double &  dfVal,
double  dfLimit 
)

Bounds |dfVal| < dfLimit but keeps sign. Returns true if it was clamped

limit dfVal to lie between +/- dfLimit)

Definition at line 756 of file MOOSGenLibGlobalHelper.cpp.

template<class T >
std::string& MOOSAddValToString ( std::string &  sIn,
const std::string &  sTok,
const T &  Val 
)

Definition at line 285 of file MOOSGenLibGlobalHelper.h.

std::string MOOSChomp ( std::string &  sStr,
const std::string &  sTk = ",",
bool  bInsensitive = false 
)
template<class T >
const T& MOOSClamp ( const T &  val,
const T &  min,
const T &  max 
)

Clamps a templated type between two values

Definition at line 224 of file MOOSGenLibGlobalHelper.h.

bool MOOSCreateDirectory ( const std::string &  sDirectory)

make a directory

double MOOSDeg2Rad ( double  dfDeg)

convert deg to rad

Definition at line 1145 of file MOOSGenLibGlobalHelper.cpp.

int MOOSDiscreteUniform ( int  nMin,
int  nMax 
)

generates uniform noise in integers between interval nMin->nMax

Definition at line 1247 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSFail ( const char *  FmtStr,
  ... 
)

like MOOSTrace but returns false - useful for return statements

Definition at line 1030 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSFileParts ( std::string  sFullPath,
std::string &  sPath,
std::string &  sFile,
std::string &  sExtension 
)

splits a fully qualified path into parts -path, filestem and extension

std::string MOOSFormat ( const char *  FmtStr,
  ... 
)

return a formatted string (with printf-like format codes

Definition at line 992 of file MOOSGenLibGlobalHelper.cpp.

int MOOSGetch ( )

useful keyboard trap

Definition at line 954 of file MOOSGenLibGlobalHelper.cpp.

std::string MOOSGetDate ( )

get the current date formatted nicely

Definition at line 781 of file MOOSGenLibGlobalHelper.cpp.

std::string MOOSGetTimeStampString ( )

return nicely formatted time stamp string

Definition at line 873 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSGetValueFromToken ( STRING_LIST sParams,
const std::string &  sToken,
std::string &  sVal 
)
bool MOOSIsNumeric ( std::string  str)

returbn true if numeric

double MOOSLocalTime ( bool  bApplyTimeWarping = true)

Return time as a double (time since unix in seconds). This returns the time as reported by the local clock. It will *not* return time at the Comms Server, as MOOSTime tries to do.

Definition at line 149 of file MOOSGenLibGlobalHelper.cpp.

double MOOSNormalInv ( double  dfArea)

returns x for probablity mass such p(v<=x) = dfArea)

Definition at line 1216 of file MOOSGenLibGlobalHelper.cpp.

void MOOSPause ( int  nMS,
bool  bApplyTimeWarping = true 
)

pause for nMS milliseconds

Definition at line 255 of file MOOSGenLibGlobalHelper.cpp.

double MOOSRad2Deg ( double  dfRad)

convert rad 2 deg

Definition at line 1150 of file MOOSGenLibGlobalHelper.cpp.

void MOOSRemoveChars ( std::string &  sStr,
const std::string &  sTok 
)

remove all characters in sTok from sStr

bool MOOSStrCmp ( std::string  s1,
std::string  s2 
)

case insensitive string comparison. returns true if equal

size_t MOOSStrFind ( const std::string &  sSource,
const std::string &  sToken,
bool  bInsensitive = false 
)

Definition at line 306 of file MOOSGenLibGlobalHelper.cpp.

std::string MOOSThirdPartyActuationString ( double *  pdfRudder,
double *  pdfElevator,
double *  pdfThrust 
)

Definition at line 1190 of file MOOSGenLibGlobalHelper.cpp.

std::string MOOSThirdPartyStatusString ( std::string  sStatusCommand)
double MOOSTime ( bool  bApplyTimeWarping = true)

return time as a double (time since unix in seconds). This will also apply a skew to this time so that all processes connected to a MOOSCommsServer (often in the shap of a DB) will have a unified time. Of course if your process isn't using MOOSComms at all this funtion works just fine and returns the unadulterated time as you would expect

Definition at line 233 of file MOOSGenLibGlobalHelper.cpp.

void MOOSToUpper ( std::string &  str)

convert string to upper case

void MOOSTrace ( std::string  Str)

print a string

void MOOSTrace ( const char *  FmtStr,
  ... 
)

print a formatted string (with printf-like format codes) and to debug window in DevStudio

Definition at line 1085 of file MOOSGenLibGlobalHelper.cpp.

void MOOSTrimWhiteSpace ( std::string &  str)

remove white space form start and end of a string

double MOOSUniformRandom ( double  dfMin,
double  dfMax 
)

generates uniform noise in interval dfMin-dfMax

Definition at line 1241 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( bool bVal,
const std::string &  sStr,
const std::string &  sTk,
bool  bInsensitive = false 
)
bool MOOSValFromString ( double &  dfVal,
const std::string &  sStr,
const std::string &  sTk,
bool  bInsensitive = false 
)
bool MOOSValFromString ( std::vector< unsigned int > &  nValVec,
int &  nRows,
int &  nCols,
const std::string &  sStr,
const std::string &  sToken,
bool  bInsensitive = false 
)

Definition at line 670 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( std::vector< double > &  dfValVec,
int &  nRows,
int &  nCols,
const std::string &  sStr,
const std::string &  sToken,
bool  bInsensitive = false 
)

Definition at line 654 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( float &  fVal,
const std::string &  sStr,
const std::string &  sTk,
bool  bInsensitive = false 
)
bool MOOSValFromString ( long long &  nVal,
const std::string &  sStr,
const std::string &  sTk,
bool  bInsensitive = false 
)
bool MOOSValFromString ( long &  nVal,
const std::string &  sStr,
const std::string &  sTk,
bool  bInsensitive = false 
)
bool MOOSValFromString ( std::string &  sVal,
const std::string &  sStr,
const std::string &  sTk,
bool  bInsensitive = false 
)
bool MOOSValFromString ( unsigned int &  nVal,
const std::string &  sStr,
const std::string &  sTk,
bool  bInsensitive = false 
)
bool MOOSValFromString ( int &  nVal,
const std::string &  sStr,
const std::string &  sTk,
bool  bInsensitive = false 
)
bool MOOSVectorFromString ( const std::string &  sStr,
std::vector< unsigned int > &  dfVecVal,
int &  nRows,
int &  nCols 
)
bool MOOSVectorFromString ( const std::string &  sStr,
std::vector< double > &  dfVecVal,
int &  nRows,
int &  nCols 
)
bool MOOSVectorFromString ( const std::string &  sStr,
std::vector< float > &  fValVec,
int &  nRows,
int &  nCols 
)
double MOOSWhiteNoise ( double  Sigma)

returns sample fom Gaussian process strength Sigma mena zero

Definition at line 1264 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSWildCmp ( const std::string &  sPattern,
const std::string &  sString 
)

pattern matching using * and ?. returns true if sPattern matches sString

Definition at line 811 of file MOOSGenLibGlobalHelper.cpp.

void Progress ( double  dfPC)

print a progress bar - dfPC is the percent of a job completed

prints a "progress bar" upto 40 characters long dfPC is the fraction complete - ie 0:1

Definition at line 1307 of file MOOSGenLibGlobalHelper.cpp.

void SetMOOSSkew ( double  dfSkew)

Definition at line 100 of file MOOSGenLibGlobalHelper.cpp.

bool SetMOOSTimeWarp ( double  dfWarp)

set the rate at which time is accelerated (from start of unix time)

Definition at line 244 of file MOOSGenLibGlobalHelper.cpp.

bool SetWin32HighPrecisionTiming ( bool  bEnable)

call this to disable or anble high precision windows timers. By default they are on and always used in calls to MOOSTime()

Definition at line 137 of file MOOSGenLibGlobalHelper.cpp.

template<class T >
T SwapByteOrder ( const T &  v)

templated function which swaps byte order of type T returning it

Definition at line 252 of file MOOSGenLibGlobalHelper.h.

std::stringstream& Write ( std::stringstream &  os,
const std::vector< int > &  Vec 
)

write a std::vector<int> to a stringstream (using MOOS Notation)

formats a vector of ints into standard MOOS format

Definition at line 1361 of file MOOSGenLibGlobalHelper.cpp.

std::stringstream& Write ( std::stringstream &  os,
const std::vector< double > &  Vec 
)

write a std::vector<double> to a stringstream (using MOOS Notation)

formats a vector of doubles into standard MOOS format

Definition at line 1334 of file MOOSGenLibGlobalHelper.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines