summaryrefslogtreecommitdiffstats
path: root/IdManager.h
blob: 8f846a9b44fca60deda1b8ac6948a9e9091e53c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef IDMANAGER_H_
#define IDMANAGER_H_

#include <string>
#include <set>
#include <map>


class IdManager {
  private:
    std::set<std::string> usedIds;
    std::map<std::string, unsigned long> prefixMap;
    
    bool isValid(const std::string &id) const;
    bool unique(const std::string &id) const;
    
  public:
    bool add(const std::string &id);
    bool remove(const std::string &id);
    
    bool valid(const std::string &id) const;
    
    std::string generate(const std::string &prefix);
};

#endif /*IDMANAGER_H_*/