GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GBase.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GBase.hpp - GammaLib base class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2014 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GBase.hpp
23  * @brief Definition of interface for all GammaLib classes
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GBASE_HPP
28 #define GBASE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <iostream>
33 #include "GTypemaps.hpp"
34 
35 
36 /***********************************************************************//**
37  * @class GBase
38  *
39  * @brief Interface class for all GammaLib classes
40  *
41  * This class defines the interface for all GammaLib classes. It is an
42  * abstract base class from which all other GammaLib classes will be
43  * derived. The interface class imposes on all GammaLib classes to
44  * implement the following methods:
45  *
46  * clear - Clear container
47  * clone - Clones container
48  * class_name - Returns the class name
49  * print - Print container content
50  *
51  ***************************************************************************/
52 class GBase {
53 
54 public:
55  /// @brief Destructor
56  ///
57  /// Destroys class.
58  virtual ~GBase(void) {}
59 
60  /// @brief Clear object
61  ///
62  /// Sets the object to a clean initial state. After calling the method
63  /// the object will be in the same state as it were if an empty instance
64  /// of the object would have been created.
65  virtual void clear(void) = 0;
66 
67  /// @brief Clones object
68  ///
69  /// @return Pointer to deep copy of object.
70  ///
71  /// Creates a deep copy of the object and returns a pointer to the
72  /// object.
73  virtual GBase* clone(void) const = 0;
74 
75  /// @brief Return class name
76  ///
77  /// @return String containing the class name.
78  ///
79  /// Returns the class name for non-abstract classes in a human readable
80  /// way.
81  virtual std::string classname(void) const = 0;
82 
83  /// @brief Print content of object
84  ///
85  /// @param[in] chatter Chattiness (defaults to NORMAL).
86  /// @return String containing the content of the object.
87  ///
88  /// Formats the content in a standard way and puts this content in a
89  /// C++ string that is returned.
90  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
91 };
92 
93 /* __ Forward declarations _______________________________________________ */
94 class GLog;
95 
96 /* __ Prototypes _________________________________________________________ */
97 std::ostream& operator<<(std::ostream& os, const GBase& base);
98 GLog& operator<<(GLog& log, const GBase& base);
99 
100 #endif /* GBASE_HPP */
virtual void clear(void)=0
Clear object.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual ~GBase(void)
Destructor.
Definition: GBase.hpp:58
Information logger interface definition.
Definition: GLog.hpp:62
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
virtual GBase * clone(void) const =0
Clones object.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Definition: GVector.cpp:1274
std::ostream & operator<<(std::ostream &os, const GBase &base)
Output operator.
Definition: GBase.cpp:57
GChatter
Definition: GTypemaps.hpp:33
Definition of GammaLib typemaps.
virtual std::string classname(void) const =0
Return class name.