Class: Roby::Plan::DRoby

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

Overview

An intermediate representation of Plan objects suitable to be sent to our peers.

FIXME: It assumes that the only Plan object sent to the peers is actually the main plan of the plan manager. We must fix that.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(peer, id) ⇒ DRoby

Create a DRoby representation of a plan object with the given parameters



311
# File 'lib/roby/distributed/proxy.rb', line 311

def initialize(peer, id); @peer, @id = peer, id end

Instance Attribute Details

#idObject

The plan remote_id



308
309
310
# File 'lib/roby/distributed/proxy.rb', line 308

def id
  @id
end

#peerObject

The peer which manages this plan



306
307
308
# File 'lib/roby/distributed/proxy.rb', line 306

def peer
  @peer
end

Instance Method Details

#proxy(peer) ⇒ Object

Create a new proxy which maps the object of peer represented by this communication intermediate.



314
# File 'lib/roby/distributed/proxy.rb', line 314

def proxy(peer); peer.connection_space.plan end

#remote_siblingsObject

The set of remote siblings for that object. This is used to avoid creating proxies when not needed. See PlanObject::DRoby#remote_siblings.



321
# File 'lib/roby/distributed/proxy.rb', line 321

def remote_siblings; @remote_siblings ||= Hash[peer, id] end

#sibling_on(peer) ⇒ Object

If peer is the plan’s owner, returns #id. Otherwise, raises RemotePeerMismatch. This is used to avoid creating proxies when not needed. See BasicObject::DRoby#sibling_on.



325
326
327
328
329
# File 'lib/roby/distributed/proxy.rb', line 325

def sibling_on(peer)
    if peer.remote_id == self.peer.peer_id then id
    else raise RemotePeerMismatch, "no known sibling for #{self} on #{peer}"
    end
end

#to_sObject

:nodoc:



315
316
317
# File 'lib/roby/distributed/proxy.rb', line 315

def to_s # :nodoc:
    "#<dRoby:Plan #{id.to_s(peer)}>" 
end