OpenSim Moco  0.2.0
Classes | Functions
Generic utilities

Utilities for parallelism, strings, date/time, and error-checking. More...

Classes

class  OpenSim::Stopwatch
 Record and report elapsed real time ("clock" or "wall" time) in seconds. More...
 
class  OpenSim::ThreadsafeJar< T >
 This class lets you store objects of a single type for reuse by multiple threads, ensuring threadsafe access to each of those objects. More...
 
class  OpenSim::FileDeletionThrowerException
 Thrown by FileDeletionThrower::throwIfDeleted(). More...
 
class  OpenSim::FileDeletionThrower
 This class helps a user cause an exception within the code. More...
 

Functions

template<typename T , typename... Args>
std::unique_ptr< T > OpenSim::make_unique (Args &&... args)
 Since Moco does not require C++14 (which contains std::make_unique()), here is an implementation of make_unique().
 
OSIMMOCO_API std::string OpenSim::getMocoFormattedDateTime (bool appendMicroseconds=false, std::string format="%Y-%m-%dT%H%M%S")
 Get a string with the current date and time formatted as Y-m-dTHMS (year, month, day, "T", hour, minute, second). More...
 
bool OpenSim::startsWith (const std::string &string, const std::string &start)
 Determine if string starts with the substring start. More...
 
bool OpenSim::endsWith (const std::string &string, const std::string &ending)
 Determine if string ends with the substring ending. More...
 
template<typename T >
void OpenSim::checkPropertyInSet (const Object &obj, const Property< T > &p, const std::set< T > &set)
 Throw an exception if the property's value is not in the provided set. More...
 
template<typename T >
void OpenSim::checkPropertyIsPositive (const Object &obj, const Property< T > &p)
 Throw an exception if the property's value is not positive. More...
 
template<typename T >
void OpenSim::checkPropertyInRangeOrSet (const Object &obj, const Property< T > &p, const T &lower, const T &upper, const std::set< T > &set)
 Throw an exception if the property's value is neither in the provided range nor in the provided set. More...
 
OSIMMOCO_API int OpenSim::getMocoParallelEnvironmentVariable ()
 This obtains the value of the OPENSIM_MOCO_PARALLEL environment variable. More...
 

Detailed Description

Utilities for parallelism, strings, date/time, and error-checking.

Function Documentation

◆ checkPropertyInRangeOrSet()

template<typename T >
void OpenSim::checkPropertyInRangeOrSet ( const Object &  obj,
const Property< T > &  p,
const T &  lower,
const T &  upper,
const std::set< T > &  set 
)

Throw an exception if the property's value is neither in the provided range nor in the provided set.

We assume that p is a single-value property.

◆ checkPropertyInSet()

template<typename T >
void OpenSim::checkPropertyInSet ( const Object &  obj,
const Property< T > &  p,
const std::set< T > &  set 
)

Throw an exception if the property's value is not in the provided set.

We assume that p is a single-value property.

◆ checkPropertyIsPositive()

template<typename T >
void OpenSim::checkPropertyIsPositive ( const Object &  obj,
const Property< T > &  p 
)

Throw an exception if the property's value is not positive.

We assume that p is a single-value property.

◆ endsWith()

bool OpenSim::endsWith ( const std::string &  string,
const std::string &  ending 
)
inline

◆ getMocoFormattedDateTime()

OSIMMOCO_API std::string OpenSim::getMocoFormattedDateTime ( bool  appendMicroseconds = false,
std::string  format = "%Y-%m-%dT%H%M%S" 
)

Get a string with the current date and time formatted as Y-m-dTHMS (year, month, day, "T", hour, minute, second).

You can change the datetime format via the format parameter. If you specify "ISO", then we use the ISO 8601 extended datetime format Y-m-dTH:M:S. See https://en.cppreference.com/w/cpp/io/manip/put_time.

◆ getMocoParallelEnvironmentVariable()

OSIMMOCO_API int OpenSim::getMocoParallelEnvironmentVariable ( )

This obtains the value of the OPENSIM_MOCO_PARALLEL environment variable.

The value has the following meanings:

  • 0: run in series (not parallel).
  • 1: run in parallel using all cores.
  • greater than 1: run in parallel with this number of threads. If the environment variable is not set, this function returns -1.

This variable does not indicate which calculations are parallelized or how the parallelization is achieved. Moco may even ignore or override the setting from the environment variable. See documentation elsewhere (e.g., from a specific MocoSolver) for more information.

◆ startsWith()

bool OpenSim::startsWith ( const std::string &  string,
const std::string &  start 
)
inline