1 //
2 // C++ Interface: effectortypes
3 //
4 // Description:
5 // Enumeration of effector types and a a specialized EffectorVisitor that
6 // allows for a more effective effector type detection than dynamic_cast<>.
7 //
8 // Copyright (C) 2010  Bjarne Juul Pasgaard <bjvest@users.sourceforge.net>
9 //
10 // This program is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU General Public License
12 // as published by the Free Software Foundation; either version 2
13 // of the License, or (at your option) any later version.
14 //
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
23 // USA.
24 
25 #ifndef EFFECTORTYPES_H
26 #define EFFECTORTYPES_H
27 
28 #include "effector.h"
29 #include "effectorVisitor.h"
30 
31 /// @brief Enumeration of the available effector types.
32 enum EffectorType {
33   KenBurns,   ///< Ken Burns effect
34   Crossfade,  ///< Cross fading
35   Plain,      ///< Plain pictures
36   Blur,       ///< Bluring at changeover
37   Shift,      ///< Shift left effect
38   ShiftBlend  ///< Shift and blend left effect
39 };
40 
41 // Forward declarations
42 class KenBurnsEffect;
43 class Crossfader;
44 class LowpassEffect;
45 class PlainPicture;
46 class ShiftEffect;
47 class ShiftblendEffect;
48 
49 /// @brief A functor that determines the type of an
50 ///        effector specialization.
51 ///
52 /// This is an alternative to dynamic_cast<>, but is often
53 /// far more effective and has the advantage of a known
54 /// constant-time complexity (in contrast to dynamic_cast<>).
55 class GetEffectorType : protected EffectorVisitor {
56 public:
57 
58   /// @brief The entry point of the functor.
59   ///
60   /// @param effector The effector to determine the type of.
61   ///
62   /// @return The type of the supplied effector.
63   EffectorType operator()(const Effector& effector);
64 
~GetEffectorType()65   virtual ~GetEffectorType() {}
66 
67 protected:
68 
69   // Overridden base class methods
70   virtual void visit(const KenBurnsEffect&);
71   virtual void visit(const Crossfader&);
72   virtual void visit(const LowpassEffect&);
73   virtual void visit(const PlainPicture&);
74   virtual void visit(const ShiftEffect&);
75   virtual void visit(const ShiftblendEffect&);
76 
77 protected:
78 
79   EffectorType t;
80 
81 };
82 
83 #endif
84