SHARE
TWEET

Untitled

a guest Jan 29th, 2020 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. // Created by qnbhd on 29.01.2020.
  3. //
  4.  
  5. #ifndef ANASTASIA_COMMANDSET_HPP
  6. #define ANASTASIA_COMMANDSET_HPP
  7.  
  8. #include "Set.hpp"
  9.  
  10.  
  11. class CommandFunctor {
  12. public:
  13.     CommandFunctor (int * leftA, int * rightA) {}
  14.     CommandFunctor() {};
  15.     virtual ~CommandFunctor() = default;
  16.     virtual void operator()(){};
  17. };
  18.  
  19. class AND : public CommandFunctor{
  20. private:
  21.     int * leftOperand;
  22.     int * rightOperand;
  23. public:
  24.     AND (int * leftA, int * rightA) :
  25.         leftOperand(leftA),
  26.         rightOperand(rightA)
  27.     {}
  28.  
  29.     void operator ()() override{
  30.         *rightOperand &= *leftOperand;
  31.     };
  32. };
  33.  
  34. class CommandSet {
  35. private:
  36.     Set<CommandFunctor*> Operators;
  37.     Set<CommandFunctor*> Commands;
  38.  
  39.     int ** Registers;
  40. public:
  41.  
  42.     CommandSet (){
  43.         Registers = new int * [16];
  44.         for (int i = 0; i < 16; ++i)
  45.             Registers[i] = new int;
  46.     }
  47.  
  48.     ~CommandSet(){
  49.         for (int i = 0; i < 16; ++i)
  50.             delete Registers[i];
  51.         delete [] Registers;
  52.     }
  53.  
  54.     void put (int commandIndex, int register1, int * address)
  55.     {
  56.         switch (commandIndex)
  57.         {
  58.             case 1:
  59.                 Commands.insert (new AND(Registers[register1], address));
  60.             default:;
  61.         }
  62.     }
  63.  
  64.     void print (){
  65.         for (int i = 0; i < 16; ++i)
  66.         {
  67.            
  68.         }
  69.     }
  70.  
  71. };
  72.  
  73.  
  74. #endif //ANASTASIA_COMMANDSET_HPP
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top