class Orocos::CORBA::NameService
Name service client to access the CORBA name service and retrieve an handle to registered Orocos Tasks. By default there is one global instance accessible via {Orocos::CORBA.name_service} which is also by default added to {Orocos.name_service}
The default {Orocos::CORBA.name_service} is used to register all Orocos Tasks started by the ruby instance no matter if it was removed from {Orocos.name_service} or not.
@see Orocos.name_service @author Alexander Duda
Public Class Methods
# File lib/orocos/name_service.rb, line 534 def initialize(host = "") self.ip = host end
Public Instance Methods
Bind an existing task under an alternative name
@param [TaskContext] task the task context @param [String] name the name
# File lib/orocos/name_service.rb, line 568 def bind(task, name) do_bind(task, name) end
Removes dangling references from the name service
This method removes objects that are not accessible anymore from the name service
# File lib/orocos/name_service.rb, line 656 def cleanup names = names().dup names.each do |n| begin CORBA.info "trying task context #{n}" get(n) rescue Orocos::NotFound => e deregister(n) CORBA.warn "deregistered dangling CORBA name #{n}: #{e.message}" end end end
Deregisters the given name or task from the name service.
@param [String,TaskContext] name The name or task
# File lib/orocos/name_service.rb, line 633 def deregister(name) name = if name.respond_to? :name name.name else name end verify_same_namespace(name) CORBA.refine_exceptions("corba naming service #{ip}") do do_unbind(basename(name)) end end
(see Orocos::NameServiceBase#get)
# File lib/orocos/name_service.rb, line 604 def get(name = nil, namespace: nil, process: nil, ior: nil) if ior Orocos::TaskContext.new(ior, namespace: namespace, process: process) else ns,_ = split_name(name) ns = if !ns || ns.empty? self.namespace else ns end namespace ||= (ns || "") Orocos::TaskContext.new(ior(name), namespace: namespace, process: process) end rescue ComError => e raise Orocos::NotFound, "task context #{name} is registered but cannot be reached." end
(see Orocos::NameServiceBase#ior)
# File lib/orocos/name_service.rb, line 588 def ior(name) verify_same_namespace(name) CORBA.refine_exceptions("corba naming service(#{ip})") do do_ior(basename(name)) end end
@return [String] The ip where the client tries to reach the CORBA name service
# File lib/orocos/name_service.rb, line 555 def ip do_ip end
Sets the ip address or host name where the CORBA name service is running
@param [String] host The ip address or host name
# File lib/orocos/name_service.rb, line 550 def ip=(host) reset(host) end
(see Orocos::NameServiceBase#name)
# File lib/orocos/name_service.rb, line 539 def name "CORBA:#{namespace}" end
(see Orocos::NameServiceBase#names)
# File lib/orocos/name_service.rb, line 596 def names result = CORBA.refine_exceptions("corba naming service(#{ip})") do do_task_context_names.find_all { |n| n !~ /^orocosrb_(\d+)$/ } end map_to_namespace(result) end
# File lib/orocos/name_service.rb, line 543 def namespace ip end
@return [String] The port where the client tries to reach the CORBA name service
# File lib/orocos/name_service.rb, line 560 def port do_port end
Registers the IOR of the given {Orocos::TaskContext} on the CORBA name service.
@param [Orocos::TaskContext] task The task. @param [String] name The name which is used to register the task.
# File lib/orocos/name_service.rb, line 625 def register(task,name=task.name) verify_same_namespace(name) do_bind(task,basename(name)) end
The async-access object for this name service @param (see Orocos::Async::CORBA::NameService#initialize) @return [Orocos::Async::CORBA::NameService]
# File lib/orocos/name_service.rb, line 575 def to_async(reconnect: true) Orocos::Async::CORBA::NameService.new(ip, reconnect: reconnect) end
(see Orocos::NameServiceBase#validate)
# File lib/orocos/name_service.rb, line 646 def validate CORBA.refine_exceptions("corba naming service #{ip}") do do_validate end end