8#ifndef COVR_FILE_MANAGER_H
9#define COVR_FILE_MANAGER_H
23#include <util/coExport.h>
29#include <osg/Texture2D>
30#include <osgDB/ReadFile>
33#include <vrb/client/SharedState.h>
61class coTUIFileBrowserButton;
69 Url(
const std::string &url);
71 static std::string
decode(
const std::string &str,
bool path=
false);
73 std::string
str()
const;
74 operator std::string()
const;
82 const std::string &
path()
const;
83 const std::string &
query()
const;
91 std::string m_authority;
92 bool m_haveAuthority =
false;
93 std::string m_userinfo;
98 std::string m_fragment;
106 int (*loadUrl)(
const Url &url, osg::Group *parent,
const char *covise_key);
107 int (*loadFile)(
const char *filename, osg::Group *parent,
const char *covise_key);
108 int (*unloadFile)(
const char *filename,
const char *covise_key);
116 friend struct LoadedFile;
134 std::string
findOrGetFile(
const std::string &fileName,
bool *isTmp = (
bool *)
false);
161 osg::ref_ptr<osgText::Font>
loadFont(
const char *fontname);
206 std::string
remoteFetch(
const std::string &filePath,
int fileOwner = -1);
215 int coLoadFontDefaultStyle();
217 bool remoteFetchEnabled =
false;
219 std::string remoteFetchPath;
220 std::string viewPointFile;
222 std::unique_ptr<ui::Owner> m_owner;
223 ui::Group *m_fileGroup =
nullptr;
224 int uniqueNumber = 0;
226 typedef std::list<const FileHandler *> FileHandlerList;
227 FileHandlerList fileHandlerList;
229 typedef std::list<coVRIOReader *> IOReaderList;
230 IOReaderList ioReaderList;
232 typedef std::map<std::string, osg::ref_ptr<osg::Texture2D> > TextureMap;
233 TextureMap textureList;
234 std::map<std::string, coTUIFileBrowserButton *> fileFBMap;
237 struct IOReadOperation
246 std::string filename;
250 typedef std::map<std::string, std::list<IOReadOperation> > ReadOperations;
251 ReadOperations readOperations;
254 LoadedFile *m_lastFile =
nullptr;
255 LoadedFile *m_loadingFile =
nullptr;
256 std::map<std::string, LoadedFile *> m_files;
257 typedef std::pair<std::string, int> fileOwner;
259 typedef std::vector<fileOwner> fileOwnerList;
261 void loadPartnerFiles();
263 bool operator()(
const std::string& first,
const std::string& second) {
264 return first.size() > second.size();
269 void getSharedDataPath();
270 std::string m_sharedDataLink;
272 void convertBackslash(std::string &path);
274 std::string cutFileName(
const std::string & filePath);
276 std::string reduceToAlphanumeric(
const std::string & str);
279 std::string writeFile(
const std::string& fileName,
const char* content,
int size);
281 int guessFileOwner(
const std::string& filePath);
282 bool serializeFile(
const std::string& fileName, covise::TokenBuffer& tb);
283 std::vector<covise::Message*> m_sendFileMessages;
288 static std::string
cutStringAt(
const std::string &s,
char delimiter);
291 osg::ref_ptr<osgDB::ReaderWriter::Options>
options;
Definition: ARToolKit.h:33
Definition: coClusterStat.h:29
Definition: coTabletUI.h:51
Definition: coVRFileManager.h:44
Definition: coTabletUI.h:277
Definition: coVRFileManager.h:67
static Url fromFileOrUrl(const std::string &furl)
const std::string & query() const
const std::string & scheme() const
const std::string & path() const
static std::string decode(const std::string &str, bool path=false)
std::string extension() const
Url(const std::string &url)
const std::string & fragment() const
const std::string & authority() const
Definition: coVRFileManager.h:105
const char * extension
Definition: coVRFileManager.h:109
Definition: coVRFileManager.h:115
const FileHandler * getFileHandler(const char *extension)
coTUIFileBrowserButton * getMatchingFileBrowserInstance(std::string keyFileName)
void sendFile(covise::TokenBuffer &tb)
int registerFileHandler(const FileHandler *handler)
bool makeRelativeToSharedDataLink(std::string &fileName)
coVRIOReader * findIOHandler(const char *extension)
std::string getFontFile(const char *fontname)
std::string findFileExt(const Url &url)
std::string getWriteFilterList()
const FileHandler * findFileHandler(const char *extension)
osg::ref_ptr< osgText::Font > loadFont(const char *fontname)
static coVRFileManager * instance()
void setViewPointFile(const std::string &viewPointFile)
osg::Node * loadIcon(const char *filename)
std::string getViewPointFile()
bool isInTmpDir(const std::string &fileName)
int getFileId(const char *url)
compares the url with m_sharedFiles. If found returns its position in, else -1;
osg::Texture2D * loadTexture(const char *texture)
osg::Node * loadFile(const char *file, coTUIFileBrowserButton *fb=NULL, osg::Group *parent=NULL, const char *covise_key="")
std::string remoteFetch(const std::string &filePath, int fileOwner=-1)
request the file from vrb -> file gets copied to tmp
int unregisterFileHandler(const FileHandler *handler)
std::string findOrGetFile(const std::string &fileName, bool *isTmp=(bool *) false)
osg::ref_ptr< osgDB::ReaderWriter::Options > options
Definition: coVRFileManager.h:291
int registerFileHandler(coVRIOReader *handler)
static std::string cutStringAt(const std::string &s, char delimiter)
return the substring of s until the delimiter(delimiter is cut off)
bool fileExist(const std::string &fileName)
const char * getName(const char *file)
std::string getFilterList()
osg::Node * replaceFile(const char *file, coTUIFileBrowserButton *fb=NULL, osg::Group *parent=NULL, const char *covise_key="")
const char * buildFileName(const char *)
void unloadFile(const char *file=NULL)
bool makeRelativePath(std::string &fileName, const std::string &basePath)
std::string getFileName(const std::string &filePath)
get the filename + extension from a path: path/fileName -> fileName
int unregisterFileHandler(coVRIOReader *handler)
static std::string resolveEnvs(const std::string &s)
replaces all occurences of environmentvariables (env$ on win or $env/ on unix) with the first entry (...
void SetDefaultFB(coTUIFileBrowserButton *fb)
bool fileExist(const char *fileName)
Definition: coVRIOReader.h:21
objects that are derived from this class are called once per frame
Definition: coUpdateManager.h:20