Chemical Data Processing Library C++ API - Version 1.2.0
DataIOBase.hpp
Go to the documentation of this file.
1 /*
2  * DataIOBase.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_BASE_DATAIOBASE_HPP
30 #define CDPL_BASE_DATAIOBASE_HPP
31 
32 #include <vector>
33 #include <utility>
34 #include <cstddef>
35 #include <functional>
36 
37 #include "CDPL/Base/APIPrefix.hpp"
39 
40 
41 namespace CDPL
42 {
43 
44  namespace Base
45  {
46 
59  {
60 
61  public:
68  typedef std::function<void(const DataIOBase&, double)> IOCallbackFunction;
69 
75  std::size_t registerIOCallback(const IOCallbackFunction& func);
76 
84  void unregisterIOCallback(std::size_t id);
85 
90  void invokeIOCallbacks(double progress) const;
91 
96 
97  protected:
102 
108  DataIOBase(const DataIOBase& io_base):
109  ControlParameterContainer(io_base) {}
110 
115 
122  DataIOBase& operator=(const DataIOBase& io_base);
123 
124  private:
125  typedef std::pair<std::size_t, IOCallbackFunction> CallbackListEntry;
126  typedef std::vector<CallbackListEntry> CallbackList;
127 
128  CallbackList callbacks;
129  };
130  } // namespace Base
131 } // namespace CDPL
132 
133 #endif // CDPL_BASE_DATAIOBASE_HPP
Definition of the preprocessor macro CDPL_BASE_API.
#define CDPL_BASE_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of the class CDPL::Base::ControlParameterContainer.
A class providing methods for the storage and lookup of control-parameter values.
Definition: ControlParameterContainer.hpp:93
Provides infrastructure for the registration of I/O callback functions.
Definition: DataIOBase.hpp:59
~DataIOBase()
Destructor.
Definition: DataIOBase.hpp:114
void unregisterIOCallback(std::size_t id)
Unregisters the I/O callback function specified by id.
std::size_t registerIOCallback(const IOCallbackFunction &func)
Registers an I/O callback target function.
void clearIOCallbacks()
Clears all registered I/O callback functions.
std::function< void(const DataIOBase &, double)> IOCallbackFunction
A functor class used to wrap I/O callback target functions.
Definition: DataIOBase.hpp:68
DataIOBase & operator=(const DataIOBase &io_base)
Assignment operator.
void invokeIOCallbacks(double progress) const
Invokes all registered I/O callback functions with the argument *this.
DataIOBase()
Default constructor.
Definition: DataIOBase.hpp:101
DataIOBase(const DataIOBase &io_base)
Copy constructor.
Definition: DataIOBase.hpp:108
The namespace of the Chemical Data Processing Library.