v6502cpp/SegmentCache.h

55 lines
1.0 KiB
C++

/*
* File: SegmentCache.h
* Author: Christopher
*
* Created on December 10, 2013, 9:56 PM
*/
#ifndef SEGMENTCACHE_H
#define SEGMENTCACHE_H
#include "setpSeg.h"
#include <memory>
#include <string>
#include <map>
#include <set>
class Segment;
class Common;
class SegmentCache {
public:
SegmentCache() {
}
virtual ~SegmentCache() {
}
Segment* getOrAdd(const std::string& id);
setpSeg all() const;
std::map<const std::string, std::shared_ptr<Segment > >::const_iterator begin() const {
return this->cache.begin();
}
std::map<const std::string, std::shared_ptr<Segment > >::const_iterator end() const {
return this->cache.end();
}
private:
std::map<const std::string, std::shared_ptr<Segment > > cache;
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;
};
#endif /* SEGMENTCACHE_H */