PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/src/common/types/PolicyResult.cpp

https://gitlab.com/admin-github-cloud/cynara
C++ | 64 lines | 28 code | 14 blank | 22 comment | 5 complexity | f57666d3d9de0e6330fd0ccbae463172 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/common/types/PolicyResult.cpp
  18. * @author Aleksander Zdyb <a.zdyb@samsung.com>
  19. * @author Zofia Abramowska <z.abramowska@samsung.com>
  20. * @version 1.0
  21. * @brief PolicyResult implementation
  22. */
  23. #include "PolicyResult.h"
  24. namespace Cynara {
  25. PolicyResult::PolicyResult() : m_type(PredefinedPolicyType::DENY) {}
  26. PolicyResult::PolicyResult(const PolicyType &policyType) : m_type(policyType) {}
  27. PolicyResult::PolicyResult(const PolicyType &policyType, const PolicyMetadata &metadata)
  28. : m_type(policyType) , m_metadata(metadata) {}
  29. const PolicyType &PolicyResult::policyType(void) const {
  30. return m_type;
  31. }
  32. const PolicyResult::PolicyMetadata &PolicyResult::metadata(void) const {
  33. return m_metadata;
  34. }
  35. bool PolicyResult::operator <(const PolicyResult &other) const {
  36. return this->m_type < other.m_type;
  37. }
  38. bool PolicyResult::operator ==(const PolicyResult &other) const {
  39. return std::tie(m_type, m_metadata) == std::tie(other.m_type, other.m_metadata);
  40. }
  41. bool PolicyResult::operator !=(const PolicyResult &other) const {
  42. return !(*this == other);
  43. }
  44. bool PolicyResult::operator ==(const PolicyType &policyType) const {
  45. return (m_type == policyType) && m_metadata.empty();
  46. }
  47. bool PolicyResult::operator !=(const PolicyType &policyType) const {
  48. return !(*this == policyType);
  49. }
  50. } // namespace Cynara