PageRenderTime 30ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/client-async/callback/ResponseCallback.cpp

https://gitlab.com/github-cloud-corporation/cynara
C++ | 62 lines | 32 code | 9 blank | 21 comment | 4 complexity | 2794cac57c944ca18211617521e2560b MD5 | raw file
  1. /*
  2. * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License
  15. */
  16. /**
  17. * @file src/client-async/callback/ResponseCallback.cpp
  18. * @author Marcin Niesluchowski <m.niesluchow@samsung.com>
  19. * @version 1.0
  20. * @brief This file contains definition of ResponseCallback class
  21. */
  22. #include "ResponseCallback.h"
  23. namespace Cynara {
  24. ResponseCallback::ResponseCallback(cynara_response_callback callback, void *userData)
  25. : m_callback(callback), m_userData(userData) {
  26. }
  27. ResponseCallback::ResponseCallback(ResponseCallback &&other)
  28. : m_callback(other.m_callback), m_userData(other.m_userData) {
  29. other.m_callback = nullptr;
  30. other.m_userData = nullptr;
  31. }
  32. void ResponseCallback::onAnswer(cynara_check_id checkId, int response) const {
  33. if (!m_callback)
  34. return;
  35. m_callback(checkId, cynara_async_call_cause::CYNARA_CALL_CAUSE_ANSWER, response, m_userData);
  36. }
  37. void ResponseCallback::onCancel(cynara_check_id checkId) const {
  38. if (!m_callback)
  39. return;
  40. m_callback(checkId, cynara_async_call_cause::CYNARA_CALL_CAUSE_CANCEL, 0, m_userData);
  41. }
  42. void ResponseCallback::onFinish(cynara_check_id checkId) const {
  43. if (!m_callback)
  44. return;
  45. m_callback(checkId, cynara_async_call_cause::CYNARA_CALL_CAUSE_FINISH, 0, m_userData);
  46. }
  47. void ResponseCallback::onDisconnected(cynara_check_id checkId) const {
  48. if (!m_callback)
  49. return;
  50. m_callback(checkId, cynara_async_call_cause::CYNARA_CALL_CAUSE_SERVICE_NOT_AVAILABLE, 0,
  51. m_userData);
  52. }
  53. } // namespace Cynara