OMNeT++ Simulation Library  5.6.1
cstringparimpl.h
1 //==========================================================================
2 // CSTRINGPARIMPL.H - part of
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //==========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 1992-2017 Andras Varga
10  Copyright (C) 2006-2017 OpenSim Ltd.
11 
12  This file is distributed WITHOUT ANY WARRANTY. See the file
13  `license' for details on this and other legal matters.
14 *--------------------------------------------------------------*/
15 
16 #ifndef __OMNETPP_CSTRINGPARIMPL_H
17 #define __OMNETPP_CSTRINGPARIMPL_H
18 
19 #include "cparimpl.h"
20 
21 namespace omnetpp {
22 
29 class SIM_API cStringParImpl : public cParImpl
30 {
31  protected:
32  // only one of expr and val is active at a time; however, we cannot use
33  // union here because std::string has constructor/destructor.
34  // selector: flags & FL_ISEXPR
35  cExpression *expr;
36  std::string val;
37 
38  private:
39  void copy(const cStringParImpl& other);
40 
41  protected:
42  void deleteOld();
43 
44  public:
47 
51  explicit cStringParImpl();
52 
56  cStringParImpl(const cStringParImpl& other) : cParImpl(other) {copy(other);}
57 
61  virtual ~cStringParImpl();
62 
66  void operator=(const cStringParImpl& otherpar);
68 
71 
75  virtual cStringParImpl *dup() const override {return new cStringParImpl(*this);}
76 
80  virtual void parsimPack(cCommBuffer *buffer) const override;
81 
85  virtual void parsimUnpack(cCommBuffer *buffer) override;
87 
90 
94  virtual void setBoolValue(bool b) override;
95 
99  virtual void setIntValue(intpar_t l) override;
100 
104  virtual void setDoubleValue(double d) override;
105 
109  virtual void setStringValue(const char *s) override;
110 
114  virtual void setXMLValue(cXMLElement *node) override;
115 
120  virtual void setExpression(cExpression *e) override;
122 
125 
129  virtual bool boolValue(cComponent *context) const override;
130 
134  virtual intpar_t intValue(cComponent *context) const override;
135 
139  virtual double doubleValue(cComponent *context) const override;
140 
144  virtual const char *stringValue(cComponent *context) const override;
145 
149  virtual std::string stdstringValue(cComponent *context) const override;
150 
154  virtual cXMLElement *xmlValue(cComponent *context) const override;
155 
159  virtual cExpression *getExpression() const override;
161 
164 
168  virtual Type getType() const override;
169 
173  virtual bool isNumeric() const override;
175 
178 
183  virtual void convertToConst(cComponent *context) override;
184 
188  virtual std::string str() const override;
189 
193  virtual void parse(const char *text) override;
194 
198  virtual int compare(const cParImpl *other) const override;
200 };
201 
202 } // namespace omnetpp
203 
204 
205 #endif
206 
207 
cStringParImpl(const cStringParImpl &other)
Definition: cstringparimpl.h:56
Common base for module and channel classes.
Definition: ccomponent.h:48
Represents an XML element in an XML configuration file.
Definition: cxmlelement.h:73
int64_t intpar_t
Type for NED parameter values that store integers. It is guaranteed to be signed and at least as wide...
Definition: simkerneldefs.h:86
Buffer for the communications layer of parallel simulation.
Definition: ccommbuffer.h:41
A cParImpl subclass that stores a module/channel parameter of the type string.
Definition: cstringparimpl.h:29
Definition: cabstracthistogram.h:21
virtual cStringParImpl * dup() const override
Definition: cstringparimpl.h:75
Abstract base class for expression evaluators.
Definition: cexpression.h:33
Internal class that stores values for cPar objects.
Definition: cparimpl.h:44