Class: Orocos::Async::NameService
- Inherits:
-
NameServiceBase
- Object
- ObjectBase
- NameServiceBase
- Orocos::Async::NameService
- Defined in:
- lib/orocos/async/name_service.rb
Constant Summary
Constants included from Namespace
Instance Attribute Summary
Attributes inherited from NameServiceBase
Attributes included from ObjectBase::Periodic::ClassMethods
Attributes inherited from ObjectBase
#emitting, #event_loop, #name, #options, #pending_adds
Instance Method Summary collapse
-
#add(name_service) ⇒ Object
Emits the name_service_added event.
-
#add_front(name_service) ⇒ Object
Emits the name_service_added event.
-
#add_listener(listener) ⇒ Object
Overloaded to emit the name_service_added event for already registered name services.
- #clear ⇒ Object
-
#initialize(*name_services) ⇒ NameService
constructor
A new instance of NameService.
- #proxy(name, options = Hash.new) ⇒ Object
-
#remove(name_service) ⇒ Object
Emits the name_service_removed event.
Methods inherited from NameServiceBase
#on_task_added, #really_add_listener, #remove_listener
Methods included from Namespace
#basename, #map_to_namespace, #namespace, #namespace=, #same_namespace?, #split_name, split_name, validate_namespace_name, #verify_same_namespace
Methods included from ObjectBase::Periodic
#default_period, #period, #period=
Methods inherited from ObjectBase
define_event, define_events, #disable_emitting, #event, event_names, #event_names, #invalidate_delegator!, #listener?, #listeners, #number_of_listeners, #on_event, #proxy_event, #reachable!, #reachable?, #really_add_listener, #remove_all_listeners, #remove_listener, #remove_proxy_event, #unreachable!, #valid_delegator?, valid_event?, #valid_event?, validate_event, #validate_event, #wait
Constructor Details
#initialize(*name_services) ⇒ NameService
Returns a new instance of NameService
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/orocos/async/name_service.rb', line 134 def initialize(*name_services) = if name_services.last.is_a? Hash name_services.pop else Hash.new end name_services = name_services.map { |ns| ns.to_async } name_service = Orocos::NameService.new *name_services super(name_service,) end |
Instance Method Details
#add(name_service) ⇒ Object
Emits the name_service_added event
175 176 177 178 179 |
# File 'lib/orocos/async/name_service.rb', line 175 def add(name_service) name_service = name_service.to_async orig_add(name_service) event :name_service_added,name_service end |
#add_front(name_service) ⇒ Object
Emits the name_service_added event
184 185 186 187 188 |
# File 'lib/orocos/async/name_service.rb', line 184 def add_front(name_service) name_service = name_service.to_async orig_add_front(name_service) event :name_service_added,name_service end |
#add_listener(listener) ⇒ Object
Overloaded to emit the name_service_added event for already registered name services
160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/orocos/async/name_service.rb', line 160 def add_listener(listener) if listener.event == :name_service_added services = name_services.dup event_loop.once do services.each do |ns| listener.call ns end end end super end |
#clear ⇒ Object
145 146 147 148 |
# File 'lib/orocos/async/name_service.rb', line 145 def clear task_context_proxies.clear orig_clear end |
#proxy(name, options = Hash.new) ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/orocos/async/name_service.rb', line 150 def proxy(name, = Hash.new) if(name_services.empty?) Vizkit.error "Orocos is not initialized!" unless Orocos.initialized? raise "No name service available." end super end |
#remove(name_service) ⇒ Object
Emits the name_service_removed event
193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/orocos/async/name_service.rb', line 193 def remove(name_service) removed = false name_services.delete_if do |ns| if name_service == ns || ns.delegator_obj == ns true end end if removed event :name_service_removed,name_service true end end |