Bridge++  Ver. 2.0.2
source.h
Go to the documentation of this file.
1 
14 #ifndef SOURCE_INCLUDED
15 #define SOURCE_INCLUDED
16 
17 #include "Parameters/parameters.h"
18 #include "Field/field.h"
19 
20 #include "IO/bridgeIO.h"
21 
22 #ifdef USE_FACTORY
23 #include "Tools/factory.h"
24 #endif
25 
27 
37 class Source
38 {
39  public:
40  Source() {}
41  virtual ~Source() {}
42 
43  private:
44  // non-copyable
45  Source(const Source&);
46  Source& operator=(const Source&);
47 
48  public:
49  virtual void set_parameters(const Parameters&) = 0;
50 
51  virtual void get_parameters(Parameters&) const = 0;
52 
53  virtual void set(Field&, const int) = 0;
54  virtual void set(Field&, const int, const int) = 0;
55  virtual void set_all_color(Field&, const int) = 0;
56  virtual void set_all_color_spin(Field&) = 0;
57 
58 #ifdef USE_FACTORY
59  public:
60  typedef Source *(*ProductCreator)();
61  typedef Source *(*ProductCreator_params)(const Parameters&);
62 
65 
66  static Source *New(const IdentifierType& subtype)
67  {
68  ProductCreator p = Factory::Find(subtype);
69  return p ? (*p)() : 0;
70  }
71 
72  static Source *New(const IdentifierType& subtype, const Parameters& params)
73  {
74  ProductCreator_params p = Factory_params::Find(subtype);
75  return p ? (*p)(params) : 0;
76  }
77 
78 #ifdef USE_FACTORY_AUTOREGISTER
79 #else
80  static bool init_factory();
81 #endif
82 #endif
83 };
84 #endif /* SOURCE_INCLUDED */
bridgeIO.h
factory.h
Parameters
Class for parameters.
Definition: parameters.h:46
Source::set_parameters
virtual void set_parameters(const Parameters &)=0
Source::set
virtual void set(Field &, const int)=0
Source::Source
Source()
Definition: source.h:40
Source::get_parameters
virtual void get_parameters(Parameters &) const =0
Source
Base class of source for a linear solver.
Definition: source.h:37
Source::set_all_color_spin
virtual void set_all_color_spin(Field &)=0
Source::set_all_color
virtual void set_all_color(Field &, const int)=0
Source::operator=
Source & operator=(const Source &)
field.h
parameters.h
FactoryTemplate
Definition: factory.h:42
Source::~Source
virtual ~Source()
Definition: source.h:41
Field
Container of Field-type object.
Definition: field.h:46
IdentifierType
std::string IdentifierType
Definition: factory.h:39