[go: up one dir, main page]

Menu

[r1123]: / trunk / src / calcmethod.h  Maximize  Restore  History

Download this file

54 lines (45 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef GUARD_CalcMethod_h
#define GUARD_CalcMethod_h
#include <map>
#include <string>
#include <vector>
#include "System.h"
namespace mesmer
{
class System;
/** Abstract base class as interface for plugin classes which do various
types of execution, e.g. single calculations, gridsearch and fitting
**/
class CalcMethod : public TopPlugin
{
public:
static const char* typeID(){ return "Calculation methods"; }
virtual ~CalcMethod(){}
virtual const char* getTypeID(){return typeID();}
virtual bool DoesOwnParsing() { return false; }
//Get a pointer to a derived class by providing its id.
static CalcMethod* Find(const std::string& id)
{
return dynamic_cast<CalcMethod*>(TopFind(id, typeID()));
}
System* getParent() { return m_parent; }
void setParent(System* parent) { m_parent = parent; }
//Function to do the work
virtual bool DoCalculation(System* pSys)=0;
//Parses the <me:control> section of the XML input file to find the specified method
//For instance: <calcMethod>simpleCalc</calcMethod>
//If there is no <calcMethod> element, the simpleCalc, set in defaults.xml, is used.
//If there is an unrecognized method, the acceptable method are listed in an error message
//and returns false.
static CalcMethod* GetCalcMethod(PersistPtr ppControl, std::string& name)
{
const char* type = ppControl->XmlReadValue("me:calcMethod"); //or uses default
name = std::string(type) ;
CalcMethod* method = Find(type);
return method;
}
private:
System* m_parent;
};
}//namespace
#endif