v6502cpp/SegmentCache.h

59 lines
988 B
C
Raw Permalink Normal View History

2013-12-12 22:05:33 +00:00
/*
* File: SegmentCache.h
* Author: Christopher
*
* Created on December 10, 2013, 9:56 PM
*/
#ifndef SEGMENTCACHE_H
#define SEGMENTCACHE_H
#include "SegmentTypes.h"
2013-12-12 22:05:33 +00:00
#include <map>
#include <set>
#include <string>
#include <memory>
2013-12-12 22:05:33 +00:00
2013-12-15 06:13:44 +00:00
class Common;
class SegmentCache final {
2013-12-12 22:05:33 +00:00
public:
SegmentCache() {
2013-12-12 22:05:33 +00:00
}
Segment* getOrAdd(const std::string& id);
SegmentSet all() const;
2013-12-13 14:55:19 +00:00
2013-12-12 22:05:33 +00:00
typedef std::map<const std::string, std::shared_ptr<Segment>> Map;
Map::const_iterator begin() const {
return this->cache.begin();
}
Map::const_iterator end() const {
return this->cache.end();
}
2013-12-12 22:05:33 +00:00
2013-12-17 02:51:12 +00:00
Map::size_type size() const {
return this->cache.size();
}
2013-12-12 22:05:33 +00:00
private:
Map cache;
2013-12-12 22:05:33 +00:00
2013-12-14 06:49:50 +00:00
SegmentCache(const SegmentCache&) = delete;
SegmentCache& operator=(const SegmentCache&) = delete;
Segment* get(const std::string& id) const;
bool cached(const std::string& id) const;
friend Common;
2013-12-12 22:05:33 +00:00
};
#endif /* SEGMENTCACHE_H */