Guidelines - grame-cncm/inscore GitHub Wiki
Coding guidelines
Source code organisation
The source code is located in the src
folder. It is organised as follows:
guido2.ttf
: the Guido fontemcc
: bindings and specific code for the WASM libraryfaustarch
: faust architecture file (copy to avoid faust dependency and obsolete)imf
: inscore xml export format (unfinished and obsolete)inscore
: the core library source codeinscore2
: source code of the inscore language version 2inscoreviewer
: the viewer source filesjson
: json supportlibmapping
: the mappings librarymobile
: android and iOS specific filesQArchive
: the INScore archive utilityQt
: Qt specific sourcestests
: various utilities for testing specific componentsview
: inscore views implementationsHTMLView
: used by the WASM libraryQtView
: used by the inscore viewerTextView
: (obsolete)VoidView
: no view (may be used for memory leak detection on model side)
INScore architecture
INScore is based on a MVC architecture:
- objects of the model are located in the
inscore/model
folder - objects of the view are located in the
view
folder. Basis of the view are ininscore/view
.
Update of the model and propagation to the view is in charge of the inscore/controller/IGlue
object.
It is processed by a time task that runs by default every 10 ms.
INScore messages are implemented in inscore/controller
, the parser is located in inscore/ITLParser
.
Incoming messages are pushed on a stack to be processed asynchronously by the time task.
Messages are distributed to objects according to their OSC address.
Objects of the model are represented as a tree that reflects the OSC address space.
Coding rules
- class names: use the upper camel case convention
- method names: use the lower camel case convention
- fields names: must start with
f
and use next the camel case convention - constants: must start with
k
and use next the camel case convention
Recommendations
- Expose class fields and methods only when necessary. The public section of a class should reflect it's services only and not it's internal implementation. The protected section should reflect behaviors shared at inheritance level only. And otherwise, make everything private as much as possible.
- Don't use the friend attribute
- Use and abuse of the
const
keyword whenever possible.