// Copyright (c) ONNX Project Contributors
//
// SPDX-License-Identifier: Apache-2.0

/// @file onnx_pb.h
/// @brief Central header that takes the role of the protobuf-generated
///        <tt>onnx_pb.h</tt> in the standard ONNX package.
///
/// **Why this file exists**
///
/// In the standard *onnx* package every message class (``ModelProto``,
/// ``TensorProto``, etc.) is auto-generated by the ``protoc`` compiler from
/// the ONNX ``.proto`` schema files, and the generated translation unit is
/// named ``onnx_pb.h``.  That file is the single include point relied on by
/// almost all ONNX C++ source files to pull in the message types and the
/// ``ONNX_LIGHT_NAMESPACE`` / ``ONNX_API`` macros.
///
/// *onnx-light* eliminates the protobuf dependency entirely: message classes
/// are hand-written in ``onnx_light/onnx/onnx_proto/onnx.h`` using a set of
/// code-generation macros (``BEGIN_PROTO``, ``FIELD``, etc.) defined in
/// ``stream_class.h``.  This file acts as the drop-in replacement for the
/// protobuf-generated ``onnx_pb.h``; it includes the hand-crafted message
/// types and provides the same namespace and export macros so that the rest
/// of the ONNX C++ sources compile unchanged.

#pragma once

#include "onnx_proto/onnx.h"

/// @brief Namespace used for all onnx-light C++ symbols.
///
/// Defaults to ``onnx_light``.  Can be overridden at compile time to allow
/// onnx-light to coexist with the standard onnx library in the same
/// translation unit.
#ifndef ONNX_LIGHT_NAMESPACE
#define ONNX_LIGHT_NAMESPACE onnx_light
#endif

/// @brief Backwards-compatible alias so that code referencing
///        ``ONNX_NAMESPACE`` (the macro used in the standard onnx package)
///        resolves to the same namespace as ``ONNX_LIGHT_NAMESPACE``.
#ifndef ONNX_NAMESPACE
#define ONNX_NAMESPACE ONNX_LIGHT_NAMESPACE
#endif

/// @brief Alias that makes onnx-light headers compatible with code that
///        references ``ONNX_LIGHT_NAMESPACE`` (the macro used in the standard onnx
///        package).
///
/// Set to ``ONNX_LIGHT_NAMESPACE`` so both names resolve to the same
/// namespace.
#ifndef ONNX_LIGHT_NAMESPACE
#define ONNX_LIGHT_NAMESPACE ONNX_LIGHT_NAMESPACE
#endif

/// @brief Symbol-visibility attribute for the public onnx-light C++ API.
///
/// Maps the upstream compatibility macro to onnx-light's explicit proto ABI
/// annotation. This keeps declarations from vendored ONNX headers visible when
/// ``lib_onnx_proto`` uses hidden visibility by default.
#ifndef ONNX_API
#define ONNX_API ONNX_LIGHT_PROTO_API
#endif

/// @brief Namespace alias so that ONNX C++ code (and consumers such as
///        onnxruntime) that refers to the literal ``onnx`` namespace — rather
///        than the ``ONNX_NAMESPACE`` macro — resolves to the onnx-light
///        namespace.  The standard onnx package lives in ``namespace onnx``;
///        onnx-light uses ``onnx_light`` (via ONNX_LIGHT_NAMESPACE), so this
///        alias keeps onnx-light a true drop-in.  It is only introduced when the
///        onnx-light namespace differs from ``onnx``.
namespace ONNX_LIGHT_NAMESPACE {}
#ifndef ONNX_LIGHT_ONNX_NAMESPACE_ALIAS_DEFINED
#define ONNX_LIGHT_ONNX_NAMESPACE_ALIAS_DEFINED
namespace onnx = ONNX_LIGHT_NAMESPACE;
#endif

/// @brief Expose the flat protobuf-style enum aliases (``TensorProto_DataType``,
///        ``TensorShapeProto_Dimension``, ...).
///
/// The standard protobuf-generated ``onnx_pb.h`` exposes these flat names, so
/// consumers that include ``<onnx/onnx_pb.h>`` (for example onnxruntime) expect
/// ``ONNX_NAMESPACE::TensorProto_DataType`` to resolve.  Pulling the aliases in
/// here — after ``onnx.h`` (which defines the scoped message types) and the
/// ``ONNX_LIGHT_NAMESPACE`` macro above — keeps onnx-light a true drop-in.
#include "onnx_proto/onnx_alias.h"
