refactor: extract setpSeg typedef to own header

This commit is contained in:
Christopher Mosher 2013-12-15 00:23:25 -05:00
parent da174b54cd
commit 84715444c9
10 changed files with 43 additions and 14 deletions

View File

@ -9,7 +9,9 @@
#define CIRCUIT_H
#include <set>
#include "trans.h"
#include "setpSeg.h"
class Segment;
/*
* Builds a circuit, given one segment in that circuit.

View File

@ -7,6 +7,7 @@
#include "Common.h"
#include "SegmentCache.h"
#include "trans.h"
Common Common::create(const SegmentCache& segs) {
return Common(

View File

@ -8,9 +8,10 @@
#ifndef COMMON_H
#define COMMON_H
#include "trans.h"
#include "setpSeg.h"
class SegmentCache;
class Segment;
class Common {
public:

View File

@ -18,7 +18,7 @@
#define TRACEREG 1
#define TRACESEG 1
//#define TRACESEG 1

View File

@ -6,6 +6,7 @@
*/
#include "SegmentCache.h"
#include "trans.h"
#include <memory>
#include <string>
#include <map>
@ -42,3 +43,11 @@ Segment* SegmentCache::get(const std::string& id) const {
return this->cache.at(id).get();
}
setpSeg SegmentCache::all() const {
setpSeg s;
for (auto i : this->cache) {
s.insert(i.second.get());
}
return s;
}

View File

@ -8,13 +8,14 @@
#ifndef SEGMENTCACHE_H
#define SEGMENTCACHE_H
#include "trans.h"
#include "setpSeg.h"
#include <memory>
#include <string>
#include <map>
#include <set>
class Common;
class Segment;
class SegmentCache {
public:
@ -27,13 +28,7 @@ public:
Segment* getOrAdd(const std::string& id);
setpSeg all() const {
setpSeg s;
for (auto i : this->cache) {
s.insert(i.second.get());
}
return s;
}
setpSeg all() const;
std::map<const std::string, std::shared_ptr<Segment > >::const_iterator begin() const {

View File

@ -9,7 +9,10 @@
#define STATECALCULATOR_H
#include <set>
#include "trans.h"
#include "setpSeg.h"
class Segment;
class Trans;
class StateCalculator {
public:

View File

@ -7,6 +7,7 @@
#include "Trace.h"
#include "SegmentCache.h"
#include "trans.h"
#include "Common.h"
#include <iostream>
#include <iomanip>

18
setpSeg.h Normal file
View File

@ -0,0 +1,18 @@
/*
* File: setpSeg.h
* Author: Christopher
*
* Created on December 15, 2013, 12:16 AM
*/
#ifndef SETPSEG_H
#define SETPSEG_H
#include "ptr_less.h"
#include <set>
class Segment;
typedef std::set<Segment*,ptr_less<Segment>> setpSeg;
#endif /* SETPSEG_H */

View File

@ -8,7 +8,7 @@
#ifndef TRANS_H
#define TRANS_H
#include "ptr_less.h"
#include "setpSeg.h"
#include <set>
#include <string>
@ -62,7 +62,6 @@ private:
Segment& operator=(const Segment&) = delete;
};
typedef std::set<Segment*,ptr_less<Segment>> setpSeg;