blob: d6cae9cfa1419b8847a8b2f4387b337b619244b4 [file] [log] [blame]
// camera/mojo/camera_metadata.mojom-shared.h is auto generated by mojom_bindings_generator.py, do not edit
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CAMERA_MOJO_CAMERA_METADATA_MOJOM_SHARED_H_
#define CAMERA_MOJO_CAMERA_METADATA_MOJOM_SHARED_H_
#include <stdint.h>
#include <functional>
#include <iosfwd>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/enum_traits.h"
#include "mojo/public/cpp/bindings/interface_data_view.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/map_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"
#include "camera/mojo/camera_metadata.mojom-shared-internal.h"
#include "camera/mojo/camera_metadata_tags.mojom-shared.h"
namespace cros::mojom {
class CameraMetadataEntryDataView;
class CameraMetadataDataView;
} // cros::mojom
namespace mojo {
namespace internal {
template <>
struct MojomTypeTraits<::cros::mojom::CameraMetadataEntryDataView> {
using Data = ::cros::mojom::internal::CameraMetadataEntry_Data;
using DataAsArrayElement = Pointer<Data>;
static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};
template <>
struct MojomTypeTraits<::cros::mojom::CameraMetadataDataView> {
using Data = ::cros::mojom::internal::CameraMetadata_Data;
using DataAsArrayElement = Pointer<Data>;
static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};
} // namespace internal
} // namespace mojo
namespace cros::mojom {
enum class EntryType : int32_t {
TYPE_BYTE = 0,
TYPE_INT32 = 1,
TYPE_FLOAT = 2,
TYPE_INT64 = 3,
TYPE_DOUBLE = 4,
TYPE_RATIONAL = 5,
NUM_TYPES = 6,
kMinValue = 0,
kMaxValue = 6,
};
std::ostream& operator<<(std::ostream& os, EntryType value);
inline bool IsKnownEnumValue(EntryType value) {
return internal::EntryType_Data::IsKnownValue(
static_cast<int32_t>(value));
}
class CameraMetadataEntryDataView {
public:
CameraMetadataEntryDataView() = default;
CameraMetadataEntryDataView(
internal::CameraMetadataEntry_Data* data,
mojo::Message* message)
: data_(data), message_(message) {}
bool is_null() const { return !data_; }
uint32_t index() const {
return data_->index;
}
template <typename UserType>
[[nodiscard]] bool ReadTag(UserType* output) const {
auto data_value = data_->tag;
return mojo::internal::Deserialize<::cros::mojom::CameraMetadataTag>(
data_value, output);
}
::cros::mojom::CameraMetadataTag tag() const {
return ::mojo::internal::ToKnownEnumValueHelper(
static_cast<::cros::mojom::CameraMetadataTag>(data_->tag));
}
template <typename UserType>
[[nodiscard]] bool ReadType(UserType* output) const {
auto data_value = data_->type;
return mojo::internal::Deserialize<::cros::mojom::EntryType>(
data_value, output);
}
EntryType type() const {
return ::mojo::internal::ToKnownEnumValueHelper(
static_cast<::cros::mojom::EntryType>(data_->type));
}
uint32_t count() const {
return data_->count;
}
inline void GetDataDataView(
mojo::ArrayDataView<uint8_t>* output);
template <typename UserType>
[[nodiscard]] bool ReadData(UserType* output) {
auto* pointer = data_->data.Get();
return mojo::internal::Deserialize<mojo::ArrayDataView<uint8_t>>(
pointer, output, message_);
}
private:
internal::CameraMetadataEntry_Data* data_ = nullptr;
mojo::Message* message_ = nullptr;
};
class CameraMetadataDataView {
public:
CameraMetadataDataView() = default;
CameraMetadataDataView(
internal::CameraMetadata_Data* data,
mojo::Message* message)
: data_(data), message_(message) {}
bool is_null() const { return !data_; }
uint32_t size() const {
return data_->size;
}
uint32_t entry_count() const {
return data_->entry_count;
}
uint32_t entry_capacity() const {
return data_->entry_capacity;
}
uint32_t data_count() const {
return data_->data_count;
}
uint32_t data_capacity() const {
return data_->data_capacity;
}
inline void GetEntriesDataView(
mojo::ArrayDataView<CameraMetadataEntryDataView>* output);
template <typename UserType>
[[nodiscard]] bool ReadEntries(UserType* output) {
static_assert(
mojo::internal::IsValidUserTypeForOptionalValue<
mojo::ArrayDataView<::cros::mojom::CameraMetadataEntryDataView>, UserType>(),
"Attempting to read the optional `entries` field into a type which "
"cannot represent a null value. Either wrap the destination object "
"with std::optional, ensure that any corresponding "
"{Struct/Union/Array/String}Traits define the necessary IsNull and "
"SetToNull methods, or use `MaybeReadEntries` instead "
"of `ReadEntries if you're fine with null values being "
"silently ignored in this case.");
auto* pointer = data_->entries.Get();
return mojo::internal::Deserialize<mojo::ArrayDataView<::cros::mojom::CameraMetadataEntryDataView>>(
pointer, output, message_);
}
private:
internal::CameraMetadata_Data* data_ = nullptr;
mojo::Message* message_ = nullptr;
};
} // cros::mojom
namespace std {
template <>
struct hash<::cros::mojom::EntryType>
: public mojo::internal::EnumHashImpl<::cros::mojom::EntryType> {};
} // namespace std
namespace mojo {
namespace internal {
template <typename MaybeConstUserType>
struct Serializer<::cros::mojom::EntryType, MaybeConstUserType> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Traits = EnumTraits<::cros::mojom::EntryType, UserType>;
static void Serialize(UserType input, int32_t* output) {
*output = static_cast<int32_t>(Traits::ToMojom(input));
}
static bool Deserialize(int32_t input, UserType* output) {
return Traits::FromMojom(::mojo::internal::ToKnownEnumValueHelper(
static_cast<::cros::mojom::EntryType>(input)), output);
}
};
} // namespace internal
namespace internal {
template <typename MaybeConstUserType>
struct Serializer<::cros::mojom::CameraMetadataEntryDataView, MaybeConstUserType> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Traits = StructTraits<::cros::mojom::CameraMetadataEntryDataView, UserType>;
static void Serialize(
MaybeConstUserType& input,
mojo::internal::MessageFragment<::cros::mojom::internal::CameraMetadataEntry_Data>& fragment) {
if (CallIsNullIfExists<Traits>(input))
return;
fragment.Allocate();
fragment->index = Traits::index(input);
mojo::internal::Serialize<::cros::mojom::CameraMetadataTag>(
Traits::tag(input), &fragment->tag);
mojo::internal::Serialize<::cros::mojom::EntryType>(
Traits::type(input), &fragment->type);
fragment->count = Traits::count(input);
decltype(Traits::data(input)) in_data = Traits::data(input);
mojo::internal::MessageFragment<
typename decltype(fragment->data)::BaseType>
data_fragment(fragment.message());
constexpr const mojo::internal::ContainerValidateParams& data_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<uint8_t>>(
in_data, data_fragment, &data_validate_params);
fragment->data.Set(
data_fragment.is_null() ? nullptr : data_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
fragment->data.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null data in CameraMetadataEntry struct");
}
static bool Deserialize(::cros::mojom::internal::CameraMetadataEntry_Data* input,
UserType* output,
Message* message) {
if (!input)
return CallSetToNullIfExists<Traits>(output);
::cros::mojom::CameraMetadataEntryDataView data_view(input, message);
return Traits::Read(data_view, output);
}
};
} // namespace internal
namespace internal {
template <typename MaybeConstUserType>
struct Serializer<::cros::mojom::CameraMetadataDataView, MaybeConstUserType> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Traits = StructTraits<::cros::mojom::CameraMetadataDataView, UserType>;
static void Serialize(
MaybeConstUserType& input,
mojo::internal::MessageFragment<::cros::mojom::internal::CameraMetadata_Data>& fragment) {
if (CallIsNullIfExists<Traits>(input))
return;
fragment.Allocate();
fragment->size = Traits::size(input);
fragment->entry_count = Traits::entry_count(input);
fragment->entry_capacity = Traits::entry_capacity(input);
fragment->data_count = Traits::data_count(input);
fragment->data_capacity = Traits::data_capacity(input);
decltype(Traits::entries(input)) in_entries = Traits::entries(input);
mojo::internal::MessageFragment<
typename decltype(fragment->entries)::BaseType>
entries_fragment(fragment.message());
constexpr const mojo::internal::ContainerValidateParams& entries_validate_params =
mojo::internal::GetArrayValidator<0, false, nullptr>();
mojo::internal::Serialize<mojo::ArrayDataView<::cros::mojom::CameraMetadataEntryDataView>>(
in_entries, entries_fragment, &entries_validate_params);
fragment->entries.Set(
entries_fragment.is_null() ? nullptr : entries_fragment.data());
}
static bool Deserialize(::cros::mojom::internal::CameraMetadata_Data* input,
UserType* output,
Message* message) {
if (!input)
return CallSetToNullIfExists<Traits>(output);
::cros::mojom::CameraMetadataDataView data_view(input, message);
return Traits::Read(data_view, output);
}
};
} // namespace internal
} // namespace mojo
namespace cros::mojom {
inline void CameraMetadataEntryDataView::GetDataDataView(
mojo::ArrayDataView<uint8_t>* output) {
auto pointer = data_->data.Get();
*output = mojo::ArrayDataView<uint8_t>(pointer, message_);
}
inline void CameraMetadataDataView::GetEntriesDataView(
mojo::ArrayDataView<CameraMetadataEntryDataView>* output) {
auto pointer = data_->entries.Get();
*output = mojo::ArrayDataView<CameraMetadataEntryDataView>(pointer, message_);
}
} // cros::mojom
// Declare TraceFormatTraits for enums, which should be defined in ::perfetto
// namespace.
namespace perfetto {
template <>
struct TraceFormatTraits<::cros::mojom::EntryType> {
static void WriteIntoTrace(perfetto::TracedValue context, ::cros::mojom::EntryType value);
};
} // namespace perfetto
#endif // CAMERA_MOJO_CAMERA_METADATA_MOJOM_SHARED_H_