Module: Roby::Planning::Library
- Includes:
- Tools
- Defined in:
- lib/roby/planning/model.rb
Overview
A planning Library is only a way to gather a set of planning methods. It is created by
module MyLibrary
planning_library
method(:bla) do
end
end
or
my_library = Roby::Planning::Library.new do
method(:bla) do end
end
It is then used by simply including the library in another library or in a Planner class
module AnotherLibrary
include MyLibrary
end
class MyPlanner < Planner
include AnotherLibrary
end
Alternatively, you can use Planner::use and Library::use, which search for a Planning module in the given module. For instance
module Namespace
module Planning
planning_library
[...]
end end
can be used with
class MyPlanner < Planner
using Namespace
end
Instance Attribute Summary collapse
-
#default_options ⇒ Object
readonly
Returns the value of attribute default_options.
Class Method Summary collapse
Instance Method Summary collapse
-
#append_features(klass) ⇒ Object
Cannot use included here because included() is called after the module has been included.
- #method(name, options = Hash.new, &body) ⇒ Object
- #planning_methods ⇒ Object
Methods included from Tools
Instance Attribute Details
#default_options ⇒ Object (readonly)
Returns the value of attribute default_options.
845 846 847 |
# File 'lib/roby/planning/model.rb', line 845 def end |
Class Method Details
.clear_model ⇒ Object
855 856 857 |
# File 'lib/roby/planning/model.rb', line 855 def self.clear_model planning_methods.clear end |
.new(&block) ⇒ Object
888 889 890 891 892 893 |
# File 'lib/roby/planning/model.rb', line 888 def self.new(&block) Module.new do extend Library class_eval(&block) end end |
Instance Method Details
#append_features(klass) ⇒ Object
Cannot use included here because included() is called after the module has been included
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 |
# File 'lib/roby/planning/model.rb', line 861 def append_features(klass) new_libraries = ancestors.enum_for. reject { |mod| klass < mod }. find_all { |mod| mod.respond_to?(:planning_methods) } super unless klass < Planner if Class === klass Roby.debug "including a planning library in a class which is not a Planner, which is useless" else klass.extend Library end return end new_libraries.reverse_each do |mod| mod.planning_methods.each do |name, , body| begin klass.method(name, , &body) rescue ArgumentError => e raise ArgumentError, "cannot include the #{self} library in #{klass}: when inserting #{name}#{options}, #{e.message}", caller(0) end end end end |
#method(name, options = Hash.new, &body) ⇒ Object
848 849 850 851 852 853 |
# File 'lib/roby/planning/model.rb', line 848 def method(name, = Hash.new, &body) if body && = .merge() end planning_methods << [name, , body] end |
#planning_methods ⇒ Object
847 |
# File 'lib/roby/planning/model.rb', line 847 def planning_methods; @methods ||= Array.new end |