libzypp 17.37.17
zyppng::ListChoiceRequest Class Reference

#include <zypp-core/zyppng/ui/userrequest.h>

Inheritance diagram for zyppng::ListChoiceRequest:

Classes

struct  Choice

Public Types

using index_type = std::vector<Choice>::size_type
Public Types inherited from zyppng::Base
using Ptr = std::shared_ptr<Base>
using WeakPtr = std::weak_ptr<Base>

Public Member Functions

 ZYPP_DECL_PRIVATE_CONSTR_ARGS (ListChoiceRequest, std::string label, std::vector< Choice > answers, index_type defaultAnswer, UserData userData={})
UserRequestType type () const override
const std::string & label () const
void setChoice (const index_type sel)
index_type choice () const
index_type defaultAnswer () const
const std::vector< Choice > & answers () const
Public Member Functions inherited from zyppng::UserRequest
 UserRequest (UserData userData={})
 ~UserRequest () override
const UserDatauserData () const
UserDatauserData ()
Public Member Functions inherited from zyppng::Base
 Base ()
virtual ~Base ()
WeakPtr parent () const
void addChild (const Base::Ptr &child)
void removeChild (const Ptr &child)
const std::unordered_set< Ptr > & children () const
std::thread::id threadId () const
template<typename T>
std::vector< std::weak_ptr< T > > findChildren () const
template<typename T>
std::shared_ptr< T > shared_this () const
template<typename T>
std::shared_ptr< T > shared_this ()
template<typename T>
std::weak_ptr< T > weak_this () const
template<typename T>
std::weak_ptr< T > weak_this ()
template<typename SenderFunc, typename ReceiverFunc>
auto connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connectionconnectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)

Private Attributes

std::string _label
std::vector< Choice_answers
index_type _answer = 0
index_type _default = 0

Additional Inherited Members

Static Public Member Functions inherited from zyppng::Base
template<typename Obj, typename Functor>
static decltype(auto) make_base_slot (Obj *o, Functor &&f)
template<typename SenderFunc, typename ReceiverFunc>
static auto connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
static auto connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)
Protected Member Functions inherited from zyppng::Base
 Base (BasePrivate &dd)
Protected Attributes inherited from zyppng::Base
std::unique_ptr< BasePrivated_ptr

Detailed Description

The ListChoice Request class represents a choice request to the user, the possible answers are given via a vector of possible choices.

auto request = ListChoiceRequest::create( "Please select the choice you want: ", { {"y", "Info about y"}, {"n", "Info about n"}, {"d", "Info about d"} }, 1 );
context->sendUserRequest( request );
const auto choice = request->choice();
switch( choice ) {
case 0:
// handle 'y' choice
break;
case 1:
// handle 'n' choice
break;
case 2:
// handle 'd' choice
break;
default:
// error, should not happen!
break;
}
index_type choice() const

Definition at line 120 of file userrequest.h.

Member Typedef Documentation

◆ index_type

using zyppng::ListChoiceRequest::index_type = std::vector<Choice>::size_type

Definition at line 130 of file userrequest.h.

Member Function Documentation

◆ ZYPP_DECL_PRIVATE_CONSTR_ARGS()

zyppng::ListChoiceRequest::ZYPP_DECL_PRIVATE_CONSTR_ARGS ( ListChoiceRequest ,
std::string label,
std::vector< Choice > answers,
index_type defaultAnswer,
UserData userData = {} )

◆ type()

UserRequestType zyppng::ListChoiceRequest::type ( ) const
overridevirtual

Implements zyppng::UserRequest.

Definition at line 61 of file userrequest.cc.

◆ label()

const std::string & zyppng::ListChoiceRequest::label ( ) const

Definition at line 66 of file userrequest.cc.

◆ setChoice()

void zyppng::ListChoiceRequest::setChoice ( const index_type sel)

Definition at line 71 of file userrequest.cc.

◆ choice()

ListChoiceRequest::index_type zyppng::ListChoiceRequest::choice ( ) const

Definition at line 78 of file userrequest.cc.

◆ defaultAnswer()

ListChoiceRequest::index_type zyppng::ListChoiceRequest::defaultAnswer ( ) const

Definition at line 83 of file userrequest.cc.

◆ answers()

const std::vector< ListChoiceRequest::Choice > & zyppng::ListChoiceRequest::answers ( ) const

Definition at line 88 of file userrequest.cc.

Member Data Documentation

◆ _label

std::string zyppng::ListChoiceRequest::_label
private

Definition at line 146 of file userrequest.h.

◆ _answers

std::vector<Choice> zyppng::ListChoiceRequest::_answers
private

Definition at line 147 of file userrequest.h.

◆ _answer

index_type zyppng::ListChoiceRequest::_answer = 0
private

Definition at line 148 of file userrequest.h.

◆ _default

index_type zyppng::ListChoiceRequest::_default = 0
private

Definition at line 149 of file userrequest.h.


The documentation for this class was generated from the following files: