2012-03-15 11:40:46 +00:00
|
|
|
/*
|
|
|
|
* \brief Non-copyable objects design pattern.
|
|
|
|
* \author Stefan Kalkowski
|
|
|
|
* \date 2012-02-16
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 12:23:52 +00:00
|
|
|
* Copyright (C) 2012-2017 Genode Labs GmbH
|
2012-03-15 11:40:46 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2012-03-15 11:40:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__UTIL__NONCOPYABLE_H_
|
|
|
|
#define _INCLUDE__UTIL__NONCOPYABLE_H_
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
namespace Genode { class Noncopyable; }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Classes of objects not allowed to be copied, should inherit from this one.
|
|
|
|
*
|
|
|
|
* This class declares a private copy-constructor and assignment-operator.
|
|
|
|
* It's sufficient to inherit private from this class, and let the compiler
|
|
|
|
* detect any copy violations.
|
|
|
|
*/
|
|
|
|
class Genode::Noncopyable
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2015-03-20 16:50:41 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
2015-03-04 20:12:14 +00:00
|
|
|
Noncopyable(const Noncopyable&);
|
2015-03-20 16:50:41 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
const Noncopyable& operator=(const Noncopyable&);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2015-03-20 16:50:41 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* \noapi
|
|
|
|
*/
|
2015-03-04 20:12:14 +00:00
|
|
|
Noncopyable() {}
|
2015-03-20 16:50:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*
|
|
|
|
* \noapi
|
|
|
|
*/
|
2015-03-04 20:12:14 +00:00
|
|
|
~Noncopyable() {}
|
|
|
|
};
|
2012-03-15 11:40:46 +00:00
|
|
|
|
|
|
|
#endif /* _INCLUDE__UTIL__NONCOPYABLE_H_ */
|