Factories

Octopus uses the so-called factory pattern to create instances of the systems and interaction classes. The abstract factory classes are introduced to avoid the problem of circular dependencies.

The function of the factories is to create an object of a (dynamically) given type and return a pointer to it. This is done by calling the respective constructors of the classes, of which an instance is to be created.

System factories

  type, abstract :: system_factory_abst_t
  contains
    procedure(system_factory_abst_create),     deferred :: create
    procedure(system_factory_abst_block_name), deferred :: block_name
  end type system_factory_abst_t
  type, extends(system_factory_abst_t) :: system_factory_t
  contains
    procedure :: create => system_factory_create         !< @copydoc system_factory_oct_m::system_factory_create
    procedure :: block_name => system_factory_block_name !< @copydoc system_factory_oct_m::system_factory_block_name
  end type system_factory_t
Definition of system_factory_create()

Interaction factories

  type, abstract :: interactions_factory_abst_t
  contains
    procedure :: create_interactions => interactions_factory_abst_create_interactions
    !< @copydoc interactions_factory_abst_create_interactions
    procedure(interactions_factory_abst_create), deferred :: create
    !< @copydoc interactions_factory_abst_create
    procedure(interactions_factory_abst_default_mode), deferred :: default_mode
    !< @copydoc interactions_factory_abst_default_mode
    procedure(interactions_factory_abst_block_name), deferred :: block_name
    !< @copydoc interactions_factory_abst_block_name
  end type interactions_factory_abst_t
  type, extends(interactions_factory_abst_t) :: interactions_factory_t
  contains
    procedure :: create => interactions_factory_create              !< @copydoc interactions_factory_create()
    procedure :: default_mode => interactions_factory_default_mode  !< @copydoc interactions_factory_default_mode()
    procedure :: block_name => interactions_factory_block_name      !< @copydoc interactions_factory_block_name()
  end type interactions_factory_t
Definition of interactions_factory_abst_create_interactions()
Definition of interactions_factory_create()