Agent.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2004 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/More/MEAL/MEAL/Agent.h
10
11#ifndef __MEAL_Agent_H
12#define __MEAL_Agent_H
13
14#include "Registry.h"
15#include "Reference.h"
16
17namespace MEAL {
18
19 class Function;
20
22 class Agent : public Reference::Able {
23
24 public:
25
27 virtual ~Agent () { }
28
30 virtual std::string get_name () = 0;
31
33 virtual Function* new_Function () = 0;
34
35 protected:
36
38 friend class Function;
39
40 };
41
42
44
46
47 template<class Type>
48 class Advocate : public Agent
49 {
50
51 public:
52
54 Advocate () { instance = new Type; }
55
57 template<typename Arg>
58 Advocate (const Arg& arg) { instance = new Type (arg); }
59
61 std::string get_name () { return instance->get_name(); }
62
64 Function* new_Function () { return instance->clone(); }
65
66 private:
67
69 Type* instance;
70
71 };
72
73}
74
75#endif
Advocate(const Arg &arg)
Constructor ensures that template entry is instantiated.
Definition Agent.h:58
std::string get_name()
Return the name of the derived class.
Definition Agent.h:61
Advocate()
Constructor ensures that template entry is instantiated.
Definition Agent.h:54
Function * new_Function()
Return a new instance of the Function derived class.
Definition Agent.h:64
Pure virtual base class of Advocate template base class.
Definition Agent.h:22
virtual ~Agent()
Destructor.
Definition Agent.h:27
virtual std::string get_name()=0
Return the name of the derived class.
virtual Function * new_Function()=0
Return a null-constructed instance of the derived class.
friend class Function
Declare friends with Function so Function::load can access registry.
Definition Agent.h:38
Pure virtual base class of all functions.
Definition Function.h:49
virtual Function * clone() const
Clone.
Definition Function.C:86
Namespace in which all modeling and calibration related code is declared.
Definition ExampleComplex2.h:16

Generated using doxygen 1.14.0