forked from Smorodov/Multitarget-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_types.h
More file actions
44 lines (39 loc) · 998 Bytes
/
object_types.h
File metadata and controls
44 lines (39 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
#include <string>
#include <vector>
typedef int objtype_t;
constexpr objtype_t bad_type = -1;
///
class TypeConverter
{
public:
///
static std::string Type2Str(objtype_t type)
{
return (type == bad_type) ? m_badTypeName : m_typeNames[type];
}
///
static objtype_t Str2Type(const std::string& typeName)
{
for (size_t i = 0; i < m_typeNames.size(); ++i)
{
if (typeName == m_typeNames[i])
return static_cast<objtype_t>(i);
}
m_typeNames.emplace_back(typeName);
return static_cast<objtype_t>(m_typeNames.size()) - 1;
}
static bool AddNewType(const std::string& typeName)
{
for (size_t i = 0; i < m_typeNames.size(); ++i)
{
if (typeName == m_typeNames[i])
return false;
}
m_typeNames.emplace_back(typeName);
return true;
}
private:
static std::vector<std::string> m_typeNames;
static std::string m_badTypeName;
};