}
Context::Context() :
- UserOwned(_structure),
+ _structure(nullptr),
_session(nullptr)
{
check(sr_init(&_structure));
{
auto name = entry.first;
auto driver = entry.second;
- result[name] = driver->get_shared_pointer(this);
+ result[name] = driver->share_owned_by(shared_from_this());
}
return result;
}
{
auto name = entry.first;
auto input_format = entry.second;
- result[name] = input_format->get_shared_pointer(this);
+ result[name] = input_format->share_owned_by(shared_from_this());
}
return result;
}
{
auto name = entry.first;
auto output_format = entry.second;
- result[name] = output_format->get_shared_pointer(this);
+ result[name] = output_format->share_owned_by(shared_from_this());
}
return result;
}
}
Driver::Driver(struct sr_dev_driver *structure) :
- ParentOwned(structure),
Configurable(structure, nullptr, nullptr),
+ _structure(structure),
_initialized(false)
{
}
vector<shared_ptr<Channel>> result;
for (auto channel = sr_dev_inst_channels_get(_structure); channel; channel = channel->next) {
auto *const ch = static_cast<struct sr_channel *>(channel->data);
- result.push_back(_channels[ch]->get_shared_pointer(get_shared_from_this()));
+ result.push_back(_channels[ch]->share_owned_by(get_shared_from_this()));
}
return result;
}
shared_ptr<Channel> Device::get_channel(struct sr_channel *ptr)
{
- return _channels[ptr]->get_shared_pointer(get_shared_from_this());
+ return _channels[ptr]->share_owned_by(get_shared_from_this());
}
map<string, shared_ptr<ChannelGroup>>
{
auto name = entry.first;
auto channel_group = entry.second;
- result[name] = channel_group->get_shared_pointer(get_shared_from_this());
+ result[name] = channel_group->share_owned_by(get_shared_from_this());
}
return result;
}
HardwareDevice::HardwareDevice(shared_ptr<Driver> driver,
struct sr_dev_inst *structure) :
- UserOwned(structure),
Device(structure),
_driver(move(driver))
{
}
UserDevice::UserDevice(string vendor, string model, string version) :
- UserOwned(sr_dev_inst_user_new(
- vendor.c_str(), model.c_str(), version.c_str())),
- Device(UserOwned::_structure)
+ Device(sr_dev_inst_user_new(
+ vendor.c_str(), model.c_str(), version.c_str()))
{
}
}
Channel::Channel(struct sr_channel *structure) :
- ParentOwned(structure),
+ _structure(structure),
_type(ChannelType::get(_structure->type))
{
}
ChannelGroup::ChannelGroup(Device *device,
struct sr_channel_group *structure) :
- ParentOwned(structure),
Configurable(sr_dev_inst_driver_get(device->_structure), device->_structure, structure)
{
- for (GSList *entry = structure->channels; entry; entry = entry->next) {
+ for (GSList *entry = config_channel_group->channels; entry; entry = entry->next) {
auto *const ch = static_cast<struct sr_channel *>(entry->data);
_channels.push_back(device->_channels[ch]);
}
string ChannelGroup::name() const
{
- return valid_string(_structure->name);
+ return valid_string(config_channel_group->name);
}
vector<shared_ptr<Channel>> ChannelGroup::channels()
{
vector<shared_ptr<Channel>> result;
for (auto channel : _channels)
- result.push_back(channel->get_shared_pointer(_parent));
+ result.push_back(channel->share_owned_by(_parent));
return result;
}
Trigger::Trigger(shared_ptr<Context> context, string name) :
- UserOwned(sr_trigger_new(name.c_str())),
+ _structure(sr_trigger_new(name.c_str())),
_context(move(context))
{
for (auto stage = _structure->stages; stage; stage = stage->next)
{
vector<shared_ptr<TriggerStage>> result;
for (auto stage : _stages)
- result.push_back(stage->get_shared_pointer(this));
+ result.push_back(stage->share_owned_by(shared_from_this()));
return result;
}
{
auto stage = new TriggerStage(sr_trigger_stage_add(_structure));
_stages.push_back(stage);
- return stage->get_shared_pointer(this);
+ return stage->share_owned_by(shared_from_this());
}
-TriggerStage::TriggerStage(struct sr_trigger_stage *structure) :
- ParentOwned(structure)
+TriggerStage::TriggerStage(struct sr_trigger_stage *structure) :
+ _structure(structure)
{
}
{
vector<shared_ptr<TriggerMatch>> result;
for (auto match : _matches)
- result.push_back(match->get_shared_pointer(this));
+ result.push_back(match->share_owned_by(shared_from_this()));
return result;
}
TriggerMatch::TriggerMatch(struct sr_trigger_match *structure,
shared_ptr<Channel> channel) :
- ParentOwned(structure),
+ _structure(structure),
_channel(move(channel))
{
}
}
SessionDevice::SessionDevice(struct sr_dev_inst *structure) :
- ParentOwned(structure),
Device(structure)
{
}
}
Session::Session(shared_ptr<Context> context) :
- UserOwned(_structure),
+ _structure(nullptr),
_context(move(context))
{
check(sr_session_new(_context->_structure, &_structure));
}
Session::Session(shared_ptr<Context> context, string filename) :
- UserOwned(_structure),
+ _structure(nullptr),
_context(move(context)),
_filename(move(filename))
{
{
if (_owned_devices.count(sdi))
return static_pointer_cast<Device>(
- _owned_devices[sdi]->get_shared_pointer(this));
+ _owned_devices[sdi]->share_owned_by(shared_from_this()));
else if (_other_devices.count(sdi))
return _other_devices[sdi];
else
Packet::Packet(shared_ptr<Device> device,
const struct sr_datafeed_packet *structure) :
- UserOwned(structure),
+ _structure(structure),
_device(move(device))
{
switch (structure->type)
shared_ptr<PacketPayload> Packet::payload()
{
if (_payload)
- return _payload->get_shared_pointer(this);
+ return _payload->share_owned_by(shared_from_this());
else
throw Error(SR_ERR_NA);
}
}
Header::Header(const struct sr_datafeed_header *structure) :
- ParentOwned(structure),
- PacketPayload()
+ PacketPayload(),
+ _structure(structure)
{
}
{
}
-shared_ptr<PacketPayload> Header::get_shared_pointer(Packet *_parent)
+shared_ptr<PacketPayload> Header::share_owned_by(shared_ptr<Packet> _parent)
{
return static_pointer_cast<PacketPayload>(
- ParentOwned::get_shared_pointer(_parent));
+ ParentOwned::share_owned_by(_parent));
}
int Header::feed_version() const
}
Meta::Meta(const struct sr_datafeed_meta *structure) :
- ParentOwned(structure),
- PacketPayload()
+ PacketPayload(),
+ _structure(structure)
{
}
{
}
-shared_ptr<PacketPayload> Meta::get_shared_pointer(Packet *_parent)
+shared_ptr<PacketPayload> Meta::share_owned_by(shared_ptr<Packet> _parent)
{
return static_pointer_cast<PacketPayload>(
- ParentOwned::get_shared_pointer(_parent));
+ ParentOwned::share_owned_by(_parent));
}
map<const ConfigKey *, Glib::VariantBase> Meta::config() const
}
Logic::Logic(const struct sr_datafeed_logic *structure) :
- ParentOwned(structure),
- PacketPayload()
+ PacketPayload(),
+ _structure(structure)
{
}
{
}
-shared_ptr<PacketPayload> Logic::get_shared_pointer(Packet *_parent)
+shared_ptr<PacketPayload> Logic::share_owned_by(shared_ptr<Packet> _parent)
{
return static_pointer_cast<PacketPayload>(
- ParentOwned::get_shared_pointer(_parent));
+ ParentOwned::share_owned_by(_parent));
}
void *Logic::data_pointer()
}
Analog::Analog(const struct sr_datafeed_analog *structure) :
- ParentOwned(structure),
- PacketPayload()
+ PacketPayload(),
+ _structure(structure)
{
}
{
}
-shared_ptr<PacketPayload> Analog::get_shared_pointer(Packet *_parent)
+shared_ptr<PacketPayload> Analog::share_owned_by(shared_ptr<Packet> _parent)
{
return static_pointer_cast<PacketPayload>(
- ParentOwned::get_shared_pointer(_parent));
+ ParentOwned::share_owned_by(_parent));
}
void *Analog::data_pointer()
}
InputFormat::InputFormat(const struct sr_input_module *structure) :
- ParentOwned(structure)
+ _structure(structure)
{
}
auto input = sr_input_new(_structure, map_to_hash_variant(options));
if (!input)
throw Error(SR_ERR_ARG);
- return shared_ptr<Input>(
- new Input(_parent->shared_from_this(), input), Input::Deleter());
+ return shared_ptr<Input>(new Input(_parent, input), Input::Deleter());
}
Input::Input(shared_ptr<Context> context, const struct sr_input *structure) :
- UserOwned(structure),
+ _structure(structure),
_context(move(context)),
_device(nullptr)
{
_device = new InputDevice(shared_from_this(), sdi);
}
- return _device->get_shared_pointer(shared_from_this());
+ return _device->share_owned_by(shared_from_this());
}
void Input::send(void *data, size_t length)
InputDevice::InputDevice(shared_ptr<Input> input,
struct sr_dev_inst *structure) :
- ParentOwned(structure),
Device(structure),
_input(move(input))
{
Option::Option(const struct sr_option *structure,
shared_ptr<const struct sr_option *> structure_array) :
- UserOwned(structure),
+ _structure(structure),
_structure_array(move(structure_array))
{
}
}
OutputFormat::OutputFormat(const struct sr_output_module *structure) :
- ParentOwned(structure)
+ _structure(structure)
{
}
Output::Output(shared_ptr<OutputFormat> format,
shared_ptr<Device> device, const map<string, Glib::VariantBase> &options) :
- UserOwned(sr_output_new(format->_structure,
+ _structure(sr_output_new(format->_structure,
map_to_hash_variant(options), device->_structure, nullptr)),
_format(move(format)),
_device(move(device)),
Output::Output(string filename, shared_ptr<OutputFormat> format,
shared_ptr<Device> device, const map<string, Glib::VariantBase> &options) :
- UserOwned(sr_output_new(format->_structure,
+ _structure(sr_output_new(format->_structure,
map_to_hash_variant(options), device->_structure, filename.c_str())),
_format(move(format)),
_device(move(device)),