imgtools/romtools/rofsbuild/inc/cache/cache.hpp
changeset 600 6d08f4a05d93
equal deleted inserted replaced
599:fa7a3cc6effd 600:6d08f4a05d93
       
     1 /**
       
     2  * @file cache.hpp
       
     3  */
       
     4 
       
     5 
       
     6 #ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHE_H_
       
     7 #define ROM_TOOLS_ROFSBUILD_CACHE_CACHE_H_
       
     8 
       
     9 
       
    10 #define BOOST_FILESYSTEM_NO_DEPRECATED
       
    11 
       
    12 
       
    13 /**
       
    14  * @class Cache
       
    15  * @brief Cache
       
    16  */
       
    17 class Cache
       
    18 {
       
    19 public:
       
    20 	/**
       
    21 	 * @fn static Cache* Cache::GetInstance(void)
       
    22 	 * @brief Retrieve singleton instance of class Cache.
       
    23 	 * @return The singleton instance.
       
    24 	 */
       
    25 	static Cache* GetInstance(void) throw (CacheException);
       
    26 
       
    27 	/**
       
    28 	 * @fn void Cache::Initialize(path* CacheRoot)
       
    29 	 * @brief Load Cache meta data file and initialize inner structures.
       
    30 	 * @exception CacheException I/O operation failures or resource allocation failures.
       
    31 	 */
       
    32 	void Initialize(void) throw (CacheException);
       
    33 
       
    34 	/**
       
    35 	 * @fn CacheEntry Cache::GetEntryList(const char* OriginalFilename)
       
    36 	 * @param OriginalFilename The filename of original executable which is being cached.
       
    37 	 * @return A list of cached items for the original executables or NULL if there's no entries match the original filename.
       
    38 	 */
       
    39 	CacheEntry* GetEntryList(const char* OriginalFilaname);
       
    40 
       
    41 	/**
       
    42 	 * @fn void Cache::SetEntry(const char* OriginalFilename, CacheEntry* EntryRef)
       
    43 	 * @brief Add a new cache entry into cache or update an existing cache entry.
       
    44 	 * @param OriginalFilename The filename of the original executable file.
       
    45 	 * @param EntryRef The address pointing to an instance of class CacheEntry, must be valid, verified by the caller.
       
    46 	 */
       
    47 	void AddEntry(const char* OriginalFilename, CacheEntry* EntryRef);
       
    48 
       
    49 	/**
       
    50 	 * @fn void Cache::CloseCache(void)
       
    51 	 * @brief Update cache with all cache entries.
       
    52 	 * @exception CacheException Catch errors occurring when the Cache gets updated.
       
    53 	 */
       
    54 	void CloseCache(void) throw (CacheException);
       
    55 protected:
       
    56 	bool ValidateEntry(std::string& EntryRawText);
       
    57 
       
    58 	static Cache* Only;
       
    59 
       
    60 	std::string metafile;
       
    61 
       
    62 	boost::mutex cachemutex;
       
    63 
       
    64 	std::map<std::string, CacheEntry*> entrymap;
       
    65 private:
       
    66 	Cache(void);
       
    67 
       
    68 	Cache(const Cache&);
       
    69 
       
    70 	Cache& operator = (const Cache&);
       
    71 };
       
    72 
       
    73 
       
    74 #endif  /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHE_H_ */