Class: Cudd::Manager

Inherits:
Object
  • Object
show all
Includes:
Interface::Root
Defined in:
lib/cudd-rb/manager.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Interface::Root

#interface, #root_manager?

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

#optionsObject (readonly)

Options passed at construction.



7
8
9
# File 'lib/cudd-rb/manager.rb', line 7

def options
  @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`

Raises:



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cudd-rb/manager.rb', line 23

def self.root(options)
  options    = options.dup
  bdd_vars   = (options[:numVars]   ||= 0)
  zdd_vars   = (options[:numVarsZ]  ||= 0)
  num_slots  = (options[:numSlots]  ||= 256)
  cache_size = (options[:cacheSize] ||= 262144)
  max_mem    = (options[: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(options, 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).

Returns:

  • (Boolean)


50
51
52
# File 'lib/cudd-rb/manager.rb', line 50

def alive?
  !@native_manager.nil?
end

#closeObject

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.

Returns:

  • (Boolean)


57
58
59
# File 'lib/cudd-rb/manager.rb', line 57

def closed?
  @native_manager.nil?
end

#native_managerObject

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