RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
NullQueryAlgebra.h
Go to the documentation of this file.
1//
2//
3// Copyright (C) 2019 Greg Landrum and T5 Informatics GmbH
4//
5// @@ All Rights Reserved @@
6// This file is part of the RDKit.
7// The contents are covered by the terms of the BSD license
8// which is included in the file license.txt, found at the root
9// of the RDKit source tree.
10//
11#ifndef RD_NULLQUERYALGEBRA_H
12#define RD_NULLQUERYALGEBRA_H
13
14#include <GraphMol/QueryOps.h>
15
16namespace RDKit {
17namespace {
18template <class T>
21 bool negatedQ = returnQuery->getNegation();
22 bool negatedOtherQ = otherNullQ->getNegation();
23
25 // This is the only case in which we need to do anything
26 if (!negatedQ && negatedOtherQ) {
27 returnQuery->setNegation(true);
28 }
29 } else if (how == Queries::COMPOSITE_OR) {
30 // This is the only case in which we need to do anything
31 if (negatedQ && !negatedOtherQ) {
32 returnQuery->setNegation(false);
33 }
34 } else if (how == Queries::COMPOSITE_XOR) {
35 if (!negatedQ && !negatedOtherQ) {
36 returnQuery->setNegation(true);
37 } else if (negatedQ + negatedOtherQ == 1) {
38 returnQuery->setNegation(false);
39 }
40 }
41}
42
43template <class T>
46 bool negatedQ = returnQuery->getNegation();
47
49 if (!negatedQ) {
50 std::swap(returnQuery, otherQ);
51 }
52 } else if (how == Queries::COMPOSITE_OR) {
53 if (negatedQ) {
54 std::swap(returnQuery, otherQ);
55 }
56 } else if (how == Queries::COMPOSITE_XOR) {
57 std::swap(returnQuery, otherQ);
58 if (!negatedQ) {
59 returnQuery->setNegation(!returnQuery->getNegation());
60 }
61 }
62}
63
64} // namespace
65
66template <class T>
84} // namespace RDKit
85
86#endif
#define PRECONDITION(expr, mess)
Definition Invariant.h:109
@ COMPOSITE_XOR
@ COMPOSITE_AND
Std stuff.
bool rdvalue_is(const RDValue_cast_t)
void mergeNullQueries(T *&returnQuery, bool isQueryNull, T *&otherQuery, bool isOtherQNull, Queries::CompositeQueryType how)