abstractprocessor.h 4.48 KB
Newer Older
schultezub's avatar
schultezub committed
1
2
3
#ifndef PROCESSOR_H__
#define PROCESSOR_H__

schultezub's avatar
schultezub committed
4
#include "sigslot/sigslot.h"
schultezub's avatar
schultezub committed
5
6
#include "tgt/logmanager.h"
#include "core/datastructures/datacontainer.h"
schultezub's avatar
schultezub committed
7
#include "core/tools/invalidationlevel.h"
schultezub's avatar
schultezub committed
8
9
10
11
#include "core/properties/propertycollection.h"

#include <string>
#include <vector>
schultezub's avatar
schultezub committed
12
13

namespace TUMVis {
schultezub's avatar
schultezub committed
14
15
    class AbstractProperty;

schultezub's avatar
schultezub committed
16
17
    /**
     * Abstract base class for TUMVis Processors.
18
19
20
21
22
23
24
25
     * A processor implements a specific task, which it performs on the DataCollection passed
     * during process(). Properties provide a transparent layer for adjusting the processor's 
     * behaviour.
     * Once a processor has finished it sets it should set its invalidation level to valid. As
     * soon as one of its properties changes, the processor will be notified and possibliy
     * change its invalidation level. Observing pipelines will be notified of this and can
     * and have to decide which part of the pipeline has to be re-evaluated wrt. the processor's
     * invalidation level.
schultezub's avatar
schultezub committed
26
27
28
     * 
     * \sa AbstractPipeline
     */
schultezub's avatar
schultezub committed
29
    class AbstractProcessor : public HasPropertyCollection {
30
31
32
33
34
35
36
37
38
39

    /**
     * We have to find a trade-off:
     * On the one hand, we want to follow the information-hiding concept and keep the processor's
     * properties private. On the other hand pipelines will usually want direct access to them
     * (e.g. in order to setup data IDs or property sharing) and the properties in the PropertyCollection
     * are not strongly typed. Hence, we declare AbstractPipeline as our friend.
     */
    friend class AbstractPipeline;

schultezub's avatar
schultezub committed
40
    public:
41

schultezub's avatar
schultezub committed
42
43
44
45
46
47
48
49
50
51
52
        /**
         * Creates a AbstractProcessor.
         */
        AbstractProcessor();

        /**
         * Virtual Destructor
         **/
        virtual ~AbstractProcessor();


schultezub's avatar
schultezub committed
53
        /**
54
55
56
         * Initializes the processor.
         * Everything that requires a valid OpenGL context or is otherwise expensive gets in here.
         * 
schultezub's avatar
schultezub committed
57
58
59
         * \note    When overwriting this method, make sure to call the base class version first.
         */
        virtual void init();
60
61
        
        /**
schultezub's avatar
schultezub committed
62
         * Deinitializes this processor.
63
64
65
         * \note    When overwriting this method, make sure to call the base class version first.
         */
        virtual void deinit();
schultezub's avatar
schultezub committed
66

schultezub's avatar
schultezub committed
67
68
        /**
         * Execute this processor.
69
         * \param data      DataContainer to work on.
schultezub's avatar
schultezub committed
70
         **/
71
        virtual void process(DataContainer& data) = 0;
schultezub's avatar
schultezub committed
72

73
74
        /**
         * Returns the invalidation level of this processor.
schultezub's avatar
schultezub committed
75
         * \return _invalidationLevel
76
         */
schultezub's avatar
schultezub committed
77
        const InvalidationLevel& getInvalidationLevel() const;
78

79
80
81
82
83
84
        /**
         * Gets the name of this very processor. To be defined by every subclass.
         * \return  The name of this processor.
         */
        virtual const std::string getName() const = 0;

85
86
87
88
89
90
        /**
         * Gets a description of this processor. To be defined by every subclass.
         * \return  A description what this processor does.
         */
        virtual const std::string getDescription() const = 0;

schultezub's avatar
schultezub committed
91
92
93
94
95
96
        /**
         * Update the processor's invalidation level by \a nl.
         * If \a nl is VALID, the processor's invalidation level will be set to VALID.
         * If \a nl is one of the INVALID_X state, the processor's corresponding flag will be set.
         * \param nl    Invalidation level to apply.
         */
97
98
        void applyInvalidationLevel(InvalidationLevel il);
        
99
100
101
102
103
104
105
106
107
108
109
110
        /**
         * Locks all properties in the processor's PropertyCollection and marks them as "in use".
         * \sa  AbstractProcessor::unlock
         */
        void lockProperties();

        /**
         * Unlocks all properties in the processor's PropertyCollection and marks them as "not in use".
         * \sa  AbstractProcessor::lock
         */
        void unlockProperties();

111

schultezub's avatar
schultezub committed
112
113
114
115
116
117
118
119
120
121
        /// Signal emitted when the processor has been invalidated.
        sigslot::signal1<const AbstractProcessor*> s_invalidated;

        /**
         * Slot getting called when one of the observed properties changed and notifies its observers.
         * \param   prop    Property that emitted the signal
         */
        virtual void onPropertyChanged(const AbstractProperty* prop);


schultezub's avatar
schultezub committed
122
    protected:
schultezub's avatar
schultezub committed
123
124
125
        InvalidationLevel _invalidationLevel;       ///< current invalidation level of this processor


schultezub's avatar
schultezub committed
126
127
128
129
130
131
132

        static const std::string loggerCat_;
    };

}

#endif // PROCESSOR_H__