Skip to content

Commit

Permalink
Merge pull request #17 from lbl-cbg/add-nested-namespaces
Browse files Browse the repository at this point in the history
Add nested namespaces
  • Loading branch information
stephprince authored Apr 3, 2024
2 parents 76a974c + 9152fdb commit eabd559
Show file tree
Hide file tree
Showing 24 changed files with 113 additions and 110 deletions.
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ include(cmake/variables.cmake)

add_library(
aq-nwb_lib OBJECT
src/NWBFile.cpp
src/Utils.hpp
src/io/HDF5IO.cpp
src/io/BaseIO.cpp
src/hdmf/base/Data.hpp
src/hdmf/base/Container.cpp
src/hdmf/table/DynamicTable.cpp
src/hdmf/table/ElementIdentifiers.hpp
src/hdmf/table/VectorData.hpp
src/device/Device.cpp
src/file/ElectrodeGroup.cpp
src/file/ElectrodeTable.cpp
src/BaseIO.cpp
src/hdf5/HDF5IO.cpp
src/nwb/NWBFile.cpp
src/nwb/device/Device.cpp
src/nwb/file/ElectrodeGroup.cpp
src/nwb/file/ElectrodeTable.cpp
src/nwb/hdmf/base/Data.hpp
src/nwb/hdmf/base/Container.cpp
src/nwb/hdmf/table/DynamicTable.cpp
src/nwb/hdmf/table/ElementIdentifiers.hpp
src/nwb/hdmf/table/VectorData.hpp

)

target_include_directories(
Expand Down
2 changes: 1 addition & 1 deletion src/io/BaseIO.cpp → src/BaseIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Utils.hpp"

using namespace AQNWBIO;
using namespace AQNWB;

// BaseDataType

Expand Down
10 changes: 5 additions & 5 deletions src/io/BaseIO.hpp → src/BaseIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#define DEFAULT_STR_SIZE 256
#define DEFAULT_ARRAY_SIZE 1

using Status = Types::Status;
using SizeArray = Types::SizeArray;
using SizeType = Types::SizeType;
using Status = AQNWB::Types::Status;
using SizeArray = AQNWB::Types::SizeArray;
using SizeType = AQNWB::Types::SizeType;

namespace AQNWBIO
namespace AQNWB
{

class BaseRecordingData;
Expand Down Expand Up @@ -372,4 +372,4 @@ class BaseRecordingData
std::vector<uint32_t> rowXPos;
};

} // namespace AQNWBIO
} // namespace AQNWB
3 changes: 3 additions & 0 deletions src/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <vector>

namespace AQNWB
{
/**
* @brief Provides definitions for various types used in the project.
*/
Expand All @@ -27,3 +29,4 @@ class Types
*/
using SizeArray = std::vector<size_t>;
};
} // namespace AQNWB
4 changes: 2 additions & 2 deletions src/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>

namespace AQNWBIO
namespace AQNWB
{
/**
* @brief Generates a UUID (Universally Unique Identifier) as a string.
Expand Down Expand Up @@ -40,4 +40,4 @@ inline std::string getCurrentTime()

return oss.str();
}
} // namespace AQNWBIO
} // namespace AQNWB
12 changes: 6 additions & 6 deletions src/io/HDF5IO.cpp → src/hdf5/HDF5IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "Utils.hpp"

using namespace H5;
using namespace AQNWBIO;
using namespace AQNWB::HDF5;

// HDF5IO

Expand Down Expand Up @@ -342,7 +342,7 @@ Status HDF5IO::createStringDataSet(const std::string& path,
return Status::Success;
}

BaseRecordingData* HDF5IO::getDataSet(const std::string& path)
AQNWB::BaseRecordingData* HDF5IO::getDataSet(const std::string& path)
{
std::unique_ptr<DataSet> data;

Expand All @@ -364,10 +364,10 @@ BaseRecordingData* HDF5IO::getDataSet(const std::string& path)
}
}

BaseRecordingData* HDF5IO::createDataSet(const BaseDataType& type,
const SizeArray& size,
const SizeArray& chunking,
const std::string& path)
AQNWB::BaseRecordingData* HDF5IO::createDataSet(const BaseDataType& type,
const SizeArray& size,
const SizeArray& chunking,
const std::string& path)
{
std::unique_ptr<DataSet> data;
DSetCreatPropList prop;
Expand Down
12 changes: 6 additions & 6 deletions src/io/HDF5IO.hpp → src/hdf5/HDF5IO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DataType;
class Exception;
} // namespace H5

namespace AQNWBIO
namespace AQNWB::HDF5
{
class HDF5RecordingData; // declare here because gets used in HDF5IO class

Expand Down Expand Up @@ -216,10 +216,10 @@ class HDF5IO : public BaseIO
/**
* @brief Represents an HDF5 Dataset that can be extended indefinitely
in blocks.
*
* This class provides functionality for reading and writing 2D blocks of data
* (samples x channels) to an HDF5 dataset.
*/
*
* This class provides functionality for reading and writing 2D blocks of data
* (samples x channels) to an HDF5 dataset.
*/
class HDF5RecordingData : public BaseRecordingData
{
public:
Expand Down Expand Up @@ -275,4 +275,4 @@ class HDF5RecordingData : public BaseRecordingData
*/
Status checkStatus(int status);
};
} // namespace AQNWBIO
} // namespace AQNWB::HDF5
26 changes: 14 additions & 12 deletions src/NWBFile.cpp → src/nwb/NWBFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

#include "NWBFile.hpp"

#include "BaseIO.hpp"
#include "Utils.hpp"
#include "device/Device.hpp"
#include "file/ElectrodeGroup.hpp"
#include "file/ElectrodeTable.hpp"
#include "io/BaseIO.hpp"
#include "nwb/device/Device.hpp"
#include "nwb/file/ElectrodeGroup.hpp"
#include "nwb/file/ElectrodeTable.hpp"

using namespace AQNWBIO;
namespace fs = std::filesystem;
using namespace AQNWB::NWB;

// NWBFile

Expand Down Expand Up @@ -137,12 +136,15 @@ void NWBFile::cacheSpecifications(const std::string& specPath,
io->createGroup("/specifications/" + specPath);
io->createGroup("/specifications/" + specPath + versionNumber);

fs::path currentFile = __FILE__;
fs::path schemaDir = currentFile.parent_path().parent_path()
/ "resources/spec" / specPath / versionNumber;
std::filesystem::path currentFile = __FILE__;
std::filesystem::path schemaDir =
currentFile.parent_path().parent_path().parent_path() / "resources/spec"
/ specPath / versionNumber;

for (auto const& entry : fs::directory_iterator {schemaDir})
if (fs::is_regular_file(entry) && entry.path().extension() == ".json") {
for (auto const& entry : std::filesystem::directory_iterator {schemaDir})
if (std::filesystem::is_regular_file(entry)
&& entry.path().extension() == ".json")
{
std::string specName =
entry.path().filename().replace_extension("").string();
if (specName.find("namespace") != std::string::npos)
Expand All @@ -159,7 +161,7 @@ void NWBFile::cacheSpecifications(const std::string& specPath,
}

// recording data factory method /
std::unique_ptr<BaseRecordingData> NWBFile::createRecordingData(
std::unique_ptr<AQNWB::BaseRecordingData> NWBFile::createRecordingData(
BaseDataType type,
const SizeArray& size,
const SizeArray& chunking,
Expand Down
6 changes: 3 additions & 3 deletions src/NWBFile.hpp → src/nwb/NWBFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <cstdint>

#include "io/BaseIO.hpp"
#include "BaseIO.hpp"

namespace AQNWBIO
namespace AQNWB::NWB
{
/**
* @brief The NWBFile class provides an interface for setting up and managing
Expand Down Expand Up @@ -168,4 +168,4 @@ class NWBRecordingEngine
*/
std::vector<int64_t> smpBuffer;
};
} // namespace AQNWBIO
} // namespace AQNWB::NWB
4 changes: 2 additions & 2 deletions src/device/Device.cpp → src/nwb/device/Device.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Device.hpp"
#include "nwb/device/Device.hpp"

using namespace AQNWBIO;
using namespace AQNWB::NWB;

// Device
/** Constructor */
Expand Down
8 changes: 4 additions & 4 deletions src/device/Device.hpp → src/nwb/device/Device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include <string>

#include "hdmf/base/Container.hpp"
#include "io/BaseIO.hpp"
#include "BaseIO.hpp"
#include "nwb/hdmf/base/Container.hpp"

namespace AQNWBIO
namespace AQNWB::NWB
{
/**
* @brief Metadata about a data acquisition device, e.g., recording system,
Expand Down Expand Up @@ -60,4 +60,4 @@ class Device : public Container
*/
std::string manufacturer;
};
} // namespace AQNWBIO
} // namespace AQNWB::NWB
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ElectrodeGroup.hpp"
#include "nwb/file/ElectrodeGroup.hpp"

using namespace AQNWBIO;
using namespace AQNWB::NWB;

// ElectrodeGroup

Expand Down
10 changes: 5 additions & 5 deletions src/file/ElectrodeGroup.hpp → src/nwb/file/ElectrodeGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include <string>

#include "device/Device.hpp"
#include "hdmf/base/Container.hpp"
#include "io/BaseIO.hpp"
#include "BaseIO.hpp"
#include "nwb/device/Device.hpp"
#include "nwb/hdmf/base/Container.hpp"

namespace AQNWBIO
namespace AQNWB::NWB
{
/**
* @brief The ElectrodeGroup class represents a physical grouping of electrodes,
Expand Down Expand Up @@ -78,4 +78,4 @@ class ElectrodeGroup : public Container
*/
Device device;
};
} // namespace AQNWBIO
} // namespace AQNWB::NWB
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ElectrodeTable.hpp"
#include "nwb/file/ElectrodeTable.hpp"

using namespace AQNWBIO;
using namespace AQNWB::NWB;

// ElectrodeTable

Expand Down
12 changes: 6 additions & 6 deletions src/file/ElectrodeTable.hpp → src/nwb/file/ElectrodeTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include <string>

#include "hdmf/table/DynamicTable.hpp"
#include "hdmf/table/ElementIdentifiers.hpp"
#include "hdmf/table/VectorData.hpp"
#include "io/BaseIO.hpp"
#include "BaseIO.hpp"
#include "nwb/hdmf/table/DynamicTable.hpp"
#include "nwb/hdmf/table/ElementIdentifiers.hpp"
#include "nwb/hdmf/table/VectorData.hpp"

namespace AQNWBIO
namespace AQNWB::NWB
{
/**
* @brief Represents a table containing electrode metadata.
Expand Down Expand Up @@ -115,4 +115,4 @@ class ElectrodeTable : public DynamicTable
*/
std::string groupPath = "/general/extracellular_ephys/array1";
};
} // namespace AQNWBIO
} // namespace AQNWB::NWB
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Container.hpp"
#include "nwb/hdmf/base/Container.hpp"

using namespace AQNWBIO;
using namespace AQNWB::NWB;

// Container

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <memory>
#include <string>

#include "io/BaseIO.hpp"
#include "BaseIO.hpp"

namespace AQNWBIO
namespace AQNWB::NWB
{
/**
* @brief Abstract data type for a group storing collections of data and
Expand Down Expand Up @@ -48,4 +48,4 @@ class Container
*/
std::shared_ptr<BaseIO> io;
};
} // namespace AQNWBIO
} // namespace AQNWB::NWB
6 changes: 3 additions & 3 deletions src/hdmf/base/Data.hpp → src/nwb/hdmf/base/Data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <memory>

#include "io/BaseIO.hpp"
#include "BaseIO.hpp"

namespace AQNWBIO
namespace AQNWB::NWB
{
/**
* @brief An abstract data type for a dataset.
Expand All @@ -27,4 +27,4 @@ class Data
*/
std::unique_ptr<BaseRecordingData> dataset;
};
} // namespace AQNWBIO
} // namespace AQNWB::NWB
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "DynamicTable.hpp"
#include "nwb/hdmf/table/DynamicTable.hpp"

using namespace AQNWBIO;
using namespace AQNWB::NWB;

// DynamicTable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include <string>

#include "hdmf/base/Container.hpp"
#include "hdmf/table/ElementIdentifiers.hpp"
#include "hdmf/table/VectorData.hpp"
#include "io/BaseIO.hpp"
#include "BaseIO.hpp"
#include "nwb/hdmf/base/Container.hpp"
#include "nwb/hdmf/table/ElementIdentifiers.hpp"
#include "nwb/hdmf/table/VectorData.hpp"

namespace AQNWBIO
namespace AQNWB::NWB
{
/**
* @brief Represents a group containing multiple datasets that are aligned on
Expand Down Expand Up @@ -94,4 +94,4 @@ class DynamicTable : public Container
*/
std::vector<std::string> colNames;
};
} // namespace AQNWBIO
} // namespace AQNWB::NWB
Loading

0 comments on commit eabd559

Please sign in to comment.