23 #ifndef ABSTRACTFRAME_H 24 #define ABSTRACTFRAME_H 26 #include <taglib/fileref.h> 27 #include <taglib/mpegfile.h> 28 #include <taglib/id3v2tag.h> 29 #include <taglib/id3v2frame.h> 32 #include "Helper/Logger/Logger.h" 40 template<
typename ModelType_t,
typename FrameType_t>
50 const char* _four=
nullptr;
51 TagLib::ID3v2::Tag* _tag=
nullptr;
52 ModelType_t _data_model;
53 FrameType_t* _frame=
nullptr;
72 virtual void map_frame_to_model()=0;
82 TagLib::MPEG::File* file_mp3;
83 TagLib::ID3v2::FrameListMap map;
84 TagLib::ID3v2::FrameList frame_list;
86 file_mp3 =
dynamic_cast<TagLib::MPEG::File*
>(file_ref->file());
91 _tag = file_mp3->ID3v2Tag();
97 map = _tag->frameListMap();
98 frame_list = map[_four];
99 if(!frame_list.isEmpty()) {
100 _frame =
dynamic_cast<FrameType_t*
> (frame_list.front());
116 virtual bool read(ModelType_t& data){
121 map_frame_to_model();
134 virtual bool write(
const ModelType_t& data_model){
136 bool created =
false;
152 _data_model = data_model;
158 _tag->addFrame(_frame);
170 return (_frame !=
nullptr);
174 #endif // ABSTRACTFRAME_H virtual bool read(ModelType_t &data)
sets the _data_model by reading from the frame
Definition: AbstractFrame.h:116
virtual bool write(const ModelType_t &data_model)
insert the _data_model into the frame
Definition: AbstractFrame.h:134
bool is_frame_found() const
if the frame was found when called read()
Definition: AbstractFrame.h:169
ID3v2Frame namespace.
Definition: AbstractFrame.h:38
The AbstractFrame class for example AbstractFrame<Discnumber, TagLib::ID3v2::TextIdentificationFrame>...
Definition: AbstractFrame.h:47
virtual void map_model_to_frame()=0
map_model_to_frame maps the model to the frame and vice versa so the frame knows how to get/set data ...
virtual TagLib::ID3v2::Frame * create_id3v2_frame()=0
create_id3v2_frame creates new id3v2 frame if there's no frame we have to create it manually every su...