// $Id: ESMCI_FTable.h,v 1.16.2.1 2010/02/05 20:03:54 svasquez Exp $ // // Earth System Modeling Framework // Copyright 2002-2010, University Corporation for Atmospheric Research, // Massachusetts Institute of Technology, Geophysical Fluid Dynamics // Laboratory, University of Michigan, National Centers for Environmental // Prediction, Los Alamos National Laboratory, Argonne National Laboratory, // NASA Goddard Space Flight Center. // Licensed under the University of Illinois-NCSA License. // //------------------------------------------------------------------------- // (all lines below between the !BOP and !EOP markers will be included in // the automated document processing.) //----------------------------------------------------------------------------- // // these lines prevent this file from being read more than once if it // ends up being included multiple times #ifndef ESMCI_FTable_H #define ESMCI_FTable_H //----------------------------------------------------------------------------- //BOPI // !CLASS: ESMCI::FTable - function and data pointer table. // // !DESCRIPTION: // List of descriptive strings and function/data pointers which can // be get and set by name. Used to register and call functions by // string instead of making public symbols. // //EOPI //----------------------------------------------------------------------------- #include #include "ESMCI_VM.h" #include "ESMCI_Comp.h" namespace ESMCI { // constants and enums // These are the types of functions which can be entered in the function // table. The types are the arguments that will be stored in the table // and that the function will be called with. There are a few generic // types (called with an int, 2 ints, etc) and then some very specific // types used by the framework (e.g. a Gridded Component called with a list // of void's and a final int * for the return code.) // The typedefs are to ease the declarations of the function entry point // itself. enum dtype { DT_VOIDP=1, DT_FORTRAN_UDT_POINTER }; enum ftype { FT_NULL=1, FT_VOIDP1INTP, FT_VOIDP4INTP }; typedef void (*VoidFunc)(void); typedef void (*VoidP1IntPFunc)(void *, int *); typedef void (*VoidP4IntPFunc)(void *, void *, void *, void *, int *); // classes class FTable; // class definition class funcinfo { private: static const int numargs = 16; protected: char *funcname; void *funcptr; void *funcarg[numargs]; int funcintarg; enum ftype ftype; public: funcinfo(){ funcname = NULL; funcptr = NULL; for (int i=0; inextElement; delete table; table = next; } table = NULL; } // other methods int print(void)const; int add(std::string labelArg, void *pointer); int add(std::string labelArg, std::string name, std::string sharedObj); int remove(std::string labelArg); int execute(std::string labelArg, void *object, int *userRc); }; } // namespace ESMCI #endif // ESMCI_FTable_H