pearlymlnode.h

Go to the documentation of this file.
00001 /*******************************************************************\
00002 
00003                    SESAME project software license
00004 
00005           Copyright (C) 2002, 2003 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 PEARLYMLNODE_H
00029 #define PEARLYMLNODE_H
00030 
00043 #include <ymlnode.h>
00044 #include <map>
00045 #include <list>
00046 #include <vector>
00047 
00048 #ifndef LTSTR
00049 #define LTSTR
00050 #include <string.h>
00051 struct ltstr {
00052   bool operator()(const char* s1, const char* s2) const {
00053     return strcmp(s1, s2) < 0;
00054   }
00055 };
00056 #endif
00057 
00058 class PearlYMLNode : public YMLNode {
00059   typedef enum {INT_T, ARRAY_T, PORT_T} parm_type;
00060 
00061   struct _parm_t;
00062   typedef std::list<_parm_t> parmList_t;
00063 
00064   struct _parm_t {
00065     parm_type type;
00066 
00067     union {
00068       int integer;
00069       parmList_t *array;
00070       int peerID;
00071     } data;
00072   };
00073 
00074   typedef struct _parm_t parm_t;
00075 
00076   const char *input;
00077   parmList_t *initParms;
00078   parmList_t *subArray;
00079   int dataCount;
00080 
00081   int jobnr;
00082 
00083  public:
00084   PearlYMLNode();
00085   virtual ~PearlYMLNode();
00086 
00087   int getJobNum() {return jobnr;}
00088 
00089   void finalize();
00090 
00091   void initProcess();
00092 
00093   void getPeersByType(char *type_name, std::vector<int> &peers);
00094 
00095  protected:
00096   void parseInit();
00097   void parseParmList();
00098   void parseInteger();
00099   void parseArray(bool addSize);
00100   void parseTypeMatch(bool addSize);
00101   void parseRegex();
00102   void getRegexMatches(const char *regex);
00103   void addParm(parm_t &parm);
00104   void addIntParm(int i);
00105   void addPortParm(int peerID);
00106   void addArrayParm(parmList_t *array);
00107 };
00108 #endif

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