KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tracking_entity.h
Go to the documentation of this file.
1 /* =========================================================================== *
2  |
3  | Copyright (c) 1994-2011 by Kobus Barnard (author)
4  |
5  | Personal and educational use of this code is granted, provided that this
6  | header is kept intact, and that the authorship is not misrepresented, that
7  | its use is acknowledged in publications, and relevant papers are cited.
8  |
9  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
10  |
11  | Please note that the code in this file has not necessarily been adequately
12  | tested. Naturally, there is no guarantee of performance, support, or fitness
13  | for any particular task. Nonetheless, I am interested in hearing about
14  | problems that you encounter.
15  |
16  | Author: Kyle Simek, Ernesto Brau, Jinyan Guan
17  * =========================================================================== */
18 
19 /* $Id: tracking_entity.h 18005 2014-10-30 20:45:03Z ksimek $ */
20 
21 #ifndef TRACKING_ENTITY_H
22 #define TRACKING_ENTITY_H
23 
24 #include <string>
25 #include <vector>
26 #include <istream>
27 #include <ostream>
28 #include <cassert>
29 
30 namespace kjb {
31 namespace tracking {
32 
39 // To add a new type, add entries to Entity_type, and Entity_type_map;
44 
46 std::vector<std::string> get_all_entity_type_names();
47 
49 const std::string& get_entity_type_name(Entity_type type);
50 
52 Entity_type get_entity_type(const std::string& name);
53 
56 
59 
62 
65 
68 
71 
73 std::ostream& operator<<(std::ostream& ost, Entity_type type);
74 
76 std::istream& operator>>(std::istream& ist, Entity_type& type);
77 
82 struct Entity_id
83 {
85  int index;
86 
89  index(-1)
90  {}
91 
92  Entity_id(Entity_type type_, int index_) :
93  type(type_),
94  index(index_)
95  {}
96 
97  bool operator!=(const Entity_id& other) const
98  {
99  return !operator==(other);
100  }
101 
102  bool operator==(const Entity_id& other) const
103  {
104  if(type != other.type) return false;
105  if(index != other.index) return false;
106  return true;
107  }
108 
109  bool operator<(const Entity_id& other) const
110  {
111  // lexicographical ordering
112  return type < other.type || (type == other.type && index < other.index);
113  }
114 
115  bool operator!() const
116  {
117  // for consistency, either both values are "null" or neither are.
118  assert((type == NUM_ENTITY_TYPES && index == -1) ||
119  (type != NUM_ENTITY_TYPES && index != -1));
120 
121  return (type == NUM_ENTITY_TYPES);
122  }
123 };
124 
126 std::istream& operator>>(std::istream& ist, Entity_id& id);
127 
129 std::ostream& operator<<(std::ostream& ost, const Entity_id& id);
130 
131 }} //namespace kjb::tracking
132 
133 #endif /* TRACKING_ENTITY_H */
134 
bool operator!=(const Entity_id &other) const
Definition: tracking_entity.h:97
Definition: tracking_entity.h:41
double get_entity_type_average_height(Entity_type type)
Get the average height of an entity.
Definition: tracking_entity.cpp:110
double get_entity_type_average_girth(Entity_type type)
Get the average girth of an entity.
Definition: tracking_entity.cpp:138
const std::string & get_entity_type_name(Entity_type type)
Get the name of a entity type.
Definition: tracking_entity.cpp:103
Entity_id(Entity_type type_, int index_)
Definition: tracking_entity.h:92
Entity_type type
Definition: tracking_entity.h:84
Definition: tracking_entity.h:40
Definition: tracking_entity.h:41
int index
Definition: tracking_entity.h:85
bool operator!() const
Definition: tracking_entity.h:115
Definition: tracking_entity.h:40
Definition: tracking_entity.h:41
Entity + index; used for file I/O.
Definition: tracking_entity.h:82
double get_entity_type_stddev_girth(Entity_type type)
Get the standard deviation of the girth of an entity.
Definition: tracking_entity.cpp:145
Definition: tracking_entity.h:43
bool operator==(const Entity_id &other) const
Definition: tracking_entity.h:102
Entity_type get_entity_type(const std::string &name)
Get the type of a entity name.
Definition: tracking_entity.cpp:96
std::ostream & operator<<(std::ostream &ost, Entity_type type)
Stream out an entity.
Definition: tracking_entity.cpp:152
double get_entity_type_average_width(Entity_type type)
Get the average width of an entity.
Definition: tracking_entity.cpp:124
double get_entity_type_stddev_width(Entity_type type)
Get the standard deviation of the width of an entity.
Definition: tracking_entity.cpp:131
Entity_type
Definition: tracking_entity.h:40
bool operator<(const Entity_id &other) const
Definition: tracking_entity.h:109
double get_entity_type_stddev_height(Entity_type type)
Get the standard deviation of the height of an entity.
Definition: tracking_entity.cpp:117
Definition: tracking_entity.h:43
Definition: tracking_entity.h:41
Entity_id()
Definition: tracking_entity.h:87
std::istream & operator>>(std::istream &ist, Entity_type &type)
Stream in an entity.
Definition: tracking_entity.cpp:163
Definition: tracking_entity.h:42
std::vector< std::string > get_all_entity_type_names()
Get all types.
Definition: tracking_entity.cpp:80
Definition: tracking_entity.h:40
Definition: tracking_entity.h:42
Definition: tracking_entity.h:42