Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / server / src / frontend_service / selection_generator.h
blob73da30986de3370fe6cb37a586e745d6e9df6c10
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef NL_SELECTION_GENERATOR_H
20 #define NL_SELECTION_GENERATOR_H
22 #include <nel/misc/types_nl.h>
23 #include <nel/misc/debug.h>
24 #include <vector>
27 /**
28 * Interface ISelectionGenerator for class that generates a series of numbers that are "selection levels".
29 * Note1: this is an "adaptable generator" as defined in the STL.
30 * \author Olivier Cado
31 * \author Nevrax France
32 * \date 2002
34 class ISelectionGenerator
36 public:
38 /// Type of level
39 typedef uint32 TSelectionLevel;
41 /// Type for STL compatibility
42 typedef TSelectionLevel result_type;
44 /// Initialization of a selection cycle
45 virtual void init( TSelectionLevel nblevels ) {}
47 /// Change the number of levels without restarting the cycle
48 virtual void changeNbLevels( TSelectionLevel nblevels ) {}
50 /// Return the next level to select
51 virtual TSelectionLevel getNext() = 0;
53 /// Return the next level to select (STL style)
54 result_type operator() () { return getNext(); }
59 * CP2CGenerator: selection generator for strategy Power2WithCeiling
61 class CP2CGenerator : public ISelectionGenerator
63 public:
65 /// Constructor
66 CP2CGenerator( TSelectionLevel ceiling );
68 /// Initialization of a selection cycle
69 virtual void init( TSelectionLevel nblevels );
71 /// Change the number of levels without restarting the cycle
72 virtual void changeNbLevels( TSelectionLevel nblevels );
74 /// Return the next level to select
75 virtual TSelectionLevel getNext();
77 /// Resursive function that fills _LevelSequence
78 static void generateLevels( std::vector<TSelectionLevel>::iterator& iter, TSelectionLevel level );
80 private:
82 /// Stored sequence
83 std::vector<TSelectionLevel> _LevelSequence;
85 /// Index of current level, pointing to _LevelSequence
86 uint32 _CurrentLevelIndex;
88 /// Max level for power of 2. All greater levels (which I call "low ranks") are equitable
89 TSelectionLevel _Ceiling;
91 /// Total number of levels
92 TSelectionLevel _NbLevels;
94 /// Current index in the low ranks (equitable levels)
95 uint32 _CurrentLowRank;
100 /// Default ceiling
101 const ISelectionGenerator::TSelectionLevel DEFAULT_P2C_CEILING = 2;
105 * CScoringGenerator: selection generator for strategy Scoring
107 class CScoringGenerator : public ISelectionGenerator
109 public:
111 /// Initialization of a selection cycle
112 virtual void init( TSelectionLevel nblevels );
114 /// Change the number of levels without restarting the cycle
115 virtual void changeNbLevels( TSelectionLevel nblevels );
117 /// Return the next level to select
118 virtual TSelectionLevel getNext();
120 /// Display the scores (debugging)
121 void printScores();
123 private:
125 /// Type of vector of level scores
126 typedef std::vector<uint32> TLevelScores;
128 /// Vector of level scores
129 TLevelScores _LevelScores;
134 #endif // NL_SELECTION_GENERATOR_H
136 /* End of selection_generator.h */