#ifndef _assemblyDefinitionFileCache_h_
#define _assemblyDefinitionFileCache_h_
#include <maya/MString.h>
#include <ciso646>
#if defined( _WIN32 ) || defined( _LIBCPP_VERSION )
#include <memory>
#include <unordered_map>
#define ADSTD std
#else
#include <tr1/memory>
#include <tr1/unordered_map>
#define ADSTD std::tr1
#endif
#include <string>
#include <vector>
#include <time.h>
class AssemblyDefinitionFileCache
{
private:
class Timestamp
{
public:
MInt64 fFileSize;
time_t fMTime;
};
friend inline bool operator==(const Timestamp& lhs,
const Timestamp& rhs);
public:
class RepresentationCreationArgs
{
public:
RepresentationCreationArgs(
const MString& name,
: fName(name), fType(type), fLabel(label), fData(data)
{}
const MString& getName()
const {
return fName; }
const MString& getType()
const {
return fType; }
const MString& getLabel()
const {
return fLabel; }
const MString& getData()
const {
return fData; }
private:
};
typedef std::vector<RepresentationCreationArgs> RepCreationArgsList;
class Entry
{
public:
const RepCreationArgsList& getRepCreationArgsList() const
{ return fRepCreationArgsList; }
private:
friend class AssemblyDefinitionFileCache;
struct Deleter { void operator()(Entry* entry); };
Entry(const std::string& defnFile,
const Timestamp& timestamp,
const RepCreationArgsList& repCreationArgsList)
: fDefnFile( defnFile),
fTimestamp( timestamp),
fRepCreationArgsList( repCreationArgsList)
{}
const Timestamp& getTimestamp() const
{ return fTimestamp; }
std::string fDefnFile;
Timestamp fTimestamp;
RepCreationArgsList fRepCreationArgsList;
};
typedef ADSTD::shared_ptr<Entry> EntryPtr;
static AssemblyDefinitionFileCache& getInstance();
EntryPtr
get(
const MString& defnFile);
EntryPtr insert(
const MString& defnFile,
const RepCreationArgsList& repCreationArgsList);
private:
typedef ADSTD::unordered_map<std::string, ADSTD::weak_ptr<Entry> > Entries;
Entries fEntries;
};
#endif