21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

autoevaluationpipeline.h 4.34 KB
Newer Older
1
2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Software Framework.
4
5
// 
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
7
8
9
//      Chair for Computer Aided Medical Procedures
//      Technische Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, Germany
schultezub's avatar
schultezub committed
10
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
// 
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// 
// ================================================================================================

30
31
#ifndef AUTOEVALUATIONPIPELINE_H__
#define AUTOEVALUATIONPIPELINE_H__
32

schultezub's avatar
schultezub committed
33
#include "sigslot/sigslot.h"
34
35
36
#include <tbb/concurrent_hash_map.h>
#include <tbb/concurrent_unordered_map.h>
#include <tbb/spin_rw_mutex.h>
37

38
39
#include "core/pipeline/abstractpipeline.h"

schultezub's avatar
schultezub committed
40

schultezub's avatar
schultezub committed
41
namespace campvis {
42
    /**
43
44
45
     * Specializtaion of AbstractPipeline performing automatic execution of invalidated processors.
     * AutoEvaluationPipeline connects to the s_(in)validated signals of all of its processors and
     * executes processors with invalid results using the correct threads.
46
47
48
     * 
     * \param   dc  Pointer to the DataContainer containing local working set of data for this 
     *              pipeline, must not be 0, must be valid the whole lifetime of this pipeline.
49
     */
50
    class AutoEvaluationPipeline : public AbstractPipeline {
51
52
    public:
        /**
53
         * Creates a AutoEvaluationPipeline.
54
         */
55
        AutoEvaluationPipeline(DataContainer* dc);
56
57
58
59

        /**
         * Virtual Destructor
         **/
60
        virtual ~AutoEvaluationPipeline();
61
62


63
        /// \see AbstractPipeline::init()
64
        virtual void init();
65
        /// \see AbstractPipeline::deinit()
66
67
        virtual void deinit();

68
69
        /// \see AbstractPipeline::addProcessor()
        virtual void addProcessor(AbstractProcessor* processor);
schultezub's avatar
schultezub committed
70
71

    protected:
72
73
        /**
         * Slot getting called when one of the observed processors got invalidated.
74
         * The default behaviour is to dispatch a job to execute the invalidated processor and emit the s_invalidated signal.
75
76
77
         * \param   processor   The processor that emitted the signal
         */
        virtual void onProcessorInvalidated(AbstractProcessor* processor);
78

79
80
81
82
83
84
85
86
87

        static const std::string loggerCat_;

    private:
        void onDataNamePropertyChanged(const AbstractProperty* prop);

        virtual void onDataContainerDataAdded(const std::string& name, const DataHandle& dh);

        /// Hashmap storing for each processor whether it's a VisualizationProcessor or not.
88
89
        tbb::concurrent_hash_map<AbstractProcessor*, bool> _isVisProcessorMap;

90

91
92
93
94
95
96
97
        typedef tbb::concurrent_unordered_multimap<std::string, DataNameProperty*> PortMapType;
        typedef tbb::concurrent_unordered_map<DataNameProperty*, PortMapType::iterator> IteratorMapType;

        /// Multimap to simulate ports between processors
        PortMapType _portMap;
        IteratorMapType _iteratorMap;
        tbb::spin_rw_mutex _pmMutex;
98
99
100
101
    };

}

102
#endif // AUTOEVALUATIONPIPELINE_H__