00001 /* 00002 Smacky - Music emulator on speakers 00003 Copyright (C) 2006 - Nicolas Lermé 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 3 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 #ifndef __BLOCK_H__ 00021 #define __BLOCK_H__ 00022 00023 #include <vector> 00024 #include "smart_ptr.h" 00025 #include "entity.h" 00026 #include "impulse.h" 00027 00028 00029 class CBlock : public IEntity 00030 { 00031 friend class DefaultSPStorage<CBlock>; 00032 00033 private : 00034 ushort m_Loops; 00035 uint m_Tempo, m_NbNotes, m_NbPauses, m_NbBlocks; 00036 std::vector<CSmartPtr<IEntity> > m_Entities; 00037 00038 typedef std::vector<CSmartPtr<IEntity> > TEntities; 00039 typedef TEntities::iterator TEntitiesIt; 00040 typedef TEntities::const_iterator TEntitiesCIt; 00041 00042 CBlock( const ushort Loops, const uint Tempo ); 00043 00044 public : 00045 static CSmartPtr<CBlock> Create( const ushort Loops, const uint Tempo ) 00046 { 00047 return new CBlock(Loops, Tempo); 00048 } 00049 00050 virtual ~CBlock(); 00051 00052 static ushort DefaultLoops() 00053 { 00054 return 1; 00055 } 00056 00057 virtual void AddEntity( const CSmartPtr<IEntity> & Entity ); 00058 virtual void Purge(); 00059 virtual void Play() const; 00060 virtual EEntityType Type() const; 00061 00062 const ushort & Loops() const; 00063 void Loops( const ushort Loops ); 00064 const uint & Tempo() const; 00065 void Tempo( const uint Tempo ); 00066 const TEntities & Entities() const; 00067 const uint NbNotes() const; 00068 const uint NbPauses() const; 00069 const uint & NbBlocks() const; 00070 }; 00071 00072 #endif //__BLOCK_H__