LCOV - code coverage report
Current view: top level - vesselbase - VesselRegister.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 1 1 100.0 %
Date: 2018-12-19 07:49:13 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-2018 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_vesselbase_VesselRegister_h
      23             : #define __PLUMED_vesselbase_VesselRegister_h
      24             : 
      25             : #include <string>
      26             : #include <cstring>
      27             : #include <vector>
      28             : #include <map>
      29             : #include "tools/Exception.h"
      30             : #include "tools/Keywords.h"
      31             : 
      32             : namespace PLMD {
      33             : namespace vesselbase {
      34             : 
      35             : class Vessel;
      36             : class VesselOptions;
      37             : 
      38         841 : class VesselRegister {
      39             : private:
      40             : /// Pointer to a function which, given the keyword for a distribution function, creates it
      41             :   typedef Vessel*(*creator_pointer)(const VesselOptions&);
      42             : /// Pointer to the function that reserves the keyword for the distribution
      43             :   typedef void(*keyword_pointer)(Keywords&);
      44             : /// The set of possible distribution functions we can work with
      45             :   std::map<std::string,creator_pointer> m;
      46             : /// Map action to a function which documents the related object
      47             :   std::map<std::string,keyword_pointer> mk;
      48             : /// A vector of function pointers - this is used to create the documentation
      49             :   Keywords keywords;
      50             : public:
      51             : /// The destructor
      52             :   ~VesselRegister();
      53             : /// Add a new distribution function option to the register of distribution functions
      54             :   void add(std::string keyword,creator_pointer,keyword_pointer k,keyword_pointer ik);
      55             : /// Remove a distribution function from the register of distribution functions
      56             :   void remove(creator_pointer f);
      57             : /// Verify if a distribution keyword is present in the register
      58             :   bool check(std::string keyname);
      59             : /// Create a distribution function of the specified type
      60             :   Vessel* create(std::string keyword, const VesselOptions&da);
      61             : /// Return the keywords
      62             :   Keywords getKeywords();
      63             : };
      64             : 
      65             : VesselRegister& vesselRegister();
      66             : 
      67             : #define PLUMED_REGISTER_VESSEL(classname,keyword) \
      68             :   static class classname##RegisterMe{ \
      69             :     static PLMD::vesselbase::Vessel * create(const PLMD::vesselbase::VesselOptions&da){return new classname(da);} \
      70             :   public: \
      71             :     classname##RegisterMe(){PLMD::vesselbase::vesselRegister().add(keyword,create,classname::reserveKeyword,classname::registerKeywords);} \
      72             :     ~classname##RegisterMe(){PLMD::vesselbase::vesselRegister().remove(create);} \
      73             :   } classname##RegisterMeObject;
      74             : 
      75             : }
      76             : }
      77             : #endif

Generated by: LCOV version 1.13