Commit ff7d830a authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Put public types in a medialibrary namespace

parent 0c9b3d36
......@@ -27,6 +27,9 @@
#include "IMediaLibrary.h"
namespace medialibrary
{
class IAlbum
{
public:
......@@ -66,3 +69,5 @@ public:
virtual uint32_t nbTracks() const = 0;
virtual unsigned int duration() const = 0;
};
}
......@@ -25,6 +25,9 @@
#include "IMediaLibrary.h"
namespace medialibrary
{
class IAlbumTrack
{
public:
......@@ -50,4 +53,6 @@ class IAlbumTrack
virtual unsigned int discNumber() const = 0;
};
}
#endif // IALBUMTRACK_H
......@@ -27,6 +27,9 @@
#include "IMediaLibrary.h"
namespace medialibrary
{
class IArtist
{
public:
......@@ -39,3 +42,5 @@ public:
virtual const std::string& artworkMrl() const = 0;
virtual const std::string& musicBrainzId() const = 0;
};
}
......@@ -25,6 +25,9 @@
#include "IMediaLibrary.h"
namespace medialibrary
{
class IAudioTrack
{
public:
......@@ -41,4 +44,6 @@ class IAudioTrack
virtual const std::string& description() const = 0;
};
}
#endif // IAUDIOTRACK_H
......@@ -24,6 +24,9 @@
#include <string>
namespace medialibrary
{
class IFile
{
public:
......@@ -53,3 +56,5 @@ public:
virtual Type type() const = 0;
virtual unsigned int lastModificationDate() const = 0;
};
}
......@@ -26,6 +26,9 @@
#include <vector>
namespace medialibrary
{
class IGenre
{
public:
......@@ -36,3 +39,5 @@ public:
virtual std::vector<MediaPtr> tracks( medialibrary::SortingCriteria sort = medialibrary::SortingCriteria::Default, bool desc = false ) const = 0;
virtual std::vector<AlbumPtr> albums( medialibrary::SortingCriteria sort = medialibrary::SortingCriteria::Default, bool desc = false ) const = 0;
};
}
......@@ -24,6 +24,9 @@
#include <string>
namespace medialibrary
{
class IHistoryEntry
{
public:
......@@ -33,3 +36,5 @@ public:
virtual bool isFavorite() const = 0;
virtual bool setFavorite( bool isFavorite ) = 0;
};
}
......@@ -28,6 +28,9 @@
#include "IMediaLibrary.h"
namespace medialibrary
{
class ILabel
{
public:
......@@ -38,4 +41,6 @@ class ILabel
virtual std::vector<MediaPtr> files() = 0;
};
}
#endif // ILABEL_H
......@@ -24,6 +24,9 @@
#include <string>
namespace medialibrary
{
class ILogger
{
public:
......@@ -33,3 +36,5 @@ public:
virtual void Info( const std::string& msg ) = 0;
virtual void Debug( const std::string& msg ) = 0;
};
}
......@@ -27,6 +27,9 @@
#include "IMediaLibrary.h"
namespace medialibrary
{
class IAlbumTrack;
class IShowEpisode;
class ITrackInformation;
......@@ -93,3 +96,5 @@ class IMedia
virtual unsigned int insertionDate() const = 0;
virtual unsigned int releaseDate() const = 0;
};
}
......@@ -64,7 +64,6 @@ namespace medialibrary
LastModificationDate,
ReleaseDate,
};
}
class IMediaLibraryCb
{
......@@ -207,9 +206,11 @@ class IMediaLibrary
virtual void reload( const std::string& entryPoint ) = 0;
};
}
extern "C"
{
IMediaLibrary* NewMediaLibrary();
medialibrary::IMediaLibrary* NewMediaLibrary();
}
#endif // IMEDIALIBRARY_H
......@@ -25,6 +25,9 @@
#include "IMediaLibrary.h"
namespace medialibrary
{
class IMovie
{
public:
......@@ -37,4 +40,6 @@ class IMovie
virtual std::vector<MediaPtr> files() = 0;
};
}
#endif // IMOVIE_H
......@@ -26,6 +26,9 @@
#include "Types.h"
namespace medialibrary
{
class IPlaylist
{
public:
......@@ -72,3 +75,5 @@ public:
///
virtual bool remove( int64_t mediaId ) = 0;
};
}
......@@ -25,6 +25,9 @@
#include "IMediaLibrary.h"
namespace medialibrary
{
class IShow
{
public:
......@@ -38,4 +41,6 @@ class IShow
virtual std::vector<ShowEpisodePtr> episodes() = 0;
};
}
#endif // ISHOW_H
......@@ -23,10 +23,11 @@
#ifndef ISHOWEPISODE_H
#define ISHOWEPISODE_H
class IShow;
#include "IMediaLibrary.h"
namespace medialibrary
{
class IShowEpisode
{
public:
......@@ -43,4 +44,6 @@ class IShowEpisode
virtual std::vector<MediaPtr> files() = 0;
};
}
#endif // ISHOWEPISODE_H
......@@ -25,6 +25,9 @@
#include "IMediaLibrary.h"
namespace medialibrary
{
class IVideoTrack
{
public:
......@@ -36,4 +39,6 @@ class IVideoTrack
virtual float fps() const = 0;
};
}
#endif // IVIDEOTRACK_H
......@@ -24,10 +24,12 @@
#include <memory>
namespace medialibrary
{
class IAlbum;
class IAlbumTrack;
class IAudioTrack;
class IDiscoverer;
class IFile;
class IGenre;
class IHistoryEntry;
......@@ -41,8 +43,7 @@ class IVideoTrack;
class ILogger;
class IArtist;
class IPlaylist;
class SqliteConnection;
class MediaLibrary;
class IMediaLibraryCb;
using AlbumPtr = std::shared_ptr<IAlbum>;
using AlbumTrackPtr = std::shared_ptr<IAlbumTrack>;
......@@ -59,10 +60,6 @@ using ShowEpisodePtr = std::shared_ptr<IShowEpisode>;
using ShowPtr = std::shared_ptr<IShow>;
using VideoTrackPtr = std::shared_ptr<IVideoTrack>;
using MediaLibraryPtr = const MediaLibrary*;
typedef SqliteConnection* DBConnection;
enum class LogLevel
{
/// Verbose: Extra logs (currently used by to enable third parties logs
......@@ -73,3 +70,11 @@ enum class LogLevel
Warning,
Error,
};
}
class SqliteConnection;
class MediaLibrary;
typedef SqliteConnection* DBConnection;
using MediaLibraryPtr = const MediaLibrary*;
......@@ -41,7 +41,7 @@ struct FileTable
};
}
class File : public IFile, public DatabaseHelpers<File, policy::FileTable>
class File : public medialibrary::IFile, public DatabaseHelpers<File, policy::FileTable>
{
public:
File( MediaLibraryPtr ml, sqlite::Row& row );
......
......@@ -48,6 +48,8 @@ namespace factory
class IFileSystem;
}
using namespace medialibrary;
class MediaLibrary : public IMediaLibrary
{
public:
......
......@@ -65,6 +65,6 @@ private:
std::condition_variable m_cond;
std::atomic_bool m_run;
std::vector<std::unique_ptr<IDiscoverer>> m_discoverers;
IMediaLibraryCb* m_cb;
medialibrary::IMediaLibraryCb* m_cb;
};
......@@ -22,10 +22,10 @@
#pragma once
#include <ILogger.h>
#include "ILogger.h"
#include <iostream>
class IostreamLogger : public ILogger
class IostreamLogger : public medialibrary::ILogger
{
public:
virtual void Error(const std::string& msg) override
......
......@@ -23,6 +23,8 @@
#include "Logger.h"
#include "logging/IostreamLogger.h"
using namespace medialibrary;
std::unique_ptr<ILogger> Log::s_defaultLogger = std::unique_ptr<ILogger>( new IostreamLogger );
std::atomic<ILogger*> Log::s_logger;
std::atomic<LogLevel> Log::s_logLevel;
......@@ -55,7 +55,7 @@ private:
}
template <typename... Args>
static void log(LogLevel lvl, Args&&... args)
static void log( medialibrary::LogLevel lvl, Args&&... args)
{
if ( lvl < s_logLevel.load( std::memory_order_relaxed ) )
return;
......@@ -72,34 +72,34 @@ private:
switch ( lvl )
{
case LogLevel::Error:
case medialibrary::LogLevel::Error:
l->Error( msg );
break;
case LogLevel::Warning:
case medialibrary::LogLevel::Warning:
l->Warning( msg );
break;
case LogLevel::Info:
case medialibrary::LogLevel::Info:
l->Info( msg );
break;
case LogLevel::Verbose:
case LogLevel::Debug:
case medialibrary::LogLevel::Verbose:
case medialibrary::LogLevel::Debug:
l->Debug( msg );
break;
}
}
public:
static void SetLogger( ILogger* logger )
static void SetLogger( medialibrary::ILogger* logger )
{
s_logger.store( logger, std::memory_order_relaxed );
}
static void setLogLevel( LogLevel level )
static void setLogLevel( medialibrary::LogLevel level )
{
s_logLevel.store( level, std::memory_order_relaxed );
}
static LogLevel logLevel()
static medialibrary::LogLevel logLevel()
{
return s_logLevel.load( std::memory_order_relaxed );
}
......@@ -107,33 +107,33 @@ public:
template <typename... Args>
static void Error( Args&&... args )
{
log( LogLevel::Error, std::forward<Args>( args )... );
log( medialibrary::LogLevel::Error, std::forward<Args>( args )... );
}
template <typename... Args>
static void Warning( Args&&... args )
{
log( LogLevel::Warning, std::forward<Args>( args )... );
log( medialibrary::LogLevel::Warning, std::forward<Args>( args )... );
}
template <typename... Args>
static void Info( Args&&... args )
{
log( LogLevel::Info, std::forward<Args>( args )... );
log( medialibrary::LogLevel::Info, std::forward<Args>( args )... );
}
template <typename... Args>
static void Debug( Args&&... args )
{
log( LogLevel::Debug, std::forward<Args>( args )... );
log( medialibrary::LogLevel::Debug, std::forward<Args>( args )... );
}
private:
private:
static std::unique_ptr<ILogger> s_defaultLogger;
static std::atomic<ILogger*> s_logger;
static std::atomic<LogLevel> s_logLevel;
static std::unique_ptr<medialibrary::ILogger> s_defaultLogger;
static std::atomic<medialibrary::ILogger*> s_logger;
static std::atomic<medialibrary::LogLevel> s_logLevel;
};
#if defined(__clang__) || defined(__GNUG__)
......
......@@ -29,8 +29,6 @@
#include "File.h"
class IMediaLibraryCb;
// Use an interface to expose only the "done" method
class IParserCb
{
......
......@@ -32,7 +32,6 @@
#include "Types.h"
class IParserCb;
class IMediaLibraryCb;
class ModificationNotifier;
class ParserService
......@@ -73,7 +72,7 @@ private:
protected:
MediaLibrary* m_ml;
IMediaLibraryCb* m_cb;
medialibrary::IMediaLibraryCb* m_cb;
std::shared_ptr<ModificationNotifier> m_notifier;
private:
......
......@@ -29,9 +29,10 @@
#include <thread>
#include <vector>
#include <chrono>
#include "Types.h"
class IMediaLibraryCb;
using namespace medialibrary;
class ModificationNotifier
{
......
......@@ -36,7 +36,7 @@ struct Init
};
instance = VLC::Instance( sizeof(args) / sizeof(args[0]), args );
instance.logSet([this](int lvl, const libvlc_log_t*, std::string msg) {
if ( Log::logLevel() != LogLevel::Verbose )
if ( Log::logLevel() != medialibrary::LogLevel::Verbose )
return;
if ( lvl == LIBVLC_ERROR )
Log::Error( msg );
......
......@@ -24,6 +24,8 @@
#include "IMediaLibrary.h"
using namespace medialibrary;
namespace mock
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment