Skip to content

Commit

Permalink
reapi: add accessors for traverser pre/post order count
Browse files Browse the repository at this point in the history
Problem: new resource query and potentially other tools using this
api may need access to the traverser pre and post order counts.
Accessors for these fields do not exist.

Create accessors for these fields in reapi_cli_t and
resource_query_t.
  • Loading branch information
zekemorton committed Dec 4, 2023
1 parent bb7469a commit 70a45c0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion resource/reapi/bindings/c++/reapi_cli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class resource_query_t {
const std::shared_ptr<job_info_t> &get_job (const uint64_t jobid);
const bool reservation_exists (const uint64_t jobid);
const bool allocation_exists (const uint64_t jobid);
const unsigned int preorder_count ();
const unsigned int postorder_count ();

/* Mutators */
void clear_resource_query_err_msg ();
Expand Down Expand Up @@ -142,7 +144,9 @@ class reapi_cli_t : public reapi_t {
static int info (void *h, const uint64_t jobid, std::string &mode,
bool &reserved, int64_t &at, double &ov);
static int info (void *h, const uint64_t jobid,
std::shared_ptr<job_info_t> &job);
std::shared_ptr<job_info_t> &job);
static unsigned int preorder_count (void *h);
static unsigned int postorder_count (void *h);
static int stat (void *h, int64_t &V, int64_t &E,int64_t &J,
double &load, double &min, double &max, double &avg);
static const std::string &get_err_message ();
Expand Down
24 changes: 24 additions & 0 deletions resource/reapi/bindings/c++/reapi_cli_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,20 @@ int reapi_cli_t::info (void *h, const uint64_t jobid,
return 0;
}

unsigned int reapi_cli_t::preorder_count (void *h)
{
resource_query_t *rq = static_cast<resource_query_t *> (h);

return rq->preorder_count ();
}

unsigned int reapi_cli_t::postorder_count (void *h)
{
resource_query_t *rq = static_cast<resource_query_t *> (h);

return rq->postorder_count ();
}

int reapi_cli_t::stat (void *h, int64_t &V, int64_t &E,int64_t &J,
double &load, double &min, double &max, double &avg)
{
Expand Down Expand Up @@ -634,6 +648,16 @@ const bool resource_query_t::reservation_exists (const uint64_t jobid)
return reservations.find (jobid) != reservations.end ();
}

const unsigned int resource_query_t::preorder_count ()
{
return traverser->get_total_preorder_count ();
}

const unsigned int resource_query_t::postorder_count ()
{
return traverser->get_total_postorder_count ();
}

void resource_query_t::clear_resource_query_err_msg ()
{
m_err_msg = "";
Expand Down

0 comments on commit 70a45c0

Please sign in to comment.