Coding standards
================

In the header files, #pragma once should be the first line of code.
Then, the order of the inclusions should be, for example, for a MsXpertSuite software (adapt according to different needs):


/////////////////////// stdlib includes


/////////////////////// Qt includes


/////////////////////// pappsomspp includes


/////////////////////// libXpertMass includes


/////////////////////// libXpertMassGui includes


/////////////////////// Local includes

CLASS METHODS
=============

When setting/retrieving member data, use the get/set paradigm.
Do not use the get/set paradigm for any function that performs a computation not
setting/getting a member datum. Note that the get/set function name needs to be
formed using the exact member datum name with the "mxx_" prefix.

When setting/retrieving boolean member data use setXxxx() and isXxxx().

In the get/set function pair, declare/define first the set and then the get.

Functions are always declared/defined in camelCase.


Use std::size_t instead of unsigned int (or uint) when the standard library uses
std::site_t. For Qt containers, the qsizetype type should be used.
Attentions, std:size_t is unsigned, while qsizetype is signed.
Think about it when creating the variable!


VARIABLE / FUNCTION NAMING LOGIC
================================

For class members:
------------------

* Ordinary members: m_peakWidth (camelCase)

* For pointers:
		mp_integrationParams (raw pointer)
		msp_integrationParams (shared pointer, std::make_shared<T>())
		mcsp_integrationParams (shared pointer to const, std::make_shared<const T>())
		mpa_integrationParams (a for allocated that indicates the object will require explicit destruction using free())


For variables in function scope: snake_case
-------------------------------------------

The snake-casing operation involves replacing the uppercase character by _<lowercase>.
The mp_, msp_ and mcsp_ prefixes become suffixes:

Example for argumuments to a function:

void
ClassName::exampleFunction(int the_integer, MzIntegrationParamsCSPtr *mz_integration_params_csp)

In general, the variable name snake-cases the class name of the parameter, as shown above.

Avoid using variable names so short that one cannot understand what that variable is about:

int i = 0;

If that is an iteration counter, use 'iter' ('jter', 'kter', for nested loops).


void
exampleFunction(int the_integer, const QString &the_string)
{

qsizetype item_list_count = 0;
}


The parameters and inner-function-scope variables are always snake_case:

* Ordinary variables :

	bool should_abort_run = false;

* Pointers:

	mz_integration_params_p (raw pointer)
	mz_integration_params_sp (shared pointer)
	mz_integration_params_csp (shared pointer to const)


Variables in function scope
===========================

A good discipline is to snake-case the class name:

QualifiedMassSpectrum qualified_mass_spectrum;


typedef std::shared_ptr<MassSpectrum> MassSpectrumSPtr;
typedef std::shared_ptr<const MassSpectrum> MassSpectrumCstSPtr;


ENUMS
=====

In general, use class enums:


enum class CapType
{
  NONE  = 0 << 1,
  LEFT  = 1 << 1,
  RIGHT = 2 << 1,
  BOTH  = (LEFT | RIGHT)
};
Q_ENUM_NS(CapType)

// Overload bitwise AND operator
inline CapType
operator&(CapType lhs, CapType rhs)
{
  return static_cast<CapType>(
    static_cast<std::underlying_type_t<CapType>>(lhs) &
    static_cast<std::underlying_type_t<CapType>>(rhs));
}


Use a map to provide text strings mapping the enum's values.

In header file:
extern DECLSPEC std::map<Enums::CapType, QString> capTypeMap;

In cpp file:
std::map<Enums::CapType, QString> capTypeMap{{CapType::NONE, "NONE"},
                                             {CapType::LEFT, "LEFT"},
                                             {CapType::RIGHT, "RIGHT"},
                                             {CapType::BOTH, "BOTH"}};


TYPEDEFS
========

typedef std::shared_ptr<MassSpectrum> MassSpectrumSPtr;
typedef QSharePointer<MassSpectrum> MassSpectrumQSPtr;
typedef std::shared_ptr<const MassSpectrum> MassSpectrumCstSPtr;
typedef QSharePointer<const MassSpectrum> MassSpectrumQCstSPtr;


CONSTRUCTION OF OBJECTS AND INITIALIZATION
==========================================

Construction of objects with initialization must be performed traditionally
(C++98). Only when initializing a container, the braces ({xxx,xxx})
initialization is authorized.


CONTAINERS
==========

Use the right container! If the class is going to be a Q_OBJECT that might be used in
scripting, use Qt containers, otherwise use STL containers:

QVector vs std::vector
----------------------

In Qt, recently the QList has an implementation that is like QVector and these
two classes have become almost interchangeable. The Qt guys recommend using QList.

