Class: Cudd::Manager
- Inherits:
-
Object
- Object
- Cudd::Manager
- Includes:
- Interface::Root
- Defined in:
- lib/cudd-rb/manager.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Options passed at construction.
Class Method Summary collapse
-
.root(options) ⇒ Object
private
Creates a root manager by invoking ‘Cudd_Init`.
Instance Method Summary collapse
-
#alive? ⇒ Boolean
Is this manager alive?.
-
#close ⇒ Object
Closes this manager by invoking ‘Cudd_Quit`.
-
#closed? ⇒ Boolean
Returns true if this manager has already been closed, false otherwise.
-
#initialize(*args) ⇒ Manager
constructor
private
Creates a manager instance.
-
#native_manager ⇒ Object
Returns the native manager, that is, a FFI::Pointer to the CUDD’s ‘DdManager`.
Methods included from Interface::Root
Constructor Details
#initialize(*args) ⇒ Manager
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a manager instance.
12 13 14 15 16 17 18 |
# File 'lib/cudd-rb/manager.rb', line 12 def initialize(*args) args.each do |arg| @options = arg if arg.is_a?(Hash) @root_manager = arg if arg.is_a?(Manager) @native_manager = arg if arg.is_a?(FFI::Pointer) end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Options passed at construction.
7 8 9 |
# File 'lib/cudd-rb/manager.rb', line 7 def @options end |
Class Method Details
.root(options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a root manager by invoking ‘Cudd_Init`
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cudd-rb/manager.rb', line 23 def self.root() = .dup bdd_vars = ([:numVars] ||= 0) zdd_vars = ([:numVarsZ] ||= 0) num_slots = ([:numSlots] ||= 256) cache_size = ([:cacheSize] ||= 262144) max_mem = ([:maxMemory] ||= 0) native_manager = Wrapper.Init(bdd_vars, zdd_vars, num_slots, cache_size, max_mem) raise Cudd::Error, "Unable to create a manager" unless native_manager Manager.new(, native_manager).tap do |m| ObjectSpace.define_finalizer(m, lambda{|d| d.close}) end end |
Instance Method Details
#alive? ⇒ Boolean
Is this manager alive?
A manager is alive between its creation (via ‘Cudd.manager`) and an invocation to `close`, either explicitely of implicitely (garbage collected by ruby).
50 51 52 |
# File 'lib/cudd-rb/manager.rb', line 50 def alive? !@native_manager.nil? end |
#close ⇒ Object
Closes this manager by invoking ‘Cudd_Quit`.
38 39 40 41 42 |
# File 'lib/cudd-rb/manager.rb', line 38 def close Wrapper.Quit(@native_manager) if @native_manager ensure @native_manager = nil end |
#closed? ⇒ Boolean
Returns true if this manager has already been closed, false otherwise.
57 58 59 |
# File 'lib/cudd-rb/manager.rb', line 57 def closed? @native_manager.nil? end |
#native_manager ⇒ Object
Returns the native manager, that is, a FFI::Pointer to the CUDD’s ‘DdManager`.
65 66 67 |
# File 'lib/cudd-rb/manager.rb', line 65 def native_manager @native_manager end |