Module

class zhetapi::Module : public zhetapi::Token

Represents a collection of variables (algorithms, registrables, functions, operands) from a separate library or file.

Public Types

using Exporter = void (*)(Module*)

Exporter type alias. The “exporter” of each compiled library is a function that is executed upon loading the library. Any symbols that the library designer wishes to make available through the library’s interface are made public in this function.

Public Functions

Module(const std::string&)

Name constructor.

Parameters

name – the name of the resulting Module object.

Module(const std::string&, const std::vector<NamedToken>&)

Name and member constructor.

Parameters
  • name – the name of the resulting Module object.

  • parts – the members to be added to the object, as a list of pairs of their names (as std::strings) and values (as Tokens).

Token *attr(const std::string&, Engine*, const Targs&, size_t) override

Overrided attribute method for Modules. Prioritizes the members of the object over its own methods.

Parameters
  • id – the name of the member or method.

  • ctx – the execution context.

  • args – the arguments to be provided to the member/method.

  • osize – the original size of the tree’s leaves.

virtual void list_attributes(std::ostream&) const override

Overrides the list_attributes method from Tokens. Prints the attributes the members and methods of the object.

void add(const NamedToken&)

Adds a member to the object.

Parameters

nt – a pair containing the name and value of the member.

void add(const char*, Token*)

Adds a member to the object.

Parameters
  • name – the name of the member.

  • tptr – the value of the member.

void add(const std::string&, Token*)

Adds a member to the object.

Parameters
  • name – the name of the member.

  • tptr – the value of the member.

virtual Token *copy() const override

Returns a copy of the Token (with the same data: the resulting Token should equal the original with ==). Pure virtual because any Tokens used will be copied at some point.