From 485c3e34b2d1e044936bbe103f4de1b469ab916a Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Thu, 27 Dec 2012 22:25:45 +0000 Subject: [PATCH] Use more DISALLOW_COPY_AND_ASSIGN --- packages/CLPBN/horus/BeliefProp.h | 7 +++++++ packages/CLPBN/horus/ConstraintTree.h | 13 +++++-------- packages/CLPBN/horus/CountingBp.h | 7 ++++++- packages/CLPBN/horus/ElimGraph.h | 3 ++- packages/CLPBN/horus/Factor.h | 1 + packages/CLPBN/horus/FactorGraph.h | 16 ++++++++-------- packages/CLPBN/horus/GroundSolver.h | 2 ++ packages/CLPBN/horus/Histogram.h | 4 ++++ packages/CLPBN/horus/Horus.h | 10 ++++++++-- packages/CLPBN/horus/Indexer.h | 4 ++++ packages/CLPBN/horus/LiftedBp.h | 2 ++ packages/CLPBN/horus/LiftedKc.h | 5 ++++- packages/CLPBN/horus/LiftedOperations.h | 2 ++ packages/CLPBN/horus/LiftedSolver.h | 3 +++ packages/CLPBN/horus/LiftedUtils.h | 1 - packages/CLPBN/horus/LiftedVe.h | 15 ++++++++++++++- packages/CLPBN/horus/LiftedWCNF.h | 5 ++++- packages/CLPBN/horus/Parfactor.h | 3 +-- packages/CLPBN/horus/VarElim.h | 2 ++ packages/CLPBN/horus/WeightedBp.h | 5 ++++- 20 files changed, 83 insertions(+), 27 deletions(-) diff --git a/packages/CLPBN/horus/BeliefProp.h b/packages/CLPBN/horus/BeliefProp.h index 6399c65e7..68d47ac5c 100644 --- a/packages/CLPBN/horus/BeliefProp.h +++ b/packages/CLPBN/horus/BeliefProp.h @@ -76,6 +76,9 @@ class BpLink Params* currMsg_; Params* nextMsg_; double residual_; + + private: + DISALLOW_COPY_AND_ASSIGN (BpLink); }; typedef vector BpLinks; @@ -84,10 +87,12 @@ typedef vector 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 diff --git a/packages/CLPBN/horus/ConstraintTree.h b/packages/CLPBN/horus/ConstraintTree.h index cccb070b4..2c0c09464 100644 --- a/packages/CLPBN/horus/ConstraintTree.h +++ b/packages/CLPBN/horus/ConstraintTree.h @@ -23,7 +23,6 @@ typedef vector ConstraintTrees; class CTNode { public: - struct CompareSymbol { bool operator() (const CTNode* n1, const CTNode* n2) const @@ -33,11 +32,9 @@ class CTNode }; private: - typedef TinySet 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&); diff --git a/packages/CLPBN/horus/CountingBp.h b/packages/CLPBN/horus/CountingBp.h index c6487cdd0..4f674e687 100644 --- a/packages/CLPBN/horus/CountingBp.h +++ b/packages/CLPBN/horus/CountingBp.h @@ -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 diff --git a/packages/CLPBN/horus/ElimGraph.h b/packages/CLPBN/horus/ElimGraph.h index 881f59759..a636d316d 100644 --- a/packages/CLPBN/horus/ElimGraph.h +++ b/packages/CLPBN/horus/ElimGraph.h @@ -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 varMap_; static ElimHeuristic elimHeuristic_; + + DISALLOW_COPY_AND_ASSIGN (ElimGraph); }; #endif // HORUS_ELIMGRAPH_H diff --git a/packages/CLPBN/horus/Factor.h b/packages/CLPBN/horus/Factor.h index 415a3d1df..ea11d1137 100644 --- a/packages/CLPBN/horus/Factor.h +++ b/packages/CLPBN/horus/Factor.h @@ -287,6 +287,7 @@ class Factor : public TFactor void clone (const Factor& f); + DISALLOW_ASSIGN (Factor); }; #endif // HORUS_FACTOR_H diff --git a/packages/CLPBN/horus/FactorGraph.h b/packages/CLPBN/horus/FactorGraph.h index 3417acf38..a235d8d26 100644 --- a/packages/CLPBN/horus/FactorGraph.h +++ b/packages/CLPBN/horus/FactorGraph.h @@ -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 VarMap; VarMap varMap_; + + DISALLOW_ASSIGN (FactorGraph); }; diff --git a/packages/CLPBN/horus/GroundSolver.h b/packages/CLPBN/horus/GroundSolver.h index ec6bf60c7..eac28b045 100644 --- a/packages/CLPBN/horus/GroundSolver.h +++ b/packages/CLPBN/horus/GroundSolver.h @@ -29,6 +29,8 @@ class GroundSolver protected: const FactorGraph& fg; + + DISALLOW_COPY_AND_ASSIGN (GroundSolver); }; #endif // HORUS_GROUNDSOLVER_H diff --git a/packages/CLPBN/horus/Histogram.h b/packages/CLPBN/horus/Histogram.h index c9bdd78e1..9b65f9f02 100644 --- a/packages/CLPBN/horus/Histogram.h +++ b/packages/CLPBN/horus/Histogram.h @@ -5,6 +5,8 @@ #include +#include "Horus.h" + using namespace std; typedef vector Histogram; @@ -40,6 +42,8 @@ class HistogramSet unsigned size_; Histogram hist_; + + DISALLOW_COPY_AND_ASSIGN (HistogramSet); }; #endif // HORUS_HISTOGRAM_H diff --git a/packages/CLPBN/horus/Horus.h b/packages/CLPBN/horus/Horus.h index 17141d63e..46d619b9d 100644 --- a/packages/CLPBN/horus/Horus.h +++ b/packages/CLPBN/horus/Horus.h @@ -1,12 +1,18 @@ #ifndef HORUS_HORUS_H #define HORUS_HORUS_H -#include - #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 + using namespace std; class Var; diff --git a/packages/CLPBN/horus/Indexer.h b/packages/CLPBN/horus/Indexer.h index cb8135866..a4141ebed 100644 --- a/packages/CLPBN/horus/Indexer.h +++ b/packages/CLPBN/horus/Indexer.h @@ -120,6 +120,8 @@ class Indexer const Ranges& ranges_; size_t size_; vector offsets_; + + DISALLOW_COPY_AND_ASSIGN (Indexer); }; @@ -239,6 +241,8 @@ class MapIndexer const Ranges& ranges_; bool valid_; vector offsets_; + + DISALLOW_COPY_AND_ASSIGN (MapIndexer); }; diff --git a/packages/CLPBN/horus/LiftedBp.h b/packages/CLPBN/horus/LiftedBp.h index 274503f29..01807ddfb 100644 --- a/packages/CLPBN/horus/LiftedBp.h +++ b/packages/CLPBN/horus/LiftedBp.h @@ -37,6 +37,8 @@ class LiftedBp : public LiftedSolver WeightedBp* solver_; FactorGraph* fg_; + DISALLOW_COPY_AND_ASSIGN (LiftedBp); + }; #endif // HORUS_LIFTEDBP_H diff --git a/packages/CLPBN/horus/LiftedKc.h b/packages/CLPBN/horus/LiftedKc.h index 6dc4440ea..949787f01 100644 --- a/packages/CLPBN/horus/LiftedKc.h +++ b/packages/CLPBN/horus/LiftedKc.h @@ -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 originClausesMap_; unordered_map 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 diff --git a/packages/CLPBN/horus/LiftedOperations.h b/packages/CLPBN/horus/LiftedOperations.h index 1f4b53d3a..d17bb5359 100644 --- a/packages/CLPBN/horus/LiftedOperations.h +++ b/packages/CLPBN/horus/LiftedOperations.h @@ -21,6 +21,8 @@ class LiftedOperations private: static Parfactors absorve (ObservedFormula&, Parfactor*); + + DISALLOW_COPY_AND_ASSIGN (LiftedOperations); }; #endif // HORUS_LIFTEDOPERATIONS_H diff --git a/packages/CLPBN/horus/LiftedSolver.h b/packages/CLPBN/horus/LiftedSolver.h index 5429fc5b3..afdfe1461 100644 --- a/packages/CLPBN/horus/LiftedSolver.h +++ b/packages/CLPBN/horus/LiftedSolver.h @@ -21,6 +21,9 @@ class LiftedSolver protected: const ParfactorList& parfactorList; + + private: + DISALLOW_COPY_AND_ASSIGN (LiftedSolver); }; #endif // HORUS_LIFTEDSOLVER_H diff --git a/packages/CLPBN/horus/LiftedUtils.h b/packages/CLPBN/horus/LiftedUtils.h index 70e0d1071..66d5c6e07 100644 --- a/packages/CLPBN/horus/LiftedUtils.h +++ b/packages/CLPBN/horus/LiftedUtils.h @@ -160,6 +160,5 @@ class Substitution }; - #endif // HORUS_LIFTEDUTILS_H diff --git a/packages/CLPBN/horus/LiftedVe.h b/packages/CLPBN/horus/LiftedVe.h index b747d9da3..d66f42e7f 100644 --- a/packages/CLPBN/horus/LiftedVe.h +++ b/packages/CLPBN/horus/LiftedVe.h @@ -23,6 +23,9 @@ class LiftedOperator static vector 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> getAffectedFormulas (void); + vector> 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 diff --git a/packages/CLPBN/horus/LiftedWCNF.h b/packages/CLPBN/horus/LiftedWCNF.h index 2aed7a6cf..619d2c5a5 100644 --- a/packages/CLPBN/horus/LiftedWCNF.h +++ b/packages/CLPBN/horus/LiftedWCNF.h @@ -148,6 +148,8 @@ class Clause LogVarSet posCountedLvs_; LogVarSet negCountedLvs_; ConstraintTree constr_; + + DISALLOW_ASSIGN (Clause); }; typedef vector 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> map_; unordered_map> weights_; + + DISALLOW_COPY_AND_ASSIGN (LiftedWCNF); }; #endif // HORUS_LIFTEDWCNF_H diff --git a/packages/CLPBN/horus/Parfactor.h b/packages/CLPBN/horus/Parfactor.h index 6cd04b23c..f21fc5f69 100644 --- a/packages/CLPBN/horus/Parfactor.h +++ b/packages/CLPBN/horus/Parfactor.h @@ -96,7 +96,6 @@ class Parfactor : public TFactor 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 ConstraintTree* constr_; + DISALLOW_ASSIGN (Parfactor); }; - typedef vector Parfactors; #endif // HORUS_PARFACTOR_H diff --git a/packages/CLPBN/horus/VarElim.h b/packages/CLPBN/horus/VarElim.h index 96906bb00..da05e51a1 100644 --- a/packages/CLPBN/horus/VarElim.h +++ b/packages/CLPBN/horus/VarElim.h @@ -37,6 +37,8 @@ class VarElim : public GroundSolver unsigned largestFactorSize_; unsigned totalFactorSize_; unordered_map> varMap_; + + DISALLOW_COPY_AND_ASSIGN (VarElim); }; #endif // HORUS_VARELIM_H diff --git a/packages/CLPBN/horus/WeightedBp.h b/packages/CLPBN/horus/WeightedBp.h index 1e79fd4db..9bb40fe95 100644 --- a/packages/CLPBN/horus/WeightedBp.h +++ b/packages/CLPBN/horus/WeightedBp.h @@ -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> weights_; + + DISALLOW_COPY_AND_ASSIGN (WeightedBp); }; #endif // HORUS_WEIGHTEDBP_H