class Orocos::NameService
This name service abstracts all underlying name services. By default there is one global instance accessible via {Orocos.name_service} which has by default one {Orocos::CORBA::NameService} instance as underlying name service.
@author Alexander Duda
@see Orocos::CORBA.name_service @see Orocos::CORBA::NameService @see Orocos::Avahi::NameService
Attributes
@return [Array] The array with all underlying name services. The order implies the search order.
Public Class Methods
Returns a new instance of NameService
@param [NameServiceBase,Array<NameServiceBase>] #name_services The initial underlying name services @return [NameService]
# File lib/orocos/name_service.rb, line 229 def initialize(*name_services) @name_services = name_services end
Public Instance Methods
Adds a name service.
@param [NameServiceBase] name_service The name service.
# File lib/orocos/name_service.rb, line 256 def <<(name_service) add(name_service) end
(see <<)
# File lib/orocos/name_service.rb, line 269 def add(name_service) return if @name_services.include? name_service @name_services << name_service end
Adds a name service to the top of {#name_services}
@param [NameServiceBase] name_service The name service.
# File lib/orocos/name_service.rb, line 263 def add_front(name_service) return if @name_services.include? name_service @name_services.insert(0,name_service) end
Calls cleanup on all underlying name services which support cleanup
# File lib/orocos/name_service.rb, line 352 def cleanup name_services.each do |service| service.cleanup end end
Removes all underlying name services
# File lib/orocos/name_service.rb, line 364 def clear @name_services.clear end
remove the service from the list of services
# File lib/orocos/name_service.rb, line 359 def delete service @name_services.delete service end
Enumerates the name services registered on this global name service
@yield [TaskContext]
# File lib/orocos/name_service.rb, line 243 def each(&block) @name_services.each(&block) end
Finds an underlying name service of the given class
@param [class] klass the class
# File lib/orocos/name_service.rb, line 289 def find(klass) @name_services.find do |service| true if service.is_a? klass end end
(see Orocos::NameServiceBase#get)
# File lib/orocos/name_service.rb, line 311 def get(name,options = Hash.new) name_services.each do |service| begin if service.same_namespace?(name) task_context = service.get(name,options) return task_context if task_context end rescue Orocos::NotFound end end raise Orocos::NotFound, error_message(name) end
Checks if an underlying name service is of the given class
@param [class] klass the class @return [Boolean]
# File lib/orocos/name_service.rb, line 299 def include?(klass) !!find(klass) end
Checks if there is at least one underlying name service
@return [Boolean]
# File lib/orocos/name_service.rb, line 306 def initialized? !@name_services.empty? end
(see Orocos::NameServiceBase#ior)
# File lib/orocos/name_service.rb, line 325 def ior(name) verify_same_namespace(name) name_services.each do |service| next if !service.respond_to?(:ior) begin if service.same_namespace?(name) return service.ior(name) end rescue Orocos::NotFound end end raise Orocos::NotFound, error_message(name) end
(see Orocos::NameServiceBase#names)
# File lib/orocos/name_service.rb, line 340 def names names = name_services.collect do |service| begin service.names rescue Orocos::CORBAError,Orocos::CORBA::ComError [] end end names.flatten.uniq end
Remove a name service from the set of resolvants
@param [NameServiceBase] name_service the name service object @return [true,false] true if the name service was registered, false
otherwise
# File lib/orocos/name_service.rb, line 279 def remove(name_service) if @name_services.include? name_service @name_services.delete name_service true end end
(see Orocos::Namespace#same_namespace?)
# File lib/orocos/name_service.rb, line 234 def same_namespace?(name) name_services.any? do |service| service.same_namespace?(name) end end