Stores loaded NED files, and keeps track of components in them. More...
#include <nedresourcecache.h>
Classes | |
class | CachedTypeNames |
class | INEDTypeNames |
Interface that enumerates NED types; used by resolveType(). More... | |
struct | PendingNedType |
Public Member Functions | |
NEDResourceCache () | |
virtual | ~NEDResourceCache () |
virtual int | loadNedSourceFolder (const char *foldername) |
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 | doneLoadingNedFiles () |
virtual bool | addFile (const char *fname, NEDElement *node) |
virtual NEDElement * | getFile (const char *fname) const |
virtual NedFileElement * | getParentPackageNedFile (NedFileElement *nedfile) const |
virtual NEDTypeInfo * | lookup (const char *qname) const |
virtual NEDTypeInfo * | getDecl (const char *qname) const |
virtual std::string | resolveNedType (const NEDLookupContext &context, const char *nedtypename, INEDTypeNames *qnames) |
virtual std::string | resolveNedType (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, NEDElement *node) |
Protected Types | |
typedef std::map< std::string, NEDElement * > | NEDFileMap |
typedef std::map< std::string, NEDTypeInfo * > | NEDTypeInfoMap |
typedef std::map< std::string, std::string > | StringMap |
Protected Member Functions | |
virtual void | registerBuiltinDeclarations () |
virtual int | doLoadNedSourceFolder (const char *foldername, const char *expectedPackage) |
virtual void | doLoadNedFileOrText (const char *nedfname, const char *nedtext, const char *expectedPackage, bool isXML) |
virtual NEDElement * | 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 (NEDElement *node, const std::string &namespacePrefix, bool areInnerTypes) |
virtual void | collectNedType (const char *qname, bool isInnerType, NEDElement *node) |
virtual bool | areDependenciesResolved (const char *qname, NEDElement *node) |
virtual void | registerPendingNedTypes () |
virtual void | registerNedType (const char *qname, bool isInnerType, NEDElement *node) |
Protected Attributes | |
NEDFileMap | files |
NEDTypeInfoMap | nedTypes |
std::vector< std::string > | nedTypeNames |
StringMap | folderPackages |
std::vector< PendingNedType > | pendingList |
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.
typedef std::map<std::string, NEDElement *> NEDResourceCache::NEDFileMap [protected] |
typedef std::map<std::string, NEDTypeInfo *> NEDResourceCache::NEDTypeInfoMap [protected] |
typedef std::map<std::string,std::string> NEDResourceCache::StringMap [protected] |
NEDResourceCache::NEDResourceCache | ( | ) |
Constructor.
virtual NEDResourceCache::~NEDResourceCache | ( | ) | [virtual] |
Destructor.
virtual bool NEDResourceCache::addFile | ( | const char * | fname, | |
NEDElement * | node | |||
) | [virtual] |
Add a file (parsed into an object tree) to the cache.
If the file was already added, no processing takes place and the function returns false; otherwise it returns true.
virtual bool NEDResourceCache::areDependenciesResolved | ( | const char * | qname, | |
NEDElement * | node | |||
) | [protected, virtual] |
virtual void NEDResourceCache::collectNedType | ( | const char * | qname, | |
bool | isInnerType, | |||
NEDElement * | node | |||
) | [protected, virtual] |
virtual void NEDResourceCache::collectNedTypesFrom | ( | NEDElement * | node, | |
const std::string & | namespacePrefix, | |||
bool | areInnerTypes | |||
) | [protected, virtual] |
virtual std::string NEDResourceCache::determineRootPackageName | ( | const char * | nedSourceFolderName | ) | [protected, virtual] |
virtual void NEDResourceCache::doLoadNedFileOrText | ( | const char * | nedfname, | |
const char * | nedtext, | |||
const char * | expectedPackage, | |||
bool | isXML | |||
) | [protected, virtual] |
virtual int NEDResourceCache::doLoadNedSourceFolder | ( | const char * | foldername, | |
const char * | expectedPackage | |||
) | [protected, virtual] |
virtual void NEDResourceCache::doneLoadingNedFiles | ( | ) | [virtual] |
To be called after all NED folders / files have been loaded.
May be redefined to issue errors for components that could not be fully resolved because of missing base types or interfaces.
virtual NEDTypeInfo* NEDResourceCache::getDecl | ( | const char * | qname | ) | const [virtual] |
Like lookup(), but asserts non-NULL return value.
virtual NEDElement* NEDResourceCache::getFile | ( | const char * | fname | ) | const [virtual] |
Get a file (represented as object tree) from the cache.
virtual std::string NEDResourceCache::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.
virtual std::string NEDResourceCache::getNedSourceFolderForFolder | ( | const char * | folder | ) | const [protected, virtual] |
static NEDLookupContext NEDResourceCache::getParentContextOf | ( | const char * | qname, | |
NEDElement * | node | |||
) | [static] |
Utility method, useful with resolveNedType()/resolveComponentType().
virtual NedFileElement* NEDResourceCache::getParentPackageNedFile | ( | NedFileElement * | nedfile | ) | const [virtual] |
Given a NED file, returns the package.ned file from the same folder, or the nearest ancestor package.ned file.
If the file is a package.ned file itself, returns the nearest ancestor package.ned file. Returns NULL if there is no parent package.ned file.
virtual const std::vector<std::string>& NEDResourceCache::getTypeNames | ( | ) | const [virtual] |
Available NED type names.
virtual void NEDResourceCache::loadNedFile | ( | const char * | nedfname, | |
const char * | expectedPackage, | |||
bool | isXML | |||
) | [virtual] |
Load a single NED file.
If the expected package is given (non-NULL), it should match the package declaration inside the NED file.
Note: doneLoadingNedFiles() must be called after the last loadNedSourceFolder()/loadNedFile()/loadNedText() call.
virtual int NEDResourceCache::loadNedSourceFolder | ( | const char * | foldername | ) | [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. Returns the number of files loaded.
Note: doneLoadingNedFiles() must be called after the last loadNedSourceFolder()/loadNedFile()/loadNedText() call.
virtual void NEDResourceCache::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-NULL), it should match the package declaration inside the NED file.
Note: doneLoadingNedFiles() must be called after the last loadNedSourceFolder()/loadNedFile()/loadNedText() call.
virtual NEDTypeInfo* NEDResourceCache::lookup | ( | const char * | qname | ) | const [virtual] |
Look up a fully qualified NED type name from the cache.
Returns NULL if not found.
virtual NEDElement* NEDResourceCache::parseAndValidateNedFileOrText | ( | const char * | nedfname, | |
const char * | nedtext, | |||
bool | isXML | |||
) | [protected, virtual] |
virtual void NEDResourceCache::registerBuiltinDeclarations | ( | ) | [protected, virtual] |
virtual void NEDResourceCache::registerNedType | ( | const char * | qname, | |
bool | isInnerType, | |||
NEDElement * | node | |||
) | [protected, virtual] |
virtual void NEDResourceCache::registerPendingNedTypes | ( | ) | [protected, virtual] |
virtual std::string NEDResourceCache::resolveNedType | ( | const NEDLookupContext & | context, | |
const char * | nedtypename | |||
) | [inline, virtual] |
Resolves NED type name, based on the NED files loaded.
virtual std::string NEDResourceCache::resolveNedType | ( | const NEDLookupContext & | context, | |
const char * | nedtypename, | |||
INEDTypeNames * | qnames | |||
) | [virtual] |
Resolves the given NED type name in the given context, among the given type names.
Returns "" if not found.
NEDFileMap NEDResourceCache::files [protected] |
StringMap NEDResourceCache::folderPackages [protected] |
std::vector<std::string> NEDResourceCache::nedTypeNames [mutable, protected] |
NEDTypeInfoMap NEDResourceCache::nedTypes [protected] |
std::vector<PendingNedType> NEDResourceCache::pendingList [protected] |