Class: Orocos::Async::Local::NameService

Inherits:
NameServiceBase show all
Extended by:
Utilrb::EventLoop::Forwardable
Defined in:
lib/orocos/async/name_service.rb

Constant Summary

Constants included from Namespace

Namespace::DELIMATOR

Instance Attribute Summary

Attributes inherited from NameServiceBase

#task_context_proxies

Attributes included from ObjectBase::Periodic::ClassMethods

#default_period

Attributes inherited from ObjectBase

#emitting, #event_loop, #name, #options, #pending_adds

Instance Method Summary collapse

Methods inherited from NameServiceBase

#on_task_added, #proxy, #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

#add_listener, 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(options = Hash.new) ⇒ NameService

Returns a new instance of NameService



222
223
224
225
226
227
228
# File 'lib/orocos/async/name_service.rb', line 222

def initialize(options = Hash.new)
    options,other_options = Kernel.filter_options options,
        :tasks => Array.new

    name_service = Orocos::Local::NameService.new options[:tasks]
    super(name_service,other_options)
end

Instance Method Details

#get(name, options = Hash.new, &block) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/orocos/async/name_service.rb', line 230

def get(name,options=Hash.new,&block)
    async_options,other_options = Kernel.filter_options options,
        :sync_key => nil,
        :raise => nil,
        :event_loop => @event_loop,
        :period => nil,
        :wait => nil

    if block
        p = proc do |task,error|
            task = task.to_async(async_options) unless error
            if block.arity == 2
                block.call task,error
            elsif !error
                block.call task
            end
        end
        orig_get name,other_options,&p
    else
        task = orig_get name,other_options
        task.to_async(async_options)
    end
end