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

#include "tgt/logmanager.h"
schultezub's avatar
schultezub committed
5
#include "core/tools/invalidationlevel.h"
schultezub's avatar
schultezub committed
6
#include "core/datastructures/datacontainer.h"
schultezub's avatar
schultezub committed
7
8
9
10
11
#include "core/properties/abstractproperty.h"
#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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    class AbstractProcessor;

    /**
     * Observer Arguments for Property observers.
     */
    struct ProcessorObserverArgs : public GenericObserverArgs<AbstractProcessor> {
        /**
         * Creates new PropertyObserverArgs.
         * \param subject               Subject that emits the notification
         * \param invalidationLevel     Invalidation level of that property
         */
        ProcessorObserverArgs(const AbstractProcessor* subject, InvalidationLevel invalidationLevel)
            : GenericObserverArgs<AbstractProcessor>(subject)
            , _invalidationLevel(invalidationLevel)
        {}

        InvalidationLevel _invalidationLevel;       ///< Invalidation level of that processor
    };

schultezub's avatar
schultezub committed
33
34
35
36
37
38

    /**
     * Abstract base class for TUMVis Processors.
     * 
     * \sa AbstractPipeline
     */
schultezub's avatar
schultezub committed
39
    class AbstractProcessor : GenericObserver<PropertyObserverArgs>, public GenericObservable<ProcessorObserverArgs> {
schultezub's avatar
schultezub committed
40
    public:
41

schultezub's avatar
schultezub committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
        /**
         * Creates a AbstractProcessor.
         */
        AbstractProcessor();

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


        /**
         * Execute this processor.
         **/
        virtual void process() = 0;

        /**
         * Adds the given DataHandle \a data, accessible by the key \name, to this DataContainer.
         * Already existing DataHandles with the same key will be removed from this DataContainer.
         *
         * \param   name    Key for accessing the DataHandle within this DataContainer
         * \param   data    DataHandle to add.
         **/
        virtual void addDataHandle(const std::string& name, const DataHandle* dh);

        /**
         * Returns the local DataContainer of this Processor.
69
         * \return _dataContainer
schultezub's avatar
schultezub committed
70
71
72
         **/
        const DataContainer& getDataContainer() const;

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

        /**
schultezub's avatar
schultezub committed
80
81
         * Returns the PropertyCollection of this processor.
         * \return _properties
82
         */
schultezub's avatar
schultezub committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
        PropertyCollection& getPropertyCollection();

        /**
         * 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.
         */
        void applyInvalidationLevel(InvalidationLevel::NamedLevels nl);


        /**
         * Gets called when one of the observed properties changed notifies its observers.
         * \sa GenericObserver::onNotify, AbstractProperty
         * \param poa   PropertyObserverArgs    ObserverArgument struct containing the emitting property and its InvalidationLevel
         */
        virtual void onNotify(const PropertyObserverArgs& poa);

101

schultezub's avatar
schultezub committed
102
    protected:
103
        DataContainer _dataContainer;               ///< DataContainer containing local working set of data for this Processor
schultezub's avatar
schultezub committed
104
105
106
107
        InvalidationLevel _invalidationLevel;       ///< current invalidation level of this processor

        PropertyCollection _properties;             ///< PropertyCollection of this processor

schultezub's avatar
schultezub committed
108
109
110
111
112
113
114

        static const std::string loggerCat_;
    };

}

#endif // PROCESSOR_H__