Class: Roby::DistributedObject
- Defined in:
- lib/roby/distributed_object.rb,
lib/roby.rb
Overview
Base class for most plan-related objects (Plan, PlanObject, …)
This class contains the information and manipulation attributes that are at the core of Roby object management. In particular, it maintains the distributed object information (needed in multi-Roby setups).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#local_owner_id ⇒ Object
readonly
The ID of the local process.
-
#owners ⇒ Object
readonly
The set of Peer objects which own this object.
Instance Method Summary collapse
- #add_owner(owner) ⇒ Object
- #clear_owners ⇒ Object
-
#initialize ⇒ DistributedObject
constructor
:nodoc:.
-
#initialize_copy(old) ⇒ Object
:nodoc:.
-
#owned_by?(peer_id) ⇒ Boolean
True if the given peer owns this object.
- #remove_owner(owner) ⇒ Object
Constructor Details
#initialize ⇒ DistributedObject
:nodoc:
41 42 43 44 |
# File 'lib/roby/distributed_object.rb', line 41 def initialize # :nodoc: @owners = Array.new @self_owned = true end |
Instance Attribute Details
#local_owner_id ⇒ Object (readonly)
The ID of the local process
35 36 37 |
# File 'lib/roby/distributed_object.rb', line 35 def local_owner_id @local_owner_id end |
#owners ⇒ Object (readonly)
The set of Peer objects which own this object
37 38 39 |
# File 'lib/roby/distributed_object.rb', line 37 def owners @owners end |
Instance Method Details
#add_owner(owner) ⇒ Object
51 52 53 54 |
# File 'lib/roby/distributed_object.rb', line 51 def add_owner(owner) @owners << owner @self_owned = @owners.include?(local_owner_id) end |
#clear_owners ⇒ Object
70 71 72 73 |
# File 'lib/roby/distributed_object.rb', line 70 def clear_owners owners.clear @self_owned = true end |
#initialize_copy(old) ⇒ Object
:nodoc:
46 47 48 49 |
# File 'lib/roby/distributed_object.rb', line 46 def initialize_copy(old) # :nodoc: super @owners = Array.new end |
#owned_by?(peer_id) ⇒ Boolean
True if the given peer owns this object
62 63 64 65 66 67 68 |
# File 'lib/roby/distributed_object.rb', line 62 def owned_by?(peer_id) if peer_id == local_owner_id self_owned? else owners.include?(peer_id) end end |
#remove_owner(owner) ⇒ Object
56 57 58 59 |
# File 'lib/roby/distributed_object.rb', line 56 def remove_owner(owner) @owners.delete(owner) @self_owned = @owners.empty? || @owners.include?(local_owner_id) end |