Skip to content

Commit

Permalink
Merge pull request #179 from Argonne-National-Laboratory/kk/version
Browse files Browse the repository at this point in the history
Implemented functions to query versions
  • Loading branch information
kibaekkim committed Dec 11, 2020
2 parents 448b4fc + 6834ee5 commit 97c8863
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/DspApiEnv.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef DSPAPIENV_H_
#define DSPAPIENV_H_

#include "DspConfig.h"
#include "Solver/DecSolver.h"
#include "Model/DecModel.h"
#include "Utility/DspParams.h"
Expand All @@ -25,6 +26,15 @@ class DspApiEnv
/** A default destructore */
virtual ~DspApiEnv();

/** Query DSP version major */
int getVersionMajor() { return DSP_VERSION_MAJOR; }

/** Query DSP version minor */
int getVersionMinor() { return DSP_VERSION_MINOR; }

/** Query DSP version patch */
int getVersionPatch() { return DSP_VERSION_PATCH; }

DecSolver * solver_; /**< A decomposition solver object */
DecModel * model_; /**< A decomposition model object */
DspParams * par_; /**< A parameters object */
Expand Down
15 changes: 15 additions & 0 deletions src/DspCInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,21 @@ void printModel(DspApiEnv * env)
env->model_->__printData();
}

int getVersionMajor(DspApiEnv *env)
{
return env->getVersionMajor();
}

int getVersionMinor(DspApiEnv *env)
{
return env->getVersionMinor();
}

int getVersionPatch(DspApiEnv *env)
{
return env->getVersionPatch();
}

#undef DSP_API_CHECK_MODEL
#undef DSP_API_CHECK_ENV

Expand Down
10 changes: 10 additions & 0 deletions src/DspCInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Utility/DspMpi.h"

/** DSP */
#include "DspConfig.h"
#include "DspApiEnv.h"

class TssModel;
Expand Down Expand Up @@ -242,6 +243,15 @@ void writeMps(DspApiEnv * env, const char * name);
/** print model */
void printModel(DspApiEnv *env);

/** query the DSP version major */
int getVersionMajor(DspApiEnv *env);

/** query the DSP version minor */
int getVersionMinor(DspApiEnv *env);

/** query the DSP version patch */
int getVersionPatch(DspApiEnv *env);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/DspConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
#define DSP_VERSION_MAJOR 1
#define DSP_VERSION_MINOR 4
#define DSP_VERSION_PATCH 0
#define DSP_VERSION_PATCH 1

#include <stdio.h>

Expand Down
11 changes: 11 additions & 0 deletions src/test/src/tests-DspCInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ TEST_CASE("C interface functions") {
REQUIRE(env->solver_ == NULL);
}

SECTION("Version checks")
{
int major = getVersionMajor(env);
int minor = getVersionMinor(env);
int patch = getVersionPatch(env);

REQUIRE(major == DSP_VERSION_MAJOR);
REQUIRE(minor == DSP_VERSION_MINOR);
REQUIRE(patch == DSP_VERSION_PATCH);
}

SECTION("freeEnv function") {
freeEnv(env);
REQUIRE(env == NULL);
Expand Down

0 comments on commit 97c8863

Please sign in to comment.