|
|
GridFileManager provides utility functions for working with files in Mongo GridFS and links to them stored in entity attributes (s. More...
#include <MemoryX/core/GridFileManager.h>
Inheritance diagram for GridFileManager:Public Member Functions | |
| std::string | addFileToAttr (const std::string &filesDBName, const std::string &localFileName, EntityAttributeBasePtr &fileAttr, const std::string &gridFSName="") |
| Stores a file in GridFS and puts a reference to it into entity attribute. More... | |
| bool | ensureFileInCache (const EntityAttributeBasePtr &fileAttr, std::string &cacheFileName, bool preserveOriginalName=false) |
| Caches the file locally and returns the filename. More... | |
| bool | ensureFileInCache (GridFileInterfacePrx &filePrx, std::string &cacheFileName, bool preserveOriginalName=false) |
| Caches the file locally and returns the filename. More... | |
| bool | ensureFilesInCache (const EntityAttributeBasePtr &fileAttr, bool preserveOriginalNames=false) |
| Caches multiple files locally. More... | |
| bool | ensureFilesInCache (const EntityAttributeBasePtr &fileAttr, std::vector< std::string > &cacheFileNames, bool preserveOriginalNames=false) |
| Caches multiple files locally. More... | |
| CommonStorageInterfacePrx | getDBPrx () const |
| std::string | getFileCachePath () const |
| Retrieves a local path where files will be cached. More... | |
| bool | getFileStream (const EntityAttributeBasePtr &fileAttr, std::ifstream &fs) |
| Caches the file locally and opens a filestream for it. More... | |
| bool | getFileStream (GridFileInterfacePrx &filePrx, std::ifstream &fs) |
| Caches the file locally and opens a filestream for it. More... | |
| GridFileManager (const CommonStorageInterfacePrx &databasePrx) | |
| Constructs new GridFileManager. More... | |
| GridFileManager (const CommonStorageInterfacePrx &databasePrx, const std::string &cachePath) | |
| Constructs new GridFileManager. More... | |
| bool | removeAttrDirectory (const EntityAttributeBasePtr &fileAttr) |
| Removes GridFS directory referenced by entity attribute. More... | |
| bool | removeAttrFile (const EntityAttributeBasePtr &fileAttr, unsigned int fileIndex) |
| bool | removeAttrFiles (const EntityAttributeBasePtr &fileAttr) |
| Removes all GridFS files referenced by entity attribute. More... | |
| bool | storeDirectoryToAttr (const std::string &filesDBName, const std::string &localDirectoryName, EntityAttributeBasePtr &fileAttr, std::string excludeFilter=".svn") |
| Stores a complete directory tree in GridFS and puts a reference to it into entity attribute Overwrites any previously stored attribute. More... | |
| bool | storeFilesToAttr (const std::string &filesDBName, const std::string &localBaseDirectoryName, const std::vector< std::string > &localFiles, EntityAttributeBasePtr &fileAttr) |
| Stores a set of files with in GridFS and puts a reference to it into entity attribute. More... | |
| std::string | storeFileToAttr (const std::string &filesDBName, const std::string &localFileName, EntityAttributeBasePtr &fileAttr, const std::string &gridFSName="") |
| Stores a file in GridFS and puts a reference to it into entity attribute. More... | |
| ~GridFileManager () override | |
Public Member Functions inherited from Logging | |
| SpamFilterDataPtr | deactivateSpam (float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const |
| disables the logging for the current line for the given amount of seconds. More... | |
| MessageTypeT | getEffectiveLoggingLevel () const |
| Logging () | |
| void | setLocalMinimumLoggingLevel (MessageTypeT level) |
| With setLocalMinimumLoggingLevel the minimum verbosity-level of log-messages can be set. More... | |
| void | setTag (const LogTag &tag) |
| void | setTag (const std::string &tagName) |
| virtual | ~Logging () |
Protected Member Functions | |
| void | init (std::string cachePath) |
Protected Member Functions inherited from Logging | |
| bool | checkLogLevel (MessageTypeT level) const |
| const LogSenderPtr & | getLogSender () const |
| Retrieve log sender. More... | |
| LogSenderPtr | loghelper (const char *file, int line, const char *function) const |
Additional Inherited Members | |
Protected Attributes inherited from Logging | |
| MessageTypeT | minimumLoggingLevel |
| SpamFilterDataPtr | spamFilter |
| LogTag | tag |
GridFileManager provides utility functions for working with files in Mongo GridFS and links to them stored in entity attributes (s.
Definition at line 41 of file GridFileManager.h.
| GridFileManager | ( | const CommonStorageInterfacePrx & | databasePrx | ) |
Constructs new GridFileManager.
GridFileManager needs a MongoDB connection, so CommonStorage proxy needs to be specified. Cache path for files is retrived from the Application properties.
| databasePrx | CommonStorage proxy. It can be obtained either directly or via getCommonStorage() method of WorkingMemory and PriorKnowledge. |
Definition at line 44 of file GridFileManager.cpp.
Here is the call graph for this function:| GridFileManager | ( | const CommonStorageInterfacePrx & | databasePrx, |
| const std::string & | cachePath | ||
| ) |
Constructs new GridFileManager.
GridFileManager needs a MongoDB connection, so CommonStorage proxy needs to be specified. Use this constructor, if you want to provide an own cache path.
| databasePrx | CommonStorage proxy. It can be obtained either directly or via getCommonStorage() method of WorkingMemory and PriorKnowledge. |
| cachePath | Path where to store cache files. Path may contain environmenta variables, which get replaced by their value. |
Definition at line 61 of file GridFileManager.cpp.
Here is the call graph for this function:
|
override |
Definition at line 68 of file GridFileManager.cpp.
| std::string addFileToAttr | ( | const std::string & | filesDBName, |
| const std::string & | localFileName, | ||
| EntityAttributeBasePtr & | fileAttr, | ||
| const std::string & | gridFSName = "" |
||
| ) |
Stores a file in GridFS and puts a reference to it into entity attribute.
Allows to add multiple files to an attribdatabasePrxute.
| filesDBName | Mongo database name to store file into |
| localFileName | name of a file to store (gets turned into an absolute path) |
| fileAttr | entity attribute to store file reference into |
| gridFSName | name of the file in GridFS. Default: localFileName WITHOUT path |
Definition at line 276 of file GridFileManager.cpp.
Here is the caller graph for this function:| bool ensureFileInCache | ( | const EntityAttributeBasePtr & | fileAttr, |
| std::string & | cacheFileName, | ||
| bool | preserveOriginalName = false |
||
| ) |
Caches the file locally and returns the filename.
| fileAttr | entity attribute containing a file reference |
| cacheFileName | name of local file |
| preserveOriginalName | whether file should be saved under its original GridFS name (true) or or it could be given a special name to simplify modification check (false). Even though the latter option is preferred, sometimes original names must be preserved because of links between files (e.g. textures in .iv file) |
Definition at line 183 of file GridFileManager.cpp.
Here is the call graph for this function:| bool ensureFileInCache | ( | GridFileInterfacePrx & | filePrx, |
| std::string & | cacheFileName, | ||
| bool | preserveOriginalName = false |
||
| ) |
Caches the file locally and returns the filename.
| filePrx | file proxy |
| cacheFileName | name of local file |
| preserveOriginalName | whether file should be saved under its original GridFS name (true) or or it could be given a special name to simplify modification check (false). Even though the latter option is preferred, sometimes original names must be preserved because of links between files (e.g. textures in .iv file) |
Definition at line 107 of file GridFileManager.cpp.
Here is the caller graph for this function:| bool ensureFilesInCache | ( | const EntityAttributeBasePtr & | fileAttr, |
| bool | preserveOriginalNames = false |
||
| ) |
Caches multiple files locally.
Version without returning the cache file names
| fileAttr | entity attribute containing file references |
| preserveOriginalName | whether file should be saved under its original GridFS name (true) or or it could be given a special name to simplify modification check (false). Even though the latter option is preferred, sometimes original names must be preserved because of links between files (e.g. textures in .iv file) |
Definition at line 231 of file GridFileManager.cpp.
Here is the call graph for this function:| bool ensureFilesInCache | ( | const EntityAttributeBasePtr & | fileAttr, |
| std::vector< std::string > & | cacheFileNames, | ||
| bool | preserveOriginalNames = false |
||
| ) |
Caches multiple files locally.
| fileAttr | entity attribute containing file references |
| cacheFileNames | names of caches files |
| preserveOriginalName | whether file should be saved under its original GridFS name (true) or or it could be given a special name to simplify modification check (false). Even though the latter option is preferred, sometimes original names must be preserved because of links between files (e.g. textures in .iv file) |
Definition at line 203 of file GridFileManager.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 241 of file GridFileManager.h.
| std::string getFileCachePath | ( | ) | const |
Retrieves a local path where files will be cached.
Definition at line 101 of file GridFileManager.cpp.
| bool getFileStream | ( | const EntityAttributeBasePtr & | fileAttr, |
| std::ifstream & | fs | ||
| ) |
Caches the file locally and opens a filestream for it.
| fileAttr | entity attribute containing a file reference |
| fs | file stream to open. |
Definition at line 256 of file GridFileManager.cpp.
Here is the call graph for this function:| bool getFileStream | ( | GridFileInterfacePrx & | filePrx, |
| std::ifstream & | fs | ||
| ) |
Caches the file locally and opens a filestream for it.
| filePrx | file proxy |
| fs | file stream to open. |
Definition at line 240 of file GridFileManager.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Definition at line 73 of file GridFileManager.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| bool removeAttrDirectory | ( | const EntityAttributeBasePtr & | fileAttr | ) |
Removes GridFS directory referenced by entity attribute.
| fileAttr | entity attribute containing file reference(s) |
| bool removeAttrFile | ( | const EntityAttributeBasePtr & | fileAttr, |
| unsigned int | fileIndex | ||
| ) |
| bool removeAttrFiles | ( | const EntityAttributeBasePtr & | fileAttr | ) |
Removes all GridFS files referenced by entity attribute.
| fileAttr | entity attribute containing file reference(s) |
Definition at line 400 of file GridFileManager.cpp.
Here is the call graph for this function:| bool storeDirectoryToAttr | ( | const std::string & | filesDBName, |
| const std::string & | localDirectoryName, | ||
| EntityAttributeBasePtr & | fileAttr, | ||
| std::string | excludeFilter = ".svn" |
||
| ) |
Stores a complete directory tree in GridFS and puts a reference to it into entity attribute Overwrites any previously stored attribute.
| filesDBName | Mongo database name to store file into |
| localDirectoryName | name of a directory to store |
| fileAttr | entity attribute to store file reference into |
Definition at line 319 of file GridFileManager.cpp.
Here is the call graph for this function:| bool storeFilesToAttr | ( | const std::string & | filesDBName, |
| const std::string & | localBaseDirectoryName, | ||
| const std::vector< std::string > & | localFiles, | ||
| EntityAttributeBasePtr & | fileAttr | ||
| ) |
Stores a set of files with in GridFS and puts a reference to it into entity attribute.
The directory structure is preserved while localBaseDirectoryName and all preceding directories are removed from the filenames. Overwrites any previously stored attribute.
| filesDBName | Mongo database name to store file into |
| localBaseDirectoryName | the base directory. All file names will be made realtive to this directory |
| localFiles | The set of files. Absolute filenames. |
| fileAttr | entity attribute to store file reference into |
Definition at line 361 of file GridFileManager.cpp.
Here is the call graph for this function:| std::string storeFileToAttr | ( | const std::string & | filesDBName, |
| const std::string & | localFileName, | ||
| EntityAttributeBasePtr & | fileAttr, | ||
| const std::string & | gridFSName = "" |
||
| ) |
Stores a file in GridFS and puts a reference to it into entity attribute.
Overwrites any previously stored attribute.
| filesDBName | Mongo database name to store file into |
| localFileName | name of a file to store |
| fileAttr | entity attribute to store file reference into |
| gridFSName | name of the file in GridFS. Default: localFileName WITHOUT path |
Definition at line 266 of file GridFileManager.cpp.
Here is the call graph for this function: