<plugin id="Tuto05MultithreadConsoleCpp" library="true" >

    <requirement id="sight::module::service" />
    <requirement id="sight::module::ui::console" />

    <extension implements="sight::service::extension::Factory" >
        <type>sight::service::IController</type>
        <service>Tuto05MultithreadConsoleCpp::SReadArray</service>
        <object>sight::data::Array</object>
    </extension>

    <extension implements="sight::service::extension::Factory" >
        <type>sight::service::IController</type>
        <service>Tuto05MultithreadConsoleCpp::SShowArray</service>
        <object>sight::data::Array</object>
    </extension>

    <extension implements="sight::service::extension::Factory" >
        <type>sight::service::IController</type>
        <service>Tuto05MultithreadConsoleCpp::SIncrementArray</service>
        <object>sight::data::Array</object>
    </extension>

    <extension implements="sight::service::extension::AppConfig" >
        <id>Tuto05MultithreadConsoleCpp_AppCfg</id>
        <parameters>
        </parameters>
        <config>

            <!-- ******************************* Objects declaration ****************************** -->

            <object uid="array" type="sight::data::Array" />

            <!-- ******************************* Services ***************************************** -->

            <!-- Simulate the reading of an array of integers. It simply fills 10 values from 0 to 9. -->
            <service uid="readArraySrv" type="Tuto05MultithreadConsoleCpp::SReadArray" worker="worker1" >
                <inout key="array" uid="array" />
            </service>

            <!-- Increment each element of the array every 500ms. -->
            <service uid="incrementArraySrv" type="Tuto05MultithreadConsoleCpp::SIncrementArray" worker="worker2" >
                <inout key="array" uid="array" />
            </service>

            <!-- Display the content of the array. -->
            <service uid="showArraySrv" type="Tuto05MultithreadConsoleCpp::SShowArray" worker="worker3" >
                <in key="array" uid="array" />
            </service>

            <!-- ******************************* Connections ***************************************** -->

            <!-- Start the increment of the array when it is read, show the content every time the array is modified -->
            <connect>
                <signal>array/modified</signal>
                <slot>incrementArraySrv/startTimer</slot>
                <slot>showArraySrv/update</slot>
            </connect>

            <!-- ******************************* Start services ***************************************** -->

            <start uid="readArraySrv" />
            <start uid="incrementArraySrv" />
            <start uid="showArraySrv" />

            <!-- ******************************* Update services ***************************************** -->

            <!-- Read the array -->
            <update uid="readArraySrv" />

        </config>
    </extension>

</plugin>
