/***************************************************************************
 *                          Zanoza Modeler v2.x                            *
 *      This is unpublished propietary source code of Zanoza Software.     *
 *      The copyright notice does not evidence any actual or intended      *
 *                    publication of such source code.                     *
 *                                                                         *
 *                Copyright (c) 2002-2008 Zanoza Software.                 *
 *                                                                         *
 *                        All rights reserved.                             *
 ***************************************************************************
 *--------------------------------------------------------------------------
 * @author:   Oleg Melashenko
 *--------------------------------------------------------------------------
 * @purpose:  Declaration of the class IProfilingService
 *   Services for storing profile records. This is an alternate
 *   to standard CWinApp:: profile routines. The services is
 *   aimed to store data in XML format in the same folder as
 *   ZModeler to allow multiple versions of Zmodeler be installed
 *   and run simultaniouesly.
 *--------------------------------------------------------------------------
 * @created: Sunday, February 23, 2003 19:38:13
 */

#if !defined(IProfilingService_h_included)
#define IProfilingService_h_included
//forward declaration of this class might require
namespace services
{ class IProfilingService; };
#include <zmodeler.h>
#include <core/coreTypes.h>
#include <services/zmServices.h>
#include <services/IService.h>
#include <services/IXMLWriteService.h>


namespace services
{
  
  class IProfilingService : public services::IService
  {
  public:
    virtual ZRESULT writeProfileString(ZStringSeq& seqFolder, ZString strKey, ZString strValue)=0;
    virtual ZRESULT readProfileString(ZStringSeq& seqFolder, ZString strKey, ZString& strValue)=0;
    virtual ZRESULT writeProfileLong(ZStringSeq& seqFolder, ZString strKey, long nValue, bool bHex=false)=0;
    virtual ZRESULT readProfileLong(ZStringSeq& seqFolder, ZString strKey, long& nValue)=0;
    /* Sets supplied folder as a root for a sequence of calls. Pass empty
     * sequence to reset current root */
    virtual ZRESULT setRootFolder(ZStringSeq& seqFolder)=0;
    /* Tells whether profile contains supplied folder */
    virtual ZRESULT isExistFolder(ZStringSeq& seqFolder)=0;
    /* Provides a number of subfolders in supplied folder */
    virtual ZRESULT getNumSubFolders(ZStringSeq& seqFolder, long& nChildren)=0;
    virtual ZRESULT getFolderName(ZStringSeq& seqFolder, long nIndex, ZString& strName)=0;
    /* Provides amount of key-values stored in supplied folder */
    virtual ZRESULT getNumKeys(ZStringSeq& seqFolder, long& nKeys)=0;
    /* Provides key name at specified position. pKeyType is optional ret-val argument
     * is filled with key-type value as follows:
     * 1: string key
     * 2: signed long
     * 3: unsigned long
     * 4: binary */
    virtual ZRESULT getKeyName(ZStringSeq& seqFolder, long nIndex, ZString& strName, long* pKeyType=NULL)=0;
    /* Clears content of the folder (but not the folder itself) */
    virtual ZRESULT clearFolder(ZStringSeq& seqFolder, bool bSubfolder=true)=0;
    /* Deletes folder from profile. */
    virtual ZRESULT deleteFolder(ZStringSeq& seqFolder)=0;
    virtual ZRESULT deleteKey(ZStringSeq& seqFolder, ZString& strName)=0;
    /* Renames folder or key. */
    virtual ZRESULT renameItem(ZStringSeq& seqFolder, ZString& strOldName, ZString strNewName)=0;
    /* Tries to change value of the "item". Item is either a folder or a key. Value is
     * passed as string and item consernes how to interpret it. */
    virtual ZRESULT setItemValue(ZStringSeq& seqFolder, ZString& strName, ZString strValue)=0;
    /* Flushes data onto disk. No data saved into profile untill this routine is called
     * explicitly. ZModeler calls this routine on exit only. it's your choice to force file
     * saving. If supplied with non-NULL XMLWriteService, the services writes into
     * supplied service from current root (setRootFolder). Otherwise, it writes from
     * global root to standard zmodeler profile.xml. */
    virtual ZRESULT flush(services::IXMLWriteService* pS)=0;
  
  };//class IProfilingService
};//services

#endif
