Use more DISALLOW_COPY_AND_ASSIGN

This commit is contained in:
Tiago Gomes 2012-12-27 22:25:45 +00:00
parent 7b7f663ac6
commit 485c3e34b2
20 changed files with 83 additions and 27 deletions

View File

@ -76,6 +76,9 @@ class BpLink
Params* currMsg_;
Params* nextMsg_;
double residual_;
private:
DISALLOW_COPY_AND_ASSIGN (BpLink);
};
typedef vector<BpLink*> BpLinks;
@ -84,10 +87,12 @@ typedef vector<BpLink*> BpLinks;
class SPNodeInfo
{
public:
SPNodeInfo (void) { }
void addBpLink (BpLink* link) { links_.push_back (link); }
const BpLinks& getLinks (void) { return links_; }
private:
BpLinks links_;
DISALLOW_COPY_AND_ASSIGN (SPNodeInfo);
};
@ -204,6 +209,8 @@ class BeliefProp : public GroundSolver
bool converged (void);
virtual void printLinkInformation (void) const;
DISALLOW_COPY_AND_ASSIGN (BeliefProp);
};
#endif // HORUS_BELIEFPROP_H

View File

@ -23,7 +23,6 @@ typedef vector<ConstraintTree*> ConstraintTrees;
class CTNode
{
public:
struct CompareSymbol
{
bool operator() (const CTNode* n1, const CTNode* n2) const
@ -33,11 +32,9 @@ class CTNode
};
private:
typedef TinySet<CTNode*, CompareSymbol> CTChilds_;
public:
CTNode (const CTNode& n, const CTChilds_& chs = CTChilds_())
: symbol_(n.symbol()), childs_(chs), level_(n.level()) { }
@ -52,8 +49,6 @@ class CTNode
void setSymbol (const Symbol s) { symbol_ = s; }
public:
CTChilds_& childs (void) { return childs_; }
const CTChilds_& childs (void) const { return childs_; }
@ -89,9 +84,11 @@ class CTNode
private:
void updateChildLevels (CTNode*, unsigned);
Symbol symbol_;
CTChilds_ childs_;
unsigned level_;
Symbol symbol_;
CTChilds_ childs_;
unsigned level_;
DISALLOW_ASSIGN (CTNode);
};
ostream& operator<< (ostream &out, const CTNode&);

View File

@ -75,6 +75,8 @@ class VarCluster
private:
VarNodes members_;
VarNode* repr_;
DISALLOW_COPY_AND_ASSIGN (VarCluster);
};
@ -98,6 +100,8 @@ class FacCluster
FacNodes members_;
FacNode* repr_;
VarClusters varClusters_;
DISALLOW_COPY_AND_ASSIGN (FacCluster);
};
@ -166,7 +170,6 @@ class CountingBp : public GroundSolver
unsigned getWeight (const FacCluster*,
const VarCluster*, size_t index) const;
Color freeColor_;
Colors varColors_;
Colors facColors_;
@ -175,6 +178,8 @@ class CountingBp : public GroundSolver
VarClusterMap varClusterMap_;
const FactorGraph* compressedFg_;
WeightedBp* solver_;
DISALLOW_COPY_AND_ASSIGN (CountingBp);
};
#endif // HORUS_COUNTINGBP_H

View File

@ -63,7 +63,6 @@ class ElimGraph
static void setElimHeuristic (ElimHeuristic eh) { elimHeuristic_ = eh; }
private:
void addEdge (EgNode* n1, EgNode* n2)
{
assert (n1 != n2);
@ -136,6 +135,8 @@ class ElimGraph
unordered_map<VarId, EgNode*> varMap_;
static ElimHeuristic elimHeuristic_;
DISALLOW_COPY_AND_ASSIGN (ElimGraph);
};
#endif // HORUS_ELIMGRAPH_H

View File

@ -287,6 +287,7 @@ class Factor : public TFactor<VarId>
void clone (const Factor& f);
DISALLOW_ASSIGN (Factor);
};
#endif // HORUS_FACTOR_H

View File

@ -25,9 +25,9 @@ class VarNode : public Var
const FacNodes& neighbors (void) const { return neighs_; }
private:
DISALLOW_COPY_AND_ASSIGN (VarNode);
FacNodes neighs_;
DISALLOW_COPY_AND_ASSIGN (VarNode);
};
@ -52,11 +52,11 @@ class FacNode
string getLabel (void) { return factor_.getLabel(); }
private:
DISALLOW_COPY_AND_ASSIGN (FacNode);
VarNodes neighs_;
Factor factor_;
size_t index_;
DISALLOW_COPY_AND_ASSIGN (FacNode);
};
@ -113,8 +113,6 @@ class FactorGraph
void exportToLibDaiFormat (const char*) const;
private:
// DISALLOW_COPY_AND_ASSIGN (FactorGraph);
void ignoreLines (std::ifstream&) const;
bool containsCycle (void) const;
@ -128,11 +126,13 @@ class FactorGraph
VarNodes varNodes_;
FacNodes facNodes_;
BayesBallGraph structure_;
bool bayesFactors_;
BayesBallGraph structure_;
bool bayesFactors_;
typedef unordered_map<unsigned, VarNode*> VarMap;
VarMap varMap_;
DISALLOW_ASSIGN (FactorGraph);
};

View File

@ -29,6 +29,8 @@ class GroundSolver
protected:
const FactorGraph& fg;
DISALLOW_COPY_AND_ASSIGN (GroundSolver);
};
#endif // HORUS_GROUNDSOLVER_H

View File

@ -5,6 +5,8 @@
#include <ostream>
#include "Horus.h"
using namespace std;
typedef vector<unsigned> Histogram;
@ -40,6 +42,8 @@ class HistogramSet
unsigned size_;
Histogram hist_;
DISALLOW_COPY_AND_ASSIGN (HistogramSet);
};
#endif // HORUS_HISTOGRAM_H

View File

@ -1,12 +1,18 @@
#ifndef HORUS_HORUS_H
#define HORUS_HORUS_H
#include <vector>
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
#define DISALLOW_COPY(TypeName) \
TypeName(const TypeName&)
#define DISALLOW_ASSIGN(TypeName) \
void operator=(const TypeName&)
#include <vector>
using namespace std;
class Var;

View File

@ -120,6 +120,8 @@ class Indexer
const Ranges& ranges_;
size_t size_;
vector<size_t> offsets_;
DISALLOW_COPY_AND_ASSIGN (Indexer);
};
@ -239,6 +241,8 @@ class MapIndexer
const Ranges& ranges_;
bool valid_;
vector<size_t> offsets_;
DISALLOW_COPY_AND_ASSIGN (MapIndexer);
};

View File

@ -37,6 +37,8 @@ class LiftedBp : public LiftedSolver
WeightedBp* solver_;
FactorGraph* fg_;
DISALLOW_COPY_AND_ASSIGN (LiftedBp);
};
#endif // HORUS_LIFTEDBP_H

View File

@ -217,7 +217,6 @@ class LiftedCircuit
void exportToGraphViz (const char*);
private:
void compile (CircuitNode** follow, Clauses& clauses);
bool tryUnitPropagation (CircuitNode** follow, Clauses& clauses);
@ -273,6 +272,8 @@ class LiftedCircuit
Clauses backupClauses_;
unordered_map<CircuitNode*, Clauses> originClausesMap_;
unordered_map<CircuitNode*, string> explanationMap_;
DISALLOW_COPY_AND_ASSIGN (LiftedCircuit);
};
@ -293,6 +294,8 @@ class LiftedKc : public LiftedSolver
LiftedWCNF* lwcnf_;
LiftedCircuit* circuit_;
ParfactorList pfList_;
DISALLOW_COPY_AND_ASSIGN (LiftedKc);
};
#endif // HORUS_LIFTEDKC_H

View File

@ -21,6 +21,8 @@ class LiftedOperations
private:
static Parfactors absorve (ObservedFormula&, Parfactor*);
DISALLOW_COPY_AND_ASSIGN (LiftedOperations);
};
#endif // HORUS_LIFTEDOPERATIONS_H

View File

@ -21,6 +21,9 @@ class LiftedSolver
protected:
const ParfactorList& parfactorList;
private:
DISALLOW_COPY_AND_ASSIGN (LiftedSolver);
};
#endif // HORUS_LIFTEDSOLVER_H

View File

@ -160,6 +160,5 @@ class Substitution
};
#endif // HORUS_LIFTEDUTILS_H

View File

@ -23,6 +23,9 @@ class LiftedOperator
static vector<ParfactorList::iterator> getParfactorsWithGroup (
ParfactorList&, PrvGroup group);
private:
DISALLOW_ASSIGN (LiftedOperator);
};
@ -48,6 +51,8 @@ class ProductOperator : public LiftedOperator
ParfactorList::iterator g1_;
ParfactorList::iterator g2_;
ParfactorList& pfList_;
DISALLOW_COPY_AND_ASSIGN (ProductOperator);
};
@ -74,6 +79,8 @@ class SumOutOperator : public LiftedOperator
PrvGroup group_;
ParfactorList& pfList_;
DISALLOW_COPY_AND_ASSIGN (SumOutOperator);
};
@ -101,6 +108,8 @@ class CountingOperator : public LiftedOperator
ParfactorList::iterator pfIter_;
LogVar X_;
ParfactorList& pfList_;
DISALLOW_COPY_AND_ASSIGN (CountingOperator);
};
@ -123,11 +132,13 @@ class GroundOperator : public LiftedOperator
string toString (void);
private:
vector<pair<PrvGroup, unsigned>> getAffectedFormulas (void);
vector<pair<PrvGroup, unsigned>> getAffectedFormulas (void);
PrvGroup group_;
unsigned lvIndex_;
ParfactorList& pfList_;
DISALLOW_COPY_AND_ASSIGN (GroundOperator);
};
@ -149,6 +160,8 @@ class LiftedVe : public LiftedSolver
ParfactorList pfList_;
double largestCost_;
DISALLOW_COPY_AND_ASSIGN (LiftedVe);
};
#endif // HORUS_LIFTEDVE_H

View File

@ -148,6 +148,8 @@ class Clause
LogVarSet posCountedLvs_;
LogVarSet negCountedLvs_;
ConstraintTree constr_;
DISALLOW_ASSIGN (Clause);
};
typedef vector<Clause*> Clauses;
@ -220,7 +222,6 @@ class LiftedWCNF
void printClauses (void) const;
private:
LiteralId getLiteralId (PrvGroup prvGroup, unsigned range);
void addIndicatorClauses (const ParfactorList& pfList);
@ -232,6 +233,8 @@ class LiftedWCNF
const ParfactorList& pfList_;
unordered_map<PrvGroup, vector<LiteralId>> map_;
unordered_map<LiteralId, std::pair<double,double>> weights_;
DISALLOW_COPY_AND_ASSIGN (LiftedWCNF);
};
#endif // HORUS_LIFTEDWCNF_H

View File

@ -96,7 +96,6 @@ class Parfactor : public TFactor<ProbFormula>
static bool canMultiply (Parfactor*, Parfactor*);
private:
void simplifyCountingFormulas (size_t fIdx);
void simplifyParfactor (size_t fIdx1, size_t fIdx2);
@ -113,9 +112,9 @@ class Parfactor : public TFactor<ProbFormula>
ConstraintTree* constr_;
DISALLOW_ASSIGN (Parfactor);
};
typedef vector<Parfactor*> Parfactors;
#endif // HORUS_PARFACTOR_H

View File

@ -37,6 +37,8 @@ class VarElim : public GroundSolver
unsigned largestFactorSize_;
unsigned totalFactorSize_;
unordered_map<VarId, vector<size_t>> varMap_;
DISALLOW_COPY_AND_ASSIGN (VarElim);
};
#endif // HORUS_VARELIM_H

View File

@ -24,6 +24,8 @@ class WeightedLink : public BpLink
}
private:
DISALLOW_COPY_AND_ASSIGN (WeightedLink);
size_t index_;
unsigned weight_;
Params pwdMsg_;
@ -43,7 +45,6 @@ class WeightedBp : public BeliefProp
Params getPosterioriOf (VarId);
private:
void createLinks (void);
void maxResidualSchedule (void);
@ -55,6 +56,8 @@ class WeightedBp : public BeliefProp
void printLinkInformation (void) const;
vector<vector<unsigned>> weights_;
DISALLOW_COPY_AND_ASSIGN (WeightedBp);
};
#endif // HORUS_WEIGHTEDBP_H