Class: Roby::TaskModelTag::DRoby

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/distributed/protocol.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tagdef) ⇒ DRoby

Returns a new instance of DRoby.



62
# File 'lib/roby/distributed/protocol.rb', line 62

def initialize(tagdef); @tagdef = tagdef end

Instance Attribute Details

#tagdefObject (readonly)

Returns the value of attribute tagdef.



61
62
63
# File 'lib/roby/distributed/protocol.rb', line 61

def tagdef
  @tagdef
end

Class Method Details

._load(str) ⇒ Object



64
# File 'lib/roby/distributed/protocol.rb', line 64

def self._load(str); DRoby.new(Marshal.load(str)) end

.local_tag(name, remote_tag) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/roby/distributed/protocol.rb', line 77

def self.local_tag(name, remote_tag)
    if !remote_tag.kind_of?(Distributed::RemoteID)
 remote_tag
    elsif local_model = TaskModelTag.remote_to_local[remote_tag]
 local_model
    else
 if name && !name.empty?
      local_model = constant(name) rescue nil
 end
 unless local_model
      local_model = Roby::TaskModelTag.new do
  define_method(:name) { name }
      end
      TaskModelTag.remote_to_local[remote_tag] = local_model
      TaskModelTag.local_to_remote[local_model] = [name, remote_tag]
      yield(local_model) if block_given?
 end
 local_model
    end
end

Instance Method Details

#==(other) ⇒ Object



98
99
100
101
# File 'lib/roby/distributed/protocol.rb', line 98

def ==(other)
    other.kind_of?(DRoby) && 
 tagdef.zip(other.tagdef).all? { |a, b| a == b }
end

#_dump(lvl) ⇒ Object



63
# File 'lib/roby/distributed/protocol.rb', line 63

def _dump(lvl); @__droby_marshalled__ ||= Marshal.dump(tagdef) end

#proxy(peer) ⇒ Object



66
67
68
69
70
71
72
73
74
75
# File 'lib/roby/distributed/protocol.rb', line 66

def proxy(peer)
    including = []
    tagdef.each do |name, remote_tag|
 tag = DRoby.local_tag(name, remote_tag) do |tag|
      including.each { |mod| tag.include mod }
 end
 including << tag
    end
    including.last
end