Commit 56e151ce8a037732393ba837585d373971ea1757
1 parent
d0af6bc5
A few more changes
Showing
2 changed files
with
98 additions
and
0 deletions
docs/docs/docs/cpp_api.md
| @@ -152,6 +152,7 @@ | @@ -152,6 +152,7 @@ | ||
| 152 | [QApplication]: http://doc.qt.io/qt-5/qapplication.html "QApplication" | 152 | [QApplication]: http://doc.qt.io/qt-5/qapplication.html "QApplication" |
| 153 | [QCoreApplication]: http://doc.qt.io/qt-5/qcoreapplication.html "QCoreApplication" | 153 | [QCoreApplication]: http://doc.qt.io/qt-5/qcoreapplication.html "QCoreApplication" |
| 154 | [QObject]: http://doc.qt.io/qt-5/QObject.html "QObject" | 154 | [QObject]: http://doc.qt.io/qt-5/QObject.html "QObject" |
| 155 | +[Qt Property System]: http://doc.qt.io/qt-5/properties.html "Qt Property System" | ||
| 155 | 156 | ||
| 156 | [QString]: http://doc.qt.io/qt-5/QString.html "QString" | 157 | [QString]: http://doc.qt.io/qt-5/QString.html "QString" |
| 157 | [QStringList]: http://doc.qt.io/qt-5/qstringlist.html "QStringList" | 158 | [QStringList]: http://doc.qt.io/qt-5/qstringlist.html "QStringList" |
docs/docs/docs/cpp_api/object.md
| 1 | <!-- OBJECT --> | 1 | <!-- OBJECT --> |
| 2 | + | ||
| 3 | +Inherits from [QObject][QObject] | ||
| 4 | + | ||
| 5 | +This is the base class of all OpenBR plugins. [Objects](#object) are constructed from [Files](#files). The [File's](#file) [name](#file-members-name) specifies which plugin to construct and the [File's](#file) [metadata](#file-members-m_metadata) provides initialization values for the plugin's properties. | ||
| 6 | + | ||
| 7 | +## Members {: #object-members } | ||
| 8 | + | ||
| 9 | +Member | Type | Description | ||
| 10 | +--- | --- | --- | ||
| 11 | +file | [File](#file) | The [File](#file) used to construct the plugin. | ||
| 12 | +firstAvailablePropertyIdx | int | Index of the first property of the object that can be set via command line arguments | ||
| 13 | + | ||
| 14 | +## Macros {: #object-macros } | ||
| 15 | + | ||
| 16 | +### BR_PROPERTY {: #object-macros-br_property } | ||
| 17 | + | ||
| 18 | +This macro provides an extension to the [Qt Property System][Qt Property System]. It's purpose is to set default values for each property in an object. Every call to <tt>BR_PROPERTY</tt> should have a corresponding call to <tt>Q_PROPERTY</tt>. | ||
| 19 | + | ||
| 20 | +* **macro definition:** | ||
| 21 | + | ||
| 22 | + #define BR_PROPERTY(TYPE,NAME,DEFAULT) | ||
| 23 | + | ||
| 24 | +* **parameters:** | ||
| 25 | + | ||
| 26 | + Parameter | Description | ||
| 27 | + --- | --- | ||
| 28 | + TYPE | The type of the property (int, float etc.) | ||
| 29 | + NAME | The name of the property | ||
| 30 | + DEFAULT | The default value of the property | ||
| 31 | + | ||
| 32 | +* **example:** | ||
| 33 | + | ||
| 34 | + class ExampleTransform : public Transform | ||
| 35 | + { | ||
| 36 | + Q_OBJECT | ||
| 37 | + | ||
| 38 | + Q_PROPERTY(int property1 READ get_property1 WRITE set_property1 RESET reset_property1 STORED false) | ||
| 39 | + Q_PROPERTY(float property2 READ get_property2 WRITE set_property2 RESET reset_property2 STORED false) | ||
| 40 | + Q_PROPERTY(QString property3 READ get_property3 WRITE set_property3 RESET reset_property3 STORED false) | ||
| 41 | + BR_PROPERTY(int, property1, 1) // sets default value of "property1" to 1 | ||
| 42 | + BR_PROPERTY(float, property2, 2.5) // sets default value of "property2" to 2.5 | ||
| 43 | + BR_PROPERTY(QString, property3, "Value") // sets default value of "property3" to "Value" | ||
| 44 | + | ||
| 45 | + ... | ||
| 46 | + }; | ||
| 47 | + | ||
| 48 | + | ||
| 49 | +## Static Functions {: #object-static-functions } | ||
| 50 | + | ||
| 51 | +### [QStringList][QStringList] parse(const [QString][QString] &string, char split = ',') | ||
| 52 | + | ||
| 53 | +Split the provided string using the provided split character. Lexical scoping of <tt>()</tt>, <tt>[]</tt>, <tt>\<\></tt>, and <tt>{}</tt> is respected. | ||
| 54 | + | ||
| 55 | +* **function definition:** | ||
| 56 | + | ||
| 57 | + static QStringList parse(const QString &string, char split = ','); | ||
| 58 | + | ||
| 59 | +* **parameters:** | ||
| 60 | + | ||
| 61 | + Parameter | Type | Description | ||
| 62 | + --- | --- | --- | ||
| 63 | + string | const [QString][QString] & | String to be split | ||
| 64 | + split | char | (Optional) The character to split the string on. Default is ',' | ||
| 65 | + | ||
| 66 | +* **output:** ([QStringList][QStringList]) Returns a list of the split strings | ||
| 67 | +* **example:** | ||
| 68 | + | ||
| 69 | + Object::parse("Transform1(p1=v1,p2=v2),Transform2(p1=v3,p2=v4)"); // returns ["Transform1(p1=v1,p2=v2)", "Transform2(p1=v3,p2=v4)"] | ||
| 70 | + | ||
| 71 | + | ||
| 72 | +## Functions {: #object-functions } | ||
| 73 | + | ||
| 74 | +### void init() {: #object-function-init } | ||
| 75 | + | ||
| 76 | +This is a virtual function. It is meant to be overloaded by derived classes if they need to initialize internal variables. The default constructor of derived objects should *never* be overloaded. | ||
| 77 | + | ||
| 78 | +* **function definition:** | ||
| 79 | + | ||
| 80 | + virtual void init() | ||
| 81 | + | ||
| 82 | +* **parameters:** NONE | ||
| 83 | +* **output:** (void) | ||
| 84 | + | ||
| 85 | + | ||
| 86 | +### void store([QDataStream][QDataStream] &stream) | ||
| 87 | + | ||
| 88 | +This is a virtual function. Serialize an item to a [QDataStream][QDataStream]. The default implementation serializes each property and its value to disk. | ||
| 89 | + | ||
| 90 | +* **function definition:** | ||
| 91 | + | ||
| 92 | + virtual void store(QDataStream &stream) const | ||
| 93 | + | ||
| 94 | +* **parameters:** | ||
| 95 | + | ||
| 96 | + Parameter | Type | Description | ||
| 97 | + --- | --- | --- | ||
| 98 | + stream | [QDataStream][QDataStream] & | Stream to store serialized data |