1 #ifndef __PREFIX_MAX__KEYGENERATOR_
2 #define __PREFIX_MAX__KEYGENERATOR_
4 //------------------------------------------------------------------------------------------------------------
6 //------------------------------------------------------------------------------------------------------------
17 * Class that manages the creation of std::string keys of multiple objects independently, identified each by a unique name.
18 * Format of the key is: <prefixOfTheKeyThing> <maxOfTheKeyThing>
20 class PrefixMaxKeyGenerator{
21 //------------------------------------------------------------------------------------------------------------
22 // Constructors & Destructors
23 //------------------------------------------------------------------------------------------------------------
27 * Creates the prefix+max key generator
29 PrefixMaxKeyGenerator();
32 * Destroys the outline manager
34 ~PrefixMaxKeyGenerator();
36 //------------------------------------------------------------------------------------------------------------
38 //------------------------------------------------------------------------------------------------------------
41 * Adds a key thing to the keyThings building the respective KeyThing (new keyThing).
42 * @param theName Is the name of the new keyThing to include. If the name is not unique, returns false.
43 * @param thePrefix Is the prefix of the new keyThing for the key generation correponding to the new keyThing
44 * @param theMax Is the maximum value for the key generation correponding to the new keyThing
45 * @return Returns true if the keyThing could be added of not.
47 bool addKeyThing( std::string theName, std::string thePrefix, int theMax=0 );
51 * @param theName Is the name of the keyThing to remove.
53 void removeKeyThing( std::string theName );
56 * Indicates if a key thing existis in the generator
57 * @param theName Is the name of the keyThing to search.
58 * @return Returns true if the keyThing exists in the keyThings.
60 bool existsKeyThing( std::string theName );
63 * Updates the maximum value of a key thing if necesary (posibleMax>theMaxOfKeyThing). If the key thing doesn't exist nothing is done.
64 * @param theName Is the name of the keyThing to update.
65 * @param posibleMax Is the number that corresponds to a posible max value of the keyThing to update.
67 void updateMaxTo( std::string theName, int posibleMax );
70 * Generates a (std::string) key for a given keyThing. If the key thing doesn't exist nothing is done and returns false.
71 * @param theName Is the name of the keyThing to search.
72 * @param theInputString Is string to load the generated key formed like <prefixOfTheKeyThing> <maxOfTheKeyThing>
73 * @return theKey Returns true if the key was generated successfully. (If theName is an existent keyThing)
75 bool generateKeyOf( std::string theName , std::string &theInputString );
78 * Generates a (std::string) key for a given keyThing and updates the max value of it if necesary. If the key thing doesn't exist nothing is done.
79 * @param theName Is the name of the keyThing to search.
80 * @param posibleMax Is the number that corresponds to a posible max value of the keyThing to update.
81 * @param theInputString Is string to load the generated key formed like <prefixOfTheKeyThing> <maxOfTheKeyThing>
82 * @return Returns true if the key was generated successfully. (If theName is an existent keyThing)
84 bool generateKeyOf( std::string theName, int posibleMax, std::string &theInputString );
87 * Gets the prefix of a specific keyThing identified with the name in the parameter, if the key thing doesn't exists return false.
88 * @param theName Is the name of the keyThing to search the prefix.
89 * @param theInputString Is string to load the prefix of the searched keyThing.
90 * @return isStringOutputReal Returns if the loaded string in theInputString is real (i.e if the -theName- keyThing exists)
92 bool getPrefixOf(std::string theName, std::string &theInputString);
95 * Gets the max value of a specific keyThing identified with the name in the parameter. If the key thing doesn't exists returns -1.
96 * @param theName Is the name of the keyThing to search the maximum.
97 * @return theMax Returns the maxumum value for key generation at the keyThing. Returns -1 if not finded keyThing.
99 int getCurrentMaxOf(std::string theName);
102 * Gets the total of keyThings managed
103 * @return Retuns the total of keyThing managed
105 int getTotalThingsNumber();
108 * Clears the generator deleating the existring keyThings
112 //------------------------------------------------------------------------------------------------------------
114 //------------------------------------------------------------------------------------------------------------
116 //------------------------------------------------------------------------------------------------------------
118 //------------------------------------------------------------------------------------------------------------
123 * Represents the number of things that are currently managing
125 int numberOfKeyThings;
128 * Represents the map or table in which the key-things are saved
130 std::map<std::string,KeyThing> keyThings;