Don't import ogdf namespace
[TortoiseGit.git] / ext / OGDF / ogdf / basic / ModuleOption.h
blobda4b412117b992ea53e644c5f1608a83874399a0
1 /*
2 * $Revision: 2523 $
4 * last checkin:
5 * $Author: gutwenger $
6 * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7 ***************************************************************/
9 /** \file
10 * \brief Declaration of parameterized class for module options
12 * \author Carsten Gutwenger
14 * \par License:
15 * This file is part of the Open Graph Drawing Framework (OGDF).
17 * \par
18 * Copyright (C)<br>
19 * See README.txt in the root directory of the OGDF installation for details.
21 * \par
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * Version 2 or 3 as published by the Free Software Foundation;
25 * see the file LICENSE.txt included in the packaging of this file
26 * for details.
28 * \par
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * \par
35 * You should have received a copy of the GNU General Public
36 * License along with this program; if not, write to the Free
37 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
38 * Boston, MA 02110-1301, USA.
40 * \see http://www.gnu.org/copyleft/gpl.html
41 ***************************************************************/
44 #ifdef _MSC_VER
45 #pragma once
46 #endif
48 #ifndef OGDF_MODULE_OPTION_H
49 #define OGDF_MODULE_OPTION_H
52 #include <ogdf/basic/basic.h>
55 namespace ogdf {
58 /**
59 * \brief The parameterized base class for module options.
61 * M is type (base class) of corresponding module. Notice that module
62 * instances passed to set() must be allocated with new and will be
63 * freed by ModuleOption.
65 template<class M> class ModuleOption {
67 M *m_pModule; //!< Pointer to the module.
69 public:
70 //! Initializes a module option; the initial module is just a 0-pointer.
71 ModuleOption() : m_pModule(0) { }
73 // destruction
74 ~ModuleOption() { delete m_pModule; }
76 //! Sets the module to \a pM.
77 /**
78 * This function will also free the module currently stored by the option.
80 void set(M *pM) {
81 delete m_pModule;
82 m_pModule = pM;
85 //! Returns true iff the option currently stores a module.
86 bool valid() const { return m_pModule != 0; }
88 //! Returns a reference to the stored module.
89 /**
90 * It is required that the option currently stores a module, i.e.,
91 * valid() is true.
93 M &get() { return *m_pModule; }
97 } // end namespace ogdf
100 #endif