SceneLoader.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  SceneLoader
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @author Matthew Jacobs (jacobs.mh@gmail.com)
00005    @date   Fall 2008
00006 
00007    @brief
00008       Abstract scene loader
00009    <!-------------------------------------------------------------------->**/
00010 
00011 #ifndef SCENE_LOADER_H_
00012 #define SCENE_LOADER_H_
00013 
00014 #include <renderers/Renderer.h>
00015 #include <utils/PropertyMap.h>
00016 #include <utils/Log.h>
00017 
00018 class RenderOutput;
00019 class Renderer;
00020 class Camera;
00021 class ShapeSet;
00022 
00023 /**
00024  * @brief
00025  *    Wrapper for data which may be loaded externally
00026  */
00027 struct ParseData : public Log {
00028    // main outputs
00029    Renderer     *renderer;
00030    Camera       *camera;
00031    
00032    RenderOutput *output;
00033    PropertyMap   outputProperties;
00034    
00035    // version of the milton scene format being parsed
00036    real_t        version;
00037    
00038    // source filename or description of source being parsed
00039    std::string   source;
00040    
00041    // error message if parsing goes awry
00042    std::string   error;
00043    
00044    // (default log is standard output when debug logging is enabled)
00045    inline ParseData(bool debug = false)
00046       : Log(debug), 
00047         renderer(NULL), camera(NULL), output(NULL), 
00048         version(0), source(""), error("")
00049    { }
00050    
00051    inline ParseData &operator=(ParseData &data) {
00052       *(static_cast<Log*>(this)) = data;
00053       
00054       renderer = data.renderer;
00055       camera   = data.camera;
00056       output   = data.output;
00057       
00058       outputProperties.inherit(data.outputProperties);
00059       
00060       error    = data.error;
00061       
00062       return *this;
00063    }
00064    
00065    void reset() {
00066       renderer = NULL;
00067       output   = NULL;
00068       camera   = NULL;
00069       outputProperties.clear();
00070       
00071       error    = "";
00072       init();
00073    }
00074 };
00075 
00076 class SceneLoader : public PropertyMap {
00077    public:
00078       ///@name Constructors
00079       //@{-----------------------------------------------------------------
00080       
00081       SceneLoader()
00082          : PropertyMap()
00083       { }
00084       
00085       virtual ~SceneLoader()
00086       { }
00087       
00088       //@}-----------------------------------------------------------------
00089       ///@name Main usage interface
00090       //@{-----------------------------------------------------------------
00091       
00092       /**
00093        * @brief
00094        *    Attempts to parse the given file, storing the results in outData
00095        * 
00096        * @returns whether or not parsing was successful
00097        */
00098       virtual bool parse(const std::string &fileName, ParseData &outData) = 0;
00099       
00100       //@}-----------------------------------------------------------------
00101 };
00102 
00103 #endif // SCENE_LOADER_H_
00104 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6