TeBkUm.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. Copyright 2009-2020, Sumeet Chhetri
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /*
  14. * TeBkUm.h
  15. *
  16. * Created on: 03-Feb-2020
  17. * Author: sumeetc
  18. */
  19. #ifndef WEB_TE_BENCHMARK_UM_INCLUDE_TeBkUm_H_
  20. #define WEB_TE_BENCHMARK_UM_INCLUDE_TeBkUm_H_
  21. #include "TemplateHandler.h"
  22. #include "vector"
  23. #include "DataSourceManager.h"
  24. #include <stdlib.h>
  25. #include <algorithm>
  26. #include "CryptoHandler.h"
  27. #include "vector"
  28. #include "CastUtil.h"
  29. #include <stdlib.h>
  30. #include "CacheManager.h"
  31. #include "HttpRequest.h"
  32. #include "HttpResponse.h"
  33. #include "JSONSerialize.h"
  34. #include "string"
  35. #include "TeBkUmWorld.h"
  36. #include "yuarel.h"
  37. #include "Router.h"
  38. #pragma @Entity
  39. #pragma @Table name="fortune"
  40. class TeBkUmFortune {
  41. #pragma @Id dbf="id"
  42. int id;
  43. #pragma @Column dbf="message"
  44. std::string message;
  45. public:
  46. TeBkUmFortune();
  47. virtual ~TeBkUmFortune();
  48. int getId() const;
  49. void setId(int id);
  50. const std::string& getMessage() const;
  51. void setMessage(const std::string& message);
  52. bool operator < (const TeBkUmFortune& other) const;
  53. };
  54. class TeBkUmMessage {
  55. std::string message;
  56. public:
  57. virtual ~TeBkUmMessage();
  58. const std::string& getMessage() const;
  59. void setMessage(const std::string& message);
  60. };
  61. class TeBkUmRouter : public Router {
  62. static const std::string HELLO_WORLD;
  63. static std::string WORLD;
  64. static TemplatePtr tmplFunc;
  65. static Ser m_ser;
  66. static Ser w_ser;
  67. static SerCont wcont_ser;
  68. bool strToNum(const char* str, int len, int& ret);
  69. void db(TeBkUmWorld&);
  70. void queries(const char*, int, std::vector<TeBkUmWorld>&);
  71. void updates(const char*, int, std::vector<TeBkUmWorld>&);
  72. void cachedWorlds(const char*, int, std::vector<TeBkUmWorld>&);
  73. void getContext(HttpRequest* request, Context* context);
  74. public:
  75. TeBkUmRouter();
  76. virtual ~TeBkUmRouter();
  77. void updateCache();
  78. bool route(HttpRequest* req, HttpResponse* res, SocketInterface* sif);
  79. };
  80. #endif /* WEB_TE_BENCHMARK_UM_INCLUDE_TeBkUm_H_ */