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
#include <
RDGeneral/export.h
>
34
#ifndef RDKIT_REGISTER_DESCRIPTOR_H
35
#define RDKIT_REGISTER_DESCRIPTOR_H
36
37
#include <
RDGeneral/BoostStartInclude.h
>
38
#include <boost/shared_ptr.hpp>
39
#include <
RDGeneral/BoostEndInclude.h
>
40
#include "
Property.h
"
41
42
namespace
RDKit
{
43
class
ROMol;
44
namespace
Descriptors {
45
46
// these macros create a static class that can call the specified function.
47
// using double class::operator(const ROMol&)
48
// this class also contains a function pointer with the signature
49
// double(*)(const ROMol&)
50
// these classes are automatically registered with the property registry
51
/*
52
#define REGISTER_FULL_DESCRIPTOR( NAME, VERSION, FUNC ) \
53
double NAME##PropertyFunction(const ROMol&m){return static_cast<double>(FUNC(mol));}\
54
struct NAME##PropertyFunctor : public PropertyFunctor{ \
55
NAME##PropertyFunctor(bool registerProp=true) : PropertyFunctor(#NAME, VERSION) { \
56
if (registerProp) Properties::registerProperty(new NAME##PropertyFunctor(false)); \
57
d_dataFunc = &NAME##PropertyFunction; \
58
} \
59
double operator()(const RDKit::ROMol &mol) const { \
60
return NAME##PropertyFunction(mol); } \
61
}; \
62
static NAME##PropertyFunctor NAME##PropertyFunctor__;
63
*/
64
65
66
67
#define REGISTER_DESCRIPTOR( NAME, FUNC ) \
68
struct NAME##PropertyFunctor : public PropertyFunctor{ \
69
static double _func(const ROMol&m){return static_cast<double>(FUNC(m));} \
70
NAME##PropertyFunctor(bool registerProp=true) : \
71
PropertyFunctor(#NAME, NAME##Version, _func) { \
72
if (registerProp) Properties::registerProperty(new NAME##PropertyFunctor(false)); \
73
} \
74
double operator()(const RDKit::ROMol &mol) const { \
75
return _func(mol); } \
76
}; \
77
static NAME##PropertyFunctor NAME##PropertyFunctor__;
78
}
79
}
80
81
#endif
BoostStartInclude.h
export.h
Property.h
BoostEndInclude.h
RDKit
Std stuff.
Definition:
Atom.h:30
GraphMol
Descriptors
RegisterDescriptor.h
Generated on Wed May 1 2019 11:56:24 for RDKit by
1.8.13