669 lines
27 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PCL C++ Programming Style Guide</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> Point Cloud Library
</a>
<div class="version">
1.12.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<!-- Local TOC -->
<div class="local-toc"><ul>
<li><a class="reference internal" href="#">PCL C++ Programming Style Guide</a><ul>
<li><a class="reference internal" href="#naming">1. Naming</a><ul>
<li><a class="reference internal" href="#files">1.1. Files</a></li>
<li><a class="reference internal" href="#directories">1.2. Directories</a></li>
<li><a class="reference internal" href="#includes">1.3. Includes</a></li>
<li><a class="reference internal" href="#defines-macros">1.4. Defines &amp; Macros</a></li>
<li><a class="reference internal" href="#namespaces">1.5. Namespaces</a></li>
<li><a class="reference internal" href="#classes-structs">1.6. Classes / Structs</a></li>
<li><a class="reference internal" href="#functions-methods">1.7. Functions / Methods</a></li>
<li><a class="reference internal" href="#variables">1.8. Variables</a><ul>
<li><a class="reference internal" href="#iterators">1.8.1. Iterators</a></li>
<li><a class="reference internal" href="#constants">1.8.2. Constants</a></li>
<li><a class="reference internal" href="#member-variables">1.8.3. Member variables</a></li>
</ul>
</li>
<li><a class="reference internal" href="#return-statements">1.9. Return statements</a></li>
</ul>
</li>
<li><a class="reference internal" href="#indentation-and-formatting">2. Indentation and Formatting</a><ul>
<li><a class="reference internal" href="#id1">2.1. Namespaces</a></li>
<li><a class="reference internal" href="#classes">2.2. Classes</a></li>
<li><a class="reference internal" href="#id2">2.3. Functions / Methods</a></li>
<li><a class="reference internal" href="#braces">2.4. Braces</a></li>
<li><a class="reference internal" href="#spacing">2.5. Spacing</a></li>
<li><a class="reference internal" href="#automatic-code-formatting">2.6. Automatic code formatting</a><ul>
<li><a class="reference internal" href="#script-usage">2.6.1. Script usage</a></li>
</ul>
</li>
<li><a class="reference internal" href="#id3">2.7. Includes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#structuring">3. Structuring</a><ul>
<li><a class="reference internal" href="#classes-and-api">3.1. Classes and API</a></li>
<li><a class="reference internal" href="#passing-arguments">3.2. Passing arguments</a></li>
<li><a class="reference internal" href="#object-declaration">3.3. Object declaration</a><ul>
<li><a class="reference internal" href="#use-of-auto">3.3.1 Use of auto</a></li>
<li><a class="reference internal" href="#type-qualifiers-of-variables">3.3.2 Type qualifiers of variables</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Point Cloud Library</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li>PCL C++ Programming Style Guide</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="pcl-c-programming-style-guide">
<span id="pcl-style-guide"></span><h1>PCL C++ Programming Style Guide</h1>
<p>To make sure that all code in PCL is coherent and easily understood by other
developers and users, we follow a set of strict rules that everyone should
adopt. These rules are not to be broken unless there is a very good reason to
do so. Changes to these rules are always possible, but the person proposing and
changing a rule will have the unfortunate task to go and apply the rule change
to all the existing code.</p>
<div class="contents local topic" id="table-of-contents">
<p class="topic-title">Table of Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#naming" id="id4">1. Naming</a><ul>
<li><a class="reference internal" href="#files" id="id5">1.1. Files</a></li>
<li><a class="reference internal" href="#directories" id="id6">1.2. Directories</a></li>
<li><a class="reference internal" href="#includes" id="id7">1.3. Includes</a></li>
<li><a class="reference internal" href="#defines-macros" id="id8">1.4. Defines &amp; Macros</a></li>
<li><a class="reference internal" href="#namespaces" id="id9">1.5. Namespaces</a></li>
<li><a class="reference internal" href="#classes-structs" id="id10">1.6. Classes / Structs</a></li>
<li><a class="reference internal" href="#functions-methods" id="id11">1.7. Functions / Methods</a></li>
<li><a class="reference internal" href="#variables" id="id12">1.8. Variables</a><ul>
<li><a class="reference internal" href="#iterators" id="id13">1.8.1. Iterators</a></li>
<li><a class="reference internal" href="#constants" id="id14">1.8.2. Constants</a></li>
<li><a class="reference internal" href="#member-variables" id="id15">1.8.3. Member variables</a></li>
</ul>
</li>
<li><a class="reference internal" href="#return-statements" id="id16">1.9. Return statements</a></li>
</ul>
</li>
<li><a class="reference internal" href="#indentation-and-formatting" id="id17">2. Indentation and Formatting</a><ul>
<li><a class="reference internal" href="#id1" id="id18">2.1. Namespaces</a></li>
<li><a class="reference internal" href="#classes" id="id19">2.2. Classes</a></li>
<li><a class="reference internal" href="#id2" id="id20">2.3. Functions / Methods</a></li>
<li><a class="reference internal" href="#braces" id="id21">2.4. Braces</a></li>
<li><a class="reference internal" href="#spacing" id="id22">2.5. Spacing</a></li>
<li><a class="reference internal" href="#automatic-code-formatting" id="id23">2.6. Automatic code formatting</a><ul>
<li><a class="reference internal" href="#script-usage" id="id24">2.6.1. Script usage</a></li>
</ul>
</li>
<li><a class="reference internal" href="#id3" id="id25">2.7. Includes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#structuring" id="id26">3. Structuring</a><ul>
<li><a class="reference internal" href="#classes-and-api" id="id27">3.1. Classes and API</a></li>
<li><a class="reference internal" href="#passing-arguments" id="id28">3.2. Passing arguments</a></li>
<li><a class="reference internal" href="#object-declaration" id="id29">3.3. Object declaration</a><ul>
<li><a class="reference internal" href="#use-of-auto" id="id30">3.3.1 Use of auto</a></li>
<li><a class="reference internal" href="#type-qualifiers-of-variables" id="id31">3.3.2 Type qualifiers of variables</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="naming">
<h2>1. Naming</h2>
<div class="section" id="files">
<h3>1.1. Files</h3>
<p>All files should be <strong>under_scored</strong>.</p>
<ul class="simple">
<li>Header files have the extension <strong>.h</strong></li>
<li>Templated implementation files have the extension <strong>.hpp</strong></li>
<li>Source files have the extension <strong>.cpp</strong></li>
</ul>
</div>
<div class="section" id="directories">
<h3>1.2. Directories</h3>
<p>All directories and subdirectories should be <strong>under_scored</strong>.</p>
<ul class="simple">
<li>Header files should go under <strong>include/</strong></li>
<li>Templated implementation files should go under <strong>include/impl/</strong></li>
<li>Source files should go under <strong>src/</strong></li>
</ul>
</div>
<div class="section" id="includes">
<h3>1.3. Includes</h3>
<p>Include statements are made with <strong>“quotes”</strong> only if the file is in the
same directory, in any other case the include statement is made with
<strong>&lt;chevron_brackets&gt;</strong>, e.g.:</p>
<blockquote>
<div><div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">&lt;pcl/module_name/file_name.h&gt;</span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf">&lt;pcl/module_name/impl/file_name.hpp&gt;</span><span class="cp"></span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="defines-macros">
<h3>1.4. Defines &amp; Macros</h3>
<p>Macros should all be <strong>ALL_CAPITALS_AND_UNDERSCORED</strong>.</p>
<p>Include guards are not implemented with defines, instead <code class="docutils literal notranslate"><span class="pre">#pragma</span> <span class="pre">once</span></code> should be used.</p>
<blockquote>
<div><div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="c1">// the license</span>
<span class="cp">#pragma once</span>
<span class="c1">// the code</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="namespaces">
<h3>1.5. Namespaces</h3>
<p>Namespaces should be <strong>under_scored</strong>, e.g.:</p>
<blockquote>
<div><div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">pcl_io</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="classes-structs">
<h3>1.6. Classes / Structs</h3>
<p>Class names (and other type names) should be <strong>CamelCased</strong>.
Exception: if the class name contains a short acronym, the acronym itself
should be all capitals. Class and struct names are preferably <strong>nouns</strong>:
PFHEstimation instead of EstimatePFH.</p>
<p>Correct examples:</p>
<blockquote>
<div><div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">ExampleClass</span><span class="p">;</span>
<span class="k">class</span> <span class="nc">PFHEstimation</span><span class="p">;</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="functions-methods">
<h3>1.7. Functions / Methods</h3>
<p>Functions and class method names should be <strong>camelCased</strong>, and arguments are
<strong>under_scored</strong>. Function and method names are preferably <strong>verbs</strong>, and the name
should make clear what it does: checkForErrors() instead of errorCheck(),
dumpDataToFile() instead of dataFile().</p>
<p>Correct usage:</p>
<blockquote>
<div><div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span>
<span class="nf">applyExample</span> <span class="p">(</span><span class="kt">int</span> <span class="n">example_arg</span><span class="p">);</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="variables">
<h3>1.8. Variables</h3>
<p>Variable names should be <strong>under_scored</strong>.</p>
<blockquote>
<div><div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="n">my_variable</span><span class="p">;</span>
</pre></div>
</div>
</div></blockquote>
<div class="section" id="iterators">
<h4>1.8.1. Iterators</h4>
<p>Iterator variables should indicate what theyre iterating over, e.g.:</p>
<blockquote>
<div><div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="n">std</span><span class="o">::</span><span class="n">list</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">pid_list</span><span class="p">;</span>
<span class="n">std</span><span class="o">::</span><span class="n">list</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;::</span><span class="n">iterator</span> <span class="n">pid_it</span><span class="p">;</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="constants">
<h4>1.8.2. Constants</h4>
<p>Constants should be <strong>ALL_CAPITALS</strong>, e.g.:</p>
<blockquote>
<div><div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="k">const</span> <span class="k">static</span> <span class="kt">int</span> <span class="n">MY_CONSTANT</span> <span class="o">=</span> <span class="mi">1000</span><span class="p">;</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="member-variables">
<h4>1.8.3. Member variables</h4>
<p>Variables that are members of a class are <strong>under_scored_</strong>, with a trailing
underscore added, e.g.:</p>
<blockquote>
<div><div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="n">example_int_</span><span class="p">;</span>
</pre></div>
</div>
</div></blockquote>
</div>
</div>
<div class="section" id="return-statements">
<h3>1.9. Return statements</h3>
<p>Return statements should have their values in parentheses, e.g.:</p>
<blockquote>
<div><div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span>
<span class="nf">main</span> <span class="p">()</span>
<span class="p">{</span>
<span class="k">return</span> <span class="p">(</span><span class="mi">0</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div></blockquote>
<div class="line-block">
<div class="line"><br /></div>
</div>
</div>
</div>
<div class="section" id="indentation-and-formatting">
<h2>2. Indentation and Formatting</h2>
<p>The standard indentation for each block in PCL is <strong>2 spaces</strong>. Under no
circumstances, tabs or other spacing measures should be used. PCL uses a
variant of the GNU style formatting.</p>
<div class="section" id="id1">
<h3>2.1. Namespaces</h3>
<p>In both header and implementation files, namespaces are to be explicitly
declared, and their contents should not be indented, like clang-format
enforces in the Formatting CI job, e.g.:</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">pcl</span>
<span class="p">{</span>
<span class="k">class</span> <span class="nc">Foo</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">};</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="classes">
<h3>2.2. Classes</h3>
<p>The template parameters of a class should be declared on a different line,
e.g.:</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span> <span class="n">T</span><span class="o">&gt;</span>
<span class="k">class</span> <span class="nc">Foo</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="id2">
<h3>2.3. Functions / Methods</h3>
<p>The return type of each function declaration must be placed on a different
line, e.g.:</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span>
<span class="nf">bar</span> <span class="p">();</span>
</pre></div>
</div>
<p>Same for the implementation/definition, e.g.:</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span>
<span class="nf">bar</span> <span class="p">()</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
</pre></div>
</div>
<p>or</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span>
<span class="n">Foo</span><span class="o">::</span><span class="n">bar</span> <span class="p">()</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
</pre></div>
</div>
<p>or</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span> <span class="n">T</span><span class="o">&gt;</span> <span class="kt">void</span>
<span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;::</span><span class="n">bar</span> <span class="p">()</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="braces">
<h3>2.4. Braces</h3>
<p>Braces, both open and close, go on their own lines, e.g.:</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="n">a</span> <span class="o">&lt;</span> <span class="n">b</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Braces can be omitted if the enclosed block is a single-line statement, e.g.:</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="n">a</span> <span class="o">&lt;</span> <span class="n">b</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">a</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="spacing">
<h3>2.5. Spacing</h3>
<p>Well say it again: the standard indentation for each block in PCL is <strong>2
spaces</strong>. We also include a space before the bracketed list of arguments to a
function/method, e.g.:</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span>
<span class="nf">exampleMethod</span> <span class="p">(</span><span class="kt">int</span> <span class="n">example_arg</span><span class="p">);</span>
</pre></div>
</div>
<p>Class and struct members are indented by <strong>2 spaces</strong>. Access qualifiers (public, private and protected) are put at the
indentation level of the class body and members affected by these qualifiers are indented by one more level, i.e. 2 spaces. E.g.:</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="k">namespace</span> <span class="n">foo</span>
<span class="p">{</span>
<span class="k">class</span> <span class="nc">Bar</span>
<span class="p">{</span>
<span class="kt">int</span> <span class="n">i</span><span class="p">;</span>
<span class="k">public</span><span class="o">:</span>
<span class="kt">int</span> <span class="n">j</span><span class="p">;</span>
<span class="k">protected</span><span class="o">:</span>
<span class="kt">void</span>
<span class="n">baz</span> <span class="p">();</span>
<span class="p">};</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="automatic-code-formatting">
<h3>2.6. Automatic code formatting</h3>
<p>We currently use clang-format-10 as the tool for auto-formatting our C++ code.
Please note that different versions of clang-format can result in slightly different outputs.</p>
<p>The style rules mentioned in this document are enforced via <a class="reference external" href="https://github.com/PointCloudLibrary/pcl/blob/master/.clang-format">PCLs .clang-format file</a>.
The style files which were previously distributed should now be considered deprecated.</p>
<p>For the integration of clang-format with various text editors and IDEs, refer to this <a class="reference external" href="https://clang.llvm.org/docs/ClangFormat.html">page</a>.</p>
<p>Details about the style options used can be found <a class="reference external" href="https://clang.llvm.org/docs/ClangFormatStyleOptions.html">here</a>.</p>
<div class="section" id="script-usage">
<h4>2.6.1. Script usage</h4>
<p>PCL also creates a build target format to format the whitelisted directories using clang-format.</p>
<p>Command line usage:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>$ make format
</pre></div>
</div>
</div>
</div>
<div class="section" id="id3">
<h3>2.7. Includes</h3>
<p>For consistent usage, headers should be included in the following order with alphabetical grouping ensured:</p>
<ol class="arabic">
<li><p class="first">PCL headers</p>
<ol class="lowerroman">
<li><p class="first">All modular PCL includes, except main includes of common module.</p>
<p>Examples:</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">&lt;pcl/common/common.h&gt;</span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf">&lt;pcl/simulation/camera.h&gt;</span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf">&lt;pcl/ml/dt/decision_forest.h&gt;</span><span class="cp"></span>
</pre></div>
</div>
</li>
<li><p class="first">The main PCL includes of common module. These are the header files in the <code class="docutils literal notranslate"><span class="pre">pcl/common/include/pcl/</span></code> directory.</p>
<p>Examples:</p>
<div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">&lt;pcl/memory.h&gt;</span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf">&lt;pcl/pcl_macros.h&gt;</span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf">&lt;pcl/point_cloud.h&gt;</span><span class="cp"></span>
</pre></div>
</div>
</li>
</ol>
</li>
<li><p class="first">Major 3rd-Party components of tests and modules</p>
<ol class="lowerroman simple">
<li>gtest</li>
<li>boost</li>
<li>Eigen</li>
<li>flann</li>
</ol>
</li>
<li><p class="first">Major 3rd-Party components of apps</p>
<ol class="lowerroman simple">
<li>Qt</li>
<li>ui-files</li>
<li>vtk</li>
</ol>
</li>
<li><p class="first">Minor 3rd-Party components</p>
<ol class="lowerroman simple">
<li>librealsense</li>
<li>ros/message_filters</li>
<li>opencv/opencv2</li>
<li>tide</li>
<li>thrust</li>
<li>OpenGL, GL &amp; GLUT</li>
</ol>
</li>
<li><p class="first">C++ standard library headers (alphabetical)</p>
</li>
<li><p class="first">Others</p>
</li>
</ol>
<p>This style can also be enforced via clang-format. For usage instructions, refer <a class="reference internal" href="#automatic-code-formatting">2.6. Automatic code formatting</a>.</p>
</div>
</div>
<div class="section" id="structuring">
<h2>3. Structuring</h2>
<div class="section" id="classes-and-api">
<h3>3.1. Classes and API</h3>
<p>For most classes in PCL, it is preferred that the interface (all public
members) does not contain variables and only two types of methods:</p>
<ul class="simple">
<li>The first method type is the get/set type that allows to manipulate the
parameters and input data used by the class.</li>
<li>The second type of methods is actually performing the class functionality
and produces output, e.g. compute, filter, segment.</li>
</ul>
</div>
<div class="section" id="passing-arguments">
<h3>3.2. Passing arguments</h3>
<p>For get/set type methods the following rules apply:</p>
<ul class="simple">
<li>If large amounts of data needs to be set (usually the case with input data
in PCL) it is preferred to pass a boost shared pointer instead of the actual
data.</li>
<li>Getters always need to pass exactly the same types as their repsective setters
and vice versa.</li>
<li>For getters, if only one argument needs to be passed this will be done via
the return keyword. If two or more arguments need to be passed they will
all be passed by reference instead.</li>
</ul>
<p>For the compute, filter, segment, etc. type methods the following rules apply:</p>
<ul class="simple">
<li>The output arguments are preferably non-pointer type, regardless of data
size.</li>
<li>The output arguments will always be passed by reference.</li>
</ul>
</div>
<div class="section" id="object-declaration">
<h3>3.3. Object declaration</h3>
<div class="section" id="use-of-auto">
<h4>3.3.1 Use of auto</h4>
<ul class="simple">
<li>For Iterators auto must be used as much as possible</li>
<li>In all the other cases auto can be used at the authors discretion</li>
<li>Use const auto references by default in range loops. Drop the const if the item needs to be modified.</li>
</ul>
</div>
<div class="section" id="type-qualifiers-of-variables">
<h4>3.3.2 Type qualifiers of variables</h4>
<ul class="simple">
<li>Declare variables const when they dont need to be modified.</li>
<li>Use const references whenever you dont need a copy of the variable.</li>
<li>Use of unsigned variables if the value is sure to not go negative by
use and by definition of the variable</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>