Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nested namespaces #17

Merged
merged 7 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ 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/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
src/nwb/core/device/Device.cpp
src/nwb/core/file/ElectrodeGroup.cpp
src/nwb/core/file/ElectrodeTable.cpp
)

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;
Comment on lines +13 to +15
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these using still necessary? Just wondering, because BaseIO and Types are now in the same namespace?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was using it more to create a type alias for Status, SizeArray, and SizeType, but I can replace the usage with Types::Status throughout BaseIO, HDF5IO if that's better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the clarification. Makes sense. This is fine.


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
4 changes: 2 additions & 2 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 @@ -275,4 +275,4 @@ class HDF5RecordingData : public BaseRecordingData
*/
Status checkStatus(int status);
};
} // namespace AQNWBIO
} // namespace AQNWB::HDF5
33 changes: 18 additions & 15 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/core/device/Device.hpp"
#include "nwb/core/file/ElectrodeGroup.hpp"
#include "nwb/core/file/ElectrodeTable.hpp"

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

// NWBFile

Expand Down Expand Up @@ -98,17 +97,18 @@ Status NWBFile::startRecording()
std::string devicePath = "general/devices/" + groupName;
std::string elecPath = "general/extracellular_ephys/" + groupName;

Device device = Device(devicePath, io, "description", "unknown");
NWB::Device device = NWB::Device(devicePath, io, "description", "unknown");
device.initialize();

ElectrodeGroup elecGroup =
ElectrodeGroup(elecPath, io, "description", "unknown", device);
NWB::ElectrodeGroup elecGroup =
NWB::ElectrodeGroup(elecPath, io, "description", "unknown", device);
elecGroup.initialize();
}

// Create electrode table
std::string electrodePath = "general/extracellular_ephys/electrodes/";
ElectrodeTable elecTable = ElectrodeTable(electrodePath, io, channels);
NWB::ElectrodeTable elecTable =
NWB::ElectrodeTable(electrodePath, io, channels);
elecTable.initialize();

elecTable.electrodeDataset->dataset = createRecordingData(
Expand Down Expand Up @@ -137,12 +137,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 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
stephprince marked this conversation as resolved.
Show resolved Hide resolved
{
/**
* @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
4 changes: 2 additions & 2 deletions src/device/Device.cpp → src/nwb/core/device/Device.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Device.hpp"
#include "nwb/core/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/core/device/Device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

stephprince marked this conversation as resolved.
Show resolved Hide resolved
#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/core/file/ElectrodeGroup.hpp"

using namespace AQNWBIO;
using namespace AQNWB::NWB;

// ElectrodeGroup

Expand Down
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/core/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/core/file/ElectrodeTable.hpp"

using namespace AQNWBIO;
using namespace AQNWB::NWB;

// ElectrodeTable

Expand Down
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