In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

autoevaluationpipeline.h 5.65 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-2014, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
7
//      Chair for Computer Aided Medical Procedures
8 9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
// 
schultezub's avatar
schultezub committed
11
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
12
// 
13 14 15 16
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
17
// 
18 19 20 21
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
22 23 24
// 
// ================================================================================================

25 26
#ifndef AUTOEVALUATIONPIPELINE_H__
#define AUTOEVALUATIONPIPELINE_H__
27

schultezub's avatar
schultezub committed
28
#include "sigslot/sigslot.h"
29 30 31
#include <tbb/concurrent_hash_map.h>
#include <tbb/concurrent_unordered_map.h>
#include <tbb/spin_rw_mutex.h>
32

33 34
#include "core/pipeline/abstractpipeline.h"

schultezub's avatar
schultezub committed
35

schultezub's avatar
schultezub committed
36
namespace campvis {
37
    /**
38 39 40
     * 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.
41 42 43
     * 
     * \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.
44
     */
45
    class CAMPVIS_CORE_API AutoEvaluationPipeline : public AbstractPipeline {
46 47
    public:
        /**
48
         * Creates a AutoEvaluationPipeline.
49
         */
50
        explicit AutoEvaluationPipeline(DataContainer* dc);
51 52 53 54

        /**
         * Virtual Destructor
         **/
55
        virtual ~AutoEvaluationPipeline();
56 57


58
        /// \see AbstractPipeline::init()
59
        virtual void init();
60
        /// \see AbstractPipeline::deinit()
61 62
        virtual void deinit();

63 64
        /// \see AbstractPipeline::addProcessor()
        virtual void addProcessor(AbstractProcessor* processor);
schultezub's avatar
schultezub committed
65

66 67 68
        /// \see AbstractPipeline::executePipeline()
        virtual void executePipeline();

69 70
    protected:

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

78 79 80
        static const std::string loggerCat_;

    private:
81 82 83 84
        /**
         * Callback slot called if one of the DataNameProperties in the port map has changed.
         * \param   prop    DataNameProperty that has changed.
         */
85 86
        void onDataNamePropertyChanged(const AbstractProperty* prop);

87 88 89 90 91 92
        /**
         * Gets called when the data collection of this pipeline has changed and thus has notified its observers.
         * If \a name equals the name of the renderTarget, the s_renderTargetChanged signal will be emitted.
         * \param   name    Name of the added data.
         * \param   dh      DataHandle to the newly added data.
         */
93
        virtual void onDataContainerDataAdded(std::string name, DataHandle dh);
94

95 96 97 98 99 100 101 102 103 104 105 106 107 108
        /**
         * Callback when a property was added to one of the PropertyCollections.
         * This property will be added to the port map.
         * \param   property    Property that was added to the collection.
         */
        virtual void onPropertyCollectionPropertyAdded(AbstractProperty* property);

        /**
         * Callback when a property was removed from one of the PropertyCollections.
         * This property will be removed from the port map.
         * \param   property    Property that was added removed from collection.
         */
        virtual void onPropertyCollectionPropertyRemoved(AbstractProperty* property);

109 110 111 112 113 114 115
        /**
         * Recursively looks for all DataNameProperties in \a pc and adds them to the port map.
         * If \a pc contains a MetaProperty, it will be seached recursively.
         * \param   pc  PropertyCollection to search for DataNameProperties.
         */
        void findDataNamePropertiesAndAddToPortMap(const HasPropertyCollection* pc);

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

119
        /// PortMap typedef mapping a string to a set of DataNameProperties using a concurrent unordered multimap
120
        typedef tbb::concurrent_unordered_multimap<std::string, DataNameProperty*> PortMapType;
121
        /// IteratorMap typedef mapping a DataNameProperty to an iterator in a PortMap using a concurrent unordered map
122 123 124 125 126 127
        typedef tbb::concurrent_unordered_map<DataNameProperty*, PortMapType::iterator> IteratorMapType;

        /// Multimap to simulate ports between processors
        PortMapType _portMap;
        IteratorMapType _iteratorMap;
        tbb::spin_rw_mutex _pmMutex;
128 129 130 131
    };

}

132
#endif // AUTOEVALUATIONPIPELINE_H__