foobar2000 SDK  2015-08-03
playable_location.h
Go to the documentation of this file.
1 #ifndef _FOOBAR2000_PLAYABLE_LOCATION_H_
2 #define _FOOBAR2000_PLAYABLE_LOCATION_H_
3 
4 //playable_location stores location of a playable resource, currently implemented as file path and integer for indicating multiple playable "subsongs" per file
5 //also see: file_info.h
6 //for getting more info about resource referenced by a playable_location, see metadb.h
7 
8 //char* strings are all UTF-8
9 
10 class NOVTABLE playable_location//interface (for passing around between DLLs)
11 {
12 public:
13  virtual const char * get_path() const = 0;
14  virtual void set_path(const char*) = 0;
15  virtual t_uint32 get_subsong() const = 0;
16  virtual void set_subsong(t_uint32) = 0;
17 
18  void copy(const playable_location & p_other) {
19  set_path(p_other.get_path());
20  set_subsong(p_other.get_subsong());
21  }
22 
23  static int g_compare(const playable_location & p_item1,const playable_location & p_item2);
24  static bool g_equals( const playable_location & p_item1, const playable_location & p_item2);
25 
26  const playable_location & operator=(const playable_location & src) {copy(src);return *this;}
27 
28  bool operator==(const playable_location & p_other) const;
29  bool operator!=(const playable_location & p_other) const;
30 
31  void reset();
32 
33  inline t_uint32 get_subsong_index() const {return get_subsong();}
34  inline void set_subsong_index(t_uint32 v) {set_subsong(v);}
35 
36  bool is_empty() const;
37  bool is_valid() const;
38 
39 
40  class comparator {
41  public:
42  static int compare(const playable_location & v1, const playable_location & v2) {return g_compare(v1,v2);}
43  };
44 
45 protected:
48 };
49 
54 
55 class playable_location_impl : public playable_location//implementation
56 {
57 public:
58  virtual const char * get_path() const;
59  virtual void set_path(const char* p_path);
60  virtual t_uint32 get_subsong() const;
61  virtual void set_subsong(t_uint32 p_subsong);
62 
63  const playable_location_impl & operator=(const playable_location & src);
64 
66  playable_location_impl(const char * p_path,t_uint32 p_subsong);
68 private:
71 };
72 
73 // usage: somefunction( make_playable_location("file://c:\blah.ogg",0) );
74 // only for use as a parameter to a function taking const playable_location &
76 {
77  const char * path;
79 
80  virtual void set_path(const char*);
81  virtual void set_subsong(t_uint32);
82 public:
83  virtual const char * get_path() const;
84  virtual t_uint32 get_subsong() const;
85 
86  make_playable_location(const char * p_path,t_uint32 p_num);
87 };
88 
90 
91 #endif //_FOOBAR2000_PLAYABLE_LOCATION_H_
playable_location & rplayable_location
virtual t_uint32 get_subsong() const =0
const playable_location & operator=(const playable_location &src)
void set_subsong_index(t_uint32 v)
virtual const char * get_path() const =0
playable_location const & rcplayable_location
pfc::string_base & operator<<(pfc::string_base &p_fmt, const playable_location &p_location)
string_simple_t< char > string_simple
Definition: string_base.h:826
bool operator==(const replaygain_info &item1, const replaygain_info &item2)
Definition: file_info.h:66
t_uint32 get_subsong_index() const
void copy(const playable_location &p_other)
bool operator!=(const replaygain_info &item1, const replaygain_info &item2)
Definition: file_info.h:67
pfc::string_simple m_path
playable_location const * pcplayable_location
This is free and unencumbered software released into the public domain Anyone is free to copy
Definition: pfc-license.txt:3
playable_location * pplayable_location
uint32_t t_uint32
Definition: int_types.h:5
static int compare(const playable_location &v1, const playable_location &v2)