VRS
A file format for sensor data.
Loading...
Searching...
No Matches
LegacyFormatsProvider.h
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <mutex>
20
21#include "RecordFormat.h"
22
23namespace vrs {
24
25using std::map;
26using std::recursive_mutex;
27using std::string;
28using std::unique_ptr;
29using std::vector;
30
31class DataLayout;
32class LegacyFormatsProvider;
33
37 RecordFormatRegistrar() = default;
38
39 public:
40 // Public interface
41
44 static void registerProvider(unique_ptr<LegacyFormatsProvider> provider);
45
46 // VRS internal interface
47
51
57
61 unique_ptr<DataLayout> getLegacyDataLayout(const ContentBlockId& blockId);
62
72 unique_ptr<DataLayout> getLatestDataLayout(RecordableTypeId typeId, Record::Type recordType);
73
77 RecordableTypeId typeId,
78 Record::Type recordType,
79 uint32_t formatVersion,
80 const RecordFormat& format,
81 const vector<const DataLayout*>& layouts);
82
83 private:
84 const map<string, string>& getLegacyRegistry(RecordableTypeId typeId);
85 void registerProviderInternal(unique_ptr<LegacyFormatsProvider> provider);
86
87 recursive_mutex mutex_;
88 vector<unique_ptr<LegacyFormatsProvider>> providers_;
89 map<RecordableTypeId, map<string, string>> legacyRecordFormats_;
90};
91
100 public:
101 virtual ~LegacyFormatsProvider();
102
107
108 protected:
122 RecordableTypeId typeId,
123 Record::Type recordType,
124 uint32_t formatVersion,
125 const RecordFormat& format,
126 const vector<const DataLayout*>& layouts) {
128 typeId, recordType, formatVersion, format, layouts);
129 }
130};
131
132} // namespace vrs
Helper to identify a particular content block within a file.
Definition RecordFormat.h:600
System to inject record format & data layout definitions for files created without.
Definition LegacyFormatsProvider.h:99
virtual void registerLegacyRecordFormats(RecordableTypeId typeId)=0
static bool addLegacyRecordFormat(RecordableTypeId typeId, Record::Type recordType, uint32_t formatVersion, const RecordFormat &format, const vector< const DataLayout * > &layouts)
Definition LegacyFormatsProvider.h:121
Description of the format of a VRS record as a succession of typed blocks of content.
Definition RecordFormat.h:644
Utility class to handle record format registry manipulations.
Definition LegacyFormatsProvider.h:35
static RecordFormatRegistrar & getInstance()
Definition LegacyFormatsProvider.cpp:40
static void registerProvider(unique_ptr< LegacyFormatsProvider > provider)
Definition LegacyFormatsProvider.cpp:31
void getLegacyRecordFormats(RecordableTypeId id, RecordFormatMap &outFormats)
Definition LegacyFormatsProvider.cpp:45
bool addLegacyRecordFormat(RecordableTypeId typeId, Record::Type recordType, uint32_t formatVersion, const RecordFormat &format, const vector< const DataLayout * > &layouts)
Definition LegacyFormatsProvider.cpp:83
unique_ptr< DataLayout > getLegacyDataLayout(const ContentBlockId &blockId)
Definition LegacyFormatsProvider.cpp:52
unique_ptr< DataLayout > getLatestDataLayout(RecordableTypeId typeId, Record::Type recordType)
Definition LegacyFormatsProvider.cpp:57
Type
Definition Record.h:88
Definition AsyncDiskFileChunk.hpp:49
map< pair< Record::Type, uint32_t >, RecordFormat > RecordFormatMap
Map a pair of record type/format version to a record format, for a particular stream.
Definition RecordFormat.h:590
RecordableTypeId
VRS stream type or class identifier enum.
Definition StreamId.h:49