DBVectorProcessor.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Copyright (C) 2017 Carlos Aguilar Melchor, Joris Barrier, Marc-Olivier Killijian
  2. *
  3. * This file is written by Konstantinos Andrikopoulos
  4. *
  5. * This file is part of XPIR.
  6. *
  7. * XPIR is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * XPIR is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with XPIR. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef DEF_DBVECPROC
  21. #define DEF_DBVECPROC
  22. #include "DBHandler.hpp"
  23. #include <vector>
  24. #include <map>
  25. #include <tuple>
  26. #include <string.h>
  27. struct Element {
  28. Element(std::string, uint64_t, char*);
  29. std::string name;
  30. size_t data_size;
  31. char *data;
  32. };
  33. typedef Element element_t;
  34. class DBVectorProcessor : public DBHandler
  35. {
  36. private:
  37. std::vector<element_t>& elements;
  38. std::map<uint64_t, char*> openStreamOffsets;
  39. uint64_t maxFileByteSize;
  40. public:
  41. DBVectorProcessor(std::vector<element_t>& vector_db);
  42. virtual ~DBVectorProcessor();
  43. std::string getCatalog(const bool typeOfCatalog);
  44. uint64_t getNbStream();
  45. uint64_t getmaxFileBytesize();
  46. bool openStream(uint64_t streamNb, uint64_t requested_offset);
  47. uint64_t readStream(uint64_t streamNb, char * buf, uint64_t size);
  48. void closeStream(uint64_t streamNb);
  49. };
  50. #endif /* DEF_DBVECPROC */