From 62bb4608d12b8c166b0705208db9ae2abeb4af95 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Tue, 4 Feb 2025 12:45:41 -0500 Subject: [PATCH 1/2] feat(opac): began module public interface definition --- src/opac/public/opac.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/opac/public/opac.h diff --git a/src/opac/public/opac.h b/src/opac/public/opac.h new file mode 100644 index 0000000..3d71c2c --- /dev/null +++ b/src/opac/public/opac.h @@ -0,0 +1,23 @@ +#ifndef OPAC_H +#define OPAC_H + +#include +#include +#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& 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 From c304d002bb62b856ed49e19e02596da04b25211a Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Tue, 4 Feb 2025 12:55:49 -0500 Subject: [PATCH 2/2] feat(dobj): added error tracking to DObject DObject now includes an error code so that errors can be tracked with return values from functions --- src/dobj/private/DObject.cpp | 15 ++++++++++++++- src/dobj/public/DObject.h | 17 +++++++++++++++++ tests/dobj/DObjectTest.cpp | 23 +++++++++++------------ 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/dobj/private/DObject.cpp b/src/dobj/private/DObject.cpp index c1b1746..0ce0bed 100644 --- a/src/dobj/private/DObject.cpp +++ b/src/dobj/private/DObject.cpp @@ -48,6 +48,19 @@ bool DObject::isDebuggingEnabled() const noexcept { 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. */ @@ -203,4 +216,4 @@ std::ostream& operator<<(std::ostream& os, const DObject& obj) { os << "\n Data Type: " << obj.dataTypeMap.at(obj.data_.index()); os << "\n Plugins Registered: " << obj.plugins_.size() << "\n"; return os; -} \ No newline at end of file +} diff --git a/src/dobj/public/DObject.h b/src/dobj/public/DObject.h index 9a3102a..4261610 100644 --- a/src/dobj/public/DObject.h +++ b/src/dobj/public/DObject.h @@ -96,6 +96,7 @@ public: {18, "vector>"} }; + /** * @brief Placeholder type for plugins. * @@ -165,6 +166,21 @@ public: */ 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. * @@ -214,6 +230,7 @@ public: private: DataType data_; ///< The main data stored in the DObject. bool debugEnabled_ = false; ///< Indicates whether debugging is enabled. + int errorCode_ = 0; ///< Error code tracked by the DObject. std::map plugins_; ///< Registry for dynamically registered plugins. }; diff --git a/tests/dobj/DObjectTest.cpp b/tests/dobj/DObjectTest.cpp index 79e7ac6..1db09ed 100644 --- a/tests/dobj/DObjectTest.cpp +++ b/tests/dobj/DObjectTest.cpp @@ -60,6 +60,17 @@ TEST_F(DObjectTest, DebuggingFlag) { 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 */ @@ -72,16 +83,4 @@ TEST_F(DObjectTest, IntegrationTest) { 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); -// }