Synodic-Software / Soul-Engine

Physically based renderer and simulation engine for real-time applications.
GNU General Public License v3.0
42 stars 24 forks source link

Decouple the FileManager from ArchiveBase #100

Closed Behemyth closed 6 years ago

Behemyth commented 7 years ago

At the moment, the base class for all the Archives ArchiveBase is derived from FileManager. Instead, the file manager should be a stand alone namespace.

namespace FileSystem {

    /*
        Abstract base class for all file i / o classes to inherit from.
    */
    class FileManager {
    public:

        /*
            @param      filename_       name of file to operate on
        */
        FileManager(const std::string & filename_) :filename(filename_) {}

        /*
            @effects        read from the file specified by gilename
        */
        virtual void Read() = 0;

        /*
            @effects        write to the file specified by filename
        */
        virtual void Write() = 0;

    protected:
        std::string filename;

    };
};

becomes

namespace FileSystem {

        /*
            @effects        read from the file specified by filename
        */
        void Read(std::string& filename);

        /*
            @effects        write to the file specified by filename
        */
        void Write(std::string& filename);

    };
};

You then must implement the functions and create FileManager.cpp. Examples of these implementations can be found online.

You will not be specifically writing anything, so the written files specified by filename will be empty.

The ArchiveBase then needs its own Read and Write functions. e.g

/*
            @effects        read from the file specified by gilename
        */
        virtual void Read() = 0;

        /*
            @effects        write to the file specified by filename
        */
        virtual void Write() = 0;

After you implement this, all the Archive classes will keep their inherited Read and Write function overload.

Behemyth commented 6 years ago

Finished!