module AutoC::Module::EntityContainer::AutoC::Module::EntityContainer::Module::State::AutoC::Module::EntityContainer::AutoC::Module::EntityContainer::Module::State::Module::StreamFile::AutoC::Module::EntityContainer::AutoC::Module::EntityContainer::Module::State::AutoC::Module::EntityContainer::AutoC::Module::EntityContainer::Module::State::Module::StreamFile::Module::Header::AutoC::Module::EntityContainer::AutoC::Module::EntityContainer::Module::State::AutoC::Module::EntityContainer::AutoC::Module::EntityContainer::Module::State::Module::StreamFile::AutoC::Module::EntityContainer::AutoC::Module::EntityContainer::Module::State::AutoC::Module::EntityContainer::AutoC::Module::EntityContainer::Module::State::Module::StreamFile::Module::Header::Module::Source::Entity

Constants

ReferenceSet

Public Instance Methods

<=>(other) click to toggle source
# File lib/autoc/module.rb, line 327
  def <=>(other) = position <=> other.position

  # Compute the entity's relative position with respect to its dependencies
  def position = @position ||= begin
    p = 0
    # This code goes into infinite recursion on circular dependency
    # which must be resolved manually with Entity#references
    total_dependencies.each do |d|
      unless equal?(d)
        dp = d.position
        p = dp if p < dp # p <- max(p, dp)
      end
    end
    p + 1 # Arrange entity to follow all its dependencies
  end

  def complexity = forward_declarations.complexity + implementation.complexity # Interface part is not considered as it is shared across the sources

  def interface
    @interface ||= begin
      render_interface(stream = Module::Builder.new)
      stream
    end
  end

  def forward_declarations
    @forward_declarations ||= begin
      render_forward_declarations(stream = Module::Builder.new)
      stream
    end
  end

  def implementation
    @implementation ||= begin
      render_implementation(stream = Module::Builder.new)
      stream
    end
  end

private

  ### Overridable rendering methods

  def render_interface(stream) = nil

  def render_forward_declarations(stream) = nil

  def render_implementation(stream) = nil

end # Entity


Entity::ReferenceSet = ::Set


# @private
class Entity::DependencySet < ::Set

  def initialize(entity)
    super()
    @entity = entity
  end

  def <<(x)
    @entity.references << x # Each dependency is also registered as a reference
    super
  end

end # DependencySet


# Helper class to represent plain C side code block
class Code

  include Entity

  def initialize(interface: nil, implementation: nil, definitions: nil)
    @interface_ = interface
    @definitions_ = definitions
    @implementation_ = implementation
  end

  def inspect = "... <#{self.class}>"

private

  def render_interface(stream)
    stream << @interface_ unless @interface_.nil?
  end

  def render_implementation(stream)
    stream << @implementation_ unless @implementation_.nil?
  end

  def render_forward_declarations(stream)
    stream << @definitions_ unless @definitions_.nil?
  end

end # Code


# Helper class to inject a system-wide header into the C side interface part of the module
class SystemHeader < AutoC::Code
  def initialize(header)
    super interface: %{
      #include <#{header}>
    }
  end
collect_dependencies(set) click to toggle source
# File lib/autoc/module.rb, line 319
          def collect_dependencies(set)
  unless set.include?(self)
    set << self
    dependencies.each { |x| x.collect_dependencies(set) }
  end
  set
end
collect_references(set) click to toggle source
# File lib/autoc/module.rb, line 311
          def collect_references(set)
  unless set.include?(self)
    set << self
    references.each { |x| x.collect_references(set) }
  end
  set
end
complexity(= forward_declarations.complexity + implementation.complexity) click to toggle source
# File lib/autoc/module.rb, line 343
  def complexity = forward_declarations.complexity + implementation.complexity # Interface part is not considered as it is shared across the sources

  def interface
    @interface ||= begin
      render_interface(stream = Module::Builder.new)
      stream
    end
  end

  def forward_declarations
    @forward_declarations ||= begin
      render_forward_declarations(stream = Module::Builder.new)
      stream
    end
  end

  def implementation
    @implementation ||= begin
      render_implementation(stream = Module::Builder.new)
      stream
    end
  end

private

  ### Overridable rendering methods

  def render_interface(stream) = nil

  def render_forward_declarations(stream) = nil

  def render_implementation(stream) = nil

end # Entity


Entity::ReferenceSet = ::Set


# @private
class Entity::DependencySet < ::Set

  def initialize(entity)
    super()
    @entity = entity
  end

  def <<(x)
    @entity.references << x # Each dependency is also registered as a reference
    super
  end

end # DependencySet


# Helper class to represent plain C side code block
class Code

  include Entity

  def initialize(interface: nil, implementation: nil, definitions: nil)
    @interface_ = interface
    @definitions_ = definitions
    @implementation_ = implementation
  end

  def inspect = "... <#{self.class}>"

private

  def render_interface(stream)
    stream << @interface_ unless @interface_.nil?
  end

  def render_implementation(stream)
    stream << @implementation_ unless @implementation_.nil?
  end

  def render_forward_declarations(stream)
    stream << @definitions_ unless @definitions_.nil?
  end

end # Code


# Helper class to inject a system-wide header into the C side interface part of the module
class SystemHeader < AutoC::Code
  def initialize(header)
    super interface: %{
      #include <#{header}>
    }
  end
dependencies(= @dependencies ||= DependencySet.new(self)) click to toggle source

A set of the entity’s immediate dependencies which enforce the entities relative ordering

# File lib/autoc/module.rb, line 306
  def dependencies = @dependencies ||= DependencySet.new(self)

  # Return the entire entity's dependency set staring with self
  def total_dependencies = @total_dependencies ||= collect_dependencies(::Set.new)

  protected def collect_references(set)
    unless set.include?(self)
      set << self
      references.each { |x| x.collect_references(set) }
    end
    set
  end

  protected def collect_dependencies(set)
    unless set.include?(self)
      set << self
      dependencies.each { |x| x.collect_dependencies(set) }
    end
    set
  end

  def <=>(other) = position <=> other.position

  # Compute the entity's relative position with respect to its dependencies
  def position = @position ||= begin
    p = 0
    # This code goes into infinite recursion on circular dependency
    # which must be resolved manually with Entity#references
    total_dependencies.each do |d|
      unless equal?(d)
        dp = d.position
        p = dp if p < dp # p <- max(p, dp)
      end
    end
    p + 1 # Arrange entity to follow all its dependencies
  end

  def complexity = forward_declarations.complexity + implementation.complexity # Interface part is not considered as it is shared across the sources

  def interface
    @interface ||= begin
      render_interface(stream = Module::Builder.new)
      stream
    end
  end

  def forward_declarations
    @forward_declarations ||= begin
      render_forward_declarations(stream = Module::Builder.new)
      stream
    end
  end

  def implementation
    @implementation ||= begin
      render_implementation(stream = Module::Builder.new)
      stream
    end
  end

private

  ### Overridable rendering methods

  def render_interface(stream) = nil

  def render_forward_declarations(stream) = nil

  def render_implementation(stream) = nil

end # Entity


Entity::ReferenceSet = ::Set


# @private
class Entity::DependencySet < ::Set

  def initialize(entity)
    super()
    @entity = entity
  end

  def <<(x)
    @entity.references << x # Each dependency is also registered as a reference
    super
  end

end # DependencySet


# Helper class to represent plain C side code block
class Code

  include Entity

  def initialize(interface: nil, implementation: nil, definitions: nil)
    @interface_ = interface
    @definitions_ = definitions
    @implementation_ = implementation
  end

  def inspect = "... <#{self.class}>"

private

  def render_interface(stream)
    stream << @interface_ unless @interface_.nil?
  end

  def render_implementation(stream)
    stream << @implementation_ unless @implementation_.nil?
  end

  def render_forward_declarations(stream)
    stream << @definitions_ unless @definitions_.nil?
  end

end # Code


# Helper class to inject a system-wide header into the C side interface part of the module
class SystemHeader < AutoC::Code
  def initialize(header)
    super interface: 
forward_declarations() click to toggle source
# File lib/autoc/module.rb, line 352
def forward_declarations
  @forward_declarations ||= begin
    render_forward_declarations(stream = Module::Builder.new)
    stream
  end
end
implementation() click to toggle source
# File lib/autoc/module.rb, line 359
def implementation
  @implementation ||= begin
    render_implementation(stream = Module::Builder.new)
    stream
  end
end
interface() click to toggle source
# File lib/autoc/module.rb, line 345
def interface
  @interface ||= begin
    render_interface(stream = Module::Builder.new)
    stream
  end
end
position(= @position ||= begin p = 0) click to toggle source

Compute the entity’s relative position with respect to its dependencies

# File lib/autoc/module.rb, line 330
def position = @position ||= begin
  p = 0
  # This code goes into infinite recursion on circular dependency
  # which must be resolved manually with Entity#references
  total_dependencies.each do |d|
    unless equal?(d)
      dp = d.position
      p = dp if p < dp # p <- max(p, dp)
    end
  end
  p + 1 # Arrange entity to follow all its dependencies
end
references(= @references ||= ReferenceSet.new) click to toggle source

A set of the entity’s immediate references which, unlike dependencies, do not enforce the entities relative ordering

# File lib/autoc/module.rb, line 300
  def references = @references ||= ReferenceSet.new

  # Return the entire entity's reference set staring with self
  def total_references = @total_references ||= collect_references(::Set.new)

  # A set of the entity's immediate dependencies which enforce the entities relative ordering
  def dependencies = @dependencies ||= DependencySet.new(self)

  # Return the entire entity's dependency set staring with self
  def total_dependencies = @total_dependencies ||= collect_dependencies(::Set.new)

  protected def collect_references(set)
    unless set.include?(self)
      set << self
      references.each { |x| x.collect_references(set) }
    end
    set
  end

  protected def collect_dependencies(set)
    unless set.include?(self)
      set << self
      dependencies.each { |x| x.collect_dependencies(set) }
    end
    set
  end

  def <=>(other) = position <=> other.position

  # Compute the entity's relative position with respect to its dependencies
  def position = @position ||= begin
    p = 0
    # This code goes into infinite recursion on circular dependency
    # which must be resolved manually with Entity#references
    total_dependencies.each do |d|
      unless equal?(d)
        dp = d.position
        p = dp if p < dp # p <- max(p, dp)
      end
    end
    p + 1 # Arrange entity to follow all its dependencies
  end

  def complexity = forward_declarations.complexity + implementation.complexity # Interface part is not considered as it is shared across the sources

  def interface
    @interface ||= begin
      render_interface(stream = Module::Builder.new)
      stream
    end
  end

  def forward_declarations
    @forward_declarations ||= begin
      render_forward_declarations(stream = Module::Builder.new)
      stream
    end
  end

  def implementation
    @implementation ||= begin
      render_implementation(stream = Module::Builder.new)
      stream
    end
  end

private

  ### Overridable rendering methods

  def render_interface(stream) = nil

  def render_forward_declarations(stream) = nil

  def render_implementation(stream) = nil

end # Entity


Entity::ReferenceSet = ::Set


# @private
class Entity::DependencySet < ::Set

  def initialize(entity)
    super()
    @entity = entity
  end

  def <<(x)
    @entity.references << x # Each dependency is also registered as a reference
    super
  end

end # DependencySet


# Helper class to represent plain C side code block
class Code

  include Entity

  def initialize(interface: nil, implementation: nil, definitions: nil)
    @interface_ = interface
    @definitions_ = definitions
    @implementation_ = implementation
  end

  def inspect = "... <#{self.class}>"

private

  def render_interface(stream)
    stream << @interface_ unless @interface_.nil?
  end

  def render_implementation(stream)
    stream << @implementation_ unless @implementation_.nil?
  end

  def render_forward_declarations(stream)
    stream << @definitions_ unless @definitions_.nil?
  end

end # Code


# Helper class to inject a system-wide header into the C side interface part of the module
class SystemHeader < AutoC::Code
  def initialize(header)
    
render_forward_declarations(stream) click to toggle source
# File lib/autoc/module.rb, line 372
  def render_forward_declarations(stream) = nil

  def render_implementation(stream) = nil

end # Entity


Entity::ReferenceSet = ::Set


# @private
class Entity::DependencySet < ::Set

  def initialize(entity)
    super()
    @entity = entity
  end

  def <<(x)
    @entity.references << x # Each dependency is also registered as a reference
    super
  end

end # DependencySet


# Helper class to represent plain C side code block
class Code

  include Entity

  def initialize(interface: nil, implementation: nil, definitions: nil)
    @interface_ = interface
    @definitions_ = definitions
    @implementation_ = implementation
  end

  def inspect = "... <#{self.class}>"

private

  def render_interface(stream)
    stream << @interface_ unless @interface_.nil?
  end

  def render_implementation(stream)
    stream << @implementation_ unless @implementation_.nil?
  end

  def render_forward_declarations(stream)
    stream << @definitions_ unless @definitions_.nil?
  end

end # Code


# Helper class to inject a system-wide header into the C side interface part of the module
class SystemHeader < AutoC::Code
  def initialize(header)
    super interface: %{
      #include <#{header}>
    }
  end
end # SystemHeader

render_implementation(stream) click to toggle source
# File lib/autoc/module.rb, line 374
  def render_implementation(stream) = nil

end
render_interface(stream) click to toggle source

Overridable rendering methods

# File lib/autoc/module.rb, line 370
  def render_interface(stream) = nil

  def render_forward_declarations(stream) = nil

  def render_implementation(stream) = nil

end # Entity


Entity::ReferenceSet = ::Set


# @private
class Entity::DependencySet < ::Set

  def initialize(entity)
    super()
    @entity = entity
  end

  def <<(x)
    @entity.references << x # Each dependency is also registered as a reference
    super
  end

end # DependencySet


# Helper class to represent plain C side code block
class Code

  include Entity

  def initialize(interface: nil, implementation: nil, definitions: nil)
    @interface_ = interface
    @definitions_ = definitions
    @implementation_ = implementation
  end

  def inspect = "... <#{self.class}>"

private

  def render_interface(stream)
    stream << @interface_ unless @interface_.nil?
  end

  def render_implementation(stream)
    stream << @implementation_ unless @implementation_.nil?
  end

  def render_forward_declarations(stream)
    stream << @definitions_ unless @definitions_.nil?
  end

end # Code


# Helper class to inject a system-wide header into the C side interface part of the module
class SystemHeader < AutoC::Code
  def initialize(header)
    super interface: %{
      #include <#{header}>
    }
  end
end 
total_dependencies(= @total_dependencies ||= collect_dependencies(::Set.new)) click to toggle source

Return the entire entity’s dependency set staring with self

# File lib/autoc/module.rb, line 309
  def total_dependencies = @total_dependencies ||= collect_dependencies(::Set.new)

  protected def collect_references(set)
    unless set.include?(self)
      set << self
      references.each { |x| x.collect_references(set) }
    end
    set
  end

  protected def collect_dependencies(set)
    unless set.include?(self)
      set << self
      dependencies.each { |x| x.collect_dependencies(set) }
    end
    set
  end

  def <=>(other) = position <=> other.position

  # Compute the entity's relative position with respect to its dependencies
  def position = @position ||= begin
    p = 0
    # This code goes into infinite recursion on circular dependency
    # which must be resolved manually with Entity#references
    total_dependencies.each do |d|
      unless equal?(d)
        dp = d.position
        p = dp if p < dp # p <- max(p, dp)
      end
    end
    p + 1 # Arrange entity to follow all its dependencies
  end

  def complexity = forward_declarations.complexity + implementation.complexity # Interface part is not considered as it is shared across the sources

  def interface
    @interface ||= begin
      render_interface(stream = Module::Builder.new)
      stream
    end
  end

  def forward_declarations
    @forward_declarations ||= begin
      render_forward_declarations(stream = Module::Builder.new)
      stream
    end
  end

  def implementation
    @implementation ||= begin
      render_implementation(stream = Module::Builder.new)
      stream
    end
  end

private

  ### Overridable rendering methods

  def render_interface(stream) = nil

  def render_forward_declarations(stream) = nil

  def render_implementation(stream) = nil

end # Entity


Entity::ReferenceSet = ::Set


# @private
class Entity::DependencySet < ::Set

  def initialize(entity)
    super()
    @entity = entity
  end

  def <<(x)
    @entity.references << x # Each dependency is also registered as a reference
    super
  end

end # DependencySet


# Helper class to represent plain C side code block
class Code

  include Entity

  def initialize(interface: nil, implementation: nil, definitions: nil)
    @interface_ = interface
    @definitions_ = definitions
    @implementation_ = implementation
  end

  def inspect = "... <#{self.class}>"

private

  def render_interface(stream)
    stream << @interface_ unless @interface_.nil?
  end

  def render_implementation(stream)
    stream << @implementation_ unless @implementation_.nil?
  end

  def render_forward_declarations(stream)
    stream << @definitions_ unless @definitions_.nil?
  end

end # Code


# Helper class to inject a system-wide header into the C side interface part of the module
class SystemHeader < AutoC::Code
  def initialize(header)
    super interface: %{
      #include <#{header}>
    }
total_references(= @total_references ||= collect_references(::Set.new)) click to toggle source

Return the entire entity’s reference set staring with self

# File lib/autoc/module.rb, line 303
  def total_references = @total_references ||= collect_references(::Set.new)

  # A set of the entity's immediate dependencies which enforce the entities relative ordering
  def dependencies = @dependencies ||= DependencySet.new(self)

  # Return the entire entity's dependency set staring with self
  def total_dependencies = @total_dependencies ||= collect_dependencies(::Set.new)

  protected def collect_references(set)
    unless set.include?(self)
      set << self
      references.each { |x| x.collect_references(set) }
    end
    set
  end

  protected def collect_dependencies(set)
    unless set.include?(self)
      set << self
      dependencies.each { |x| x.collect_dependencies(set) }
    end
    set
  end

  def <=>(other) = position <=> other.position

  # Compute the entity's relative position with respect to its dependencies
  def position = @position ||= begin
    p = 0
    # This code goes into infinite recursion on circular dependency
    # which must be resolved manually with Entity#references
    total_dependencies.each do |d|
      unless equal?(d)
        dp = d.position
        p = dp if p < dp # p <- max(p, dp)
      end
    end
    p + 1 # Arrange entity to follow all its dependencies
  end

  def complexity = forward_declarations.complexity + implementation.complexity # Interface part is not considered as it is shared across the sources

  def interface
    @interface ||= begin
      render_interface(stream = Module::Builder.new)
      stream
    end
  end

  def forward_declarations
    @forward_declarations ||= begin
      render_forward_declarations(stream = Module::Builder.new)
      stream
    end
  end

  def implementation
    @implementation ||= begin
      render_implementation(stream = Module::Builder.new)
      stream
    end
  end

private

  ### Overridable rendering methods

  def render_interface(stream) = nil

  def render_forward_declarations(stream) = nil

  def render_implementation(stream) = nil

end # Entity


Entity::ReferenceSet = ::Set


# @private
class Entity::DependencySet < ::Set

  def initialize(entity)
    super()
    @entity = entity
  end

  def <<(x)
    @entity.references << x # Each dependency is also registered as a reference
    super
  end

end # DependencySet


# Helper class to represent plain C side code block
class Code

  include Entity

  def initialize(interface: nil, implementation: nil, definitions: nil)
    @interface_ = interface
    @definitions_ = definitions
    @implementation_ = implementation
  end

  def inspect = "... <#{self.class}>"

private

  def render_interface(stream)
    stream << @interface_ unless @interface_.nil?
  end

  def render_implementation(stream)
    stream << @implementation_ unless @implementation_.nil?
  end

  def render_forward_declarations(stream)
    stream << @definitions_ unless @definitions_.nil?
  end

end # Code


# Helper class to inject a system-wide header into the C side interface part of the module
class SystemHeader < AutoC::Code
  def initialize(header)
    super