static-supported-modes-manager.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. *
  3. * Copyright (c) 2021 Project CHIP Authors
  4. * All rights reserved.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #pragma once
  19. #include <app/clusters/mode-select-server/supported-modes-manager.h>
  20. #include <app/util/af.h>
  21. #include <app/util/config.h>
  22. #include <cstring>
  23. namespace chip {
  24. namespace app {
  25. namespace Clusters {
  26. namespace ModeSelect {
  27. /**
  28. * This implementation statically defines the options.
  29. */
  30. class StaticSupportedModesManager : public chip::app::Clusters::ModeSelect::SupportedModesManager
  31. {
  32. using ModeOptionStructType = Structs::ModeOptionStruct::Type;
  33. using storage_value_type = const ModeOptionStructType;
  34. struct EndpointSpanPair
  35. {
  36. const EndpointId mEndpointId;
  37. const Span<storage_value_type> mSpan;
  38. EndpointSpanPair(const EndpointId aEndpointId, const Span<storage_value_type> && aSpan) :
  39. mEndpointId(aEndpointId), mSpan(aSpan)
  40. {}
  41. EndpointSpanPair() : mEndpointId(0), mSpan(Span<storage_value_type>()) {}
  42. };
  43. static storage_value_type coffeeOptions[];
  44. static const EndpointSpanPair supportedOptionsByEndpoints[EMBER_AF_MODE_SELECT_CLUSTER_SERVER_ENDPOINT_COUNT];
  45. public:
  46. static const StaticSupportedModesManager instance;
  47. SupportedModesManager::ModeOptionsProvider getModeOptionsProvider(EndpointId endpointId) const override;
  48. Protocols::InteractionModel::Status getModeOptionByMode(EndpointId endpointId, uint8_t mode,
  49. const ModeOptionStructType ** dataPtr) const override;
  50. ~StaticSupportedModesManager(){};
  51. StaticSupportedModesManager() {}
  52. static inline const StaticSupportedModesManager & getStaticSupportedModesManagerInstance() { return instance; }
  53. };
  54. const SupportedModesManager * getSupportedModesManager();
  55. } // namespace ModeSelect
  56. } // namespace Clusters
  57. } // namespace app
  58. } // namespace chip