aGrUM  0.16.0
structuralConstraintSetStatic_tpl.h
Go to the documentation of this file.
1 
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 
31 # include <iostream>
32 
33 namespace gum {
34 
35  namespace learning {
36 
38  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
39  INLINE __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
40  __StructuralConstraintSetStatic() {}
41 
43  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
44  INLINE __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
45  __StructuralConstraintSetStatic(
46  const __StructuralConstraintSetStatic< CONSTRAINT1,
47  OTHER_CONSTRAINTS... >& from) :
48  CONSTRAINT1(from),
49  __StructuralConstraintSetStatic< OTHER_CONSTRAINTS... >(from) {}
50 
52  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
53  INLINE __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
54  ~__StructuralConstraintSetStatic() {}
55 
57  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
58  INLINE __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >&
59  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
60  operator=(
61  const __StructuralConstraintSetStatic< CONSTRAINT1,
62  OTHER_CONSTRAINTS... >& from) {
63  if (this != &from) {
64  next_constraints::operator=(from);
65  first_constraint::operator=(from);
66  }
67 
68  return *this;
69  }
70 
72  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
73  INLINE void
74  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
75  setGraph(const DiGraph& graph) {
76  next_constraints::setGraph(graph);
77  first_constraint::setGraphAlone(graph);
78  }
79 
81  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
82  INLINE void
83  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
84  modifyGraph(const ArcAddition& change) {
85  next_constraints::modifyGraph(change);
86  first_constraint::modifyGraphAlone(change);
87  }
88 
90  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
91  INLINE void
92  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
93  modifyGraph(const ArcDeletion& change) {
94  next_constraints::modifyGraph(change);
95  first_constraint::modifyGraphAlone(change);
96  }
97 
99  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
100  INLINE void
101  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
102  modifyGraph(const ArcReversal& change) {
103  next_constraints::modifyGraph(change);
104  first_constraint::modifyGraphAlone(change);
105  }
106 
108  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
109  INLINE void
110  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
111  modifyGraph(const GraphChange& change) {
112  next_constraints::modifyGraph(change);
113  first_constraint::modifyGraphAlone(change);
114  }
115 
117  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
118  INLINE bool
119  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
120  isAlwaysInvalid(const GraphChange& change) const {
121  return next_constraints::isAlwaysInvalid(change)
122  || first_constraint::isAlwaysInvalidAlone(change);
123  }
124 
126  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
127  INLINE bool
128  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
129  checkArcAddition(NodeId x, NodeId y) const {
130  return next_constraints::checkArcAddition(x, y)
131  && first_constraint::checkArcAdditionAlone(x, y);
132  }
133 
135  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
136  INLINE bool
137  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
138  checkArcDeletion(NodeId x, NodeId y) const {
139  return next_constraints::checkArcDeletion(x, y)
140  && first_constraint::checkArcDeletionAlone(x, y);
141  }
142 
144  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
145  INLINE bool
146  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
147  checkArcReversal(NodeId x, NodeId y) const {
148  return next_constraints::checkArcReversal(x, y)
149  && first_constraint::checkArcReversalAlone(x, y);
150  }
151 
153  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
154  INLINE bool
155  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
156  checkModification(const ArcAddition& change) const {
157  return next_constraints::checkModification(change)
158  && first_constraint::checkModificationAlone(change);
159  }
160 
162  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
163  INLINE bool
164  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
165  checkModification(const ArcDeletion& change) const {
166  return next_constraints::checkModification(change)
167  && first_constraint::checkModificationAlone(change);
168  }
169 
171  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
172  INLINE bool
173  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
174  checkModification(const ArcReversal& change) const {
175  return next_constraints::checkModification(change)
176  && first_constraint::checkModificationAlone(change);
177  }
178 
180  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
181  INLINE bool
182  __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
183  checkModification(const GraphChange& change) const {
184  return next_constraints::checkModification(change)
185  && first_constraint::checkModificationAlone(change);
186  }
187 
188  // ===========================================================================
189 
191  template < typename CONSTRAINT >
192  INLINE __StructuralConstraintSetStatic<
193  CONSTRAINT >::__StructuralConstraintSetStatic() {}
194 
196  template < typename CONSTRAINT >
197  INLINE __StructuralConstraintSetStatic< CONSTRAINT >::
198  __StructuralConstraintSetStatic(
199  const __StructuralConstraintSetStatic< CONSTRAINT >& from) :
200  CONSTRAINT(from) {}
201 
203  template < typename CONSTRAINT >
204  INLINE __StructuralConstraintSetStatic<
205  CONSTRAINT >::~__StructuralConstraintSetStatic() {}
206 
208  template < typename CONSTRAINT >
209  INLINE __StructuralConstraintSetStatic< CONSTRAINT >&
210  __StructuralConstraintSetStatic< CONSTRAINT >::
211  operator=(const __StructuralConstraintSetStatic< CONSTRAINT >& from) {
212  if (this != &from) { CONSTRAINT::operator=(from); }
213 
214  return *this;
215  }
216 
218  template < typename CONSTRAINT >
219  INLINE void __StructuralConstraintSetStatic< CONSTRAINT >::setGraph(
220  const DiGraph& graph) {
221  first_constraint::setGraphAlone(graph);
222  }
223 
225  template < typename CONSTRAINT >
226  INLINE void __StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(
227  const ArcAddition& change) {
228  first_constraint::modifyGraphAlone(change);
229  }
230 
232  template < typename CONSTRAINT >
233  INLINE void __StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(
234  const ArcDeletion& change) {
235  first_constraint::modifyGraphAlone(change);
236  }
237 
239  template < typename CONSTRAINT >
240  INLINE void __StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(
241  const ArcReversal& change) {
242  first_constraint::modifyGraphAlone(change);
243  }
244 
246  template < typename CONSTRAINT >
247  INLINE void __StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(
248  const GraphChange& change) {
249  first_constraint::modifyGraphAlone(change);
250  }
251 
253  template < typename CONSTRAINT >
254  INLINE bool __StructuralConstraintSetStatic< CONSTRAINT >::isAlwaysInvalid(
255  const GraphChange& change) const {
256  return first_constraint::isAlwaysInvalidAlone(change);
257  }
258 
260  template < typename CONSTRAINT >
261  INLINE bool __StructuralConstraintSetStatic< CONSTRAINT >::checkArcAddition(
262  NodeId x, NodeId y) const {
263  return first_constraint::checkArcAdditionAlone(x, y);
264  }
265 
267  template < typename CONSTRAINT >
268  INLINE bool __StructuralConstraintSetStatic< CONSTRAINT >::checkArcDeletion(
269  NodeId x, NodeId y) const {
270  return first_constraint::checkArcDeletionAlone(x, y);
271  }
272 
274  template < typename CONSTRAINT >
275  INLINE bool __StructuralConstraintSetStatic< CONSTRAINT >::checkArcReversal(
276  NodeId x, NodeId y) const {
277  return first_constraint::checkArcReversalAlone(x, y);
278  }
279 
281  template < typename CONSTRAINT >
282  INLINE bool __StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
283  const ArcAddition& change) const {
284  return first_constraint::checkModificationAlone(change);
285  }
286 
288  template < typename CONSTRAINT >
289  INLINE bool __StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
290  const ArcDeletion& change) const {
291  return first_constraint::checkModificationAlone(change);
292  }
293 
295  template < typename CONSTRAINT >
296  INLINE bool __StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
297  const ArcReversal& change) const {
298  return first_constraint::checkModificationAlone(change);
299  }
300 
302  template < typename CONSTRAINT >
303  INLINE bool __StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
304  const GraphChange& change) const {
305  return first_constraint::checkModificationAlone(change);
306  }
307 
308  // ===========================================================================
309 
311  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
312  INLINE StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
313  StructuralConstraintSetStatic() {
314  GUM_CONSTRUCTOR(StructuralConstraintSetStatic);
315  }
316 
318  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
319  INLINE StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
320  StructuralConstraintSetStatic(
321  const StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >&
322  from) :
323  constraints(from) {
324  GUM_CONS_CPY(StructuralConstraintSetStatic);
325  }
326 
328  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
329  INLINE StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
330  ~StructuralConstraintSetStatic() {
331  GUM_DESTRUCTOR(StructuralConstraintSetStatic);
332  }
333 
335  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
336  INLINE StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >&
337  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
338  operator=(
339  const StructuralConstraintSetStatic< CONSTRAINT1,
340  OTHER_CONSTRAINTS... >& from) {
341  if (this != &from) { constraints::operator=(from); }
342 
343  return *this;
344  }
345 
347  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
348  INLINE void
349  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
350  setGraph(const DiGraph& graph) {
351  constraints::setGraph(graph);
352  }
353 
355  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
356  INLINE bool
357  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
358  checkArcAddition(NodeId x, NodeId y) const {
359  return constraints::checkArcAddition(x, y);
360  }
361 
363  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
364  INLINE bool
365  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
366  checkArcDeletion(NodeId x, NodeId y) const {
367  return constraints::checkArcDeletion(x, y);
368  }
369 
371  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
372  INLINE bool
373  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
374  checkArcReversal(NodeId x, NodeId y) const {
375  return constraints::checkArcReversal(x, y);
376  }
377 
379  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
380  INLINE bool
381  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
382  checkModification(const ArcAddition& change) const {
383  return constraints::checkModification(change);
384  }
385 
387  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
388  INLINE bool
389  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
390  checkModification(const ArcDeletion& change) const {
391  return constraints::checkModification(change);
392  }
393 
395  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
396  INLINE bool
397  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
398  checkModification(const ArcReversal& change) const {
399  return constraints::checkModification(change);
400  }
401 
403  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
404  INLINE bool
405  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
406  checkModification(const GraphChange& change) const {
407  return constraints::checkModification(change);
408  }
409 
411  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
412  INLINE void
413  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
414  modifyGraph(const ArcAddition& change) {
415  if (checkModification(change)) {
416  constraints::modifyGraph(change);
417  } else {
418  GUM_ERROR(OperationNotAllowed,
419  "the constraint set does not allow this arc addition between "
420  << change.node1() << " and " << change.node2());
421  }
422  }
423 
425  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
426  INLINE void
427  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
428  modifyGraph(const ArcDeletion& change) {
429  if (checkModification(change)) {
430  constraints::modifyGraph(change);
431  } else {
432  GUM_ERROR(OperationNotAllowed,
433  "the constraint set does not allow this arc deletion between "
434  << change.node1() << " and " << change.node2());
435  }
436  }
437 
439  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
440  INLINE void
441  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
442  modifyGraph(const ArcReversal& change) {
443  if (checkModification(change)) {
444  constraints::modifyGraph(change);
445  } else {
446  GUM_ERROR(OperationNotAllowed,
447  "the constraint set does not allow this arc reversal between "
448  << change.node1() << " and " << change.node2());
449  }
450  }
451 
453  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
454  INLINE void
455  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
456  modifyGraph(const GraphChange& change) {
457  switch (change.type()) {
459  modifyGraph(reinterpret_cast< const ArcAddition& >(change));
460  break;
461 
463  modifyGraph(reinterpret_cast< const ArcDeletion& >(change));
464  break;
465 
467  modifyGraph(reinterpret_cast< const ArcReversal& >(change));
468  break;
469 
470  default:
471  GUM_ERROR(OperationNotAllowed,
472  "edge modifications are not "
473  "currently supported by constraint sets");
474  }
475  }
476 
478  template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
479  INLINE bool
480  StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
481  isAlwaysInvalid(const GraphChange& change) const {
482  return constraints::isAlwaysInvalid(change);
483  }
484 
485  // ===========================================================================
486 
488  template < typename CONSTRAINT >
489  INLINE StructuralConstraintSetStatic<
490  CONSTRAINT >::StructuralConstraintSetStatic() {
491  GUM_CONSTRUCTOR(StructuralConstraintSetStatic);
492  }
493 
495  template < typename CONSTRAINT >
496  INLINE
497  StructuralConstraintSetStatic< CONSTRAINT >::StructuralConstraintSetStatic(
498  const StructuralConstraintSetStatic< CONSTRAINT >& from) :
499  constraints(from) {
500  GUM_CONS_CPY(StructuralConstraintSetStatic);
501  }
502 
504  template < typename CONSTRAINT >
505  INLINE StructuralConstraintSetStatic<
506  CONSTRAINT >::~StructuralConstraintSetStatic() {
507  GUM_DESTRUCTOR(StructuralConstraintSetStatic);
508  }
509 
511  template < typename CONSTRAINT >
512  INLINE StructuralConstraintSetStatic< CONSTRAINT >&
513  StructuralConstraintSetStatic< CONSTRAINT >::
514  operator=(const StructuralConstraintSetStatic< CONSTRAINT >& from) {
515  if (this != &from) { constraints::operator=(from); }
516 
517  return *this;
518  }
519 
521  template < typename CONSTRAINT >
522  INLINE void StructuralConstraintSetStatic< CONSTRAINT >::setGraph(
523  const DiGraph& graph) {
524  constraints::setGraph(graph);
525  }
526 
528  template < typename CONSTRAINT >
529  INLINE bool StructuralConstraintSetStatic< CONSTRAINT >::checkArcAddition(
530  NodeId x, NodeId y) const {
531  return constraints::checkArcAddition(x, y);
532  }
533 
535  template < typename CONSTRAINT >
536  INLINE bool StructuralConstraintSetStatic< CONSTRAINT >::checkArcDeletion(
537  NodeId x, NodeId y) const {
538  return constraints::checkArcDeletion(x, y);
539  }
540 
542  template < typename CONSTRAINT >
543  INLINE bool StructuralConstraintSetStatic< CONSTRAINT >::checkArcReversal(
544  NodeId x, NodeId y) const {
545  return constraints::checkArcReversal(x, y);
546  }
547 
549  template < typename CONSTRAINT >
550  INLINE bool StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
551  const ArcAddition& change) const {
552  return constraints::checkModification(change);
553  }
554 
556  template < typename CONSTRAINT >
557  INLINE bool StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
558  const ArcDeletion& change) const {
559  return constraints::checkModification(change);
560  }
561 
563  template < typename CONSTRAINT >
564  INLINE bool StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
565  const ArcReversal& change) const {
566  return constraints::checkModification(change);
567  }
568 
570  template < typename CONSTRAINT >
571  INLINE bool StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
572  const GraphChange& change) const {
573  return constraints::checkModification(change);
574  }
575 
577  template < typename CONSTRAINT >
578  INLINE void StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(
579  const ArcAddition& change) {
580  if (checkModification(change)) {
581  constraints::modifyGraph(change);
582  } else {
583  GUM_ERROR(OperationNotAllowed,
584  "the constraint set does not allow this arc addition between "
585  << change.node1() << " and " << change.node2());
586  }
587  }
588 
590  template < typename CONSTRAINT >
591  INLINE void StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(
592  const ArcDeletion& change) {
593  if (checkModification(change)) {
594  constraints::modifyGraph(change);
595  } else {
596  GUM_ERROR(OperationNotAllowed,
597  "the constraint set does not allow this arc deletion between "
598  << change.node1() << " and " << change.node2());
599  }
600  }
601 
603  template < typename CONSTRAINT >
604  INLINE void StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(
605  const ArcReversal& change) {
606  if (checkModification(change)) {
607  constraints::modifyGraph(change);
608  } else {
609  GUM_ERROR(OperationNotAllowed,
610  "the constraint set does not allow this arc reversal between "
611  << change.node1() << " and " << change.node2());
612  }
613  }
614 
616  template < typename CONSTRAINT >
617  INLINE void StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(
618  const GraphChange& change) {
619  switch (change.type()) {
621  modifyGraph(reinterpret_cast< const ArcAddition& >(change));
622  break;
623 
625  modifyGraph(reinterpret_cast< const ArcDeletion& >(change));
626  break;
627 
629  modifyGraph(reinterpret_cast< const ArcReversal& >(change));
630  break;
631 
632  default:
633  GUM_ERROR(OperationNotAllowed,
634  "edge modifications are not "
635  "currently supported by constraint sets");
636  }
637  }
638 
640  template < typename CONSTRAINT >
641  INLINE bool StructuralConstraintSetStatic< CONSTRAINT >::isAlwaysInvalid(
642  const GraphChange& change) const {
643  return constraints::isAlwaysInvalid(change);
644  }
645 
646  } /* namespace learning */
647 
648 } /* namespace gum */
649 
650 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55