Page 1 of 1

ResourceGroupManager::ResourceGroup impedence mismatch

Posted: Thu Apr 18, 2013 9:05 pm
by Mikachu
Hi,

2 public methods in ResourceGroupManager use protected struct ResourceGroupManager::ResourceGroup in their arguments :

Code: Select all

   /** Find out if the named file exists in a group. 
        @param group Pointer to the resource group
        @param filename Fully qualified name of the file to test for
        */
        bool resourceExists(ResourceGroup* group, const String& filename);

....

	/** Retrieve the modification time of a given file */
		time_t resourceModifiedTime(ResourceGroup* group, const String& filename); 
Those 2 methods should be made protected as well, or ResourceGroupManager::ResourceGroup should be public...

Actually, I don't know why the compiler is letting this happen :wink:

Re: ResourceGroupManager::ResourceGroup impedence mismatch

Posted: Fri Apr 19, 2013 12:07 am
by masterfalcon
I don't believe that it matters because it's not an instance but rather the definition of the type. The definition is within the class scope and so class methods have access to those types. I could be wrong and this is just something that compilers just allow. I haven't checked in the C++ spec to verify.

Re: ResourceGroupManager::ResourceGroup impedence mismatch

Posted: Fri Apr 19, 2013 10:40 am
by Mikachu
I've setup a test case here : http://ideone.com/KHkTGT

I think the compiler doesn't throw an error because:
  • the pointer can be null, in which case the caller doesn't need pointer type
  • a pointer to the type can be used by callee if it doesn't explicitely name it, as in the above example
None of the above cases is useful for Ogre, so the fact that the 2 functions are public is misleading.
IMHO, the struct ResourceGroupManager::ResourceGroup should be made public...

Shall I file an issue for this?