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 
17 namespace 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 
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
std::string get_name()
Return the name of the derived class.
Definition: Agent.h:66
virtual std::string get_name()=0
Return the name of the derived class.
Namespace in which all modeling and calibration related code is declared.
Definition: ExampleComplex2.h:16
virtual ~Agent()
Destructor.
Definition: Agent.h:32
Pure virtual base class of all functions.
Definition: Function.h:49
Function * new_Function()
Return a new instance of the Function derived class.
Definition: Agent.h:69
virtual Function * new_Function()=0
Return a null-constructed instance of the derived class.
Advocate()
Constructor ensures that template entry is instantiated.
Definition: Agent.h:59

Generated using doxygen 1.8.17