-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! The approach looks overall good to me. A couple of suggestions below.
Not sure if it's worth noting but the nested namespace definitions (namespace A::B::C) were added in C++17 so if we want to be compatible with older compilers we would need the longer, separate namespace definitions (e.g. namespace A { namespace B { namespace C { }}}).
I would go with the longer definition of namespace A { namespace B
. I don't think the short-hand adds that much that it's worth requiring C++ 17 for.
- Add
AQNWB::HDF5
andAQNWB::Schema
sub namespaces with everything else in the main namespace.
I agree, going too deep with the nesting is not useful at this point and this strikes a nice balance between separating concerns with namespaces while keeping the code readable by avoiding too many namespaces. 👍
I would suggest the following changes:
- Instead of
schema
I think calling the namespacenwb
would be more intuitive for users and also leave the termschema
open in case we need to eventually add functionality for interacting with schema - I would match the folder structure with the namespaces structure, i.e., have two subfolders:
nwb
andhdf5
and have all the files for that namespace in those folders. I think it's Ok to have subfolders within those folders if necessary that are not separate sub-namespaces if necessary. To match the folder structure, I think this means thatBaseIO
would move fromhdf5
to the main folderNWBFile
would move from the main folder to thenwb
namespace
If you would like to use more nested namespaces with matching folder structure, but still keep code readable, we could use |
Sounds good! I changed the name to
Wanted to add that I realized there was at least one other place where I've used C++17 features (mainly when using the |
We should look at some of the acquisition system software what they allow. I suspect that C++11 is fine but I wouldn't be surprised if C++17 is not yet supported. In general I think if it's not adding significant value, then avoiding C+17 features seems preferable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a couple of additional comments, but otherwise this looks good.
Digging around the web a bit more, it looks like C++17 should be fine with most compilers less than 3-5years old. So C++17 I think should be Ok. https://en.cppreference.com/w/cpp/compiler_support/17 I think we should avoid C++ 20 features as compiler support seems to be still not as mature and widespread. E.g., the GCC status page says "Because the ISO C++20 standard is very recent, GCC's support is experimental" (see https://gcc.gnu.org/projects/cxx-status.html). The compiler list also still shows a bunch of red for C++ 20 https://en.cppreference.com/w/Template:cpp/compiler_support/20 . Also, to use C++ 20 seem to still required additional build parameters, e.g., C++ 23 and 26 are too recent and support is still too spotty so we should not use those features yet https://en.cppreference.com/w/cpp/compiler_support |
using Status = AQNWB::Types::Status; | ||
using SizeArray = AQNWB::Types::SizeArray; | ||
using SizeType = AQNWB::Types::SizeType; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Got it, that's a really helpful page for looking at the compiler support. I can change back the namespace definitions then if we think C++17 should be ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Whichever style you prefer for the namespace definitions is fine with me. |
Ok, I have a slight preference for the newer style just in case we ever need deeper nesting so I will go with that! |
Fix #14 and #3.
We mentioned previously that we wanted to consider adding sub-namespaces to the main AQNWB namespace (see here). For example, adding something like
AQNWB::HDF5::HDF5IO
to isolate the backends (see here).If we want to add nested namespaces, here were a couple options I was thinking of for how to structure these:
AQNWB::HDF5
andAQNWB::Schema
sub namespaces with everything else in the main namespace. Additional backends would get their own subnamespaces. The current version of the PR implements this - adding the nestedSchema
andHDF5
namespaces and restructuring schema files into a single schema subfolder.AQNWB::IO
,AQNWB::IO::HDF5
,AQNWB::Schema::HDMF
,AQNWB::Schema::NWB
namespaces. This more closely matches the folder structure but adds deeper nesting which might make it less readable. (A slightly related question, do we want the folder naming to be more like pynwb withnwb-schema/core
andnwb-schema/hdmf-common-schema
subfolders?)Not sure if it's worth noting but the nested namespace definitions (namespace A::B::C) were added in C++17 so if we want to be compatible with older compilers we would need the longer, separate namespace definitions (e.g. namespace A { namespace B { namespace C { }}}).