GNU Radio's OsmoSDR Package
pimpl.h
Go to the documentation of this file.
1
//
2
// Copyright 2010 Ettus Research LLC
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
//
17
18
#ifndef INCLUDED_OSMOSDR_PIMPL_H
19
#define INCLUDED_OSMOSDR_PIMPL_H
20
21
#include <boost/shared_ptr.hpp>
22
23
/*! \file pimpl.h
24
* "Pimpl idiom" (pointer to implementation idiom).
25
* The OSMOSDR_PIMPL_* macros simplify code overhead for declaring and making pimpls.
26
*
27
* Each pimpl is implemented as a shared pointer to the implementation:
28
* - The container class will not have to deallocate the pimpl.
29
* - The container class will use the pimpl as a regular pointer.
30
* - Usage: _impl->method(arg0, arg1)
31
* - Usage: _impl->member = value;
32
*
33
* \see http://en.wikipedia.org/wiki/Opaque_pointer
34
*/
35
36
/*!
37
* Make a declaration for a pimpl in a header file.
38
* - Usage: OSMOSDR_PIMPL_DECL(impl) _impl;
39
* \param _name the name of the pimpl class
40
*/
41
#define OSMOSDR_PIMPL_DECL(_name) \
42
struct _name; boost::shared_ptr<_name>
43
44
/*!
45
* Make an instance of a pimpl in a source file.
46
* - Usage: _impl = OSMOSDR_PIMPL_MAKE(impl, ());
47
* - Usage: _impl = OSMOSDR_PIMPL_MAKE(impl, (a0, a1));
48
* \param _name the name of the pimpl class
49
* \param _args the constructor args for the pimpl
50
*/
51
#define OSMOSDR_PIMPL_MAKE(_name, _args) \
52
boost::shared_ptr<_name>(new _name _args)
53
54
#endif
/* INCLUDED_OSMOSDR_PIMPL_H */
include
osmosdr
pimpl.h
Generated by
1.8.11