nedsupport.h

00001 //==========================================================================
00002 //   NEDSUPPORT.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 __NEDSUPPORT_H
00019 #define __NEDSUPPORT_H
00020 
00021 #include "cdynamicexpression.h"
00022 
00023 NAMESPACE_BEGIN
00024 
00025 namespace NEDSupport {
00026 
00027 class ModuleIndex : public cDynamicExpression::Functor
00028 {
00029   public:
00030     ModuleIndex();
00031     ModuleIndex *dup() const {return new ModuleIndex();}
00032     virtual const char *getFullName() const {return "index";}
00033     virtual const char *getArgTypes() const {return "";}
00034     virtual char getReturnType() const {return 'L';}
00035     virtual cNEDValue evaluate(cComponent *context, cNEDValue args[], int numargs);
00036     virtual std::string str(std::string args[], int numargs);
00037 };
00038 
00042 class ParameterRef : public cDynamicExpression::Functor
00043 {
00044   protected:
00045     bool ofParent;  // if true, return parentModule->par(paramName)
00046     bool explicitKeyword; // when ofParent==false: whether the NED file contained the explicit "this" qualifier
00047     std::string paramName;
00048   public:
00049     ParameterRef(const char *paramName, bool ofParent, bool explicitKeyword);
00050     ParameterRef *dup() const {return new ParameterRef(paramName.c_str(), ofParent, explicitKeyword);}
00051     virtual const char *getFullName() const {return paramName.c_str();}
00052     virtual const char *getArgTypes() const {return "";}
00053     virtual char getReturnType() const {return '*';}
00054     virtual cNEDValue evaluate(cComponent *context, cNEDValue args[], int numargs);
00055     virtual std::string str(std::string args[], int numargs);
00056 };
00057 
00061 class SiblingModuleParameterRef : public cDynamicExpression::Functor
00062 {
00063   protected:
00064     bool ofParent;  // if true, return parentModule->getSubmodule(...)->par(parname)
00065     std::string moduleName;
00066     bool withModuleIndex;
00067     std::string paramName;
00068   public:
00069     SiblingModuleParameterRef(const char *moduleName, const char *paramName, bool ofParent, bool withModuleIndex);
00070     SiblingModuleParameterRef *dup() const {return new SiblingModuleParameterRef(moduleName.c_str(), paramName.c_str(), ofParent, withModuleIndex);}
00071     virtual const char *getFullName() const {return paramName.c_str();}
00072     virtual const char *getArgTypes() const {return withModuleIndex ? "L" : "";}
00073     virtual char getReturnType() const {return '*';}
00074     virtual cNEDValue evaluate(cComponent *context, cNEDValue args[], int numargs);
00075     virtual std::string str(std::string args[], int numargs);
00076 };
00077 
00081 class LoopVar : public cDynamicExpression::Functor
00082 {
00083   private:
00084     // the loopvar stack (vars of nested loops are pushed on the stack by cNEDNetworkBuilder)
00085     static const char *varNames[32];
00086     static long vars[32];
00087     static int varCount;
00088   public:
00089     static long& pushVar(const char *varName);
00090     static void popVar();
00091     static void reset();
00092     static const char **getVarNames() {return varNames;}
00093     static int getNumVars() {return varCount;}
00094 
00095   protected:
00096     std::string varName;
00097   public:
00098     LoopVar(const char *varName) {this->varName = varName;}
00099     LoopVar *dup() const {return new LoopVar(varName.c_str());}
00100     virtual const char *getFullName() const {return varName.c_str();}
00101     virtual const char *getArgTypes() const {return "";}
00102     virtual char getReturnType() const {return 'L';}
00103     virtual cNEDValue evaluate(cComponent *context, cNEDValue args[], int numargs);
00104     virtual std::string str(std::string args[], int numargs);
00105 };
00106 
00107 
00111 class Sizeof : public cDynamicExpression::Functor
00112 {
00113   protected:
00114     bool ofParent;  // if true, return parentModule->gateSize(ident)
00115     bool explicitKeyword; // when ofParent==false: whether the NED file contained the explicit "this" qualifier
00116     std::string ident;
00117   public:
00118     Sizeof(const char *ident, bool ofParent, bool explicitKeyword);
00119     Sizeof *dup() const {return new Sizeof(ident.c_str(), ofParent, explicitKeyword);}
00120     virtual const char *getFullName() const {return ident.c_str();}
00121     virtual const char *getArgTypes() const {return "";}
00122     virtual char getReturnType() const {return 'L';}
00123     virtual cNEDValue evaluate(cComponent *context, cNEDValue args[], int numargs);
00124     virtual std::string str(std::string args[], int numargs);
00125 };
00126 
00127 /*XXX TODO
00128 static cNEDValue getSizeofIdent(cComponent *context, cNEDValue args[], int numargs);
00129 static cNEDValue getSizeofGate(cComponent *context, cNEDValue args[], int numargs);
00130 static cNEDValue getSizeofParentModuleGate(cComponent *context, cNEDValue args[], int numargs);
00131 static cNEDValue getSizeofSiblingModuleGate(cComponent *context, cNEDValue args[], int numargs);
00132 static cNEDValue getSizeofIndexedSiblingModuleGate(cComponent *context, cNEDValue args[], int numargs);
00133 
00134 class Sizeof : public Functor
00135 {
00136   protected:
00137     bool ofParent;
00138     bool bstd::string paramName;
00139     std::string moduleName;
00140   public:
00141     virtual const char *getArgTypes() const {return "";}
00142     virtual char getReturnType() const {return 'L';}
00143     virtual cNEDValue evaluate(cComponent *context, cNEDValue args[], int numargs);
00144     virtual std::string str(std::string args[], int numargs) {return "index";}
00145 };
00146 */
00147 
00148 };
00149 
00150 NAMESPACE_END
00151 
00152 
00153 #endif
00154 
00155 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3