Project

General

Profile

Statistics
| Branch: | Revision:

root / src / envir / cxmldoccache.h @ master

History | View | Annotate | Download (1.83 KB)

1
//==========================================================================
2
//  XMLDOCCACHE.H - part of
3
//                     OMNeT++/OMNEST
4
//            Discrete System Simulation in C++
5
//
6
//  Declaration of the following classes:
7
//    cXMLDocCache : reads and caches XML config files
8
//
9
//  Author: Andras Varga
10
//
11
//==========================================================================
12

    
13
/*--------------------------------------------------------------*
14
  Copyright (C) 1992-2008 Andras Varga
15
  Copyright (C) 2006-2008 OpenSim Ltd.
16

17
  This file is distributed WITHOUT ANY WARRANTY. See the file
18
  `license' for details on this and other legal matters.
19
*--------------------------------------------------------------*/
20

    
21
#ifndef __XMLDOCCACHE_H
22
#define __XMLDOCCACHE_H
23

    
24
#include <map>
25
#include <string>
26
#include "simkerneldefs.h"
27
#include "envirdefs.h"
28
#include "cxmlelement.h"
29

    
30
NAMESPACE_BEGIN
31

    
32
/**
33
 * Reads and caches XML config files.
34
 */
35
class ENVIR_API cXMLDocCache : public cObject
36
{
37
  protected:
38
    typedef std::map<std::string,cXMLElement*> XMLDocMap;
39
    XMLDocMap cache;
40
    cXMLElement *parseDocument(const char *filename);
41

    
42
  public:
43
    /**
44
     * Constructor
45
     */
46
    cXMLDocCache();
47

    
48
    /**
49
     * Destructor
50
     */
51
    virtual ~cXMLDocCache();
52

    
53
    /**
54
     * Returns the given document. NOTE: The returned node is the equivalent
55
     * of the DOM "Document node", which is the <i>parent</i> of the
56
     * root element, not the root element itself.
57
     */
58
    virtual cXMLElement *getDocument(const char *filename);
59

    
60
    /**
61
     * Removes the given document from the cache, and deletes its cXMLElement
62
     * tree. Nothing happens if the file has not been loaded.
63
     */
64
    virtual void forgetDocument(const char *filename);
65

    
66
    /**
67
     * Empties the document cache.
68
     */
69
    virtual void flushCache();
70
};
71

    
72
NAMESPACE_END
73

    
74

    
75
#endif
76