Overte C++ Documentation
TransitionStage.h
1 //
2 // TransitionStage.h
3 
4 // Created by Olivier Prat on 07/07/2017.
5 // Copyright 2017 High Fidelity, Inc.
6 //
7 // Distributed under the Apache License, Version 2.0.
8 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9 //
10 
11 #ifndef hifi_render_TransitionStage_h
12 #define hifi_render_TransitionStage_h
13 
14 #include "Stage.h"
15 #include "IndexedContainer.h"
16 #include "Engine.h"
17 #include "Transition.h"
18 
19 namespace render {
20 
21  // Transition stage to set up Transition-related effects
22  class TransitionStage : public render::Stage {
23  public:
24 
25  static const std::string& getName() { return _name; }
26 
27  using Index = indexed_container::Index;
28  static const Index INVALID_INDEX;
29  using TransitionIdList = indexed_container::Indices;
30 
31  static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; }
32 
33  bool isTransitionUsed(Index index) const { return _transitions.checkIndex(index) && !_transitions.isElementFreed(index); }
34 
35  const Transition& getTransition(Index TransitionId) const { return _transitions.get(TransitionId); }
36 
37  Transition& editTransition(Index TransitionId) { return _transitions.edit(TransitionId); }
38 
39  Index addTransition(ItemID itemId, Transition::Type type, ItemID boundId);
40  void removeTransition(Index index);
41 
42  TransitionIdList::iterator begin() { return _activeTransitionIds.begin(); }
43  TransitionIdList::iterator end() { return _activeTransitionIds.end(); }
44 
45  private:
46 
47  using Transitions = indexed_container::IndexedVector<Transition>;
48 
49  static std::string _name;
50 
51  Transitions _transitions;
52  TransitionIdList _activeTransitionIds;
53  };
54  using TransitionStagePointer = std::shared_ptr<TransitionStage>;
55 
56  class TransitionStageSetup {
57  public:
58  using JobModel = render::Job::Model<TransitionStageSetup>;
59 
60  TransitionStageSetup();
61  void run(const RenderContextPointer& renderContext);
62 
63  protected:
64  };
65 
66 }
67 
68 #endif // hifi_render_TransitionStage_h