libzypp 17.34.0
zyppglobal.h File Reference
Include dependency graph for zyppglobal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LIBZYPP_NG_EXPORT
 
#define LIBZYPP_NG_NO_EXPORT
 
#define ZYPP_DECLARE_PRIVATE(Class)
 
#define ZYPP_IMPL_PRIVATE(Class)
 
#define ZYPP_DECLARE_PUBLIC(Class)
 
#define Z_D()   auto const d = d_func()
 
#define Z_Z()   auto const z = z_func()
 
#define ZYPP_FWD_DECL_REFS(T)
 
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
 
#define ZYPP_FWD_DECL_TEMPL_TYPE_WITH_REFS_ARG1(T, TArg1)
 
#define ZYPP_ADD_PRIVATE_CONSTR_HELPER()    struct private_constr_t { private_constr_t () noexcept = default; }
 
#define ZYPP_PRIVATE_CONSTR_ARG    private_constr_t
 
#define ZYPP_PRIVATE_CONSTR_ARG_VAL    private_constr_t{}
 
#define ZYPP_ADD_CREATE_FUNC(Class)
 
#define ZYPP_DECL_PRIVATE_CONSTR(Class)   Class( private_constr_t )
 
#define ZYPP_IMPL_PRIVATE_CONSTR(Class)   Class::Class( private_constr_t )
 
#define ZYPP_DECL_PRIVATE_CONSTR_ARGS(Class, ...)   Class( private_constr_t, __VA_ARGS__ )
 
#define ZYPP_IMPL_PRIVATE_CONSTR_ARGS(Class, ...)   Class::Class( private_constr_t, __VA_ARGS__ )
 

Functions

template<typename T >
T * zyppGetPtrHelper (T *ptr)
 
template<typename Ptr >
auto zyppGetPtrHelper (const Ptr &ptr) -> decltype(ptr.operator->())
 
template<typename Ptr >
auto zyppGetPtrHelper (Ptr &ptr) -> decltype(ptr.operator->())
 

Macro Definition Documentation

◆ LIBZYPP_NG_EXPORT

#define LIBZYPP_NG_EXPORT

Definition at line 7 of file zyppglobal.h.

◆ LIBZYPP_NG_NO_EXPORT

#define LIBZYPP_NG_NO_EXPORT

Definition at line 8 of file zyppglobal.h.

◆ ZYPP_DECLARE_PRIVATE

#define ZYPP_DECLARE_PRIVATE ( Class)
Value:
Class##Private* d_func();\
const Class##Private* d_func() const; \
friend class Class##Private;

Definition at line 86 of file zyppglobal.h.

◆ ZYPP_IMPL_PRIVATE

#define ZYPP_IMPL_PRIVATE ( Class)
Value:
Class##Private* Class::d_func() \
{ return static_cast<Class##Private *>(zyppGetPtrHelper(d_ptr)); } \
const Class##Private* Class::d_func() const \
{ return static_cast<const Class##Private *>(zyppGetPtrHelper(d_ptr)); }
T * zyppGetPtrHelper(T *ptr)
Definition zyppglobal.h:82

Definition at line 91 of file zyppglobal.h.

◆ ZYPP_DECLARE_PUBLIC

#define ZYPP_DECLARE_PUBLIC ( Class)
Value:
public: \
inline Class* z_func() { return static_cast<Class *>(z_ptr); } \
inline const Class* z_func() const { return static_cast<const Class *>(z_ptr); } \
friend class Class; \
private:

Definition at line 97 of file zyppglobal.h.

◆ Z_D

#define Z_D ( )    auto const d = d_func()

Definition at line 104 of file zyppglobal.h.

◆ Z_Z

#define Z_Z ( )    auto const z = z_func()

Definition at line 105 of file zyppglobal.h.

◆ ZYPP_FWD_DECL_REFS

#define ZYPP_FWD_DECL_REFS ( T)
Value:
using T##Ref = std::shared_ptr<T>; \
using T##WeakRef = std::weak_ptr<T>

Helper macro to declare Ref types

Definition at line 110 of file zyppglobal.h.

◆ ZYPP_FWD_DECL_TYPE_WITH_REFS

#define ZYPP_FWD_DECL_TYPE_WITH_REFS ( T)
Value:
class T; \
ZYPP_FWD_DECL_REFS(T)

Definition at line 117 of file zyppglobal.h.

◆ ZYPP_FWD_DECL_TEMPL_TYPE_WITH_REFS_ARG1

#define ZYPP_FWD_DECL_TEMPL_TYPE_WITH_REFS_ARG1 ( T,
TArg1 )
Value:
template< typename TArg1> \
class T; \
template< typename TArg1> \
using T##Ref = std::shared_ptr<T<TArg1>>; \
template< typename TArg1> \
using T##WeakRef = std::weak_ptr<T<TArg1>>

Definition at line 121 of file zyppglobal.h.

◆ ZYPP_ADD_PRIVATE_CONSTR_HELPER

#define ZYPP_ADD_PRIVATE_CONSTR_HELPER ( )     struct private_constr_t { private_constr_t () noexcept = default; }

Defines a dummy struct that can be used to make a public constructor unusable outside the class.

See also
ZYPP_ADD_CREATE_FUNC.

Definition at line 145 of file zyppglobal.h.

◆ ZYPP_PRIVATE_CONSTR_ARG

#define ZYPP_PRIVATE_CONSTR_ARG    private_constr_t

Use this to add the private constr argument to a constructor

Definition at line 151 of file zyppglobal.h.

◆ ZYPP_PRIVATE_CONSTR_ARG_VAL

#define ZYPP_PRIVATE_CONSTR_ARG_VAL    private_constr_t{}

Use this to pass the private constr arg to a constructor

Definition at line 157 of file zyppglobal.h.

◆ ZYPP_ADD_CREATE_FUNC

#define ZYPP_ADD_CREATE_FUNC ( Class)
Value:
private: \
ZYPP_ADD_PRIVATE_CONSTR_HELPER(); \
public: \
template < typename ...Args > \
inline static Class##Ref create ( Args &&... args ) { \
return std::make_shared< Class >( private_constr_t{}, std::forward<Args>(args)... ); \
} \
private:

Helper macro to add the default Class::create() static function commonly used in libzypp.

// always forward declare the Ref types so they can be used in the class
class MyClass
{
// this adds the construct template function
public:
// adds a constructor that takes no args:
// MyClass::create();
// adds a constructor with two arguments
// MyClass::create( 10, "Hello");
ZYPP_DECL_PRIVATE_CONSTR_ARGS(MyClass, int arg1, const std::string &label)
}
// do stuff
}
ZYPP_IMPL_PRIVATE_CONSTR_ARGS( MyClass, int arg1, const std::string &label ) {
// do stuff with args
}
#define ZYPP_IMPL_PRIVATE_CONSTR_ARGS(Class,...)
Definition zyppglobal.h:215
#define ZYPP_DECL_PRIVATE_CONSTR_ARGS(Class,...)
Definition zyppglobal.h:214
#define ZYPP_DECL_PRIVATE_CONSTR(Class)
Definition zyppglobal.h:212
#define ZYPP_ADD_CREATE_FUNC(Class)
Definition zyppglobal.h:196
#define ZYPP_IMPL_PRIVATE_CONSTR(Class)
Definition zyppglobal.h:213
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:117
Note
requires the ref types for the class to be already defined \TODO Add this to already existing objects

Definition at line 196 of file zyppglobal.h.

◆ ZYPP_DECL_PRIVATE_CONSTR

#define ZYPP_DECL_PRIVATE_CONSTR ( Class)    Class( private_constr_t )

Definition at line 212 of file zyppglobal.h.

◆ ZYPP_IMPL_PRIVATE_CONSTR

#define ZYPP_IMPL_PRIVATE_CONSTR ( Class)    Class::Class( private_constr_t )

Definition at line 213 of file zyppglobal.h.

◆ ZYPP_DECL_PRIVATE_CONSTR_ARGS

#define ZYPP_DECL_PRIVATE_CONSTR_ARGS ( Class,
... )   Class( private_constr_t, __VA_ARGS__ )

Definition at line 214 of file zyppglobal.h.

◆ ZYPP_IMPL_PRIVATE_CONSTR_ARGS

#define ZYPP_IMPL_PRIVATE_CONSTR_ARGS ( Class,
... )   Class::Class( private_constr_t, __VA_ARGS__ )

Definition at line 215 of file zyppglobal.h.

Function Documentation

◆ zyppGetPtrHelper() [1/3]

template<typename T >
T * zyppGetPtrHelper ( T * ptr)
inline

Definition at line 82 of file zyppglobal.h.

◆ zyppGetPtrHelper() [2/3]

template<typename Ptr >
auto zyppGetPtrHelper ( const Ptr & ptr) -> decltype(ptr.operator->())
inline

Definition at line 83 of file zyppglobal.h.

◆ zyppGetPtrHelper() [3/3]

template<typename Ptr >
auto zyppGetPtrHelper ( Ptr & ptr) -> decltype(ptr.operator->())
inline

Definition at line 84 of file zyppglobal.h.