Add Control/State Interfaces.
These interfaces will be used to increase composition
and decrease inheritance in the metadata controls.
ControlDelegates are responsible for getting/setting values,
While ControlOptions are responsible for validating values
(breaking these two apart allows, for example, unused sliders
and unused enums to share the same ControlDelegate, but have different
options, with minimal code duplication).
StateDelegates are for read-only values that may change.
ControlDelegate inherits from this because it will allow
the State interface to be passed around, while one owner
maintains control of updating it behind the scenes.
BUG: 30140438
TEST: unit tests pass. Interfaces only so no new tests
Change-Id: I8042c1ccf97655558f45a1f8411e3a4a36de7506
diff --git a/modules/camera/3_4/metadata/control_delegate_interface.h b/modules/camera/3_4/metadata/control_delegate_interface.h
new file mode 100644
index 0000000..8896e72
--- /dev/null
+++ b/modules/camera/3_4/metadata/control_delegate_interface.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_H_
+#define V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_H_
+
+#include "state_delegate_interface.h"
+
+namespace v4l2_camera_hal {
+
+// A ControlDelegate extends StateDelegate with a setter method.
+template <typename T>
+class ControlDelegateInterface : public StateDelegateInterface<T> {
+ public:
+ virtual ~ControlDelegateInterface(){};
+
+ // ControlDelegates are allowed to be unreliable, so SetValue is best-effort;
+ // GetValue immediately after may not match (SetValue may, for example,
+ // automatically replace invalid values with valid ones,
+ // or have a delay before setting the requested value).
+ // Returns 0 on success, error code on failure.
+ virtual int SetValue(const T& value) = 0;
+ // Children must also override GetValue from StateDelegateInterface.
+};
+
+} // namespace v4l2_camera_hal
+
+#endif // V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_H_
diff --git a/modules/camera/3_4/metadata/control_options_interface.h b/modules/camera/3_4/metadata/control_options_interface.h
new file mode 100644
index 0000000..49b7653
--- /dev/null
+++ b/modules/camera/3_4/metadata/control_options_interface.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_H_
+#define V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_H_
+
+#include <vector>
+
+namespace v4l2_camera_hal {
+
+// A ControlOptions defines acceptable values for a control.
+template <typename T>
+class ControlOptionsInterface {
+ public:
+ virtual ~ControlOptionsInterface(){};
+
+ // Get a metadata-acceptable representation of the options.
+ // For enums this will be a list of values, for ranges this
+ // will be min and max, etc.
+ virtual std::vector<T> MetadataRepresentation() = 0;
+ // Get whether or not a given value is acceptable.
+ virtual bool IsSupported(const T& option);
+};
+
+} // namespace v4l2_camera_hal
+
+#endif // V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_H_
diff --git a/modules/camera/3_4/metadata/state_delegate_interface.h b/modules/camera/3_4/metadata/state_delegate_interface.h
new file mode 100644
index 0000000..c18ee3c
--- /dev/null
+++ b/modules/camera/3_4/metadata/state_delegate_interface.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef V4L2_CAMERA_HAL_METADATA_STATE_DELEGATE_INTERFACE_H_
+#define V4L2_CAMERA_HAL_METADATA_STATE_DELEGATE_INTERFACE_H_
+
+namespace v4l2_camera_hal {
+
+// A StateDelegate is simply a dynamic value that can be queried.
+// The value may change between queries.
+template <typename T>
+class StateDelegateInterface {
+ public:
+ virtual ~StateDelegateInterface(){};
+ // Returns 0 on success, error code on failure.
+ virtual int GetValue(T* value) = 0;
+};
+
+} // namespace v4l2_camera_hal
+
+#endif // V4L2_CAMERA_HAL_METADATA_STATE_DELEGATE_INTERFACE_H_