| [de061d] | 1 | /*
 | 
|---|
 | 2 |  *    vmg - a versatile multigrid solver
 | 
|---|
 | 3 |  *    Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
 | 
|---|
 | 4 |  *
 | 
|---|
 | 5 |  *  vmg is free software: you can redistribute it and/or modify
 | 
|---|
 | 6 |  *  it under the terms of the GNU General Public License as published by
 | 
|---|
 | 7 |  *  the Free Software Foundation, either version 3 of the License, or
 | 
|---|
 | 8 |  *  (at your option) any later version.
 | 
|---|
 | 9 |  *
 | 
|---|
 | 10 |  *  vmg is distributed in the hope that it will be useful,
 | 
|---|
 | 11 |  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 12 |  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
 | 13 |  *  GNU General Public License for more details.
 | 
|---|
 | 14 |  *
 | 
|---|
 | 15 |  *  You should have received a copy of the GNU General Public License
 | 
|---|
 | 16 |  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
|---|
 | 17 |  */
 | 
|---|
 | 18 | 
 | 
|---|
 | 19 | /**
 | 
|---|
 | 20 |  * @file   proxy.hpp
 | 
|---|
 | 21 |  * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
 | 
|---|
 | 22 |  * @date   Mon Apr 18 12:23:43 2011
 | 
|---|
 | 23 |  *
 | 
|---|
 | 24 |  * @brief  Header file for the classes VMG::CommandProxyBase and
 | 
|---|
 | 25 |  *         VMG::CommandProxy, used register commands at the factory.
 | 
|---|
 | 26 |  *
 | 
|---|
 | 27 |  */
 | 
|---|
 | 28 | 
 | 
|---|
 | 29 | #ifndef COMMAND_PROXY_HPP_
 | 
|---|
 | 30 | #define COMMAND_PROXY_HPP_
 | 
|---|
 | 31 | 
 | 
|---|
 | 32 | namespace VMG
 | 
|---|
 | 33 | {
 | 
|---|
 | 34 | 
 | 
|---|
 | 35 | class Command;
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | class CommandProxyBase
 | 
|---|
 | 38 | {
 | 
|---|
 | 39 | public:
 | 
|---|
 | 40 |   CommandProxyBase();
 | 
|---|
 | 41 |   virtual ~CommandProxyBase() {}
 | 
|---|
 | 42 |   virtual Command* CreateCommand() const = 0;
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 |   virtual const char* Name() const = 0;
 | 
|---|
 | 45 |   virtual int Arguments() const = 0;
 | 
|---|
 | 46 | };
 | 
|---|
 | 47 | 
 | 
|---|
 | 48 | template <class T>
 | 
|---|
 | 49 | class CommandProxy : public CommandProxyBase
 | 
|---|
 | 50 | {
 | 
|---|
 | 51 | public:
 | 
|---|
 | 52 |   Command* CreateCommand() const
 | 
|---|
 | 53 |   {
 | 
|---|
 | 54 |     return new T;
 | 
|---|
 | 55 |   }
 | 
|---|
 | 56 | 
 | 
|---|
 | 57 |   const char* Name() const
 | 
|---|
 | 58 |   {
 | 
|---|
 | 59 |     return T::Name();
 | 
|---|
 | 60 |   }
 | 
|---|
 | 61 | 
 | 
|---|
 | 62 |   int Arguments() const
 | 
|---|
 | 63 |   {
 | 
|---|
 | 64 |     return T::Arguments();
 | 
|---|
 | 65 |   }
 | 
|---|
 | 66 | };
 | 
|---|
 | 67 | 
 | 
|---|
 | 68 | }
 | 
|---|
 | 69 | 
 | 
|---|
 | 70 | #endif /* COMMAND_PROXY_HPP_ */
 | 
|---|