Class: Orocos::NameService
- Inherits:
-
NameServiceBase
- Object
- NameServiceBase
- Orocos::NameService
- Includes:
- Namespace
- Defined in:
- lib/orocos/name_service.rb
Overview
This name service abstracts all underlying name services. By default there is one global instance accessible via name_service which has by default one CORBA::NameService instance as underlying name service.
Constant Summary
Constants included from Namespace
Instance Attribute Summary collapse
-
#name_services ⇒ Array
The array with all underlying name services.
Attributes inherited from NameServiceBase
Instance Method Summary collapse
-
#<<(name_service) ⇒ Object
Adds a name service.
-
#add(name_service) ⇒ Object
Adds a name service.
-
#add_front(name_service) ⇒ Object
Adds a name service to the top of #name_services.
-
#cleanup ⇒ Object
Calls cleanup on all underlying name services which support cleanup.
-
#clear ⇒ Object
Removes all underlying name services.
-
#delete(service) ⇒ Object
remove the service from the list of services.
-
#each {|TaskContext| ... } ⇒ Object
Enumerates the name services registered on this global name service.
-
#find(klass) ⇒ Object
Finds an underlying name service of the given class.
-
#get(name, options = Hash.new) ⇒ Orocos::TaskContext, Orocos::Log::TaskContext
Gets an handle to a local/remote Orocos Task having the given name.
-
#include?(klass) ⇒ Boolean
Checks if an underlying name service is of the given class.
-
#initialize(*name_services) ⇒ NameService
constructor
Returns a new instance of NameService.
-
#initialized? ⇒ Boolean
Checks if there is at least one underlying name service.
-
#ior(name) ⇒ String
Gets the IOR for the given Orocos Task having the given name.
-
#names ⇒ Array<String>
Returns all Orocos Task names known by the name service inclusive the namespace of the NameService instance.
-
#remove(name_service) ⇒ true, false
Remove a name service from the set of resolvants.
-
#same_namespace?(name) ⇒ Boolean
Checks if the given name is in the same namespace.
Methods included from Namespace
#basename, #map_to_namespace, #namespace, #split_name, split_name, validate_namespace_name, #verify_same_namespace
Methods inherited from NameServiceBase
#each_task, #find_one_running, #get_provides, #reachable?, #task_reachable?, #validate
Constructor Details
#initialize(*name_services) ⇒ NameService
Returns a new instance of NameService
229 230 231 |
# File 'lib/orocos/name_service.rb', line 229 def initialize(*name_services) @name_services = name_services end |
Instance Attribute Details
#name_services ⇒ Array
Returns The array with all underlying name services
223 224 225 |
# File 'lib/orocos/name_service.rb', line 223 def name_services @name_services end |
Instance Method Details
#<<(name_service) ⇒ Object
Adds a name service.
256 257 258 |
# File 'lib/orocos/name_service.rb', line 256 def <<(name_service) add(name_service) end |
#add(name_service) ⇒ Object
Adds a name service.
269 270 271 272 |
# File 'lib/orocos/name_service.rb', line 269 def add(name_service) return if @name_services.include? name_service @name_services << name_service end |
#add_front(name_service) ⇒ Object
Adds a name service to the top of #name_services
263 264 265 266 |
# 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 |
#cleanup ⇒ Object
Calls cleanup on all underlying name services which support cleanup
352 353 354 355 356 |
# File 'lib/orocos/name_service.rb', line 352 def cleanup name_services.each do |service| service.cleanup end end |
#clear ⇒ Object
Removes all underlying name services
364 365 366 |
# File 'lib/orocos/name_service.rb', line 364 def clear @name_services.clear end |
#delete(service) ⇒ Object
remove the service from the list of services
359 360 361 |
# File 'lib/orocos/name_service.rb', line 359 def delete service @name_services.delete service end |
#each {|TaskContext| ... } ⇒ Object
Enumerates the name services registered on this global name service
243 244 245 |
# File 'lib/orocos/name_service.rb', line 243 def each(&block) @name_services.each(&block) end |
#find(klass) ⇒ Object
Finds an underlying name service of the given class
289 290 291 292 293 |
# File 'lib/orocos/name_service.rb', line 289 def find(klass) @name_services.find do |service| true if service.is_a? klass end end |
#get(name, options = Hash.new) ⇒ Orocos::TaskContext, Orocos::Log::TaskContext
Gets an handle to a local/remote Orocos Task having the given name.
311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/orocos/name_service.rb', line 311 def get(name, = Hash.new) name_services.each do |service| begin if service.same_namespace?(name) task_context = service.get(name,) return task_context if task_context end rescue Orocos::NotFound end end raise Orocos::NotFound, (name) end |
#include?(klass) ⇒ Boolean
Checks if an underlying name service is of the given class
299 300 301 |
# File 'lib/orocos/name_service.rb', line 299 def include?(klass) !!find(klass) end |
#initialized? ⇒ Boolean
Checks if there is at least one underlying name service
306 307 308 |
# File 'lib/orocos/name_service.rb', line 306 def initialized? !@name_services.empty? end |
#ior(name) ⇒ String
Gets the IOR for the given Orocos Task having the given name.
325 326 327 328 329 330 331 332 333 334 335 336 337 |
# 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, (name) end |
#names ⇒ Array<String>
Returns all Orocos Task names known by the name service inclusive the namespace of the NameService instance.
340 341 342 343 344 345 346 347 348 349 |
# 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(name_service) ⇒ true, false
Remove a name service from the set of resolvants
279 280 281 282 283 284 |
# 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 |
#same_namespace?(name) ⇒ Boolean
Checks if the given name is in the same namespace.
234 235 236 237 238 |
# File 'lib/orocos/name_service.rb', line 234 def same_namespace?(name) name_services.any? do |service| service.same_namespace?(name) end end |