Tawara  0.1.0
track_operation.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, 2012, Geoffrey Biggs, geoffrey.biggs@aist.go.jp
5  * RT-Synthesis Research Group
6  * Intelligent Systems Research Institute,
7  * National Institute of Advanced Industrial Science and Technology (AIST),
8  * Japan
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * * Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * * Redistributions in binary form must reproduce the above
18  * copyright notice, this list of conditions and the following
19  * disclaimer in the documentation and/or other materials provided
20  * with the distribution.
21  * * Neither the name of Geoffrey Biggs nor AIST, nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #if !defined(TAWARA_TRACK_OPERATION_H_)
40 #define TAWARA_TRACK_OPERATION_H_
41 
42 #include <boost/operators.hpp>
43 #include <boost/smart_ptr.hpp>
44 #include <tawara/el_ids.h>
45 #include <tawara/master_element.h>
46 #include <tawara/uint_element.h>
47 #include <tawara/win_dll.h>
48 #include <vector>
49 
52 
53 namespace tawara
54 {
60  {
61  public:
64  : MasterElement(id)
65  {}
66 
68  virtual ~TrackOperationBase() {}
69 
74  virtual std::string type() const = 0;
75 
77  typedef boost::shared_ptr<TrackOperationBase> Ptr;
78  }; // class TrackOperationBase
79 
80 
90  public boost::equality_comparable<TrackJoinBlocks>
91  {
92  public:
95 
98 
100  std::string type() const
101  {
102  return "joinblocks";
103  }
104 
110  void append(uint64_t uid);
111 
117  uint64_t remove(unsigned int pos);
118 
123  uint64_t operator[](unsigned int pos) const;
124 
126  unsigned int count() const { return uids_.size(); }
127 
129 
134  virtual std::streamsize write_body(std::ostream& output);
135 
137  friend bool operator==(TrackJoinBlocks const& lhs,
138  TrackJoinBlocks const& rhs);
139 
140  protected:
141  std::vector<UIntElement> uids_;
142 
144  virtual std::streamsize body_size() const;
145 
147  virtual std::streamsize read_body(std::istream& input,
148  std::streamsize size);
149  }; // class TrackJoinBlocks
150 
151 
153  inline bool operator==(TrackJoinBlocks const& lhs,
154  TrackJoinBlocks const& rhs)
155  {
156  return lhs.uids_ == rhs.uids_;
157  }
158 }; // namespace tawara
159 
161 // group elements
162 
163 #endif // TAWARA_TRACK_OPERATION_H_
164 
virtual ~TrackOperationBase()
Desctructor.
Abstract base class for individual track operations.
JoinBlocks track operation.
std::streamsize size(ID id)
Get the number of bytes required by an ID.
#define TAWARA_EXPORT
Definition: win_dll.h:51
The MasterElement interface.
std::vector< UIntElement > uids_
bool operator==(AttachedFile const &lhs, AttachedFile const &rhs)
Equality operator for the AttachedFile object.
TrackOperationBase(ids::ID id)
Constructor - this must be called to set the Class ID.
uint32_t ID
Definition: el_ids.h:60
~TrackJoinBlocks()
Destructor.
std::string type() const
Get the type of operation to be performed.
const ID TrackJoinBlocks(0xE9)
boost::shared_ptr< TrackOperationBase > Ptr
Base type of a track operation pointer.
unsigned int count() const
Get the number of UIDs stored.