OMNeT++ API 6.1
Discrete Event Simulation Library
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  // if not null: list of acceptable values
40  std::vector<std::string> *enumValues = nullptr;
41 
42  private:
43  void copy(const cStringParImpl& other);
44  void validate(const char *value) const;
45 
46  protected:
47  void deleteOld() {cParImpl::deleteOld(expr);}
48 
49  public:
52 
56  explicit cStringParImpl() {}
57 
61  cStringParImpl(const cStringParImpl& other) : cParImpl(other) {copy(other);}
62 
66  virtual ~cStringParImpl();
67 
71  void operator=(const cStringParImpl& otherpar);
73 
76 
80  virtual cStringParImpl *dup() const override {return new cStringParImpl(*this);}
82 
85 
89  virtual void setEnumValues(const std::vector<std::string>& values);
90 
94  virtual std::vector<std::string> getEnumValues() const;
96 
99 
103  virtual void setBoolValue(bool b) override;
104 
108  virtual void setIntValue(intval_t l) override;
109 
113  virtual void setDoubleValue(double d) override;
114 
118  virtual void setStringValue(const char *s) override;
119 
123  virtual void setObjectValue(cObject *object) override;
124 
128  virtual void setXMLValue(cXMLElement *node) override;
129 
134  virtual void setExpression(cExpression *e) override;
136 
139 
143  virtual bool boolValue(cComponent *context) const override;
144 
148  virtual intval_t intValue(cComponent *context) const override;
149 
153  virtual double doubleValue(cComponent *context) const override;
154 
158  virtual const char *stringValue(cComponent *context) const override;
159 
163  virtual std::string stdstringValue(cComponent *context) const override;
164 
168  virtual cObject *objectValue(cComponent *context) const override;
169 
173  virtual cXMLElement *xmlValue(cComponent *context) const override;
174 
178  virtual cExpression *getExpression() const override;
180 
183 
187  virtual Type getType() const override;
188 
192  virtual bool isNumeric() const override;
194 
197 
202  virtual void convertToConst(cComponent *context) override;
203 
207  virtual std::string str() const override;
208 
212  virtual void parse(const char *text, FileLine loc) override;
213 
217  virtual int compare(const cParImpl *other) const override;
219 };
220 
221 } // namespace internal
222 } // namespace omnetpp
223 
224 #endif
225 
226 
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:61
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:56
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:80