Class: Orocos::RemoteProcesses::Loader

Inherits:
OroGen::Loaders::Base
  • Object
show all
Defined in:
lib/orocos/remote_processes/loader.rb

Overview

A loader object that allows to load models from a remote process server

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, root_loader = self) ⇒ Loader

Returns a new instance of Loader



12
13
14
15
16
17
18
# File 'lib/orocos/remote_processes/loader.rb', line 12

def initialize(client, root_loader = self)
    @client = client
    @available_projects,
        @available_deployments,
        @available_typekits = client.info
    super(root_loader)
end

Instance Attribute Details

#available_deploymentsObject (readonly)

Returns the value of attribute available_deployments



9
10
11
# File 'lib/orocos/remote_processes/loader.rb', line 9

def available_deployments
  @available_deployments
end

#available_projectsObject (readonly)

Returns the value of attribute available_projects



8
9
10
# File 'lib/orocos/remote_processes/loader.rb', line 8

def available_projects
  @available_projects
end

#available_typekitsObject (readonly)

Returns the value of attribute available_typekits



10
11
12
# File 'lib/orocos/remote_processes/loader.rb', line 10

def available_typekits
  @available_typekits
end

#clientObject (readonly)

Returns the value of attribute client



6
7
8
# File 'lib/orocos/remote_processes/loader.rb', line 6

def client
  @client
end

Instance Method Details

#each_available_project_name(&block) ⇒ Object



84
85
86
# File 'lib/orocos/remote_processes/loader.rb', line 84

def each_available_project_name(&block)
    return available_projects.each_key(&block)
end

#find_project_from_deployment_name(name) ⇒ String?

Returns the project that defines the given deployment

Parameters:

  • deployment_name (String)

    the deployment we are looking for

Returns:

  • (String, nil)


76
77
78
79
80
81
82
# File 'lib/orocos/remote_processes/loader.rb', line 76

def find_project_from_deployment_name(name)
    if project_name = available_deployments[name]
        return project_name
    else 
        raise OroGen::DeploymentModelNotFound, "#{client} has no deployment called #{name}"
    end
end

#has_deployment?(name) ⇒ Boolean

Tests if a deployment with that name exists

Parameters:

  • name (String)

    the deployment name

Returns:

  • (Boolean)


69
70
71
# File 'lib/orocos/remote_processes/loader.rb', line 69

def has_deployment?(name)
    available_deployments.has_key?(name)
end

#has_project?(name) ⇒ Boolean

Tests if a project with that name exists

Parameters:

  • name (String)

    the project name

Returns:

  • (Boolean)


53
54
55
# File 'lib/orocos/remote_processes/loader.rb', line 53

def has_project?(name)
    available_projects.has_key?(name)
end

#has_typekit?(name) ⇒ Boolean

Tests if a typekit with that name exists

Parameters:

  • name (String)

    the typekit name

Returns:

  • (Boolean)


61
62
63
# File 'lib/orocos/remote_processes/loader.rb', line 61

def has_typekit?(name)
    available_typekits.has_key?(name)
end

#project_model_text_from_name(name) ⇒ (String,String)

Returns the textual representation of a project model

Parameters:

  • the (String)

    project name

Returns:

  • ((String,String))

    the model as text, as well as a path to the model file (or nil if there is no such file)

Raises:

  • (OroGen::NotFound)

    if there is no project with that name.



27
28
29
30
31
32
33
# File 'lib/orocos/remote_processes/loader.rb', line 27

def project_model_text_from_name(name)
    if text = available_projects[name]
        return text
    else
        raise OroGen::ProjectNotFound, "#{client} has no project called #{name}, available projects: #{available_projects.keys.sort.join(", ")}"
    end
end

#typekit_model_text_from_name(name) ⇒ (String,String)

Returns the textual representation of a typekit

Parameters:

  • the (String)

    typekit name

Returns:

  • ((String,String))

    the typekit registry as XML and the typekit's typelist

Raises:

  • (OroGen::NotFound)

    if there is no typekit with that name



41
42
43
44
45
46
47
# File 'lib/orocos/remote_processes/loader.rb', line 41

def typekit_model_text_from_name(name)
    if text = available_typekits[name]
        return *text
    else 
        raise OroGen::TypekitNotFound, "#{client} has no typekit called #{name}"
    end
end