v6502cpp/SegmentCache.h

71 lines
1.4 KiB
C
Raw 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 "trans.h"
#include <memory>
#include <string>
#include <map>
#include <set>
class Common;
2013-12-12 22:05:33 +00:00
class SegmentCache {
public:
2013-12-14 06:49:50 +00:00
SegmentCache() : c(nullptr) {
2013-12-12 22:05:33 +00:00
}
virtual ~SegmentCache();
2013-12-12 22:05:33 +00:00
Segment* getOrAdd(const std::string& id);
setpSeg all() const {
setpSeg s;
for (auto i : this->cache) {
2013-12-14 04:06:13 +00:00
s.insert(i.second.get());
2013-12-13 14:55:19 +00:00
}
return s;
}
2013-12-12 22:05:33 +00:00
unsigned char rData() const;
unsigned short rAddr() const;
unsigned char rA() const;
unsigned char rX() const;
unsigned char rY() const;
unsigned char rS() const;
unsigned short rPC() const;
void setDataSegs(const unsigned char data);
void addDataToRecalc(setpSeg& s) 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();
}
2013-12-12 22:05:33 +00:00
private:
std::map<const std::string, std::shared_ptr<Segment > > cache;
2013-12-14 06:49:50 +00:00
SegmentCache(const SegmentCache&) = delete;
SegmentCache& operator=(const SegmentCache&) = delete;
Segment* get(const std::string& id) const;
public:
void initCommon();
Common* c;
2013-12-12 22:05:33 +00:00
};
#endif /* SEGMENTCACHE_H */