libzypp 17.37.10

zyppglobal.h File Reference
`#include <memory>`
`#include <zypp-core/base/Easy.h>`

Go to the source code of this file.

## Namespaces
namespace | zyppng

## 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()
#define | Z_Z()
#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()
#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)
#define | ZYPP_IMPL_PRIVATE_CONSTR(Class)
#define | ZYPP_DECL_PRIVATE_CONSTR_ARGS(Class, ...)
#define | ZYPP_IMPL_PRIVATE_CONSTR_ARGS(Class, ...)
#define | ZYPP_NODISCARD [[nodiscard]]

## Typedefs
template<typename T>
using | zyppng::Ref = std::shared_ptr<T>
template<typename T>
using | zyppng::WeakRef = std::weak_ptr<T>

## 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 8 of file zyppglobal.h.

## ◆ LIBZYPP_NG_NO_EXPORT

#define LIBZYPP_NG_NO_EXPORT

Definition at line 9 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 87 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)); }
zyppGetPtrHelper
T * zyppGetPtrHelper(T *ptr)
Definition zyppglobal.h:83

Definition at line 92 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 98 of file zyppglobal.h.

## ◆ Z_D

#define Z_D | ( |  | ) |

Value:
auto const d = d_func()

Definition at line 105 of file zyppglobal.h.

## ◆ Z_Z

#define Z_Z | ( |  | ) |

Value:
auto const z = z_func()

Definition at line 106 of file zyppglobal.h.

## ◆ ZYPP_FWD_DECL_REFS

#define ZYPP_FWD_DECL_REFS | ( |  | T | ) |

Value:
using T##Ref = ::zyppng::Ref<T>; \
using T##WeakRef = ::zyppng::WeakRef<T>
zyppng::Ref
std::shared_ptr< T > Ref
Definition zyppglobal.h:110
zyppng::WeakRef
std::weak_ptr< T > WeakRef
Definition zyppglobal.h:113

Helper macro to declare Ref types

Definition at line 119 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 126 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 = Ref<T<TArg1>>; \
template< typename TArg1> \
using T##WeakRef = WeakRef<T<TArg1>>

Definition at line 130 of file zyppglobal.h.

## ◆ ZYPP_ADD_PRIVATE_CONSTR_HELPER

#define ZYPP_ADD_PRIVATE_CONSTR_HELPER | ( |  | ) |

Value:
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 154 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 160 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 166 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 auto 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
ZYPP_FWD_DECL_TYPE_WITH_REFS(MyClass)
class MyClass
{
// this adds the construct template function
ZYPP_ADD_CREATE_FUNC(MyClass)
public:
// adds a constructor that takes no args:
// MyClass::create();
ZYPP_DECL_PRIVATE_CONSTR(MyClass)
// adds a constructor with two arguments
// MyClass::create( 10, "Hello");
ZYPP_DECL_PRIVATE_CONSTR_ARGS(MyClass, int arg1, const std::string &label)
}
ZYPP_IMPL_PRIVATE_CONSTR( MyClass ) {
// do stuff
}
ZYPP_IMPL_PRIVATE_CONSTR_ARGS( MyClass, int arg1, const std::string &label ) {
// do stuff with args
}
ZYPP_IMPL_PRIVATE_CONSTR_ARGS
#define ZYPP_IMPL_PRIVATE_CONSTR_ARGS(Class,...)
Definition zyppglobal.h:224
ZYPP_DECL_PRIVATE_CONSTR_ARGS
#define ZYPP_DECL_PRIVATE_CONSTR_ARGS(Class,...)
Definition zyppglobal.h:223
ZYPP_DECL_PRIVATE_CONSTR
#define ZYPP_DECL_PRIVATE_CONSTR(Class)
Definition zyppglobal.h:221
ZYPP_ADD_CREATE_FUNC
#define ZYPP_ADD_CREATE_FUNC(Class)
Definition zyppglobal.h:205
ZYPP_IMPL_PRIVATE_CONSTR
#define ZYPP_IMPL_PRIVATE_CONSTR(Class)
Definition zyppglobal.h:222
ZYPP_FWD_DECL_TYPE_WITH_REFS
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:126

Note
  requires the ref types for the class to be already defined \TODO Add this to already existing objects

Definition at line 205 of file zyppglobal.h.

## ◆ ZYPP_DECL_PRIVATE_CONSTR

#define ZYPP_DECL_PRIVATE_CONSTR | ( |  | Class | ) |

Value:
Class( private_constr_t )

Definition at line 221 of file zyppglobal.h.

## ◆ ZYPP_IMPL_PRIVATE_CONSTR

#define ZYPP_IMPL_PRIVATE_CONSTR | ( |  | Class | ) |

Value:
Class::Class( private_constr_t )

Definition at line 222 of file zyppglobal.h.

## ◆ ZYPP_DECL_PRIVATE_CONSTR_ARGS

#define ZYPP_DECL_PRIVATE_CONSTR_ARGS | ( |  | Class,
|  |  | ... )

Value:
Class( private_constr_t, __VA_ARGS__ )

Definition at line 223 of file zyppglobal.h.

## ◆ ZYPP_IMPL_PRIVATE_CONSTR_ARGS

#define ZYPP_IMPL_PRIVATE_CONSTR_ARGS | ( |  | Class,
|  |  | ... )

Value:
Class::Class( private_constr_t, __VA_ARGS__ )

Definition at line 224 of file zyppglobal.h.

## ◆ ZYPP_NODISCARD

#define ZYPP_NODISCARD [[nodiscard]]

Definition at line 226 of file zyppglobal.h.

## Function Documentation

## ◆ zyppGetPtrHelper() [1/3]

template<typename T>

T * zyppGetPtrHelper | ( | T * | ptr | ) |
| inline

Definition at line 83 of file zyppglobal.h.

## ◆ zyppGetPtrHelper() [2/3]

template<typename Ptr>

auto zyppGetPtrHelper | ( | const Ptr & | ptr | ) | -> decltype(ptr.operator->())
| inline

Definition at line 84 of file zyppglobal.h.

## ◆ zyppGetPtrHelper() [3/3]

template<typename Ptr>

auto zyppGetPtrHelper | ( | Ptr & | ptr | ) | -> decltype(ptr.operator->())
| inline

Definition at line 85 of file zyppglobal.h.