RDKit: RegisterDescriptor.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
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#ifndef RDKIT_REGISTER_DESCRIPTOR_H
33#define RDKIT_REGISTER_DESCRIPTOR_H
34
35#include "Property.h"
36
37namespace RDKit {
38class ROMol;
39namespace Descriptors {
40
41// these macros create a static class that can call the specified function.
42// using double class::operator(const ROMol&)
43// this class also contains a function pointer with the signature
44// double(*)(const ROMol&)
45// these classes are automatically registered with the property registry
46/*
47#define REGISTER_FULL_DESCRIPTOR( NAME, VERSION, FUNC ) \
48double NAME##PropertyFunction(const ROMol&m){return
49static_cast<double>(FUNC(mol));}\
50struct NAME##PropertyFunctor : public PropertyFunctor{ \
51 NAME##PropertyFunctor(bool registerProp=true) : PropertyFunctor(#NAME,
52VERSION) { \
53 if (registerProp) Properties::registerProperty(new
54NAME##PropertyFunctor(false)); \
55 d_dataFunc = &NAME##PropertyFunction; \
56 } \
57 double operator()(const RDKit::ROMol &mol) const { \
58 return NAME##PropertyFunction(mol); } \
59}; \
60static NAME##PropertyFunctor NAME##PropertyFunctor__;
61*/
62
63#define REGISTER_DESCRIPTOR(NAME, FUNC) \
64 Properties::registerProperty(new PropertyFunctor( \
65 #NAME, NAME##Version, \
66 [](const ROMol &m) { return static_cast<double>(FUNC(m)); }));
67
68} // namespace Descriptors
69} // namespace RDKit
70
71#endif
Property.h
RDKit::ROMol
Definition ROMol.h:199
RDKit::Descriptors
Definition AtomFeat.h:30
RDKit
Std stuff.
Definition Abbreviations.h:19