GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GContainer.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GContainer.hpp - Container interface class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2013-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 GContainer.hpp
23  * @brief Definition of interface for container classes
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCONTAINER_HPP
28 #define GCONTAINER_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include "GBase.hpp"
32 
33 
34 /***********************************************************************//**
35  * @class GContainer
36  *
37  * @brief Interface class for container classes
38  *
39  * This class defines the interface for container classes. The usage of the
40  * interface class imposes on all container classes are coherent interface.
41  * The following methods are mandatory:
42  *
43  * clear - Clear container (inherited from GBase)
44  * clone - Clones container (inherited from GBase)
45  * classname - Returns the class name (inherited from GBase)
46  * print - Print container content (inherited from GBase)
47  * size - Returns number of objects is container
48  * is_empty - Checks if container is empty
49  * remove - Removes an object from the container
50  * reserve - Reserves space in the container
51  ***************************************************************************/
52 class GContainer : public GBase {
53 
54 public:
55  /// @brief Destructor
56  ///
57  /// Destroys class.
58  virtual ~GContainer(void) {}
59 
60  /// @brief Return number of objects in container
61  ///
62  /// @return Number of objects in container.
63  virtual int size(void) const = 0;
64 
65  /// @brief Checks if container is empty
66  ///
67  /// @return True if no objects are in container, false otherwise.
68  virtual bool is_empty(void) const = 0;
69 
70  /// @brief Remove object from container
71  ///
72  /// @param[in] index Index.
73  ///
74  /// Removes the object with the specified @p index from the container.
75  virtual void remove(const int& index) = 0;
76 
77  /// @brief Reserves space in the container
78  ///
79  /// @param[in] num Number of objects.
80  ///
81  /// Reserves space for @p num objects in the container.
82  virtual void reserve(const int& num) = 0;
83 };
84 
85 #endif /* GCONTAINER_HPP */
Definition of interface for all GammaLib classes.
virtual int size(void) const =0
Return number of objects in container.
virtual bool is_empty(void) const =0
Checks if container is empty.
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
virtual ~GContainer(void)
Destructor.
Definition: GContainer.hpp:58
virtual void reserve(const int &num)=0
Reserves space in the container.
Interface class for container classes.
Definition: GContainer.hpp:52