Guidelines for Namespaces in C++ Code

References

  • DataChallenge email discussion thread: Notes on C++ header files from DC2 phone con
  • Stroustrup discussion:
    • S8.2.3: Using Directives (see esp. last paragraph)
    • S8.2.8: Building namespaces out of other namespaces
    • S8.2.7: Namespace aliases
    • S8.4: general advice

Organizing code into Namespaces

This is simply my mail from the lists, and isn't definitive

I think that we agreed that all packages would lie at least one level below namespace lsst (or am I supposed to say above?), with the extra level being the package name.

For example, fw include files are included with

#include "lsst/fw/Citizen.h"

and are in namespace

lsst::fw

What's more, Trace is expected to use the same convention, but with the leading lsst omitted; e.g.

lsst::fw::Trace::trace("fw.Citizen", ...)

Note that the convention here is to add the class name.

I don't understand exactly how we package other parts of the system, but my guess is that it'll be similar, and that we can follow these conventions.

Proposed change to Coding Standards

Rule 4.13::

in progress