From 6f5e97fa48827d7eec89512fa8ecdbadd073524a Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Fri, 8 Jul 2011 10:20:55 +0200
Subject: [PATCH] Added some utility methods

To retrieve the timestep and to retrieve the periodicity
---
 src/Action.cpp |  4 ++++
 src/Action.h   |  3 +++
 src/Value.cpp  | 10 ++++++++++
 src/Value.h    |  2 ++
 4 files changed, 19 insertions(+)

diff --git a/src/Action.cpp b/src/Action.cpp
index fd8155ad5..2ac3b5bdf 100644
--- a/src/Action.cpp
+++ b/src/Action.cpp
@@ -95,6 +95,10 @@ double Action::getTime()const{
   return plumed.getAtoms().getTimeStep()*getStep();
 }
 
+double Action::getTimeStep()const{
+  return plumed.getAtoms().getTimeStep();
+}
+
 
 
 void Action::exit(int c){
diff --git a/src/Action.h b/src/Action.h
index 51d6f3d80..b432074e8 100644
--- a/src/Action.h
+++ b/src/Action.h
@@ -75,6 +75,9 @@ protected:
 /// Return the present time
   double getTime()const;
 
+/// Return the timestep
+  double getTimeStep()const;
+
 /// Check if Action was properly read.
 /// This checks if Action::line is empty. It must be called after
 /// a final Action has been initialized
diff --git a/src/Value.cpp b/src/Value.cpp
index 618a1bb30..1ec70fcfc 100644
--- a/src/Value.cpp
+++ b/src/Value.cpp
@@ -13,6 +13,16 @@ Value::Value(ActionWithValue&action,const std::string& name):
   max(0.0)
 {}
 
+bool Value::isPeriodic()const{
+  assert(periodicity!=unset);
+  return periodicity==periodic;
+}
+
+void Value::getDomain(double&min,double&max)const{
+  min=this->min;
+  max=this->max;
+}
+
 void Value::setPeriodicity(bool p){
   if(p) periodicity=periodic;
   else periodicity=notperiodic;
diff --git a/src/Value.h b/src/Value.h
index 8568d98b4..990362283 100644
--- a/src/Value.h
+++ b/src/Value.h
@@ -31,6 +31,8 @@ public:
   double get()const;
   void setPeriodicity(bool);
   void setDomain(double,double);
+  bool isPeriodic()const;
+  void getDomain(double&,double&)const;
   const std::string& getName()const;
   const std::string getFullName()const;
   void enableDerivatives();
-- 
GitLab