Class: Orocos::Log::InterfaceObject
- Inherits:
-
Object
- Object
- Orocos::Log::InterfaceObject
- Defined in:
- lib/orocos/log/task_context.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The object name.
-
#orocos_type_name ⇒ Object
readonly
The underlying opaque type if #type is an intermediate type.
-
#stream ⇒ Pocolog::Datastream
readonly
The backing stream.
-
#type ⇒ Typelib::Type
readonly
The object type.
-
#type_name ⇒ Object
readonly
deprecated
Deprecated.
use #type.name instead
Instance Method Summary collapse
- #guess_object_name(stream) ⇒ Object
- #guess_orocos_type_name(stream) ⇒ Object
-
#initialize(stream) ⇒ InterfaceObject
constructor
A new instance of InterfaceObject.
Constructor Details
#initialize(stream) ⇒ InterfaceObject
Returns a new instance of InterfaceObject
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/orocos/log/task_context.rb', line 36 def initialize(stream) if !stream.respond_to?(:name) || !stream.respond_to?(:type) || !stream.respond_to?(:typename) || !stream.respond_to?(:metadata) raise ArgumentError, "cannot use #{stream} to back "\ "a #{self.class.name}" end @stream = stream @type = stream.type @type_name = stream.type.name @name = guess_object_name(stream) @orocos_type_name = guess_orocos_type_name(stream) end |
Instance Attribute Details
#name ⇒ String (readonly)
The object name
23 24 25 |
# File 'lib/orocos/log/task_context.rb', line 23 def name @name end |
#orocos_type_name ⇒ Object (readonly)
The underlying opaque type if #type is an intermediate type
34 35 36 |
# File 'lib/orocos/log/task_context.rb', line 34 def orocos_type_name @orocos_type_name end |
#stream ⇒ Pocolog::Datastream (readonly)
The backing stream
18 19 20 |
# File 'lib/orocos/log/task_context.rb', line 18 def stream @stream end |
#type ⇒ Typelib::Type (readonly)
The object type
28 29 30 |
# File 'lib/orocos/log/task_context.rb', line 28 def type @type end |
#type_name ⇒ Object (readonly)
Deprecated.
use #type.name instead
31 32 33 |
# File 'lib/orocos/log/task_context.rb', line 31 def type_name @type_name end |
Instance Method Details
#guess_object_name(stream) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/orocos/log/task_context.rb', line 50 def guess_object_name(stream) if (name = stream.["rock_task_object_name"]) return name end Log.warn "stream '#{stream.name}' has no rock_task_object_name "\ "metadata, guessing the #{self.class.name} name from the "\ "stream name" # backward compatibility if (name = stream.name.to_s.match(/\.(.*)$/)) name[1] else Log.warn "stream name '#{stream.name}' does not follow "\ "the convention TASKNAME.PORTNAME, taking it whole as "\ "the #{self.class.name} name" stream.name end end |
#guess_orocos_type_name(stream) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/orocos/log/task_context.rb', line 70 def guess_orocos_type_name(stream) = stream. || Hash.new if (name = ['rock_orocos_type_name']) return name elsif (name = ['rock_cxx_type_name']) return name end Log.warn "stream '#{stream.name}' has neither the "\ "rock_cxx_type_name nor the rock_orocos_type_name metadata set, "\ "falling back on the Typelib type's name" if (match = /^(.*)_m$/.match(stream.type.name)) match[1] else stream.type.name end end |