/* libzzinet
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2004-2006, Toni Thomsson <toni@tonjac.org> 
*/

/**
    Base for all renders

    Toni Thomsson, toni@tonjac.org
*/

#ifndef zz_output_render_h
#define zz_output_render_h

#include <zz_string.h>
#include "zz_data_service.h"
#include <vector>
#include <map>
#include <zz_parameter_map.h>
#include <zz_log.h>

class ZZ_API CzzOutputRender
{

public:

    virtual ~CzzOutputRender();
    virtual CzzString& render( void );
        
protected:

    //* Construction
    CzzOutputRender( const CzzString& templ, void* session, CzzParameterMap* cgi, bool destroy_svcs = true );

    void addFieldSvc( CzzDataService* svc );
    void addListSvc( const CzzString& tablemarker, CzzDataService* svc );
    
    void addBeforeRender( CzzOutputRender* render );
    void addAfterRender( CzzOutputRender* render );
    
    CzzLog m_Log;
    CzzParameterMap* m_CGI;
    
    vector<CzzDataService*> m_FieldSvcs;
    map<CzzString,CzzDataService*> m_ListSvcs;

private:
    bool m_DestroySvcs;
    CzzString m_Template;
    void* m_Session;
    CzzString m_Name;
    CzzString m_TableMarker;
    
    vector<CzzOutputRender*> m_RenderBefore;
    vector<CzzOutputRender*> m_RenderAfter;
};

#endif // zz_output_render_h