diff --git a/src/tools/DLLoader.cpp b/src/tools/DLLoader.cpp index ab8c59c3bcc0ec5582d74a602617c4d9b639f6a0..8ac2c0c59b2df2ddb94358be76bd05fe06e1bff7 100644 --- a/src/tools/DLLoader.cpp +++ b/src/tools/DLLoader.cpp @@ -20,7 +20,6 @@ along with plumed. If not, see <http://www.gnu.org/licenses/>. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ #include "DLLoader.h" -#include "Exception.h" #ifdef __PLUMED_HAS_DLOPEN #include <dlfcn.h> diff --git a/src/tools/DLLoader.h b/src/tools/DLLoader.h index cd16c0e65fefac52c874126e2ccd1da1c24e2b8c..d26172a48454c2f6a3cb9ba1fb3a7239fc08e5c5 100644 --- a/src/tools/DLLoader.h +++ b/src/tools/DLLoader.h @@ -53,7 +53,7 @@ public: void* load(const std::string&); /// Returns the last error in dynamic loader const std::string & error(); -/// Returs true if the dynamic loader is available (on some systems it may not). +/// Returns true if the dynamic loader is available (on some systems it may not). static bool installed(); }; diff --git a/src/tools/Exception.h b/src/tools/Exception.h index 9f89ff81f531aae456cefa745e5d1f57f2a19fd9..aabb5b31e4f4492690f5b574b2fdb78972bcb748 100644 --- a/src/tools/Exception.h +++ b/src/tools/Exception.h @@ -59,6 +59,12 @@ extensive error message can be added. if(a<=0) plumed_error(); if(a<=0) plumed_merror("a should be larger than zero"); \endverbatim +The additional macros +plumed_dbg_assert() and plumed_dbg_massert() are similar +to plumed_assert() and plumed_massert() respectively, but the corresponding +check is only performed when NDEBUG macro is not defined. They should +be used when the check is expensive and should be skipped in production +code. By default, execution is terminated imediately and a message is printed on stderr. @@ -133,7 +139,7 @@ public: /// Conditionally print file/line/function information and exit when NDEBUG flag is not present #define plumed_dbg_assert(test) if(!(test)) throw PLMD::Exception("assertion failed " #test,__FILE__,__LINE__,__PRETTY_FUNCTION__) /// \relates PLMD::Exception -/// Conditionally print file/line/function information plus msg and exit when NDEBUG flast is not present +/// Conditionally print file/line/function information plus msg and exit when NDEBUG flag is not present #define plumed_dbg_massert(test,msg) if(!(test)) throw PLMD::Exception("assertion failed " #test ", " msg,__FILE__,__LINE__,__PRETTY_FUNCTION__) #endif diff --git a/src/tools/Log.h b/src/tools/Log.h index f69a4ea513e236e426c99c1b8a6c97a35e0b8091..f242b0e30785c228c1cdfb3a72e46a95bbae4435 100644 --- a/src/tools/Log.h +++ b/src/tools/Log.h @@ -26,8 +26,6 @@ namespace PLMD{ -class Communicator; - /// Class containing the log stream. /// /// It is similar to a FILE stream. It allows a printf() function, and diff --git a/src/tools/Units.h b/src/tools/Units.h index b6a3d7194d36d4cf91f03c1c53f3bd07399cb159..b9cded09331fda9c4fe63ee2657c478c9ea20076 100644 --- a/src/tools/Units.h +++ b/src/tools/Units.h @@ -26,10 +26,18 @@ namespace PLMD{ -/// Small utility class. -/// It has no implemented methods, and all its data are public. -/// It just simplify the syntax of functions which should pass the -/// value of all the units. +/** +\ingroup TOOLBOX +Small utility class that contains information about units. + +This class can be used to contain in a single place all the +information about units. Units are expressed in terms of +standard PLUMED units, i.e. kj/mol, nm, and ps. +Units can be set as double or as string. In the latter case, +one can also use strings such as kcal/mol. + + +*/ class Units{ /// Units for energy, expressed in kj/mol (e.g. 4.184 means kcal/mol) double energy; @@ -41,19 +49,40 @@ class Units{ double time; std::string timeString; public: -// Constructor, setting default values (1.0) +/// Constructor, setting default values (1.0) Units(); +/// Set energy units from string. +/// Also understands the following strings: +/// kj/mol, kcal/mol, j/mol, and eV. void setEnergy(const std::string &); +/// Set time units from string. +/// Also understands the following strings: +/// ps, ns, fs. void setTime(const std::string &); +/// Set lengh units from string. +/// Also understands the following strings: +/// nm, A, um. void setLength(const std::string &); - void setEnergy(const double); - void setTime(const double); - void setLength(const double); +/// Set energy units from double. +/// Should be specified in units of kj/mol (e.g. 4.184 means kcal/mol) + void setEnergy(double); +/// Set time units from double. +/// Should be specified in units of ps (e.g. 0.001 means fs) + void setTime(double); +/// Set lenght units from double. +/// Should be specified in units of nm (e.g. 0.1 means A) + void setLength(double); +/// Get energy units as double. const double & getEnergy()const; +/// Get length units as double. const double & getLength()const; +/// Get time units as double. const double & getTime()const; +/// Get energy units as string. const std::string & getEnergyString()const; +/// Get length units as string. const std::string & getLengthString()const; +/// Get time units as string. const std::string & getTimeString()const; };