Files
source/VFS/Interface/vfs_location_interface.h
T
Wanne 14750c6903 **********************************************************
** Big Maps Projects code (incl. Multiplayer v1.5 **
**********************************************************
- Merged Big Maps Project code from BMP+MP trunk (Revision: 3340)
o Complete SVN Revision history: https://81.169.133.124/source/ja2/branches/Wanne/JA2%201.13%20MP
- Before THIS merge, I made a branch of the existing 1.13 source
o SVN Branch: https://81.169.133.124/source/ja2/branches/JA2_rev.3336/src
- Removed old VS 6.0 and VS 2003 project and solutions files, because compilation is broken long time ago
- I will add VS 2010 projects and solution file in the next few days

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@3341 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2010-02-28 18:38:52 +00:00

138 lines
3.6 KiB
C++

#ifndef _VFS_LOCATION_INTERFACE_H_
#define _VFS_LOCATION_INTERFACE_H_
#include "../vfs_types.h"
#include "../vfs_debug.h"
#include "vfs_file_interface.h"
#include "vfs_iterator_interface.h"
#include <map>
#include <list>
#include <typeinfo>
namespace vfs
{
class VFS_API IBaseLocation
{
public:
typedef TIterator<vfs::IBaseFile> Iterator;
virtual ~IBaseLocation()
{};
virtual bool implementsWritable() = 0;
virtual bool implementsReadable() = 0;
virtual vfs::Path const& getPath() = 0;
virtual bool fileExists(vfs::Path const& sFileName) = 0;
virtual vfs::IBaseFile* getFile(vfs::Path const& sFileName) = 0;
virtual Iterator begin() = 0;
virtual void getSubDirList(std::list<vfs::Path>& rlSubDirs) = 0;
};
/**
* TVFSLocation
*/
template<typename ReadType, typename WriteType>
class VFS_API TLocationTemplate : public IBaseLocation
{
public:
typedef vfs::TLocationTemplate<ReadType,WriteType> tLocationType;
typedef vfs::TFileTemplate<ReadType,WriteType> tFileType;
typedef ReadType tReadType;
typedef WriteType tWriteType;
typedef std::list<std::pair<tFileType*,vfs::Path> > tListFilesWithPath;
public:
TLocationTemplate(vfs::Path const& mountPoint)
: m_mountPoint(mountPoint)
{};
virtual ~TLocationTemplate()
{};
// has to be virtual , or the types of the caller (not the real object) will be tested
virtual bool implementsWritable()
{
return typeid(tWriteType) == typeid(vfs::IWritable);
}
virtual bool implementsReadable()
{
return typeid(tReadType) == typeid(vfs::IReadable);
}
vfs::Path const& getMountPoint()
{
return m_mountPoint;
}
/**
* TLocationTemplate interface
*/
virtual vfs::Path const& getPath()
{
return m_mountPoint;
}
virtual bool fileExists(vfs::Path const& sFileName) = 0;
virtual vfs::IBaseFile* getFile(vfs::Path const& sFileName) = 0;
virtual tFileType* getFileTyped(vfs::Path const& rFileName) = 0;
protected:
vfs::Path m_mountPoint;
};
/**************************************************************************************/
/**************************************************************************************/
template<typename WriteType=vfs::IWriteType>
class TReadLocation : public TLocationTemplate<IReadable,WriteType>
{
public:
typedef TReadLocation<WriteType> tLocationType;
static tLocationType* cast(vfs::IBaseLocation* bl)
{
if(bl && bl->implementsReadable())
{
return static_cast<tLocationType*>(bl);
}
return NULL;
}
public:
TReadLocation(vfs::Path const& sLocalPath)
: vfs::TLocationTemplate<IReadable,WriteType>(sLocalPath)
{};
virtual ~TReadLocation(){};
};
template<typename ReadType=vfs::IReadType>
class TWriteLocation : public vfs::TLocationTemplate<ReadType,vfs::IWritable>
{
public:
typedef TWriteLocation<ReadType> tLocationType;
static tLocationType* cast(vfs::IBaseLocation* bl)
{
if(bl && bl->implementsWritable())
{
return static_cast<tLocationType*>(bl);
}
return NULL;
}
public:
TWriteLocation(vfs::Path const& sLocalPath)
: vfs::TLocationTemplate<ReadType,vfs::IWritable>(sLocalPath)
{};
virtual ~TWriteLocation(){};
};
/**************************************************************************************/
/**************************************************************************************/
typedef TReadLocation<vfs::IWriteType> tReadLocation;
typedef TWriteLocation<vfs::IReadType> tWriteLocation;
} // end namespace
#endif // _VFS_LOCATION_INTERFACE_H_