OMNeT++ Simulation Library  6.0.3
cobjectparimpl.h
1 //==========================================================================
2 // COBJECTPARIMPL.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_COBJECTPARIMPL_H
17 #define __OMNETPP_COBJECTPARIMPL_H
18 
19 #include "cparimpl.h"
20 
21 namespace omnetpp {
22 
23 class cTemporaryOwner;
24 
25 namespace internal {
26 
40 class SIM_API cObjectParImpl : public cParImpl
41 {
42  protected:
43  // selector: flags & FL_ISEXPR
44  cExpression *expr = nullptr;
45  mutable cObject *obj = nullptr; // stores the result of the last evaluation
46  opp_staticpooledstring expectedType; // value of the "@class" property, or ""
47 
48  private:
49  void copy(const cObjectParImpl& other);
50 
51  protected:
52  void deleteExpression();
53  void deleteObject();
54  virtual void doSetObject(cObject *object);
55  virtual void checkType(cObject *object) const;
56  virtual void checkOwnership(cObject *obj, cTemporaryOwner& tmp) const;
57 
58  public:
61 
65  explicit cObjectParImpl() {}
66 
70  cObjectParImpl(const cObjectParImpl& other) : cParImpl(other) {copy(other);}
71 
75  virtual ~cObjectParImpl();
76 
80  void operator=(const cObjectParImpl& otherpar);
82 
85 
89  virtual cObjectParImpl *dup() const override {return new cObjectParImpl(*this);}
91 
94 
98  virtual void setBoolValue(bool b) override;
99 
103  virtual void setIntValue(intval_t l) override;
104 
108  virtual void setDoubleValue(double d) override;
109 
113  virtual void setStringValue(const char *s) override;
114 
118  virtual void setObjectValue(cObject *object) override;
119 
123  virtual void setXMLValue(cXMLElement *node) override;
124 
129  virtual void setExpression(cExpression *e) override;
131 
134 
138  virtual bool boolValue(cComponent *context) const override;
139 
143  virtual intval_t intValue(cComponent *context) const override;
144 
148  virtual double doubleValue(cComponent *context) const override;
149 
153  virtual const char *stringValue(cComponent *context) const override;
154 
158  virtual std::string stdstringValue(cComponent *context) const override;
159 
163  virtual cObject *objectValue(cComponent *context) const override;
164 
168  virtual cXMLElement *xmlValue(cComponent *context) const override;
169 
173  virtual cExpression *getExpression() const override;
175 
178 
182  virtual Type getType() const override;
183 
187  virtual bool isNumeric() const override;
188 
192  virtual void setExpectedType(const char *s);
194 
201  virtual void convertToConst(cComponent *context) override;
202 
206  virtual std::string str() const override;
207 
211  virtual void parse(const char *text, FileLine loc) override;
212 
216  virtual int compare(const cParImpl *other) const override;
217 
221  virtual void forEachChild(cVisitor *v, cComponent *context) override;
223 };
224 
225 } // namespace internal
226 } // namespace omnetpp
227 
228 #endif
229 
230 
omnetpp::cObject
cObject is a lightweight class which serves as the root of the OMNeT++ class hierarchy....
Definition: cobject.h:92
omnetpp::internal::cObjectParImpl::dup
virtual cObjectParImpl * dup() const override
Definition: cobjectparimpl.h:89
omnetpp::cExpression
Abstract base class for expression evaluators.
Definition: cexpression.h:33
omnetpp::cVisitor
Enables traversing the tree of (cObject-rooted) simulation objects.
Definition: cvisitor.h:56
omnetpp::FileLine
Definition: fileline.h:27
omnetpp::opp_staticpooledstring
Definition: opp_pooledstring.h:29
omnetpp::internal::cObjectParImpl
A cParImpl subclass that stores a module/channel parameter of type object.
Definition: cobjectparimpl.h:40
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::cObjectParImpl::cObjectParImpl
cObjectParImpl()
Definition: cobjectparimpl.h:65
omnetpp::internal::cObjectParImpl::cObjectParImpl
cObjectParImpl(const cObjectParImpl &other)
Definition: cobjectparimpl.h:70