fw4spl
AppConfig

The FW4SPL architecture provides a dynamic management of configurations to allow the use of multiple objects and services.

The xml configuration for an application is defines with the extension fwServices::registry::AppConfig.

1 <extension implements="::fwServices::registry::AppConfig">
2  <id>myAppConfigId</id>
3  <parameters>
4  <param name="appName" default="my Application" />
5  <param name="appIconPath" />
6  </parameters>
7  <desc>Image Viewer</desc>
8  <config>
9 
10  <object type="::fwData::Composite">
11 
12  <!--
13  Description service of the GUI:
14  The ::gui::frame::SDefaultFrame service automatically positions the various
15  containers in the application main window.
16  Here, it declares a container for the 3D rendering service.
17  -->
18  <service uid="myFrame" impl="::gui::frame::SDefaultFrame">
19  <gui>
20  <frame>
21  <name>${appName}</name>
22  <icon>${appIconPath}</icon>
23  <minSize width="800" height="600" />
24  </frame>
25  </gui>
26  <registry>
27  <!-- Associate the container for the rendering service. -->
28  <view sid="myRendering" />
29  </registry>
30  </service>
31 
32  <item key="myImage">
33  <object uid="myImageUid" type="::fwData::Image">
34  <!--
35  Reading service:
36  The <file> tag defines the path of the image to load. Here, it is a relative
37  path from the repository in which you launch the application.
38  -->
39  <service uid="myReaderPathFile" impl="::ioVTK::SImageReader">
40  <file>./TutoData/patient1.vtk</file>
41  </service>
42 
43  <!--
44  Visualization service of a 3D medical image:
45  This service will render the 3D image.
46  -->
47  <service uid="myRendering" impl="::vtkSimpleNegato::SRenderer" />
48  </object>
49  </item>
50 
51  <!--
52  Definition of the starting order of the different services:
53  The frame defines the 3D scene container, so it must be started first.
54  The services will be stopped the reverse order compared to the starting one.
55  -->
56  <start uid="myFrame" />
57  <start uid="myReaderPathFile" />
58  <start uid="myRendering" />
59 
60  <!--
61  Definition of the service to update:
62  The reading service load the data on the update.
63  The render update must be called after the reading of the image.
64  -->
65  <update uid="myReaderPathFile" />
66  <update uid="myRendering" />
67 
68  </object>
69 
70  </config>
71 </extension>
  • id: it is the configuration identifier
  • parameters (optional): it defines the list of the parameters used by the configuration
  • param: defines a parameter
    • name: parameter name, used as "${paramName}" in the configuration. It will be replaced by the string defined by the service, activity or application that launchs the configuration.
    • default(optional): default value for the parameter, it is used if the value is not given by the config launcher.
  • desc (optional): it is the description of the application
  • config: it defines the services and objects to launch
  • object: it defines an object of the AppConfig. We usually use a fwData::Composite in order to add sub-objects. An object can defines a list of services. Some object object can have a specific configuration : fwData::TransformationMatrix3D, fwData::Float, fwData::List, ...
    • uid (optional): unique identifier of the object (fwTools::fwID). If it is not defined, it will be automatically generated.
    • type: object type (ex: fwData::Image, fwData::Composite)
    • src (optional, "new" by default): defines if the object should be created ("new") or if it already exists in the application ("ref"). In the last case, the uid must be the same as the first declaration of this object (with "new").
  • service: it represents a service working on the object. Some services needs a specific configuration, it is usually described in the doxygen of the method configuring().
    • uid (optional): unique identifier of the service. If it is not defined, it will be automatically generated.
    • impl: service implementation
    • type (optional): service type (ex: fwGui::IFrameSrv)
    • autoConnect (optional, "no" by default): defines if the service listen the signals of the working object
    • worker (optional): allows to run the service in another worker (see fwThread::Worker)
  • matrix (optional): it works only for fwData::TransformationMatrix3D objects. It defines the value of the matrix.
1 <object uid="matrix" type="::fwData::TransformationMatrix3D">
2  <matrix>
3  <![CDATA[
4  1 0 0 0
5  0 1 0 0
6  0 0 1 0
7  0 0 0 1
8  ]]>
9  </matrix>
10 </object>
1 <object type="::fwData::Integer">
2  <value>42</value>
3 </object>
  • item (optional): it defines a sub-object of a composite. It can only be used if the parent object is a fwData::Composite.
    • key: key of the object in the composite
    • object: the 'item' tag can only contain 'object' tags that represents the composite sub-object
1 <item key="myImage">
2  <object uid="myImageUid" type="::fwData::Image" />
3 </item>
1 <object type="::fwData::TransferFunction">
2  <colors>
3  <step color="#ff0000ff" value="1" />
4  <step color="#ffff00ff" value="500" />
5  <step color="#00ff00ff" value="1000" />
6  <step color="#00ffffff" value="1500" />
7  <step color="#0000ffff" value="2000" />
8  <step color="#000000ff" value="4000" />
9  </colors>
10 </object>
  • connect (optional): allows to connect a signal to one or more slot(s). The signal and slots must be compatible.
1 <connect>
2  <signal>object_uid/signal_name</signal>
3  <slot>service_uid/slot_name</slot>
4 </connect>
  • proxy (optional): allows to connect one or more signal(s) to one or more slot(s). The signals and slots must be compatible.
    • channel: name of the channel use for the proxy.
1 <proxy channel="myChannel">
2  <signal>object_uid/signal_name</signal>
3  <slot>service_uid/slot_name</slot>
4 </proxy>
  • start: defines the service to start when the AppConfig is launched. The services will be automatically stopped in the reverse order when the AppConfig is stopped.
1 <start uid="service_uid" />
  • update: defines the service to update when the AppConfig is launched.
1 <update uid="service_uid" />

The FW4SPL architecture provides a dynamic management of configurations to allow the use of multiple objects and services.

The xml configuration for an application is defines with the extension fwServices::registry::AppConfig.

1 <extension implements="::fwServices::registry::AppConfig">
2  <id>myAppConfigId</id>
3  <parameters>
4  <param name="appName" default="my Application" />
5  <param name="appIconPath" />
6  </parameters>
7  <desc>Image Viewer</desc>
8  <config>
9 
10  <object uid="myImage" type="::fwData::Image" />
11 
12  <!--
13  Description service of the GUI:
14  The ::gui::frame::SDefaultFrame service automatically positions the various
15  containers in the application main window.
16  Here, it declares a container for the 3D rendering service.
17  -->
18  <service uid="myFrame" type="::gui::frame::SDefaultFrame">
19  <gui>
20  <frame>
21  <name>${appName}</name>
22  <icon>${appIconPath}</icon>
23  <minSize width="800" height="600" />
24  </frame>
25  </gui>
26  <registry>
27  <!-- Associate the container for the rendering service. -->
28  <view sid="myRendering" />
29  </registry>
30  </service>
31 
32  <!--
33  Reading service:
34  The <file> tag defines the path of the image to load. Here, it is a relative
35  path from the repository in which you launch the application.
36  -->
37  <service uid="myReaderPathFile" type="::ioVTK::SImageReader">
38  <inout key="target" uid="myImage" />
39  <file>./TutoData/patient1.vtk</file>
40  </service>
41 
42  <!--
43  Visualization service of a 3D medical image:
44  This service will render the 3D image.
45  -->
46  <service uid="myRendering" type="::vtkSimpleNegato::SRenderer">
47  <in key="image" uid="myImage" />
48  </service>
49 
50  <!--
51  Definition of the starting order of the different services:
52  The frame defines the 3D scene container, so it must be started first.
53  The services will be stopped the reverse order compared to the starting one.
54  -->
55  <start uid="myFrame" />
56  <start uid="myReaderPathFile" />
57  <start uid="myRendering" />
58 
59  <!--
60  Definition of the service to update:
61  The reading service load the data on the update.
62  The render update must be called after the reading of the image.
63  -->
64  <update uid="myReaderPathFile" />
65  <update uid="myRendering" />
66 
67  </config>
68 </extension>

Definition

Parameters

  • id: it is the configuration identifier
  • parameters (optional): it defines the list of the parameters used by the configuration
  • param: defines a parameter
    • name: parameter name, used as "${paramName}" in the configuration. It will be replaced by the string defined by the service, activity or application that launchs the configuration.
    • default(optional): default value for the parameter, it is used if the value is not given by the config launcher.
  • desc (optional): it is the description of the application
  • config: it defines the services and objects to launch

Object

  • object: it defines an object of the AppConfig.
    • uid (optional): unique identifier of the object (fwTools::fwID). If it is not defined, it will be automatically generated.
    • type: object type (ex: fwData::Image, fwData::Mesh)
    • src (optional, "new" by default, values: "new", "ref", "deferred"):
      • "new" : defines that the object should be created
      • "ref" : defines that the object already exists in the application. The uid must be the same as the first declaration of this object (with "new").
      • "deferred" : defines that the object will be created later (by a service).

Some objects can have a specific configuration :

1 <object uid="matrix" type="::fwData::TransformationMatrix3D">
2  <matrix>
3  <![CDATA[
4  1 0 0 0
5  0 1 0 0
6  0 0 1 0
7  0 0 0 1
8  ]]>
9  </matrix>
10 </object>
1 <object type="::fwData::Integer">
2  <value>42</value>
3 </object>
1 <object type="::fwData::TransferFunction">
2  <colors>
3  <step color="#ff0000ff" value="1" />
4  <step color="#ffff00ff" value="500" />
5  <step color="#00ff00ff" value="1000" />
6  <step color="#00ffffff" value="1500" />
7  <step color="#0000ffff" value="2000" />
8  <step color="#000000ff" value="4000" />
9  </colors>
10 </object>
  • item (optional): it defines a sub-object of a composite or a field of any other object.
    • key: key of the object
    • object: the 'item' tag can only contain 'object' tags that represents the sub-object
1 <item key="myImage">
2  <object uid="myImageUid" type="::fwData::Image" />
3 </item>

Service

  • service: it represents a service working on the object. Services list the data the use and how they access them. Some services needs a specific configuration, it is usually described in the doxygen of the method configuring().
    • uid (optional): unique identifier of the service. If it is not defined, it will be automatically generated.
    • type: service type (ex: ioVTK::SImageReader)
    • autoConnect (optional, "no" by default): defines if the service listen the signals of the working objects
    • worker (optional): allows to run the service in another worker (see fwThread::Worker)
1 <service uid="mesher" type="::opMesh::SMesher">
2  <in key="image" uid="imageId" />
3  <out key="mesh" uid="meshId" />
4 </service>
  • in : input object, it is const and cannot be modified
  • inout : input object that can be modified
  • out : output object, it must be created by the service and registered with the 'setOutput(key, obj)' method. The output object must be declared as "deferred" in the <object> declaration.
    • key: Object key used to retreive the object into the service
    • uid: Uid of the object declared in the <object> tag
    • optional(optional, default "no", values: "yes" or "no") If "yes", the service can be started even if the object is not present. The output objects are always optional.
::fwData::Image::csptr image = this->getInput< ::fwData::Image >("image");
::fwData::Mesh::sptr mesh = ::fwData::Mesh::New();
// mesher .....
this->setOutput("mesh", mesh);
  • connect (optional): allows to connect one or more signal(s) to one or more slot(s). The signals and slots must be compatible.
    • channel (optional): name of the channel use for the connections.
1 <connect channel="myChannel">
2  <signal>object_uid/signal_name</signal>
3  <slot>service_uid/slot_name</slot>
4 </connect>
  • start: defines the service to start when the AppConfig is launched. The services will be automatically stopped in the reverse order when the AppConfig is stopped.
1 <start uid="service_uid" />

The service using "deferred" object as input will be automatically started when the object is created.

  • update: defines the service to update when the AppConfig is launched.
1 <update uid="service_uid" />