C++: Implement Deleter pattern in UserOwned template.
This commit is contained in:
parent
90e89c2a42
commit
b4ed33a776
|
@ -211,6 +211,13 @@ protected:
|
||||||
structure(structure)
|
structure(structure)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Deleter needed to allow shared_ptr use with protected destructor. */
|
||||||
|
class Deleter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void operator()(Class *object) { delete object; }
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Type of log callback */
|
/** Type of log callback */
|
||||||
|
@ -269,12 +276,6 @@ protected:
|
||||||
LogCallbackFunction log_callback;
|
LogCallbackFunction log_callback;
|
||||||
Context();
|
Context();
|
||||||
~Context();
|
~Context();
|
||||||
/** Deleter needed to allow shared_ptr use with protected destructor. */
|
|
||||||
class Deleter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void operator()(Context *context) { delete context; }
|
|
||||||
};
|
|
||||||
friend class Deleter;
|
friend class Deleter;
|
||||||
friend class Session;
|
friend class Session;
|
||||||
friend class Driver;
|
friend class Driver;
|
||||||
|
@ -448,12 +449,7 @@ protected:
|
||||||
~Trigger();
|
~Trigger();
|
||||||
shared_ptr<Context> context;
|
shared_ptr<Context> context;
|
||||||
vector<TriggerStage *> stages;
|
vector<TriggerStage *> stages;
|
||||||
/** Deleter needed to allow shared_ptr use with protected destructor. */
|
friend class Deleter;
|
||||||
class Deleter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void operator()(Trigger *trigger) { delete trigger; }
|
|
||||||
};
|
|
||||||
friend class Context;
|
friend class Context;
|
||||||
friend class Session;
|
friend class Session;
|
||||||
};
|
};
|
||||||
|
@ -638,12 +634,6 @@ protected:
|
||||||
string save_filename;
|
string save_filename;
|
||||||
uint64_t save_samplerate;
|
uint64_t save_samplerate;
|
||||||
shared_ptr<Trigger> trigger;
|
shared_ptr<Trigger> trigger;
|
||||||
/** Deleter needed to allow shared_ptr use with protected destructor. */
|
|
||||||
class Deleter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void operator()(Session *session) { delete session; }
|
|
||||||
};
|
|
||||||
friend class Deleter;
|
friend class Deleter;
|
||||||
friend class Context;
|
friend class Context;
|
||||||
friend class DatafeedCallbackData;
|
friend class DatafeedCallbackData;
|
||||||
|
@ -663,12 +653,6 @@ protected:
|
||||||
~Packet();
|
~Packet();
|
||||||
shared_ptr<Device> device;
|
shared_ptr<Device> device;
|
||||||
PacketPayload *payload;
|
PacketPayload *payload;
|
||||||
/** Deleter needed to allow shared_ptr use with protected destructor. */
|
|
||||||
class Deleter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void operator()(Packet *packet) { delete packet; }
|
|
||||||
};
|
|
||||||
friend class Deleter;
|
friend class Deleter;
|
||||||
friend class Session;
|
friend class Session;
|
||||||
friend class Output;
|
friend class Output;
|
||||||
|
@ -809,12 +793,6 @@ protected:
|
||||||
~Input();
|
~Input();
|
||||||
shared_ptr<Context> context;
|
shared_ptr<Context> context;
|
||||||
InputDevice *device;
|
InputDevice *device;
|
||||||
/** Deleter needed to allow shared_ptr use with protected destructor. */
|
|
||||||
class Deleter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void operator()(Input *input) { delete input; }
|
|
||||||
};
|
|
||||||
friend class Deleter;
|
friend class Deleter;
|
||||||
friend class Context;
|
friend class Context;
|
||||||
friend class InputFormat;
|
friend class InputFormat;
|
||||||
|
@ -830,13 +808,6 @@ protected:
|
||||||
~InputDevice();
|
~InputDevice();
|
||||||
shared_ptr<Device> get_shared_from_this();
|
shared_ptr<Device> get_shared_from_this();
|
||||||
shared_ptr<Input> input;
|
shared_ptr<Input> input;
|
||||||
/** Deleter needed to allow shared_ptr use with protected destructor. */
|
|
||||||
class Deleter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void operator()(InputDevice *device) { delete device; }
|
|
||||||
};
|
|
||||||
friend class Deleter;
|
|
||||||
friend class Input;
|
friend class Input;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -859,12 +830,6 @@ protected:
|
||||||
shared_ptr<const struct sr_option *> structure_array);
|
shared_ptr<const struct sr_option *> structure_array);
|
||||||
~Option();
|
~Option();
|
||||||
shared_ptr<const struct sr_option *> structure_array;
|
shared_ptr<const struct sr_option *> structure_array;
|
||||||
/** Deleter needed to allow shared_ptr use with protected destructor. */
|
|
||||||
class Deleter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void operator()(Option *option) { delete option; }
|
|
||||||
};
|
|
||||||
friend class Deleter;
|
friend class Deleter;
|
||||||
friend class InputFormat;
|
friend class InputFormat;
|
||||||
friend class OutputFormat;
|
friend class OutputFormat;
|
||||||
|
@ -908,12 +873,6 @@ protected:
|
||||||
const shared_ptr<OutputFormat> format;
|
const shared_ptr<OutputFormat> format;
|
||||||
const shared_ptr<Device> device;
|
const shared_ptr<Device> device;
|
||||||
const map<string, Glib::VariantBase> options;
|
const map<string, Glib::VariantBase> options;
|
||||||
/** Deleter needed to allow shared_ptr use with protected destructor. */
|
|
||||||
class Deleter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void operator()(Output *output) { delete output; }
|
|
||||||
};
|
|
||||||
friend class Deleter;
|
friend class Deleter;
|
||||||
friend class OutputFormat;
|
friend class OutputFormat;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue