chromium/third_party/mediapipe/src/mediapipe/framework/collection_item_id.h

// Copyright 2019 The MediaPipe Authors.
//
// 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 MEDIAPIPE_FRAMEWORK_COLLECTION_ITEM_ID_H_
#define MEDIAPIPE_FRAMEWORK_COLLECTION_ITEM_ID_H_

#include "mediapipe/framework/deps/strong_int.h"

namespace mediapipe {

namespace tool {
class TagMap;
}  // namespace tool

// TagMap allows access to a collection using a tag and index value.
// The underlying data in the collection is stored in a flat array.
// CollectionItemId is the index into that array.  Although this type is
// conceptually an int we don't allow implicit type conversion so as to
// avoid confusion where a user accidentally forgets to query the TagMap
// to get an actual CollectionItemId.
// For example, accidentally using Inputs().Get(2) when Inputs().Index(2)
// was meant will cause a type error.
class CollectionItemId {};

std::ostream& operator<<(std::ostream& os, CollectionItemId arg);

CollectionItemId operator+(int lhs, CollectionItemId rhs);
CollectionItemId operator-(int lhs, CollectionItemId rhs);
CollectionItemId operator*(int lhs, CollectionItemId rhs);

}  // namespace mediapipe

#endif  // MEDIAPIPE_FRAMEWORK_COLLECTION_ITEM_ID_H_