| 1 | = What is it ? = |
| 2 | |
| 3 | A Driver is something taking a [wiki:DsxWare Ware] and makeing somthing useful with it (typically generating source). |
| 4 | |
| 5 | A Driver may be helped by [wiki:NodeDriver NodeDrivers], thus having a decentralized generation of products. |
| 6 | |
| 7 | = Services = |
| 8 | |
| 9 | Through class (ie even with no instance): |
| 10 | * Keeps a list of known [wiki:NodeDriver NodeDrivers] and the associated [wiki:Node node] types. (see #Registering) |
| 11 | Through instances: |
| 12 | * Has some parameters (output directory, optional featues, ...) chosen at instanciation |
| 13 | * Keeps silent until code generation is asked (it may never be asked) |
| 14 | |
| 15 | This way, we may generate with the same driver class (eg generate SystemC/Caba code) different [wiki:DsxWare Wares], with different options; or the other way around, generate the same [wiki:DsxWare Wares] many times through different backends. |
| 16 | |
| 17 | = Registering = |
| 18 | |
| 19 | With method `register()` a NodeDriver can register as a generation class for a [wiki:Node Node]. |
| 20 | API between a Driver and its associated NodeDrivers is ad-hoc: the Driver's needs and design rules. |
| 21 | |
| 22 | A base NodeDriver valid for a given Driver should be given, with basic functionalities, doing a no-op for the code. |
| 23 | |
| 24 | = Registration usage = |
| 25 | |
| 26 | Let's have the following class hierarchies: |
| 27 | |
| 28 | {{{ |
| 29 | Node |
| 30 | MyWareTypeNode |
| 31 | MyWareWidgetNode |
| 32 | MyWareThingieNode |
| 33 | MyWareOtherNode |
| 34 | }}} |
| 35 | |
| 36 | Let's have the following drivers: |
| 37 | |
| 38 | {{{ |
| 39 | NodeDriver |
| 40 | MyDriverNoopDriver |
| 41 | MyWareWidgetNodeDriver |
| 42 | MyWareOtherNodeDriver |
| 43 | }}} |
| 44 | |
| 45 | Now, if we register in our new driver called `MyDriver`: |
| 46 | {{{ |
| 47 | # default registration |
| 48 | MyDriver.register(MyWareTypeNode, MyWareWidgetNoopDriver) |
| 49 | |
| 50 | # specialized drivers |
| 51 | MyDriver.register(MyWareWidgetNode, MyWareWidgetNodeDriver) |
| 52 | MyDriver.register(MyWareOtherNode, MyWareOtherNodeDriver) |
| 53 | }}} |
| 54 | |
| 55 | `MyWareThingieNode` will be driven by `MyWareWidgetNoopDriver`. |
| 56 | |
| 57 | This kind of walk through inherances also works with more childs and classes |