1 #ifndef	_PLAYLIST_H
2 #define _PLAYLIST_H
3 
4 #include <string>
5 #include "base.h"
6 #include "SmartPtr.h"
7 
8 namespace	ContentDecoder
9 {
10 
11 /*
12 	CPlaylist().
13 	Playlist interface.
14 */
15 class	CPlaylist
16 {
17 	public:
CPlaylist()18 			CPlaylist()	{}
~CPlaylist()19 			virtual ~CPlaylist()	{}
20 			virtual uint32	Size() = PureVirtual;
21 			virtual bool	Add( const std::string &_file ) = PureVirtual;
22 			virtual bool	Next( std::string &_result, bool& _bEnoughSheep, uint32 _curID, const bool _bRebuild = false, bool _bStartByRandom = true ) = PureVirtual;
23 			virtual bool	ChooseSheepForPlaying( uint32 curGen, uint32 curID ) = PureVirtual;
24 
GetSheepInfoFromPath(const std::string & _path,uint32 & Generation,uint32 & ID,uint32 & First,uint32 & Last,std::string & _filename)25 			virtual bool GetSheepInfoFromPath( const std::string& _path, uint32& Generation, uint32& ID, uint32& First, uint32& Last, std::string& _filename )
26 			{
27 				//	Remove the full path so we can work on the filename.
28 				size_t offs = _path.find_last_of( "/\\", _path.size() );
29 
30 				_filename = _path.substr(offs+1);
31 
32 				//	Deduce graph position from filename.
33 				int ret = sscanf( _filename.c_str(), "%d=%d=%d=%d.avi", &Generation, &ID, &First, &Last );
34 				if( ret != 4 )
35 				{
36 					g_Log->Error( "Unable to deduce sheep info from %s", _path.c_str() );
37 					return false;
38 				}
39 
40 				return true;
41 			}
42 
43 };
44 
45 MakeSmartPointers( CPlaylist );
46 
47 }
48 
49 
50 #endif
51