OMNeT++ NEDXML  6.0.3
nedtypeinfo.h
Go to the documentation of this file.
1 //==========================================================================
2 // NEDTYPEINFO.H -
3 //
4 // OMNeT++/OMNEST
5 // Discrete System Simulation in C++
6 //
7 //==========================================================================
8 
9 /*--------------------------------------------------------------*
10  Copyright (C) 2002-2017 Andras Varga
11  Copyright (C) 2006-2017 OpenSim Ltd.
12 
13  This file is distributed WITHOUT ANY WARRANTY. See the file
14  `license' for details on this and other legal matters.
15 *--------------------------------------------------------------*/
16 
17 
18 #ifndef __OMNETPP_NEDXML_NEDTYPEINFO_H
19 #define __OMNETPP_NEDXML_NEDTYPEINFO_H
20 
21 #include <map>
22 #include <vector>
23 #include <string>
24 #include "common/commonutil.h"
25 #include "nedelements.h"
26 
27 namespace omnetpp {
28 namespace nedxml {
29 
30 class NedResourceCache;
31 
44 {
45  public:
46  enum Type {SIMPLE_MODULE, COMPOUND_MODULE, MODULEINTERFACE, CHANNEL, CHANNELINTERFACE};
47 
48  protected:
49  // the resolver this type is in
51 
53  std::string qualifiedName;
54  bool isInner; // whether it is an inner type
55  ASTNode *tree; // points into resolver
56 
57  typedef std::vector<std::string> StringVector;
58  typedef std::map<std::string,ASTNode*> NameToElementMap;
59 
60  // inheritance. Vectors contain fully qualifies names, and include
61  // indirect base types/interfaces as well (transitive closure).
64 
65  std::string enclosingTypeName;
66 
67  // simple module/channel C++ class to instantiate
68  std::string implClassName;
69 
70  // local declarations by name
77 
78  protected:
79  void checkComplianceToInterface(NedTypeInfo *interfaceDecl);
80  void collectLocalDeclarations();
81  void addToElementMap(NameToElementMap& elementMap, ASTNode *node);
82  void mergeElementMap(NameToElementMap& destMap, const NameToElementMap& elementMap);
83 
84  public:
86  NedTypeInfo(NedResourceCache *resolver, const char *qname, bool isInnerType, ASTNode *tree);
87 
89  virtual ~NedTypeInfo();
90 
92  virtual const char *getName() const;
93 
95  virtual const char *getFullName() const;
96 
98  virtual ASTNode *getTree() const;
99 
101  NedResourceCache *getResolver() const {return resolver;}
102 
107  virtual Type getType() const {return type;}
108 
112  virtual const char *getSourceFileName() const;
113 
118  virtual std::string getPackage() const;
119 
123  virtual std::string str() const;
124 
128  virtual std::string getNedSource() const;
129 
134  virtual int numExtendsNames() const {return extendsNames.size();}
135 
140  virtual const char *getExtendsName(int k) const;
141 
148  virtual int numInterfaceNames() const {return interfaceNames.size();}
149 
154  virtual const char *getInterfaceName(int k) const;
155 
160  virtual bool supportsInterface(const char *qname);
161 
165  virtual bool isInnerType() const {return isInner;}
166 
171  virtual const char *getEnclosingTypeName() const;
172 
177  virtual bool isNetwork() const;
178 
184  virtual const char *getImplementationClassName() const;
185 
193  virtual std::string getPackageProperty(const char *name) const;
194 
196  virtual std::string getCxxNamespace() const;
197 
199  virtual NedTypeInfo *getSuperDecl() const;
200 
203  TypesElement *getTypesElement() const;
204  ParametersElement *getParametersElement() const;
205  GatesElement *getGatesElement() const;
206  SubmodulesElement *getSubmodulesElement() const;
207  ConnectionsElement *getConnectionsElement() const;
208 
210  SubmoduleElement *getLocalSubmoduleElement(const char *submoduleName) const;
211 
213  ConnectionElement *getLocalConnectionElement(long id) const;
214 
216  SubmoduleElement *getSubmoduleElement(const char *submoduleName) const;
217 
219  ConnectionElement *getConnectionElement(long id) const;
220 
222  ParamElement *findLocalParamDecl(const char *name) const;
223 
225  ParamElement *findParamDecl(const char *name) const;
226 
228  GateElement *findLocalGateDecl(const char *name) const;
229 
231  GateElement *findGateDecl(const char *name) const;
233 };
234 
235 } // namespace nedxml
236 } // namespace omnetpp
237 
238 
239 #endif
240 
omnetpp::nedxml::NedTypeInfo::localSubmoduleDecls
NameToElementMap localSubmoduleDecls
Definition: nedtypeinfo.h:74
omnetpp::nedxml::NedResourceCache
Stores loaded NED files, and keeps track of components in them.
Definition: nedresourcecache.h:52
omnetpp::nedxml::NedTypeInfo::localConnectionDecls
NameToElementMap localConnectionDecls
Definition: nedtypeinfo.h:75
omnetpp::nedxml::NedTypeInfo::localParamDecls
NameToElementMap localParamDecls
Definition: nedtypeinfo.h:72
omnetpp::nedxml::NedTypeInfo::Type
Type
Definition: nedtypeinfo.h:46
omnetpp::nedxml::NedTypeInfo::interfaceNames
StringVector interfaceNames
Definition: nedtypeinfo.h:63
omnetpp::nedxml::NedTypeInfo::getResolver
NedResourceCache * getResolver() const
Definition: nedtypeinfo.h:101
omnetpp::nedxml::NedTypeInfo::implClassName
std::string implClassName
Definition: nedtypeinfo.h:68
NEDXML_API
#define NEDXML_API
Definition: nedxmldefs.h:31
omnetpp::nedxml::NedTypeInfo::tree
ASTNode * tree
Definition: nedtypeinfo.h:55
omnetpp::nedxml::NedTypeInfo::numInterfaceNames
virtual int numInterfaceNames() const
Definition: nedtypeinfo.h:148
omnetpp
Definition: astbuilder.h:25
omnetpp::nedxml::NedTypeInfo::StringVector
std::vector< std::string > StringVector
Definition: nedtypeinfo.h:57
omnetpp::nedxml::NedTypeInfo::numExtendsNames
virtual int numExtendsNames() const
Definition: nedtypeinfo.h:134
omnetpp::nedxml::NedTypeInfo::resolver
NedResourceCache * resolver
Definition: nedtypeinfo.h:50
omnetpp::nedxml::NedTypeInfo::localGateDecls
NameToElementMap localGateDecls
Definition: nedtypeinfo.h:73
omnetpp::nedxml::NedTypeInfo
Stores information on a NED type.
Definition: nedtypeinfo.h:43
omnetpp::nedxml::ASTNode
Definition: astnode.h:87
omnetpp::nedxml::NedTypeInfo::getType
virtual Type getType() const
Definition: nedtypeinfo.h:107
omnetpp::nedxml::NedTypeInfo::extendsNames
StringVector extendsNames
Definition: nedtypeinfo.h:62
omnetpp::nedxml::NedTypeInfo::NameToElementMap
std::map< std::string, ASTNode * > NameToElementMap
Definition: nedtypeinfo.h:58
omnetpp::nedxml::NedTypeInfo::allLocalDecls
NameToElementMap allLocalDecls
Definition: nedtypeinfo.h:76
omnetpp::nedxml::NedTypeInfo::type
Type type
Definition: nedtypeinfo.h:52
omnetpp::nedxml::NedTypeInfo::localInnerTypeDecls
NameToElementMap localInnerTypeDecls
Definition: nedtypeinfo.h:71
omnetpp::nedxml::NedTypeInfo::qualifiedName
std::string qualifiedName
Definition: nedtypeinfo.h:53
omnetpp::nedxml::NedTypeInfo::enclosingTypeName
std::string enclosingTypeName
Definition: nedtypeinfo.h:65
omnetpp::nedxml::NedTypeInfo::isInnerType
virtual bool isInnerType() const
Definition: nedtypeinfo.h:165
omnetpp::nedxml::NedTypeInfo::isInner
bool isInner
Definition: nedtypeinfo.h:54