OMNeT++ NEDXML 6.1
Discrete Event Simulation Library
NedResourceCache Class Reference

Description

Stores loaded NED files, and keeps track of components in them.

This class can be turned into a cache (discarding and reloading NED files on demand) if such need arises.

Classes

class  CachedTypeNames
 
class  INedTypeNames
 

Public Member Functions

 NedResourceCache ()
 
virtual ~NedResourceCache ()
 
virtual int loadNedSourceFolder (const char *foldername, const char *excludedPackages)
 
virtual void loadNedFile (const char *nedfname, const char *expectedPackage, bool isXML)
 
virtual void loadNedText (const char *name, const char *nedtext, const char *expectedPackage, bool isXML)
 
virtual void resolveAllNedTypes ()
 
virtual void doneLoadingNedFiles ()
 
std::vector< NedFileElement * > getPackageNedListForLookup (const char *packageName) const
 
virtual NedTypeInfolookup (const char *qname) const
 
virtual NedTypeInfogetDecl (const char *qname)
 
virtual std::string lookupNedType (const NedLookupContext &context, const char *nedTypeName, const INedTypeNames &amongQNames)
 
virtual std::string lookupNedType (const NedLookupContext &context, const char *nedTypeName)
 
virtual const std::vector< std::string > & getTypeNames () const
 
virtual std::string getNedPackageForFolder (const char *folder) const
 

Static Public Member Functions

static NedLookupContext getParentContextOf (const char *qname, ASTNode *node)
 

Protected Types

typedef std::map< std::string, std::string > StringMap
 

Protected Member Functions

virtual void addFile (NedFileElement *node, const char *expectedPackage)
 
virtual void registerBuiltinDeclarations ()
 
virtual int doLoadNedSourceFolder (const char *foldername, const char *expectedPackage, const std::vector< std::string > &excludedFolders)
 
virtual void doLoadNedFileOrText (const char *nedfname, const char *nedtext, const char *expectedPackage, bool isXML)
 
virtual NedFileElement * parseAndValidateNedFileOrText (const char *nedfname, const char *nedtext, bool isXML)
 
virtual std::string determineRootPackageName (const char *nedSourceFolderName)
 
virtual std::string getNedSourceFolderForFolder (const char *folder) const
 
virtual void collectNedTypesFrom (ASTNode *node, const std::string &packagePrefix, bool areInnerTypes)
 
virtual NedTypeInfocreateTypeInfo (const char *qname, bool isInnerType, ASTNode *node)
 
virtual void registerNedType (const char *qname, bool isInnerType, ASTNode *node)
 
virtual bool hasResolvedTypeUnder (const std::string &packageName) const
 
virtual std::string getFirstError (ErrorStore *errors, const char *prefix=nullptr)
 

Protected Attributes

std::map< std::string, NedFileElement * > nedFiles
 
std::map< std::string, NedFileElement * > packageDotNedFiles
 
std::map< std::string, NedTypeInfo * > nedTypes
 
std::vector< std::string > nedTypeNames
 
StringMap folderPackages
 

Member Typedef Documentation

◆ StringMap

typedef std::map<std::string,std::string> StringMap
protected

Constructor & Destructor Documentation

◆ NedResourceCache()

NedResourceCache ( )
inline

Constructor

◆ ~NedResourceCache()

virtual ~NedResourceCache ( )
virtual

Destructor

Member Function Documentation

◆ addFile()

virtual void addFile ( NedFileElement *  node,
const char *  expectedPackage 
)
protectedvirtual

◆ registerBuiltinDeclarations()

virtual void registerBuiltinDeclarations ( )
protectedvirtual

◆ doLoadNedSourceFolder()

virtual int doLoadNedSourceFolder ( const char *  foldername,
const char *  expectedPackage,
const std::vector< std::string > &  excludedFolders 
)
protectedvirtual

◆ doLoadNedFileOrText()

virtual void doLoadNedFileOrText ( const char *  nedfname,
const char *  nedtext,
const char *  expectedPackage,
bool  isXML 
)
protectedvirtual

◆ parseAndValidateNedFileOrText()

virtual NedFileElement* parseAndValidateNedFileOrText ( const char *  nedfname,
const char *  nedtext,
bool  isXML 
)
protectedvirtual

◆ determineRootPackageName()

virtual std::string determineRootPackageName ( const char *  nedSourceFolderName)
protectedvirtual

◆ getNedSourceFolderForFolder()

virtual std::string getNedSourceFolderForFolder ( const char *  folder) const
protectedvirtual

◆ collectNedTypesFrom()

virtual void collectNedTypesFrom ( ASTNode node,
const std::string &  packagePrefix,
bool  areInnerTypes 
)
protectedvirtual

◆ createTypeInfo()

virtual NedTypeInfo* createTypeInfo ( const char *  qname,
bool  isInnerType,
ASTNode node 
)
protectedvirtual

◆ registerNedType()

virtual void registerNedType ( const char *  qname,
bool  isInnerType,
ASTNode node 
)
protectedvirtual

◆ hasResolvedTypeUnder()

virtual bool hasResolvedTypeUnder ( const std::string &  packageName) const
protectedvirtual

◆ getFirstError()

virtual std::string getFirstError ( ErrorStore errors,
const char *  prefix = nullptr 
)
protectedvirtual

◆ loadNedSourceFolder()

virtual int loadNedSourceFolder ( const char *  foldername,
const char *  excludedPackages 
)
virtual

Load all NED files from a NED source folder. This involves visiting each subdirectory, and loading all "*.ned" files from there. The given folder is assumed to be the root of the NED package hierarchy. A list of packages to skip may be specified in the excludedPackages parameter (items must be separated with a semicolon).

The function returns the number of NED files loaded.

Note: doneLoadingNedFiles() must be called after the last loadNedSourceFolder()/loadNedFile()/loadNedText() call.

◆ loadNedFile()

virtual void loadNedFile ( const char *  nedfname,
const char *  expectedPackage,
bool  isXML 
)
virtual

Load a single NED file. If the expected package is given (non-nullptr), it should match the package declaration inside the NED file.

Note: doneLoadingNedFiles() must be called after the last loadNedSourceFolder()/loadNedFile()/loadNedText() call.

◆ loadNedText()

virtual void loadNedText ( const char *  name,
const char *  nedtext,
const char *  expectedPackage,
bool  isXML 
)
virtual

Parses and loads the NED source code passed in the nedtext argument. The name argument will be used as filename in error messages, and and should be unique among the files loaded. If the expected package is given (non-nullptr), it should match the package declaration inside the NED file.

Note: doneLoadingNedFiles() must be called after the last loadNedSourceFolder()/loadNedFile()/loadNedText() call.

◆ resolveAllNedTypes()

virtual void resolveAllNedTypes ( )
virtual

Forces resolving (see NedTypeInfo::resolve()) all loaded NED types, so that missing base types and other problems are detected. Without calling this function, such errors only surface on the first use of the NED type.

◆ doneLoadingNedFiles()

virtual void doneLoadingNedFiles ( )
virtual

Deprecated. Calling this method is no longer required. Currently delegates to resolveAllNedTypes().

◆ getPackageNedListForLookup()

std::vector<NedFileElement*> getPackageNedListForLookup ( const char *  packageName) const

Return a list of "package.ned" files relevant for the given package. Files are in bottom-up order, the order they should be searched for package properties.

◆ lookup()

virtual NedTypeInfo* lookup ( const char *  qname) const
virtual

Look up a fully qualified NED type name. Returns nullptr if not found.

Referenced by NedResourceCache::CachedTypeNames::contains().

◆ getDecl()

virtual NedTypeInfo* getDecl ( const char *  qname)
virtual

Like lookup(), but asserts non-nullptr return value.

◆ lookupNedType() [1/2]

virtual std::string lookupNedType ( const NedLookupContext context,
const char *  nedTypeName,
const INedTypeNames amongQNames 
)
virtual

Resolves the given NED type name in the given context among the given fully qualified type names. Returns "" if not found.

◆ lookupNedType() [2/2]

virtual std::string lookupNedType ( const NedLookupContext context,
const char *  nedTypeName 
)
inlinevirtual

Resolves given NED type name, based on the NED files loaded. Returns "" if not found.

◆ getTypeNames()

virtual const std::vector<std::string>& getTypeNames ( ) const
inlinevirtual

Returns the list of available (fully qualified) NED type names.

Referenced by NedResourceCache::CachedTypeNames::get(), and NedResourceCache::CachedTypeNames::size().

◆ getNedPackageForFolder()

virtual std::string getNedPackageForFolder ( const char *  folder) const
virtual

Returns the NED package that corresponds to the given folder. Returns "" for the default package, and "-" if the folder is outside all NED folders.

◆ getParentContextOf()

static NedLookupContext getParentContextOf ( const char *  qname,
ASTNode node 
)
static

Utility method, useful with resolveNedType()/resolveComponentType()

Member Data Documentation

◆ nedFiles

std::map<std::string,NedFileElement*> nedFiles
protected

◆ packageDotNedFiles

std::map<std::string, NedFileElement*> packageDotNedFiles
protected

◆ nedTypes

std::map<std::string, NedTypeInfo*> nedTypes
protected

◆ nedTypeNames

std::vector<std::string> nedTypeNames
protected

◆ folderPackages

StringMap folderPackages
protected

The documentation for this class was generated from the following file: