KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bbb_intentional_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_INTENTIONAL_ACTIVITY_H
22 #define B3_INTENTIONAL_ACTIVITY_H
23 
24 #include <bbb_cpp/bbb_traj_set.h>
25 #include <m_cpp/m_vector.h>
26 #include <string>
27 #include <iostream>
28 #include <algorithm>
29 #include <iterator>
30 
31 namespace kjb {
32 namespace bbb {
33 
40 {
41 public:
42  typedef Vector Param;
43 
44 public:
47  (
48  const std::string& name,
49  size_t start,
50  size_t end,
51  const Param& params,
52  const Traj_set& trajs
53  ) :
54  name_(name),
55  start_(start),
56  end_(end),
57  params_(params),
58  trajs_(trajs)
59  {}
60 
62  const std::string& name() const { return name_; }
63 
65  size_t start() const { return start_; }
66 
68  size_t end() const { return end_; }
69 
71  size_t size() const { return end() - start() + 1; }
72 
74  const Param& parameters() const { return params_; }
75 
77  const Traj_set& trajectories() const { return trajs_; }
78 
79 private:
80  std::string name_;
81  size_t start_;
82  size_t end_;
83  Param params_;
84  Traj_set trajs_;
85 };
86 
87 /* \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ */
88 
90 inline
91 std::ostream& operator<<(std::ostream& ost, const Intentional_activity& activity)
92 {
93  // sanity check
94  assert(activity.trajectories().size() != 0);
95 
96  // output name and times
97  ost << activity.name() << "(";
98  ost << activity.start() << ", ";
99  ost << activity.end() << ")";
100  ost << " : ";
101 
102  // output params
103  ost << "[";
104  ost << activity.parameters();
105  ost << "]";
106  ost << " : ";
107 
108  // output member trajectories
109  Traj_set::const_iterator szt_p = --activity.trajectories().end();
110  ost << "{";
111  std::copy(
112  activity.trajectories().begin(), szt_p,
113  std::ostream_iterator<Traj_set::value_type>(ost, ", "));
114  ost << *szt_p << "}";
115 
116  return ost;
117 }
118 
119 }} // namespace kjb::bbb
120 
121 #endif /*B3_INTENTIONAL_ACTIVITY_H */
122 
Definition: bbb_intentional_activity.h:39
Intentional_activity(const std::string &name, size_t start, size_t end, const Param &params, const Traj_set &trajs)
Create an empty IA with the given name and roles.
Definition: bbb_intentional_activity.h:47
const Param & parameters() const
Get this IA's parameters.
Definition: bbb_intentional_activity.h:74
Vector Param
Definition: bbb_intentional_activity.h:42
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
std::ostream & operator<<(std::ostream &ost, const Activity_sequence &aseq)
Push an activity sequence to an output stream.
size_t size() const
Gets the size of this IA.
Definition: bbb_intentional_activity.h:71
size_t end() const
Gets the end frame of this IA.
Definition: bbb_intentional_activity.h:68
size_t start() const
Gets the start frame of this IA.
Definition: bbb_intentional_activity.h:65
Definition: bbb_traj_set.h:37
const_iterator begin() const
Iterator to first index.
Definition: bbb_traj_set.h:67
const std::string & name() const
Gets the name of this IA.
Definition: bbb_intentional_activity.h:62
size_t size() const
Number of trajectories in this set.
Definition: bbb_traj_set.h:79
const Traj_set & trajectories() const
Get this IA's trajectories.
Definition: bbb_intentional_activity.h:77
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
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