imgtools/romtools/rofsbuild/inc/cache/cachemanager.hpp
changeset 607 378360dbbdba
parent 600 6d08f4a05d93
equal deleted inserted replaced
591:22486c9c7b15 607:378360dbbdba
       
     1 /**
       
     2  * @file cachemanager.hpp
       
     3  */
       
     4 
       
     5 
       
     6 #ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEMANAGER_H_
       
     7 #define ROM_TOOLS_ROFSBUILD_CACHE_CACHEMANAGER_H_
       
     8 
       
     9 
       
    10 #define BOOST_FILESYSTEM_NO_DEPRECATED
       
    11 
       
    12 
       
    13 /**
       
    14  * @class CacheManager
       
    15  * @brief Managing cache content and the processing of generating/updating cache.
       
    16  * @note CacheManager will accept forward slashes as file separators and all input filenames will be normalized.
       
    17  */
       
    18 class CacheManager
       
    19 {
       
    20 public:
       
    21 	/**
       
    22 	 * @fn static CacheManager* CacheManager::GetInstance(void)
       
    23 	 * @brief This method is thread-safe as it's using double-check pattern for singleton creation.
       
    24 	 * @exception CacheException Catch initialization failures.
       
    25 	 * @return Retrieve the singleton instance of class CacheManager.
       
    26 	 */
       
    27 	static CacheManager* GetInstance(void) throw (CacheException);
       
    28 
       
    29 	/**
       
    30 	 * @fn E32ImageFile* CacheManager::GetE32ImageFile(char* Filename, int CurrentCompressionID)
       
    31 	 * @brief Retrieve an instance of class E32ImageFile.
       
    32 	 * @param OriginalFilename The filename of the original file.
       
    33 	 * @param CurrentCompressionID The ID of compression method used over current image build.
       
    34 	 * @return Instance of class E32ImageFile or NULL if the original file has not been cached yet.
       
    35 	 */
       
    36 	E32ImageFile* GetE32ImageFile(char* OriginalFilename, int CurrentCompressionID);
       
    37 
       
    38 	/**
       
    39 	 * @fn CacheEntry* CacheManager::GetE32ImageFileRepresentation(char* OriginalFilename, int CurrentCompressionID, int FileFlags)
       
    40 	 * @param OriginalFilename The filename of the original executable file.
       
    41 	 * @param CurrentCompressionID
       
    42 	 * @return A valid cached entry or NULL if the original file has not been cached yet.
       
    43 	 */
       
    44 	CacheEntry* GetE32ImageFileRepresentation(char* OriginalFilename, int CurrentCompressionID);
       
    45 
       
    46 	/**
       
    47 	 * @fn void CacheManager::Invalidate(const char* Filename)
       
    48 	 * @brief Add an invalidated cache entry into the cacheable list.
       
    49 	 * @param Filename The filename of the original file.
       
    50 	 * @param EntryRef The reference of newly created CacheEntry instance.
       
    51 	 * @exception CacheException Catch resource allocation failures.
       
    52 	 */
       
    53 	void Invalidate(char* Filename, CacheEntry* EntryRef) throw (CacheException);
       
    54 
       
    55 	/**
       
    56 	 * @fn void CacheManager::CleanCache(void)
       
    57 	 * @brief Remove all cache content from hard drive.
       
    58 	 * @exception CacheException Catch I/O failures on deletion.
       
    59 	 */
       
    60 	void CleanCache(void) throw (CacheException);
       
    61 
       
    62 	/**
       
    63 	 * @fn const char* CacheManager::GetCacheRoot(void)
       
    64 	 * @brief Retrieve the root directory of cache.
       
    65 	 * @return The absolute path of root directory.
       
    66 	 */
       
    67 	const char* GetCacheRoot(void);
       
    68 
       
    69 	/**
       
    70 	 * @fn CacheManager::~CacheManager(void)
       
    71 	 * @brief Clean up allocated resources and writes Cache class back in the cache.
       
    72 	 * @note It's important to delete CacheManager instance if you created it with new operation.
       
    73 	 */
       
    74 	virtual ~CacheManager(void);
       
    75 
       
    76 	/**
       
    77 	 * @fn void CacheManager::NormalizeFilename(char* Filename)
       
    78 	 * @brief Convert back slashes into forward slashes and remove redundant slashes.
       
    79 	 * @param Filename The filename which will be normalized when this function gets returned.
       
    80 	 */
       
    81 	void NormalizeFilename(char* Filename);
       
    82 protected:
       
    83 	void InitializeCache(void) throw (CacheException);
       
    84 
       
    85 	char* cacheroot;
       
    86 
       
    87 	static boost::mutex creationlock;
       
    88 
       
    89 	static CacheManager* Only;
       
    90 private:
       
    91 	CacheManager(void);
       
    92 
       
    93 	CacheManager(const CacheManager&);
       
    94 
       
    95 	CacheManager& operator = (const CacheManager&);
       
    96 };
       
    97 
       
    98 
       
    99 #endif  /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEMANAGER_H_ */