IntegrationExtension.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2008 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/Base/Classes/Pulsar/IntegrationExtension.h
10 
11 #ifndef __Pulsar_Integration_Extension_h
12 #define __Pulsar_Integration_Extension_h
13 
14 #include "Pulsar/Integration.h"
15 #include "TextInterface.h"
16 #include "extutil.h"
17 
18 namespace Pulsar
19 {
25  {
26  public:
27 
29  Extension (const char* name);
30 
32  virtual ~Extension ();
33 
35  virtual Extension* clone () const = 0;
36 
38  virtual TextInterface::Parser* get_interface () { return 0; }
39 
41  virtual void integrate (const Integration* subint) { }
42 
44  virtual void update (const Integration* subint) { }
45 
47  std::string get_extension_name () const;
48 
50  virtual std::string get_short_name () const;
51 
53  static Extension* factory (const std::string& name);
54 
56  template<typename T>
57  class Interface : public TextInterface::To<T>
58  {
59  std::string get_interface_name() const
60  { return this->instance->get_short_name(); }
61  };
62 
63  protected:
64 
66  std::string extension_name;
67 
69  const Archive* get_parent (const Integration* subint) const;
70  };
71 
75  template<class T>
76  const T* Integration::get () const
77  {
78  return get_ext<const T> (this, "Pulsar::Integration::get<Ext>", verbose);
79  }
80 
84  template<class T>
85  T* Integration::get ()
86  {
87  return get_ext<T> (this, "Pulsar::Integration::get<Ext>", verbose);
88  }
89 
92  template<class T>
94  {
95  T* ext = get<T>();
96  if (ext)
97  return ext;
98 
99  Reference::To<T> add_ext = new T;
100  add_extension (add_ext);
101  return add_ext;
102  }
103 }
104 
105 #endif
Definition: IntegrationExtension.h:29
static bool verbose
flag controls the amount output to stderr by Integration methods
Definition: Integration.h:42
Convenience class implements TextInterface::To<T>::get_interface_name.
Definition: IntegrationExtension.h:67
std::string get_extension_name() const
Return the name of the Extension.
Definition: Integration.C:45
friend class Extension
The Extensions added to this Integration instance.
Definition: Integration.h:428
The primary interface to pulsar observational data.
Definition: Archive.h:45
Extension(const char *name)
Construct with a name.
Definition: Integration.C:36
virtual Extension * clone() const =0
Return a new copy-constructed instance identical to this instance.
virtual void add_extension(Extension *extension)
Add an Extension to the Integration instance.
Definition: Integration.C:90
virtual void update(const Integration *subint)
Update information based on the provided Integration.
Definition: IntegrationExtension.h:54
virtual std::string get_short_name() const
Return an abbreviated name that can be typed relatively quickly.
Definition: Integration.C:50
virtual ~Extension()
Destructor.
Definition: Integration.C:41
Array of Profiles integrated over the same time interval.
Definition: Integration.h:37
static Extension * factory(const std::string &name)
Derived type factory.
Definition: Extension_factory.C:25
ExtensionType * getadd()
Template method returns an Extension of the specified type.
virtual void integrate(const Integration *subint)
Integrate information from another Integration.
Definition: IntegrationExtension.h:51
const Archive * get_parent(const Integration *subint) const
Provide Extension derived classes with access to parent Archive.
Definition: Integration.C:56
Defines the PSRCHIVE library.
Definition: CalSource.h:17
virtual TextInterface::Parser * get_interface()
Return a text interface that can be used to access this instance.
Definition: IntegrationExtension.h:48
Reference::To< C, false > instance
std::string extension_name
Extension name - useful when debugging.
Definition: IntegrationExtension.h:76
const ExtensionType * get() const
Template method searches for an Extension of the specified type.

Generated using doxygen 1.8.17