Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Aug 28, 2024
1 parent 7a18056 commit e354961
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 35 deletions.
4 changes: 2 additions & 2 deletions resources/generate_spec_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
with open(header_file, 'a') as fo:
fo.write(f'const std::string namespaces = R"delimiter(\n{json.dumps(ns_output, separators=(',', ':'))})delimiter";\n\n')
fo.write('void registerVariables(std::map<std::string, const std::string*>& registry) {\n')
fo.write(''.join([f' registry["{name.replace('_', '.')}"] = &{name};\n' for name in var_names]))
fo.write(f' registry["namespace"] = &namespaces;\n')
fo.write(''.join([f' registry["{name.replace('_', '.')}"] = &{name};\n' for name in var_names]))
fo.write(f' registry["namespace"] = &namespaces;\n')
fo.write(f'}};\n}} // namespace AQNWB::spec::{ns['name'].replace('-', '_')}\n')
21 changes: 14 additions & 7 deletions src/nwb/NWBFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ Status NWBFile::createFileStructure()

io->createGroup("/specifications");
io->createReferenceAttribute("/specifications", "/", ".specloc");
cacheSpecifications("core", spec::core::version, spec::core::registerVariables);
cacheSpecifications("hdmf-common", spec::hdmf_common::version, spec::hdmf_common::registerVariables);
cacheSpecifications("hdmf-experimental", spec::hdmf_experimental::version, spec::hdmf_experimental::registerVariables);
cacheSpecifications(
"core", spec::core::version, spec::core::registerVariables);
cacheSpecifications("hdmf-common",
spec::hdmf_common::version,
spec::hdmf_common::registerVariables);
cacheSpecifications("hdmf-experimental",
spec::hdmf_experimental::version,
spec::hdmf_experimental::registerVariables);

std::string time = getCurrentTime();
std::vector<std::string> timeVec = {time};
Expand Down Expand Up @@ -149,9 +154,10 @@ void NWBFile::stopRecording()
io->stopRecording();
}

void NWBFile::cacheSpecifications(const std::string& specPath,
const std::string& version,
void (*registerFunc)(std::map<std::string, const std::string*>&))
void NWBFile::cacheSpecifications(
const std::string& specPath,
const std::string& version,
void (*registerFunc)(std::map<std::string, const std::string*>&))
{
std::map<std::string, const std::string*> registry;
registerFunc(registry);
Expand All @@ -160,7 +166,8 @@ void NWBFile::cacheSpecifications(const std::string& specPath,
io->createGroup("/specifications/" + specPath + "/" + version);

for (const auto& [name, content] : registry) {
io->createStringDataSet("/specifications/" + specPath + "/" + version + "/" + name, *content);
io->createStringDataSet(
"/specifications/" + specPath + "/" + version + "/" + name, *content);
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/nwb/NWBFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ class NWBFile
* @param registry The registry of specification files.
* @param versionNumber The version number of the specification files.
*/
void cacheSpecifications(const std::string& specPath,
const std::string& version,
void (*registerFunc)(std::map<std::string, const std::string*>&));
void cacheSpecifications(
const std::string& specPath,
const std::string& version,
void (*registerFunc)(std::map<std::string, const std::string*>&));

/**
* @brief Holds the Container (usually TimeSeries) objects that have been
Expand Down
29 changes: 15 additions & 14 deletions src/spec/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,20 @@ const std::string nwb_retinotopy = R"delimiter(
const std::string namespaces = R"delimiter(
{"namespaces":[{"name":"core","doc":"NWB namespace","author":["Andrew Tritt","Oliver Ruebel","Ryan Ly","Ben Dichter","Keith Godfrey","Jeff Teeters"],"contact":["[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]"],"full_name":"NWB core","schema":[{"namespace":"hdmf-common"},{"source":"nwb.base"},{"source":"nwb.device"},{"source":"nwb.epoch"},{"source":"nwb.image"},{"source":"nwb.file"},{"source":"nwb.misc"},{"source":"nwb.behavior"},{"source":"nwb.ecephys"},{"source":"nwb.icephys"},{"source":"nwb.ogen"},{"source":"nwb.ophys"},{"source":"nwb.retinotopy"}],"version":"2.7.0"}]})delimiter";

void registerVariables(std::map<std::string, const std::string*>& registry) {
registry["nwb.base"] = &nwb_base;
registry["nwb.device"] = &nwb_device;
registry["nwb.epoch"] = &nwb_epoch;
registry["nwb.image"] = &nwb_image;
registry["nwb.file"] = &nwb_file;
registry["nwb.misc"] = &nwb_misc;
registry["nwb.behavior"] = &nwb_behavior;
registry["nwb.ecephys"] = &nwb_ecephys;
registry["nwb.icephys"] = &nwb_icephys;
registry["nwb.ogen"] = &nwb_ogen;
registry["nwb.ophys"] = &nwb_ophys;
registry["nwb.retinotopy"] = &nwb_retinotopy;
registry["namespace"] = &namespaces;
void registerVariables(std::map<std::string, const std::string*>& registry)
{
registry["nwb.base"] = &nwb_base;
registry["nwb.device"] = &nwb_device;
registry["nwb.epoch"] = &nwb_epoch;
registry["nwb.image"] = &nwb_image;
registry["nwb.file"] = &nwb_file;
registry["nwb.misc"] = &nwb_misc;
registry["nwb.behavior"] = &nwb_behavior;
registry["nwb.ecephys"] = &nwb_ecephys;
registry["nwb.icephys"] = &nwb_icephys;
registry["nwb.ogen"] = &nwb_ogen;
registry["nwb.ophys"] = &nwb_ophys;
registry["nwb.retinotopy"] = &nwb_retinotopy;
registry["namespace"] = &namespaces;
};
} // namespace AQNWB::spec::core
11 changes: 6 additions & 5 deletions src/spec/hdmf_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ const std::string sparse = R"delimiter(
const std::string namespaces = R"delimiter(
{"namespaces":[{"name":"hdmf-common","doc":"Common data structures provided by HDMF","author":["Andrew Tritt","Oliver Ruebel","Ryan Ly","Ben Dichter"],"contact":["[email protected]","[email protected]","[email protected]","[email protected]"],"full_name":"HDMF Common","schema":[{"source":"base"},{"source":"table"},{"source":"sparse"}],"version":"1.8.0"}]})delimiter";

void registerVariables(std::map<std::string, const std::string*>& registry) {
registry["base"] = &base;
registry["table"] = &table;
registry["sparse"] = &sparse;
registry["namespace"] = &namespaces;
void registerVariables(std::map<std::string, const std::string*>& registry)
{
registry["base"] = &base;
registry["table"] = &table;
registry["sparse"] = &sparse;
registry["namespace"] = &namespaces;
};
} // namespace AQNWB::spec::hdmf_common
9 changes: 5 additions & 4 deletions src/spec/hdmf_experimental.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ const std::string resources = R"delimiter(
const std::string namespaces = R"delimiter(
{"namespaces":[{"name":"hdmf-experimental","doc":"Experimental data structures provided by HDMF. These are not guaranteed to be available in the future.","author":["Andrew Tritt","Oliver Ruebel","Ryan Ly","Ben Dichter","Matthew Avaylon"],"contact":["[email protected]","[email protected]","[email protected]","[email protected]","[email protected]"],"full_name":"HDMF Experimental","schema":[{"namespace":"hdmf-common"},{"source":"experimental"},{"source":"resources"}],"version":"0.5.0"}]})delimiter";

void registerVariables(std::map<std::string, const std::string*>& registry) {
registry["experimental"] = &experimental;
registry["resources"] = &resources;
registry["namespace"] = &namespaces;
void registerVariables(std::map<std::string, const std::string*>& registry)
{
registry["experimental"] = &experimental;
registry["resources"] = &resources;
registry["namespace"] = &namespaces;
};
} // namespace AQNWB::spec::hdmf_experimental

0 comments on commit e354961

Please sign in to comment.