Parser.h

Go to the documentation of this file.
00001 /* $Id: Parser.h,v 1.3 2002/09/17 16:36:20 cvs Exp $ */
00002 
00003 #ifndef __PARSER_H
00004 #define __PARSER_H
00005 
00006 #include <stdio.h>
00007 #include <esg/SceneGraphObject.h>
00008 #include <esg/spacesorting/SDS.h>
00009 #include <esg/LightSource.h>
00010 
00011 namespace esg {
00012 
00013 class Parser {
00014 public:
00015     struct Statistics {
00016         int vertices;
00017         int primitives;
00018         int vertNormals;
00019         Statistics() : vertices(0), primitives(0), vertNormals(0) {}
00020         void init() { vertices=0; primitives=0; vertNormals=0; }
00021     };
00022 
00023 protected:
00024     const SDS             * _pSSProto;       // SS used for primitive storage
00025     SceneGraphObject::OID   _oid;            // start of OID range 
00026     SceneGraphObject      * _pParsedObject;  // result of current parsing
00027     Statistics            * _pStat;          // statistics
00028     List<LightSource>       _lights;         // lights
00029 
00030 public:
00031     Parser(const char            * /* path */,
00032            const SDS             & proto,
00033            SceneGraphObject::OID   firstOID = 1,
00034            Statistics            * pStat = NULL)
00035         : _oid(firstOID)
00036     {
00037         _pSSProto = (SDS*) proto.clone();
00038         _pParsedObject = NULL;
00039         _pStat = pStat;
00040         if (_pStat) _pStat->init();
00041     }
00042 
00043     virtual ~Parser() {
00044         LightSource * l;
00045         do { l=_lights.remove(_lights.firstItem()); delete l; } while (l);
00046         delete _pSSProto;
00047     }
00048     
00049     virtual bool              parseObject (void) = 0;
00050     virtual SceneGraphObject* getObject   (void) { return _pParsedObject; }
00051     
00052     virtual LightSource* getLight(void) {
00053         return _lights.remove(_lights.firstItem());
00054     }
00055     
00056 
00057     void                  setOID (SceneGraphObject::OID o) { _oid = o; }
00058     SceneGraphObject::OID getOID (void) const              { return _oid; }
00059 
00060     Statistics* getStatistics (void) { return _pStat; }
00061 
00062 };
00063 
00064 }; // namespace
00065 
00066 #endif // __PARSER_H

Generated on Wed Jun 28 12:24:28 2006 for esg by  doxygen 1.4.6