LocatorListComparisons.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  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. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @file LocatorListComparisons.hpp
  16. */
  17. #ifndef _FASTDDS_RTPS_COMMON_LOCATORLISTCOMPARISONS_HPP_
  18. #define _FASTDDS_RTPS_COMMON_LOCATORLISTCOMPARISONS_HPP_
  19. #include <fastdds/rtps/common/Locator.h>
  20. #include <fastrtps/utils/collections/ResourceLimitedVector.hpp>
  21. #include <algorithm>
  22. namespace eprosima {
  23. namespace fastrtps {
  24. namespace rtps {
  25. static inline bool operator == (
  26. const ResourceLimitedVector<Locator_t>& lhs,
  27. const ResourceLimitedVector<Locator_t>& rhs)
  28. {
  29. if (lhs.size() == rhs.size())
  30. {
  31. for (const Locator_t& locator : lhs)
  32. {
  33. if (std::find(rhs.begin(), rhs.end(), locator) == rhs.end())
  34. {
  35. return false;
  36. }
  37. }
  38. return true;
  39. }
  40. return false;
  41. }
  42. } /* namespace rtps */
  43. } /* namespace fastrtps */
  44. } /* namespace eprosima */
  45. #endif /* _FASTDDS_RTPS_COMMON_LOCATORLISTCOMPARISONS_HPP_ */