Nuitrack  1.6.0
3D Skeleton Tracking Middleware
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Events Groups Pages
Issue.h
1 #ifndef NUITRACK_ISSUE_H_
2 #define NUITRACK_ISSUE_H_
3 
4 #include <memory>
5 #include <string>
6 #include<cstring>
7 
8 namespace tdv
9 {
10 namespace nuitrack
11 {
16 enum IssueId
17 {
18  NONE_ISSUE = 0,
19  FRAME_BORDER_ISSUE = 1,
20  OCCLUSION_ISSUE = 2,
21  SENSOR_ISSUE = 3
22 };
23 
30 class Issue
31 {
32 public:
36  typedef std::shared_ptr<Issue> Ptr;
37 
41  static std::string getType()
42  {
43  static std::string _type = "Issue";
44  return _type;
45  }
46 
50  virtual std::string getName() const
51  {
52  return std::string(_name);
53  }
54 
59  {
60  return _id;
61  }
62 
66  Issue() :
67  _id(NONE_ISSUE)
68  {
69  std::string name = "Issue";
70  _name = new char[name.length() + 1];
71  std::strcpy(_name, name.c_str());
72  }
73 
77  Issue(IssueId id, const std::string &name) :
78  _id(id)
79  {
80  _name = new char[name.length() + 1];
81  std::strcpy(_name, name.c_str());
82  }
83 
84  virtual ~Issue()
85  {
86  deleteString();
87  }
88 
92  void deleteString()
93  {
94  if(_name)
95  {
96  delete[] _name;
97  _name = NULL;
98  }
99  }
100 
104  Issue(const Issue& issue)
105  {
106  copyIssue(issue);
107  }
108 
112  void operator=(const Issue& issue)
113  {
114  copyIssue(issue);
115  }
116 
117 protected:
121  char* _name;
122 
123 private:
124  void copyIssue(const Issue& issue)
125  {
126  _id = issue._id;
127 
128  uint32_t nameSize = 0;
129  while(issue._name[nameSize] != '\0')
130  nameSize++;
131 
132  _name = new char[nameSize + 1];
133  for(uint32_t i = 0; i <= nameSize; i++)
134  _name[i] = issue._name[i];
135  }
136 };
137 
138 } /* namespace nuitrack */
139 } /* namespace tdv */
140 
141 #endif /* NUITRACK_ISSUE_H_ */
void deleteString()
Definition: Issue.h:92
Issue(const Issue &issue)
Copy constructor.
Definition: Issue.h:104
IssueId _id
Definition: Issue.h:119
std::shared_ptr< Issue > Ptr
Smart pointer to access the Issue instance.
Definition: Issue.h:36
static std::string getType()
Returns the issue type as a string.
Definition: Issue.h:41
virtual std::string getName() const
Returns the issue name.
Definition: Issue.h:50
IssueId
Describes an issue identifier.
Definition: Issue.h:16
Issue(IssueId id, const std::string &name)
Constructs an issue object from its identifier and name.
Definition: Issue.h:77
void operator=(const Issue &issue)
Overloaded copy assignment operator.
Definition: Issue.h:112
Stores general information about a issue.
Definition: Issue.h:30
char * _name
Definition: Issue.h:121
IssueId getId()
Returns the issue identifier.
Definition: Issue.h:58
Issue()
Constructs a default issue.
Definition: Issue.h:66