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
58 lines (52 loc) · 1.44 KB
/
object_types.h
File metadata and controls
58 lines (52 loc) · 1.44 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include <string>
#include <vector>
#include <iostream>
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[(size_t)type];
}
///
static objtype_t Str2Type(const std::string& typeName)
{
for (size_t i = 0; i < m_typeNames.size(); ++i)
{
if (typeName == m_typeNames[i])
{
//std::cout << "Str2Type: " << typeName << " exist: " << i << std::endl;
return static_cast<objtype_t>(i);
}
}
m_typeNames.emplace_back(typeName);
//std::cout << "Str2Type: " << typeName << " new: " << (m_typeNames.size()) - 1 << std::endl;
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])
{
//std::cout << "AddNewType: " << typeName << ": false" << std::endl;
return false;
}
}
m_typeNames.emplace_back(typeName);
//std::cout << "AddNewType: " << typeName << ": " << (m_typeNames.size() - 1) << std::endl;
return true;
}
static size_t TypesCount()
{
return m_typeNames.size();
}
private:
static std::vector<std::string> m_typeNames;
static std::string m_badTypeName;
};