codac 2.0.0
Loading...
Searching...
No Matches
codac2::FunctionArgsList Class Reference

A container class to manage a collection of function arguments. More...

#include <codac2_FunctionArgsList.h>

Public Member Functions

 FunctionArgsList ()
 Default constructor. It creates an empty list of arguments.
 
 FunctionArgsList (const FunctionArgsList &args)
 Copy constructor.
 
 FunctionArgsList (std::initializer_list< std::reference_wrapper< VarBase > > args)
 Constructor to initialize a FunctionArgsList from an initializer list of references to VarBase objects.
 
 FunctionArgsList (const std::vector< std::reference_wrapper< VarBase > > &args)
 Constructor to initialize a FunctionArgsList from a vector of of references to VarBase objects.
 
Index total_size () const
 Calculates the total size of the function arguments, as the sum of the sizes of each argument.
 

Detailed Description

A container class to manage a collection of function arguments.

Constructor & Destructor Documentation

◆ FunctionArgsList() [1/3]

codac2::FunctionArgsList::FunctionArgsList ( const FunctionArgsList & args)
inline

Copy constructor.

Each argument is deep-copied using its arg_copy() method.

Parameters
argsThe FunctionArgsList to copy from.
42 : std::vector<std::shared_ptr<VarBase>>(args.size())
43 {
44 size_t i = 0;
45 for(const auto& arg : args)
46 (*this)[i++] = arg->arg_copy();
47 compute_unique_arg_names();
48 }

◆ FunctionArgsList() [2/3]

codac2::FunctionArgsList::FunctionArgsList ( std::initializer_list< std::reference_wrapper< VarBase > > args)
inline

Constructor to initialize a FunctionArgsList from an initializer list of references to VarBase objects.

Each argument is deep-copied by calling its arg_copy() on the referenced objects.

Parameters
argsAn initializer list of references to VarBase objects.
59 : FunctionArgsList(std::vector<std::reference_wrapper<VarBase>>(args))
60 { }
FunctionArgsList()
Default constructor. It creates an empty list of arguments.
Definition codac2_FunctionArgsList.h:31

◆ FunctionArgsList() [3/3]

codac2::FunctionArgsList::FunctionArgsList ( const std::vector< std::reference_wrapper< VarBase > > & args)
inline

Constructor to initialize a FunctionArgsList from a vector of of references to VarBase objects.

Each argument is deep-copied by calling its arg_copy() on the referenced objects.

Parameters
argsAn initializer list of references to VarBase objects.
71 {
72 for(const auto& arg : args)
73 push_back(arg.get().arg_copy());
74 compute_unique_arg_names();
75 }

Member Function Documentation

◆ total_size()

Index codac2::FunctionArgsList::total_size ( ) const
inline

Calculates the total size of the function arguments, as the sum of the sizes of each argument.

Returns
The sum of the sizes of all arguments.
84 {
85 Index n = 0;
86 for(const auto& ai : *this)
87 n += ai->size();
88 return n;
89 }

The documentation for this class was generated from the following file: