-
Notifications
You must be signed in to change notification settings - Fork 87
Library structure
Hannes Hauswedell edited this page Jun 30, 2017
·
5 revisions
There are three structures or hierarchies in the library:
- Filesystem hierarchy
- Module hierarchy (almost identical to filesystem hierarchy)
- Namespace hierarchy
- The library is structured into modules and sub-modules.
- Modules are sub-directories of the top-level include directory.
- Sub-modules are all sub-directories of module directories with the exception of sub-folders called
detail(see below). - Modules and sub-modules may contain a
detailfolder that does not constitute a sub-module, it belong the (sub-)module it is in and contains implementation detail (all headers inside shall not be included by consumers of the library). - All top-level entities in
- header-only: SeqAn is a header-only library and all functionality is implemented in header files.
-
extension: Header files have the extension
.hpp. -
file-names:
- all-lower snake_case
- only lower case standard characters
[a-z]and underscore! - generalised singular (
concept.hppinstead ofconcepts.hpp)
- utf8: All files are expected to be UTF-8 encoded. Special characters are allowed in documentation and string literals, but not in regular code (function names etc) and file names.
- self-contained: every header shall include every other header that it needs.
-
seqan3/core/platform.hpp: every header that doesn't include another SeqAn3 header shall includeseqan3/core/platform.hpp. -
visibility: every header that is not in a
detailsubfolder or contains_detailin it's name is considered part of the API and may be directly included by users of the library.
-
Copyright notice:
- Copy from the license file or another header.
- Update the year if necessary.
- Don't add an Author line, instead add it to doc (see below).
-
File-Documentation:
-
\fileThis says doxygen that the documentation block belongs to this file -
\brief+ one-line description starting with upper case and ending in. \author your name <your AT mail.com>-
\ingroup MODULENAME(e.g.alphabet,core...) - optionally a longer description
-
-
Single-inclusion:
#pragma once(more information); we don't use header guards. -
Names and order of includes: (an empty line between each block, sorted alphabetically within)
- C system headers (rarely)
- C++ Standard Library headers
- SDSL headers (in
<>) - Ranges-V3 headers (in
<>) - SeqAn3 headers (also in
<>!)
-
rest of file (likely starts with a namespace opening)
// ============================================================================
// SeqAn - The Library for Sequence Analysis
// ============================================================================
//
// Copyright (c) 2006-2017, Knut Reinert & Freie Universitaet Berlin
// Copyright (c) 2016-2017, Knut Reinert & MPI Molekulare Genetik
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ============================================================================
/*!\file
* \brief Contains many nice things.
* \author Hannes Hauswedell <hannes.hauswedell AT fu-berlin.de>
* \ingroup alphabet
*/
#pragma once
#include <any>
#include <type_traits>
#include <vector>
#include <range/v3/view/drop.hpp>
#include <range/v3/view/take.hpp>
#include <seqan3/container/concepts.hpp>
// here comes the codeIn some cases you need headers only in DEBUG mode, e.g. when static_asserting a concept. In these cases you may include the header inside the DEBUG block, but only if this actually improves readability of the file.
10 different DEBUG block which each include different headers do not improve readability, in this case please move everything to an extra _detail.hpp.
-
namespace seqan3: everything, except the following exceptions -
namespace seqan3::detail: all free/global functions, metafunctions, static variables and class definitions that are considered implementation detail and not part of the API- if you write lot's of code that is specific to a module or file and may collide with other implementations, you can create sub-namespaces under
detail
- if you write lot's of code that is specific to a module or file and may collide with other implementations, you can create sub-namespaces under
-
namespace seqan3::literals: seqan-defined literals -
namespace seqan3::action: seqan-defined actions -
namespace seqan3::view: seqan-defined views -
namespace std: overloads ofstd::functions likestd::begin(rarely) - nothing should be in the global namespace
- never have
using namespace ...in a header file
- braces go on newline
- closing braces shall be documented
- there is no indention!
- for better readability and because we don't indent, nested namespaces are not declared inside parent, but separately and with full name
namespace seqan3::detail
{
void my_non_public_function()
{
// ...
}
} // namespace seqan3::detail
namespace seqan3
{
void my_public_function()
{
detail::my_non_public_function();
// ...
}
} // namespace seqan3