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 2 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
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ add_library(
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/schema/hdmf/base/Data.hpp
src/schema/hdmf/base/Container.cpp
src/schema/hdmf/table/DynamicTable.cpp
src/schema/hdmf/table/ElementIdentifiers.hpp
src/schema/hdmf/table/VectorData.hpp
src/schema/nwb/device/Device.cpp
src/schema/nwb/file/ElectrodeGroup.cpp
src/schema/nwb/file/ElectrodeTable.cpp
)

target_include_directories(
Expand Down
29 changes: 16 additions & 13 deletions src/NWBFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#include "NWBFile.hpp"

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

using namespace AQNWBIO;
namespace fs = std::filesystem;
using namespace AQNWB;
stephprince marked this conversation as resolved.
Show resolved Hide resolved

// NWBFile

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

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

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

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

elecTable.electrodeDataset->dataset = createRecordingData(
Expand Down Expand Up @@ -137,12 +138,14 @@ 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()
std::filesystem::path currentFile = __FILE__;
std::filesystem::path schemaDir = currentFile.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
4 changes: 2 additions & 2 deletions src/NWBFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "io/BaseIO.hpp"

namespace AQNWBIO
namespace AQNWB
{
/**
* @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
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
2 changes: 1 addition & 1 deletion src/io/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
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
12 changes: 6 additions & 6 deletions src/io/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
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Container.hpp"
#include "schema/hdmf/base/Container.hpp"

using namespace AQNWBIO;
using namespace AQNWB::Schema;

// Container

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "io/BaseIO.hpp"

namespace AQNWBIO
namespace AQNWB::Schema
{
/**
* @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::Schema
4 changes: 2 additions & 2 deletions src/hdmf/base/Data.hpp → src/schema/hdmf/base/Data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "io/BaseIO.hpp"

namespace AQNWBIO
namespace AQNWB::Schema
{
/**
* @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::Schema
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "DynamicTable.hpp"
#include "schema/hdmf/table/DynamicTable.hpp"

using namespace AQNWBIO;
using namespace AQNWB::Schema;

// 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 "schema/hdmf/base/Container.hpp"
#include "schema/hdmf/table/ElementIdentifiers.hpp"
#include "schema/hdmf/table/VectorData.hpp"

namespace AQNWBIO
namespace AQNWB::Schema
{
/**
* @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::Schema
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include "hdmf/base/Data.hpp"
#include "schema/hdmf/base/Data.hpp"

namespace AQNWBIO
namespace AQNWB::Schema
{
/**
* @brief A list of unique identifiers for values within a dataset, e.g. rows of
Expand All @@ -11,4 +11,4 @@ namespace AQNWBIO
class ElementIdentifiers : public Data
{
};
} // namespace AQNWBIO
} // namespace AQNWB::Schema
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "VectorData.hpp"
#include "schema/hdmf/table/VectorData.hpp"

using namespace AQNWBIO;
using namespace AQNWB::Schema;

// VectorData
std::string VectorData::getDescription() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <string>

#include "hdmf/base/Data.hpp"
#include "schema/hdmf/base/Data.hpp"

namespace AQNWBIO
namespace AQNWB::Schema
{
/**
* @brief An n-dimensional dataset representing a column of a DynamicTable.
Expand All @@ -24,4 +24,4 @@ class VectorData : public Data
*/
std::string description;
};
} // namespace AQNWBIO
} // namespace AQNWB::Schema
4 changes: 2 additions & 2 deletions src/device/Device.cpp → src/schema/nwb/device/Device.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Device.hpp"
#include "schema/nwb/device/Device.hpp"

using namespace AQNWBIO;
using namespace AQNWB::Schema;

// Device
/** Constructor */
Expand Down
6 changes: 3 additions & 3 deletions src/device/Device.hpp → src/schema/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 "schema/hdmf/base/Container.hpp"

namespace AQNWBIO
namespace AQNWB::Schema
{
/**
* @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::Schema
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ElectrodeGroup.hpp"
#include "schema/nwb/file/ElectrodeGroup.hpp"

using namespace AQNWBIO;
using namespace AQNWB::Schema;

// 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 "schema/hdmf/base/Container.hpp"
#include "schema/nwb/device/Device.hpp"

namespace AQNWBIO
namespace AQNWB::Schema
{
/**
* @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::Schema
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ElectrodeTable.hpp"
#include "schema/nwb/file/ElectrodeTable.hpp"

using namespace AQNWBIO;
using namespace AQNWB::Schema;

// ElectrodeTable

Expand Down
Loading