   threaded Plugable FileManager aproach?
  well I have created a singelton FileManager that has the ability to load files that are registerd through a cCodec class.the fileManager alone can''t load any files at all.. it needs a codec or several.whenever the FileManager::Load(..) is called then it will check the fileType (the letters after the last dot e.g. tga for "bluebox.tga" ) with registerd codecs if there is a match then it will use that codec to load the file.works something like thiscImage *MyImage = (cImage*)cFileManager::Create()->Load("BlueBox.tga");Source:   /** pure virtual file codec*/class cCodec { public: virtual char *GetFileType(void) = 0; virtual void *Load(char *FileName) = 0;};/** The FileManager*/class cFileManager{ // Singelton stuff static cFileManager m_Instance; cFileManager (void); // Codec list list<cCodec*> Codecs;public: static cFileManager *Create(void); // Singelton stuff void Register( cCodec *codec ) { Codecs.push_back(codec); }; void *Load(char *FileName);};to create a codec for a file this aproach is used:   class cCodecTGA : public cCodec { // private stuff for Tga file loading, if needed. ...public: char *GetFileType(void) { return "tga"; } void *Load(char *FileName);};the thing I want to do now is to create my fileManager Multi threaded, the load-process in a single thread. so I can queue several files then call a function to load all the files at once in another thread, to leave the main-thread to do something else while loading.. altough I don''t really know how to pass the pointers around?! becouse this line:cImage *MyImage = (cImage*)cFileManager::Create()->Queue("BlueBox.tga");will not return the loaded image becouse it hasn''t been loaded yet need to call the LoadAllFiles() function first... but then how do I know where the image has been loaded? 
  perhaps to the filemanager create function....you can pass in a callback function or something to let you know when that file was finished loading and have it pass to your callback function the memory location of the loaded file....orrrrin the filemanage create function have the filemanager return an id number instead of a memory location.....internally the filemanager will pair up id #s with their associated file.....now when you want access to the file later after it is loaded you give the filemanager the id number and it will return to you the memory location.....but how do we know when the file is finished loading ?something like int id = filemanager->create("naked chick.bmp");load other stuff herefilemanage->loadAllFiles();. do some more stuff.while (!filemanage->finishedLoading(id)){  Sleep(1) or process other stuff}unsigned char* imageLocation = filemanage->fileLocation(id);understand what i am saying ? "A soldier is a part of the 1% of the population that keeps the other 99% free"  - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA ;  sorry, I don't answer your main question, but:quote:whenever the FileManager::Load(..) is called then it will check the fileType (the letters after the last dot e.g. tga for "bluebox.tga" ) with registerd codecs if there is a match then it will use that codec to load the file.you can improve that a lot... something better to do would be to check the file headers, not only the file type.if you've got your codecs in a DLL, export a function that will tell if the codec can read the file or not.then for text files just do:BOOL is_file_supported(char *path){  if (!strcasecmp(get_extension(path), "txt"))    return (TRUE);  return (FALSE);}   and for some binary file codec:BOOL is_file_supported(char *path){  FILE *fp;  if (!(fp = fopen(path, rb)))    return (FALSE);  return (is_header_valid(fp));}  so let your codecs decide how they check if the file is valid, and for binary files codecs, use the file header instead of the extension.the gimp checks the file formats using the file headers, and it is IMO a really nice technique  [edited by - sBibi on February 2, 2004 8:26:22 AM];  Thanks for the answers I havn''t thought about the "File-header-check" thing. that could be usefull.. but still isn''t there any other aproach to get the loaded data then using ID''s?;  perhaps in your loadFile() function you return a pointer to the area in memory where it is loaded toopen up the file to be loaded or at least figure out how much memory that you need to allocate for the file....allocate that storage area then create the thread to load it in.pass to the thread the memory area that you allocated so it can fill it up with the data from the filenow while that thread goes off and does its own thing, return to the user a pointer to that same memory area where the file is being loaded to by that other threadnow you still have the trick of needing to know when the thread is done loading the file so that you can make sure you are accessing valid datathat is the part i leave to you./....... "A soldier is a part of the 1% of the population that keeps the other 99% free"  - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA ;  With ID''s you could return one when you ''register'' the file, then have a second function that you call to actualise the ID, which would either return the already loaded reference or load the resource & block until that operation is complete ;  well.. about the Valid-data-check I have been thinking.. if I create some kind of engine-states for my engine so whenever a state-change is made the engine checks if there is any files that needs to be loaded if so then the engine goes into STATE_LOADING so every thing that all files are loaded before going into next state then when the loading process is done the engine goes into the state it was going into the first place..