FOX/ObjCryst++  1.10.X (development)
Tracker.h
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2005- Vincent Favre-Nicolin vincefn@users.sourceforge.net
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 /*
19 * header file ObjCryst++ Tracker class
20 *
21 */
22 
23 #ifndef _REFINABLEOBJ_TRACKER_H_
24 #define _REFINABLEOBJ_TRACKER_H_
25 
26 #include <set>
27 #include <vector>
28 #include <utility>
29 #include "ObjCryst/RefinableObj/RefinableObj.h"
30 
31 #ifdef __WX__CRYST__
32 namespace ObjCryst
33 {
34 class MainTracker;
35 class Tracker;
36 }
37 #include "ObjCryst/wxCryst/wxTrackerGraph.h"
38 #endif
39 namespace ObjCryst
40 {
41 
47 class Tracker
48 {
49  public:
50  Tracker(const std::string &name);
51  virtual ~Tracker();
52  const std::string& GetName()const;
53  void AppendValue(const long trial);
55  void Clear();
56  const std::map<long,REAL>& GetValues() const;
57  std::map<long,REAL>& GetValues();
58  protected:
59  virtual REAL ReadValue()=0;
60  std::map<long,REAL> mvValues;
61  std::string mName;
62 };
63 
69 {
70  public:
71  MainTracker();
72  ~MainTracker();
73  void AddTracker(Tracker *t);
74  void AppendValues(const long trial);
76  void ClearTrackers();
78  void ClearValues();
81  void SaveAll(std::ostream &out)const;
82  const std::set<Tracker*> &GetTrackerList()const;
84  void UpdateDisplay()const;
88  const RefinableObjClock& GetClockValues()const;
89  private:
90  std::set<Tracker*> mvpTracker;
95  #ifdef __WX__CRYST__
96  public:
97  WXTrackerGraph* WXCreate(wxFrame*);
98  WXTrackerGraph* WXGet();
99  void WXDelete();
100  void WXNotifyDelete();
101  protected:
102  WXTrackerGraph *mpWXTrackerGraph;
103  #endif
104 };
105 
109 template <class T> class TrackerObject:public Tracker
110 {
111  public:
112  TrackerObject(const std::string &name, const T&obj, REAL (T::*f)() const):
113  Tracker(name),mpObj(&obj),mfp(f)
114  {}
115  private:
116  const T *mpObj;
117  REAL (T::*mfp)() const;
118  REAL ReadValue(){return (mpObj->*mfp)();}
119 };
120 
121 }//namespace
122 #endif
Tracker for objects (RefinableObj, Crystal, PowderPattern, RefPar,...)
Definition: Tracker.h:109
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:138
void Clear()
Removes all stored values.
Definition: Tracker.cpp:44
void UpdateDisplay() const
Update display, if any.
Definition: Tracker.cpp:133
RefinableObjClock mClockTrackerList
Last time a tracker was added.
Definition: Tracker.h:92
void ClearValues()
Removes all stored values.
Definition: Tracker.cpp:97
const RefinableObjClock & GetClockValues() const
Get last time values were whanged.
Definition: Tracker.cpp:140
A class to track the variation of parameters as a function of a number of cycles/trials.
Definition: Tracker.h:47
const RefinableObjClock & GetClockTrackerList() const
Get last time a tracker was added.
Definition: Tracker.cpp:139
A class to hold all trackers.
Definition: Tracker.h:68
void ClearTrackers()
Removes all Trackers.
Definition: Tracker.cpp:88
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: Atom.cpp:47
void SaveAll(std::ostream &out) const
Will save to a single file if all recorded trial numbers are the same Otherwise ? ...
Definition: Tracker.cpp:105
RefinableObjClock mClockValues
Last time values were whanged.
Definition: Tracker.h:94