OMNeT++ Simulation Library  6.0.3
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 namespace internal {
23 
30 class SIM_API cStringParImpl : public cParImpl
31 {
32  protected:
33  // only one of expr and val is active at a time; however, we cannot use
34  // union here because std::string has constructor/destructor.
35  // selector: flags & FL_ISEXPR
36  cExpression *expr = nullptr;
37  std::string val;
38 
39  private:
40  void copy(const cStringParImpl& other);
41 
42  protected:
43  void deleteOld();
44 
45  public:
48 
52  explicit cStringParImpl() {}
53 
57  cStringParImpl(const cStringParImpl& other) : cParImpl(other) {copy(other);}
58 
62  virtual ~cStringParImpl();
63 
67  void operator=(const cStringParImpl& otherpar);
69 
72 
76  virtual cStringParImpl *dup() const override {return new cStringParImpl(*this);}
78 
81 
85  virtual void setBoolValue(bool b) override;
86 
90  virtual void setIntValue(intval_t l) override;
91 
95  virtual void setDoubleValue(double d) override;
96 
100  virtual void setStringValue(const char *s) override;
101 
105  virtual void setObjectValue(cObject *object) override;
106 
110  virtual void setXMLValue(cXMLElement *node) override;
111 
116  virtual void setExpression(cExpression *e) override;
118 
121 
125  virtual bool boolValue(cComponent *context) const override;
126 
130  virtual intval_t intValue(cComponent *context) const override;
131 
135  virtual double doubleValue(cComponent *context) const override;
136 
140  virtual const char *stringValue(cComponent *context) const override;
141 
145  virtual std::string stdstringValue(cComponent *context) const override;
146 
150  virtual cObject *objectValue(cComponent *context) const override;
151 
155  virtual cXMLElement *xmlValue(cComponent *context) const override;
156 
160  virtual cExpression *getExpression() const override;
162 
165 
169  virtual Type getType() const override;
170 
174  virtual bool isNumeric() const override;
176 
179 
184  virtual void convertToConst(cComponent *context) override;
185 
189  virtual std::string str() const override;
190 
194  virtual void parse(const char *text, FileLine loc) override;
195 
199  virtual int compare(const cParImpl *other) const override;
201 };
202 
203 } // namespace internal
204 } // namespace omnetpp
205 
206 #endif
207 
208 
omnetpp::cObject
cObject is a lightweight class which serves as the root of the OMNeT++ class hierarchy....
Definition: cobject.h:92
omnetpp::internal::cStringParImpl::cStringParImpl
cStringParImpl(const cStringParImpl &other)
Definition: cstringparimpl.h:57
omnetpp::cExpression
Abstract base class for expression evaluators.
Definition: cexpression.h:33
omnetpp::internal::cStringParImpl
A cParImpl subclass that stores a module/channel parameter of the type string.
Definition: cstringparimpl.h:30
omnetpp::FileLine
Definition: fileline.h:27
omnetpp::internal::cStringParImpl::cStringParImpl
cStringParImpl()
Definition: cstringparimpl.h:52
omnetpp::intval_t
int64_t intval_t
Signed integer type which is guaranteed to be at least 64 bits wide. It is used throughout the librar...
Definition: simkerneldefs.h:101
omnetpp::internal::cParImpl
Internal class that stores values for cPar objects.
Definition: cparimpl.h:46
omnetpp::cXMLElement
Represents an XML element in an XML configuration file.
Definition: cxmlelement.h:75
omnetpp::cComponent
Common base for module and channel classes.
Definition: ccomponent.h:49
omnetpp::internal::cStringParImpl::dup
virtual cStringParImpl * dup() const override
Definition: cstringparimpl.h:76