forked from RRZE-HPC/likwid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add expression tree interface documentation and include guards
- Loading branch information
Showing
2 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,55 @@ | ||
// calculator_exptree.h | ||
// TODO: file description | ||
|
||
struct exptree_node; // fwd declaration | ||
#ifndef CALCULATOR_EXPTREE_H_INCLUDED | ||
#define CALCULATOR_EXPTREE_H_INCLUDED | ||
|
||
/** | ||
* @brief Forward declaration of struct exptree_node | ||
* | ||
*/ | ||
struct exptree_node; | ||
|
||
// cannot fwd declare CounterList because it was an anonymous struct (changed) | ||
// thus we named CounterList to avoid unnecessary cyclic inclusion dependency with: | ||
// thus we named CounterList to avoid unnecessary inclusion dependency with: | ||
// #include "perfgroup.h" | ||
struct CounterList; // fwd declaration | ||
/** | ||
* @brief Forward declaration of struct CounterList | ||
* | ||
*/ | ||
struct CounterList; | ||
|
||
// TODO: documentation of interfaces | ||
// TODO: do we want "print_expression_tree"? | ||
|
||
/** | ||
* @brief Builds a binary expression tree from expression expr | ||
* | ||
* @param expr The expression | ||
* @return struct exptree_node* Expression tree node on success, NULL on error | ||
*/ | ||
extern struct exptree_node *make_expression_tree(const char *expr); | ||
|
||
/** | ||
* @brief Deallocates the binary expression tree | ||
* | ||
* @param root The root node | ||
*/ | ||
extern void free_expression_tree(struct exptree_node *root); | ||
|
||
extern double evaluate_expression_tree(const struct exptree_node *node, const struct CounterList *clist); | ||
/** | ||
* @brief Evaluates the expression tree with values from counter list | ||
* | ||
* @param root The root node | ||
* @param clist The counter list | ||
* @return double The value of the expression tree evaluation on success, NAN on error | ||
*/ | ||
extern double evaluate_expression_tree(const struct exptree_node *root, const struct CounterList *clist); | ||
|
||
/** | ||
* @brief Prints the expression tree in infix order | ||
* | ||
* @param root The root node | ||
*/ | ||
extern void print_expression_tree(const struct exptree_node *root); | ||
|
||
#endif /* CALCULATOR_EXPTREE_H_INCLUDED */ |