File: plugins.rst

package info (click to toggle)
siconos 4.3.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 82,496 kB
  • sloc: cpp: 159,693; ansic: 108,665; fortran: 33,248; python: 20,709; xml: 1,244; sh: 385; makefile: 226
file content (47 lines) | stat: -rw-r--r-- 1,306 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
.. _siconos_devel_plugins:


About plugins in classes
------------------------

An attempt to write some rules when implementing a plugin for a class attribute ...


Rules
^^^^^
Consider a class with an attribute '_xx', for which you want to propose a plugin-mechanism.


Attributes to add to the class:

- _pluginxx, a :class:`PluggedObject`,
  
Methods to add to the class:

- getPluginXx() returns the _pluginxx object
- setComputeXxFunction(args), args=(path,name) or (fptr) to connect fPtr of the PluggedObject to a user-defined function 'name' in file 'path'.
- computeXx(...) call the plugged function and update _xx content.

Others

- _zeroPlugin() -->  set to 'zero' all PluggedObject of the class
- updatePlugins(time) --> call all plugged functions of the class, for time and current state

Plugged functions can be set either with the construtor or with the setComputeXxFunction method.


Example/template
^^^^^^^^^^^^^^^^

computation of :math:`f(x,t,z)` in :class:`FirstOrderNonLinearDS`.

Attributes and methods

- :class:`FirstOrderNonLinearDS::_f`
- :class:`FirstOrderNonLinearDS::_pluginf`
- :class:`FirstOrderNonLinearDS::computef()`
- :class:`FirstOrderNonLinearDS::setComputeFFunction`
- :class:`FirstOrderNonLinearDS::_zeroPlugin`
- :class:`FirstOrderNonLinearDS::updatePlugins`