Merge pull request #3 from tboudreaux/enhancment/dobj-error
[enhancment/dobj-error -> main] Error code tracking built into DObject
This commit is contained in:
@@ -48,6 +48,19 @@ bool DObject::isDebuggingEnabled() const noexcept {
|
|||||||
return debugEnabled_;
|
return debugEnabled_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @breif Sets an error code and returns the old one
|
||||||
|
*/
|
||||||
|
int DObject::setErrorCode(int code) noexcept {
|
||||||
|
int oldCode = errorCode_;
|
||||||
|
errorCode_ = code;
|
||||||
|
return oldCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DObject::getErrorCode() const noexcept {
|
||||||
|
return errorCode_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Registers a plugin with the DObject.
|
* @brief Registers a plugin with the DObject.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ public:
|
|||||||
{18, "vector<vector<vector<double>>"}
|
{18, "vector<vector<vector<double>>"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Placeholder type for plugins.
|
* @brief Placeholder type for plugins.
|
||||||
*
|
*
|
||||||
@@ -165,6 +166,21 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isDebuggingEnabled() const noexcept;
|
bool isDebuggingEnabled() const noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @breif Set error code tracked by the DOBject
|
||||||
|
*
|
||||||
|
* @return The previous error code
|
||||||
|
*/
|
||||||
|
int setErrorCode(int code) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the error code tracked by the DObject
|
||||||
|
*
|
||||||
|
* @return The error code
|
||||||
|
*/
|
||||||
|
int getErrorCode() const noexcept;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Registers a plugin with the DObject.
|
* @brief Registers a plugin with the DObject.
|
||||||
*
|
*
|
||||||
@@ -214,6 +230,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
DataType data_; ///< The main data stored in the DObject.
|
DataType data_; ///< The main data stored in the DObject.
|
||||||
bool debugEnabled_ = false; ///< Indicates whether debugging is enabled.
|
bool debugEnabled_ = false; ///< Indicates whether debugging is enabled.
|
||||||
|
int errorCode_ = 0; ///< Error code tracked by the DObject.
|
||||||
std::map<std::string, Plugin> plugins_; ///< Registry for dynamically registered plugins.
|
std::map<std::string, Plugin> plugins_; ///< Registry for dynamically registered plugins.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
23
src/opac/public/opac.h
Normal file
23
src/opac/public/opac.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef OPAC_H
|
||||||
|
#define OPAC_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include "DObject.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @breif initlaize the opacity module
|
||||||
|
* @param args: a hash map of all arguments needed to intialize opac
|
||||||
|
* @return error code in a DObject
|
||||||
|
**/
|
||||||
|
DObject initlaize_opac(const std::map<std::string, DObject>& args);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @breif opacity given a temperature, density, and composition
|
||||||
|
* @param args: a hash map of all arguments needed to calculate opac
|
||||||
|
* @return error code in a DObject
|
||||||
|
**/
|
||||||
|
DObject
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -60,6 +60,17 @@ TEST_F(DObjectTest, DebuggingFlag) {
|
|||||||
EXPECT_FALSE(defaultObject.isDebuggingEnabled());
|
EXPECT_FALSE(defaultObject.isDebuggingEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(DObjectTest, ErrorCodeSetteGetter) {
|
||||||
|
int prevCode;
|
||||||
|
prevCode = defaultObject.setErrorCode(1);
|
||||||
|
EXPECT_EQ(prevCode, 0);
|
||||||
|
prevCode = defaultObject.setErrorCode(2);
|
||||||
|
EXPECT_EQ(prevCode, 1);
|
||||||
|
int getCode;
|
||||||
|
getCode = defaultObject.getErrorCode();
|
||||||
|
EXPECT_EQ(getCode, 2);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test Basic Integration Test
|
* @test Basic Integration Test
|
||||||
*/
|
*/
|
||||||
@@ -72,16 +83,4 @@ TEST_F(DObjectTest, IntegrationTest) {
|
|||||||
EXPECT_EQ(data, newData);
|
EXPECT_EQ(data, newData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @test Verify human-readable summary.
|
|
||||||
// */
|
|
||||||
// TEST_F(DObjectTest, HumanReadableOutput) {
|
|
||||||
// std::ostringstream oss;
|
|
||||||
// oss << initializedObject;
|
|
||||||
|
|
||||||
// std::string output = oss.str();
|
|
||||||
// EXPECT_TRUE(output.find("Debugging Enabled: Yes") != std::string::npos);
|
|
||||||
// EXPECT_TRUE(output.find("Metadata: ") != std::string::npos);
|
|
||||||
// EXPECT_TRUE(output.find("Data: ") != std::string::npos);
|
|
||||||
// EXPECT_TRUE(output.find("Plugins Registered: 0") != std::string::npos);
|
|
||||||
// }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user