libzypp: zypp-core/ng/base/zyppglobal.h File Reference

libzypp 17.38.7

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 | 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

## ◆ 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 80 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:76

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

## ◆ Z_D

#define Z_D | ( |  | ) |

Value:
auto const d = d_func()

Definition at line 98 of file zyppglobal.h.

## ◆ Z_Z

#define Z_Z | ( |  | ) |

Value:
auto const z = z_func()

Definition at line 99 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:103
zyppng::WeakRef
std::weak_ptr< T > WeakRef
Definition zyppglobal.h:106

Helper macro to declare Ref types

Definition at line 112 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 119 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 123 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 147 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 153 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 159 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:217
ZYPP_DECL_PRIVATE_CONSTR_ARGS
#define ZYPP_DECL_PRIVATE_CONSTR_ARGS(Class,...)
Definition zyppglobal.h:216
ZYPP_DECL_PRIVATE_CONSTR
#define ZYPP_DECL_PRIVATE_CONSTR(Class)
Definition zyppglobal.h:214
ZYPP_ADD_CREATE_FUNC
#define ZYPP_ADD_CREATE_FUNC(Class)
Definition zyppglobal.h:198
ZYPP_IMPL_PRIVATE_CONSTR
#define ZYPP_IMPL_PRIVATE_CONSTR(Class)
Definition zyppglobal.h:215
ZYPP_FWD_DECL_TYPE_WITH_REFS
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:119

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

Definition at line 198 of file zyppglobal.h.

## ◆ ZYPP_DECL_PRIVATE_CONSTR

#define ZYPP_DECL_PRIVATE_CONSTR | ( |  | Class | ) |

Value:
Class( private_constr_t )

Definition at line 214 of file zyppglobal.h.

## ◆ ZYPP_IMPL_PRIVATE_CONSTR

#define ZYPP_IMPL_PRIVATE_CONSTR | ( |  | Class | ) |

Value:
Class::Class( private_constr_t )

Definition at line 215 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 216 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 217 of file zyppglobal.h.

## ◆ ZYPP_NODISCARD

#define ZYPP_NODISCARD [[nodiscard]]

Definition at line 219 of file zyppglobal.h.

## Function Documentation

## ◆ zyppGetPtrHelper() [1/3]

template<typename T>

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

Definition at line 76 of file zyppglobal.h.

## ◆ zyppGetPtrHelper() [2/3]

template<typename Ptr>

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

Definition at line 77 of file zyppglobal.h.

## ◆ zyppGetPtrHelper() [3/3]

template<typename Ptr>

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

Definition at line 78 of file zyppglobal.h.