class Orocos::NameServiceBase
Base class for all Orocos name services. An orocos name service is used to find local and remote Orocos Tasks based on their name and namespace.
@author Alexander Duda
Attributes
Public Instance Methods
Calls the given code block for all reachable {TaskContext} known by the name service.
@yield [TaskContext] code block which is called for each TaskContext
# File lib/orocos/name_service.rb, line 170 def each_task return enum_for(__method__) if !block_given? names.each do |name| task = begin get(name) rescue Orocos::NotFound end yield(task) if task end end
Find exactly one running tasks from the provided names.
@param [String,Array<String>] names the names @return [Orocos::TaskContext] @raise [RuntimeError] if none of the tasks are running, reachable or more than one of them is running.
# File lib/orocos/name_service.rb, line 186 def find_one_running(*names) candidates = names.map do |name| begin get name rescue Orocos::NotFound end end.compact if candidates.empty? raise Orocos::NotFound, "cannot find any tasks matching #{names.join(", ")}" end running_candidates = candidates.find_all(&:running?) if running_candidates.empty? raise Orocos::NotFound, "none of #{names.join(", ")} are running" elsif running_candidates.size > 1 raise Orocos::NotFound, "multiple candidates are running: #{running_candidates.map(&:name)}" else running_candidates.first end end
Gets an handle to a local/remote Orocos Task having the given name.
@param [String] name the name of the {TaskContext} @param [Hash] options the options used by the name service to find the {TaskContext} @option options [String] :name Overwrites The real name of the task @option options [Orocos::Process] :process The process supporting the task
@return [Orocos::TaskContext,Orocos::Log::TaskContext] @raise [Orocos::NotFound] if no {TaskContext} can be found
@see Orocos::NameService
# File lib/orocos/name_service.rb, line 98 def get(name,options=Hash.new) raise NotImplementedError end
Gets the IOR for the given Orocos Task having the given name.
@param [String] name the name of the TaskContext @return [String] @raise [Orocos::NotFound] if the TaskContext cannot be found
# File lib/orocos/name_service.rb, line 112 def ior(name) raise NotImplementedError end
Returns all Orocos Task names known by the name service inclusive the namespace of the NameService instance.
@return [Array<String>]
# File lib/orocos/name_service.rb, line 120 def names raise NotImplementedError end
Checks if the name service is reachable.
@return [Boolean]
# File lib/orocos/name_service.rb, line 140 def reachable? validate true rescue false end
True if name is a valid name inside this service's
namespace
# File lib/orocos/name_service.rb, line 125 def same_namespace?(name) true end
Checks if a {TaskContext} with the given name is reachable.
@param [String] name the name if the TaskContext @return [Boolean]
# File lib/orocos/name_service.rb, line 80 def task_reachable?(name) get(name) true rescue Orocos::NotFound false end
Checks if the name service is reachable if not it raises a ComError.
@return [nil] @raise [Orocos::ComError]
# File lib/orocos/name_service.rb, line 134 def validate end