-  [WT]  [PS]  [Home] [Manage]

Posting mode: Reply
  1.   (reply to 5091)
  2. (for post and file deletion)
/pr/ - Programming
  • Supported file types are: C, CSS, DOC, DOCX, GIF, H, JAVA, JPG, PDF, PNG, SVG, SWF, TXT, WEBM
  • Maximum file size allowed is 10000 KB.
  • Images greater than 200x200 pixels will be thumbnailed.
  • Currently 389 unique user posts. View catalog

  • Blotter updated: 2011-01-12 Show/Hide Show All

There's a new /777/ up, it's /gardening/ Check it out. Suggest new /777/s here.

Movies & TV 24/7 via Channel7: Web Player, .m3u file. Music via Radio7: Web Player, .m3u file.

WebM is now available sitewide! Please check this thread for more info.

Request for comments Neckbearded Basement Dweller 18/01/02(Tue)02:39 No. 5091

File 15148571617.jpg - (29.41KB , 331x400 , confused1.jpg )

I'm hacking up a dynamic class loader, and I have all of the easy stuff done (dlfcn, dirent, etc.).
So the manager needs to know which container to construct based off the extension of the file that needs to be passed to the containers constructor.

The question then is: should I have the container shared object advertise which file extensions are supported or should I have it advertise a mime type?

My concern with using the mime type is that I would need a mapping from file extensions to mime type.
And my concern with using just the file extension is that there may be extension collisions.

Neckbearded Basement Dweller 18/01/06(Sat)01:24 No. 5092

Incase anyone is interested, I decided to implement the code analagous to the following pseudo-code:

for ( auto module : modules.equal_range( input ) ) {
try { auto module_class = module.second.constructor( input );
return std::unique_ptr< Module >( module_class );
} catch ( exception e ) { }

I let the modules advertise what inputs they support and use that do decide which loaded modules to attempt to create. In documentation I require that the module throw an exception if the input is not supported, or fails to load. I'll deal with the other issues related to that as I think of them.

Delete post []
Report post