processloader.h

Go to the documentation of this file.
00001 /*******************************************************************\
00002 
00003                    SESAME project software license
00004 
00005               Copyright (C) 2002 University of Amsterdam
00006 
00007     This program is free software; you can redistribute it and/or
00008      modify it under the terms of the GNU General Public License
00009     as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015              GNU General Public License for more details.
00016 
00017   You should have received a copy of the GNU General Public License
00018      along with this program; if not, write to the Free Software
00019       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00020                            02111-1307, USA.
00021 
00022       For information regarding the SESAME software project see
00023               http://sesamesim.sourceforge.net or email
00024                     jcofflan@users.sourceforge.net
00025 
00026 \*******************************************************************/
00027 
00028 #ifndef PROCESSLOADER_H
00029 #define PROCESSLOADER_H
00030 
00031 #include <BasicUtils/BasicThread.h>
00032 #include <libmanager.h>
00033 #include <ymlnode.h>
00034 
00035 #include <string.h>
00036 #include <string>
00037 #include <iostream>
00038 #include <map>
00039 
00040 #ifndef LTSTR
00041 #define LTSTR
00042 #include <string.h>
00043 struct ltstr {
00044   bool operator()(const char* s1, const char* s2) const {
00045     return strcmp(s1, s2) < 0;
00046   }
00047 };
00048 #endif
00049 
00050 // Forward declarations
00051 class PNConnection;
00052 class DataBlockClass;
00053 
00055 
00062 class ProcessLoader : public BasicThread, public YMLNode {
00063   LibManager libManager;
00064 
00066   int pargc;
00067 
00069   char **pargs;
00070 
00071   typedef enum {S_STOPPED, S_RUNNING, S_READING, S_SENDING_READ,
00072                 S_WRITING, S_SENDING_WRITE, S_SENDING_EXECUTE} state_t;
00073   state_t state;
00074   int stateID;
00075 
00076  public:
00077   ProcessLoader();
00078   virtual ~ProcessLoader();
00079 
00080   DataBlockClass *read(int portId);
00081   void write(int portId, DataBlockClass *dataBlock);
00082   void execute(const char *operation);
00083   void execute(int operation);
00084 
00085   LibManager *getLibManager() {return &libManager;}
00086   void loadLibraries();
00087 
00088   void loadProcessArgs();
00089   int getProcessArgc() {return pargc;}
00090   char **getProcessArgs() {return pargs;}
00091 
00092   virtual void init();
00093 
00094   virtual bool load();
00095   virtual void exit();
00096 
00097   std::string getStateString();
00098 
00099   friend std::ostream &operator<<(std::ostream &stream, ProcessLoader &p);
00100 };
00101 
00102 std::ostream &operator<<(std::ostream &stream, ProcessLoader &p);
00103 
00104 #endif

Generated on Wed Apr 5 20:57:45 2006 for Sesame by  doxygen 1.4.6