0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-10-02 11:54:59 +03:00

Define code style and format all source file using clang-format-14

except those placed in 3rdparty directories.
This commit is contained in:
Андрей Лухнов
2024-09-04 17:31:16 +03:00
parent c5b9ac265d
commit 0fca7169d3
285 changed files with 19120 additions and 17875 deletions

View File

@@ -30,54 +30,61 @@
#ifndef LRATTRIBABSTRACTFACTORY_H
#define LRATTRIBABSTRACTFACTORY_H
#include "lrsingleton.h"
#include "lrglobal.h"
#include <stdexcept>
#include "lrsingleton.h"
#include <QMap>
#include <QString>
namespace LimeReport{
#include <stdexcept>
template
<
typename AbstractProduct,
typename IdentifierType,
typename ProductCreator,
typename Attribs
>
class AttribsAbstractFactory
: public Singleton< AttribsAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >
{
namespace LimeReport {
template <typename AbstractProduct, typename IdentifierType, typename ProductCreator,
typename Attribs>
class AttribsAbstractFactory:
public Singleton<
AttribsAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, Attribs>> {
private:
typedef QMap<IdentifierType,ProductCreator> FactoryMap;
typedef QMap<IdentifierType,Attribs> AliasMap;
friend class Singleton< AttribsAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >;
typedef QMap<IdentifierType, ProductCreator> FactoryMap;
typedef QMap<IdentifierType, Attribs> AliasMap;
friend class Singleton<
AttribsAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, Attribs>>;
public:
bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator){
if (m_factoryMap.contains(id)) return true;
return (m_factoryMap.insert(id,creator).value() == creator) &&
(m_attribsMap.insert(id,attribs).value() == attribs);
bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator)
{
if (m_factoryMap.contains(id))
return true;
return (m_factoryMap.insert(id, creator).value() == creator)
&& (m_attribsMap.insert(id, attribs).value() == attribs);
}
bool unregisterCreator(const IdentifierType& id){
bool unregisterCreator(const IdentifierType& id)
{
return (m_factoryMap.remove(id) == 1) && (m_attribsMap.remove(id) == 1);
}
ProductCreator objectCreator(const IdentifierType& id){
if (m_factoryMap.contains(id)){
ProductCreator objectCreator(const IdentifierType& id)
{
if (m_factoryMap.contains(id)) {
return m_factoryMap[id];
} else return 0;
} else
return 0;
}
QString attribs(const IdentifierType& id){
if (m_attribsMap.contains(id)){
QString attribs(const IdentifierType& id)
{
if (m_attribsMap.contains(id)) {
return m_attribsMap.value(id);
} else return "";
} else
return "";
}
const FactoryMap& map(){return m_factoryMap;}
const AliasMap& attribsMap(){return m_attribsMap;}
int mapElementCount(){return m_factoryMap.count();}
private:
const FactoryMap& map() { return m_factoryMap; }
const AliasMap& attribsMap() { return m_attribsMap; }
int mapElementCount() { return m_factoryMap.count(); }
private:
FactoryMap m_factoryMap;
AliasMap m_attribsMap;
};
}
} // namespace LimeReport
#endif // LRATTRIBABSTRACTFACTORY_H

View File

@@ -30,74 +30,76 @@
#ifndef LRSIMPLEABSTRACTFACTORY_H
#define LRSIMPLEABSTRACTFACTORY_H
#include "lrsingleton.h"
#include "lrglobal.h"
#include <stdexcept>
#include "lrsingleton.h"
#include <QHash>
#include <QMap>
#include <QString>
namespace LimeReport{
template
<
typename AbstractProduct,
typename IdentifierType,
typename ProductCreator
>
class SimpleAbstractFactory
: public Singleton< SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > >
{
#include <stdexcept>
namespace LimeReport {
template <typename AbstractProduct, typename IdentifierType, typename ProductCreator>
class SimpleAbstractFactory:
public Singleton<SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator>> {
private:
typedef QHash<IdentifierType,ProductCreator> FactoryMap;
friend class Singleton< SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > >;
typedef QHash<IdentifierType, ProductCreator> FactoryMap;
friend class Singleton<SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator>>;
public:
bool registerCreator(const IdentifierType& id, ProductCreator creator){
return (m_factoryMap.insert(id,creator).value()==creator);
bool registerCreator(const IdentifierType& id, ProductCreator creator)
{
return (m_factoryMap.insert(id, creator).value() == creator);
}
bool unregisterCreator(const IdentifierType& id){
return (m_factoryMap.remove(id)==1);
}
ProductCreator objectCreator(const IdentifierType& id){
if (m_factoryMap.contains(id)){
bool unregisterCreator(const IdentifierType& id) { return (m_factoryMap.remove(id) == 1); }
ProductCreator objectCreator(const IdentifierType& id)
{
if (m_factoryMap.contains(id)) {
return m_factoryMap[id];
} else {
return 0;
}
}
const FactoryMap& map(){return m_factoryMap;}
int mapElementCount(){return m_factoryMap.count();}
const FactoryMap& map() { return m_factoryMap; }
int mapElementCount() { return m_factoryMap.count(); }
private:
FactoryMap m_factoryMap;
};
template
<
typename AbstractProduct,
typename IdentifierType,
typename ProductCreator,
typename Attribs
>
class AttribAbstractFactory : public SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator >{
typedef SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > SimpleFactory;
typedef QMap<IdentifierType,Attribs> AliasMap;
friend class Singleton<AttribAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >;
public :
bool registerCreator(const IdentifierType &id, Attribs attribs, ProductCreator creator){
return SimpleFactory::registerCreator(id,creator) && (m_attribsMap.insert(id,attribs).value()==attribs);
template <typename AbstractProduct, typename IdentifierType, typename ProductCreator,
typename Attribs>
class AttribAbstractFactory:
public SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator> {
typedef SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator> SimpleFactory;
typedef QMap<IdentifierType, Attribs> AliasMap;
friend class Singleton<
AttribAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, Attribs>>;
public:
bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator)
{
return SimpleFactory::registerCreator(id, creator)
&& (m_attribsMap.insert(id, attribs).value() == attribs);
}
bool unregisterCreator(const IdentifierType &id){
return SimpleFactory::unregisterCreator(id)&&(m_attribsMap.remove(id)==1);
bool unregisterCreator(const IdentifierType& id)
{
return SimpleFactory::unregisterCreator(id) && (m_attribsMap.remove(id) == 1);
}
QString attribs(const IdentifierType& id){
if (m_attribsMap.contains(id)){
QString attribs(const IdentifierType& id)
{
if (m_attribsMap.contains(id)) {
return m_attribsMap.value(id);
} else return "";
} else
return "";
}
const AliasMap& attribsMap(){return m_attribsMap;}
const AliasMap& attribsMap() { return m_attribsMap; }
private:
AliasMap m_attribsMap;
};
}
} // namespace LimeReport
#endif //LRSIMPLEABSTRACTFACTORY_H
#endif // LRSIMPLEABSTRACTFACTORY_H

View File

@@ -32,28 +32,27 @@
#include <cstdlib>
namespace LimeReport{
namespace LimeReport {
template <typename T>
class Singleton
{
template <typename T> class Singleton {
public:
static T& instance(){
if (0==inst){
static T& instance()
{
if (0 == inst) {
inst = new T();
::atexit( destroy );
} else {};
::atexit(destroy);
} else {
};
return *inst;
}
private:
static T* inst;
private:
static void destroy() {
delete inst;
}
static void destroy() { delete inst; }
};
template <typename T>
T* Singleton< T >::inst =0;
}
template <typename T> T* Singleton<T>::inst = 0;
} // namespace LimeReport
#endif // LRSINGLETON_H