All pastes #773614 Raw Edit

Someone

public text v1 · immutable
·published 2007-11-14 17:47 UTC
rendered paste body
/////////////////////////// Cache.hpp ////////////////////////////////
#include <map>

#include <fstream>



#ifndef CACHE_HPP

#define CACHE_HPP



using namespace std;



template <typename T>

class Cache

{

  private:

    map<int, T*> iDictionary;



  public:

    Cache(char* aFilename);

    ~Cache();



  protected:

    T* page;

    ifstream inputStream;

};



template <typename T>

Cache<T>::Cache(char* aFilename)

{
  inputStream.open(aFilename, ios::binary);

}



template <typename T>

Cache<T>::~Cache()

{
  inputStream.close();

  map<int, T*>::const_iterator itr;
  for(itr = iDictionary.begin(); itr != iDictionary.end(); ++itr)

    delete[] itr->second;

}



#endif

/////////////////////////// CacheReach.hpp ////////////////////////////////
#include "Cache.hpp"



#ifndef CACHEREACH_HPP

#define CACHEREACH_HPP



class CacheReach : public Cache<int>

{

  public:

    CacheReach(char* aFilename): Cache<int>(aFilename) {}

};



#endif