LAD Project: the ANSWER Module
Summary: The ANSWER object serves the following purpose. It records
a function approximator's answers to the questions posed to it by the
question module.
An answer contains a set of boolean flags, telling you whether for
each reg_type (see the [question] module), that question has been
answered. For those questions which have been answered, a record is
kept of the answer. The type of the answer can be deduced from
req_type_ans_type(int reg_type) function. You may only set or
reference a reg_type in an answer with the access function of the
appropriate type.
answer *mk_empty_answer()
MALLOCs and returns an answer with no answer slots filled in
bool answer_exists(answer *an,int req_type)
Returns truth of: Is the answer slot associated with req_type filled in?
double number_from_answer(answer *an,int req_type)
Assuming that this req_type is meant to return a number, and
assuming that this req_type has been answered, returns the (number)
answer. Else an error
dyv *dyv_from_answer(answer *an,int req_type)
Assuming that this req_type is meant to return a dyv, and
assuming that this req_type has been answered, returns the (dyv)
answer. Else an error. Returns a pointer to a dyv inside the
answer which as usual mustnt-be-updated-or-freed-and-only-valid-while-
answer-exists
dym *dym_from_answer(answer *an,int req_type)
Assuming that this req_type is meant to return a dym, and
assuming that this req_type has been answered, returns the (dym)
answer. Else an error. Returns a pointer to a dym inside the
answer which as usual mustnt-be-updated-or-freed-and-only-valid-while-
answer-exists
dym_array *dym_array_from_answer(answer *an,int req_type)
Assuming that this req_type is meant to return a dym_array, and
assuming that this req_type has been answered, returns the (dym_array)
answer. Else an error. Returns a pointer to a dym_array inside the
answer which as usual mustnt-be-updated-or-freed-and-only-valid-while-
answer-exists
dist *dist_from_answer(answer *an,int req_type)
Assuming that this req_type is meant to return a dist, and
assuming that this req_type has been answered, returns the (dist)
answer. Else an error. Returns a pointer to a dist inside the
answer which as usual mustnt-be-updated-or-freed-and-only-valid-while-
answer-exists
void answer_set_number(answer *an,int req_type,double value)
Sets the answer for req_type with number "value". Error if an
answer of a different answer_type is expected. Error if the answer is
already defined.
void answer_set_dyv(answer *an,int req_type,dyv *value)
Sets the answer for req_type with dyv "value". Error if an
answer of a different answer_type is expected. Error if the answer is
already defined.
void answer_set_dym(answer *an,int req_type,dym *value)
Sets the answer for req_type with dym "value". Error if an
answer of a different answer_type is expected. Error if the answer is
already defined.
void answer_set_dym_array(answer *an,int req_type,dym_array *value)
Sets the answer for req_type with dym_array "value". Error if an
answer of a different answer_type is expected. Error if the answer is
already defined.
void answer_set_dist(answer *an,int req_type,dist *value)
Sets the answer for req_type with dist "value". Error if an
answer of a different answer_type is expected. Error if the answer is
already defined.
void fprintf_answer(FILE *s,char *m1,answer *an,char *m2)
fprints an answer in standard form
void free_answer(answer *an)
Frees an answer and all its subcomponents