RDKit
Open-source cheminformatics and machine learning.
RegisterDescriptor.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016, Novartis Institutes for BioMedical Research Inc.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following
13 // disclaimer in the documentation and/or other materials provided
14 // with the distribution.
15 // * Neither the name of Novartis Institutes for BioMedical Research Inc.
16 // nor the names of its contributors may be used to endorse or promote
17 // products derived from this software without specific prior written
18 // permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 //
32 
33 #ifndef RDKIT_REGISTER_DESCRIPTOR_H
34 #define RDKIT_REGISTER_DESCRIPTOR_H
35 
37 #include <boost/shared_ptr.hpp>
39 #include "Property.h"
40 
41 namespace RDKit {
42 class ROMol;
43 namespace Descriptors {
44 
45 // these macros create a static class that can call the specified function.
46 // using double class::operator(const ROMol&)
47 // this class also contains a function pointer with the signature
48 // double(*)(const ROMol&)
49 // these classes are automatically registered with the property registry
50  /*
51 #define REGISTER_FULL_DESCRIPTOR( NAME, VERSION, FUNC ) \
52  double NAME##PropertyFunction(const ROMol&m){return static_cast<double>(FUNC(mol));}\
53  struct NAME##PropertyFunctor : public PropertyFunctor{ \
54  NAME##PropertyFunctor(bool registerProp=true) : PropertyFunctor(#NAME, VERSION) { \
55  if (registerProp) Properties::registerProperty(new NAME##PropertyFunctor(false)); \
56  d_dataFunc = &NAME##PropertyFunction; \
57  } \
58  double operator()(const RDKit::ROMol &mol) const { \
59  return NAME##PropertyFunction(mol); } \
60  }; \
61  static NAME##PropertyFunctor NAME##PropertyFunctor__;
62  */
63 
64 
65 
66 #define REGISTER_DESCRIPTOR( NAME, FUNC ) \
67  struct NAME##PropertyFunctor : public PropertyFunctor{ \
68  static double _func(const ROMol&m){return static_cast<double>(FUNC(m));} \
69  NAME##PropertyFunctor(bool registerProp=true) : \
70  PropertyFunctor(#NAME, NAME##Version, _func) { \
71  if (registerProp) Properties::registerProperty(new NAME##PropertyFunctor(false)); \
72  } \
73  double operator()(const RDKit::ROMol &mol) const { \
74  return _func(mol); } \
75  }; \
76  static NAME##PropertyFunctor NAME##PropertyFunctor__;
77 }
78 }
79 
80 #endif
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:29