Module: Roby::Models::PlanObject

Extended by:
MetaRuby::Attributes
Includes:
MetaRuby::ModelAsClass, Transaction::Proxying::Cache
Included in:
PlanObject
Defined in:
lib/roby/models/plan_object.rb

Instance Attribute Summary

Attributes included from Transaction::Proxying::Cache

#transaction_forwarder_module, #transaction_proxy_module

Instance Method Summary collapse

Instance Method Details

#child_plan_object(attribute) ⇒ Object

This class method sets up the enclosing class as a child object, with the root object being returned by the given attribute. Task event generators are for instance defined by

class TaskEventGenerator < EventGenerator
    # The task this generator belongs to
    attr_reader :task

    child_plan_object :task
end


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/roby/models/plan_object.rb', line 44

def child_plan_object(attribute)
    class_eval <<-EOD, __FILE__, __LINE__+1
    def root_object; #{attribute} end
    def root_object?; false end
    def owners; #{attribute}.owners end
    def distribute?; #{attribute}.distribute? end
    def plan; #{attribute}.plan end
    def executable?; #{attribute}.executable? end

    def subscribed?; #{attribute}.subscribed? end
    def updated?; #{attribute}.updated? end
    def updated_by?(peer); #{attribute}.updated_by?(peer) end
    def update_on?(peer); #{attribute}.update_on?(peer) end
    def updated_peers; #{attribute}.updated_peers end
    def remotely_useful?; #{attribute}.remotely_useful? end

    def forget_peer(peer)
        remove_sibling_for(peer)
    end
    def sibling_of(remote_object, peer)
        if !distribute?
            raise ArgumentError, "#{self} is local only"
        end

        add_sibling_for(peer, remote_object)
    end

    private :plan=
    private :executable=
    EOD
end

#finalization_handlerArray<UnboundMethod>

Returns set of finalization handlers defined at the model level.

Returns:

  • (Array<UnboundMethod>)

    set of finalization handlers defined at the model level

See Also:



11
# File 'lib/roby/models/plan_object.rb', line 11

inherited_attribute(:finalization_handler, :finalization_handlers) { Array.new }

#matchObject



77
78
79
# File 'lib/roby/models/plan_object.rb', line 77

def match
    Queries::PlanObjectMatcher.new.with_model(self)
end

#when_finalized(&block) ⇒ void

This method returns an undefined value.

Adds a model-level finalization handler, i.e. a handler that will be called on every instance of the class

The block is called in the context of the task that got finalized (i.e. in the block, self is this task)



20
21
22
23
24
# File 'lib/roby/models/plan_object.rb', line 20

def when_finalized(&block)
    method_name = "finalization_handler_#{block.object_id}"
    define_method(method_name, &block)
    finalization_handlers << instance_method(method_name)
end