#include<stdlib.h>
#include "functioncall.h"
#include "../../repository/repository.h"
#include "../../domain/domain.h"
#include "../../vector/vector.h"

FunctionCall* _FunctionCall_Constructor(int (*function)(Repository*, Material*), Vector* args){
    FunctionCall* functionCall = (FunctionCall*)malloc(sizeof(FunctionCall));
    functionCall->function = function;
    functionCall->args = args;
    return functionCall;
}

void _FunctionCall_Destructor(FunctionCall* functionCall){
    _Material_Destructor((Material*)functionCall->args->elems[1]);
    _Vector_Destructor(functionCall->args);
    free(functionCall);
}

void _FunctionCall_Execute(FunctionCall* functionCall){
    functionCall->function((Repository*)functionCall->args->elems[0], (Material*)functionCall->args->elems[1]);
}