Class: AutoC::Collection Abstract

Inherits:
Composite show all
Defined in:
lib/autoc/collection.rb

Overview

This class is abstract.

Generator for C types which contain zero or more elements of a particular type

Direct Known Subclasses

Association, List, Set

Constant Summary

Constants inherited from Composite

AutoC::Composite::DEFINITIONS, AutoC::Composite::PRIVATE

Constants included from Entity

Entity::ReferenceSet

Constants included from STD

STD::ASSERT_H, STD::BOOL, STD::CHAR, STD::COMPLEX, STD::COMPLEX_H, STD::DOUBLE, STD::DOUBLE_COMPLEX, STD::DOUBLE_T, STD::FLOAT, STD::FLOAT_COMPLEX, STD::FLOAT_T, STD::INT, STD::INTMAX_T, STD::INTPTR_T, STD::INTTYPES_H, STD::LONG, STD::LONG_DOUBLE, STD::LONG_DOUBLE_COMPLEX, STD::LONG_LONG, STD::MALLOC_H, STD::MATH_H, STD::PTRDIFF_T, STD::SHORT, STD::SIGNED_CHAR, STD::SIZE_T, STD::STDBOOL_H, STD::STDDEF_H, STD::STDLIB_H, STD::STRING_H, STD::UINTMAX_T, STD::UINTPTR_T, STD::UNSIGNED, STD::UNSIGNED_CHAR, STD::UNSIGNED_LONG, STD::UNSIGNED_LONG_LONG, STD::UNSIGNED_SHORT, STD::WCHAR_T

Instance Attribute Summary collapse

Attributes inherited from Composite

#_master, #visibility

Attributes inherited from Type

#signature

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Composite

allocator, allocator=, #const_lvalue, #const_rvalue, decorator, decorator=, #defgroup, hasher, #hasher, hasher=, #identifier, #ingroup, #inspect, #internal?, #lvalue, #memory, #prefix, #private?, #public?, #respond_to_missing?, #rvalue, #to_value

Methods included from Entity

#<=>, #complexity, #dependencies, #forward_declarations, #implementation, #interface, #position, #references, #total_dependencies, #total_references

Methods inherited from Type

abstract, #constructible?, #copy, #custom_constructible?, #custom_create, #default_constructible?, #default_create, #destroy, #inspect, #to_s, #to_type

Constructor Details

#initialize(signature, element, **kws) ⇒ Collection

Returns a new instance of Collection.



28
29
30
31
# File 'lib/autoc/collection.rb', line 28

def initialize(signature, element, **kws)
  super(signature, **kws)
  dependencies << (@element = element.to_type)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AutoC::Composite

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



18
19
20
# File 'lib/autoc/collection.rb', line 18

def element
  @element
end

#rangeObject (readonly)

Returns the value of attribute range.



20
21
22
# File 'lib/autoc/collection.rb', line 20

def range
  @range
end

Class Method Details

.new(*args, **kws) ⇒ Object



22
23
24
25
26
# File 'lib/autoc/collection.rb', line 22

def self.new(*args, **kws)
  obj = super
  obj.references << obj.range # Range has to be referenced after the iterable object gets fully configured
  obj
end

Instance Method Details

#comparable?Boolean

For container to be comparable a comparable element type is required

Returns:

  • (Boolean)


37
# File 'lib/autoc/collection.rb', line 37

def comparable? = super && element.comparable?

#copyable?Boolean

For container to be copyable a copyable element type is required

Returns:

  • (Boolean)


34
# File 'lib/autoc/collection.rb', line 34

def copyable? = super && element.copyable?

#destructible?Boolean

A destructible element type mandates creation of the container’s destructor

Returns:

  • (Boolean)


43
# File 'lib/autoc/collection.rb', line 43

def destructible? = super || element.destructible?

#hashable?Boolean

For container to be hashable a hashable element type is required

Returns:

  • (Boolean)


46
# File 'lib/autoc/collection.rb', line 46

def hashable? = super && element.hashable?

#orderable?Boolean

For container to be orderable an orderable element type is required

Returns:

  • (Boolean)


40
# File 'lib/autoc/collection.rb', line 40

def orderable? = super && element.orderable?

#type_tagObject



48
# File 'lib/autoc/collection.rb', line 48

def type_tag = "#{signature}<#{element}>"