本文整理汇总了C++中Ticket类的典型用法代码示例。如果您正苦于以下问题:C++ Ticket类的具体用法?C++ Ticket怎么用?C++ Ticket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ticket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compare
//! Compare another ticket with this object.
//! Only interface and destination are compared.
//! @return true if tickets hold same basic information,
//! false otherwise.
bool
compare(const Ticket ticket)
{
if (m_ticket.interface == ticket.getInterface() &&
m_ticket.destination == ticket.getDestination())
return true;
return false;
}
示例2: getTicket
Ticket* OTicketDAO::getTicket(int id)
{
for(int i =0; i < tickets.size(); i++)
{
Ticket* temp = tickets.at(i);
if(temp->getTicketID() == id)
return temp;
}
return 0;
}
示例3: getPositie
//Geeft de positie van een element in de array; Enkel noodzakelijk om de database te simuleren
int OTicketDAO::getPositie(int id)
{
for(int i = 0; i < tickets.size(); i++)
{
Ticket* temp = tickets.at(i);
if(temp->getTicketID() == id)
return i;
}
return -1;
}
示例4: Lotto
Ticket Lotto(int Tot, int Ran) { // generate and return randomized & sorted array of lottery numbers
Ticket temp; // create a ticket that will be returned once generated with random lottery numbers with respect to arguments passed to function
int i = 0;
if (Tot < 5) { // check for the first argument passed to function
cout << "Invalid number range, resetting to default: [1-5]" << endl; // if range of lottery number max is below 5, change it to min allowed - 5
Tot = 5;
}
if (Ran < 2) { // check the second argument, if less than 2, set it to default value of 2, we need at least 2 winning numbers to play with
cout << "Invalid ticket request, setting number of winning numbers to default - 2." << endl;
Ran = 2;
}
for (i = 0; i < Tot; i++) // generate non-random sequence of numbers from 1 to Tot and store it in vector<int> array
temp.push_back(i+1);
for (i = 0; i < Ran; i++) // shuffle the numbers "Ran" many times to have better randomization of numbers
random_shuffle(temp.begin(), temp.end());
temp.erase(temp.begin()+Ran, temp.end()); // erase unnecessary numbers from Ran+, numbers from 1 to Ran are kept in.
sort(temp.begin(), temp.end()); // finally, sort the numbers
return temp; // and return the sorted and randomized array
}
示例5:
vector<Ticket*> OTicketDAO::vindTicketDoorID(int ID)
{
vector<Ticket*> results = vector<Ticket*>();
for(int i =0; i < tickets.size(); i++)
{
Ticket* temp = tickets.at(i);
if(temp->getTicketID() == ID)
results.push_back(temp);
}
return results;
}
示例6: lk
Status TransportLayerLegacy::_runTicket(Ticket ticket) {
if (!_running.load()) {
return TransportLayer::ShutdownStatus;
}
if (ticket.expiration() < Date_t::now()) {
return Ticket::ExpiredStatus;
}
AbstractMessagingPort* amp;
{
stdx::lock_guard<stdx::mutex> lk(_connectionsMutex);
auto conn = _connections.find(ticket.sessionId());
if (conn == _connections.end()) {
return TransportLayer::TicketSessionUnknownStatus;
}
// "check out" the port
conn->second.inUse = true;
amp = conn->second.amp.get();
}
auto legacyTicket = checked_cast<LegacyTicket*>(getTicketImpl(ticket));
auto res = legacyTicket->_fill(amp);
{
stdx::lock_guard<stdx::mutex> lk(_connectionsMutex);
auto conn = _connections.find(ticket.sessionId());
invariant(conn != _connections.end());
#ifdef MONGO_CONFIG_SSL
// If we didn't have an X509 subject name, see if we have one now
if (!conn->second.sslPeerInfo) {
auto info = amp->getX509PeerInfo();
if (info.subjectName != "") {
conn->second.sslPeerInfo = info;
}
}
#endif
conn->second.inUse = false;
if (conn->second.ended) {
Listener::globalTicketHolder.release();
_connections.erase(conn);
}
}
return res;
}
示例7: while
bool ListenerSSL::_checkHalt(void)
{
while (this->_th->TryGet())
{
Ticket *t = this->_th->CurTicket;
if (t->GetAction() == CORE_HALT_MODULE)
{
this->_th->Drop("CORE", CORE_HALTED_MODULE);
return (true);
}
}
return (false);
}
示例8: loadInfoTicket
void formUpdBug::loadInfoTicket(Ticket source)
{
idTk = source.getIdTicket();
ui->titleTicket->setText(source.getNameTicket());
ui->description->setText(source.getDescrTicket());
ui->dateCrea->setDateTime(QDateTime::fromString(source.getCreateDt(),"yyyy-MM-ddTHH:mm:ss"));
ui->dateAssign->setDateTime(QDateTime::fromString(source.getSetUserDate(),"yyyy-MM-ddTHH:mm:ss"));
ui->dateEnd->setDateTime(QDateTime::fromString(source.getEndDate(),"yyyy-MM-ddTHH:mm:ss"));
ui->etatComboBox->setCurrentIndex(ui->etatComboBox->findText(source.getEtat()));
ui->usrComboBox->setCurrentIndex(ui->usrComboBox->findText(source.getDev()));
ui->createComboBox->setCurrentIndex(ui->createComboBox->findText(source.getCreateName()));
}
示例9: on_save_clicked
void formUpdBug::on_save_clicked()
{
Ticket bug;
bug.setIdTicket(idTk);
bug.setNameTicket(ui->titleTicket->text());
bug.setDescrTicket(ui->description->toPlainText());
bug.setCreateName(ui->createComboBox->currentText());
bug.setDev(ui->usrComboBox->currentText());
bug.setEtat(ui->etatComboBox->currentText());
emit save_upd_ticket(bug);
}
示例10: while
Ticket Cine::ingresarASalaC(Sala s, const Ticket &t){
Lista<pair<Sala, int> > es=espectadores_;
int i=0;
int se=0;
while (i<es.longitud()) {
if (((es.iesimo(i)).first)==s) {
se=i;
}
i++;
}
espectadores_.agregarAtras(make_pair(s,espectadoresC(s)+1));
espectadores_.sacar(es.iesimo(se));
ticketsVendidos_.eliminarPosicion(ticketsVendidos_.posicion(t));
Pelicula p=t.peliculaT();
Ticket res=Ticket(p,s,true);
return res;
}
示例11: catch
Status TransportLayerLegacy::_runTicket(Ticket ticket) {
if (!_running.load()) {
return TransportLayer::ShutdownStatus;
}
if (ticket.expiration() < Date_t::now()) {
return Ticket::ExpiredStatus;
}
// get the weak_ptr out of the ticket
// attempt to make it into a shared_ptr
auto legacyTicket = checked_cast<LegacyTicket*>(getTicketImpl(ticket));
auto session = legacyTicket->getSession();
if (!session) {
return TransportLayer::TicketSessionClosedStatus;
}
auto conn = session->conn();
if (conn->closed) {
return TransportLayer::TicketSessionClosedStatus;
}
Status res = Status::OK();
try {
res = legacyTicket->fill(conn->amp.get());
} catch (...) {
res = exceptionToStatus();
}
#ifdef MONGO_CONFIG_SSL
// If we didn't have an X509 subject name, see if we have one now
auto& sslPeerInfo = SSLPeerInfo::forSession(legacyTicket->getSession());
if (sslPeerInfo.subjectName.empty()) {
auto info = conn->amp->getX509PeerInfo();
if (!info.subjectName.empty()) {
sslPeerInfo = info;
}
}
#endif
return res;
}
示例12: lock
void SiriTokenProvider::PushBackTicket( const Ticket& t,bool bLock)
{
if(t.IsExpired())
return;
if(bLock)
{
FastMutex::ScopedLock lock(_mutex_tickets);
list<string>::iterator it=std::find(assistant_in_uses.begin(),assistant_in_uses.end(),t.assistantId);
list<Ticket>::iterator itr=std::find(g_tickets.begin(),g_tickets.end(),t);
if((itr==g_tickets.end()) && (it==assistant_in_uses.end()))
{
g_tickets.push_back(t);
}
}
else
{
list<string>::iterator it=std::find(assistant_in_uses.begin(),assistant_in_uses.end(),t.assistantId);
list<Ticket>::iterator itr=std::find(g_tickets.begin(),g_tickets.end(),t);
if((itr==g_tickets.end()) && (it==assistant_in_uses.end()))
{
g_tickets.push_back(t);
}
}
}
示例13: debug
void UserProcessingCenter::handleKerberosLogin(CMazeMsg* context)
{
//cout<<":: kerberos login:: "<<endl;
debug("kerberos login request");
char *pbuf = context->getMsg();
int rt = context->getLen();
MBlockSocket *pclient = context->getSocket();
UserDatabase *userdb = UserDatabase::getInstance();
KMsgHead kmsghead;
if(kmsghead.unserialize(pbuf,rt)!=-1)
{
switch(kmsghead.msgtype)
{
case USER_LOGIN_REQUEST:
{
//cout<<"::kerberos login::"<<endl;
UserLoginRequest req;
if(req.unserialize(pbuf,rt)!=-1)
{
USERDB *userinfo = new USERDB;
//debug("recv req from user %d to @time %d"<<req.uid<<" "<<req.ts);
bool logfind=false;
if(req.uid!=0)
{
debug("recv req from user id to @time--->"<<req.uid<<" "<<req.ts);
logfind=(userdb->get_record( req.uid,userinfo) == 0);
debug("find user %d 's user info"<<req.uid);
}
else
{
debug("recv req from user email to @time---->"<<req.emailAddr<<" "<<req.ts);
string emailAddr=req.emailAddr;
string badEmail = string("[email protected]");
if(emailAddr == badEmail)
{
cout<<"--------bad email--------"<<endl;
logfind = false;
}
else
{
logfind=(userdb->get_record(emailAddr,userinfo) == 0);
debug("find user %s 's user info"<<emailAddr.c_str());
}
}
if(logfind)
{
//generate ticket and send it back to User here...
UserLoginReply reply;
strncpy(reply.userInfo.NickName,userinfo->NickName,24);
strncpy(reply.userInfo.MailAddr,userinfo->MailAddr,128);
reply.userInfo.UID=userinfo->UID;
reply.userInfo.IP=pclient->GetPeerName().GetIP(); //TODO
reply.userInfo.ServerPort=pclient->GetPeerName().GetPort(); //TODO
reply.userInfo.Account=userinfo->Account;
reply.userInfo.Level=userinfo->Level;
reply.userInfo.LastAccountAddTime=(unsigned)userinfo->LastAddAccount;
//get user password(key) from user database;
string userKey=userinfo->Pwd;
//get tgs key from config or database.
string tgsKey ="tgskey";
//generate a random string to be the session key shared by user and tgs.
string sessionKey=GenRandomKey();
unsigned ts=(unsigned)time(NULL);//the time-stamp of the ticket release.
reply.ts =ts;
reply.life =TGS_TICKET_LIFE;//the life of the ticket below
reply.privilege=0;//TODO privilege of user..
reply.head.src=0;
reply.head.dst=req.uid;
reply.head.status=0;
reply.sessionKey.set(sessionKey.c_str(),sessionKey.length());
Ticket ticket;
ticket.uid=req.uid;
ticket.uaddr=0; //TODO
ticket.ts=ts;
ticket.life=TGS_TICKET_LIFE;
ticket.privilege=0;//TODO;
ticket.sessionKey.set(sessionKey.c_str(),sessionKey.length());
reply.cipheredTicket=ticket.serializeAndEncrypt(tgsKey.c_str(),tgsKey.length());
RawData result=reply.serializeAndEncrypt(userKey.c_str(),userKey.length());
debug("AS:\tGrant ticket and session key {%s} to user %d\n"<<sessionKey.c_str()<<req.uid);
unsigned int ip = pclient->GetPeerName().GetIP();
string ip_str=pclient->GetPeerName().ip();
pclient->SendPacket(result.data,result.len);
//.........这里部分代码省略.........
示例14: main
int main() {
int lotMaxR, winN, matchingN = 0; // lotMaxR = max range number for lottery numbers to be drawn, from 1 to lotMaxR
do {
cout << "Enter lottery range, from 1 to (5 or greater): "; // ask to input maximum range of possible lottery draw number
} while(cin >> lotMaxR && lotMaxR < 5); // get proper number from user until 5 or more is entered
do {
cout << "Enter how many numbers to draw (2 or greater): "; // ask for how many spots on the lotto card or winning numbers to draw in lottery play
} while(cin >> winN && winN < 2); // ask for input until 2 or number is entered
Ticket winners = Lotto(lotMaxR,winN); // generate random numbers for winning numbers
Ticket myticket = Lotto(lotMaxR,winN); // generate random numbers for user's playing ticket, something like QuickPick
cout << "Winning numbers: ";
DisplayTicket(winners); // display winning numbers
cout << "Your ticket numbers: ";
DisplayTicket(myticket); // display playing user's numbers
cout << "Number(s) matched on your ticket: "; // display matching numbers from both arrays (lottery drawn numbers and user's quick pick)
for (int i = 0; i < winN; i++)
if (find(winners.begin(), winners.end(), myticket[i]) != winners.end()) { // compare each winning number to user's picked numbers
cout << myticket[i] << " "; // if matched, display the number
matchingN++; // and increase the number of matched numbers
}
if (matchingN == 0) // if no numbers were matched display the message
cout << "None" << endl;
else
cout << endl;
if (matchingN == winN && matchingN > 5) // if all winning numbers guessed correctly and the total number of them is 6 or more - almost impossible win, display epic congratulations message!
cout << "You've guessed all numbers!!! BEER IS ON ME!";
else if (matchingN == winN && matchingN == 2 ) // special occasion: if out of 2 winning numbers 2 guessed correctly, display FREE ticket prize msg
cout << "Congratulations, you've won min 2x2 game! Prize: 10 FREE tickets!" << endl;
else if (matchingN > 5) // display messages for each number of correctly guessed numbers, the greater the number the more fun and expensive prize....or maybe not :)
cout << "Congratulations, You've guessed " << matchingN << " winning numbers!!!" << endl;
else
switch(matchingN) {
case 5:
cout << "Congratilations, You've guessed 5 winning numbers!!!!" << endl;
break;
case 4:
cout << "Congratulations, You've guessed 4 winning numbers!!" << endl;
break;
case 3:
cout << "Congratulations, You've guessed 3 winning numbers!!" << endl;
break;
default:
cout << "You've guessed " << matchingN << " winning number(s)!!" << endl;
break;
}
cout << "\nBye!\n"; // all is done, good bye
system("pause");
return 0;
}
示例15: DisplayTicket
void DisplayTicket(const Ticket & t) { // function displays victor<int> array or defined as Ticket
for (int i = 0; i < t.size(); i++) // go through each element until t.size(), the max number of elements, is reached
cout << t[i] << " "; // display the element
cout << endl;
}