diff --git a/sbg/Makefile.include b/sbg/Makefile.include index dae4948..c17a937 100755 --- a/sbg/Makefile.include +++ b/sbg/Makefile.include @@ -2,6 +2,7 @@ UTIL_ROOT := util SBG_ROOT := sbg DTO_ROOT := sbg/dto +CONVERTERS_ROOT := sbg/dto/converters # Sources SBG_SRC := \ @@ -16,7 +17,8 @@ DTO_ROOT := sbg/dto $(SBG_ROOT)/pw_map.cpp \ $(SBG_ROOT)/sbg.cpp \ $(SBG_ROOT)/sbg_algorithms.cpp \ - $(DTO_ROOT)/interval_dto.cpp + $(DTO_ROOT)/interval_dto.cpp \ + $(CONVERTERS_ROOT)/interval_dto_converter.cpp include util/Makefile.include @@ -25,4 +27,5 @@ SBG_OBJ=$(addprefix $(BUILD_DIR)/, $(SBG_SRC:.cpp=.o)) create-folders:: @mkdir -p $(BUILD_DIR)/$(SBG_ROOT) \ - @mkdir -p $(BUILD_DIR)/$(DTO_ROOT) + @mkdir -p $(BUILD_DIR)/$(DTO_ROOT) \ + @mkdir -p $(BUILD_DIR)/$(CONVERTERS_ROOT) diff --git a/sbg/dto/converters/interval_dto_converter.cpp b/sbg/dto/converters/interval_dto_converter.cpp new file mode 100644 index 0000000..b6178e0 --- /dev/null +++ b/sbg/dto/converters/interval_dto_converter.cpp @@ -0,0 +1,32 @@ +/******************************************************************************* + + This file is part of Set--Based Graph Library. + + SBG Library is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SBG Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SBG Library. If not, see . + + ******************************************************************************/ + +#include "sbg/dto/converters/interval_dto_converter.hpp" + +namespace SBG { + +namespace API { + +SBG::LIB::Interval IntervalDTOConverter::convertToInterval(const IntervalDTO& dto) { + return SBG::LIB::Interval(dto.begin_, dto.step_, dto.end_); +} + +} // namespace API + +} // namespace SBG \ No newline at end of file diff --git a/sbg/dto/converters/interval_dto_converter.hpp b/sbg/dto/converters/interval_dto_converter.hpp new file mode 100644 index 0000000..e23efe0 --- /dev/null +++ b/sbg/dto/converters/interval_dto_converter.hpp @@ -0,0 +1,53 @@ +/** @file interval_dto_converter.hpp + + @brief IntervalDTOConverter implementation + + The IntervalDTOConverter provides the methods to convert an IntervalDTO to + the corresponding interval representation. Currently, it can convert to + LIB::Interval, but more conversions can/will be added in the future. + +
+ + This file is part of Set--Based Graph Library. + + SBG Library is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SBG Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SBG Library. If not, see . + + ******************************************************************************/ + +#ifndef SBG_DTO_INTERVAL_CONVERTER_HPP +#define SBG_DTO_INTERVAL_CONVERTER_HPP + +#include "sbg/dto/interval_dto.hpp" +#include "sbg/interval.hpp" + +namespace SBG { + +namespace API { + +class IntervalDTOConverter { +public: + /** + * @brief Converts an IntervalDTO object to an actual interval implementation (e.g., LIB::Interval). + * + * @param dto The IntervalDTO object to convert. + * @return SBG::LIB::Interval The converted interval object. + */ + static SBG::LIB::Interval convertToInterval(const IntervalDTO& dto); +}; + +} // namespace API + +} // namespace SBG + +#endif // SBG_DTO_INTERVAL_CONVERTER_HPP