class Roby::StateModel

Representation of a level in the state model

Attributes

superclass[R]

Returns the superclass, i.e. the state model this is a refinement on

Public Class Methods

new(super_or_obj = nil, attach_to = nil, attach_name = nil) click to toggle source
Calls superclass method Roby::OpenStructModel::new
# File lib/roby/state/state_model.rb, line 45
def initialize(super_or_obj = nil, attach_to = nil, attach_name = nil)
    super(super_or_obj, attach_to, attach_name)
    global_filter do |name, value|
        if value.respond_to?(:to_state_variable_model)
            value.to_state_variable_model(self, name)
        else
            raise ArgumentError, "cannot set #{value} on #{name} in a state model. Only allowed values are StateVariableModel, and values that respond to #to_state_variable_model"
        end
    end
end

Public Instance Methods

resolve_data_sources(object, state) click to toggle source

This methods iterates over the state model, and for each state variable for which a data source model is provided, create the corresponding data source by calling resolve

# File lib/roby/state/state_model.rb, line 59
def resolve_data_sources(object, state)
    each_member do |name, field|
        if field.respond_to?(:data_source)
            state.data_sources.set(name, field.data_source.resolve(object))
        else
            field.resolve_data_sources(object, state.__get(name, true))
        end
    end
end
to_s() click to toggle source
# File lib/roby/state/state_model.rb, line 41
def to_s
    "#<StateModel:#{object_id} path=#{path.join("/")} fields=#{@members.keys.sort.join(",")}>"
end