|
| 1 | +## Translations |
| 2 | +You can participate in the translation. |
| 3 | +[](https://poeditor.com/join/project/Y4F6vHRFjA) |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +> TODO: Be more specific, provide a Visual Studio Code workspace with plugins and pre configured build tasks |
| 8 | +
|
| 9 | +Get Hyperion to compile: [Compile HowTo](CompileHowTo.md) |
| 10 | + |
| 11 | +## Workflow |
| 12 | + |
| 13 | +### Issue |
| 14 | + |
| 15 | +> TODO |
| 16 | +
|
| 17 | +### Pull requests |
| 18 | + |
| 19 | +- Create a feature branch from the default branch (`master`) and merge back against that branch. |
| 20 | +- It's OK to have multiple small commits as you work on the PR - GitHub automatically squashes them before merging. |
| 21 | +- Make sure tests pass. |
| 22 | +- If adding a new feature: |
| 23 | + - Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it. |
| 24 | +- If fixing bug: |
| 25 | + - If you are resolving an open issue, add `(fix #xxxx)` (`#xxxx` being the issue ID) in your PR title for a better release log, e.g. `chore(feat): implement SSR (fix #1234)`. |
| 26 | + - Provide a detailed description of the bug in the PR. |
| 27 | + |
| 28 | +## Code Specification |
| 29 | + |
| 30 | +- use QT wherever it's possible (except there is a good reason) |
| 31 | +- use unix line endings (not windows) |
| 32 | +- indent your code with TABs instead of spaces |
| 33 | +- your files should end with a newline |
| 34 | +- names are camel case |
| 35 | +- use utf8 file encoding (ANSI encoding is strictly forbidden!) |
| 36 | +- use speaking names for variables. |
| 37 | +- avoid code dups -> if you write similar code blocks more the 2 times -> refactoring! |
| 38 | +- avoid compiler macros (#ifdef #define ...) where possible |
| 39 | +- class member variables must prefixed with underscore `int _myMemberVar` |
| 40 | +- initializer list on constructors: |
| 41 | + |
| 42 | +```c++ |
| 43 | +bad: |
| 44 | +MyClass::MyClass() |
| 45 | + : myVarA(0), myVarB("eee"), myVarC(true) |
| 46 | +{ |
| 47 | +} |
| 48 | + |
| 49 | +MyClass::MyClass() : myVarA(0), |
| 50 | + myVarB("eee"), |
| 51 | + myVarC(true) |
| 52 | +{ |
| 53 | +} |
| 54 | + |
| 55 | +good: |
| 56 | +MyClass::MyClass() |
| 57 | + : myVarA(0) |
| 58 | + , myVarB("eee") |
| 59 | + , myVarC(true) |
| 60 | +{ |
| 61 | +} |
| 62 | +``` |
| 63 | +
|
| 64 | +- pointer declaration |
| 65 | +
|
| 66 | +```c++ |
| 67 | +bad: |
| 68 | +int *foo; |
| 69 | +int * fooFoo; |
| 70 | +
|
| 71 | +good: |
| 72 | +int* foo; |
| 73 | +``` |
| 74 | + |
| 75 | +### Logger |
| 76 | +Hyperion has a own logger class with different log levels. |
| 77 | + - Use macros in include/utils/logger.h |
| 78 | + - Don't use the Logger class directly unless there is a good reason to do so. |
| 79 | +``` c++ |
| 80 | +// *** including |
| 81 | +#include <utils/logger.h> |
| 82 | + |
| 83 | +// creating |
| 84 | +// get a logger, this will create a logger named MAIN with min loglevel INFO, DEBUG messages won't displayed |
| 85 | +Logger * log_main = Logger::getInstance("MAIN"); |
| 86 | + |
| 87 | +// get a logger, this will create a logger named MAIN with min loglevel DEBUG, all messages displayed |
| 88 | +Logger * log_main = Logger::getInstance("MAIN", Logger::DEBUG); |
| 89 | + |
| 90 | +// using |
| 91 | +// basic |
| 92 | +Debug( log_main, "hello folks!"); |
| 93 | +Info( log_main, "hello again!"); |
| 94 | +Warning( log_main, "something is crazy"); |
| 95 | +Error( log_main, "oh to crazy, aborting"); |
| 96 | + |
| 97 | +// quick logging, when only one message exists and want no typing overhead - or usage in static functions |
| 98 | +Info( Logger::getInstance("LedDevice"), "Leddevice %s started", "PublicStreetLighting"); |
| 99 | + |
| 100 | +// a bit mor complex - with printf like format |
| 101 | +Info( log_main, "hello %s, you have %d messages", "Dax", 25); |
| 102 | + |
| 103 | +// conditional messages |
| 104 | +WarningIf( (value>threshold), log_main, "Alert, your value is greater then %d", threshold ); |
| 105 | +``` |
| 106 | +The amount of "%" mus match with following arguments |
| 107 | +
|
| 108 | +#### The Placeholders |
| 109 | + - %s for strings (this are cstrings, when having std::string use myStdString.c_str() to convert) |
| 110 | + - %d for integer numbers |
| 111 | + - %f for float numbers |
| 112 | + - more placeholders possible, see [here](http://www.cplusplus.com/reference/cstdio/printf/) |
| 113 | +
|
| 114 | +#### Log Level |
| 115 | + * Debug - used when message is more or less for the developer or for trouble shooting |
| 116 | + * Info - used for not absolutly developer stuff messages for what's going on |
| 117 | + * Warning - warn if something is not as it should be, but didn't harm |
| 118 | + * Error - used when an error occurs |
| 119 | +
|
| 120 | +
|
| 121 | +## Commit specification |
| 122 | +
|
| 123 | +> TODO |
0 commit comments