cexpression.h

00001 //==========================================================================
00002 //   CEXPRESSION.H  - part of
00003 //                     OMNeT++/OMNEST
00004 //            Discrete System Simulation in C++
00005 //
00006 //  Author: Andras Varga
00007 //
00008 //==========================================================================
00009 
00010 /*--------------------------------------------------------------*
00011   Copyright (C) 1992-2008 Andras Varga
00012   Copyright (C) 2006-2008 OpenSim Ltd.
00013 
00014   This file is distributed WITHOUT ANY WARRANTY. See the file
00015   `license' for details on this and other legal matters.
00016 *--------------------------------------------------------------*/
00017 
00018 #ifndef __CEXPRESSION_H
00019 #define __CEXPRESSION_H
00020 
00021 #include "cobject.h"
00022 #include "cexception.h"
00023 #include "cnedvalue.h"
00024 
00025 NAMESPACE_BEGIN
00026 
00027 class cXMLElement;
00028 
00035 class SIM_API cExpression : public cObject
00036 {
00037   public:
00040 
00044     explicit cExpression() {}
00045 
00049     cExpression(const cExpression& other) : cObject(other) {}
00050 
00054     virtual ~cExpression() {}
00055 
00059     cExpression& operator=(const cExpression& other) {return *this;}
00061 
00067     virtual cExpression *dup() const {copyNotSupported(); return NULL;}
00068 
00073     virtual std::string info() const {return "";}
00074 
00078     virtual void parsimPack(cCommBuffer *buffer)  {throw cRuntimeError(this, eCANTPACK);}
00079 
00083     virtual void parsimUnpack(cCommBuffer *buffer)  {throw cRuntimeError(this, eCANTPACK);}
00085 
00088 
00092     virtual cNEDValue evaluate(cComponent *context=NULL) const {return cNEDValue();} //TODO in 5.0: make this pure virtual, and remove type-specific getters (boolValue(), etc)
00093 
00098     virtual bool boolValue(cComponent *context=NULL) = 0;
00099 
00105     virtual long longValue(cComponent *context=NULL, const char *expectedUnit=NULL) = 0;
00106 
00112     virtual double doubleValue(cComponent *context=NULL, const char *expectedUnit=NULL) = 0;
00113 
00118     virtual std::string stringValue(cComponent *context=NULL) = 0;
00119 
00124     virtual cXMLElement *xmlValue(cComponent *context=NULL) = 0;
00126 
00132     virtual std::string str() const = 0;
00133 
00141     virtual void parse(const char *text) = 0;
00142 
00147     virtual int compare(const cExpression *other) const = 0;
00148 
00152     virtual bool containsConstSubexpressions() const = 0;
00153 
00158     virtual void evaluateConstSubexpressions(cComponent *context) = 0;
00160 };
00161 
00162 NAMESPACE_END
00163 
00164 
00165 #endif
00166 
00167 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3