#ifndef FUNCTIONMEM_H_INCLUDED
#define FUNCTIONMEM_H_INCLUDED

#include "functionInst.h"

// This class is the class for memory (RAM ROM)

class functionMem : public functionInst{
    private :
        vector<unsigned long> data;
        string name;
        short id;
        /// Last id used -> next id will be lastId+1
        static short lastId;
        bool alreadyPutDeclarations;

        /// Length (bits) of each data
        /// Has to be <=32 bits
        short dataLength;
        /// Number of data
        short addrLength;

        friend class FunctionMemSameName;

    public :
        /// List of all memories (RAM/ROM)
        static vector<functionMem *> listMems;

        bool readOnly;

        functionMem(string, bool, operation * = 0);
        ~functionMem();

        bool VerifyNumberOfIO();

        void Eval();

        functionInst *Copy();

		void CPutDeclarations(ostream &, const string);
        void CPutCommands(ostream &, const string, const string);

        friend bool ParserMem(string &);
};

/**
 * Enable us to find a functionMem by its name in a list of functionMems.
 **/
class FunctionMemSameName{
    private :
        string name;
    public :
        FunctionMemSameName(string name_){name=name_;}
        bool operator () (functionMem *f) { return (f->name==name); }
};

#endif // FUNCTIONMEM_H_INCLUDED
