Statistics
| Branch: | Revision:

root / include / cxmlparimpl.h @ 7f251033

History | View | Annotate | Download (4.55 KB)

1
//==========================================================================
2
//   CXMLPARIMPL.H  - part of
3
//                     OMNeT++/OMNEST
4
//            Discrete System Simulation in C++
5
//
6
//  Author: Andras Varga
7
//
8
//==========================================================================
9

    
10
/*--------------------------------------------------------------*
11
  Copyright (C) 1992-2008 Andras Varga
12
  Copyright (C) 2006-2008 OpenSim Ltd.
13

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

    
18
#ifndef __CXMLPARIMPL_H
19
#define __CXMLPARIMPL_H
20

    
21
#include "cparimpl.h"
22

    
23
NAMESPACE_BEGIN
24

    
25
/**
26
 * A cParImpl subclass that stores a module/channel parameter of type XML.
27
 *
28
 * @ingroup Internals
29
 */
30
class SIM_API cXMLParImpl : public cParImpl
31
{
32
  protected:
33
    // selector: flags & FL_ISEXPR
34
    cExpression *expr;
35
    cXMLElement *val;
36

    
37
  protected:
38
    cXMLElement *evaluate(cComponent *context) const;
39
    void deleteOld();
40

    
41
  public:
42
    /** @name Constructors, destructor, assignment. */
43
    //@{
44

    
45
    /**
46
     * Constructor.
47
     */
48
    explicit cXMLParImpl();
49

    
50
    /**
51
     * Copy constructor.
52
     */
53
    cXMLParImpl(const cXMLParImpl& other) {setName(other.getName()); operator=(other);}
54

    
55
    /**
56
     * Destructor.
57
     */
58
    virtual ~cXMLParImpl();
59

    
60
    /**
61
     * Assignment operator.
62
     */
63
    void operator=(const cXMLParImpl& otherpar);
64
    //@}
65

    
66
    /** @name Redefined cObject member functions */
67
    //@{
68

    
69
    /**
70
     * Creates and returns an exact copy of this object.
71
     */
72
    virtual cXMLParImpl *dup() const  {return new cXMLParImpl(*this);}
73

    
74
    /**
75
     * Returns a multi-line description of the contained XML element.
76
     */
77
    virtual std::string detailedInfo() const;
78

    
79
    /**
80
     * Serializes the object into a buffer.
81
     */
82
    virtual void parsimPack(cCommBuffer *buffer);
83

    
84
    /**
85
     * Deserializes the object from a buffer.
86
     */
87
    virtual void parsimUnpack(cCommBuffer *buffer);
88
    //@}
89

    
90
    /** @name Redefined cParImpl setter functions. */
91
    //@{
92

    
93
    /**
94
     * Raises an error: cannot convert bool to XML.
95
     */
96
    virtual void setBoolValue(bool b);
97

    
98
    /**
99
     * Raises an error: cannot convert long to XML.
100
     */
101
    virtual void setLongValue(long l);
102

    
103
    /**
104
     * Raises an error: cannot convert double to XML.
105
     */
106
    virtual void setDoubleValue(double d);
107

    
108
    /**
109
     * Raises an error: cannot convert string to XML.
110
     */
111
    virtual void setStringValue(const char *s);
112

    
113
    /**
114
     * Sets the value to the given cXMLElement tree.
115
     */
116
    virtual void setXMLValue(cXMLElement *node);
117

    
118
    /**
119
     * Sets the value to the given expression. This object will
120
     * assume the responsibility to delete the expression object.
121
     */
122
    virtual void setExpression(cExpression *e);
123
    //@}
124

    
125
    /** @name Redefined cParImpl getter functions. */
126
    //@{
127

    
128
    /**
129
     * Raises an error: cannot convert XML to bool.
130
     */
131
    virtual bool boolValue(cComponent *context) const;
132

    
133
    /**
134
     * Raises an error: cannot convert XML to long.
135
     */
136
    virtual long longValue(cComponent *context) const;
137

    
138
    /**
139
     * Raises an error: cannot convert XML to double.
140
     */
141
    virtual double doubleValue(cComponent *context) const;
142

    
143
    /**
144
     * Raises an error: cannot convert XML to string.
145
     */
146
    virtual const char *stringValue(cComponent *context) const;
147

    
148
    /**
149
     * Raises an error: cannot convert XML to string.
150
     */
151
    virtual std::string stdstringValue(cComponent *context) const;
152

    
153
    /**
154
     * Returns the value of the parameter.
155
     */
156
    virtual cXMLElement *xmlValue(cComponent *context) const;
157

    
158
    /**
159
     * Returns pointer to the expression stored by the object, or NULL.
160
     */
161
    virtual cExpression *getExpression() const;
162
    //@}
163

    
164
    /** @name Type, prompt text, input flag, change flag. */
165
    //@{
166

    
167
    /**
168
     * Returns XML.
169
     */
170
    virtual Type getType() const;
171

    
172
    /**
173
     * Returns false.
174
     */
175
    virtual bool isNumeric() const;
176
    //@}
177

    
178
    /** @name Redefined cParImpl misc functions. */
179
    //@{
180

    
181
    /**
182
     * Replaces for non-const values, replaces the stored expression with its
183
     * evaluation.
184
     */
185
    virtual void convertToConst(cComponent *context);
186

    
187
    /**
188
     * Returns the value in text form.
189
     */
190
    virtual std::string str() const;
191

    
192
    /**
193
     * Converts from text.
194
     */
195
    virtual void parse(const char *text);
196

    
197
    /**
198
     * Object comparison.
199
     */
200
    virtual int compare(const cParImpl *other) const;
201
    //@}
202
};
203

    
204
NAMESPACE_END
205

    
206

    
207
#endif
208

    
209