Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes

BonnMotionFileCache Class Reference
[mobility - modules handling the mobility of the hosts]

#include <BonnMotionFileCache.h>

Collaboration diagram for BonnMotionFileCache:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual const BonnMotionFilegetFile (const char *filename)

Static Public Member Functions

static BonnMotionFileCachegetInstance ()
static void deleteInstance ()

Protected Types

typedef std::map< std::string,
BonnMotionFile
BMFileMap

Protected Member Functions

void parseFile (const char *filename, BonnMotionFile &bmFile)

Protected Attributes

BMFileMap cache

Static Protected Attributes

static BonnMotionFileCacheinst

Detailed Description

Singleton object to read and store BonnMotion files. Used within BonnMotionMobility. Needed because otherwise every node would have to open and read the file independently.

Author:
Andras Varga

Definition at line 53 of file BonnMotionFileCache.h.


Member Function Documentation

void BonnMotionFileCache::deleteInstance (  )  [static]

Deletes the singleton instance.

Definition at line 41 of file BonnMotionFileCache.cc.

{
    if (inst) 
    {
        delete inst;
        inst = NULL;
    }
}

const BonnMotionFile * BonnMotionFileCache::getFile ( const char *  filename  )  [virtual]

Returns the given document.

Definition at line 50 of file BonnMotionFileCache.cc.

Referenced by BonnMotionMobility::initialize().

{
    // if found, return it from cache
    BMFileMap::iterator it = cache.find(std::string(filename));
    if (it!=cache.end())
        return &(it->second);

    // load and store in cache
    BonnMotionFile& bmFile = cache[filename];
    parseFile(filename, bmFile);
    return &bmFile;
}

BonnMotionFileCache * BonnMotionFileCache::getInstance (  )  [static]

Returns the singleton instance.

Definition at line 34 of file BonnMotionFileCache.cc.

Referenced by BonnMotionMobility::initialize().

{
    if (!inst)
        inst = new BonnMotionFileCache;
    return inst;
}


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