Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2013-2019 The plumed team
3 : (see the PEOPLE file at the root of the distribution for a list of names)
4 :
5 : See http://www.plumed.org for more information.
6 :
7 : This file is part of plumed, version 2.
8 :
9 : plumed is free software: you can redistribute it and/or modify
10 : it under the terms of the GNU Lesser General Public License as published by
11 : the Free Software Foundation, either version 3 of the License, or
12 : (at your option) any later version.
13 :
14 : plumed is distributed in the hope that it will be useful,
15 : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : GNU Lesser General Public License for more details.
18 :
19 : You should have received a copy of the GNU Lesser General Public License
20 : along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 : #ifndef __PLUMED_analysis_LandmarkRegister_h
23 : #define __PLUMED_analysis_LandmarkRegister_h
24 :
25 : #include <string>
26 : #include <cstring>
27 : #include <vector>
28 : #include <map>
29 : #include "LandmarkSelectionBase.h"
30 :
31 : namespace PLMD {
32 :
33 : class PDB;
34 :
35 : namespace analysis {
36 :
37 1607 : class LandmarkRegister {
38 : private:
39 : /// Pointer to a function which, given the type for a ReferenceConfiguration, creates it
40 : typedef LandmarkSelectionBase*(*creator_pointer)(const LandmarkSelectionOptions&);
41 : /// The set of possible landmark selection algorithms we can work with
42 : std::map<std::string,creator_pointer> m;
43 : public:
44 : /// The destructor
45 : ~LandmarkRegister();
46 : /// Add a new landmark selection style to the register of landmark selectors
47 : void add( std::string type, creator_pointer );
48 : /// Remove a landmark selection style from the register of metrics
49 : void remove(creator_pointer f);
50 : /// Verify if a landmark selection style is present in the register
51 : bool check(std::string type);
52 : /// Create a landmark selection object
53 : LandmarkSelectionBase* create( const LandmarkSelectionOptions& lo );
54 : };
55 :
56 : LandmarkRegister& landmarkRegister();
57 :
58 : #define PLUMED_REGISTER_LANDMARKS(classname,type) \
59 : static class classname##RegisterMe{ \
60 : static LandmarkSelectionBase * create(const LandmarkSelectionOptions&lo){return new classname(lo);} \
61 : public: \
62 : classname##RegisterMe(){landmarkRegister().add(type,create);}; \
63 : ~classname##RegisterMe(){landmarkRegister().remove(create);}; \
64 : } classname##RegisterMeObject;
65 :
66 : }
67 : }
68 : #endif
|