blob: 78cd2fa19f1b4104778c25f67de7d49d46a70909 [file] [log] [blame]
Ari Hausman-Cohen407cca92016-08-02 11:03:15 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
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#ifndef V4L2_CAMERA_HAL_METADATA_PROPERTY_H_
18#define V4L2_CAMERA_HAL_METADATA_PROPERTY_H_
19
20#include "../common.h"
21#include "tagged_partial_metadata.h"
22
23namespace v4l2_camera_hal {
24
25// A Property is a PartialMetadata that only has a single static tag.
26template <typename T>
27class Property : public TaggedPartialMetadata {
28 public:
29 Property(int32_t tag) : TaggedPartialMetadata({tag}, {}, {}){};
30
31 virtual int PopulateStaticFields(
32 android::CameraMetadata* metadata) const override {
33 HAL_LOG_ENTER();
34 return UpdateMetadata(metadata, Tag(), Value());
35 };
36
37 virtual int PopulateDynamicFields(
38 android::CameraMetadata* metadata) const override {
39 HAL_LOG_ENTER();
40 return 0;
41 };
42
43 virtual bool SupportsRequestValues(
44 const android::CameraMetadata& metadata) const override {
45 HAL_LOG_ENTER();
46 return true;
47 };
48
49 virtual int SetRequestValues(
50 const android::CameraMetadata& metadata) override {
51 HAL_LOG_ENTER();
52 return 0;
53 };
54
55 protected:
56 // Simpler access to tag.
57 inline int32_t Tag() const { return StaticTags()[0]; }
58 // Get the value associated with this property.
59 virtual const T& Value() const = 0;
60};
61
62} // namespace v4l2_camera_hal
63
64#endif // V4L2_CAMERA_HAL_METADATA_PROPERTY_H_