aGrUM  0.14.2
structuralConstraintPatternInline.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
21 // this file should be included at the end of the StructuralConstraints inline
22 // files (see StructuralConstraintDAG to see how it should be included).
23 // This concerns only StructuralConstraints that derive from other
24 // StructuralConstraints. If your class does not derive from anoter constraint,
25 // include file StructuralConstraintPatternRootInline.h instead.
26 
27 #ifdef GUM_CONSTRAINT_CLASS_NAME
28 
30 INLINE void GUM_CONSTRAINT_CLASS_NAME::setGraph(const DiGraph& graph) {
31  constraints::setGraph(graph);
32  setGraphAlone(graph);
33 }
34 
36 INLINE bool GUM_CONSTRAINT_CLASS_NAME::checkArcAddition(NodeId x, NodeId y) const {
37  return constraints::checkArcAddition(x, y) && checkArcAdditionAlone(x, y);
38 }
39 
41 INLINE bool GUM_CONSTRAINT_CLASS_NAME::checkArcDeletion(NodeId x, NodeId y) const {
42  return constraints::checkArcDeletion(x, y) && checkArcDeletionAlone(x, y);
43 }
44 
46 INLINE bool GUM_CONSTRAINT_CLASS_NAME::checkArcReversal(NodeId x, NodeId y) const {
47  return constraints::checkArcReversal(x, y) && checkArcReversalAlone(x, y);
48 }
49 
51 INLINE void GUM_CONSTRAINT_CLASS_NAME::modifyGraph(const ArcAddition& change) {
52  constraints::modifyGraph(change);
53  modifyGraphAlone(change);
54 }
55 
57 INLINE void GUM_CONSTRAINT_CLASS_NAME::modifyGraph(const ArcDeletion& change) {
58  constraints::modifyGraph(change);
59  modifyGraphAlone(change);
60 }
61 
63 INLINE void GUM_CONSTRAINT_CLASS_NAME::modifyGraph(const ArcReversal& change) {
64  constraints::modifyGraph(change);
65  modifyGraphAlone(change);
66 }
67 
69 INLINE void GUM_CONSTRAINT_CLASS_NAME::modifyGraph(const GraphChange& change) {
70  constraints::modifyGraph(change);
71  modifyGraphAlone(change);
72 }
73 
75 INLINE bool
76  GUM_CONSTRAINT_CLASS_NAME::isAlwaysInvalid(const GraphChange& change) const {
77  return constraints::isAlwaysInvalid(change) || isAlwaysInvalidAlone(change);
78 }
79 
81 INLINE bool
82  GUM_CONSTRAINT_CLASS_NAME::checkModification(const ArcAddition& change) const {
83  return checkArcAddition(change.node1(), change.node2());
84 }
85 
87 INLINE bool
88  GUM_CONSTRAINT_CLASS_NAME::checkModification(const ArcDeletion& change) const {
89  return checkArcDeletion(change.node1(), change.node2());
90 }
91 
93 INLINE bool
94  GUM_CONSTRAINT_CLASS_NAME::checkModification(const ArcReversal& change) const {
95  return checkArcReversal(change.node1(), change.node2());
96 }
97 
99 INLINE bool
100  GUM_CONSTRAINT_CLASS_NAME::checkModification(const GraphChange& change) const {
101  switch (change.type()) {
103  return checkArcAddition(change.node1(), change.node2());
104 
106  return checkArcDeletion(change.node1(), change.node2());
107 
109  return checkArcReversal(change.node1(), change.node2());
110 
111  default:
112  GUM_ERROR(OperationNotAllowed,
113  "edge modifications are not supported by the constraint");
114  }
115 }
116 
117 #endif /* GUM_CONSTRAINT_CLASS_NAME */
Size NodeId
Type for node ids.
Definition: graphElements.h:97
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52