Skip to content
Dmitry Koplyarov edited this page Feb 29, 2016 · 14 revisions

Back to reference

class token
{
public:
	struct implementation
	{
		virtual void release_token_impl() = 0;
		virtual ~implementation() { }
	};

public:
	token(token&& other);
	~token();

	token(const token&) = delete;
	token& operator = (const token&) = delete;

	template < typename Implementation_, typename... Args_ >
	static token create(Args_&&... args);

	void reset();
};

A RAII class for managing generic resource ownership. Used for holding signal connections in wigwag library.
You can also use it in your code for managing various listeners (e.g. logger sinks) registration/unregistration.

Table of contents

Nested types

implementation

struct implementation
{
	virtual void release_token_impl() = 0;
	virtual ~implementation() { }
};

A base class that manages a resource ownership via release_token_impl method.

Constructors and destructors

move constructor

token(token&& other);

Just an ordinary move constructor. Nothing special.

copy constructor

token(const token&) = delete;

The copy constructor is prohibited.

destructor

~token();

Resets a token object if it hasn't been reset before.
Releases the associated resource (e.g. signal connection).

Static methods

create

template < typename Implementation_, typename... Args_ >
static token create (Args_&&... args);

Creates a token object.

Template arguments:

  • Implementation_ - an implementation subclass
  • Args_... - variadic arguments types

Arguments:

  • args... - forwarded to the Implementation_ class constructor

Methods

reset

void reset();

Resets a token object if it hasn't been reset before.
Releases the associated resource (e.g. signal connection).

Operators

## operator = ```c++ token& operator = (const token&) = delete; ``` The assignment operator is prohibited

Clone this wiki locally