PIRReplyWriter.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Copyright (C) 2014 Carlos Aguilar Melchor, Joris Barrier, Marc-Olivier Killijian
  2. * This file is part of XPIR.
  3. *
  4. * XPIR is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * XPIR is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with XPIR. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef DEF_PIRREPLYWRITER
  18. #define DEF_PIRREPLYWRITER
  19. #include <iostream>
  20. #include <boost/signals2.hpp>
  21. #include <boost/thread.hpp>
  22. #include <omp.h>
  23. #include <unistd.h>
  24. #include "pir/shared_queue.hpp"
  25. #include "pir/PIRParameters.hpp"
  26. #include "pir/ClientDefines.hpp"
  27. #include "pir/GlobalConstant.hpp"
  28. #include "crypto/PaillierAdapter.hpp"
  29. #include "pir/events/WriteEvent.hpp"
  30. #include "pir/events/MessageEvent.hpp"
  31. #include "apps/client/DESC.hpp"
  32. class PIRReplyWriter
  33. {
  34. private:
  35. bool dontWrite;
  36. string filename, filePath;
  37. PIRParameters& pirParams;
  38. HomomorphicCrypto* cryptoMethod;
  39. shared_queue<char*> clearChunks;
  40. static const std::string kDefaultFolder;
  41. boost::thread writeThread;
  42. boost::signals2::signal<void (WriteEvent&)> &writeListeners;
  43. boost::signals2::signal<void (MessageEvent&)> &messageListeners;
  44. public:
  45. PIRReplyWriter(PIRParameters& param, boost::signals2::signal<void ( WriteEvent& )> &writeListeners_, boost::signals2::signal<void (MessageEvent&)> &messageListeners_);
  46. ~PIRReplyWriter();
  47. void writeAggregatedFileSecurely(uint64_t chosenElement, DESC catalog);
  48. void writeFileSecurely(uint64_t element, DESC catalog, uint64_t &skipbytes, WriteEvent &event);
  49. void startFileWritting(uint64_t chosenElement, DESC catalog);
  50. void setCryptoMethod(HomomorphicCrypto* crypto_method);
  51. shared_queue<char*>* getClearDataQueue();
  52. void join();
  53. void setdontWrite(bool newvalue);
  54. };
  55. #endif