-
Notifications
You must be signed in to change notification settings - Fork 97
Contributing
We encourage contributions to the library. Contributing to G+Smo is very profitable for both, the contributor and the library.
We keep a page of ideas of possible contributions, where you could find one that is of your interest to implement. Nevertheless, you are mostly welcome to send your ideas e.g. via GitHub issues.
Post build and test reports to https://cdash-ci.inria.fr/index.php?project=Gismo This is done by
$ make Experimental
- Use only spaces, no tabs for indentation.
- Use 4 spaces per indentation level.
- Open bracket (iteration, switch, function, etc) at flush left position.
- No indentation inside the namespace, except for a sub-namespace.
- No indentation for access modifiers (public, private, etc) inside classes.
Note: For CLion there is already a codestyle file in the project.
We use the following convention regarding filenames.
There are the following four types of files in G+Smo.
-
gsFilename.hfile should contain function declarations, Doxygen documentation and, possibly, definitions of very short inline functions/** @file ... */ #pragma once #include <gsWhereIFindIt/gsWhateverINeed.h> namespace gismo { /** \brief Here say what this class is and does.. */ class GISMO_EXPORT gsMyClass { public: /// Prints "Hello, World!". void helloWorld(); /// Returns true. inline bool returnTrue() { return true; } }; /** \brief Here say what this class is and does.. \tparam dim The dimention */ template<unsigned dim> gsMyTemplatedClass { /// Function templated w.r.t. dim void functionDependingOnDim(); }; }// namespace gismo #ifndef GISMO_BUILD_LIB #include GISMO_HPP_HEADER(gsFilename.hpp) #endif
-
gsFilename.cppfile contains the definitions (i.e., the bodies) of the non-templated functions declared ingsFilename.h/** @file ... */ #include <gsWhereIFindIt/gsWhateverINeed.h> #include <gsMyFolder/gsFilename.h> namespace gismo { void gsMyClass::helloWorld() { std::cout << "Hello, World!" << std::endl; } }// namespace gismo
-
gsFilename.hppfile contains the definitions of the templated functions declared in thegsFilename.h#include <gsMyFolder/gsFilename.h> // Only for syntax highlighting in Qtcreator, as during compilation, this file is included by the gsFilename.h namespace gismo { template<unsigned dim> gsMyTemplatedClass<dim>::functionDependingOnDim() { // code depending on dim } } // namespace gismo
-
gsFilename_.cppfile consists of explicit template instantiations, that are explorted to the dynamic library. This is done by a macro so that it is platform independent./** @file ... */ #include <gsWhereIFindIt/gsWhateverINeed.h> #include <gsMyFolder/gsFilename.hpp> namespace gismo { CLASS_TEMPLATE_INST gsMyTemplatedClass<1> ; CLASS_TEMPLATE_INST gsMyTemplatedClass<2> ; // ... } // namespace gismo
If your non-templated class has definitions in the gsMyClass.cpp file, you need to export it to allow the users call its public functions. This you do by adding GISMO_EXPORT in gsMyClass.h:
class GISMO_EXPORT gsMyClass
{
void helloWorld();
// etc., as before
};If you forget, you get linking error undefined reference to gismo::gsMyClass::myFunction() which is quite hard to figure out in these circumstances.
For templated functions, this keyword is not needed. However, if the templated class is partitioned in gsMyClass.h and gsMyClass.hpp files, an exported instance has to be added, this is the gsMyClass_.cpp file. In this situation the instantization and exporting is done by
#include <gsCore/gsTemplateTools.h>
#include <gsMyModule/gsMyClass.h>
#include <gsMyModule/gsMyClass.hpp>
namespace gismo {
CLASS_TEMPLATE_INST gsMyClass<real_t>;
}The export attribute is now hidden in CLASS_TEMPLATE_INST.
namespace gismo
{
template<class T, class KnotVectorType >
class gsBSplineBasis : public gsBasis<T>
{
public:
typedef gsBasis<T> Base;
public:
gsBSplineBasis() : Base()
{
}
gsBSplineBasis( const KnotVectorType & KV, int p) : m_p(p), m_knots(KV)
{
if( ! check() )
gsWarn << "Warning: Insconsistent "<< *this<< "\n";
m_knots.set_degree(p);
}
}; //end class
}// end namespace gismo-
Style settings for QtCreator, see http://doc.qt.io/qtcreator/creator-code-style-settings.html
-
Style settings for Visual Studio, see https://docs.microsoft.com/en-us/visualstudio/ide/reference/options-text-editor-c-cpp-formatting?view=vs-2017
Open the Text Editor options. (Tools / Options / Text Editor). Expand "All Languages" and then click "Tabs". Set the "Tab size" to 4 and check "Insert spaces". Click OK.
-
Style settings for emacs: Put this into your
.emacsfile:
(defun gismo-indent-setup ()
(setq c-default-style "bsd"
c-basic-offset 4
c++-basic-offset 4
c-indent-level 4
c++-indent-level 4
tab-width 4
inline-open 0
indent-tabs-mode nil
substatement-open 0
)
(c-set-offset 'innamespace '0)
(c-set-offset 'member-init-intro '0)
(c-set-offset 'inline-open '0)
)
(add-hook 'c-mode-hook 'gismo-indent-setup)
(add-hook 'c++-mode-hook 'gismo-indent-setup)
- Style setting for vim: Put this into your
.vimrcfile:
set expandtab
set shiftwidth=4
set softtabstop=4