NGSolve
4.9
|
00001 #ifndef FILE_NUMPROC 00002 #define FILE_NUMPROC 00003 00004 /*********************************************************************/ 00005 /* File: numproc.hh */ 00006 /* Author: Joachim Schoeberl */ 00007 /* Date: 10. Jul. 2000 */ 00008 /*********************************************************************/ 00009 00010 namespace ngsolve 00011 { 00012 00017 class PDE; 00018 00020 class NGS_DLL_HEADER NumProc : public NGS_Object 00021 { 00022 protected: 00024 PDE & pde; 00025 00026 int callposition; 00027 public: 00029 NumProc (PDE & apde, const int acallposition = 0); 00031 NumProc (PDE & apde, const Flags & flags, const int acallposition = 0); 00033 virtual ~NumProc(); 00035 virtual void Do(LocalHeap & lh) = 0; 00037 virtual void PrintReport (ostream & ost); 00039 static void PrintDoc (ostream & ost); 00040 00041 int GetCallPosition (void) const { return callposition;} 00042 }; 00043 00044 00045 00046 00048 class NGS_DLL_HEADER NumProcs 00049 { 00050 public: 00051 class NumProcInfo 00052 { 00053 public: 00054 string name; 00055 int dim; 00056 00057 NumProc* (*creator)(PDE & pde, const Flags & flags); 00058 void (*printdoc) (ostream & ost); 00059 00060 NumProcInfo (const string & aname, int adim, 00061 NumProc* (*acreator)(PDE & pde, const Flags & flags), 00062 void (*aprintdoc) (ostream & ost)); 00063 }; 00064 00065 Array<NumProcInfo*> npa; 00066 public: 00067 NumProcs(); 00068 ~NumProcs(); 00069 void AddNumProc (const string & aname, 00070 NumProc* (*acreator)(PDE & pde, const Flags & flags), 00071 void (*printdoc) (ostream & ost) = NumProc::PrintDoc); 00072 00073 00074 void AddNumProc (const string & aname, int dim, 00075 NumProc* (*acreator)(PDE & pde, const Flags & flags), 00076 void (*printdoc) (ostream & ost) = NumProc::PrintDoc); 00077 00078 const Array<NumProcInfo*> & GetNumProcs() { return npa; } 00079 const NumProcInfo * GetNumProc(const string & name, int dim); 00080 00081 void Print (ostream & ost) const; 00082 }; 00083 00084 00085 extern NGS_DLL_HEADER NumProcs & GetNumProcs (); 00086 00087 00088 template <typename NP> 00089 class RegisterNumProc 00090 { 00091 public: 00092 RegisterNumProc (string label, int dim = -1) 00093 { 00094 GetNumProcs().AddNumProc (label, dim, Create, NP::PrintDoc); 00095 // cout << "register numproc '" << label << "'" << endl; 00096 } 00097 00098 static NumProc * Create (PDE & pde, const Flags & flags) 00099 { 00100 return new NP (pde, flags); 00101 } 00102 }; 00103 00104 00105 } 00106 00107 #endif