Tide 0.1.0

cluster.h

Go to the documentation of this file.
00001 /* Tide
00002  *
00003  * Header for the Cluster element's base class.
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_CLUSTER_H_)
00029 #define TIDE_CLUSTER_H_
00030 
00031 #include <tide/block_element.h>
00032 #include <tide/master_element.h>
00033 #include <tide/uint_element.h>
00034 #include <tide/win_dll.h>
00035 
00038 
00039 namespace tide
00040 {
00046     class SilentTrackNumber : public UIntElement
00047     {
00048         public:
00049             SilentTrackNumber(uint64_t track_number)
00050                 : UIntElement(ids::SilentTrackNumber, track_number)
00051             {
00052             }
00053     };
00054 
00138     //template <typename Impl>
00139     class TIDE_EXPORT Cluster : public MasterElement
00140     {
00141         public:
00143             typedef boost::shared_ptr<Cluster> Ptr;
00145             typedef BlockElement::Ptr value_type;
00147             typedef size_t size_type;
00149             typedef value_type& reference;
00151             typedef value_type const& const_reference;
00152 
00158             Cluster(uint64_t timecode=0);
00159 
00161             virtual ~Cluster() {};
00162 
00164             // Cluster interface
00166 
00168             virtual bool empty() const = 0;
00170             virtual size_type count() const = 0;
00172             virtual void clear() = 0;
00173 
00178             //virtual void erase(typename Impl::Iterator position) = 0;
00184             //virtual void erase(typename Impl::Iterator first, typename Impl::Iterator last) = 0;
00185 
00194             virtual void push_back(value_type const& value) = 0;
00195 
00202             uint64_t timecode() const { return timecode_; }
00204             void timecode(uint64_t timecode) { timecode_ = timecode; }
00205 
00216             std::vector<SilentTrackNumber>& silent_tracks()
00217                 { return silent_tracks_; }
00218 
00227             uint64_t position() const;
00228 
00237             uint64_t previous_size() const { return prev_size_; }
00239             void previous_size(uint64_t size) { prev_size_ = size; }
00240 
00242             std::streamsize size() const;
00243 
00251             std::streamsize read(std::istream& input)
00252                 { return Element::read(input); }
00253 
00264             virtual std::streamsize finalise(std::ostream& output) = 0;
00265 
00266         protected:
00267             UIntElement timecode_;
00268             std::vector<SilentTrackNumber> silent_tracks_;
00269             UIntElement position_;
00270             UIntElement prev_size_;
00272             std::streamsize size_;
00273             bool writing_;
00274 
00276             //this element.
00277             std::streamsize meta_size() const;
00278 
00280             std::streamsize body_size() const
00281                 { return size_; }
00282 
00284             std::streamsize write_size(std::ostream& output);
00285 
00287             std::streamsize write_body(std::ostream& output);
00288 
00290             std::streamsize read_body(std::istream& input,
00291                     std::streamsize size);
00292 
00294             virtual std::streamsize blocks_size() const = 0;
00295 
00317             virtual std::streamsize read_blocks(std::istream& input,
00318                     std::streamsize size) = 0;
00319 
00324             std::streamsize read_silent_tracks(std::istream& input);
00325 
00327             virtual void reset();
00328     }; // class Cluster
00329 }; // namespace tide
00330 
00332 // group interfaces
00333 
00334 #endif // TIDE_CLUSTER_H_
00335 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines