Skip to content
44 changes: 38 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ endif()

include(GNUInstallDirs)

option(USE_SQLITE "Enable SQLite support" OFF)

# Set project directory strucuture
set(SRC_DIR src)
set(INCLUDE_DIR include)
Expand Down Expand Up @@ -102,6 +104,7 @@ set(HEADERS
${DATA_DIR_INC}/DataPriorityObject.h
${DATA_DIR_INC}/DataContainer.h
${DATA_DIR_INC}/InMemContainer.h
${DATA_DIR_INC}/DatabaseContainer.h

${COMM_DIR_INC}/CommSocket.h
${COMM_DIR_INC}/CommString.h
Expand Down Expand Up @@ -141,11 +144,25 @@ set(HEADERS
${SYNC_BENCH_INC}/FromFileGen.h
)

# Add gensync library
if(USE_SQLITE STREQUAL "ON")
message(STATUS "SQLite support ENABLED")
list(APPEND SOURCE_FILES ${DATA_DIR}/SQLiteContainer.cpp)
list(APPEND HEADERS ${DATA_DIR_INC}/SQLiteContainer.h)
set(USE_SQLITE_DEFINE USE_SQLITE)
else()
message(STATUS "SQLite support DISABLED")
set(USE_SQLITE_DEFINE "")
endif()

# Now create gensync library AFTER conditionals
add_library(gensync STATIC ${SOURCE_FILES} ${HEADERS})
target_include_directories(gensync PUBLIC ${INCLUDE_DIR})
target_compile_definitions(gensync PUBLIC RECORD="${RECORD_DIR}")
target_compile_definitions(gensync PUBLIC DEFAULT_LOGLEVEL=${DEFAULT_LOG_LEVEL})
if(USE_SQLITE)
target_compile_definitions(gensync PUBLIC ${USE_SQLITE_DEFINE})
target_link_libraries(gensync PUBLIC sqlite3)
endif()

# include Apache Data Sketches as a header-only library
target_link_libraries(gensync PUBLIC ntl pthread gmp)
Expand Down Expand Up @@ -182,19 +199,34 @@ target_link_libraries(EncodeJoin gensync)
macro(add_group_test dir name)
file(GLOB testPaths ${dir}/*Test.cpp ${dir}/*Tests.cpp)

# add one executable with all tests
add_executable(${name} ${TEST_RUNNER} ${testPaths})
set(filteredTestPaths "")

foreach(test ${testPaths})
get_filename_component(testFileName ${test} NAME)

# Skip SQLiteContainerTest if USE_SQLITE is OFF
if(testFileName MATCHES "SQLiteContainerTest.cpp")
if(USE_SQLITE)
list(APPEND filteredTestPaths ${test})
endif()
else()
list(APPEND filteredTestPaths ${test})
endif()
endforeach()

# Add one executable with all tests
add_executable(${name} ${TEST_RUNNER} ${filteredTestPaths})
target_link_libraries(${name} gensync cppunit)
target_include_directories(${name} PRIVATE tests)

# add an executable for each test file and register it
foreach(test ${testPaths})
# Add an executable for each test file and register it
foreach(test ${filteredTestPaths})
get_filename_component(testName ${test} NAME_WE)
add_executable(${testName} ${TEST_RUNNER} ${test})
target_link_libraries(${testName} gensync cppunit)
target_include_directories(${testName} PRIVATE tests)
add_test(${testName} ${testName})
endforeach(test)
endforeach()
endmacro()

if(BUILD_TESTS)
Expand Down
8 changes: 8 additions & 0 deletions include/GenSync/Aux/UID.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ class UID {
return myID;
}

/**
* @return Sets the ID of this object.
*/
void setObjectID(int newID){
myID = newID;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple function, but proper documentation is required



private:
int myID; /** the ID of this object */
static int ID_count; /** Maintains a count of the number of UIDs created in the program thus far. */
Expand Down
9 changes: 6 additions & 3 deletions include/GenSync/Data/DataContainer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* This code is part of the GenSync project developed at Boston University. Please see the README for use and references. */
// Created by GregoryFan on 7/10/2025
//

#ifndef DATACONTAINER_H
#define DATACONTAINER_H
#include <GenSync/Data/DataObject.h>
Expand Down Expand Up @@ -170,7 +173,7 @@ class DataContainer{
virtual const_iterator begin() const = 0;

/**
* @return A const iterator that points to the beginning of the container.
* @return A const iterator that points to the final item of the container.
*/
virtual const_iterator end() const = 0;

Expand All @@ -190,12 +193,12 @@ class DataContainer{
virtual void clear() = 0;

/**
* Removes all DataObjects that contain the internal data as the given DataObject.
* Removes the first DataObject that contain the internal data as the given DataObject.
* The internal data refers to the information that the DataObject represents.
* @param val The given DataObject.
* @return Returns true if object is successfully removed.
*/
virtual bool remove (const shared_ptr<DataObject>& val) = 0;
virtual bool remove(const shared_ptr<DataObject>& val) = 0;

/**
* Pushes a given DataObject into the container for storage.
Expand Down
74 changes: 74 additions & 0 deletions include/GenSync/Data/DatabaseContainer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* This code is part of the GenSync project developed at Boston University. Please see the README for use and references. */
// Created by GregoryFan on 7/10/2025
//
#ifndef DATABASECONTAINER_H
#define DATABASECONTAINER_H
#include <GenSync/Data/DataContainer.h>

/**
* Implements a generic container that stores DataObject information.
* Information stored will be based on different database implementations.
*/
class DatabaseContainer : public DataContainer {
public:
//aliases
using DataContainer::iterator;
using DataContainer::const_iterator;
using DataContainer::size_type;

/**
* Default destructor, meant to be overriden by subclasses.
*/
virtual ~DatabaseContainer() = default;

/**
* @return An iterator that points to the beginning of the container.
*/
virtual iterator begin() override = 0;

/**
* @return An iterator that points to the end of the container.
*/
virtual iterator end() override = 0;

/**
* @return A const iterator that points to the beginning of the container.
*/
virtual const_iterator begin() const override = 0;

/**
* @return A const iterator that points to the end of the container.
*/
virtual const_iterator end() const override = 0;

/**
* @return The number of items inside the container.
*/
virtual size_type size() const override = 0;

/**
* @return Whether the container has no DataObjects.
*/
virtual bool empty() const override = 0;

/**
* Removes all DataObjects from the container.
*/
virtual void clear() override = 0;

/**
* Removes the first DataObject that contain the internal data as the given DataObject.
* The internal data refers to the information that the DataObject represents.
* @param val The given DataObject.
* @return Returns true if object is successfully removed.
*/
virtual bool remove (const shared_ptr<DataObject>& val) override = 0;

/**
* Pushes a given DataObject into the container for storage.
* @param val The given DataObject to store.
*/
virtual void add (const shared_ptr<DataObject>& val) override = 0;

};
#endif
5 changes: 4 additions & 1 deletion include/GenSync/Data/InMemContainer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* This code is part of the GenSync project developed at Boston University. Please see the README for use and references. */
// Created by GregoryFan on 7/10/2025
//

#ifndef INMEMCONTAINER_H
#define INMEMCONTAINER_H
#include <GenSync/Data/DataContainer.h>
Expand Down Expand Up @@ -127,7 +130,7 @@ class InMemContainer : public DataContainer{
void clear() override;

/**
* Removes all DataObjects that contain the internal data as the given DataObject.
* Removes the first DataObject that contain the internal data as the given DataObject.
* The internal data refers to the information that the DataObject represents.
* @param val The given DataObject.
* @return Returns true if object is successfully removed.
Expand Down
Loading