Initialize capture templates.
As part of this, refactored characteristic initialization into its own
function so it can be used by both templates and static info.
BUG: 29221795
Change-Id: I88bb2e6a96256e3641c7c5d387769880b260535f
diff --git a/modules/camera/3_4/ArrayVector.h b/modules/camera/3_4/ArrayVector.h
new file mode 100644
index 0000000..53d09c5
--- /dev/null
+++ b/modules/camera/3_4/ArrayVector.h
@@ -0,0 +1,52 @@
+/*
+ * 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 ARRAY_VECTOR_H
+#define ARRAY_VECTOR_H
+
+#include <array>
+#include <vector>
+
+namespace v4l2_camera_hal {
+// ArrayVector behaves like a std::vector of fixed length C arrays,
+// with push_back accepting std::arrays to standardize length.
+// Specific methods to get number of arrays/number of elements
+// are provided and an ambiguous "size" is not, to avoid accidental
+// incorrect use.
+template <class T, int N>
+class ArrayVector {
+public:
+ const T* data() const { return mItems.data(); }
+ // The number of arrays.
+ size_t num_arrays() const { return mItems.size() / N; }
+ // The number of elements amongst all arrays.
+ size_t total_num_elements() const { return mItems.size(); }
+
+ // Access the ith array.
+ const T* operator[](int i) const { return mItems.data() + (i * N); }
+ T* operator[](int i) { return mItems.data() + (i * N); }
+
+ void push_back(const std::array<T, N>& values) {
+ mItems.insert(mItems.end(), values.begin(), values.end());
+ }
+
+private:
+ std::vector<T> mItems;
+};
+
+} // namespace v4l2_camera_hal
+
+#endif // ARRAY_VECTOR_H