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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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