From: Daniel Elstner Date: Sun, 11 Oct 2015 15:11:37 +0000 (+0200) Subject: C++: Rename get_shared_pointer() to share_owned_by() X-Git-Tag: libsigrok-0.4.0~170 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b6ab954d67b584af662323ae79ae6da0fbd3a588;p=libsigrok.git C++: Rename get_shared_pointer() to share_owned_by() This makes it clearer that this method assigns the parent (owner) reference. --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index 2bd25534..8efd103a 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -159,7 +159,7 @@ map> Context::drivers() { auto name = entry.first; auto driver = entry.second; - result[name] = driver->get_shared_pointer(shared_from_this()); + result[name] = driver->share_owned_by(shared_from_this()); } return result; } @@ -171,7 +171,7 @@ map> Context::input_formats() { auto name = entry.first; auto input_format = entry.second; - result[name] = input_format->get_shared_pointer(shared_from_this()); + result[name] = input_format->share_owned_by(shared_from_this()); } return result; } @@ -183,7 +183,7 @@ map> Context::output_formats() { auto name = entry.first; auto output_format = entry.second; - result[name] = output_format->get_shared_pointer(shared_from_this()); + result[name] = output_format->share_owned_by(shared_from_this()); } return result; } @@ -603,14 +603,14 @@ vector> Device::channels() vector> result; for (auto channel = sr_dev_inst_channels_get(_structure); channel; channel = channel->next) { auto *const ch = static_cast(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 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> @@ -621,7 +621,7 @@ Device::channel_groups() { 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; } @@ -749,7 +749,7 @@ vector> ChannelGroup::channels() { vector> result; for (auto channel : _channels) - result.push_back(channel->get_shared_pointer(_parent)); + result.push_back(channel->share_owned_by(_parent)); return result; } @@ -779,7 +779,7 @@ vector> Trigger::stages() { vector> result; for (auto stage : _stages) - result.push_back(stage->get_shared_pointer(shared_from_this())); + result.push_back(stage->share_owned_by(shared_from_this())); return result; } @@ -787,7 +787,7 @@ shared_ptr Trigger::add_stage() { auto stage = new TriggerStage(sr_trigger_stage_add(_structure)); _stages.push_back(stage); - return stage->get_shared_pointer(shared_from_this()); + return stage->share_owned_by(shared_from_this()); } TriggerStage::TriggerStage(struct sr_trigger_stage *structure) : @@ -810,7 +810,7 @@ vector> TriggerStage::matches() { vector> result; for (auto match : _matches) - result.push_back(match->get_shared_pointer(shared_from_this())); + result.push_back(match->share_owned_by(shared_from_this())); return result; } @@ -925,7 +925,7 @@ shared_ptr Session::get_device(const struct sr_dev_inst *sdi) { if (_owned_devices.count(sdi)) return static_pointer_cast( - _owned_devices[sdi]->get_shared_pointer(shared_from_this())); + _owned_devices[sdi]->share_owned_by(shared_from_this())); else if (_other_devices.count(sdi)) return _other_devices[sdi]; else @@ -1092,7 +1092,7 @@ const PacketType *Packet::type() const shared_ptr Packet::payload() { if (_payload) - return _payload->get_shared_pointer(shared_from_this()); + return _payload->share_owned_by(shared_from_this()); else throw Error(SR_ERR_NA); } @@ -1115,10 +1115,10 @@ Header::~Header() { } -shared_ptr Header::get_shared_pointer(shared_ptr _parent) +shared_ptr Header::share_owned_by(shared_ptr _parent) { return static_pointer_cast( - ParentOwned::get_shared_pointer(_parent)); + ParentOwned::share_owned_by(_parent)); } int Header::feed_version() const @@ -1143,10 +1143,10 @@ Meta::~Meta() { } -shared_ptr Meta::get_shared_pointer(shared_ptr _parent) +shared_ptr Meta::share_owned_by(shared_ptr _parent) { return static_pointer_cast( - ParentOwned::get_shared_pointer(_parent)); + ParentOwned::share_owned_by(_parent)); } map Meta::config() const @@ -1169,10 +1169,10 @@ Logic::~Logic() { } -shared_ptr Logic::get_shared_pointer(shared_ptr _parent) +shared_ptr Logic::share_owned_by(shared_ptr _parent) { return static_pointer_cast( - ParentOwned::get_shared_pointer(_parent)); + ParentOwned::share_owned_by(_parent)); } void *Logic::data_pointer() @@ -1200,10 +1200,10 @@ Analog::~Analog() { } -shared_ptr Analog::get_shared_pointer(shared_ptr _parent) +shared_ptr Analog::share_owned_by(shared_ptr _parent) { return static_pointer_cast( - ParentOwned::get_shared_pointer(_parent)); + ParentOwned::share_owned_by(_parent)); } void *Analog::data_pointer() @@ -1310,7 +1310,7 @@ shared_ptr Input::device() _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) diff --git a/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp b/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp index 38b71a6d..f8e0bf4b 100644 --- a/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp +++ b/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp @@ -178,7 +178,7 @@ protected: return shared; } - shared_ptr get_shared_pointer(shared_ptr parent) + shared_ptr share_owned_by(shared_ptr parent) { if (!parent) throw Error(SR_ERR_BUG); @@ -708,7 +708,7 @@ protected: PacketPayload(); virtual ~PacketPayload() = 0; private: - virtual shared_ptr get_shared_pointer(shared_ptr parent) = 0; + virtual shared_ptr share_owned_by(shared_ptr parent) = 0; /** Deleter needed to allow shared_ptr use with protected destructor. */ class Deleter @@ -734,7 +734,7 @@ public: private: explicit Header(const struct sr_datafeed_header *structure); ~Header(); - shared_ptr get_shared_pointer(shared_ptr parent); + shared_ptr share_owned_by(shared_ptr parent); friend class Packet; }; @@ -749,7 +749,7 @@ public: private: explicit Meta(const struct sr_datafeed_meta *structure); ~Meta(); - shared_ptr get_shared_pointer(shared_ptr parent); + shared_ptr share_owned_by(shared_ptr parent); map _config; friend class Packet; }; @@ -769,7 +769,7 @@ public: private: explicit Logic(const struct sr_datafeed_logic *structure); ~Logic(); - shared_ptr get_shared_pointer(shared_ptr parent); + shared_ptr share_owned_by(shared_ptr parent); friend class Packet; }; @@ -794,7 +794,7 @@ public: private: explicit Analog(const struct sr_datafeed_analog *structure); ~Analog(); - shared_ptr get_shared_pointer(shared_ptr parent); + shared_ptr share_owned_by(shared_ptr parent); friend class Packet; };