class Roby::GoalModel

Representation of a level in the state model

Public Class Methods

new(state_model = nil, superclass = nil, attach_to = nil, attach_name = nil) click to toggle source
Calls superclass method
# File lib/roby/state/goal_model.rb, line 33
def initialize(state_model = nil, superclass = nil, attach_to = nil, attach_name = nil)
    super(superclass, attach_to, attach_name)

    @model = state_model
    if @model
        attach_model
    end

    global_filter do |name, value|
        if value.respond_to?(:to_goal_variable_model)
            value.to_goal_variable_model(self, name)
        else
            raise ArgumentError, "cannot set #{value} on #{name} in a goal model. Only allowed values are GoalVariableModel, and values that respond to #to_goal_variable_model"
        end
    end
end

Public Instance Methods

create_model() click to toggle source
# File lib/roby/state/goal_model.rb, line 50
def create_model
    GoalModel.new
end
create_subfield(name) click to toggle source
# File lib/roby/state/goal_model.rb, line 54
def create_subfield(name)
    superklass = if superclass then superclass.get(name) end
    supermodel = if model then model.get(name) end
    self.class.new(supermodel, superklass, self, name)
end
resolve_goals(obj, space) click to toggle source

Once the task is completely instanciated, we should be able to determine its goal

# File lib/roby/state/goal_model.rb, line 62
def resolve_goals(obj, space)
    each_member do |name, value|
        if value.respond_to?(:resolve_goals)
            value.resolve_goals(obj, space.get(name))
        else
            space.set(name, value.call(obj))
        end
    end
end