Tide 0.1.0
|
00001 /* Tide 00002 * 00003 * Header for the TrackEntry element and related elements. 00004 * 00005 * Copyright 2011 Geoffrey Biggs geoffrey.biggs@aist.go.jp 00006 * RT-Synthesis Research Group 00007 * Intelligent Systems Research Institute, 00008 * National Institute of Advanced Industrial Science and Technology (AIST), 00009 * Japan 00010 * All rights reserved. 00011 * 00012 * This file is part of Tide. 00013 * 00014 * Tide is free software; you can redistribute it and/or modify it under 00015 * the terms of the GNU Lesser General Public License as published by 00016 * the Free Software Foundation; either version 2.1 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * Tide is distributed in the hope that it will be useful, but WITHOUT 00020 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00021 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00022 * License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public 00025 * License along with Tide. If not, see <http://www.gnu.org/licenses/>. 00026 */ 00027 00028 #if !defined(TIDE_TRACKS_H_) 00029 #define TIDE_TRACKS_H_ 00030 00031 #include <boost/operators.hpp> 00032 #include <map> 00033 #include <tide/master_element.h> 00034 #include <tide/track_entry.h> 00035 #include <tide/uint_element.h> 00036 #include <tide/win_dll.h> 00037 00040 00041 namespace tide 00042 { 00050 class TIDE_EXPORT Tracks : public MasterElement, 00051 public boost::equality_comparable<Tracks> 00052 { 00053 public: 00055 typedef uint64_t key_type; 00057 typedef TrackEntry::Ptr mapped_type; 00058 00059 protected: 00061 typedef std::map<key_type, mapped_type> storage_type_; 00062 00063 public: 00069 Tracks(); 00070 00072 virtual ~Tracks() {}; 00073 00075 typedef storage_type_::value_type value_type; 00077 typedef storage_type_::size_type size_type; 00079 typedef storage_type_::reference reference; 00081 typedef storage_type_::const_reference const_reference; 00083 typedef storage_type_::iterator iterator; 00085 typedef storage_type_::const_iterator const_iterator; 00087 typedef storage_type_::reverse_iterator reverse_iterator; 00089 typedef storage_type_::const_reverse_iterator 00090 const_reverse_iterator; 00091 00095 Tracks& operator=(Tracks const& other) 00096 { entries_ = other.entries_; return *this; } 00097 00103 mapped_type& at(key_type const& pos) 00104 { return entries_.at(pos); } 00110 mapped_type const& at(key_type const& pos) const 00111 { return entries_.at(pos); } 00112 00119 mapped_type& operator[](key_type const& key); 00126 mapped_type const& operator[](key_type const& key) const; 00127 00129 iterator begin() { return entries_.begin(); } 00131 const_iterator begin() const { return entries_.begin(); } 00133 iterator end() { return entries_.end(); } 00135 const_iterator end() const { return entries_.end(); } 00137 reverse_iterator rbegin() { return entries_.rbegin(); } 00139 const_reverse_iterator rbegin() const { return entries_.rbegin(); } 00143 reverse_iterator rend() { return entries_.rend(); } 00147 const_reverse_iterator rend() const { return entries_.rend(); } 00148 00150 bool empty() const { return entries_.empty(); } 00152 size_type count() const { return entries_.size(); } 00154 size_type max_count() const { return entries_.max_size(); } 00155 00157 void clear() { entries_.clear(); } 00175 std::pair<iterator, bool> insert(mapped_type const& value); 00185 void insert(const_iterator first, const_iterator last); 00190 void erase(iterator position) 00191 { entries_.erase(position); } 00197 void erase(iterator first, iterator last) 00198 { entries_.erase(first, last); } 00204 size_type erase(key_type const& number) 00205 { return entries_.erase(number); } 00210 void swap(Tracks& other) 00211 { entries_.swap(other.entries_); } 00212 00219 iterator find(key_type const& number) 00220 { return entries_.find(number); } 00227 const_iterator find(key_type const& number) const 00228 { return entries_.find(number); } 00229 00237 virtual std::streamsize write_body(std::ostream& output); 00238 00240 friend bool operator==(Tracks const& lhs, Tracks const& rhs); 00241 00242 protected: 00247 storage_type_ entries_; 00248 00250 virtual std::streamsize body_size() const; 00251 00259 virtual std::streamsize read_body(std::istream& input, 00260 std::streamsize size); 00261 00269 void validate_entries() const; 00270 00285 void verify_not_duplicate(TrackEntry::Ptr entry) const; 00286 }; // class Tracks 00287 00288 bool operator==(Tracks const& lhs, Tracks const& rhs); 00289 }; // namespace tide 00290 00292 // group elements 00293 00294 #endif // TIDE_TRACKS_H_ 00295