Okay, So the Manager template class needs to push_back a type resource_t.. that would be fine and dandy if I could get the Resource_Manager class with the Manager template in it to have the right type! Let me post code to explain my point further..
Code:
#pragma warning(disable: 4786)
#include <vector>
#include "MS3D.H"
#include <map>
class Resource_Cache // The "containers" and their data structures
{
friend class Resource_Manager;
public:
struct MS3DModelRenderData
{
float Position[3]; // will be changed to vectors eventually
float Orientation[3];
MS3DModel *pModel;
};
std::vector<MS3DModelRenderData*> MS3DModels; // holds pointers to all MS3D Models
private:
bool Add_MS3DModel_To_Cache(std::string & Filename); // loads a milkshape model to the cache
};
template < typename resource_t >
class Manager // container managers
{
Resource_Cache Global_Cache;
std::map< std::string , resource_t* > Resources;
public:
bool Check_Existance( const std::string & filename );
void Return_Resource_Reference( const std::string & filename )
{
std::map< std::string , resource_t* >::iterator entry = Resources.find( filename );
if ( entry != Resources.end() ) // if the entry is found
{
Global_Cache.MS3DModels.push_back(entry->second);
}
}
virtual ~Manager( void )
{
std::map< std::string , resource_t * >::iterator destroyer, end;
for ( destroyer = Resources.begin() , end = Resources.end() ; destroyer != end ; ++destroyer )
{
delete destroyer->second;
}
}
};
class Resource_Manager // Global Manager
{
Manager<MS3DModel> Models; <---- needs to be of type MS3DModelRenderData
std::string get_extension(std::string Filename);
public:
void Add_Resource(std::string & Filename)
{
if (get_extension (Filename ) == "ms3d")
{
if (Models.Check_Existance( Filename ) == true )
{
Models.Return_Resource_Reference( Filename );
}
else
{
// GlobalResources.Add_MS3DModel_To_Cache(Filename);
}
}
}
};
The problem with the bolded statement in that code is, well, the manager template class uses an Instance of Resource_Cache, which is GlobalCache...
Now I just can't declare another Global_Cache in Resource_Manager, I'd be trying to work with two different instances of the same thing, that's no good..
How do I keep it so I'm still working with Manager's GlobalCache but make it so I can template Global_Cache.MS3DModelRenderData...
Do I need to do like.. Manager::Global_Cache.MS3DModelRenderData ???
Here is the error btw..
Code:
--------------------Configuration: Resource_Manager - Win32 Debug--------------------
Compiling...
Resource_Manager.cpp
c:\documents and settings\jonathan\my documents\c++ programming\resource_manager\resource_manager.h(40) : error C2664: 'push_back' : cannot convert parameter 1 from 'class MS3DModel *' to 'struct Resource_Cache::MS3DModelRenderData *const & '
Reason: cannot convert from 'class MS3DModel *' to 'struct Resource_Cache::MS3DModelRenderData *const '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\jonathan\my documents\c++ programming\resource_manager\resource_manager.h(36) : while compiling class-template member function 'void __thiscall Manager<class MS3DModel>::Return_Resource_Reference(const class std::ba
sic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)'
Test.cpp
c:\documents and settings\jonathan\my documents\c++ programming\resource_manager\resource_manager.h(40) : error C2664: 'push_back' : cannot convert parameter 1 from 'class MS3DModel *' to 'struct Resource_Cache::MS3DModelRenderData *const & '
Reason: cannot convert from 'class MS3DModel *' to 'struct Resource_Cache::MS3DModelRenderData *const '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\jonathan\my documents\c++ programming\resource_manager\resource_manager.h(36) : while compiling class-template member function 'void __thiscall Manager<class MS3DModel>::Return_Resource_Reference(const class std::ba
sic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)'
Error executing cl.exe.
Creating browse info file...
Resource_Manager.exe - 2 error(s), 0 warning(s)
Hellpp please..