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

name[RW]

Public Instance Methods

each_task() { |task| ... } click to toggle source

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_one_running(*names) click to toggle source

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
get(name,options=Hash.new) click to toggle source

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
ior(name) click to toggle source

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
names() click to toggle source

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
reachable?() click to toggle source

Checks if the name service is reachable.

@return [Boolean]

# File lib/orocos/name_service.rb, line 140
def reachable?
    validate
    true
rescue
    false
end
same_namespace?(name) click to toggle source

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
task_reachable?(name) click to toggle source

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
validate() click to toggle source

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