KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bbb_physical_activity.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: Ernesto Brau
17  * =========================================================================== */
18 
19 /* $Id$ */
20 
21 #ifndef B3_PHYSICAL_ACTIVITY_H
22 #define B3_PHYSICAL_ACTIVITY_H
23 
24 #include <bbb_cpp/bbb_trajectory.h>
25 #include <bbb_cpp/bbb_traj_set.h>
26 #include <string>
27 #include <iostream>
28 #include <iterator>
29 #include <algorithm>
30 
31 namespace kjb {
32 namespace bbb {
33 
40 {
41 public:
44  (
45  const std::string& name,
46  const Trajectory& trajectory,
47  const Traj_set& trajs
48  ) :
49  name_(name),
50  trajectory_(trajectory),
51  trajs_(trajs)
52  {}
53 
55  void set_trajectory(const Trajectory& traj) { trajectory_ = traj; }
56 
58  void rename(const std::string& nm) { name_ = nm; }
59 
61  const std::string& name() const { return name_; }
62 
64  size_t start() const { return trajectory_.start(); }
65 
67  size_t end() const { return trajectory_.end(); }
68 
70  size_t size() const { return trajectory_.size(); }
71 
73  const Trajectory& trajectory() const { return trajectory_; }
74 
76  const Traj_set& trajectories() const { return trajs_; }
77 
78 private:
79  std::string name_;
80  Trajectory trajectory_;
81  Traj_set trajs_;
82 };
83 
84 /* \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ */
85 
87 inline
88 std::ostream& operator<<(std::ostream& ost, const Physical_activity& activity)
89 {
90  // sanity check
91  assert(activity.trajectories().size() != 0);
92 
93  // output name and times
94  ost << activity.name() << "(";
95  ost << activity.start() << ",";
96  ost << activity.end() << ")";
97  ost << " : ";
98 
99  // output member trajectories
100  Traj_set::const_iterator szt_p = --activity.trajectories().end();
101  ost << "{";
102  std::copy(
103  activity.trajectories().begin(), szt_p,
104  std::ostream_iterator<Traj_set::value_type>(ost, ", "));
105  ost << *szt_p << "}";
106 
107  // output trajectory
108  //ost << activity.trajectory();
109 
110  return ost;
111 }
112 
113 }} // namespace kjb::bbb
114 
115 #endif /*B3_PHYSICAL_ACTIVITY_H */
116 
size_t size() const
Gets the size of this person.
Definition: bbb_trajectory.h:118
void rename(const std::string &nm)
Rename this PA.
Definition: bbb_physical_activity.h:58
size_t end() const
Gets the end frame of this person.
Definition: bbb_trajectory.h:115
const std::string & name() const
Get this PA's name.
Definition: bbb_physical_activity.h:61
const Traj_set & trajectories() const
Get this PA's trajectory association.
Definition: bbb_physical_activity.h:76
size_t size() const
Gets the size of this PA.
Definition: bbb_physical_activity.h:70
std::ostream & operator<<(std::ostream &ost, const Activity_sequence &aseq)
Push an activity sequence to an output stream.
Physical_activity(const std::string &name, const Trajectory &trajectory, const Traj_set &trajs)
Create an empty PA.
Definition: bbb_physical_activity.h:44
Definition: bbb_trajectory.h:41
const Trajectory & trajectory() const
Get this PA's trajectory.
Definition: bbb_physical_activity.h:73
Definition: bbb_traj_set.h:37
const_iterator begin() const
Iterator to first index.
Definition: bbb_traj_set.h:67
size_t end() const
Gets the end frame of this PA.
Definition: bbb_physical_activity.h:67
size_t start() const
Gets the start frame of this PA.
Definition: bbb_physical_activity.h:64
size_t size() const
Number of trajectories in this set.
Definition: bbb_traj_set.h:79
Definition: bbb_physical_activity.h:39
size_t start() const
Gets the start frame of this person.
Definition: bbb_trajectory.h:112
void set_trajectory(const Trajectory &traj)
Set this PA's trajectory.
Definition: bbb_physical_activity.h:55
Iset::const_iterator const_iterator
Definition: bbb_traj_set.h:43
const_iterator end() const
Iterator to one-past-the-end index.
Definition: bbb_traj_set.h:70