Horde3D http://horde3d.org/forums/ |
|
A Minor Redundancy In Resource Declarations http://horde3d.org/forums/viewtopic.php?f=8&t=1584 |
Page 1 of 1 |
Author: | pioneer [ 25.10.2011, 12:18 ] |
Post subject: | A Minor Redundancy In Resource Declarations |
I was recently tasked with designing my own resource class and I noticed you the following in your declaration: Code: class SceneGraphResource : public Resource { public: static Resource *factoryFunc( const std::string &name, int flags ) { return new SceneGraphResource( name, flags ); } And again Code: static Resource *factoryFunc( const std::string &name, int flags ) { return new TextureResource( name, flags ); } What is the purpose of such a repetition when it is clearly a common function to the parent class. The following declaration is valid: Code: template <class Derived> class Resource { public: static Resource *factoryFunc(const std::string& name, int flags) { return new Derived(name, flag); } }; class Texture : public Resource<Texture> {}; While the declaration may looks slightly odd it is part of the curiously recursive template pattern defined in section 16.3 of Templates the complete guide. I have also noticed the following: Code: bool checkDDS( const char *data, int size ); Wouldn't this be more appropriate? Code: bool checkDDS( const char *data, size_t size ); Just some suggestions I came up with after browsing through your code, if you dislike them feel free to provide me with a technical response of why you disagree that is all I am interested in. Thanks for your time. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |