Class: Roby::DistributedObject

Inherits:
Object
  • Object
show all
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

Plan, PlanObject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDistributedObject

:nodoc:



47
48
49
50
# File 'lib/roby/distributed_object.rb', line 47

def initialize # :nodoc:
    @owners = []
    @self_owned = true
end

Instance Attribute Details

#local_owner_idObject (readonly)

The ID of the local process



41
42
43
# File 'lib/roby/distributed_object.rb', line 41

def local_owner_id
  @local_owner_id
end

#ownersObject (readonly)

The set of Peer objects which own this object



43
44
45
# File 'lib/roby/distributed_object.rb', line 43

def owners
  @owners
end

Instance Method Details

#add_owner(owner) ⇒ Object



57
58
59
60
# File 'lib/roby/distributed_object.rb', line 57

def add_owner(owner)
    @owners << owner
    @self_owned = @owners.include?(local_owner_id)
end

#clear_ownersObject



76
77
78
79
# File 'lib/roby/distributed_object.rb', line 76

def clear_owners
    owners.clear
    @self_owned = true
end

#initialize_copy(old) ⇒ Object

:nodoc:



52
53
54
55
# File 'lib/roby/distributed_object.rb', line 52

def initialize_copy(old) # :nodoc:
    super
    @owners = []
end

#owned_by?(peer_id) ⇒ Boolean

True if the given peer owns this object

Returns:

  • (Boolean)


68
69
70
71
72
73
74
# File 'lib/roby/distributed_object.rb', line 68

def owned_by?(peer_id)
    if peer_id == local_owner_id
        self_owned?
    else
        owners.include?(peer_id)
    end
end

#remove_owner(owner) ⇒ Object



62
63
64
65
# File 'lib/roby/distributed_object.rb', line 62

def remove_owner(owner)
    @owners.delete(owner)
    @self_owned = @owners.empty? || @owners.include?(local_owner_id)
end