blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e0e26af986e09a7940a892075e5b64a0e9d77bd2 | 450c431ed38c0ece264ac86df019a40dc9d8aff8 | /composite.h | 99a4d1ba082373c1e08e366ef992c6cf7597d6f6 | [] | no_license | tshen005/commandLab | 18970ceeb75121bc5bb2ffc5b521534cd4fc8c32 | 27d834307bf914455668992b79ac7a01041a371e | refs/heads/master | 2021-03-30T21:31:26.060189 | 2018-03-09T03:30:23 | 2018-03-09T03:30:23 | 124,482,573 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,241 | h | //
// composite.h
// commandLab
//
// Created by shen on 16/11/7.
// Copyright © 2016年 shen. All rights reserved.
//
#ifndef composite_h
#define composite_h
#include <iostream>
#include <sstream>
#include <math.h>
#include <string>
using namespace std;
// forward declare to avoid circular dependencies
class Iterator;
//Abstract Base Class
class Base {
public:
Base(){};
//virtual
virtual double evaluate() = 0;
};
//Leaf Class
class Op: public Base {
private:
double value;
public:
Op() : Base(), value(0){};
Op(double val) : Base(), value(val){};
double evaluate() {
return this->value;
};
};
//Composite Base Classes
class Operator: public Base {
protected:
Base* left, *right;
public:
Operator() : Base(){ };
Operator(Base* l, Base* r) : left(l), right(r){ };
Base* get_left() { return left; };
Base* get_right() { return right; };
virtual double evaluate() = 0; //Note: this is implicit in the inheritance, but can also be made explicit
};
class UnaryOperator: public Base {
protected:
Base* child;
public:
UnaryOperator() : Base(){};
UnaryOperator(Base* c) : child(c) { };
virtual double evaluate() = 0; //Note: this is implicit in the inheritance, but can also be made explicit
};
//Composite Classes
class Add: public Operator {
public:
Add() : Operator() { };
Add(Base* left, Base* right) : Operator(left,right) { };
double evaluate() {
return this->left->evaluate() + this->right->evaluate();
};
};
class Sub: public Operator {
public:
Sub() : Operator() { };
Sub(Base* left, Base* right) : Operator(left,right) { };
double evaluate() {
return this->left->evaluate() - this->right->evaluate();
};
};
class Mult: public Operator {
public:
Mult() : Operator() { };
Mult(Base* left, Base* right) : Operator(left,right) { };
double evaluate() {
return this->left->evaluate() * this->right->evaluate();
};
};
class Sqr: public UnaryOperator {
public:
Sqr() : UnaryOperator() { };
Sqr(Base* child) : UnaryOperator(child) { };
double evaluate() {
return pow(this->child->evaluate(),2);
};
};
#endif /* composite_h */
| [
"tshengogogo@gmail.com"
] | tshengogogo@gmail.com |
bf85b794062cccd8fbaf60709dbb2448903d29ba | 22aa648e0e0d720a49356bd53e0b216827504054 | /9.cpp | dedab63a83b29238f8cb42564619e89557348eee | [] | no_license | elifkuzucuu/Questions | f8c5e8048fb3c1a618e48ee30b3c1e3b93f2f2f5 | 39d977db719dc17f6520f5387604b1474b1d4a12 | refs/heads/main | 2023-02-02T14:02:24.580832 | 2020-12-14T19:38:00 | 2020-12-14T19:38:00 | 321,412,741 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 705 | cpp | #include <bits/stdc++.h>
using namespace std;
void permute(int *a, int l, int r)
{
int size = 0;
if (l == r) {
while(size<=r) {
cout<<a[size]<<" ";
size++;
}
cout<<endl; }
else
{
for (int i = l; i <= r; i++)
{
swap(a[l], a[i]);
permute(a, l+1, r);
swap(a[l], a[i]);
}
}
}
int main()
{
int size = 0;
int *arr = new int[size];
int girilendeger;
char newline;
while(cin>>girilendeger) {
arr[size] = girilendeger;
newline = girilendeger;
newline = getchar();
if (newline == '\n') {
break;
}
size++;
}
permute(arr, 0, size);
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
96ffee12fbc1a684eb10438dc7cf5df90c5ee16d | 1df0f2dd40099cdc146dc82ee353e7ea4e563af2 | /shared/qt/Plot1DWidget.cpp | 9e39b0b6bd9fe64cb94317b1744f4a55235c1a4c | [] | no_license | chuckbruno/aphid | 1d0b2637414a03feee91b4c8909dd5d421d229d4 | f07c216f3fda0798ee3f96cd9decb35719098b01 | refs/heads/master | 2021-01-01T18:10:17.713198 | 2017-07-25T02:37:15 | 2017-07-25T02:37:15 | 98,267,729 | 0 | 1 | null | 2017-07-25T05:30:27 | 2017-07-25T05:30:27 | null | UTF-8 | C++ | false | false | 5,190 | cpp | /*
* Plot1DWidget.cpp
*
*
* Created by jian zhang on 9/9/16.
* Copyright 2016 __MyCompanyName__. All rights reserved.
*
*/
#include <QtGui>
#include "Plot1DWidget.h"
#include <boost/format.hpp>
namespace aphid {
Plot1DWidget::Plot1DWidget(QWidget *parent) : BaseImageWidget(parent)
{
setBound(-1.f, 1.f, 4, -1.f, 1.f, 4);
}
Plot1DWidget::~Plot1DWidget()
{
std::vector<UniformPlot1D *>::iterator it = m_curves.begin();
for(;it!=m_curves.end();++it) {
delete *it;
}
m_curves.clear();
}
void Plot1DWidget::clientDraw(QPainter * pr)
{
QPen pn(Qt::black);
pn.setWidth(1);
pr->setPen(pn);
drawCoordsys(pr);
std::vector<UniformPlot1D *>::const_iterator it = m_curves.begin();
for(;it!=m_curves.end();++it) {
drawPlot(*it, pr);
}
}
void Plot1DWidget::drawCoordsys(QPainter * pr) const
{
QPoint lu = luCorner();
QPoint rb = rbCorner();
const QPoint ori(lu.x(), rb.y() );
pr->drawLine(ori, lu );
pr->drawLine(ori, rb );
drawHorizontalInterval(pr);
drawVerticalInterval(pr);
}
void Plot1DWidget::drawHorizontalInterval(QPainter * pr) const
{
QPoint lu = luCorner();
QPoint rb = rbCorner();
int l = rb.x() - lu.x();
int n = m_niterval.x;
int g = (float)l/(float)n;
if(g < 20) {
g = l;
n = 1;
}
const QPoint ori(lu.x(), rb.y() );
float h = (m_hBound.y - m_hBound.x) / n;
for(int i=0; i<= n; ++i) {
float fv = m_hBound.x + h * i;
std::string sv = boost::str(boost::format("%=6d") % fv );
QPoint p(ori.x() + g * i, ori.y() );
if(i==n) p.setX(rb.x() );
pr->drawText(QPoint(p.x() - 16, p.y() + 16), tr(sv.c_str() ) );
pr->drawLine(p, QPoint(p.x(), p.y() - 4) );
}
}
void Plot1DWidget::drawVerticalInterval(QPainter * pr) const
{
QPoint lu = luCorner();
QPoint rb = rbCorner();
int l = rb.y() - lu.y();
int n = m_niterval.y;
int g = (float)l/(float)n;
if(g < 20) {
g = l;
n = 1;
}
const QPoint ori(lu.x(), rb.y() );
float h = (m_vBound.y - m_vBound.x) / n;
for(int i=0; i<= n; ++i) {
float fv = m_vBound.x + h * i;
std::string sv = boost::str(boost::format("%=6d") % fv );
QPoint p(ori.x(), ori.y() - g * i);
if(i==n) p.setY(lu.y() );
pr->drawText(QPoint(p.x() - 40, p.y() + 4 ), tr(sv.c_str() ) );
pr->drawLine(p, QPoint(p.x() + 4, p.y()) );
}
}
void Plot1DWidget::drawPlot(const UniformPlot1D * plt, QPainter * pr)
{
switch(plt->geomType() ) {
case UniformPlot1D::GtLine :
drawLine(plt, pr);
break;
case UniformPlot1D::GtMark :
drawMark(plt, pr);
break;
default:
break;
}
}
void Plot1DWidget::drawLine(const UniformPlot1D * plt, QPainter * pr)
{
const Vector3F & cf = plt->color();
QPen pn(QColor((int)(cf.x*255), (int)(cf.y*255), (int)(cf.z*255) ) );
pn.setWidth(1);
switch (plt->lineStyle() ) {
case UniformPlot1D::LsDash :
pn.setStyle(Qt::DashLine);
break;
case UniformPlot1D::LsDot :
pn.setStyle(Qt::DotLine);
break;
default:
break;
}
pr->setPen(pn);
QPoint lu = luCorner();
QPoint rb = rbCorner();
const int & n = plt->numY() - 1;
QPoint p0, p1;
/// linspace x
p0.setX(MixClamp01F<int>(lu.x(), rb.x(), plt->x()[0]) );
p0.setY(RemapF<int>(rb.y(), lu.y(), m_vBound.x, m_vBound.y,
plt->y()[0] ));
int i=1;
for(;i<=n;++i) {
p1.setX(MixClamp01F<int>(lu.x(), rb.x(), plt->x()[i]) );
p1.setY(RemapF<int>(rb.y(), lu.y(), m_vBound.x, m_vBound.y,
plt->y()[i] ));
pr->drawLine(p0, p1 );
p0 = p1;
}
}
static const QPointF quadPoints[4] = {
QPointF(-4.0, -4.0),
QPointF( 4.0, -4.0),
QPointF( 4.0, 4.0),
QPointF(-4.0, 4.0)
};
void Plot1DWidget::drawMark(const UniformPlot1D * plt, QPainter * pr)
{
const Vector3F & cf = plt->color();
QPen pn(QColor((int)(cf.x*255), (int)(cf.y*255), (int)(cf.z*255) ) );
pn.setWidth(1);
pr->setPen(pn);
QPoint lu = luCorner();
QPoint rb = rbCorner();
const int & n = plt->numY();
QPoint p1;
int i=0;
for(;i<n;++i) {
/// actual x
p1.setX(RemapF<int>(lu.x(), rb.x(), m_hBound.x, m_hBound.y,
plt->x()[i] ));
p1.setY(RemapF<int>(rb.y(), lu.y(), m_vBound.x, m_vBound.y,
plt->y()[i] ));
pr->translate(p1);
pr->drawPolygon(quadPoints, 4);
pr->translate(p1*(-1.0));
}
}
QPoint Plot1DWidget::luCorner() const
{ return QPoint(margin().x, margin().y); }
QPoint Plot1DWidget::rbCorner() const
{ return QPoint(portSize().width() - margin().x, portSize().height() - margin().y); }
void Plot1DWidget::setBound(const float & hlow, const float & hhigh,
const int & hnintv,
const float & vlow, const float & vhigh,
const int & vnintv)
{
m_hBound.set(hlow, hhigh);
m_vBound.set(vlow, vhigh);
m_niterval.set(hnintv, vnintv);
}
void Plot1DWidget::addVectorPlot(UniformPlot1D * p)
{ m_curves.push_back(p); }
Vector2F Plot1DWidget::toRealSpace(const int & x,
const int & y) const
{
const QPoint lu = luCorner();
const QPoint rb = rbCorner();
Vector2F r;
r.x = RemapF<float>(m_hBound.x, m_hBound.y, lu.x(), rb.x(),
x);
r.y = RemapF<float>(m_vBound.x, m_vBound.y, rb.y(), lu.y(),
y);
return r;
}
float Plot1DWidget::xToBound(const float & x) const
{
return m_hBound.x + (m_hBound.y - m_hBound.x) * x;
}
} | [
"zhangmdev@gmail.com"
] | zhangmdev@gmail.com |
c717c872997a6eb19aa29b4299c6d0f4de0cdd1c | 311bca02634b791b17a1cd6e2258d858c5ee8b70 | /src/rpc/blockchain.cpp | 29d67a4467b143071fd799549a7b4c76999c2c9e | [
"MIT"
] | permissive | ed-ro0t/C-Bit | 65359b8eb1efbf3762d9c0375acd971e2352b38f | 73bc5652564d344af6847eefde6d386225d4ad02 | refs/heads/master | 2020-03-09T06:57:08.468887 | 2017-09-04T00:40:41 | 2017-09-04T00:40:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 52,115 | cpp | // Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The C-Bit Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "amount.h"
#include "chain.h"
#include "chainparams.h"
#include "checkpoints.h"
#include "coins.h"
#include "consensus/validation.h"
#include "main.h"
#include "policy/policy.h"
#include "primitives/transaction.h"
#include "rpc/server.h"
#include "streams.h"
#include "sync.h"
#include "txmempool.h"
#include "util.h"
#include "utilstrencodings.h"
#include "hash.h"
#include <stdint.h>
#include <univalue.h>
#include <boost/thread/thread.hpp> // boost::thread::interrupt
using namespace std;
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
double GetDifficulty(const CBlockIndex* blockindex)
{
// Floating point number that is a multiple of the minimum difficulty,
// minimum difficulty = 1.0.
if (blockindex == NULL)
{
if (chainActive.Tip() == NULL)
return 1.0;
else
blockindex = chainActive.Tip();
}
int nShift = (blockindex->nBits >> 24) & 0xff;
double dDiff =
(double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff);
while (nShift < 29)
{
dDiff *= 256.0;
nShift++;
}
while (nShift > 29)
{
dDiff /= 256.0;
nShift--;
}
return dDiff;
}
UniValue blockheaderToJSON(const CBlockIndex* blockindex)
{
UniValue result(UniValue::VOBJ);
result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex()));
int confirmations = -1;
// Only report confirmations if the block is on the main chain
if (chainActive.Contains(blockindex))
confirmations = chainActive.Height() - blockindex->nHeight + 1;
result.push_back(Pair("confirmations", confirmations));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", blockindex->nVersion));
result.push_back(Pair("versionHex", strprintf("%08x", blockindex->nVersion)));
result.push_back(Pair("merkleroot", blockindex->hashMerkleRoot.GetHex()));
result.push_back(Pair("time", (int64_t)blockindex->nTime));
result.push_back(Pair("mediantime", (int64_t)blockindex->GetMedianTimePast()));
result.push_back(Pair("nonce", (uint64_t)blockindex->nNonce));
result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
CBlockIndex *pnext = chainActive.Next(blockindex);
if (pnext)
result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex()));
return result;
}
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
{
UniValue result(UniValue::VOBJ);
result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex()));
int confirmations = -1;
// Only report confirmations if the block is on the main chain
if (chainActive.Contains(blockindex))
confirmations = chainActive.Height() - blockindex->nHeight + 1;
result.push_back(Pair("confirmations", confirmations));
result.push_back(Pair("strippedsize", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS)));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("weight", (int)::GetBlockWeight(block)));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion));
result.push_back(Pair("versionHex", strprintf("%08x", block.nVersion)));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
UniValue txs(UniValue::VARR);
BOOST_FOREACH(const CTransaction&tx, block.vtx)
{
if(txDetails)
{
UniValue objTx(UniValue::VOBJ);
TxToJSON(tx, uint256(), objTx);
txs.push_back(objTx);
}
else
txs.push_back(tx.GetHash().GetHex());
}
result.push_back(Pair("tx", txs));
result.push_back(Pair("time", block.GetBlockTime()));
result.push_back(Pair("mediantime", (int64_t)blockindex->GetMedianTimePast()));
result.push_back(Pair("nonce", (uint64_t)block.nNonce));
result.push_back(Pair("bits", strprintf("%08x", block.nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
CBlockIndex *pnext = chainActive.Next(blockindex);
if (pnext)
result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex()));
return result;
}
UniValue getblockcount(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getblockcount\n"
"\nReturns the number of blocks in the longest block chain.\n"
"\nResult:\n"
"n (numeric) The current block count\n"
"\nExamples:\n"
+ HelpExampleCli("getblockcount", "")
+ HelpExampleRpc("getblockcount", "")
);
LOCK(cs_main);
return chainActive.Height();
}
UniValue getbestblockhash(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getbestblockhash\n"
"\nReturns the hash of the best (tip) block in the longest block chain.\n"
"\nResult\n"
"\"hex\" (string) the block hash hex encoded\n"
"\nExamples\n"
+ HelpExampleCli("getbestblockhash", "")
+ HelpExampleRpc("getbestblockhash", "")
);
LOCK(cs_main);
return chainActive.Tip()->GetBlockHash().GetHex();
}
UniValue getdifficulty(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getdifficulty\n"
"\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n"
"\nResult:\n"
"n.nnn (numeric) the proof-of-work difficulty as a multiple of the minimum difficulty.\n"
"\nExamples:\n"
+ HelpExampleCli("getdifficulty", "")
+ HelpExampleRpc("getdifficulty", "")
);
LOCK(cs_main);
return GetDifficulty();
}
std::string EntryDescriptionString()
{
return " \"size\" : n, (numeric) transaction size in bytes\n"
" \"fee\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + "\n"
" \"modifiedfee\" : n, (numeric) transaction fee with fee deltas used for mining priority\n"
" \"time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n"
" \"height\" : n, (numeric) block height when transaction entered pool\n"
" \"startingpriority\" : n, (numeric) priority when transaction entered pool\n"
" \"currentpriority\" : n, (numeric) transaction priority now\n"
" \"descendantcount\" : n, (numeric) number of in-mempool descendant transactions (including this one)\n"
" \"descendantsize\" : n, (numeric) size of in-mempool descendants (including this one)\n"
" \"descendantfees\" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one)\n"
" \"ancestorcount\" : n, (numeric) number of in-mempool ancestor transactions (including this one)\n"
" \"ancestorsize\" : n, (numeric) size of in-mempool ancestors (including this one)\n"
" \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one)\n"
" \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n"
" \"transactionid\", (string) parent transaction id\n"
" ... ]\n";
}
void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
{
AssertLockHeld(mempool.cs);
info.push_back(Pair("size", (int)e.GetTxSize()));
info.push_back(Pair("fee", ValueFromAmount(e.GetFee())));
info.push_back(Pair("modifiedfee", ValueFromAmount(e.GetModifiedFee())));
info.push_back(Pair("time", e.GetTime()));
info.push_back(Pair("height", (int)e.GetHeight()));
info.push_back(Pair("startingpriority", e.GetPriority(e.GetHeight())));
info.push_back(Pair("currentpriority", e.GetPriority(chainActive.Height())));
info.push_back(Pair("descendantcount", e.GetCountWithDescendants()));
info.push_back(Pair("descendantsize", e.GetSizeWithDescendants()));
info.push_back(Pair("descendantfees", e.GetModFeesWithDescendants()));
info.push_back(Pair("ancestorcount", e.GetCountWithAncestors()));
info.push_back(Pair("ancestorsize", e.GetSizeWithAncestors()));
info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors()));
const CTransaction& tx = e.GetTx();
set<string> setDepends;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
if (mempool.exists(txin.prevout.hash))
setDepends.insert(txin.prevout.hash.ToString());
}
UniValue depends(UniValue::VARR);
BOOST_FOREACH(const string& dep, setDepends)
{
depends.push_back(dep);
}
info.push_back(Pair("depends", depends));
}
UniValue mempoolToJSON(bool fVerbose = false)
{
if (fVerbose)
{
LOCK(mempool.cs);
UniValue o(UniValue::VOBJ);
BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx)
{
const uint256& hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ);
entryToJSON(info, e);
o.push_back(Pair(hash.ToString(), info));
}
return o;
}
else
{
vector<uint256> vtxid;
mempool.queryHashes(vtxid);
UniValue a(UniValue::VARR);
BOOST_FOREACH(const uint256& hash, vtxid)
a.push_back(hash.ToString());
return a;
}
}
UniValue getrawmempool(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"getrawmempool ( verbose )\n"
"\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
"\nArguments:\n"
"1. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n"
"\nResult: (for verbose = false):\n"
"[ (json array of string)\n"
" \"transactionid\" (string) The transaction id\n"
" ,...\n"
"]\n"
"\nResult: (for verbose = true):\n"
"{ (json object)\n"
" \"transactionid\" : { (json object)\n"
+ EntryDescriptionString()
+ " }, ...\n"
"}\n"
"\nExamples\n"
+ HelpExampleCli("getrawmempool", "true")
+ HelpExampleRpc("getrawmempool", "true")
);
bool fVerbose = false;
if (params.size() > 0)
fVerbose = params[0].get_bool();
return mempoolToJSON(fVerbose);
}
UniValue getmempoolancestors(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2) {
throw runtime_error(
"getmempoolancestors txid (verbose)\n"
"\nIf txid is in the mempool, returns all in-mempool ancestors.\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id (must be in mempool)\n"
"2. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n"
"\nResult (for verbose=false):\n"
"[ (json array of strings)\n"
" \"transactionid\" (string) The transaction id of an in-mempool ancestor transaction\n"
" ,...\n"
"]\n"
"\nResult (for verbose=true):\n"
"{ (json object)\n"
" \"transactionid\" : { (json object)\n"
+ EntryDescriptionString()
+ " }, ...\n"
"}\n"
"\nExamples\n"
+ HelpExampleCli("getmempoolancestors", "\"mytxid\"")
+ HelpExampleRpc("getmempoolancestors", "\"mytxid\"")
);
}
bool fVerbose = false;
if (params.size() > 1)
fVerbose = params[1].get_bool();
uint256 hash = ParseHashV(params[0], "parameter 1");
LOCK(mempool.cs);
CTxMemPool::txiter it = mempool.mapTx.find(hash);
if (it == mempool.mapTx.end()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
}
CTxMemPool::setEntries setAncestors;
uint64_t noLimit = std::numeric_limits<uint64_t>::max();
std::string dummy;
mempool.CalculateMemPoolAncestors(*it, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false);
if (!fVerbose) {
UniValue o(UniValue::VARR);
BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
o.push_back(ancestorIt->GetTx().GetHash().ToString());
}
return o;
} else {
UniValue o(UniValue::VOBJ);
BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
const CTxMemPoolEntry &e = *ancestorIt;
const uint256& hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ);
entryToJSON(info, e);
o.push_back(Pair(hash.ToString(), info));
}
return o;
}
}
UniValue getmempooldescendants(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2) {
throw runtime_error(
"getmempooldescendants txid (verbose)\n"
"\nIf txid is in the mempool, returns all in-mempool descendants.\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id (must be in mempool)\n"
"2. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n"
"\nResult (for verbose=false):\n"
"[ (json array of strings)\n"
" \"transactionid\" (string) The transaction id of an in-mempool descendant transaction\n"
" ,...\n"
"]\n"
"\nResult (for verbose=true):\n"
"{ (json object)\n"
" \"transactionid\" : { (json object)\n"
+ EntryDescriptionString()
+ " }, ...\n"
"}\n"
"\nExamples\n"
+ HelpExampleCli("getmempooldescendants", "\"mytxid\"")
+ HelpExampleRpc("getmempooldescendants", "\"mytxid\"")
);
}
bool fVerbose = false;
if (params.size() > 1)
fVerbose = params[1].get_bool();
uint256 hash = ParseHashV(params[0], "parameter 1");
LOCK(mempool.cs);
CTxMemPool::txiter it = mempool.mapTx.find(hash);
if (it == mempool.mapTx.end()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
}
CTxMemPool::setEntries setDescendants;
mempool.CalculateDescendants(it, setDescendants);
// CTxMemPool::CalculateDescendants will include the given tx
setDescendants.erase(it);
if (!fVerbose) {
UniValue o(UniValue::VARR);
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) {
o.push_back(descendantIt->GetTx().GetHash().ToString());
}
return o;
} else {
UniValue o(UniValue::VOBJ);
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) {
const CTxMemPoolEntry &e = *descendantIt;
const uint256& hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ);
entryToJSON(info, e);
o.push_back(Pair(hash.ToString(), info));
}
return o;
}
}
UniValue getmempoolentry(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1) {
throw runtime_error(
"getmempoolentry txid\n"
"\nReturns mempool data for given transaction\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id (must be in mempool)\n"
"\nResult:\n"
"{ (json object)\n"
+ EntryDescriptionString()
+ "}\n"
"\nExamples\n"
+ HelpExampleCli("getmempoolentry", "\"mytxid\"")
+ HelpExampleRpc("getmempoolentry", "\"mytxid\"")
);
}
uint256 hash = ParseHashV(params[0], "parameter 1");
LOCK(mempool.cs);
CTxMemPool::txiter it = mempool.mapTx.find(hash);
if (it == mempool.mapTx.end()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
}
const CTxMemPoolEntry &e = *it;
UniValue info(UniValue::VOBJ);
entryToJSON(info, e);
return info;
}
UniValue getblockhash(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"getblockhash index\n"
"\nReturns hash of block in best-block-chain at index provided.\n"
"\nArguments:\n"
"1. index (numeric, required) The block index\n"
"\nResult:\n"
"\"hash\" (string) The block hash\n"
"\nExamples:\n"
+ HelpExampleCli("getblockhash", "1000")
+ HelpExampleRpc("getblockhash", "1000")
);
LOCK(cs_main);
int nHeight = params[0].get_int();
if (nHeight < 0 || nHeight > chainActive.Height())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
CBlockIndex* pblockindex = chainActive[nHeight];
return pblockindex->GetBlockHash().GetHex();
}
UniValue getblockheader(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"getblockheader \"hash\" ( verbose )\n"
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.\n"
"If verbose is true, returns an Object with information about blockheader <hash>.\n"
"\nArguments:\n"
"1. \"hash\" (string, required) The block hash\n"
"2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n"
"\nResult (for verbose = true):\n"
"{\n"
" \"hash\" : \"hash\", (string) the block hash (same as provided)\n"
" \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n"
" \"height\" : n, (numeric) The block height or index\n"
" \"version\" : n, (numeric) The block version\n"
" \"versionHex\" : \"00000000\", (string) The block version formatted in hexadecimal\n"
" \"merkleroot\" : \"xxxx\", (string) The merkle root\n"
" \"time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n"
" \"mediantime\" : ttt, (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n"
" \"nonce\" : n, (numeric) The nonce\n"
" \"bits\" : \"1d00ffff\", (string) The bits\n"
" \"difficulty\" : x.xxx, (numeric) The difficulty\n"
" \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
" \"nextblockhash\" : \"hash\", (string) The hash of the next block\n"
" \"chainwork\" : \"0000...1f3\" (string) Expected number of hashes required to produce the current chain (in hex)\n"
"}\n"
"\nResult (for verbose=false):\n"
"\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n"
"\nExamples:\n"
+ HelpExampleCli("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
+ HelpExampleRpc("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
);
LOCK(cs_main);
std::string strHash = params[0].get_str();
uint256 hash(uint256S(strHash));
bool fVerbose = true;
if (params.size() > 1)
fVerbose = params[1].get_bool();
if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
CBlockIndex* pblockindex = mapBlockIndex[hash];
if (!fVerbose)
{
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
ssBlock << pblockindex->GetBlockHeader();
std::string strHex = HexStr(ssBlock.begin(), ssBlock.end());
return strHex;
}
return blockheaderToJSON(pblockindex);
}
UniValue getblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"getblock \"hash\" ( verbose )\n"
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
"If verbose is true, returns an Object with information about block <hash>.\n"
"\nArguments:\n"
"1. \"hash\" (string, required) The block hash\n"
"2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n"
"\nResult (for verbose = true):\n"
"{\n"
" \"hash\" : \"hash\", (string) the block hash (same as provided)\n"
" \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n"
" \"size\" : n, (numeric) The block size\n"
" \"strippedsize\" : n, (numeric) The block size excluding witness data\n"
" \"weight\" : n (numeric) The block weight (BIP 141)\n"
" \"height\" : n, (numeric) The block height or index\n"
" \"version\" : n, (numeric) The block version\n"
" \"versionHex\" : \"00000000\", (string) The block version formatted in hexadecimal\n"
" \"merkleroot\" : \"xxxx\", (string) The merkle root\n"
" \"tx\" : [ (array of string) The transaction ids\n"
" \"transactionid\" (string) The transaction id\n"
" ,...\n"
" ],\n"
" \"time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n"
" \"mediantime\" : ttt, (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n"
" \"nonce\" : n, (numeric) The nonce\n"
" \"bits\" : \"1d00ffff\", (string) The bits\n"
" \"difficulty\" : x.xxx, (numeric) The difficulty\n"
" \"chainwork\" : \"xxxx\", (string) Expected number of hashes required to produce the chain up to this block (in hex)\n"
" \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
" \"nextblockhash\" : \"hash\" (string) The hash of the next block\n"
"}\n"
"\nResult (for verbose=false):\n"
"\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n"
"\nExamples:\n"
+ HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
+ HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
);
LOCK(cs_main);
std::string strHash = params[0].get_str();
uint256 hash(uint256S(strHash));
bool fVerbose = true;
if (params.size() > 1)
fVerbose = params[1].get_bool();
if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
CBlock block;
CBlockIndex* pblockindex = mapBlockIndex[hash];
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)");
if(!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus()))
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
if (!fVerbose)
{
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
ssBlock << block;
std::string strHex = HexStr(ssBlock.begin(), ssBlock.end());
return strHex;
}
return blockToJSON(block, pblockindex);
}
struct CCoinsStats
{
int nHeight;
uint256 hashBlock;
uint64_t nTransactions;
uint64_t nTransactionOutputs;
uint64_t nSerializedSize;
uint256 hashSerialized;
CAmount nTotalAmount;
CCoinsStats() : nHeight(0), nTransactions(0), nTransactionOutputs(0), nSerializedSize(0), nTotalAmount(0) {}
};
//! Calculate statistics about the unspent transaction output set
static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
{
boost::scoped_ptr<CCoinsViewCursor> pcursor(view->Cursor());
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
stats.hashBlock = pcursor->GetBestBlock();
{
LOCK(cs_main);
stats.nHeight = mapBlockIndex.find(stats.hashBlock)->second->nHeight;
}
ss << stats.hashBlock;
CAmount nTotalAmount = 0;
while (pcursor->Valid()) {
boost::this_thread::interruption_point();
uint256 key;
CCoins coins;
if (pcursor->GetKey(key) && pcursor->GetValue(coins)) {
stats.nTransactions++;
ss << key;
for (unsigned int i=0; i<coins.vout.size(); i++) {
const CTxOut &out = coins.vout[i];
if (!out.IsNull()) {
stats.nTransactionOutputs++;
ss << VARINT(i+1);
ss << out;
nTotalAmount += out.nValue;
}
}
stats.nSerializedSize += 32 + pcursor->GetValueSize();
ss << VARINT(0);
} else {
return error("%s: unable to read value", __func__);
}
pcursor->Next();
}
stats.hashSerialized = ss.GetHash();
stats.nTotalAmount = nTotalAmount;
return true;
}
UniValue gettxoutsetinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"gettxoutsetinfo\n"
"\nReturns statistics about the unspent transaction output set.\n"
"Note this call may take some time.\n"
"\nResult:\n"
"{\n"
" \"height\":n, (numeric) The current block height (index)\n"
" \"bestblock\": \"hex\", (string) the best block hash hex\n"
" \"transactions\": n, (numeric) The number of transactions\n"
" \"txouts\": n, (numeric) The number of output transactions\n"
" \"bytes_serialized\": n, (numeric) The serialized size\n"
" \"hash_serialized\": \"hash\", (string) The serialized hash\n"
" \"total_amount\": x.xxx (numeric) The total amount\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("gettxoutsetinfo", "")
+ HelpExampleRpc("gettxoutsetinfo", "")
);
UniValue ret(UniValue::VOBJ);
CCoinsStats stats;
FlushStateToDisk();
if (GetUTXOStats(pcoinsTip, stats)) {
ret.push_back(Pair("height", (int64_t)stats.nHeight));
ret.push_back(Pair("bestblock", stats.hashBlock.GetHex()));
ret.push_back(Pair("transactions", (int64_t)stats.nTransactions));
ret.push_back(Pair("txouts", (int64_t)stats.nTransactionOutputs));
ret.push_back(Pair("bytes_serialized", (int64_t)stats.nSerializedSize));
ret.push_back(Pair("hash_serialized", stats.hashSerialized.GetHex()));
ret.push_back(Pair("total_amount", ValueFromAmount(stats.nTotalAmount)));
} else {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set");
}
return ret;
}
UniValue gettxout(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 3)
throw runtime_error(
"gettxout \"txid\" n ( includemempool )\n"
"\nReturns details about an unspent transaction output.\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id\n"
"2. n (numeric, required) vout number\n"
"3. includemempool (boolean, optional) Whether to include the mempool\n"
"\nResult:\n"
"{\n"
" \"bestblock\" : \"hash\", (string) the block hash\n"
" \"confirmations\" : n, (numeric) The number of confirmations\n"
" \"value\" : x.xxx, (numeric) The transaction value in " + CURRENCY_UNIT + "\n"
" \"scriptPubKey\" : { (json object)\n"
" \"asm\" : \"code\", (string) \n"
" \"hex\" : \"hex\", (string) \n"
" \"reqSigs\" : n, (numeric) Number of required signatures\n"
" \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n"
" \"addresses\" : [ (array of string) array of bitcoin addresses\n"
" \"bitcoinaddress\" (string) bitcoin address\n"
" ,...\n"
" ]\n"
" },\n"
" \"version\" : n, (numeric) The version\n"
" \"coinbase\" : true|false (boolean) Coinbase or not\n"
"}\n"
"\nExamples:\n"
"\nGet unspent transactions\n"
+ HelpExampleCli("listunspent", "") +
"\nView the details\n"
+ HelpExampleCli("gettxout", "\"txid\" 1") +
"\nAs a json rpc call\n"
+ HelpExampleRpc("gettxout", "\"txid\", 1")
);
LOCK(cs_main);
UniValue ret(UniValue::VOBJ);
std::string strHash = params[0].get_str();
uint256 hash(uint256S(strHash));
int n = params[1].get_int();
bool fMempool = true;
if (params.size() > 2)
fMempool = params[2].get_bool();
CCoins coins;
if (fMempool) {
LOCK(mempool.cs);
CCoinsViewMemPool view(pcoinsTip, mempool);
if (!view.GetCoins(hash, coins))
return NullUniValue;
mempool.pruneSpent(hash, coins); // TODO: this should be done by the CCoinsViewMemPool
} else {
if (!pcoinsTip->GetCoins(hash, coins))
return NullUniValue;
}
if (n<0 || (unsigned int)n>=coins.vout.size() || coins.vout[n].IsNull())
return NullUniValue;
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
CBlockIndex *pindex = it->second;
ret.push_back(Pair("bestblock", pindex->GetBlockHash().GetHex()));
if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT)
ret.push_back(Pair("confirmations", 0));
else
ret.push_back(Pair("confirmations", pindex->nHeight - coins.nHeight + 1));
ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue)));
UniValue o(UniValue::VOBJ);
ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true);
ret.push_back(Pair("scriptPubKey", o));
ret.push_back(Pair("version", coins.nVersion));
ret.push_back(Pair("coinbase", coins.fCoinBase));
return ret;
}
UniValue verifychain(const UniValue& params, bool fHelp)
{
int nCheckLevel = GetArg("-checklevel", DEFAULT_CHECKLEVEL);
int nCheckDepth = GetArg("-checkblocks", DEFAULT_CHECKBLOCKS);
if (fHelp || params.size() > 2)
throw runtime_error(
"verifychain ( checklevel numblocks )\n"
"\nVerifies blockchain database.\n"
"\nArguments:\n"
"1. checklevel (numeric, optional, 0-4, default=" + strprintf("%d", nCheckLevel) + ") How thorough the block verification is.\n"
"2. numblocks (numeric, optional, default=" + strprintf("%d", nCheckDepth) + ", 0=all) The number of blocks to check.\n"
"\nResult:\n"
"true|false (boolean) Verified or not\n"
"\nExamples:\n"
+ HelpExampleCli("verifychain", "")
+ HelpExampleRpc("verifychain", "")
);
LOCK(cs_main);
if (params.size() > 0)
nCheckLevel = params[0].get_int();
if (params.size() > 1)
nCheckDepth = params[1].get_int();
return CVerifyDB().VerifyDB(Params(), pcoinsTip, nCheckLevel, nCheckDepth);
}
/** Implementation of IsSuperMajority with better feedback */
static UniValue SoftForkMajorityDesc(int minVersion, CBlockIndex* pindex, int nRequired, const Consensus::Params& consensusParams)
{
int nFound = 0;
CBlockIndex* pstart = pindex;
for (int i = 0; i < consensusParams.nMajorityWindow && pstart != NULL; i++)
{
if (pstart->nVersion >= minVersion)
++nFound;
pstart = pstart->pprev;
}
UniValue rv(UniValue::VOBJ);
rv.push_back(Pair("status", nFound >= nRequired));
rv.push_back(Pair("found", nFound));
rv.push_back(Pair("required", nRequired));
rv.push_back(Pair("window", consensusParams.nMajorityWindow));
return rv;
}
static UniValue SoftForkDesc(const std::string &name, int version, CBlockIndex* pindex, const Consensus::Params& consensusParams)
{
UniValue rv(UniValue::VOBJ);
rv.push_back(Pair("id", name));
rv.push_back(Pair("version", version));
rv.push_back(Pair("enforce", SoftForkMajorityDesc(version, pindex, consensusParams.nMajorityEnforceBlockUpgrade, consensusParams)));
rv.push_back(Pair("reject", SoftForkMajorityDesc(version, pindex, consensusParams.nMajorityRejectBlockOutdated, consensusParams)));
return rv;
}
static UniValue BIP9SoftForkDesc(const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
{
UniValue rv(UniValue::VOBJ);
const ThresholdState thresholdState = VersionBitsTipState(consensusParams, id);
switch (thresholdState) {
case THRESHOLD_DEFINED: rv.push_back(Pair("status", "defined")); break;
case THRESHOLD_STARTED: rv.push_back(Pair("status", "started")); break;
case THRESHOLD_LOCKED_IN: rv.push_back(Pair("status", "locked_in")); break;
case THRESHOLD_ACTIVE: rv.push_back(Pair("status", "active")); break;
case THRESHOLD_FAILED: rv.push_back(Pair("status", "failed")); break;
}
if (THRESHOLD_STARTED == thresholdState)
{
rv.push_back(Pair("bit", consensusParams.vDeployments[id].bit));
}
rv.push_back(Pair("startTime", consensusParams.vDeployments[id].nStartTime));
rv.push_back(Pair("timeout", consensusParams.vDeployments[id].nTimeout));
return rv;
}
void BIP9SoftForkDescPushBack(UniValue& bip9_softforks, const std::string &name, const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
{
// Deployments with timeout value of 0 are hidden.
// A timeout value of 0 guarantees a softfork will never be activated.
// This is used when softfork codes are merged without specifying the deployment schedule.
if (consensusParams.vDeployments[id].nTimeout > 0)
bip9_softforks.push_back(Pair(name, BIP9SoftForkDesc(consensusParams, id)));
}
UniValue getblockchaininfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getblockchaininfo\n"
"Returns an object containing various state info regarding block chain processing.\n"
"\nResult:\n"
"{\n"
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
" \"headers\": xxxxxx, (numeric) the current number of headers we have validated\n"
" \"bestblockhash\": \"...\", (string) the hash of the currently best block\n"
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
" \"mediantime\": xxxxxx, (numeric) median time for the current best block\n"
" \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
" \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n"
" \"pruned\": xx, (boolean) if the blocks are subject to pruning\n"
" \"pruneheight\": xxxxxx, (numeric) lowest-height complete block stored\n"
" \"softforks\": [ (array) status of softforks in progress\n"
" {\n"
" \"id\": \"xxxx\", (string) name of softfork\n"
" \"version\": xx, (numeric) block version\n"
" \"enforce\": { (object) progress toward enforcing the softfork rules for new-version blocks\n"
" \"status\": xx, (boolean) true if threshold reached\n"
" \"found\": xx, (numeric) number of blocks with the new version found\n"
" \"required\": xx, (numeric) number of blocks required to trigger\n"
" \"window\": xx, (numeric) maximum size of examined window of recent blocks\n"
" },\n"
" \"reject\": { ... } (object) progress toward rejecting pre-softfork blocks (same fields as \"enforce\")\n"
" }, ...\n"
" ],\n"
" \"bip9_softforks\": { (object) status of BIP9 softforks in progress\n"
" \"xxxx\" : { (string) name of the softfork\n"
" \"status\": \"xxxx\", (string) one of \"defined\", \"started\", \"locked_in\", \"active\", \"failed\"\n"
" \"bit\": xx, (numeric) the bit (0-28) in the block version field used to signal this softfork (only for \"started\" status)\n"
" \"startTime\": xx, (numeric) the minimum median time past of a block at which the bit gains its meaning\n"
" \"timeout\": xx (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in\n"
" }\n"
" }\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getblockchaininfo", "")
+ HelpExampleRpc("getblockchaininfo", "")
);
LOCK(cs_main);
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("chain", Params().NetworkIDString()));
obj.push_back(Pair("blocks", (int)chainActive.Height()));
obj.push_back(Pair("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1));
obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("mediantime", (int64_t)chainActive.Tip()->GetMedianTimePast()));
obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip())));
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
obj.push_back(Pair("pruned", fPruneMode));
const Consensus::Params& consensusParams = Params().GetConsensus();
CBlockIndex* tip = chainActive.Tip();
UniValue softforks(UniValue::VARR);
UniValue bip9_softforks(UniValue::VOBJ);
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV);
BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT);
obj.push_back(Pair("softforks", softforks));
obj.push_back(Pair("bip9_softforks", bip9_softforks));
if (fPruneMode)
{
CBlockIndex *block = chainActive.Tip();
while (block && block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA))
block = block->pprev;
obj.push_back(Pair("pruneheight", block->nHeight));
}
return obj;
}
/** Comparison function for sorting the getchaintips heads. */
struct CompareBlocksByHeight
{
bool operator()(const CBlockIndex* a, const CBlockIndex* b) const
{
/* Make sure that unequal blocks with the same height do not compare
equal. Use the pointers themselves to make a distinction. */
if (a->nHeight != b->nHeight)
return (a->nHeight > b->nHeight);
return a < b;
}
};
UniValue getchaintips(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getchaintips\n"
"Return information about all known tips in the block tree,"
" including the main chain as well as orphaned branches.\n"
"\nResult:\n"
"[\n"
" {\n"
" \"height\": xxxx, (numeric) height of the chain tip\n"
" \"hash\": \"xxxx\", (string) block hash of the tip\n"
" \"branchlen\": 0 (numeric) zero for main chain\n"
" \"status\": \"active\" (string) \"active\" for the main chain\n"
" },\n"
" {\n"
" \"height\": xxxx,\n"
" \"hash\": \"xxxx\",\n"
" \"branchlen\": 1 (numeric) length of branch connecting the tip to the main chain\n"
" \"status\": \"xxxx\" (string) status of the chain (active, valid-fork, valid-headers, headers-only, invalid)\n"
" }\n"
"]\n"
"Possible values for status:\n"
"1. \"invalid\" This branch contains at least one invalid block\n"
"2. \"headers-only\" Not all blocks for this branch are available, but the headers are valid\n"
"3. \"valid-headers\" All blocks are available for this branch, but they were never fully validated\n"
"4. \"valid-fork\" This branch is not part of the active chain, but is fully validated\n"
"5. \"active\" This is the tip of the active main chain, which is certainly valid\n"
"\nExamples:\n"
+ HelpExampleCli("getchaintips", "")
+ HelpExampleRpc("getchaintips", "")
);
LOCK(cs_main);
/*
* Idea: the set of chain tips is chainActive.tip, plus orphan blocks which do not have another orphan building off of them.
* Algorithm:
* - Make one pass through mapBlockIndex, picking out the orphan blocks, and also storing a set of the orphan block's pprev pointers.
* - Iterate through the orphan blocks. If the block isn't pointed to by another orphan, it is a chain tip.
* - add chainActive.Tip()
*/
std::set<const CBlockIndex*, CompareBlocksByHeight> setTips;
std::set<const CBlockIndex*> setOrphans;
std::set<const CBlockIndex*> setPrevs;
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex)
{
if (!chainActive.Contains(item.second)) {
setOrphans.insert(item.second);
setPrevs.insert(item.second->pprev);
}
}
for (std::set<const CBlockIndex*>::iterator it = setOrphans.begin(); it != setOrphans.end(); ++it)
{
if (setPrevs.erase(*it) == 0) {
setTips.insert(*it);
}
}
// Always report the currently active tip.
setTips.insert(chainActive.Tip());
/* Construct the output array. */
UniValue res(UniValue::VARR);
BOOST_FOREACH(const CBlockIndex* block, setTips)
{
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("height", block->nHeight));
obj.push_back(Pair("hash", block->phashBlock->GetHex()));
const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight;
obj.push_back(Pair("branchlen", branchLen));
string status;
if (chainActive.Contains(block)) {
// This block is part of the currently active chain.
status = "active";
} else if (block->nStatus & BLOCK_FAILED_MASK) {
// This block or one of its ancestors is invalid.
status = "invalid";
} else if (block->nChainTx == 0) {
// This block cannot be connected because full block data for it or one of its parents is missing.
status = "headers-only";
} else if (block->IsValid(BLOCK_VALID_SCRIPTS)) {
// This block is fully validated, but no longer part of the active chain. It was probably the active block once, but was reorganized.
status = "valid-fork";
} else if (block->IsValid(BLOCK_VALID_TREE)) {
// The headers for this block are valid, but it has not been validated. It was probably never part of the most-work chain.
status = "valid-headers";
} else {
// No clue.
status = "unknown";
}
obj.push_back(Pair("status", status));
res.push_back(obj);
}
return res;
}
UniValue mempoolInfoToJSON()
{
UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("size", (int64_t) mempool.size()));
ret.push_back(Pair("bytes", (int64_t) mempool.GetTotalTxSize()));
ret.push_back(Pair("usage", (int64_t) mempool.DynamicMemoryUsage()));
size_t maxmempool = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
ret.push_back(Pair("maxmempool", (int64_t) maxmempool));
ret.push_back(Pair("mempoolminfee", ValueFromAmount(mempool.GetMinFee(maxmempool).GetFeePerK())));
return ret;
}
UniValue getmempoolinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getmempoolinfo\n"
"\nReturns details on the active state of the TX memory pool.\n"
"\nResult:\n"
"{\n"
" \"size\": xxxxx, (numeric) Current tx count\n"
" \"bytes\": xxxxx, (numeric) Sum of all tx sizes\n"
" \"usage\": xxxxx, (numeric) Total memory usage for the mempool\n"
" \"maxmempool\": xxxxx, (numeric) Maximum memory usage for the mempool\n"
" \"mempoolminfee\": xxxxx (numeric) Minimum fee for tx to be accepted\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getmempoolinfo", "")
+ HelpExampleRpc("getmempoolinfo", "")
);
return mempoolInfoToJSON();
}
UniValue invalidateblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"invalidateblock \"hash\"\n"
"\nPermanently marks a block as invalid, as if it violated a consensus rule.\n"
"\nArguments:\n"
"1. hash (string, required) the hash of the block to mark as invalid\n"
"\nResult:\n"
"\nExamples:\n"
+ HelpExampleCli("invalidateblock", "\"blockhash\"")
+ HelpExampleRpc("invalidateblock", "\"blockhash\"")
);
std::string strHash = params[0].get_str();
uint256 hash(uint256S(strHash));
CValidationState state;
{
LOCK(cs_main);
if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
CBlockIndex* pblockindex = mapBlockIndex[hash];
InvalidateBlock(state, Params(), pblockindex);
}
if (state.IsValid()) {
ActivateBestChain(state, Params());
}
if (!state.IsValid()) {
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
}
return NullUniValue;
}
UniValue reconsiderblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"reconsiderblock \"hash\"\n"
"\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n"
"This can be used to undo the effects of invalidateblock.\n"
"\nArguments:\n"
"1. hash (string, required) the hash of the block to reconsider\n"
"\nResult:\n"
"\nExamples:\n"
+ HelpExampleCli("reconsiderblock", "\"blockhash\"")
+ HelpExampleRpc("reconsiderblock", "\"blockhash\"")
);
std::string strHash = params[0].get_str();
uint256 hash(uint256S(strHash));
{
LOCK(cs_main);
if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
CBlockIndex* pblockindex = mapBlockIndex[hash];
ResetBlockFailureFlags(pblockindex);
}
CValidationState state;
ActivateBestChain(state, Params());
if (!state.IsValid()) {
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
}
return NullUniValue;
}
static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode
// --------------------- ------------------------ ----------------------- ----------
{ "blockchain", "getblockchaininfo", &getblockchaininfo, true },
{ "blockchain", "getbestblockhash", &getbestblockhash, true },
{ "blockchain", "getblockcount", &getblockcount, true },
{ "blockchain", "getblock", &getblock, true },
{ "blockchain", "getblockhash", &getblockhash, true },
{ "blockchain", "getblockheader", &getblockheader, true },
{ "blockchain", "getchaintips", &getchaintips, true },
{ "blockchain", "getdifficulty", &getdifficulty, true },
{ "blockchain", "getmempoolancestors", &getmempoolancestors, true },
{ "blockchain", "getmempooldescendants", &getmempooldescendants, true },
{ "blockchain", "getmempoolentry", &getmempoolentry, true },
{ "blockchain", "getmempoolinfo", &getmempoolinfo, true },
{ "blockchain", "getrawmempool", &getrawmempool, true },
{ "blockchain", "gettxout", &gettxout, true },
{ "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true },
{ "blockchain", "verifychain", &verifychain, true },
/* Not shown in help */
{ "hidden", "invalidateblock", &invalidateblock, true },
{ "hidden", "reconsiderblock", &reconsiderblock, true },
};
void RegisterBlockchainRPCCommands(CRPCTable &tableRPC)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
} | [
"crzybluebilly@mailinator.com"
] | crzybluebilly@mailinator.com |
af5387a30e0a3770eea6c8095b66ccce40122f02 | afec113dcac49a1f341d42be821973755051e103 | /seglobal/globallogger.cpp | 59e78aad832517110e3ec3034ffbe6856477e9c5 | [] | no_license | radtek/earnsmart | e080bafa824bf2728fbf8603d46c11430d77cfb6 | df3983366a993d1e5ba0167d2483c3eb799b25be | refs/heads/master | 2020-06-22T06:14:04.646933 | 2019-02-15T13:32:59 | 2019-02-15T13:32:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 308 | cpp | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
#include "globallogger.h"
INITIALIZE_EASYLOGGINGPP
el::Logger* glogger = el::Loggers::getLogger("earn-smart"); | [
"sajiantony@hotmail.com"
] | sajiantony@hotmail.com |
6417bd62b328ed4918ba4cb4f60a8e9d434b506c | 04c227db51eedb48fa045738e552bfd9fc1b9b94 | /source/disassembler.h | d11910fc3ef7127abe8960a7bd507e689e3ae6eb | [
"MIT"
] | permissive | HWxp/ftrace | 8ff143ba59904e0fdd6cb282e45c0083168d324a | 1bc5099864c7eadc5846a14e0027ab07daca6549 | refs/heads/master | 2022-01-08T11:18:24.673417 | 2018-04-26T13:48:02 | 2018-04-26T13:48:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 725 | h | #ifndef _H_DISASSEMBER_
#define _H_DISASSEMBER_
#include <vector> // vector
#include <map> // map
#include <unordered_map> // unordered_map
#include <link.h> /* ElfW */
#include <capstone/capstone.h> //cs_insn
class Disassembler {
public:
void disassemble_callsites(
uint8_t* code, int32_t size, std::intptr_t code_entry, bool print_ins);
void disassemble_ins(
uint8_t* code, int32_t size, std::intptr_t code_entry, bool print_ins);
void generate_callsite(
cs_insn &insn, cs_insn &next_insn, bool print);
private:
void print_disassembled_ins(cs_insn &disassembled_ins);
std::map<std::intptr_t, cs_insn> m_disassembled_ins;
};
#endif | [
"orion64@orion64.orion64"
] | orion64@orion64.orion64 |
982582d699b96d6bd5926f30818b0d6248b4f7f8 | 786814fb24fb1d2bce788a07023675a3354ace29 | /ccf/1512-4.cc | 7d7eaab46fad445a318166d998a451c952e84e5b | [] | no_license | zhou78yang/homeworks | e7c3c989e5579f7bd7d802f3503fbaa1ffc50446 | 9fc92754c57ed108761457394174597b442bcea6 | refs/heads/master | 2021-01-22T06:44:35.475312 | 2017-11-15T14:41:36 | 2017-11-15T14:41:36 | 55,292,561 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 907 | cc | #include <iostream>
#include <algorithm>
using namespace std;
#define N 10005
#define M 100005
#define INF 999999
int n, m;
bool e[N][N] = {0}, visit[N][N] = {0};
int stack[M], top = 0;
bool dfs(int cur)
{
if(top > m) return true;
for(int i = 1; i <= n; i++)
{
if(e[cur][i] && !visit[cur][i])
{
stack[top++] = i;
visit[cur][i] = visit[i][cur] = true;
if(dfs(i)) return true;
visit[cur][i] = visit[i][cur] = false;
top--;
}
}
return false;
}
int main()
{
int u, v;
cin >> n >> m;
for(int i = 1; i <= m; i++)
{
cin >> u >> v;
e[u][v] = e[v][u] = true;
}
stack[top++] = 1;
if(dfs(1))
{
for(int i = 0; i <= m; i++) cout << stack[i] << " ";
cout << endl;
}
else
{
cout << -1 << endl;
}
return 0;
}
| [
"zhou78yang@gmail.com"
] | zhou78yang@gmail.com |
802c42ba5c883ea62ffa7e69398dcdd95fd22644 | 31f449e61b3c45659d2c2ed21204960b2ad64421 | /projects/include/loader.hpp | a6a55f6e5034dd83f16e833b18fdee9df799ce4c | [] | no_license | MedulaOblogota/yap | 62ae0745a82e8507fa1dbb746846bcc09cdac601 | 5396401cca1f304aed00bb43627abf2a0b9b927e | refs/heads/master | 2023-06-07T04:19:53.780118 | 2021-06-21T10:13:58 | 2021-06-21T10:13:58 | 370,606,403 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 201 | hpp | #ifndef INC_RD70_LOADER
#define INC_RD70_LOADER
// #include "/home/student/roy-yablonka/projects/framework/factory/factory.hpp"
#include "../framework/dir_monitor/loader.hpp"
#endif //INC_RD70_LOADER
| [
"royyab@gmail.com"
] | royyab@gmail.com |
6a72b8a331f64fa1c701e3501315719f53d27587 | 0a5645154953b0a09d3f78753a1711aaa76928ff | /common/c/nbgm/nbgmmain/src/nbgmservice/nbgmlayoutbuffer.cpp | f5f49d5ebe3ff38e899c7498057769cee2283cbc | [] | no_license | GENIVI/navigation-next | 3a6f26063350ac8862b4d0e2e9d3522f6f249328 | cb8f7ec5ec4c78ef57aa573315b75960b2a5dd36 | refs/heads/master | 2023-08-04T17:44:45.239062 | 2023-07-25T19:22:19 | 2023-07-25T19:22:19 | 116,230,587 | 17 | 11 | null | 2018-05-18T20:00:38 | 2018-01-04T07:43:22 | C++ | UTF-8 | C++ | false | false | 27,828 | cpp | /*
Copyright (c) 2018, TeleCommunication Systems, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the TeleCommunication Systems, Inc., nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
DISCLAIMED. IN NO EVENT SHALL TELECOMMUNICATION SYSTEMS, INC.BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*--------------------------------------------------------------------------
(C) Copyright 2012 by Networks In Motion, Inc.
The information contained herein is confidential, proprietary
to Networks In Motion, Inc., and considered a trade secret as
defined in section 499C of the penal code of the State of
California. Use of this information by anyone other than
authorized employees of Networks In Motion is granted only
under a written non-disclosure agreement, expressly
prescribing the scope and manner of such use.
---------------------------------------------------------------------------*/
#include "nbgmlayoutbuffer.h"
#include "nbretransformation.h"
#include "nbreoverlay.h"
#include "nbrerenderpal.h"
#include "nbrehardwarebuffer.h"
#include "nbreintersection.h"
#include "nbremath.h"
#include "nbreclipping.h"
class CheckLineCallback:
public NBGM_ISetPixelCallback
{
public:
CheckLineCallback(uint32* buffer, NBRE_Vector2i cellCount, uint32 mask, int32 lineWidth):mBuffer(buffer), mCellCount(cellCount), mMask(mask), mLineWidth(lineWidth), mIsEmpty(TRUE)
{
}
public:
virtual nb_boolean OnSetPixel(int32 x, int32 y, nb_boolean IsXDominant)
{
int32 radius = mLineWidth / 2;
nb_boolean hit = FALSE;
for (int32 r = 0; r <= radius; ++r)
{
if (IsXDominant)
{
if (!IsPixelEmpty(x, y + r))
{
hit = TRUE;
break;
}
if (r > 0 && !IsPixelEmpty(x, y - r))
{
hit = TRUE;
break;
}
}
else
{
if (!IsPixelEmpty(x + r, y))
{
hit = TRUE;
break;
}
if (r > 0 && !IsPixelEmpty(x - r, y))
{
hit = TRUE;
break;
}
}
}
if (hit)
{
mIsEmpty = FALSE;
return FALSE;
}
return TRUE;
}
nb_boolean IsPixelEmpty(int32 x, int32 y)
{
if (x >= 0 && x < mCellCount.x && y >= 0 && y < mCellCount.y)
{
if (mBuffer[mCellCount.x * y + x] & mMask)
{
return FALSE;
}
}
return TRUE;
}
nb_boolean IsLineRegionEmpty()
{
return mIsEmpty;
}
private:
uint32* mBuffer;
NBRE_Vector2i mCellCount;
uint32 mMask;
int32 mLineWidth;
nb_boolean mIsEmpty;
};
class UpdateLineCallback:
public NBGM_ISetPixelCallback
{
public:
UpdateLineCallback(uint32* buffer, NBRE_Vector2i cellCount, uint32 mask, int32 lineWidth):mBuffer(buffer), mCellCount(cellCount), mMask(mask), mLineWidth(lineWidth)
{
}
public:
virtual nb_boolean OnSetPixel(int32 x, int32 y, nb_boolean IsXDominant)
{
int32 radius = mLineWidth / 2;
for (int32 r = 0; r <= radius; ++r)
{
if (IsXDominant)
{
UpdatePixel(x, y + r);
if (r > 0)
{
UpdatePixel(x, y - r);
}
}
else
{
UpdatePixel(x + r, y);
if (r > 0)
{
UpdatePixel(x - r, y);
}
}
}
return TRUE;
}
void UpdatePixel(int32 x, int32 y)
{
if (x >= 0 && x < mCellCount.x && y >= 0 && y < mCellCount.y)
{
mBuffer[mCellCount.x * y + x] |= mMask;
}
}
private:
uint32* mBuffer;
NBRE_Vector2i mCellCount;
uint32 mMask;
int32 mLineWidth;
};
class SplitLineCallback:
public NBGM_ISetPixelCallback
{
public:
typedef NBRE_Vector<int32> StepList;
struct SubSegment
{
public:
SubSegment(int32 beginStep, int32 endStep)
:beginStep(beginStep)
,endStep(endStep)
{
}
public:
int32 beginStep;
int32 endStep;
};
typedef NBRE_Vector<SubSegment> SubSegmentList;
public:
SplitLineCallback(uint32* buffer, NBRE_Vector2i cellCount, uint32 mask, int32 lineWidth)
:mBuffer(buffer), mCellCount(cellCount), mMask(mask), mLineWidth(lineWidth), mTotalSteps(0)
{
}
public:
virtual nb_boolean OnSetPixel(int32 x, int32 y, nb_boolean IsXDominant)
{
int32 radius = mLineWidth / 2;
nb_boolean hit = FALSE;
for (int32 r = 0; r <= radius; ++r)
{
if (IsXDominant)
{
if (!IsPixelEmpty(x, y + r))
{
hit = TRUE;
break;
}
if (r > 0 && !IsPixelEmpty(x, y - r))
{
hit = TRUE;
break;
}
}
else
{
if (!IsPixelEmpty(x + r, y))
{
hit = TRUE;
break;
}
if (r > 0 && !IsPixelEmpty(x - r, y))
{
hit = TRUE;
break;
}
}
}
if (hit)
{
if (mSegment.size() > 2)
{
mSegments.push_back(SubSegment(mSegment[0], mSegment[mSegment.size() - 1]));
}
mSegment.clear();
}
else
{
mSegment.push_back(mTotalSteps);
}
++mTotalSteps;
return TRUE;
}
nb_boolean IsPixelEmpty(int32 x, int32 y)
{
if (x >= 0 && x < mCellCount.x && y >= 0 && y < mCellCount.y)
{
if (mBuffer[mCellCount.x * y + x] & mMask)
{
mBuffer[mCellCount.x * y + x] |= 0x1000;
return FALSE;
}
}
return TRUE;
}
int32 GetTotalSteps()
{
return mTotalSteps;
}
const SubSegmentList& GetSegments()
{
// Add last segment
if (mSegment.size() > 2)
{
mSegments.push_back(SubSegment(mSegment[0], mSegment[mSegment.size() - 1]));
}
mSegment.clear();
return mSegments;
}
private:
uint32* mBuffer;
NBRE_Vector2i mCellCount;
uint32 mMask;
int32 mLineWidth;
SubSegmentList mSegments;
StepList mSegment;
int32 mTotalSteps;
};
class StaticSplitLineCallback:
public NBGM_ISetPixelCallback
{
public:
typedef NBRE_Vector<NBRE_Vector2i> StepList;
struct SubSegment
{
public:
SubSegment(const NBRE_Vector2i& beginStep, const NBRE_Vector2i& endStep)
:beginStep(beginStep)
,endStep(endStep)
{
}
public:
NBRE_Vector2i beginStep;
NBRE_Vector2i endStep;
};
typedef NBRE_Vector<SubSegment> SubSegmentList;
public:
StaticSplitLineCallback(uint32* buffer, NBRE_Vector2i cellCount, uint32 mask, int32 lineWidth)
:mBuffer(buffer), mCellCount(cellCount), mMask(mask), mLineWidth(lineWidth), mTotalSteps(0)
{
}
public:
virtual nb_boolean OnSetPixel(int32 x, int32 y, nb_boolean IsXDominant)
{
int32 radius = mLineWidth / 2;
nb_boolean hit = FALSE;
for (int32 r = 0; r <= radius; ++r)
{
if (IsXDominant)
{
if (!IsPixelEmpty(x, y + r))
{
hit = TRUE;
break;
}
if (r > 0 && !IsPixelEmpty(x, y - r))
{
hit = TRUE;
break;
}
}
else
{
if (!IsPixelEmpty(x + r, y))
{
hit = TRUE;
break;
}
if (r > 0 && !IsPixelEmpty(x - r, y))
{
hit = TRUE;
break;
}
}
}
if (hit)
{
if (mSegment.size() > 0)
{
mSegments.push_back(SubSegment(mSegment[0], mSegment[mSegment.size() - 1]));
}
mSegment.clear();
}
else
{
mSegment.push_back(NBRE_Vector2i(x, y));
}
++mTotalSteps;
return TRUE;
}
nb_boolean IsPixelEmpty(int32 x, int32 y)
{
if (x >= 0 && x < mCellCount.x && y >= 0 && y < mCellCount.y)
{
if (mBuffer[mCellCount.x * y + x] & mMask)
{
return FALSE;
}
}
return TRUE;
}
int32 GetTotalSteps()
{
return mTotalSteps;
}
const SubSegmentList& GetSegments()
{
// Add last segment
if (mSegment.size() > 0)
{
mSegments.push_back(SubSegment(mSegment[0], mSegment[mSegment.size() - 1]));
}
mSegment.clear();
return mSegments;
}
private:
uint32* mBuffer;
NBRE_Vector2i mCellCount;
uint32 mMask;
int32 mLineWidth;
SubSegmentList mSegments;
StepList mSegment;
int32 mTotalSteps;
};
NBGM_LayoutBuffer::NBGM_LayoutBuffer(NBGM_Context& nbgmContext, float width, float height, float cellSize)
:mNBGMContext(nbgmContext)
,mBuffer(NULL)
,mSize(width, height)
,mCellCount(int32(width / cellSize), int32(height / cellSize))
,mCellSize(cellSize)
{
nbre_assert(cellSize != 0);
if (mCellCount.x > 0 && mCellCount.y > 0)
{
mBuffer = NBRE_NEW uint32[mCellCount.x * mCellCount.y];
nsl_memset(mBuffer, 0, mCellCount.x * mCellCount.y * sizeof(uint32));
}
}
NBGM_LayoutBuffer::~NBGM_LayoutBuffer()
{
NBRE_DELETE_ARRAY mBuffer;
}
void
NBGM_LayoutBuffer::Clear()
{
if (mCellCount.x == 0 || mCellCount.y == 0)
{
return;
}
nsl_memset(mBuffer, 0, mCellCount.x * mCellCount.y * sizeof(uint32));
}
void
NBGM_LayoutBuffer::Clear(uint32 mask)
{
if (mCellCount.x == 0 || mCellCount.y == 0)
{
return;
}
uint32 n = mCellCount.x * mCellCount.y;
uint32 v = ~mask;
for (uint32 i = 0; i < n; ++i)
{
mBuffer[i] &= v;
}
}
void
NBGM_LayoutBuffer::Resize(float width, float height)
{
if (width == 0 || height == 0)
{
return;
}
int32 xCount = (int32)(width / mCellSize);
int32 yCount = (int32)(height / mCellSize);
if (xCount < 1)
{
xCount = 1;
}
if (yCount < 1)
{
yCount = 1;
}
if (xCount != mCellCount.x || yCount != mCellCount.y)
{
NBRE_DELETE_ARRAY mBuffer;
mCellCount.x = xCount;
mCellCount.y = yCount;
mSize.x = width;
mSize.y = height;
mBuffer = NBRE_NEW uint32[mCellCount.x * mCellCount.y];
}
Clear();
}
nb_boolean
NBGM_LayoutBuffer::IsRegionAvailable(const NBRE_AxisAlignedBox2d& rect, uint32 value)
{
if (mCellCount.x == 0 || mCellCount.y == 0)
{
return FALSE;
}
if (rect.IsNull())
{
return FALSE;
}
NBRE_AxisAlignedBox2i elementRect;
if (!TransformScreenRectToBufferRect(rect, elementRect))
{
return FALSE;
}
if (!ClipRect(elementRect))
{
return FALSE;
}
for (int32 y = elementRect.minExtend.y; y <= elementRect.maxExtend.y; ++y)
{
for (int32 x = elementRect.minExtend.x; x <= elementRect.maxExtend.x; ++x)
{
if (mBuffer[y * mCellCount.x + x] & value)
{
return FALSE;
}
}
}
return TRUE;
}
void
NBGM_LayoutBuffer::UpdateRegion(const NBRE_AxisAlignedBox2d& rect, uint32 value)
{
UpdateRegion(rect, value, 0);
}
void
NBGM_LayoutBuffer::UpdateRegion(const NBRE_AxisAlignedBox2d& rect, uint32 value, int32 expand)
{
if (mCellCount.x == 0 || mCellCount.y == 0)
{
return;
}
if (rect.IsNull())
{
return;
}
NBRE_AxisAlignedBox2i elementRect;
if (!TransformScreenRectToBufferRect(rect, elementRect))
{
return;
}
if (expand > 0)
{
if (!elementRect.IsNull())
{
--elementRect.minExtend.x;
--elementRect.minExtend.y;
++elementRect.maxExtend.x;
++elementRect.maxExtend.y;
}
}
else if (expand < 0)
{
if (!elementRect.IsNull())
{
if (elementRect.maxExtend.x + elementRect.minExtend.x > 2)
{
++elementRect.minExtend.x;
--elementRect.maxExtend.x;
}
if (elementRect.maxExtend.y + elementRect.minExtend.y > 2)
{
++elementRect.minExtend.y;
--elementRect.maxExtend.y;
}
}
}
if (!ClipRect(elementRect))
{
return;
}
for (int32 y = elementRect.minExtend.y; y <= elementRect.maxExtend.y; ++y)
{
for (int32 x = elementRect.minExtend.x; x <= elementRect.maxExtend.x; ++x)
{
mBuffer[y * mCellCount.x + x] |= value;
}
}
}
nb_boolean
NBGM_LayoutBuffer::IsRegionAvailable(const NBRE_Polyline2d& polyline, int32 lineWidth, uint32 value)
{
if (mCellCount.x == 0 || mCellCount.y == 0)
{
return FALSE;
}
nbre_assert(polyline.VertexCount() >= 2);
NBGM_Point2iList transPolyline = TransformPolyline(polyline);
if (transPolyline.size() < 2)
{
return FALSE;
}
NBRE_AxisAlignedBox2i rc;
NBRE_Vector2i half(lineWidth / 2, lineWidth / 2);
for (uint32 i = 0; i < transPolyline.size() - 1; ++i)
{
NBRE_Vector2i p0 = transPolyline[i];
NBRE_Vector2i p1 = transPolyline[i + 1];
NBRE_LineClipResult result = NBRE_Clippingi::ClipLineByRect(NBRE_AxisAlignedBox2i(0, 0, mCellCount.x - 1, mCellCount.y - 1), p0, p1);
if (result != NBRE_LCR_OUTSIDE)
{
rc.minExtend = p0 - half;
rc.maxExtend = p0 + half;
if (!CheckRect(rc, value))
{
return FALSE;
}
rc.minExtend = p1 - half;
rc.maxExtend = p1 + half;
if (!CheckRect(rc, value))
{
return FALSE;
}
CheckLineCallback checkLine(mBuffer, mCellCount, value, lineWidth);
NBGM_Rasterize::DrawLine(p0.x, p0.y, p1.x, p1.y, &checkLine);
if (!checkLine.IsLineRegionEmpty())
{
return FALSE;
}
}
}
return TRUE;
}
void
NBGM_LayoutBuffer::UpdateRegion(const NBRE_Polyline2d& polyline, int32 lineWidth, uint32 value)
{
if (mCellCount.x == 0 || mCellCount.y == 0)
{
return;
}
nbre_assert(polyline.VertexCount() >= 2);
NBGM_Point2iList transPolyline = TransformPolyline(polyline);
if (transPolyline.size() < 2)
{
return;
}
UpdateLineCallback updateLine(mBuffer, mCellCount, value, lineWidth);
NBGM_Rasterize::DrawPolyline(transPolyline, &updateLine);
NBRE_AxisAlignedBox2i rc;
int32 halfS = lineWidth / 2;
NBRE_Vector2i half(halfS, halfS);
for (uint32 i = 0; i < transPolyline.size(); ++i)
{
const NBRE_Vector2i& pt = transPolyline[i];
rc.minExtend = pt - half;
rc.maxExtend = pt + half;
UpdateRect(rc, value);
}
}
void
NBGM_LayoutBuffer::UpdateRegion(const NBRE_Vector2d& p0, const NBRE_Vector2d& p1, int32 lineWidth, uint32 mask)
{
if (mCellCount.x == 0 || mCellCount.y == 0)
{
return;
}
float dx = static_cast<float>(mCellCount.x) / mSize.x;
float dy = static_cast<float>(mCellCount.y) / mSize.y;
NBRE_Vector2i pb0(static_cast<int32>(p0.x * dx), static_cast<int32>(p0.y * dy));
NBRE_Vector2i pb1(static_cast<int32>(p1.x * dx), static_cast<int32>(p1.y * dy));
UpdateLineCallback updateLine(mBuffer, mCellCount, mask, lineWidth);
NBGM_Rasterize::DrawLine(pb0.x, pb0.y, pb1.x, pb1.y, &updateLine);
NBRE_AxisAlignedBox2i rc;
int32 halfS = lineWidth / 2;
NBRE_Vector2i half(halfS, halfS);
rc.minExtend = pb0 - half;
rc.maxExtend = pb0 + half;
UpdateRect(rc, mask);
rc.minExtend = pb1 - half;
rc.maxExtend = pb1 + half;
UpdateRect(rc, mask);
}
NBGM_LayoutPolylineList
NBGM_LayoutBuffer::GetRegionAvailableParts(const NBGM_LayoutPolyline& layoutPolyline, int32 lineWidth, uint32 mask)
{
NBGM_LayoutPolylineList result;
if (mCellCount.x == 0 || mCellCount.y == 0)
{
return result;
}
NBRE_Polyline2d polyline = layoutPolyline.GetScreenPolyline();
nbre_assert(polyline.VertexCount() >= 2);
NBGM_Point2iList transPolyline = TransformPolyline(polyline);
if (transPolyline.size() < 2)
{
return result;
}
SplitLineCallback splitLine(mBuffer, mCellCount, mask, lineWidth);
NBGM_Rasterize::DrawPolyline(transPolyline, &splitLine);
int32 steps = splitLine.GetTotalSteps();
SplitLineCallback::SubSegmentList segments = splitLine.GetSegments();
double length = polyline.Length();
for (uint32 segIndex = 0; segIndex < segments.size(); ++segIndex)
{
const SplitLineCallback::SubSegment& seg = segments[segIndex];
NBGM_LayoutPolylinePosition beginPos = layoutPolyline.ConvertOffsetToParameterCoordinate(seg.beginStep * length / steps);
NBGM_LayoutPolylinePosition endPos = layoutPolyline.ConvertOffsetToParameterCoordinate((seg.endStep + 1) * length / steps);
NBGM_LayoutVertexList pts;
pts.push_back(layoutPolyline.PointAt(beginPos));
for (uint32 i = beginPos.segmentIndex + 1; i <= endPos.segmentIndex; ++i)
{
pts.push_back(layoutPolyline.Vertex(i));
}
pts.push_back(layoutPolyline.PointAt(endPos));
if (pts.size() >= 2)
{
result.push_back(NBGM_LayoutPolyline(&mNBGMContext, pts));
}
}
return result;
}
static inline uint32 CheckCell(uint32* buffer, NBRE_Vector2i mCellCount, int32 x, int32 y, uint32 mask)
{
return buffer[y * mCellCount.x + x] & mask;
}
nb_boolean
NBGM_LayoutBuffer::GetAvailablePolylineParts(const NBRE_Polyline2d& polyline, int32 lineWidth, uint32 mask, NBRE_Vector<NBRE_Polyline2d>& result)
{
if (mCellCount.x == 0 || mCellCount.y == 0 || polyline.VertexCount() < 2)
{
return FALSE;
}
NBGM_Point2iList transPolyline = TransformPolyline(polyline);
if (transPolyline.size() < 2)
{
return FALSE;
}
result.clear();
//int32 radius = lineWidth / 2;
NBRE_Vector<NBRE_Vector2i> rasterPts;
NBRE_Vector<nb_boolean> rasterFree;
NBRE_Vector<NBRE_Vector2d> polylinePts;
for (uint32 vIdx = 1; vIdx < transPolyline.size(); ++vIdx)
{
const NBRE_Vector2i& p0 = transPolyline[vIdx - 1];
const NBRE_Vector2i& p1 = transPolyline[vIdx];
rasterPts.clear();
NBGM_Rasterize::DrawLine(p0.x, p0.y, p1.x, p1.y, mCellCount.x, mCellCount.y, rasterPts);
rasterFree.resize(rasterPts.size());
for (uint32 ri = 0; ri < rasterPts.size(); ++ri)
{
const NBRE_Vector2i& rasterPoint = rasterPts[ri];
if ( CheckCell(mBuffer, mCellCount, rasterPoint.x, rasterPoint.y, mask)
|| CheckCell(mBuffer, mCellCount, rasterPoint.x - 1, rasterPoint.y, mask)
|| CheckCell(mBuffer, mCellCount, rasterPoint.x + 1, rasterPoint.y, mask)
|| CheckCell(mBuffer, mCellCount, rasterPoint.x, rasterPoint.y - 1, mask)
|| CheckCell(mBuffer, mCellCount, rasterPoint.x, rasterPoint.y + 1, mask)
)
{
// conflict found
rasterFree[ri] = FALSE;
}
else
{
rasterFree[ri] = TRUE;
}
}
for (uint32 ri = 0; ri < rasterPts.size(); ++ri)
{
uint32 idxBegin = ri;
uint32 idxEnd = ri;
while(ri + 1 < rasterPts.size() && rasterFree[++ri])
{
++idxEnd;
}
NBRE_Polyline2Positiond pos;
NBRE_Vector2d pt = polyline.Vertex(vIdx - 1);
if (idxBegin != 0)
{
if (polylinePts.size() >= 2)
{
NBRE_Polyline2d subpl(polylinePts);
result.push_back(subpl);
}
polylinePts.clear();
pt = NBRE_LinearInterpolated::Lerp(polyline.Vertex(vIdx - 1), polyline.Vertex(vIdx), (double)(idxBegin) / rasterPts.size());
polylinePts.push_back(pt);
}
else
{
if (polylinePts.size() == 0 || polylinePts.back() != pt)
{
polylinePts.push_back(pt);
}
}
pt = polyline.Vertex(vIdx);
if (idxEnd != rasterPts.size() - 1)
{
pt = NBRE_LinearInterpolated::Lerp(polyline.Vertex(vIdx - 1), polyline.Vertex(vIdx), (double)(idxEnd + 1) / rasterPts.size());
polylinePts.push_back(pt);
if (polylinePts.size() >= 2)
{
NBRE_Polyline2d subpl(polylinePts);
result.push_back(subpl);
}
polylinePts.clear();
}
else
{
if (polylinePts.size() == 0 || polylinePts.back() != pt)
{
polylinePts.push_back(pt);
}
}
}
}
if (polylinePts.size() >= 2)
{
NBRE_Polyline2d subpl(polylinePts);
result.push_back(subpl);
}
polylinePts.clear();
double rectRadius = mCellSize * lineWidth * 0.5;
NBRE_Vector2d halfSize(rectRadius, rectRadius);
for (int32 i = 0; i < (int32)result.size(); ++i)
{
const NBRE_Polyline2d& pl = result[i];
double beginOffset = 0;
double endOffset = pl.Length();
NBRE_AxisAlignedBox2d rect(pl.Vertex(0) - halfSize, pl.Vertex(0) + halfSize);
if (!IsRegionAvailable(rect, mask))
{
beginOffset = rectRadius;
}
rect.minExtend = pl.Vertex(pl.VertexCount() - 1) - halfSize;
rect.maxExtend = pl.Vertex(pl.VertexCount() - 1) + halfSize;
if (!IsRegionAvailable(rect, mask))
{
endOffset = pl.Length() - rectRadius;
}
if (beginOffset >= endOffset)
{
result.erase(result.begin() + i);
--i;
}
else
{
if (beginOffset != 0 || endOffset != pl.Length())
{
result[i] = pl.SubPolyline(beginOffset, endOffset);
}
}
}
return result.size() > 0 ? TRUE : FALSE;
}
nb_boolean
NBGM_LayoutBuffer::TransformScreenRectToBufferRect(const NBRE_AxisAlignedBox2d& rect, NBRE_AxisAlignedBox2i& result) const
{
if (rect.maxExtend.x < 0 ||
rect.maxExtend.y < 0 ||
rect.minExtend.x > mCellSize * mCellCount.x ||
rect.minExtend.y > mCellSize * mCellCount.y)
{
return FALSE;
}
float dx = static_cast<float>(mCellCount.x) / mSize.x;
float dy = static_cast<float>(mCellCount.y) / mSize.y;
result.minExtend.x = static_cast<int32>(rect.minExtend.x * dx);
result.minExtend.y = static_cast<int32>(rect.minExtend.y * dy);
result.maxExtend.x = static_cast<int32>(rect.maxExtend.x * dx);
result.maxExtend.y = static_cast<int32>(rect.maxExtend.y * dy);
return TRUE;
}
NBGM_Point2iList
NBGM_LayoutBuffer::TransformPolyline(const NBRE_Polyline2d& polyline)
{
double dx = static_cast<double>(mCellCount.x) / mSize.x;
double dy = static_cast<double>(mCellCount.y) / mSize.y;
uint32 vertexCount = polyline.VertexCount();
NBRE_Vector<NBRE_Vector2i> transVertices;
for (uint32 i = 0; i < vertexCount; ++i)
{
if (polyline.Vertex(i).IsNaN())
{
continue;
}
NBRE_Vector2i v(
static_cast<int32>((polyline.Vertex(i).x) * dx),
static_cast<int32>((polyline.Vertex(i).y) * dy));
transVertices.push_back(v);
}
return transVertices;
}
NBRE_Vector2d
NBGM_LayoutBuffer::BufferToWorld(const NBRE_Vector2i& position)
{
return NBRE_Vector2d(position.x * mSize.x / mCellCount.x, position.y * mSize.y / mCellCount.y);
}
nb_boolean
NBGM_LayoutBuffer::ClipRect(NBRE_AxisAlignedBox2i& elementRect)
{
if (elementRect.minExtend.x >= mCellCount.x ||
elementRect.minExtend.y >= mCellCount.y ||
elementRect.maxExtend.x < 0 ||
elementRect.maxExtend.y < 0
)
{
return FALSE;
}
if (elementRect.minExtend.x < 0)
{
elementRect.minExtend.x = 0;
}
if (elementRect.minExtend.y < 0)
{
elementRect.minExtend.y = 0;
}
if (elementRect.maxExtend.x >= mCellCount.x)
{
elementRect.maxExtend.x = mCellCount.x - 1;
}
if (elementRect.maxExtend.y >= mCellCount.y)
{
elementRect.maxExtend.y = mCellCount.y - 1;
}
return TRUE;
}
nb_boolean
NBGM_LayoutBuffer::CheckRect(const NBRE_AxisAlignedBox2i& rect, uint32 mask)
{
NBRE_AxisAlignedBox2i elementRect = rect;
if (!ClipRect(elementRect))
{
return TRUE;
}
for (int32 y = elementRect.minExtend.y; y <= elementRect.maxExtend.y; ++y)
{
for (int32 x = elementRect.minExtend.x; x <= elementRect.maxExtend.x; ++x)
{
if (mBuffer[y * mCellCount.x + x] & mask)
{
return FALSE;
}
}
}
return TRUE;
}
void
NBGM_LayoutBuffer::UpdateRect(const NBRE_AxisAlignedBox2i& rect, uint32 mask)
{
NBRE_AxisAlignedBox2i elementRect = rect;
if (!ClipRect(elementRect))
{
return;
}
for (int32 y = elementRect.minExtend.y; y <= elementRect.maxExtend.y; ++y)
{
for (int32 x = elementRect.minExtend.x; x <= elementRect.maxExtend.x; ++x)
{
mBuffer[y * mCellCount.x + x] |= mask;
}
}
}
| [
"caavula@telecomsys.com"
] | caavula@telecomsys.com |
39562720d08d9f1501bb4cf2b60dacfa0bb374d7 | 74358bba2f643a6aaa314724e662be1c9344feaf | /snake_class/src/entity.cpp | 3047b2d42fcdf31e38103fdd35b17ea6fc6bd4aa | [] | no_license | claridelune/UProjects | eb2583e71e051c4ae15ce7770043e3211ef76d6d | 2c75d059d2b8e6e7ddf8865f5c079c248d10e952 | refs/heads/main | 2023-09-05T00:15:05.926549 | 2021-11-22T13:47:34 | 2021-11-22T13:47:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 448 | cpp | #include "../include/entity.h"
Entity::Entity(){}
Entity::Entity(Coord pos){
this->pos = pos;
}
Entity::Entity(Entity &o){
pos = o.pos;
color = o.color;
symbol = o.symbol;
}
Entity::~Entity(){}
void Entity::setPos(Coord _pos){
this->pos = _pos;
}
void Entity::setSymbol(std::string _symbol){
this->symbol = _symbol;
}
std::string Entity::getSymbol(){
return symbol;
}
Coord Entity::getPos(){
return pos;
}
| [
"camilaclary@gmail.com"
] | camilaclary@gmail.com |
dfd23943b55f693c91e23fc6c021e9d0a5704193 | ba9322f7db02d797f6984298d892f74768193dcf | /emr/src/model/DeleteFlowProjectByIdRequest.cc | c884a4fa3922db05d1aaf7ae0c3fc1eedfd8fc4c | [
"Apache-2.0"
] | permissive | sdk-team/aliyun-openapi-cpp-sdk | e27f91996b3bad9226c86f74475b5a1a91806861 | a27fc0000a2b061cd10df09cbe4fff9db4a7c707 | refs/heads/master | 2022-08-21T18:25:53.080066 | 2022-07-25T10:01:05 | 2022-07-25T10:01:05 | 183,356,893 | 3 | 0 | null | 2019-04-25T04:34:29 | 2019-04-25T04:34:28 | null | UTF-8 | C++ | false | false | 1,437 | cc | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/emr/model/DeleteFlowProjectByIdRequest.h>
using AlibabaCloud::Emr::Model::DeleteFlowProjectByIdRequest;
DeleteFlowProjectByIdRequest::DeleteFlowProjectByIdRequest() :
RpcServiceRequest("emr", "2016-04-08", "DeleteFlowProjectById")
{}
DeleteFlowProjectByIdRequest::~DeleteFlowProjectByIdRequest()
{}
std::string DeleteFlowProjectByIdRequest::getRegionId()const
{
return regionId_;
}
void DeleteFlowProjectByIdRequest::setRegionId(const std::string& regionId)
{
regionId_ = regionId;
setParameter("RegionId", regionId);
}
std::string DeleteFlowProjectByIdRequest::getProjectId()const
{
return projectId_;
}
void DeleteFlowProjectByIdRequest::setProjectId(const std::string& projectId)
{
projectId_ = projectId;
setParameter("ProjectId", projectId);
}
| [
"haowei.yao@alibaba-inc.com"
] | haowei.yao@alibaba-inc.com |
bff9e13a228e6f4da5ba054e17dc6d1c6adeb5f6 | d9039054754abafeec2ff70a096d9ddcf51223c8 | /SYCL/SubGroup/vote.cpp | df16d59db4c6dd6c1138798b1934d55b092feba7 | [
"NCSA",
"LLVM-exception",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | hanzhan1/llvm-test-suite | 09dbb69662cf072656541f34efbc6e308feff627 | e23c7ebaa9c043f9f42277112205ba8a0d5e83a3 | refs/heads/intel | 2023-04-29T15:00:46.291096 | 2021-01-25T19:08:14 | 2021-01-25T19:08:14 | 323,266,562 | 0 | 0 | Apache-2.0 | 2021-01-14T08:11:19 | 2020-12-21T07:49:07 | Logos | UTF-8 | C++ | false | false | 3,070 | cpp | // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %HOST_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out
//==--------------- vote.cpp - SYCL sub_group vote test --*- C++ -*---------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "helper.hpp"
#include <CL/sycl.hpp>
using namespace cl::sycl;
void check(queue Queue, const int G, const int L, const int D, const int R) {
try {
range<1> GRange(G), LRange(L);
nd_range<1> NdRange(GRange, LRange);
buffer<int, 1> sganybuf(G);
buffer<int, 1> sgallbuf(G);
// Initialise buffer with zeros
Queue.submit([&](handler &cgh) {
auto sganyacc = sganybuf.get_access<access::mode::read_write>(cgh);
auto sgallacc = sgallbuf.get_access<access::mode::read_write>(cgh);
cgh.parallel_for<class init>(range<1>{(unsigned)G}, [=](id<1> index) {
sganyacc[index] = 0;
sgallacc[index] = 0;
});
});
Queue.submit([&](handler &cgh) {
auto sganyacc = sganybuf.get_access<access::mode::read_write>(cgh);
auto sgallacc = sgallbuf.get_access<access::mode::read_write>(cgh);
cgh.parallel_for<class init_bufs>(NdRange, [=](nd_item<1> NdItem) {
sganyacc[NdItem.get_global_id()] = 0;
sgallacc[NdItem.get_global_id()] = 0;
});
});
Queue.submit([&](handler &cgh) {
auto sganyacc = sganybuf.get_access<access::mode::read_write>(cgh);
auto sgallacc = sgallbuf.get_access<access::mode::read_write>(cgh);
cgh.parallel_for<class subgr>(NdRange, [=](nd_item<1> NdItem) {
ONEAPI::sub_group SG = NdItem.get_sub_group();
/* Set to 1 if any local ID in subgroup devided by D has remainder R */
if (any_of(SG, SG.get_local_id().get(0) % D == R)) {
sganyacc[NdItem.get_global_id()] = 1;
}
/* Set to 1 if remainder of division of subgroup local ID by D is less
* than R for all work items in subgroup */
if (all_of(SG, SG.get_local_id().get(0) % D < R)) {
sgallacc[NdItem.get_global_id()] = 1;
}
});
});
auto sganyacc = sganybuf.get_access<access::mode::read_write>();
auto sgallacc = sgallbuf.get_access<access::mode::read_write>();
for (int j = 0; j < G; j++) {
exit_if_not_equal(sganyacc[j], (int)(D > R), "any");
exit_if_not_equal(sgallacc[j], (int)(D <= R), "all");
}
} catch (exception e) {
std::cout << "SYCL exception caught: " << e.what();
exit(1);
}
}
int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check(Queue, 240, 80, 3, 1);
check(Queue, 24, 12, 3, 4);
check(Queue, 1024, 256, 3, 1);
std::cout << "Test passed." << std::endl;
}
| [
"noreply@github.com"
] | noreply@github.com |
d7a4cd263494b8012834479d6f31540c8b392b0f | 6c7520ea1c95f437ecde70fcdb202ab5cee54b17 | /Problems/573B1.cpp | faece9911f0a9bf3a131d971c4b026e763aa96ba | [] | no_license | Ashish-uzumaki/contests | 997a8288c63f1e834b7689c2ff97e29e965b6139 | 0084adfc3b1a9bf496146c6e4db429720a1ce98c | refs/heads/master | 2021-01-16T04:07:38.303987 | 2020-08-09T16:49:47 | 2020-08-09T16:49:47 | 242,972,066 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,930 | cpp | #include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef long double lld;
typedef long long int lli;
using namespace std;
const int N = 1000001;
const int MOD=1e9+7;
const bool DEBUG = 1;
#define sd(x) scanf("%d", &x)
#define sd2(x, y) scanf("%d%d", &x, &y)
#define sd3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define endl "\n"
#define fi first
#define se second
#define eb emplace_back
#define fbo find_by_order
#define ook order_of_key
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define LET(x, a) __typeof(a) x(a)
#define foreach(it, v) for (LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a, b) memset(a, b, sizeof(a))
#define _ \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define __ \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define all(c) c.begin(), c.end()
#define inf 1000000000000000001
#define epsilon 1e-6
#define int ll
#define RUN_T \
int _t; \
cin >> _t; \
while (_t--)
#define tr(...) \
if (DEBUG) { \
cout << __FUNCTION__ << ' ' << __LINE__ << " = "; \
trace(#__VA_ARGS__, __VA_ARGS__); \
}
template <typename S, typename T>
ostream &operator<<(ostream &out, pair<S, T> const &p) {
out << '(' << p.fi << ", " << p.se << ')';
return out;
}
template <typename T>
ostream &operator<<(ostream &out, set<T> const &v) {
for (auto i = v.begin(); i != v.end(); i++)
out << (*i) << ' ';
return out;
}
template <typename T, typename V>
ostream &operator<<(ostream &out, map<T, V> const &v) {
for (auto i = v.begin(); i != v.end(); i++)
out << "\n" << (i->first) << ":" << (i->second);
return out;
}
template <typename T, typename V>
ostream &operator<<(ostream &out, unordered_map<T, V> const &v) {
for (auto i = v.begin(); i != v.end(); i++)
out << "\n" << (i->first) << ":" << (i->second);
return out;
}
template <typename T>
ostream &operator<<(ostream &out, multiset<T> const &v) {
for (auto i = v.begin(); i != v.end(); i++)
out << (*i) << ' ';
return out;
}
template <typename T>
ostream &operator<<(ostream &out, unordered_set<T> const &v) {
for (auto i = v.begin(); i != v.end(); i++)
out << (*i) << ' ';
return out;
}
template <typename T>
ostream &operator<<(ostream &out, unordered_multiset<T> const &v) {
for (auto i = v.begin(); i != v.end(); i++)
out << (*i) << ' ';
return out;
}
template <typename T> ostream &operator<<(ostream &out, vector<T> const &v) {
ll l = v.size();
for (ll i = 0; i < l - 1; i++)
out << v[i] << ' ';
if (l > 0)
out << v[l - 1];
return out;
}
template <typename T> void trace(const char *name, T &&arg1) {
cout << name << ":" << arg1 << endl;
}
template <typename T, typename... Args>
void trace(const char *names, T &&arg1, Args &&... args) {
const char *comma = strchr(names + 1, ',');
cout.write(names, comma - names) << ":" << arg1 << "|" ;
trace(comma + 1, args...);
}
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
void add_self(int& a, int b) {
a += b;
if(a >= MOD) {
a -= MOD;
}
}
int32_t main() {
_
int n;
cin >> n;
vector<int>v(n+1);
vector<int>l(n+1),r(n+1);
for(int i = 1; i <= n; i++){
cin>>v[i];
l[i] = min(v[i], i);
r[i] = min(v[i], n - i + 1);
}
for(int i = 2; i <= n; i++){
l[i] = min(l[i], l[i-1] + 1);
}
for(int i = n - 1; i >= 1; i--){
r[i] = min(r[i], r[i+1] + 1);
}
int mx = 1;
for(int i = 1; i <= n; i++){
mx = max(mx, min(l[i],r[i]));
}
cout << mx << endl;
} | [
"Ashish.singh@iiitb.org"
] | Ashish.singh@iiitb.org |
cc96b14eaa5fa570fdb3c780255b155ae17a97c0 | 888d3c2a6e42f7d736a32bf891fe4808c3e27ad5 | /src/utils.cpp | cf760ec6d26b9e054a916363cb8e7212d4326e73 | [] | no_license | horizon-research/Real-Time-Spatio-Temporal-LiDAR-Point-Cloud-Compression | 2bc67962766d43228dc28cb764fd4978949e58c9 | 3597a5373b78dc2d5d2d4ad9db88baeabd6293c4 | refs/heads/master | 2023-05-11T06:17:54.513033 | 2023-04-30T02:11:05 | 2023-04-30T02:11:05 | 279,674,663 | 102 | 16 | null | null | null | null | UTF-8 | C++ | false | false | 8,886 | cpp | #include "utils.h"
// this is used to load xyz binary file
void load_pcloud(std::string& file_name,
std::vector<point_cloud>& pcloud_data) {
/* allocate buffer to store the data */
int32_t num = 1000000;
float * buf = (float *) malloc(num*sizeof(float));
/* pointers */
float *px = buf+0;
float *py = buf+1;
float *pz = buf+2;
float *pr = buf+3;
/* open file to read */
FILE * stream = fopen (file_name.c_str(), "rb");
std::cout << file_name.c_str() << std::endl;
// std::ofstream outstream("output.txt");
num = fread(buf, sizeof(float), num, stream)/4;
for (int32_t i = 0; i < num; i++) {
pcloud_data.push_back(point_cloud(std::move((*px)),
std::move((*py)),
std::move((*pz)),
std::move(*pr)));
/* update the new point addresses */
px+=4; py+=4; pz+=4; pr+=4;
}
/* free the additional space */
free(buf);
// outstream.close();
fclose(stream);
}
// this is used to load xyz binary file
void load_pcloud_xyz(std::string& file_name,
std::vector<point_cloud>& pcloud_data) {
/* pointers */
float x, y, z;
/* open file to read */
std::string line;
std::ifstream stream(file_name.c_str());
std::cout << file_name << std::endl;
while (std::getline(stream, line)) {
auto cnt = sscanf(line.c_str(), "%f %f %f", &x, &y, &z);
if (cnt < 3) {
std::cout << "Invalid line: " + line << std::endl;
continue;
}
pcloud_data.push_back(point_cloud(x, y, z, 0.0f));
}
stream.close();
}
void pcloud2bin(std::string filename, std::vector<point_cloud>& pcloud_data) {
/* pointers */
float x, y, z, r;
r = 0;
/* open file to read */
std::ofstream out_stream(filename, std::ofstream::binary);
std::cout << "Write " << filename << std::endl;
for (auto p : pcloud_data) {
x = p.x;
y = p.y;
z = p.z;
r = p.r;
out_stream.write(reinterpret_cast<const char*>(&x), sizeof(x));
out_stream.write(reinterpret_cast<const char*>(&y), sizeof(y));
out_stream.write(reinterpret_cast<const char*>(&z), sizeof(z));
out_stream.write(reinterpret_cast<const char*>(&r), sizeof(r));
}
out_stream.close();
}
void compute_cartesian_coord(const float radius, const float yaw,
const float pitch, float& x, float& y, float& z,
float pitch_precision, float yaw_precision) {
// start to convert spherical coordinates
// into cartesian coordinates;
float xy_radius = ((float) radius)*cos(yaw/180.0f*PI*yaw_precision);
// compute the coordinates;
z = ((float) radius)*sin(yaw/180.0f*PI*yaw_precision);
x = xy_radius*cos(pitch/180.0f*PI*pitch_precision);
y = xy_radius*sin(pitch/180.0f*PI*pitch_precision);
}
std::string pcloud2string(std::vector<point_cloud>& pcloud_data) {
std::string ret = "[";
for (auto p : pcloud_data) {
ret += p.to_string_xyz() + ",";
}
ret.pop_back();
ret += "]";
return ret;
}
void output_cloud(const std::vector<point_cloud>& pcloud, std::string file_name) {
std::ofstream stream(file_name.c_str());
stream << "ply\nformat ascii 1.0\n";
stream << "element vertex " << pcloud.size() << std::endl;
stream << "property float x\nproperty float y\nproperty float z\nend_header" << std::endl;
for (auto point : pcloud) {
float x = point.x;
float y = point.y;
float z = point.z;
stream << x << " " << y << " " << z << std::endl;
}
stream.close();
}
std::vector<float>
output_normalize_cloud(const std::vector<point_cloud>& pcloud, std::string file_name) {
float min_x = 0.f, max_x = 0.f, min_y = 0.f, max_y = 0.f, min_z = 0.f, max_z = 0.f;
for (auto point : pcloud) {
float x = point.x;
float y = point.y;
float z = point.z;
min_x = (min_x > x) ? x : min_x;
min_y = (min_y > y) ? y : min_y;
min_z = (min_z > z) ? z : min_z;
max_x = (max_x < x) ? x : max_x;
max_y = (max_y < y) ? y : max_y;
max_z = (max_z < z) ? z : max_z;
}
std::ofstream stream(file_name.c_str());
stream << "ply\nformat ascii 1.0\n";
stream << "element vertex " << pcloud.size() << std::endl;
stream << "property float x\nproperty float y\nproperty float z\nend_header" << std::endl;
for (auto point : pcloud) {
int x = (int)((point.x - min_x)/(max_x - min_x)*255.f);
int y = (int)((point.y - min_y)/(max_y - min_y)*255.f);
int z = (int)((point.z - min_z)/(max_z - min_z)*255.f);
stream << x << " " << y << " " << z << std::endl;
}
stream.close();
return {min_x, max_x, min_y, max_y, min_z, max_z};
}
float neighbor_search(float radius, cv::Mat& img, int row, int col) {
float restored_radius = img.at<float>(row, col);
for (int i = std::max(0,row-1); i < std::min(img.rows, row+2); i++) {
for (int j = std::max(0,col-1); j < std::min(img.cols, col+2); j++) {
if (std::abs(restored_radius-radius) > std::abs(img.at<float>(i, j)-radius))
restored_radius = img.at<float>(i, j);
}
}
return restored_radius;
}
float compute_loss_rate(cv::Mat& img, const std::vector<point_cloud>& pcloud,
float pitch_precision, float yaw_precision) {
// initialize different error metric;
float x_error = 0.0f, y_error = 0.0f, z_error = 0.0f;
float error = 0.0f, dist_error = 0.0f;
float norm_error = 0.0f, norm_dist_error = 0.0f;
float max_radius = 0.0f, min_radius = 0.0f;
for (auto point : pcloud) {
float x = point.x;
float y = point.y;
float z = point.z;
/* calculate some parameters for spherical coord */
float dist = sqrt(x*x + y*y);
float radius = sqrt(x*x + y*y + z*z);
float pitch = atan2(y, x) * 180.0f / pitch_precision / PI;
float yaw = atan2(z, dist) * 180.0f / yaw_precision / PI;
float row_offset = ROW_OFFSET/yaw_precision;
float col_offset = COL_OFFSET/pitch_precision;
int col = std::min(img.cols-1, std::max(0, (int)(pitch+col_offset)));
int row = std::min(img.rows-1, std::max(0, (int)(yaw+row_offset)));
// find max and min
max_radius = fmax(max_radius, radius);
min_radius = fmin(min_radius, radius);
float restored_radius(0);
restored_radius = neighbor_search(radius, img, row, col);
if (std::isnan(restored_radius) || (restored_radius > 150.f) || restored_radius < 0.1f) {
std::cout << "[IGNORE]: " << radius << " vs. " << restored_radius << ". [x,y,z]: " << x << ", " << y << ", " << z << std::endl;
restored_radius = 0.1f;
}
float restored_x, restored_y, restored_z;
compute_cartesian_coord(restored_radius, (row+0.5f)-row_offset, (col+0.5f)-col_offset,
restored_x, restored_y, restored_z,
pitch_precision, yaw_precision);
double x_diff = fabs(x - restored_x);
double y_diff = fabs(y - restored_y);
double z_diff = fabs(z - restored_z);
double diff = sqrt(x_diff*x_diff + y_diff*y_diff + z_diff*z_diff);
x_error += x_diff;
y_error += y_diff;
z_error += z_diff;
error += diff;
norm_error += diff / radius;
dist_error += abs(restored_radius - radius);
norm_dist_error += abs(restored_radius - radius) / radius;
}
if (VERBOSE) {
std::cout << "the x-error rate: " << x_error / pcloud.size() << std::endl;
std::cout << "the y-error rate: " << y_error / pcloud.size() << std::endl;
std::cout << "the z-error rate: " << z_error / pcloud.size() << std::endl;
std::cout << "the error rate: " << error / pcloud.size() << std::endl;
std::cout << "the normal error rate: " << norm_error / pcloud.size() << std::endl;
std::cout << "the distance error rate: " << dist_error / pcloud.size() << std::endl;
std::cout << "the normal distance error rate: " << norm_dist_error / pcloud.size() << std::endl;
}
// find the maximum boundary among x, y, z;
double bb_width = 2*max_radius;
// divide the error by the number of points
error = error / pcloud.size();
// compute peak-signal-to-noise ratio (psnr)
return 10.0*log10((bb_width*bb_width)/(error*error));
}
void restore_pcloud(cv::Mat& img, float pitch_precision, float yaw_precision,
std::vector<point_cloud>& restored_pcloud) {
std::cout << pitch_precision << " : " << yaw_precision << std::endl;
for (int row = 0; row < img.rows; row++) {
for (int col = 0; col < img.cols; col++) {
float radius = img.at<float>(row, col);
if (radius <= 0) continue;
float pitch = (col + 0.5) * pitch_precision - COL_OFFSET;
float yaw = (row + 0.5) * yaw_precision - ROW_OFFSET;
// std::cout << yaw << std::endl;
float z = radius*sin(yaw * PI / 180.0f);
float dist = radius*cos(yaw * PI / 180.0f);
float y = dist*sin(pitch * PI / 180.0f);
float x = dist*cos(pitch * PI / 180.0f);
restored_pcloud.push_back(point_cloud(x, y, z, radius));
}
}
}
| [
"yfeng28@ur.rochester.edu"
] | yfeng28@ur.rochester.edu |
8e13083825f303b279a18b59a229b889f573458c | 8f1090fde49a406c819bfbd7714b3ef83315a506 | /Client/src/main.cpp | 58e458af73bf5b9515f1c92937f71511a55a39e9 | [] | no_license | vinceofdrink/PlatformIO | 0c1c5028a4a1a08adbc7dac7cd425f910eb828f0 | 84548db6e991a94aa4b9a3f0339c91967f5909d9 | refs/heads/master | 2023-05-04T20:40:50.089719 | 2021-05-21T13:38:22 | 2021-05-21T13:38:22 | 369,546,447 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,422 | cpp | #include <Arduino.h>
/**
* Exemple de code pour la bibliothèque Mirf – Client Ping Pong
*/
#include <SPI.h> // Pour la communication via le port SPI
#include <Mirf.h> // Pour la gestion de la communication
#include <nRF24L01.h> // Pour les définitions des registres du nRF24L01
#include <MirfHardwareSpiDriver.h> // Pour la communication SPI
void setup() {
pinMode(4, INPUT_PULLUP);
Mirf.cePin = 9; // Broche CE sur D9
Mirf.csnPin = 10; // Broche CSN sur D10
Mirf.spi = &MirfHardwareSpi; // On veut utiliser le port SPI hardware
Mirf.init(); // Initialise la bibliothèque
// Mirf.configRegister(RF_SETUP, 0x26); //Lower transmission
Mirf.channel = 124; // Choix du canal de communication (128 canaux disponibles, de 0 à 127)
Mirf.payload = sizeof(long); // Taille d'un message (maximum 32 octets)
Mirf.config(); // Sauvegarde la configuration dans le module radio
Mirf.configRegister(RF_SETUP, 0x2F); //0x07
Mirf.setTADDR((byte *) "d@@r_"); // Adresse de transmission
Mirf.setRADDR((byte *) "nrf01"); // Adresse de réception
}
void loop() {
unsigned long time_message = millis(); // On garde le temps actuel retourné par millis()
if(digitalRead(4) == LOW ) {
Mirf.send((byte *) &time_message); // On envoie le temps actuel en utilisant une astuce pour transformer le long en octets
while(Mirf.isSending()); // On attend la fin de l'envoi
delay(600);
}
}
| [
"vinceofdrink@gmail.com"
] | vinceofdrink@gmail.com |
9e7e1290d7c784c0ecb578769a08a56e9e4a0a59 | 936a023959b7277ef0fe4cb6c87a738b531c1feb | /SpiceMySponza/source/MyController.cpp | 7e2722c5032957241c61875ad20561a5cc9227af | [
"Libpng"
] | permissive | PheroTyrian/OpenGLGraphicsProject | cd54da7e4c5e4325cb59f5c50ba5d56f3a90da04 | c3ce53066897e97047a4851b4a1891220e8f892f | refs/heads/main | 2023-03-19T14:48:23.425953 | 2021-03-08T16:55:57 | 2021-03-08T16:55:57 | 345,729,136 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,372 | cpp | #include "MyController.hpp"
#include "MyView.hpp"
#include <sponza/sponza.hpp>
#include <tygra/Window.hpp>
#include <glm/glm.hpp>
#include <iostream>
MyController::MyController()
{
scene_ = new sponza::Context();
view_ = new MyView();
view_->setScene(scene_);
}
MyController::~MyController()
{
delete view_;
delete scene_;
}
void MyController::windowControlWillStart(tygra::Window * window)
{
window->setView(view_);
window->setTitle("3D Graphics Programming :: SpiceMySponza");
}
void MyController::windowControlDidStop(tygra::Window * window)
{
window->setView(nullptr);
}
void MyController::windowControlViewWillRender(tygra::Window * window)
{
scene_->update();
if (camera_turn_mode_) {
scene_->getCamera().setRotationalVelocity(sponza::Vector2(0, 0));
}
}
void MyController::windowControlMouseMoved(tygra::Window * window,
int x,
int y)
{
static int prev_x = x;
static int prev_y = y;
if (camera_turn_mode_) {
int dx = x - prev_x;
int dy = y - prev_y;
const float mouse_speed = 0.6f;
scene_->getCamera().setRotationalVelocity(
sponza::Vector2(-dx * mouse_speed, -dy * mouse_speed));
}
prev_x = x;
prev_y = y;
}
void MyController::windowControlMouseButtonChanged(tygra::Window * window,
int button_index,
bool down)
{
if (button_index == tygra::kWindowMouseButtonLeft) {
camera_turn_mode_ = down;
}
}
void MyController::windowControlMouseWheelMoved(tygra::Window * window,
int position)
{
}
void MyController::windowControlKeyboardChanged(tygra::Window * window,
int key_index,
bool down)
{
switch (key_index) {
case tygra::kWindowKeyLeft:
case 'A':
camera_move_speed_[0] = down ? 1.f : 0.f;
break;
case tygra::kWindowKeyRight:
case 'D':
camera_move_speed_[1] = down ? 1.f : 0.f;
break;
case tygra::kWindowKeyUp:
case 'W':
camera_move_speed_[2] = down ? 1.f : 0.f;
break;
case tygra::kWindowKeyDown:
case 'S':
camera_move_speed_[3] = down ? 1.f : 0.f;
break;
}
updateCameraTranslation();
if (!down)
return;
//switch (key_index)
//{
// // TODO: put usual keypress responses here
//}
}
void MyController::windowControlGamepadAxisMoved(tygra::Window * window,
int gamepad_index,
int axis_index,
float pos)
{
const float deadzone = 0.2f;
const float rotate_speed = 3.f;
switch (axis_index) {
case tygra::kWindowGamepadAxisLeftThumbX:
if (pos < -deadzone) {
camera_move_speed_[0] = -pos;
camera_move_speed_[1] = 0.f;
}
else if (pos > deadzone) {
camera_move_speed_[0] = 0.f;
camera_move_speed_[1] = pos;
}
else {
camera_move_speed_[0] = 0.f;
camera_move_speed_[1] = 0.f;
}
break;
case tygra::kWindowGamepadAxisLeftThumbY:
if (pos < -deadzone) {
camera_move_speed_[3] = -pos;
camera_move_speed_[2] = 0.f;
}
else if (pos > deadzone) {
camera_move_speed_[3] = 0.f;
camera_move_speed_[2] = pos;
}
else {
camera_move_speed_[3] = 0.f;
camera_move_speed_[2] = 0.f;
}
break;
case tygra::kWindowGamepadAxisRightThumbX:
if (pos < -deadzone || pos > deadzone) {
camera_rotate_speed_[0] = -pos;
}
else {
camera_rotate_speed_[0] = 0.f;
}
scene_->getCamera().setRotationalVelocity(
sponza::Vector2(camera_rotate_speed_[0] * rotate_speed,
camera_rotate_speed_[1] * rotate_speed));
break;
case tygra::kWindowGamepadAxisRightThumbY:
if (pos < -deadzone || pos > deadzone) {
camera_rotate_speed_[1] = pos;
}
else {
camera_rotate_speed_[1] = 0.f;
}
scene_->getCamera().setRotationalVelocity(
sponza::Vector2(camera_rotate_speed_[0] * rotate_speed,
camera_rotate_speed_[1] * rotate_speed));
break;
}
updateCameraTranslation();
}
void MyController::windowControlGamepadButtonChanged(tygra::Window * window,
int gamepad_index,
int button_index,
bool down)
{
}
void MyController::updateCameraTranslation()
{
const float key_speed = 100.f;
const float sideward_speed = -key_speed * camera_move_speed_[0]
+ key_speed * camera_move_speed_[1];
const float forward_speed = key_speed * camera_move_speed_[2]
- key_speed * camera_move_speed_[3];
scene_->getCamera().setLinearVelocity(
sponza::Vector3(sideward_speed, 0, forward_speed));
}
| [
"trislancaster@gmail.com"
] | trislancaster@gmail.com |
b5ba6d5442015af7b2cd908a854e30d0f2ee5665 | f01f6eddf1e69927a1fdfc1a9e08024ed4d781e8 | /src/render/MBlur.cpp | 08298a1f21f8f6c388518e8f1010faf6d3e26f1d | [] | no_license | re3fork/re3-miami-vita | d24e496c7dbc1a2c6a09f8976ac319a938f4a777 | 5de9de0d8072c3644f6cb961160b0fd7bfb067fb | refs/heads/main | 2023-01-01T00:02:14.101193 | 2020-10-23T10:58:55 | 2020-10-23T10:58:55 | 307,209,977 | 1 | 0 | null | 2020-10-25T23:00:11 | 2020-10-25T23:00:11 | null | UTF-8 | C++ | false | false | 14,204 | cpp | #define WITHWINDOWS
#ifndef LIBRW
#define WITHD3D
#endif
#include "common.h"
#ifndef LIBRW
#include <d3d8caps.h>
#endif
#include "RwHelper.h"
#include "Camera.h"
#include "MBlur.h"
#include "Timer.h"
#include "postfx.h"
// Originally taken from RW example 'mblur'
RwRaster *CMBlur::pFrontBuffer;
bool CMBlur::ms_bJustInitialised;
bool CMBlur::ms_bScaledBlur;
bool CMBlur::BlurOn;
float CMBlur::Drunkness;
static RwIm2DVertex Vertex[4];
static RwIm2DVertex Vertex2[4];
static RwImVertexIndex Index[6] = { 0, 1, 2, 0, 2, 3 };
#ifndef LIBRW
extern "C" D3DCAPS8 _RwD3D8DeviceCaps;
#endif
RwBool
CMBlur::MotionBlurOpen(RwCamera *cam)
{
#ifdef EXTENDED_COLOURFILTER
CPostFX::Open(cam);
return TRUE;
#else
#ifdef GTA_PS2
RwRect rect = {0, 0, 0, 0};
if (pFrontBuffer)
return TRUE;
BlurOn = true;
rect.w = RwRasterGetWidth(RwCameraGetRaster(cam));
rect.h = RwRasterGetHeight(RwCameraGetRaster(cam));
pFrontBuffer = RwRasterCreate(0, 0, 0, rwRASTERDONTALLOCATE|rwRASTERTYPECAMERATEXTURE);
if (!pFrontBuffer)
{
printf("Error creating raster\n");
return FALSE;
}
RwRaster *raster = RwRasterSubRaster(pFrontBuffer, RwCameraGetRaster(cam), &rect);
if (!raster)
{
RwRasterDestroy(pFrontBuffer);
pFrontBuffer = NULL;
printf("Error subrastering\n");
return FALSE;
}
CreateImmediateModeData(cam, &rect);
#else
RwRect rect = { 0, 0, 0, 0 };
if(pFrontBuffer)
MotionBlurClose();
#ifndef LIBRW
extern void _GetVideoMemInfo(LPDWORD total, LPDWORD avaible);
DWORD total, avaible;
_GetVideoMemInfo(&total, &avaible);
debug("Available video memory %d\n", avaible);
#endif
if(BlurOn)
{
uint32 width = Pow(2.0f, int32(log2(RwRasterGetWidth (RwCameraGetRaster(cam))))+1);
uint32 height = Pow(2.0f, int32(log2(RwRasterGetHeight(RwCameraGetRaster(cam))))+1);
uint32 depth = RwRasterGetDepth(RwCameraGetRaster(cam));
#ifndef LIBRW
extern DWORD _dwMemTotalVideo;
if ( _RwD3D8DeviceCaps.MaxTextureWidth >= width && _RwD3D8DeviceCaps.MaxTextureHeight >= height )
{
total = _dwMemTotalVideo - 3 *
( RwRasterGetDepth(RwCameraGetRaster(cam))
* RwRasterGetHeight(RwCameraGetRaster(cam))
* RwRasterGetWidth(RwCameraGetRaster(cam)) / 8 );
BlurOn = total >= height*width*(depth/8) + (12*1024*1024) /*12 MB*/;
}
else
BlurOn = false;
#endif
if ( BlurOn )
{
ms_bScaledBlur = false;
rect.w = width;
rect.h = height;
pFrontBuffer = RwRasterCreate(rect.w, rect.h, depth, rwRASTERTYPECAMERATEXTURE);
if ( !pFrontBuffer )
{
debug("MBlurOpen can't create raster.");
BlurOn = false;
rect.w = RwRasterGetWidth(RwCameraGetRaster(cam));
rect.h = RwRasterGetHeight(RwCameraGetRaster(cam));
}
else
ms_bJustInitialised = true;
}
else
{
rect.w = RwRasterGetWidth(RwCameraGetRaster(cam));
rect.h = RwRasterGetHeight(RwCameraGetRaster(cam));
}
#ifndef LIBRW
_GetVideoMemInfo(&total, &avaible);
debug("Available video memory %d\n", avaible);
#endif
CreateImmediateModeData(cam, &rect);
}
else
{
rect.w = RwRasterGetWidth(RwCameraGetRaster(cam));
rect.h = RwRasterGetHeight(RwCameraGetRaster(cam));
CreateImmediateModeData(cam, &rect);
}
return TRUE;
#endif
#endif
}
RwBool
CMBlur::MotionBlurClose(void)
{
#ifdef EXTENDED_COLOURFILTER
CPostFX::Close();
#else
if(pFrontBuffer){
RwRasterDestroy(pFrontBuffer);
pFrontBuffer = nil;
return TRUE;
}
#endif
return FALSE;
}
void
CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect)
{
float zero, xmax, ymax;
if(RwRasterGetDepth(RwCameraGetRaster(cam)) == 16){
zero = HALFPX;
xmax = rect->w + HALFPX;
ymax = rect->h + HALFPX;
}else{
zero = -HALFPX;
xmax = rect->w - HALFPX;
ymax = rect->h - HALFPX;
}
RwIm2DVertexSetScreenX(&Vertex[0], zero);
RwIm2DVertexSetScreenY(&Vertex[0], zero);
RwIm2DVertexSetScreenZ(&Vertex[0], RwIm2DGetNearScreenZ());
RwIm2DVertexSetCameraZ(&Vertex[0], RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetRecipCameraZ(&Vertex[0], 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetU(&Vertex[0], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetV(&Vertex[0], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetIntRGBA(&Vertex[0], 255, 255, 255, 255);
RwIm2DVertexSetScreenX(&Vertex[1], zero);
RwIm2DVertexSetScreenY(&Vertex[1], ymax);
RwIm2DVertexSetScreenZ(&Vertex[1], RwIm2DGetNearScreenZ());
RwIm2DVertexSetCameraZ(&Vertex[1], RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetRecipCameraZ(&Vertex[1], 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetU(&Vertex[1], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetV(&Vertex[1], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetIntRGBA(&Vertex[1], 255, 255, 255, 255);
RwIm2DVertexSetScreenX(&Vertex[2], xmax);
RwIm2DVertexSetScreenY(&Vertex[2], ymax);
RwIm2DVertexSetScreenZ(&Vertex[2], RwIm2DGetNearScreenZ());
RwIm2DVertexSetCameraZ(&Vertex[2], RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetRecipCameraZ(&Vertex[2], 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetU(&Vertex[2], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetV(&Vertex[2], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetIntRGBA(&Vertex[2], 255, 255, 255, 255);
RwIm2DVertexSetScreenX(&Vertex[3], xmax);
RwIm2DVertexSetScreenY(&Vertex[3], zero);
RwIm2DVertexSetScreenZ(&Vertex[3], RwIm2DGetNearScreenZ());
RwIm2DVertexSetCameraZ(&Vertex[3], RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetRecipCameraZ(&Vertex[3], 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetU(&Vertex[3], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetV(&Vertex[3], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetIntRGBA(&Vertex[3], 255, 255, 255, 255);
RwIm2DVertexSetScreenX(&Vertex2[0], zero + 2.0f);
RwIm2DVertexSetScreenY(&Vertex2[0], zero + 2.0f);
RwIm2DVertexSetScreenZ(&Vertex2[0], RwIm2DGetNearScreenZ());
RwIm2DVertexSetCameraZ(&Vertex2[0], RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetRecipCameraZ(&Vertex2[0], 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetU(&Vertex2[0], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetV(&Vertex2[0], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetIntRGBA(&Vertex2[0], 255, 255, 255, 255);
RwIm2DVertexSetScreenX(&Vertex2[1], 2.0f);
RwIm2DVertexSetScreenY(&Vertex2[1], ymax + 2.0f);
RwIm2DVertexSetScreenZ(&Vertex2[1], RwIm2DGetNearScreenZ());
RwIm2DVertexSetCameraZ(&Vertex2[1], RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetRecipCameraZ(&Vertex2[1], 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetU(&Vertex2[1], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetV(&Vertex2[1], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetIntRGBA(&Vertex2[1], 255, 255, 255, 255);
RwIm2DVertexSetScreenX(&Vertex2[2], xmax + 2.0f);
RwIm2DVertexSetScreenY(&Vertex2[2], ymax + 2.0f);
RwIm2DVertexSetScreenZ(&Vertex2[2], RwIm2DGetNearScreenZ());
RwIm2DVertexSetCameraZ(&Vertex2[2], RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetRecipCameraZ(&Vertex2[2], 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetU(&Vertex2[2], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetV(&Vertex2[2], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetIntRGBA(&Vertex2[2], 255, 255, 255, 255);
RwIm2DVertexSetScreenX(&Vertex2[3], xmax + 2.0f);
RwIm2DVertexSetScreenY(&Vertex2[3], zero + 2.0f);
RwIm2DVertexSetScreenZ(&Vertex2[3], RwIm2DGetNearScreenZ());
RwIm2DVertexSetCameraZ(&Vertex2[3], RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetRecipCameraZ(&Vertex2[3], 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetU(&Vertex2[3], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetV(&Vertex2[3], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam));
RwIm2DVertexSetIntRGBA(&Vertex2[3], 255, 255, 255, 255);
}
void
CMBlur::MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha)
{
#ifdef EXTENDED_COLOURFILTER
CPostFX::Render(cam, red, green, blue, blur, type, bluralpha);
#else
RwRGBA color = { (RwUInt8)red, (RwUInt8)green, (RwUInt8)blue, (RwUInt8)blur };
#ifdef GTA_PS2
if( pFrontBuffer )
OverlayRender(cam, pFrontBuffer, color, type, bluralpha);
#else
if(ms_bJustInitialised)
ms_bJustInitialised = false;
else
OverlayRender(cam, pFrontBuffer, color, type, bluralpha);
if(BlurOn){
RwRasterPushContext(pFrontBuffer);
RwRasterRenderFast(RwCameraGetRaster(cam), 0, 0);
RwRasterPopContext();
}
#endif
#endif
}
static uint8 DrunkBlurRed = 128;
static uint8 DrunkBlurGreen = 128;
static uint8 DrunkBlurBlue = 128;
static int32 DrunkBlurIncrement = 1;
void
CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, int32 bluralpha)
{
int r, g, b, a;
r = color.red;
g = color.green;
b = color.blue;
a = color.alpha;
DefinedState();
switch(type)
{
case MOTION_BLUR_SECURITY_CAM:
r = 0;
g = 255;
b = 0;
a = 128;
break;
case MOTION_BLUR_INTRO:
r = 100;
g = 220;
b = 230;
a = 158;
break;
case MOTION_BLUR_INTRO2:
r = 80;
g = 255;
b = 230;
a = 138;
break;
case MOTION_BLUR_INTRO3:
r = 255;
g = 60;
b = 60;
a = 200;
break;
case MOTION_BLUR_INTRO4:
r = 255;
g = 180;
b = 180;
a = 128;
break;
}
if(!BlurOn){
// gta clamps these to 255 (probably a macro or inlined function)
int ovR = r * 0.6f;
int ovG = g * 0.6f;
int ovB = b * 0.6f;
int ovA = type == MOTION_BLUR_SNIPER ? a : a*0.6f;
RwIm2DVertexSetIntRGBA(&Vertex[0], ovR, ovG, ovB, ovA);
RwIm2DVertexSetIntRGBA(&Vertex[1], ovR, ovG, ovB, ovA);
RwIm2DVertexSetIntRGBA(&Vertex[2], ovR, ovG, ovB, ovA);
RwIm2DVertexSetIntRGBA(&Vertex[3], ovR, ovG, ovB, ovA);
}else{
RwIm2DVertexSetIntRGBA(&Vertex2[0], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[0], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex2[1], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[1], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex2[2], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[2], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex2[3], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[3], r, g, b, a);
}
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, raster);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
if(BlurOn){
if(type == MOTION_BLUR_SNIPER){
RwIm2DVertexSetIntRGBA(&Vertex2[0], r, g, b, 80);
RwIm2DVertexSetIntRGBA(&Vertex2[1], r, g, b, 80);
RwIm2DVertexSetIntRGBA(&Vertex2[2], r, g, b, 80);
RwIm2DVertexSetIntRGBA(&Vertex2[3], r, g, b, 80);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
// TODO(MIAMI): pBufVertCount = 0;
}else{
RwIm2DVertexSetIntRGBA(&Vertex2[0], r*2, g*2, b*2, 30);
RwIm2DVertexSetIntRGBA(&Vertex2[1], r*2, g*2, b*2, 30);
RwIm2DVertexSetIntRGBA(&Vertex2[2], r*2, g*2, b*2, 30);
RwIm2DVertexSetIntRGBA(&Vertex2[3], r*2, g*2, b*2, 30);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex2, 4, Index, 6);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
RwIm2DVertexSetIntRGBA(&Vertex2[0], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[0], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex2[1], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[1], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex2[2], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[2], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex2[3], r, g, b, a);
RwIm2DVertexSetIntRGBA(&Vertex[3], r, g, b, a);
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6);
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex2, 4, Index, 6);
}
}
int DrunkBlurAlpha = 175.0f * Drunkness;
if(DrunkBlurAlpha != 0){
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
if(BlurOn){
RwIm2DVertexSetIntRGBA(&Vertex[0], 255, 255, 255, DrunkBlurAlpha);
RwIm2DVertexSetIntRGBA(&Vertex[1], 255, 255, 255, DrunkBlurAlpha);
RwIm2DVertexSetIntRGBA(&Vertex[2], 255, 255, 255, DrunkBlurAlpha);
RwIm2DVertexSetIntRGBA(&Vertex[3], 255, 255, 255, DrunkBlurAlpha);
}else{
RwIm2DVertexSetIntRGBA(&Vertex[0], DrunkBlurRed, DrunkBlurGreen, DrunkBlurBlue, DrunkBlurAlpha);
RwIm2DVertexSetIntRGBA(&Vertex[1], DrunkBlurRed, DrunkBlurGreen, DrunkBlurBlue, DrunkBlurAlpha);
RwIm2DVertexSetIntRGBA(&Vertex[2], DrunkBlurRed, DrunkBlurGreen, DrunkBlurBlue, DrunkBlurAlpha);
RwIm2DVertexSetIntRGBA(&Vertex[3], DrunkBlurRed, DrunkBlurGreen, DrunkBlurBlue, DrunkBlurAlpha);
if(DrunkBlurIncrement){
if(DrunkBlurRed < 255) DrunkBlurRed++;
if(DrunkBlurGreen < 255) DrunkBlurGreen++;
if(DrunkBlurBlue < 255) DrunkBlurBlue++;
if(DrunkBlurRed == 255)
DrunkBlurIncrement = 0;
}else{
if(DrunkBlurRed > 128) DrunkBlurRed--;
if(DrunkBlurGreen > 128) DrunkBlurGreen--;
if(DrunkBlurBlue > 128) DrunkBlurBlue--;
if(DrunkBlurRed == 128)
DrunkBlurIncrement = 1;
}
}
RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6);
}
// TODO(MIAMI): OverlayRenderFx
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
}
void
CMBlur::SetDrunkBlur(float drunkness)
{
Drunkness = clamp(drunkness, 0.0f, 1.0f);
}
void
CMBlur::ClearDrunkBlur()
{
Drunkness = 0.0f;
CTimer::SetTimeScale(1.0f);
} | [
"rinnegatamante@gmail.com"
] | rinnegatamante@gmail.com |
f49a53c2b0aae9d640e0b3d73547a00a9563dc5f | 3ff1fe3888e34cd3576d91319bf0f08ca955940f | /tcss/include/tencentcloud/tcss/v20201101/model/ModifyVirusAutoIsolateSettingResponse.h | 20e7d19364d9d4e97a0363e74f21c22dc8dfc768 | [
"Apache-2.0"
] | permissive | TencentCloud/tencentcloud-sdk-cpp | 9f5df8220eaaf72f7eaee07b2ede94f89313651f | 42a76b812b81d1b52ec6a217fafc8faa135e06ca | refs/heads/master | 2023-08-30T03:22:45.269556 | 2023-08-30T00:45:39 | 2023-08-30T00:45:39 | 188,991,963 | 55 | 37 | Apache-2.0 | 2023-08-17T03:13:20 | 2019-05-28T08:56:08 | C++ | UTF-8 | C++ | false | false | 1,711 | h | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TENCENTCLOUD_TCSS_V20201101_MODEL_MODIFYVIRUSAUTOISOLATESETTINGRESPONSE_H_
#define TENCENTCLOUD_TCSS_V20201101_MODEL_MODIFYVIRUSAUTOISOLATESETTINGRESPONSE_H_
#include <string>
#include <vector>
#include <map>
#include <tencentcloud/core/AbstractModel.h>
namespace TencentCloud
{
namespace Tcss
{
namespace V20201101
{
namespace Model
{
/**
* ModifyVirusAutoIsolateSetting返回参数结构体
*/
class ModifyVirusAutoIsolateSettingResponse : public AbstractModel
{
public:
ModifyVirusAutoIsolateSettingResponse();
~ModifyVirusAutoIsolateSettingResponse() = default;
CoreInternalOutcome Deserialize(const std::string &payload);
std::string ToJsonString() const;
private:
};
}
}
}
}
#endif // !TENCENTCLOUD_TCSS_V20201101_MODEL_MODIFYVIRUSAUTOISOLATESETTINGRESPONSE_H_
| [
"tencentcloudapi@tencent.com"
] | tencentcloudapi@tencent.com |
ec2eecc7a01096f43e8ec387b4413bc7a5f10600 | 913e028d430c6bd47f5fd9db10615f52a18fe045 | /mainwindow.h | da11c8c16376c72f8f365fb7bd7511b148a1d4df | [] | no_license | satchelwu/vision | 5b223dc0ce2cd36444cd03c4e8e315c4a50a092b | 8fff9c8487a2a7dd79df05cdd477e5e56d3448ec | refs/heads/master | 2021-01-11T16:00:06.911716 | 2016-01-24T10:03:19 | 2016-01-24T10:03:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,712 | h | #ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <opencv2/highgui/highgui.hpp>
#include <core/core.hpp>
#include <imgproc/imgproc.hpp>
#include <QList>
#include <QListWidgetItem>
#include <QPixmap>
#include <QMutex>
#include <QTime>
//#include "cameraworker.h"
//#include "calibratorworker.h"
#include "beliefstate.h"
namespace Ui {
class MainWindow;
}
class CameraWorker;
class CalibratorWorker;
class AlgoWorker;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
QTimer *timer;
public slots:
void onCamImageReady(QPixmap *pm);
void onYUVImageReady(QPixmap *pm);
void onBeliefStateReady(BeliefState *bs);
void onTimeout();
void onMouseOnlyMove(int x, int y);
signals:
void colorChanged(int row);
void reset();
void clearMarks();
void stopCamThread();
void stopCalibThread();
void radioToggle(bool cam);
void thesholdCheckChanged(bool val);
void blobCheckChanged(bool val);
private slots:
void on_listWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
void on_camRadio_toggled(bool checked);
void on_reset_clicked();
void on_clearMarks_clicked();
void on_thresh_checkbox_stateChanged(int arg1);
void on_blobs_checkbox_stateChanged(int arg1);
void on_startButton_clicked();
void on_stopButton_clicked();
private:
Ui::MainWindow *ui;
QMutex *camMutex;
QMutex *calibMutex;
QMutex *lutMutex;
QThread *cameraThread, *calibThread, *algoThread;
CameraWorker *cw;
CalibratorWorker *calibw;
AlgoWorker *aw;
QTime *fpsTimer;
};
#endif // MAINWINDOW_H
| [
"arpit.tarang@gmail.com"
] | arpit.tarang@gmail.com |
c47409e61332bb6e4bff35e70b607df2521204c1 | abff3f461cd7d740cfc1e675b23616ee638e3f1e | /opencascade/StepFEA_FeaShellMembraneStiffness.hxx | b66a4da1eafeee9f13a0ef91cc96a5b15ada2f05 | [
"Apache-2.0"
] | permissive | CadQuery/pywrap | 4f93a4191d3f033f67e1fc209038fc7f89d53a15 | f3bcde70fd66a2d884fa60a7a9d9f6aa7c3b6e16 | refs/heads/master | 2023-04-27T04:49:58.222609 | 2023-02-10T07:56:06 | 2023-02-10T07:56:06 | 146,502,084 | 22 | 25 | Apache-2.0 | 2023-05-01T12:14:52 | 2018-08-28T20:18:59 | C++ | UTF-8 | C++ | false | false | 2,104 | hxx | // Created on: 2002-12-12
// Created by: data exchange team
// Copyright (c) 2002-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StepFEA_FeaShellMembraneStiffness_HeaderFile
#define _StepFEA_FeaShellMembraneStiffness_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <StepFEA_SymmetricTensor42d.hxx>
#include <StepFEA_FeaMaterialPropertyRepresentationItem.hxx>
class TCollection_HAsciiString;
class StepFEA_SymmetricTensor42d;
class StepFEA_FeaShellMembraneStiffness;
DEFINE_STANDARD_HANDLE(StepFEA_FeaShellMembraneStiffness, StepFEA_FeaMaterialPropertyRepresentationItem)
//! Representation of STEP entity FeaShellMembraneStiffness
class StepFEA_FeaShellMembraneStiffness : public StepFEA_FeaMaterialPropertyRepresentationItem
{
public:
//! Empty constructor
Standard_EXPORT StepFEA_FeaShellMembraneStiffness();
//! Initialize all fields (own and inherited)
Standard_EXPORT void Init (const Handle(TCollection_HAsciiString)& aRepresentationItem_Name, const StepFEA_SymmetricTensor42d& aFeaConstants);
//! Returns field FeaConstants
Standard_EXPORT StepFEA_SymmetricTensor42d FeaConstants() const;
//! Set field FeaConstants
Standard_EXPORT void SetFeaConstants (const StepFEA_SymmetricTensor42d& FeaConstants);
DEFINE_STANDARD_RTTIEXT(StepFEA_FeaShellMembraneStiffness,StepFEA_FeaMaterialPropertyRepresentationItem)
protected:
private:
StepFEA_SymmetricTensor42d theFeaConstants;
};
#endif // _StepFEA_FeaShellMembraneStiffness_HeaderFile
| [
"adam.jan.urbanczyk@gmail.com"
] | adam.jan.urbanczyk@gmail.com |
d4aea44d2e75804f7ce77c94584a0ce19027a561 | 148125096da896fd93292d2cd408265d159fec28 | /src/zmq/zmqpublishnotifier.cpp | 081289b4c7a584222205c1e9fcbec6930881460c | [
"MIT"
] | permissive | lycion/lkcoinse | 7cfbcbdfc1e98f20d9dfc497ea65fd75ca6de25d | 9cf9ed5730217566b44466c22dc255f0134ad1bb | refs/heads/master | 2020-03-30T03:24:44.245148 | 2018-09-28T04:55:30 | 2018-09-28T04:55:30 | 150,548,883 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,968 | cpp | // Copyright (c) 2015 The Lkcoinse Core developers
// Copyright (c) 2015-2018 The Lkcoinse Unlimited developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "zmqpublishnotifier.h"
#include "blockstorage/blockstorage.h"
#include "chainparams.h"
#include "main.h"
#include "util.h"
static std::multimap<std::string, CZMQAbstractPublishNotifier *> mapPublishNotifiers;
// Internal function to send multipart message
static int zmq_send_multipart(void *sock, const void *data, size_t size, ...)
{
va_list args;
va_start(args, size);
while (1)
{
zmq_msg_t msg;
int rc = zmq_msg_init_size(&msg, size);
if (rc != 0)
{
zmqError("Unable to initialize ZMQ msg");
va_end(args);
return -1;
}
void *buf = zmq_msg_data(&msg);
memcpy(buf, data, size);
data = va_arg(args, const void *);
rc = zmq_msg_send(&msg, sock, data ? ZMQ_SNDMORE : 0);
if (rc == -1)
{
zmqError("Unable to send ZMQ msg");
zmq_msg_close(&msg);
va_end(args);
return -1;
}
zmq_msg_close(&msg);
if (!data)
break;
size = va_arg(args, size_t);
}
va_end(args);
return 0;
}
bool CZMQAbstractPublishNotifier::Initialize(void *pcontext)
{
assert(!psocket);
// check if address is being used by other publish notifier
std::multimap<std::string, CZMQAbstractPublishNotifier *>::iterator i = mapPublishNotifiers.find(address);
if (i == mapPublishNotifiers.end())
{
psocket = zmq_socket(pcontext, ZMQ_PUB);
if (!psocket)
{
zmqError("Failed to create socket");
return false;
}
int rc = zmq_bind(psocket, address.c_str());
if (rc != 0)
{
zmqError("Failed to bind address");
return false;
}
// register this notifier for the address, so it can be reused for other publish notifier
mapPublishNotifiers.insert(std::make_pair(address, this));
return true;
}
else
{
LOG(ZMQ, "zmq: Reusing socket for address %s\n", address);
psocket = i->second->psocket;
mapPublishNotifiers.insert(std::make_pair(address, this));
return true;
}
}
void CZMQAbstractPublishNotifier::Shutdown()
{
assert(psocket);
int count = mapPublishNotifiers.count(address);
// remove this notifier from the list of publishers using this address
typedef std::multimap<std::string, CZMQAbstractPublishNotifier *>::iterator iterator;
std::pair<iterator, iterator> iterpair = mapPublishNotifiers.equal_range(address);
for (iterator it = iterpair.first; it != iterpair.second; ++it)
{
if (it->second == this)
{
mapPublishNotifiers.erase(it);
break;
}
}
if (count == 1)
{
LOG(ZMQ, "Close socket at address %s\n", address);
int linger = 0;
zmq_setsockopt(psocket, ZMQ_LINGER, &linger, sizeof(linger));
zmq_close(psocket);
}
psocket = 0;
}
bool CZMQPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex)
{
uint256 hash = pindex->GetBlockHash();
LOG(ZMQ, "zmq: Publish hashblock %s\n", hash.GetHex());
char data[32];
for (unsigned int i = 0; i < 32; i++)
data[31 - i] = hash.begin()[i];
int rc = zmq_send_multipart(psocket, "hashblock", 9, data, 32, 0);
return rc == 0;
}
bool CZMQPublishHashTransactionNotifier::NotifyTransaction(const CTransactionRef &ptx)
{
uint256 hash = ptx->GetHash();
LOG(ZMQ, "zmq: Publish hashtx %s\n", hash.GetHex());
char data[32];
for (unsigned int i = 0; i < 32; i++)
data[31 - i] = hash.begin()[i];
int rc = zmq_send_multipart(psocket, "hashtx", 6, data, 32, 0);
return rc == 0;
}
bool CZMQPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex)
{
LOG(ZMQ, "zmq: Publish rawblock %s\n", pindex->GetBlockHash().GetHex());
const Consensus::Params &consensusParams = Params().GetConsensus();
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
{
LOCK(cs_main);
CBlock block;
if (!ReadBlockFromDisk(block, pindex, consensusParams))
{
zmqError("Can't read block from disk");
return false;
}
ss << block;
}
int rc = zmq_send_multipart(psocket, "rawblock", 8, &(*ss.begin()), ss.size(), 0);
return rc == 0;
}
bool CZMQPublishRawTransactionNotifier::NotifyTransaction(const CTransactionRef &ptx)
{
uint256 hash = ptx->GetHash();
LOG(ZMQ, "zmq: Publish rawtx %s\n", hash.GetHex());
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << *ptx;
int rc = zmq_send_multipart(psocket, "rawtx", 5, &(*ss.begin()), ss.size(), 0);
return rc == 0;
}
| [
"lycion@gmail.com"
] | lycion@gmail.com |
96b8345d6d012d5a8655f85b9f1536c94ef84bde | db63089c4f1b55dde3fd1685bcfea978168257b6 | /src/cuBERT/op/Softmax.cpp | 3c6a4082c7eec03496f854aa12c0448fb0df99a4 | [
"MIT"
] | permissive | loretoparisi/cuBERT | 49d233125f0709556212bfcbf8c0fbb2847af78b | 8ab038415bda11c1cd715db2bc618a430d6093c1 | refs/heads/master | 2020-05-03T02:47:51.545302 | 2019-03-26T06:00:46 | 2019-03-26T06:00:46 | 178,380,180 | 1 | 0 | MIT | 2019-03-29T09:59:44 | 2019-03-29T09:59:44 | null | UTF-8 | C++ | false | false | 1,401 | cpp | #include <cmath>
#include <stdexcept>
#include "cuBERT/common.h"
#include "Softmax.h"
namespace cuBERT {
#ifdef HAVE_MKL
template<>
void softmax_<float>(float *inout,
const int batch_size,
const int channel,
float *sum_gpu,
void *stream) {
#pragma omp parallel for
for (int batch_idx = 0; batch_idx < batch_size; ++batch_idx) {
float sum = 0;
for (int i = batch_idx * channel; i < (batch_idx + 1) * channel; ++i) {
inout[i] = expf(inout[i]);
sum += inout[i];
}
for (int i = batch_idx * channel; i < (batch_idx + 1) * channel; ++i) {
inout[i] = inout[i] / sum;
}
}
}
#endif
template <typename T>
Softmax<T>::Softmax(size_t max_batch_size, size_t channel) {
this->channel = channel;
this->sum_gpu = static_cast<T *>(cuBERT::malloc(sizeof(T) * max_batch_size));
}
template <typename T>
Softmax<T>::~Softmax() {
cuBERT::free(sum_gpu);
}
template <typename T>
void Softmax<T>::compute_(size_t batch_size, T *inout_gpu, void* stream) {
softmax_<T>(inout_gpu, batch_size, channel, sum_gpu, stream);
}
template class Softmax<float>;
#ifdef HAVE_CUDA
template class Softmax<half>;
#endif
}
| [
"fanliwen@zhihu.com"
] | fanliwen@zhihu.com |
bb4169335c006f09401fe084cb4924f10afa6066 | 0eb84ec824fb34c18a87a4b50292d6cb41d15511 | /ComponentWebotsMobileRobot/smartsoft/src-gen/NavigationVelocityServiceInHandlerCore.cc | a317b5d8a49170c66b203718b8c86c09fa5ae27e | [] | no_license | SiChiTong/ComponentRepository | 1a75ef4b61e37be63b6c5ec217bfb39587eecb80 | 19b79ae0112c65dddabcc1209f64c813c68b90d6 | refs/heads/master | 2023-07-12T13:01:10.615767 | 2021-08-25T09:59:28 | 2021-08-25T09:59:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,196 | cc | //--------------------------------------------------------------------------
// Code generated by the SmartSoft MDSD Toolchain
// The SmartSoft Toolchain has been developed by:
//
// Service Robotics Research Center
// University of Applied Sciences Ulm
// Prittwitzstr. 10
// 89075 Ulm (Germany)
//
// Information about the SmartSoft MDSD Toolchain is available at:
// www.servicerobotik-ulm.de
//
// Please do not modify this file. It will be re-generated
// running the code generator.
//--------------------------------------------------------------------------
#include "NavigationVelocityServiceInHandlerCore.hh"
#include "NavigationVelocityServiceInHandler.hh"
NavigationVelocityServiceInHandlerCore::NavigationVelocityServiceInHandlerCore(
Smart::InputSubject<CommBasicObjects::CommNavigationVelocity> *subject,
const int &prescaleFactor)
: Smart::InputTaskTrigger<CommBasicObjects::CommNavigationVelocity>(subject, prescaleFactor)
{
}
NavigationVelocityServiceInHandlerCore::~NavigationVelocityServiceInHandlerCore()
{
}
void NavigationVelocityServiceInHandlerCore::updateAllCommObjects() {
}
void NavigationVelocityServiceInHandlerCore::notify_all_interaction_observers() {
std::unique_lock<std::mutex> lock(interaction_observers_mutex);
// try dynamically down-casting this class to the derived class
// (we can do it safely here as we exactly know the derived class)
if(const NavigationVelocityServiceInHandler* navigationVelocityServiceInHandler = dynamic_cast<const NavigationVelocityServiceInHandler*>(this)) {
for(auto it=interaction_observers.begin(); it!=interaction_observers.end(); it++) {
(*it)->on_update_from(navigationVelocityServiceInHandler);
}
}
}
void NavigationVelocityServiceInHandlerCore::attach_interaction_observer(NavigationVelocityServiceInHandlerObserverInterface *observer) {
std::unique_lock<std::mutex> lock(interaction_observers_mutex);
interaction_observers.push_back(observer);
}
void NavigationVelocityServiceInHandlerCore::detach_interaction_observer(NavigationVelocityServiceInHandlerObserverInterface *observer) {
std::unique_lock<std::mutex> lock(interaction_observers_mutex);
interaction_observers.remove(observer);
}
| [
"matthias@mlutz.de"
] | matthias@mlutz.de |
14e1673291305435e76b1f9a509b52f9b29ef646 | affa981ccb9aa100aa2c031e82f87be0d8d81e44 | /JSParser/ArrayExpr.h | 45168057bd1c99a766e27bf5664a81f2ec250e62 | [] | no_license | huww98/JSParser | 7c17fd7e7f2fc963930217bcf5386293617fd24e | e3135f8b1cbc307db19cc73782557bee024caf56 | refs/heads/master | 2020-03-26T21:42:22.222993 | 2018-08-20T11:08:25 | 2018-08-20T11:08:25 | 145,404,544 | 0 | 0 | null | 2018-08-20T10:46:04 | 2018-08-20T10:46:04 | null | UTF-8 | C++ | false | false | 510 | h | #pragma once
#include<vector>
#include"Expr.h"
using namespace std;
class ArrayExpr :public Expr {
vector<Expr*> elements;
public:
ArrayExpr(NodeType t=ArrayExpr_t):Node(t){}
void append(Expr* e) {
elements.push_back(e);
}
void display(int layer = 1) {
cout << setw(layer * 2) << " " << "[ArrayExpression]:" << endl;
cout << setw(layer * 2 + 2) << " " << "elements[" << elements.size() << "]:" << endl;
for (int i = 0; i < elements.size(); i++) {
elements[i]->display(layer + 2);
}
}
}; | [
"728882175@qq.com"
] | 728882175@qq.com |
393f911f694daa849e5f75d98dcb0863307bd8dd | 1af0d6fb1671efca55b1619bf1deb9177fb9248d | /catkin_ws/src/planner/src/kinematics.cpp | ca6e1b2869267865a53b1c27cdd4c9f4bebbcea1 | [
"MIT"
] | permissive | akshay-iyer/BaxterObjectSorting | a1bc17157a40caff8a662fc399b697f7c2c4c1d6 | 4f4687c8e36b2cee030ed68d4bb9b10e30531576 | refs/heads/master | 2020-04-25T08:22:00.197063 | 2019-02-24T04:10:04 | 2019-02-24T04:10:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,846 | cpp | #include <kinematics.hpp>
namespace Baxter
{
Kinematics::Kinematics(const std::vector<double> &angles)
{
createTransforms(angles);
}
Kinematics::~Kinematics(){}
void Kinematics::createTransforms(const std::vector<double> &angles)
{
createT01(angles[0]);
createT12(angles[1]);
createT23(angles[2]);
createT34(angles[3]);
createT45(angles[4]);
createT56(angles[5]);
createT67(angles[6]);
}
std::vector<geometry_msgs::Point> Kinematics::getCartesianPositions(const std::vector<double> &angles)
{
updateTransforms(angles);
const std::vector<Eigen::Matrix4d> &tfs = getJointTransforms();
std::vector<geometry_msgs::Point> pts;
for(const auto &tf : tfs)
{
pts.push_back(extractPointFromTf(tf));
}
return pts;
}
void Kinematics::updateTransforms(const std::vector<double> &angles)
{
updateT01(angles[0]);
updateT12(angles[1]);
updateT23(angles[2]);
updateT34(angles[3]);
updateT45(angles[4]);
updateT56(angles[5]);
updateT67(angles[6]);
}
const std::vector<Eigen::Matrix4d> Kinematics::getJointTransforms() const
{
std::vector<Eigen::Matrix4d> tfs;
const Eigen::Matrix4d &t02 = t01 * t12;
const Eigen::Matrix4d &t03 = t02 * t23;
const Eigen::Matrix4d &t04 = t03 * t34;
const Eigen::Matrix4d &t05 = t04 * t45;
const Eigen::Matrix4d &t06 = t05 * t56;
const Eigen::Matrix4d &t07 = t06 * t67;
tfs.push_back(t01);
tfs.push_back(t02);
tfs.push_back(t03);
tfs.push_back(t04);
tfs.push_back(t05);
tfs.push_back(t06);
tfs.push_back(t07);
return tfs;
}
const geometry_msgs::Point Kinematics::extractPointFromTf(const Eigen::Matrix4d &tf) const
{
geometry_msgs::Point pt;
pt.x = tf(0, 3);
pt.y = tf(1, 3);
pt.z = tf(2, 3);
return pt;
}
void Kinematics::createT01(const double &angle)
{
t01(0, 0) = cos(angle);
t01(0, 1) = -sin(angle);
t01(0, 2) = 0;
t01(0, 3) = 0;
t01(1, 0) = sin(angle);
t01(1, 1) = cos(angle);
t01(1, 2) = 0;
t01(1, 3) = 0;
t01(2, 0) = 0;
t01(2, 1) = 0;
t01(2, 2) = 1;
t01(2, 3) = 0;
t01(3, 0) = 0;
t01(3, 1) = 0;
t01(3, 2) = 0;
t01(3, 3) = 1;
}
void Kinematics::createT12(const double &angle)
{
const double &angle_ = angle + M_PI / 2;
t12(0, 0) = -sin(angle_);
t12(0, 1) = -cos(angle_);
t12(0, 2) = 0;
t12(0, 3) = l1;
t12(1, 0) = 0;
t12(1, 1) = 0;
t12(1, 2) = 1;
t12(1, 3) = 0;
t12(2, 0) = -cos(angle_);
t12(2, 1) = sin(angle_);
t12(2, 2) = 0;
t12(2, 3) = 0;
t12(3, 0) = 0;
t12(3, 1) = 0;
t12(3, 2) = 0;
t12(3, 3) = 1;
}
void Kinematics::createT23(const double &angle)
{
t23(0, 0) = cos(angle);
t23(0, 1) = -sin(angle);
t23(0, 2) = 0;
t23(0, 3) = 0;
t23(1, 0) = 0;
t23(1, 1) = 0;
t23(1, 2) = -1;
t23(1, 3) = -l2;
t23(2, 0) = sin(angle);
t23(2, 1) = cos(angle);
t23(2, 2) = 0;
t23(2, 3) = 0;
t23(3, 0) = 0;
t23(3, 1) = 0;
t23(3, 2) = 0;
t23(3, 3) = 1;
}
void Kinematics::createT34(const double &angle)
{
t34(0, 0) = cos(angle);
t34(0, 1) = -sin(angle);
t34(0, 2) = 0;
t34(0, 3) = l3;
t34(1, 0) = 0;
t34(1, 1) = 0;
t34(1, 2) = 1;
t34(1, 3) = 0;
t34(2, 0) = -sin(angle);
t34(2, 1) = -cos(angle);
t34(2, 2) = 0;
t34(2, 3) = 0;
t34(3, 0) = 0;
t34(3, 1) = 0;
t34(3, 2) = 0;
t34(3, 3) = 1;
}
void Kinematics::createT45(const double &angle)
{
t45(0, 0) = cos(angle);
t45(0, 1) = -sin(angle);
t45(0, 2) = 0;
t45(0, 3) = 0;
t45(1, 0) = 0;
t45(1, 1) = 0;
t45(1, 2) = -1;
t45(1, 3) = -l4;
t45(2, 0) = sin(angle);
t45(2, 1) = cos(angle);
t45(2, 2) = 0;
t45(2, 3) = 0;
t45(3, 0) = 0;
t45(3, 1) = 0;
t45(3, 2) = 0;
t45(3, 3) = 1;
}
void Kinematics::createT56(const double &angle)
{
t56(0, 0) = cos(angle);
t56(0, 1) = -sin(angle);
t56(0, 2) = 0;
t56(0, 3) = l5;
t56(1, 0) = 0;
t56(1, 1) = 0;
t56(1, 2) = 1;
t56(1, 3) = 0;
t56(2, 0) = -sin(angle);
t56(2, 1) = -cos(angle);
t56(2, 2) = 0;
t56(2, 3) = 0;
t56(3, 0) = 0;
t56(3, 1) = 0;
t56(3, 2) = 0;
t56(3, 3) = 1;
}
void Kinematics::createT67(const double &angle)
{
t67(0, 0) = cos(angle);
t67(0, 1) = -sin(angle);
t67(0, 2) = 0;
t67(0, 3) = 0;
t67(1, 0) = 0;
t67(1, 1) = 0;
t67(1, 2) = -1;
t67(1, 3) = 0;
t67(2, 0) = sin(angle);
t67(2, 1) = cos(angle);
t67(2, 2) = 0;
t67(2, 3) = 0;
t67(3, 0) = 0;
t67(3, 1) = 0;
t67(3, 2) = 0;
t67(3, 3) = 1;
}
void Kinematics::updateT01(const double &angle)
{
t01(0, 0) = cos(angle);
t01(0, 1) = -sin(angle);
t01(1, 0) = sin(angle);
t01(1, 1) = cos(angle);
}
void Kinematics::updateT12(const double &angle)
{
const double &angle_ = angle + M_PI / 2;
t12(0, 0) = -sin(angle_);
t12(0, 1) = -cos(angle_);
t12(2, 0) = -cos(angle_);
t12(2, 1) = sin(angle_);
}
void Kinematics::updateT23(const double &angle)
{
t23(0, 0) = cos(angle);
t23(0, 1) = -sin(angle);
t23(2, 0) = sin(angle);
t23(2, 1) = cos(angle);
}
void Kinematics::updateT34(const double &angle)
{
t34(0, 0) = cos(angle);
t34(0, 1) = -sin(angle);
t34(2, 0) = -sin(angle);
t34(2, 1) = -cos(angle);
}
void Kinematics::updateT45(const double &angle)
{
t45(0, 0) = cos(angle);
t45(0, 1) = -sin(angle);
t45(2, 0) = sin(angle);
t45(2, 1) = cos(angle);
}
void Kinematics::updateT56(const double &angle)
{
t56(0, 0) = cos(angle);
t56(0, 1) = -sin(angle);
t56(2, 0) = -sin(angle);
t56(2, 1) = -cos(angle);
}
void Kinematics::updateT67(const double &angle)
{
t67(0, 0) = cos(angle);
t67(0, 1) = -sin(angle);
t67(2, 0) = sin(angle);
t67(2, 1) = cos(angle);
}
}
| [
"jrblankenhorn@wpi.edu"
] | jrblankenhorn@wpi.edu |
9283af8707de0303bc35161be87bb627d454e71c | ace28e29eaa4ff031fdf7aa4d29bb5d85b46eaa3 | /Visual Mercutio/zModel/PSS_ProcessGraphModelView.h | a1d0254d83a9d0ea7e2ac63f5bc60c19b9d8e4b7 | [
"MIT"
] | permissive | emtee40/Visual-Mercutio | 675ff3d130783247b97d4b0c8760f931fbba68b3 | f079730005b6ce93d5e184bb7c0893ccced3e3ab | refs/heads/master | 2023-07-16T20:30:29.954088 | 2021-08-16T19:19:57 | 2021-08-16T19:19:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,420 | h | /****************************************************************************
* ==> PSS_ProcessGraphModelView -------------------------------------------*
****************************************************************************
* Description : Provides a graphic process model view *
* Developer : Processsoft *
****************************************************************************/
#ifndef PSS_ProcessGraphModelViewH
#define PSS_ProcessGraphModelViewH
#if _MSC_VER > 1000
#pragma once
#endif
// change the definition of AFX_EXT... to make it import
#undef AFX_EXT_CLASS
#undef AFX_EXT_API
#undef AFX_EXT_DATA
#define AFX_EXT_CLASS AFX_CLASS_IMPORT
#define AFX_EXT_API AFX_API_IMPORT
#define AFX_EXT_DATA AFX_DATA_IMPORT
// stingray studio
#include <Foundation\MVC\MvcWrapper.h>
// processsoft
#include "zBaseLib\PSS_DropScrollView.h"
#include "zBaseLib\PSS_DocumentPageSetup.h"
#include "PSS_ProcessGraphModelViewport.h"
// class name mapping
#ifndef PSS_ProcessGraphModelMdl
#define PSS_ProcessGraphModelMdl ZDProcessGraphModelMdl
#endif
// forward class declarations
class PSS_ProcessGraphModelMdl;
class PSS_ProcessGraphModelController;
#ifdef _ZMODELEXPORT
// put the values back to make AFX_EXT_CLASS export again
#undef AFX_EXT_CLASS
#undef AFX_EXT_API
#undef AFX_EXT_DATA
#define AFX_EXT_CLASS AFX_CLASS_EXPORT
#define AFX_EXT_API AFX_API_EXPORT
#define AFX_EXT_DATA AFX_DATA_EXPORT
#endif
/**
* Wrapper class that derives from both a viewport and the ZIDropScrollView class. The resulting class can be used
* like a ZIDropScrollView, except all of the drawing will automatically be delegated to the viewport class
*@note See the MvcForm sample for a demonstration of this class
*@author Dominique Aigroz, Jean-Milost Reymond
*/
class PSS_MvcScrollView : public PSS_DropScrollView, public MvcWrapper_T<PSS_ProcessGraphModelViewport>
{
public:
PSS_MvcScrollView();
virtual ~PSS_MvcScrollView();
/**
* Creates the view
*@param pClassName - the class name
*@param pWindowName - the window name
*@param style - the view style
*@param rect - the rect surrounding the view
*@param pParentWnd - the parent window
*@param id - the view identifier
*@param pContext - the view context
*@return TRUE on success, otherwise FALSE
*/
virtual BOOL Create(LPCTSTR pClassName,
LPCTSTR pWindowName,
DWORD style,
const RECT& rect,
CWnd* pParentWnd,
UINT id,
CCreateContext* pContext = NULL);
/**
* Gets the viewport
*@return the viewport
*/
virtual PSS_ProcessGraphModelViewport* GetViewport();
/**
* Sets the view origin
*@param x - x position in device units
*@param y - y position in device units
*@return the previous origin
*/
virtual CPoint SetOrigin(int x, int y);
/**
* Sets the log origin
*@param x - x position in device units
*@param y - y position in device units
*@return the previous log origin
*/
virtual CPoint SetLogOrigin(int x, int y);
/**
* Sets the view extents
*@param cx - extent width in device units
*@param cy - extent height in device units
*@return the previous extents
*/
virtual CSize SetExtents(int cx, int cy);
/**
* Sets the log extents
*@param cx - extent width in device units
*@param cy - extent height in device units
*@return the previous log extents
*/
virtual CSize SetLogExtents(int cx, int cy);
/**
* Sets the view size
*@param cx - view width in device units
*@param cy - view height in device units
*@return the previous size
*/
virtual CSize SetSize(int cx, int cy);
/**
* Sets the log size
*@param cx - log width in device units
*@param cy - log height in device units
*@return the previous log size
*/
virtual CSize SetLogSize(int cx, int cy);
/**
* Sets the log scaling
*@param scaleWidth - log scale width factor
*@param scaleHeight - log scale height factor
*@return the previous size extents
*/
virtual CSize SetLogScaling(float scaleWidth, float scaleHeight);
/**
* Sets the view virtual origin
*@param x - x position in device units
*@param y - y position in device units
*/
virtual void SetVirtualOrigin(int x, int y);
/**
* Sets the view virtual size
*@param cx - view virtual width in device units
*@param cy - view virtual height in device units
*/
virtual void SetVirtualSize(int cx, int cy);
/**
* Called when the view is initialized for the first time
*/
virtual void OnInitialUpdate();
/**
* Called when the device context is prepared for drawing
*@param pDC - the device context
*@param pInfo - the print info, ignored if NULL
*/
virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
/**
* Called when a scrolling is performed on the view
*@param scrollSize - the scroll size
*@param doScroll - if TRUE, the srolling should be performed
*@return TRUE if the view was scrolled, otherwise FALSE
*/
virtual BOOL OnScrollBy(CSize scrollSize, BOOL doScroll = TRUE);
/**
* Called when a Windows message is received in the view
*@param message - the received Windows message
*@param wParam - the message word parameter (16 bit value on old systems, now 32 bit long)
*@param lParam - the message long parameter (32 bit value)
*@param pResult - the message result
*@return TRUE if the message was handled and should no longer be processed, otherwise FALSE
*/
virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
/**
* Called when a command message is received in the view
*@param id - the message identifier
*@param code - the message code
*@param pExtra - the message extra info
*@param pHandlerInfo - the message handler info
*@return TRUE if the message was handled and should no longer be processed, otherwise FALSE
*/
virtual BOOL OnCmdMsg(UINT id, int code, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
protected:
CSize m_LineScroll;
BOOL m_UpdateScrollBars;
/**
* Scrolls the embedded viewport in response to WM_xSCROLL or WM_SIZE messages
*@param scrollPos - the scroll position in device units
*/
virtual void DoScrollViewport(const CPoint& scrollPos);
/**
* Updates the scrollbar position
*/
virtual void UpdateScrollBarPos();
/**
* Updates the scrollbar size
*/
virtual void UpdateScrollBarSize();
/**
* Called while the viewport is drawn
*@param pDC - the device context to draw on
*/
virtual void OnDraw(CDC* pDC);
};
/**
* Graphic process model view
*@author Dominique Aigroz, Jean-Milost Reymond
*/
class AFX_EXT_CLASS PSS_ProcessGraphModelView : public PSS_MvcScrollView
{
DECLARE_DYNCREATE(PSS_ProcessGraphModelView)
public:
virtual ~PSS_ProcessGraphModelView();
/**
* Gets the model controller
*@return the model controller
*/
virtual PSS_ProcessGraphModelController* GetModelController();
/**
* Gets the view model
*@return the view model
*/
virtual PSS_ProcessGraphModelMdl* GetModel();
/**
* Sets the view model
*@param pModel - the view model
*@param doSizeVp - if true, the viewport will also be sized
*/
virtual void SetModel(PSS_ProcessGraphModelMdl* pModel, bool doSizeVp = true);
/**
* Sizes the viewport to model
*/
virtual void SizeVpToModel();
/**
* Checks if the view supports the drop
*@return true if the view supports the drop, otherwise false
*/
virtual bool AcceptDrop() const;
/**
* Checks if a symbol may be dropped on this view
*@param pObj - the symbol object to drop
*@param point - the drop point
*@return true if the symbol may be dropped on this view, otherwise false
*/
virtual bool AcceptDropItem(CObject* pObj, const CPoint& point);
/**
* Drops a symbol on the view
*@param pObj - the symbol object to drop
*@param point - the drop point
*@return true on success, otherwise false
*/
virtual bool DropItem(CObject* pObj, const CPoint& point);
/**
* Gets the view name
*@return the view name
*/
virtual const CString GetViewName();
/**
* Selects the export model to image file
*@return true on success, otherwise false
*/
virtual bool SelectExportModelToImageFile();
/**
* Gets the tooltip
*@return the tooltip
*/
virtual inline CToolTipCtrl& GetToolTip();
/**
* Asserts the class validity
*/
#ifdef _DEBUG
virtual void AssertValid() const;
#endif
/**
* Dumps the class content
*@param dc - dump context
*/
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
MvcScrollWrapper_T<PSS_ProcessGraphModelViewport> m_PanVp;
CToolTipCtrl m_ToolTip;
CString m_StrToolTip;
CPoint m_VirtualOrigin;
CSize m_VirtualSize;
CSize m_MagOrigin;
double m_CurrentRatio;
bool m_PanInitialized;
PSS_ProcessGraphModelView();
/// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(PSS_ProcessGraphModelView)
virtual void OnDrawPan(CDC* pDC);
virtual void OnInitialUpdate();
virtual void OnDraw(CDC* pDC);
virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
/// Generated message map functions
//{{AFX_MSG(PSS_ProcessGraphModelView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC *pDC);
afx_msg void OnExportModelToImageFile();
afx_msg LRESULT OnRefreshSymbol(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnRefreshSymbolSet(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnBrowseSymbol(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnOpenModelPage(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnEnsureVisibleSymbol(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnModelDocumentHasChanged(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnAdviseStartPropertyEdition(WPARAM wParam, LPARAM lParam);
afx_msg BOOL OnToolTipNeedText(UINT id, NMHDR * pNMHDR, LRESULT * pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
/**
* Pre-translates the key message
*@param pMsg - the message
*@return TRUE if the message was handled, otherwise FALSE
*/
virtual BOOL PreTranslateMessage(MSG* pMsg);
/**
* Initializes the pan viewport
*/
virtual void InitializePanViewport();
/**
* Updates the overview rectangle
*/
virtual void UpdateOverviewRect();
/**
* Called before the overview is shown
*/
virtual void PreOverview();
/**
* Called after the overview is shown
*/
virtual void PostOverview();
/**
* Sets the view ratio
*/
virtual void SetRatio();
private:
PSS_ProcessGraphModelMdl* m_pViewModel;
};
//---------------------------------------------------------------------------
// PSS_ProcessGraphModelView
//---------------------------------------------------------------------------
CToolTipCtrl& PSS_ProcessGraphModelView::GetToolTip()
{
return m_ToolTip;
}
//---------------------------------------------------------------------------
#endif
| [
"jean_milost@hotmail.com"
] | jean_milost@hotmail.com |
c4dc8671d41470b6fb512149b6e07fd1a548da3c | a18ff9744addc6a64895c0e54dbeae5e05d5d5bf | /build-GestionLocationGUI-Desktop_Qt_6_1_0_MinGW_64_bit-Debug/ui_gestionlocation.h | a0054ade287aa252e0c71b02a78f73fff62e965c | [] | no_license | neopygit/GestionLocationProjet | b8baf927209a7a48cd8df89180e6d229355dcdf4 | f76556f7aac04c2d1d1c51ba568baa10fec975b1 | refs/heads/main | 2023-05-10T03:58:44.601491 | 2021-06-08T16:25:33 | 2021-06-08T16:25:33 | 374,447,390 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 192,922 | h | /********************************************************************************
** Form generated from reading UI file 'gestionlocation.ui'
**
** Created by: Qt User Interface Compiler version 6.1.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_GESTIONLOCATION_H
#define UI_GESTIONLOCATION_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QFrame>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QStackedWidget>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_GestionLocation
{
public:
QWidget *centralwidget;
QVBoxLayout *verticalLayout_25;
QStackedWidget *stackedWidget;
QWidget *mainmenu;
QVBoxLayout *verticalLayout_5;
QLabel *maintitle;
QFrame *frame1;
QVBoxLayout *verticalLayout_2;
QPushButton *rental;
QPushButton *managecar;
QPushButton *manageclient;
QPushButton *quit;
QWidget *rentcarmenu;
QVBoxLayout *verticalLayout_3;
QLabel *carrental;
QFrame *frame2;
QVBoxLayout *verticalLayout_7;
QPushButton *showcontract;
QPushButton *rentcar;
QPushButton *returncar;
QPushButton *modcontract;
QPushButton *delcontract;
QPushButton *return2;
QWidget *carmenu;
QVBoxLayout *verticalLayout_10;
QLabel *cartitle;
QFrame *frame3;
QVBoxLayout *verticalLayout_9;
QPushButton *listcar;
QPushButton *addcar;
QPushButton *modcar;
QPushButton *delcar;
QPushButton *return1;
QWidget *clientmenu;
QVBoxLayout *verticalLayout_4;
QLabel *client;
QFrame *frame4;
QVBoxLayout *verticalLayout;
QPushButton *listclient;
QPushButton *addclient;
QPushButton *modclient;
QPushButton *delclient;
QPushButton *return3;
QWidget *listcarmenu;
QVBoxLayout *verticalLayout_11;
QFrame *frame5;
QVBoxLayout *verticalLayout_6;
QLabel *carlist;
QPushButton *addcar2;
QPushButton *return4;
QPushButton *quit2;
QWidget *addcarmenu;
QVBoxLayout *verticalLayout_12;
QFrame *frame6;
QVBoxLayout *verticalLayout_13;
QFormLayout *formLayout;
QLabel *label;
QLineEdit *idvoit;
QLabel *label_2;
QLineEdit *marque;
QLabel *label_3;
QLineEdit *nomvoit;
QLabel *label_4;
QLineEdit *couleur;
QLabel *label_5;
QLineEdit *nbplace;
QLabel *label_6;
QLineEdit *prixjour;
QHBoxLayout *horizontalLayout_3;
QPushButton *savereturn;
QPushButton *return_3;
QWidget *modmenu;
QVBoxLayout *verticalLayout_8;
QLabel *label_13;
QFrame *frame7;
QVBoxLayout *verticalLayout_14;
QFormLayout *formLayout_3;
QLabel *label_14;
QLineEdit *idsearch;
QPushButton *recherche;
QLabel *result;
QFormLayout *formLayout_2;
QLabel *label_7;
QLineEdit *idvoit_2;
QLabel *label_8;
QLabel *label_9;
QLineEdit *nomvoit_2;
QLabel *label_10;
QLineEdit *couleur_2;
QLabel *label_11;
QLineEdit *nbplace_2;
QLabel *label_12;
QLineEdit *prixjour_2;
QLineEdit *marque_2;
QHBoxLayout *horizontalLayout_10;
QPushButton *savereturn_2;
QPushButton *return_6;
QWidget *listclient_2;
QVBoxLayout *verticalLayout_16;
QFrame *frame8;
QVBoxLayout *verticalLayout_20;
QLabel *clientlist;
QPushButton *addclient_2;
QPushButton *return4_2;
QPushButton *quit2_2;
QWidget *addclientmenu;
QVBoxLayout *verticalLayout_17;
QFrame *frame9;
QVBoxLayout *verticalLayout_15;
QFormLayout *formLayout_4;
QLabel *label_15;
QLineEdit *idclient;
QLabel *label_16;
QLineEdit *nom;
QLabel *label_17;
QLabel *label_18;
QLineEdit *cin;
QLabel *label_19;
QLineEdit *adresse;
QLabel *label_20;
QLineEdit *telephone;
QLineEdit *prenom;
QHBoxLayout *horizontalLayout_11;
QPushButton *savereturn_3;
QPushButton *return_7;
QWidget *modclientmenu;
QVBoxLayout *verticalLayout_19;
QFrame *frame10;
QVBoxLayout *verticalLayout_18;
QFormLayout *formLayout_5;
QLabel *label_21;
QLineEdit *idsearch_2;
QPushButton *recherche_2;
QLabel *result_2;
QFormLayout *formLayout_6;
QLabel *label_22;
QLineEdit *idclient_2;
QLabel *label_23;
QLineEdit *nom_2;
QLabel *label_24;
QLineEdit *prenom_2;
QLabel *label_25;
QLabel *label_26;
QLineEdit *adresse_2;
QLabel *label_27;
QLineEdit *telephone_2;
QLineEdit *cin_2;
QHBoxLayout *horizontalLayout_12;
QPushButton *savereturn_4;
QPushButton *return_8;
QWidget *deletecar;
QVBoxLayout *verticalLayout_21;
QFrame *frame11;
QVBoxLayout *verticalLayout_22;
QLabel *list;
QFormLayout *formLayout_7;
QLabel *label_29;
QLineEdit *idcar;
QPushButton *deletecar_2;
QLabel *delmsg;
QPushButton *return_5;
QWidget *deleteclient;
QVBoxLayout *verticalLayout_33;
QFrame *frame12;
QVBoxLayout *verticalLayout_32;
QLabel *list_3;
QFormLayout *formLayout_13;
QLabel *label_44;
QLineEdit *idclient_3;
QPushButton *deleteclient_2;
QLabel *delmsg_3;
QPushButton *return_4;
QWidget *idcheck;
QVBoxLayout *verticalLayout_34;
QFrame *frame13;
QVBoxLayout *verticalLayout_36;
QVBoxLayout *verticalLayout_35;
QLabel *label_51;
QLineEdit *id_client;
QLabel *label_52;
QLineEdit *id_car;
QPushButton *search;
QPushButton *return_10;
QLabel *searchresult;
QWidget *showcontrat;
QVBoxLayout *verticalLayout_24;
QFrame *frame14;
QVBoxLayout *verticalLayout_23;
QFormLayout *formLayout_8;
QLabel *label_28;
QLineEdit *numcontrat;
QLabel *label_33;
QLineEdit *id_car_2;
QLabel *label_30;
QLineEdit *id_client_2;
QHBoxLayout *horizontalLayout_2;
QLineEdit *debutjj;
QLineEdit *debutmm;
QLineEdit *debutaa;
QLabel *label_32;
QLabel *label_31;
QHBoxLayout *horizontalLayout;
QLineEdit *finjj;
QLineEdit *finmm;
QLineEdit *finaa;
QLineEdit *cout;
QLabel *label_34;
QPushButton *return_2;
QWidget *louervoiture;
QVBoxLayout *verticalLayout_27;
QFrame *frame15;
QVBoxLayout *verticalLayout_26;
QFormLayout *formLayout_10;
QLineEdit *clientsearch;
QLabel *label_35;
QPushButton *findclient;
QLabel *feedback;
QPushButton *addcar2_2;
QPushButton *return4_3;
QPushButton *quit2_3;
QWidget *renttime;
QVBoxLayout *verticalLayout_38;
QFrame *frame16;
QVBoxLayout *verticalLayout_37;
QLabel *label_50;
QHBoxLayout *horizontalLayout_6;
QLabel *label_46;
QLineEdit *carsearch;
QPushButton *validate;
QLabel *availablecars;
QLabel *label_45;
QFormLayout *formLayout_9;
QLabel *label_36;
QLabel *label_49;
QHBoxLayout *horizontalLayout_4;
QLineEdit *debutjj_2;
QLineEdit *debutmm_2;
QLineEdit *debutaa_2;
QLabel *label_47;
QHBoxLayout *horizontalLayout_5;
QLineEdit *finjj_2;
QLineEdit *finmm_2;
QLineEdit *finaa_2;
QLabel *label_48;
QLineEdit *cout_2;
QLineEdit *numcontrat_2;
QHBoxLayout *horizontalLayout_13;
QPushButton *saverent;
QPushButton *return_9;
QWidget *modcontractmenu;
QVBoxLayout *verticalLayout_29;
QFrame *frame17;
QVBoxLayout *verticalLayout_28;
QHBoxLayout *horizontalLayout_7;
QLabel *label_53;
QLineEdit *id_voit;
QPushButton *contratsearch;
QLabel *modcontratsearch;
QFormLayout *formLayout_11;
QLabel *label_38;
QLineEdit *idclient_4;
QLabel *label_39;
QLineEdit *idvoit_3;
QLabel *label_54;
QHBoxLayout *horizontalLayout_8;
QLineEdit *debutjj_3;
QLineEdit *debutmm_3;
QLineEdit *debutaa_3;
QLabel *label_55;
QHBoxLayout *horizontalLayout_9;
QLineEdit *finjj_3;
QLineEdit *finmm_3;
QLineEdit *finaa_3;
QLabel *label_56;
QLineEdit *cout_3;
QLineEdit *numcontrat_3;
QLabel *label_37;
QHBoxLayout *horizontalLayout_15;
QPushButton *save;
QPushButton *return_11;
QWidget *delcontractmenu;
QVBoxLayout *verticalLayout_31;
QFrame *frame18;
QVBoxLayout *verticalLayout_30;
QLabel *list_2;
QFormLayout *formLayout_12;
QLabel *label_43;
QLineEdit *idvoitcontrat;
QPushButton *delcontrat;
QLabel *delmsg_2;
QPushButton *return_12;
QWidget *page;
QVBoxLayout *verticalLayout_39;
QLabel *label_40;
QFrame *frame;
QVBoxLayout *verticalLayout_43;
QPushButton *pushButton_12;
QPushButton *pushButton_13;
void setupUi(QMainWindow *GestionLocation)
{
if (GestionLocation->objectName().isEmpty())
GestionLocation->setObjectName(QString::fromUtf8("GestionLocation"));
GestionLocation->resize(510, 433);
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(GestionLocation->sizePolicy().hasHeightForWidth());
GestionLocation->setSizePolicy(sizePolicy);
GestionLocation->setMinimumSize(QSize(400, 400));
GestionLocation->setStyleSheet(QString::fromUtf8("background-color:rgb(45, 41, 38);\n"
""));
centralwidget = new QWidget(GestionLocation);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
centralwidget->setStyleSheet(QString::fromUtf8(""));
verticalLayout_25 = new QVBoxLayout(centralwidget);
verticalLayout_25->setObjectName(QString::fromUtf8("verticalLayout_25"));
stackedWidget = new QStackedWidget(centralwidget);
stackedWidget->setObjectName(QString::fromUtf8("stackedWidget"));
sizePolicy.setHeightForWidth(stackedWidget->sizePolicy().hasHeightForWidth());
stackedWidget->setSizePolicy(sizePolicy);
stackedWidget->setMinimumSize(QSize(0, 20));
stackedWidget->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" background-color:rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QStackedWidget{\n"
" border-color:rgb(233, 75, 60);\n"
" border-width:2px;\n"
" border-radius:12px;\n"
" border-style:solid;\n"
" color:rgb(233, 75, 60);\n"
"}\n"
"QLineEdit:focus{\n"
" background-color:rgb(233, 75, 60);\n"
" color:rgb(45, 41, 38);\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}\n"
"QLabel{\n"
" color:rgb(233, 75, 60);\n"
" font: 9pt \"Segoe UI\";\n"
"}"));
mainmenu = new QWidget();
mainmenu->setObjectName(QString::fromUtf8("mainmenu"));
verticalLayout_5 = new QVBoxLayout(mainmenu);
verticalLayout_5->setObjectName(QString::fromUtf8("verticalLayout_5"));
maintitle = new QLabel(mainmenu);
maintitle->setObjectName(QString::fromUtf8("maintitle"));
QSizePolicy sizePolicy1(QSizePolicy::Fixed, QSizePolicy::Fixed);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(maintitle->sizePolicy().hasHeightForWidth());
maintitle->setSizePolicy(sizePolicy1);
maintitle->setMinimumSize(QSize(200, 38));
maintitle->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 13pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:13px;"));
maintitle->setAlignment(Qt::AlignCenter);
maintitle->setMargin(10);
verticalLayout_5->addWidget(maintitle, 0, Qt::AlignHCenter);
frame1 = new QFrame(mainmenu);
frame1->setObjectName(QString::fromUtf8("frame1"));
QSizePolicy sizePolicy2(QSizePolicy::Maximum, QSizePolicy::Maximum);
sizePolicy2.setHorizontalStretch(0);
sizePolicy2.setVerticalStretch(0);
sizePolicy2.setHeightForWidth(frame1->sizePolicy().hasHeightForWidth());
frame1->setSizePolicy(sizePolicy2);
frame1->setMinimumSize(QSize(200, 160));
frame1->setFrameShape(QFrame::NoFrame);
frame1->setFrameShadow(QFrame::Plain);
verticalLayout_2 = new QVBoxLayout(frame1);
verticalLayout_2->setSpacing(0);
verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
verticalLayout_2->setSizeConstraint(QLayout::SetFixedSize);
verticalLayout_2->setContentsMargins(1, 1, 1, 1);
rental = new QPushButton(frame1);
rental->setObjectName(QString::fromUtf8("rental"));
sizePolicy2.setHeightForWidth(rental->sizePolicy().hasHeightForWidth());
rental->setSizePolicy(sizePolicy2);
rental->setMinimumSize(QSize(200, 40));
rental->setCursor(QCursor(Qt::PointingHandCursor));
rental->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_2->addWidget(rental);
managecar = new QPushButton(frame1);
managecar->setObjectName(QString::fromUtf8("managecar"));
sizePolicy2.setHeightForWidth(managecar->sizePolicy().hasHeightForWidth());
managecar->setSizePolicy(sizePolicy2);
managecar->setMinimumSize(QSize(200, 40));
managecar->setCursor(QCursor(Qt::PointingHandCursor));
managecar->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_2->addWidget(managecar);
manageclient = new QPushButton(frame1);
manageclient->setObjectName(QString::fromUtf8("manageclient"));
sizePolicy2.setHeightForWidth(manageclient->sizePolicy().hasHeightForWidth());
manageclient->setSizePolicy(sizePolicy2);
manageclient->setMinimumSize(QSize(200, 40));
manageclient->setCursor(QCursor(Qt::PointingHandCursor));
manageclient->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_2->addWidget(manageclient);
quit = new QPushButton(frame1);
quit->setObjectName(QString::fromUtf8("quit"));
sizePolicy2.setHeightForWidth(quit->sizePolicy().hasHeightForWidth());
quit->setSizePolicy(sizePolicy2);
quit->setMinimumSize(QSize(200, 40));
quit->setCursor(QCursor(Qt::PointingHandCursor));
quit->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_2->addWidget(quit);
verticalLayout_5->addWidget(frame1, 0, Qt::AlignHCenter);
stackedWidget->addWidget(mainmenu);
rentcarmenu = new QWidget();
rentcarmenu->setObjectName(QString::fromUtf8("rentcarmenu"));
verticalLayout_3 = new QVBoxLayout(rentcarmenu);
verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
carrental = new QLabel(rentcarmenu);
carrental->setObjectName(QString::fromUtf8("carrental"));
QSizePolicy sizePolicy3(QSizePolicy::Preferred, QSizePolicy::Fixed);
sizePolicy3.setHorizontalStretch(0);
sizePolicy3.setVerticalStretch(0);
sizePolicy3.setHeightForWidth(carrental->sizePolicy().hasHeightForWidth());
carrental->setSizePolicy(sizePolicy3);
carrental->setMinimumSize(QSize(200, 50));
carrental->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 13pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:13px;"));
carrental->setAlignment(Qt::AlignCenter);
verticalLayout_3->addWidget(carrental, 0, Qt::AlignHCenter);
frame2 = new QFrame(rentcarmenu);
frame2->setObjectName(QString::fromUtf8("frame2"));
sizePolicy2.setHeightForWidth(frame2->sizePolicy().hasHeightForWidth());
frame2->setSizePolicy(sizePolicy2);
frame2->setMinimumSize(QSize(200, 240));
verticalLayout_7 = new QVBoxLayout(frame2);
verticalLayout_7->setSpacing(0);
verticalLayout_7->setObjectName(QString::fromUtf8("verticalLayout_7"));
verticalLayout_7->setContentsMargins(1, 1, 1, 1);
showcontract = new QPushButton(frame2);
showcontract->setObjectName(QString::fromUtf8("showcontract"));
sizePolicy2.setHeightForWidth(showcontract->sizePolicy().hasHeightForWidth());
showcontract->setSizePolicy(sizePolicy2);
showcontract->setMinimumSize(QSize(200, 40));
showcontract->setCursor(QCursor(Qt::PointingHandCursor));
showcontract->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_7->addWidget(showcontract);
rentcar = new QPushButton(frame2);
rentcar->setObjectName(QString::fromUtf8("rentcar"));
sizePolicy2.setHeightForWidth(rentcar->sizePolicy().hasHeightForWidth());
rentcar->setSizePolicy(sizePolicy2);
rentcar->setMinimumSize(QSize(200, 40));
rentcar->setCursor(QCursor(Qt::PointingHandCursor));
rentcar->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_7->addWidget(rentcar);
returncar = new QPushButton(frame2);
returncar->setObjectName(QString::fromUtf8("returncar"));
sizePolicy2.setHeightForWidth(returncar->sizePolicy().hasHeightForWidth());
returncar->setSizePolicy(sizePolicy2);
returncar->setMinimumSize(QSize(200, 40));
returncar->setCursor(QCursor(Qt::PointingHandCursor));
returncar->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_7->addWidget(returncar);
modcontract = new QPushButton(frame2);
modcontract->setObjectName(QString::fromUtf8("modcontract"));
sizePolicy2.setHeightForWidth(modcontract->sizePolicy().hasHeightForWidth());
modcontract->setSizePolicy(sizePolicy2);
modcontract->setMinimumSize(QSize(200, 40));
modcontract->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_7->addWidget(modcontract);
delcontract = new QPushButton(frame2);
delcontract->setObjectName(QString::fromUtf8("delcontract"));
sizePolicy2.setHeightForWidth(delcontract->sizePolicy().hasHeightForWidth());
delcontract->setSizePolicy(sizePolicy2);
delcontract->setMinimumSize(QSize(200, 40));
delcontract->setCursor(QCursor(Qt::PointingHandCursor));
delcontract->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_7->addWidget(delcontract);
return2 = new QPushButton(frame2);
return2->setObjectName(QString::fromUtf8("return2"));
sizePolicy2.setHeightForWidth(return2->sizePolicy().hasHeightForWidth());
return2->setSizePolicy(sizePolicy2);
return2->setMinimumSize(QSize(200, 40));
return2->setCursor(QCursor(Qt::PointingHandCursor));
return2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_7->addWidget(return2);
verticalLayout_3->addWidget(frame2, 0, Qt::AlignHCenter);
stackedWidget->addWidget(rentcarmenu);
carmenu = new QWidget();
carmenu->setObjectName(QString::fromUtf8("carmenu"));
verticalLayout_10 = new QVBoxLayout(carmenu);
verticalLayout_10->setObjectName(QString::fromUtf8("verticalLayout_10"));
cartitle = new QLabel(carmenu);
cartitle->setObjectName(QString::fromUtf8("cartitle"));
sizePolicy1.setHeightForWidth(cartitle->sizePolicy().hasHeightForWidth());
cartitle->setSizePolicy(sizePolicy1);
cartitle->setMinimumSize(QSize(200, 38));
cartitle->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 13pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:13px;"));
cartitle->setAlignment(Qt::AlignCenter);
verticalLayout_10->addWidget(cartitle, 0, Qt::AlignHCenter);
frame3 = new QFrame(carmenu);
frame3->setObjectName(QString::fromUtf8("frame3"));
sizePolicy2.setHeightForWidth(frame3->sizePolicy().hasHeightForWidth());
frame3->setSizePolicy(sizePolicy2);
frame3->setMinimumSize(QSize(200, 200));
verticalLayout_9 = new QVBoxLayout(frame3);
verticalLayout_9->setSpacing(0);
verticalLayout_9->setObjectName(QString::fromUtf8("verticalLayout_9"));
verticalLayout_9->setContentsMargins(1, 1, 1, 1);
listcar = new QPushButton(frame3);
listcar->setObjectName(QString::fromUtf8("listcar"));
sizePolicy2.setHeightForWidth(listcar->sizePolicy().hasHeightForWidth());
listcar->setSizePolicy(sizePolicy2);
listcar->setMinimumSize(QSize(200, 40));
listcar->setCursor(QCursor(Qt::PointingHandCursor));
listcar->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_9->addWidget(listcar);
addcar = new QPushButton(frame3);
addcar->setObjectName(QString::fromUtf8("addcar"));
sizePolicy2.setHeightForWidth(addcar->sizePolicy().hasHeightForWidth());
addcar->setSizePolicy(sizePolicy2);
addcar->setMinimumSize(QSize(200, 40));
addcar->setCursor(QCursor(Qt::PointingHandCursor));
addcar->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_9->addWidget(addcar);
modcar = new QPushButton(frame3);
modcar->setObjectName(QString::fromUtf8("modcar"));
sizePolicy2.setHeightForWidth(modcar->sizePolicy().hasHeightForWidth());
modcar->setSizePolicy(sizePolicy2);
modcar->setMinimumSize(QSize(200, 40));
modcar->setCursor(QCursor(Qt::PointingHandCursor));
modcar->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_9->addWidget(modcar);
delcar = new QPushButton(frame3);
delcar->setObjectName(QString::fromUtf8("delcar"));
sizePolicy2.setHeightForWidth(delcar->sizePolicy().hasHeightForWidth());
delcar->setSizePolicy(sizePolicy2);
delcar->setMinimumSize(QSize(200, 40));
delcar->setCursor(QCursor(Qt::PointingHandCursor));
delcar->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_9->addWidget(delcar);
return1 = new QPushButton(frame3);
return1->setObjectName(QString::fromUtf8("return1"));
sizePolicy2.setHeightForWidth(return1->sizePolicy().hasHeightForWidth());
return1->setSizePolicy(sizePolicy2);
return1->setMinimumSize(QSize(200, 40));
return1->setCursor(QCursor(Qt::PointingHandCursor));
return1->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_9->addWidget(return1);
verticalLayout_10->addWidget(frame3, 0, Qt::AlignHCenter);
stackedWidget->addWidget(carmenu);
clientmenu = new QWidget();
clientmenu->setObjectName(QString::fromUtf8("clientmenu"));
verticalLayout_4 = new QVBoxLayout(clientmenu);
verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4"));
client = new QLabel(clientmenu);
client->setObjectName(QString::fromUtf8("client"));
sizePolicy1.setHeightForWidth(client->sizePolicy().hasHeightForWidth());
client->setSizePolicy(sizePolicy1);
client->setMinimumSize(QSize(200, 38));
client->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 13pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:13px;"));
client->setAlignment(Qt::AlignCenter);
verticalLayout_4->addWidget(client, 0, Qt::AlignHCenter);
frame4 = new QFrame(clientmenu);
frame4->setObjectName(QString::fromUtf8("frame4"));
sizePolicy2.setHeightForWidth(frame4->sizePolicy().hasHeightForWidth());
frame4->setSizePolicy(sizePolicy2);
frame4->setMinimumSize(QSize(200, 200));
verticalLayout = new QVBoxLayout(frame4);
verticalLayout->setSpacing(0);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
verticalLayout->setContentsMargins(1, 1, 1, 1);
listclient = new QPushButton(frame4);
listclient->setObjectName(QString::fromUtf8("listclient"));
sizePolicy2.setHeightForWidth(listclient->sizePolicy().hasHeightForWidth());
listclient->setSizePolicy(sizePolicy2);
listclient->setMinimumSize(QSize(200, 40));
listclient->setCursor(QCursor(Qt::PointingHandCursor));
listclient->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout->addWidget(listclient);
addclient = new QPushButton(frame4);
addclient->setObjectName(QString::fromUtf8("addclient"));
sizePolicy2.setHeightForWidth(addclient->sizePolicy().hasHeightForWidth());
addclient->setSizePolicy(sizePolicy2);
addclient->setMinimumSize(QSize(200, 40));
addclient->setCursor(QCursor(Qt::PointingHandCursor));
addclient->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout->addWidget(addclient);
modclient = new QPushButton(frame4);
modclient->setObjectName(QString::fromUtf8("modclient"));
sizePolicy2.setHeightForWidth(modclient->sizePolicy().hasHeightForWidth());
modclient->setSizePolicy(sizePolicy2);
modclient->setMinimumSize(QSize(200, 40));
modclient->setCursor(QCursor(Qt::PointingHandCursor));
modclient->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout->addWidget(modclient);
delclient = new QPushButton(frame4);
delclient->setObjectName(QString::fromUtf8("delclient"));
sizePolicy2.setHeightForWidth(delclient->sizePolicy().hasHeightForWidth());
delclient->setSizePolicy(sizePolicy2);
delclient->setMinimumSize(QSize(200, 40));
delclient->setCursor(QCursor(Qt::PointingHandCursor));
delclient->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout->addWidget(delclient);
return3 = new QPushButton(frame4);
return3->setObjectName(QString::fromUtf8("return3"));
sizePolicy2.setHeightForWidth(return3->sizePolicy().hasHeightForWidth());
return3->setSizePolicy(sizePolicy2);
return3->setMinimumSize(QSize(200, 40));
return3->setCursor(QCursor(Qt::PointingHandCursor));
return3->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout->addWidget(return3);
verticalLayout_4->addWidget(frame4, 0, Qt::AlignHCenter);
stackedWidget->addWidget(clientmenu);
listcarmenu = new QWidget();
listcarmenu->setObjectName(QString::fromUtf8("listcarmenu"));
verticalLayout_11 = new QVBoxLayout(listcarmenu);
verticalLayout_11->setObjectName(QString::fromUtf8("verticalLayout_11"));
frame5 = new QFrame(listcarmenu);
frame5->setObjectName(QString::fromUtf8("frame5"));
sizePolicy2.setHeightForWidth(frame5->sizePolicy().hasHeightForWidth());
frame5->setSizePolicy(sizePolicy2);
frame5->setMinimumSize(QSize(200, 120));
frame5->setFrameShape(QFrame::NoFrame);
frame5->setFrameShadow(QFrame::Plain);
verticalLayout_6 = new QVBoxLayout(frame5);
verticalLayout_6->setSpacing(0);
verticalLayout_6->setObjectName(QString::fromUtf8("verticalLayout_6"));
verticalLayout_6->setSizeConstraint(QLayout::SetFixedSize);
verticalLayout_6->setContentsMargins(1, 1, 1, 1);
carlist = new QLabel(frame5);
carlist->setObjectName(QString::fromUtf8("carlist"));
carlist->setMinimumSize(QSize(300, 0));
carlist->setStyleSheet(QString::fromUtf8(""));
verticalLayout_6->addWidget(carlist);
addcar2 = new QPushButton(frame5);
addcar2->setObjectName(QString::fromUtf8("addcar2"));
sizePolicy2.setHeightForWidth(addcar2->sizePolicy().hasHeightForWidth());
addcar2->setSizePolicy(sizePolicy2);
addcar2->setMinimumSize(QSize(200, 40));
addcar2->setCursor(QCursor(Qt::PointingHandCursor));
addcar2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_6->addWidget(addcar2, 0, Qt::AlignHCenter);
return4 = new QPushButton(frame5);
return4->setObjectName(QString::fromUtf8("return4"));
sizePolicy2.setHeightForWidth(return4->sizePolicy().hasHeightForWidth());
return4->setSizePolicy(sizePolicy2);
return4->setMinimumSize(QSize(200, 40));
return4->setCursor(QCursor(Qt::PointingHandCursor));
return4->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_6->addWidget(return4, 0, Qt::AlignHCenter);
quit2 = new QPushButton(frame5);
quit2->setObjectName(QString::fromUtf8("quit2"));
sizePolicy2.setHeightForWidth(quit2->sizePolicy().hasHeightForWidth());
quit2->setSizePolicy(sizePolicy2);
quit2->setMinimumSize(QSize(200, 40));
quit2->setCursor(QCursor(Qt::PointingHandCursor));
quit2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_6->addWidget(quit2, 0, Qt::AlignHCenter);
verticalLayout_11->addWidget(frame5, 0, Qt::AlignHCenter);
stackedWidget->addWidget(listcarmenu);
addcarmenu = new QWidget();
addcarmenu->setObjectName(QString::fromUtf8("addcarmenu"));
verticalLayout_12 = new QVBoxLayout(addcarmenu);
verticalLayout_12->setObjectName(QString::fromUtf8("verticalLayout_12"));
frame6 = new QFrame(addcarmenu);
frame6->setObjectName(QString::fromUtf8("frame6"));
sizePolicy2.setHeightForWidth(frame6->sizePolicy().hasHeightForWidth());
frame6->setSizePolicy(sizePolicy2);
frame6->setMinimumSize(QSize(300, 180));
frame6->setFrameShape(QFrame::StyledPanel);
frame6->setFrameShadow(QFrame::Raised);
verticalLayout_13 = new QVBoxLayout(frame6);
verticalLayout_13->setObjectName(QString::fromUtf8("verticalLayout_13"));
formLayout = new QFormLayout();
formLayout->setObjectName(QString::fromUtf8("formLayout"));
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
formLayout->setHorizontalSpacing(6);
formLayout->setVerticalSpacing(2);
label = new QLabel(frame6);
label->setObjectName(QString::fromUtf8("label"));
QSizePolicy sizePolicy4(QSizePolicy::Maximum, QSizePolicy::Preferred);
sizePolicy4.setHorizontalStretch(0);
sizePolicy4.setVerticalStretch(0);
sizePolicy4.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
label->setSizePolicy(sizePolicy4);
label->setMinimumSize(QSize(120, 20));
label->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label->setAlignment(Qt::AlignCenter);
formLayout->setWidget(0, QFormLayout::LabelRole, label);
idvoit = new QLineEdit(frame6);
idvoit->setObjectName(QString::fromUtf8("idvoit"));
QSizePolicy sizePolicy5(QSizePolicy::Expanding, QSizePolicy::Maximum);
sizePolicy5.setHorizontalStretch(0);
sizePolicy5.setVerticalStretch(0);
sizePolicy5.setHeightForWidth(idvoit->sizePolicy().hasHeightForWidth());
idvoit->setSizePolicy(sizePolicy5);
idvoit->setMinimumSize(QSize(0, 30));
idvoit->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
"/* border-color:rgb(45, 41, 38);*/\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
idvoit->setFrame(true);
formLayout->setWidget(0, QFormLayout::FieldRole, idvoit);
label_2 = new QLabel(frame6);
label_2->setObjectName(QString::fromUtf8("label_2"));
sizePolicy4.setHeightForWidth(label_2->sizePolicy().hasHeightForWidth());
label_2->setSizePolicy(sizePolicy4);
label_2->setMinimumSize(QSize(120, 20));
label_2->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_2->setAlignment(Qt::AlignCenter);
formLayout->setWidget(1, QFormLayout::LabelRole, label_2);
marque = new QLineEdit(frame6);
marque->setObjectName(QString::fromUtf8("marque"));
sizePolicy5.setHeightForWidth(marque->sizePolicy().hasHeightForWidth());
marque->setSizePolicy(sizePolicy5);
marque->setMinimumSize(QSize(0, 30));
marque->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout->setWidget(1, QFormLayout::FieldRole, marque);
label_3 = new QLabel(frame6);
label_3->setObjectName(QString::fromUtf8("label_3"));
sizePolicy4.setHeightForWidth(label_3->sizePolicy().hasHeightForWidth());
label_3->setSizePolicy(sizePolicy4);
label_3->setMinimumSize(QSize(120, 20));
label_3->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_3->setAlignment(Qt::AlignCenter);
formLayout->setWidget(2, QFormLayout::LabelRole, label_3);
nomvoit = new QLineEdit(frame6);
nomvoit->setObjectName(QString::fromUtf8("nomvoit"));
sizePolicy5.setHeightForWidth(nomvoit->sizePolicy().hasHeightForWidth());
nomvoit->setSizePolicy(sizePolicy5);
nomvoit->setMinimumSize(QSize(0, 30));
nomvoit->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout->setWidget(2, QFormLayout::FieldRole, nomvoit);
label_4 = new QLabel(frame6);
label_4->setObjectName(QString::fromUtf8("label_4"));
sizePolicy4.setHeightForWidth(label_4->sizePolicy().hasHeightForWidth());
label_4->setSizePolicy(sizePolicy4);
label_4->setMinimumSize(QSize(120, 20));
label_4->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_4->setAlignment(Qt::AlignCenter);
formLayout->setWidget(3, QFormLayout::LabelRole, label_4);
couleur = new QLineEdit(frame6);
couleur->setObjectName(QString::fromUtf8("couleur"));
sizePolicy5.setHeightForWidth(couleur->sizePolicy().hasHeightForWidth());
couleur->setSizePolicy(sizePolicy5);
couleur->setMinimumSize(QSize(0, 30));
couleur->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout->setWidget(3, QFormLayout::FieldRole, couleur);
label_5 = new QLabel(frame6);
label_5->setObjectName(QString::fromUtf8("label_5"));
sizePolicy4.setHeightForWidth(label_5->sizePolicy().hasHeightForWidth());
label_5->setSizePolicy(sizePolicy4);
label_5->setMinimumSize(QSize(120, 20));
label_5->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_5->setAlignment(Qt::AlignCenter);
formLayout->setWidget(4, QFormLayout::LabelRole, label_5);
nbplace = new QLineEdit(frame6);
nbplace->setObjectName(QString::fromUtf8("nbplace"));
sizePolicy5.setHeightForWidth(nbplace->sizePolicy().hasHeightForWidth());
nbplace->setSizePolicy(sizePolicy5);
nbplace->setMinimumSize(QSize(0, 30));
nbplace->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout->setWidget(4, QFormLayout::FieldRole, nbplace);
label_6 = new QLabel(frame6);
label_6->setObjectName(QString::fromUtf8("label_6"));
sizePolicy4.setHeightForWidth(label_6->sizePolicy().hasHeightForWidth());
label_6->setSizePolicy(sizePolicy4);
label_6->setMinimumSize(QSize(120, 20));
label_6->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_6->setAlignment(Qt::AlignCenter);
formLayout->setWidget(5, QFormLayout::LabelRole, label_6);
prixjour = new QLineEdit(frame6);
prixjour->setObjectName(QString::fromUtf8("prixjour"));
sizePolicy5.setHeightForWidth(prixjour->sizePolicy().hasHeightForWidth());
prixjour->setSizePolicy(sizePolicy5);
prixjour->setMinimumSize(QSize(0, 30));
prixjour->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout->setWidget(5, QFormLayout::FieldRole, prixjour);
verticalLayout_13->addLayout(formLayout);
horizontalLayout_3 = new QHBoxLayout();
horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3"));
savereturn = new QPushButton(frame6);
savereturn->setObjectName(QString::fromUtf8("savereturn"));
sizePolicy1.setHeightForWidth(savereturn->sizePolicy().hasHeightForWidth());
savereturn->setSizePolicy(sizePolicy1);
savereturn->setMinimumSize(QSize(150, 35));
savereturn->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_3->addWidget(savereturn);
return_3 = new QPushButton(frame6);
return_3->setObjectName(QString::fromUtf8("return_3"));
sizePolicy1.setHeightForWidth(return_3->sizePolicy().hasHeightForWidth());
return_3->setSizePolicy(sizePolicy1);
return_3->setMinimumSize(QSize(150, 35));
return_3->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_3->addWidget(return_3);
verticalLayout_13->addLayout(horizontalLayout_3);
verticalLayout_12->addWidget(frame6, 0, Qt::AlignHCenter);
stackedWidget->addWidget(addcarmenu);
modmenu = new QWidget();
modmenu->setObjectName(QString::fromUtf8("modmenu"));
verticalLayout_8 = new QVBoxLayout(modmenu);
verticalLayout_8->setObjectName(QString::fromUtf8("verticalLayout_8"));
label_13 = new QLabel(modmenu);
label_13->setObjectName(QString::fromUtf8("label_13"));
QSizePolicy sizePolicy6(QSizePolicy::Maximum, QSizePolicy::Fixed);
sizePolicy6.setHorizontalStretch(0);
sizePolicy6.setVerticalStretch(0);
sizePolicy6.setHeightForWidth(label_13->sizePolicy().hasHeightForWidth());
label_13->setSizePolicy(sizePolicy6);
label_13->setMinimumSize(QSize(100, 30));
label_13->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 9pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:13px;"));
label_13->setAlignment(Qt::AlignCenter);
verticalLayout_8->addWidget(label_13, 0, Qt::AlignHCenter);
frame7 = new QFrame(modmenu);
frame7->setObjectName(QString::fromUtf8("frame7"));
sizePolicy2.setHeightForWidth(frame7->sizePolicy().hasHeightForWidth());
frame7->setSizePolicy(sizePolicy2);
frame7->setMinimumSize(QSize(300, 120));
frame7->setFrameShape(QFrame::StyledPanel);
frame7->setFrameShadow(QFrame::Raised);
verticalLayout_14 = new QVBoxLayout(frame7);
verticalLayout_14->setObjectName(QString::fromUtf8("verticalLayout_14"));
formLayout_3 = new QFormLayout();
formLayout_3->setObjectName(QString::fromUtf8("formLayout_3"));
formLayout_3->setHorizontalSpacing(6);
formLayout_3->setVerticalSpacing(6);
label_14 = new QLabel(frame7);
label_14->setObjectName(QString::fromUtf8("label_14"));
sizePolicy4.setHeightForWidth(label_14->sizePolicy().hasHeightForWidth());
label_14->setSizePolicy(sizePolicy4);
label_14->setMinimumSize(QSize(130, 0));
label_14->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_14->setAlignment(Qt::AlignCenter);
formLayout_3->setWidget(0, QFormLayout::LabelRole, label_14);
idsearch = new QLineEdit(frame7);
idsearch->setObjectName(QString::fromUtf8("idsearch"));
sizePolicy5.setHeightForWidth(idsearch->sizePolicy().hasHeightForWidth());
idsearch->setSizePolicy(sizePolicy5);
idsearch->setMinimumSize(QSize(0, 20));
idsearch->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_3->setWidget(0, QFormLayout::FieldRole, idsearch);
verticalLayout_14->addLayout(formLayout_3);
recherche = new QPushButton(frame7);
recherche->setObjectName(QString::fromUtf8("recherche"));
sizePolicy2.setHeightForWidth(recherche->sizePolicy().hasHeightForWidth());
recherche->setSizePolicy(sizePolicy2);
recherche->setMinimumSize(QSize(100, 20));
recherche->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 9pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_14->addWidget(recherche, 0, Qt::AlignHCenter);
result = new QLabel(frame7);
result->setObjectName(QString::fromUtf8("result"));
result->setStyleSheet(QString::fromUtf8(""));
result->setAlignment(Qt::AlignCenter);
verticalLayout_14->addWidget(result);
formLayout_2 = new QFormLayout();
formLayout_2->setObjectName(QString::fromUtf8("formLayout_2"));
formLayout_2->setSizeConstraint(QLayout::SetMinimumSize);
formLayout_2->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
formLayout_2->setRowWrapPolicy(QFormLayout::DontWrapRows);
formLayout_2->setHorizontalSpacing(6);
formLayout_2->setVerticalSpacing(2);
label_7 = new QLabel(frame7);
label_7->setObjectName(QString::fromUtf8("label_7"));
sizePolicy4.setHeightForWidth(label_7->sizePolicy().hasHeightForWidth());
label_7->setSizePolicy(sizePolicy4);
label_7->setMinimumSize(QSize(120, 20));
label_7->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_7->setAlignment(Qt::AlignCenter);
formLayout_2->setWidget(0, QFormLayout::LabelRole, label_7);
idvoit_2 = new QLineEdit(frame7);
idvoit_2->setObjectName(QString::fromUtf8("idvoit_2"));
sizePolicy5.setHeightForWidth(idvoit_2->sizePolicy().hasHeightForWidth());
idvoit_2->setSizePolicy(sizePolicy5);
idvoit_2->setMinimumSize(QSize(0, 30));
idvoit_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
idvoit_2->setFrame(true);
formLayout_2->setWidget(0, QFormLayout::FieldRole, idvoit_2);
label_8 = new QLabel(frame7);
label_8->setObjectName(QString::fromUtf8("label_8"));
sizePolicy4.setHeightForWidth(label_8->sizePolicy().hasHeightForWidth());
label_8->setSizePolicy(sizePolicy4);
label_8->setMinimumSize(QSize(120, 20));
label_8->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_8->setAlignment(Qt::AlignCenter);
formLayout_2->setWidget(1, QFormLayout::LabelRole, label_8);
label_9 = new QLabel(frame7);
label_9->setObjectName(QString::fromUtf8("label_9"));
sizePolicy4.setHeightForWidth(label_9->sizePolicy().hasHeightForWidth());
label_9->setSizePolicy(sizePolicy4);
label_9->setMinimumSize(QSize(120, 20));
label_9->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_9->setAlignment(Qt::AlignCenter);
formLayout_2->setWidget(2, QFormLayout::LabelRole, label_9);
nomvoit_2 = new QLineEdit(frame7);
nomvoit_2->setObjectName(QString::fromUtf8("nomvoit_2"));
sizePolicy5.setHeightForWidth(nomvoit_2->sizePolicy().hasHeightForWidth());
nomvoit_2->setSizePolicy(sizePolicy5);
nomvoit_2->setMinimumSize(QSize(0, 30));
nomvoit_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_2->setWidget(2, QFormLayout::FieldRole, nomvoit_2);
label_10 = new QLabel(frame7);
label_10->setObjectName(QString::fromUtf8("label_10"));
sizePolicy4.setHeightForWidth(label_10->sizePolicy().hasHeightForWidth());
label_10->setSizePolicy(sizePolicy4);
label_10->setMinimumSize(QSize(120, 20));
label_10->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_10->setAlignment(Qt::AlignCenter);
formLayout_2->setWidget(3, QFormLayout::LabelRole, label_10);
couleur_2 = new QLineEdit(frame7);
couleur_2->setObjectName(QString::fromUtf8("couleur_2"));
sizePolicy5.setHeightForWidth(couleur_2->sizePolicy().hasHeightForWidth());
couleur_2->setSizePolicy(sizePolicy5);
couleur_2->setMinimumSize(QSize(0, 30));
couleur_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_2->setWidget(3, QFormLayout::FieldRole, couleur_2);
label_11 = new QLabel(frame7);
label_11->setObjectName(QString::fromUtf8("label_11"));
sizePolicy4.setHeightForWidth(label_11->sizePolicy().hasHeightForWidth());
label_11->setSizePolicy(sizePolicy4);
label_11->setMinimumSize(QSize(120, 20));
label_11->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_11->setAlignment(Qt::AlignCenter);
formLayout_2->setWidget(4, QFormLayout::LabelRole, label_11);
nbplace_2 = new QLineEdit(frame7);
nbplace_2->setObjectName(QString::fromUtf8("nbplace_2"));
sizePolicy5.setHeightForWidth(nbplace_2->sizePolicy().hasHeightForWidth());
nbplace_2->setSizePolicy(sizePolicy5);
nbplace_2->setMinimumSize(QSize(0, 30));
nbplace_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_2->setWidget(4, QFormLayout::FieldRole, nbplace_2);
label_12 = new QLabel(frame7);
label_12->setObjectName(QString::fromUtf8("label_12"));
sizePolicy4.setHeightForWidth(label_12->sizePolicy().hasHeightForWidth());
label_12->setSizePolicy(sizePolicy4);
label_12->setMinimumSize(QSize(120, 20));
label_12->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_12->setAlignment(Qt::AlignCenter);
formLayout_2->setWidget(5, QFormLayout::LabelRole, label_12);
prixjour_2 = new QLineEdit(frame7);
prixjour_2->setObjectName(QString::fromUtf8("prixjour_2"));
sizePolicy5.setHeightForWidth(prixjour_2->sizePolicy().hasHeightForWidth());
prixjour_2->setSizePolicy(sizePolicy5);
prixjour_2->setMinimumSize(QSize(0, 30));
prixjour_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_2->setWidget(5, QFormLayout::FieldRole, prixjour_2);
marque_2 = new QLineEdit(frame7);
marque_2->setObjectName(QString::fromUtf8("marque_2"));
sizePolicy5.setHeightForWidth(marque_2->sizePolicy().hasHeightForWidth());
marque_2->setSizePolicy(sizePolicy5);
marque_2->setMinimumSize(QSize(0, 30));
marque_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_2->setWidget(1, QFormLayout::FieldRole, marque_2);
verticalLayout_14->addLayout(formLayout_2);
horizontalLayout_10 = new QHBoxLayout();
horizontalLayout_10->setObjectName(QString::fromUtf8("horizontalLayout_10"));
savereturn_2 = new QPushButton(frame7);
savereturn_2->setObjectName(QString::fromUtf8("savereturn_2"));
sizePolicy1.setHeightForWidth(savereturn_2->sizePolicy().hasHeightForWidth());
savereturn_2->setSizePolicy(sizePolicy1);
savereturn_2->setMinimumSize(QSize(150, 35));
savereturn_2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_10->addWidget(savereturn_2);
return_6 = new QPushButton(frame7);
return_6->setObjectName(QString::fromUtf8("return_6"));
sizePolicy1.setHeightForWidth(return_6->sizePolicy().hasHeightForWidth());
return_6->setSizePolicy(sizePolicy1);
return_6->setMinimumSize(QSize(150, 35));
return_6->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_10->addWidget(return_6);
verticalLayout_14->addLayout(horizontalLayout_10);
verticalLayout_8->addWidget(frame7, 0, Qt::AlignHCenter);
stackedWidget->addWidget(modmenu);
listclient_2 = new QWidget();
listclient_2->setObjectName(QString::fromUtf8("listclient_2"));
listclient_2->setStyleSheet(QString::fromUtf8("QLabel{\n"
"color:rgb(45, 41, 38);\n"
"font: 9pt \"Segoe UI\";\n"
"padding-right:10px;\n"
"padding-left:10px;\n"
"padding-bottom:10px;\n"
"}"));
verticalLayout_16 = new QVBoxLayout(listclient_2);
verticalLayout_16->setObjectName(QString::fromUtf8("verticalLayout_16"));
frame8 = new QFrame(listclient_2);
frame8->setObjectName(QString::fromUtf8("frame8"));
sizePolicy2.setHeightForWidth(frame8->sizePolicy().hasHeightForWidth());
frame8->setSizePolicy(sizePolicy2);
frame8->setMinimumSize(QSize(200, 120));
frame8->setFrameShape(QFrame::NoFrame);
frame8->setFrameShadow(QFrame::Plain);
verticalLayout_20 = new QVBoxLayout(frame8);
verticalLayout_20->setSpacing(0);
verticalLayout_20->setObjectName(QString::fromUtf8("verticalLayout_20"));
verticalLayout_20->setSizeConstraint(QLayout::SetFixedSize);
verticalLayout_20->setContentsMargins(1, 1, 1, 1);
clientlist = new QLabel(frame8);
clientlist->setObjectName(QString::fromUtf8("clientlist"));
clientlist->setMinimumSize(QSize(0, 100));
clientlist->setStyleSheet(QString::fromUtf8(""));
verticalLayout_20->addWidget(clientlist);
addclient_2 = new QPushButton(frame8);
addclient_2->setObjectName(QString::fromUtf8("addclient_2"));
sizePolicy2.setHeightForWidth(addclient_2->sizePolicy().hasHeightForWidth());
addclient_2->setSizePolicy(sizePolicy2);
addclient_2->setMinimumSize(QSize(200, 40));
addclient_2->setCursor(QCursor(Qt::PointingHandCursor));
addclient_2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_20->addWidget(addclient_2);
return4_2 = new QPushButton(frame8);
return4_2->setObjectName(QString::fromUtf8("return4_2"));
sizePolicy2.setHeightForWidth(return4_2->sizePolicy().hasHeightForWidth());
return4_2->setSizePolicy(sizePolicy2);
return4_2->setMinimumSize(QSize(200, 40));
return4_2->setCursor(QCursor(Qt::PointingHandCursor));
return4_2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_20->addWidget(return4_2);
quit2_2 = new QPushButton(frame8);
quit2_2->setObjectName(QString::fromUtf8("quit2_2"));
sizePolicy2.setHeightForWidth(quit2_2->sizePolicy().hasHeightForWidth());
quit2_2->setSizePolicy(sizePolicy2);
quit2_2->setMinimumSize(QSize(200, 40));
quit2_2->setCursor(QCursor(Qt::PointingHandCursor));
quit2_2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_20->addWidget(quit2_2);
verticalLayout_16->addWidget(frame8, 0, Qt::AlignHCenter);
stackedWidget->addWidget(listclient_2);
addclientmenu = new QWidget();
addclientmenu->setObjectName(QString::fromUtf8("addclientmenu"));
verticalLayout_17 = new QVBoxLayout(addclientmenu);
verticalLayout_17->setObjectName(QString::fromUtf8("verticalLayout_17"));
frame9 = new QFrame(addclientmenu);
frame9->setObjectName(QString::fromUtf8("frame9"));
sizePolicy2.setHeightForWidth(frame9->sizePolicy().hasHeightForWidth());
frame9->setSizePolicy(sizePolicy2);
frame9->setMinimumSize(QSize(300, 180));
frame9->setFrameShape(QFrame::StyledPanel);
frame9->setFrameShadow(QFrame::Raised);
verticalLayout_15 = new QVBoxLayout(frame9);
verticalLayout_15->setObjectName(QString::fromUtf8("verticalLayout_15"));
formLayout_4 = new QFormLayout();
formLayout_4->setObjectName(QString::fromUtf8("formLayout_4"));
formLayout_4->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
formLayout_4->setHorizontalSpacing(6);
formLayout_4->setVerticalSpacing(2);
label_15 = new QLabel(frame9);
label_15->setObjectName(QString::fromUtf8("label_15"));
sizePolicy4.setHeightForWidth(label_15->sizePolicy().hasHeightForWidth());
label_15->setSizePolicy(sizePolicy4);
label_15->setMinimumSize(QSize(120, 20));
label_15->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_15->setAlignment(Qt::AlignCenter);
formLayout_4->setWidget(0, QFormLayout::LabelRole, label_15);
idclient = new QLineEdit(frame9);
idclient->setObjectName(QString::fromUtf8("idclient"));
sizePolicy5.setHeightForWidth(idclient->sizePolicy().hasHeightForWidth());
idclient->setSizePolicy(sizePolicy5);
idclient->setMinimumSize(QSize(0, 30));
idclient->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
idclient->setFrame(true);
formLayout_4->setWidget(0, QFormLayout::FieldRole, idclient);
label_16 = new QLabel(frame9);
label_16->setObjectName(QString::fromUtf8("label_16"));
sizePolicy4.setHeightForWidth(label_16->sizePolicy().hasHeightForWidth());
label_16->setSizePolicy(sizePolicy4);
label_16->setMinimumSize(QSize(120, 20));
label_16->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_16->setAlignment(Qt::AlignCenter);
formLayout_4->setWidget(1, QFormLayout::LabelRole, label_16);
nom = new QLineEdit(frame9);
nom->setObjectName(QString::fromUtf8("nom"));
sizePolicy5.setHeightForWidth(nom->sizePolicy().hasHeightForWidth());
nom->setSizePolicy(sizePolicy5);
nom->setMinimumSize(QSize(0, 30));
nom->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_4->setWidget(1, QFormLayout::FieldRole, nom);
label_17 = new QLabel(frame9);
label_17->setObjectName(QString::fromUtf8("label_17"));
sizePolicy4.setHeightForWidth(label_17->sizePolicy().hasHeightForWidth());
label_17->setSizePolicy(sizePolicy4);
label_17->setMinimumSize(QSize(120, 20));
label_17->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_17->setAlignment(Qt::AlignCenter);
formLayout_4->setWidget(2, QFormLayout::LabelRole, label_17);
label_18 = new QLabel(frame9);
label_18->setObjectName(QString::fromUtf8("label_18"));
sizePolicy4.setHeightForWidth(label_18->sizePolicy().hasHeightForWidth());
label_18->setSizePolicy(sizePolicy4);
label_18->setMinimumSize(QSize(120, 20));
label_18->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_18->setAlignment(Qt::AlignCenter);
formLayout_4->setWidget(3, QFormLayout::LabelRole, label_18);
cin = new QLineEdit(frame9);
cin->setObjectName(QString::fromUtf8("cin"));
sizePolicy5.setHeightForWidth(cin->sizePolicy().hasHeightForWidth());
cin->setSizePolicy(sizePolicy5);
cin->setMinimumSize(QSize(0, 30));
cin->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_4->setWidget(3, QFormLayout::FieldRole, cin);
label_19 = new QLabel(frame9);
label_19->setObjectName(QString::fromUtf8("label_19"));
sizePolicy4.setHeightForWidth(label_19->sizePolicy().hasHeightForWidth());
label_19->setSizePolicy(sizePolicy4);
label_19->setMinimumSize(QSize(120, 20));
label_19->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_19->setAlignment(Qt::AlignCenter);
formLayout_4->setWidget(4, QFormLayout::LabelRole, label_19);
adresse = new QLineEdit(frame9);
adresse->setObjectName(QString::fromUtf8("adresse"));
sizePolicy5.setHeightForWidth(adresse->sizePolicy().hasHeightForWidth());
adresse->setSizePolicy(sizePolicy5);
adresse->setMinimumSize(QSize(0, 30));
adresse->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_4->setWidget(4, QFormLayout::FieldRole, adresse);
label_20 = new QLabel(frame9);
label_20->setObjectName(QString::fromUtf8("label_20"));
sizePolicy4.setHeightForWidth(label_20->sizePolicy().hasHeightForWidth());
label_20->setSizePolicy(sizePolicy4);
label_20->setMinimumSize(QSize(120, 20));
label_20->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_20->setAlignment(Qt::AlignCenter);
formLayout_4->setWidget(5, QFormLayout::LabelRole, label_20);
telephone = new QLineEdit(frame9);
telephone->setObjectName(QString::fromUtf8("telephone"));
sizePolicy5.setHeightForWidth(telephone->sizePolicy().hasHeightForWidth());
telephone->setSizePolicy(sizePolicy5);
telephone->setMinimumSize(QSize(200, 30));
telephone->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_4->setWidget(5, QFormLayout::FieldRole, telephone);
prenom = new QLineEdit(frame9);
prenom->setObjectName(QString::fromUtf8("prenom"));
sizePolicy5.setHeightForWidth(prenom->sizePolicy().hasHeightForWidth());
prenom->setSizePolicy(sizePolicy5);
prenom->setMinimumSize(QSize(0, 30));
prenom->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_4->setWidget(2, QFormLayout::FieldRole, prenom);
verticalLayout_15->addLayout(formLayout_4);
horizontalLayout_11 = new QHBoxLayout();
horizontalLayout_11->setObjectName(QString::fromUtf8("horizontalLayout_11"));
savereturn_3 = new QPushButton(frame9);
savereturn_3->setObjectName(QString::fromUtf8("savereturn_3"));
sizePolicy1.setHeightForWidth(savereturn_3->sizePolicy().hasHeightForWidth());
savereturn_3->setSizePolicy(sizePolicy1);
savereturn_3->setMinimumSize(QSize(150, 35));
savereturn_3->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_11->addWidget(savereturn_3);
return_7 = new QPushButton(frame9);
return_7->setObjectName(QString::fromUtf8("return_7"));
sizePolicy1.setHeightForWidth(return_7->sizePolicy().hasHeightForWidth());
return_7->setSizePolicy(sizePolicy1);
return_7->setMinimumSize(QSize(150, 35));
return_7->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_11->addWidget(return_7);
verticalLayout_15->addLayout(horizontalLayout_11);
verticalLayout_17->addWidget(frame9, 0, Qt::AlignHCenter);
stackedWidget->addWidget(addclientmenu);
modclientmenu = new QWidget();
modclientmenu->setObjectName(QString::fromUtf8("modclientmenu"));
verticalLayout_19 = new QVBoxLayout(modclientmenu);
verticalLayout_19->setObjectName(QString::fromUtf8("verticalLayout_19"));
frame10 = new QFrame(modclientmenu);
frame10->setObjectName(QString::fromUtf8("frame10"));
sizePolicy2.setHeightForWidth(frame10->sizePolicy().hasHeightForWidth());
frame10->setSizePolicy(sizePolicy2);
frame10->setMinimumSize(QSize(300, 180));
frame10->setFrameShape(QFrame::StyledPanel);
frame10->setFrameShadow(QFrame::Raised);
verticalLayout_18 = new QVBoxLayout(frame10);
verticalLayout_18->setObjectName(QString::fromUtf8("verticalLayout_18"));
formLayout_5 = new QFormLayout();
formLayout_5->setObjectName(QString::fromUtf8("formLayout_5"));
label_21 = new QLabel(frame10);
label_21->setObjectName(QString::fromUtf8("label_21"));
sizePolicy4.setHeightForWidth(label_21->sizePolicy().hasHeightForWidth());
label_21->setSizePolicy(sizePolicy4);
label_21->setMinimumSize(QSize(120, 0));
label_21->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
formLayout_5->setWidget(0, QFormLayout::LabelRole, label_21);
idsearch_2 = new QLineEdit(frame10);
idsearch_2->setObjectName(QString::fromUtf8("idsearch_2"));
sizePolicy5.setHeightForWidth(idsearch_2->sizePolicy().hasHeightForWidth());
idsearch_2->setSizePolicy(sizePolicy5);
idsearch_2->setMinimumSize(QSize(0, 20));
idsearch_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" background-color:rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:fucos{\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_5->setWidget(0, QFormLayout::FieldRole, idsearch_2);
verticalLayout_18->addLayout(formLayout_5);
recherche_2 = new QPushButton(frame10);
recherche_2->setObjectName(QString::fromUtf8("recherche_2"));
sizePolicy2.setHeightForWidth(recherche_2->sizePolicy().hasHeightForWidth());
recherche_2->setSizePolicy(sizePolicy2);
recherche_2->setMinimumSize(QSize(100, 20));
recherche_2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_18->addWidget(recherche_2, 0, Qt::AlignHCenter);
result_2 = new QLabel(frame10);
result_2->setObjectName(QString::fromUtf8("result_2"));
result_2->setStyleSheet(QString::fromUtf8(""));
result_2->setAlignment(Qt::AlignCenter);
verticalLayout_18->addWidget(result_2);
formLayout_6 = new QFormLayout();
formLayout_6->setObjectName(QString::fromUtf8("formLayout_6"));
formLayout_6->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
formLayout_6->setHorizontalSpacing(6);
formLayout_6->setVerticalSpacing(2);
label_22 = new QLabel(frame10);
label_22->setObjectName(QString::fromUtf8("label_22"));
sizePolicy4.setHeightForWidth(label_22->sizePolicy().hasHeightForWidth());
label_22->setSizePolicy(sizePolicy4);
label_22->setMinimumSize(QSize(120, 20));
label_22->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_22->setAlignment(Qt::AlignCenter);
formLayout_6->setWidget(0, QFormLayout::LabelRole, label_22);
idclient_2 = new QLineEdit(frame10);
idclient_2->setObjectName(QString::fromUtf8("idclient_2"));
sizePolicy5.setHeightForWidth(idclient_2->sizePolicy().hasHeightForWidth());
idclient_2->setSizePolicy(sizePolicy5);
idclient_2->setMinimumSize(QSize(0, 30));
idclient_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
idclient_2->setFrame(true);
formLayout_6->setWidget(0, QFormLayout::FieldRole, idclient_2);
label_23 = new QLabel(frame10);
label_23->setObjectName(QString::fromUtf8("label_23"));
sizePolicy4.setHeightForWidth(label_23->sizePolicy().hasHeightForWidth());
label_23->setSizePolicy(sizePolicy4);
label_23->setMinimumSize(QSize(120, 20));
label_23->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_23->setAlignment(Qt::AlignCenter);
formLayout_6->setWidget(1, QFormLayout::LabelRole, label_23);
nom_2 = new QLineEdit(frame10);
nom_2->setObjectName(QString::fromUtf8("nom_2"));
sizePolicy5.setHeightForWidth(nom_2->sizePolicy().hasHeightForWidth());
nom_2->setSizePolicy(sizePolicy5);
nom_2->setMinimumSize(QSize(0, 30));
nom_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_6->setWidget(1, QFormLayout::FieldRole, nom_2);
label_24 = new QLabel(frame10);
label_24->setObjectName(QString::fromUtf8("label_24"));
sizePolicy4.setHeightForWidth(label_24->sizePolicy().hasHeightForWidth());
label_24->setSizePolicy(sizePolicy4);
label_24->setMinimumSize(QSize(120, 20));
label_24->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_24->setAlignment(Qt::AlignCenter);
formLayout_6->setWidget(2, QFormLayout::LabelRole, label_24);
prenom_2 = new QLineEdit(frame10);
prenom_2->setObjectName(QString::fromUtf8("prenom_2"));
sizePolicy5.setHeightForWidth(prenom_2->sizePolicy().hasHeightForWidth());
prenom_2->setSizePolicy(sizePolicy5);
prenom_2->setMinimumSize(QSize(0, 30));
prenom_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_6->setWidget(2, QFormLayout::FieldRole, prenom_2);
label_25 = new QLabel(frame10);
label_25->setObjectName(QString::fromUtf8("label_25"));
sizePolicy4.setHeightForWidth(label_25->sizePolicy().hasHeightForWidth());
label_25->setSizePolicy(sizePolicy4);
label_25->setMinimumSize(QSize(120, 20));
label_25->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_25->setAlignment(Qt::AlignCenter);
formLayout_6->setWidget(3, QFormLayout::LabelRole, label_25);
label_26 = new QLabel(frame10);
label_26->setObjectName(QString::fromUtf8("label_26"));
sizePolicy4.setHeightForWidth(label_26->sizePolicy().hasHeightForWidth());
label_26->setSizePolicy(sizePolicy4);
label_26->setMinimumSize(QSize(120, 20));
label_26->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_26->setAlignment(Qt::AlignCenter);
formLayout_6->setWidget(4, QFormLayout::LabelRole, label_26);
adresse_2 = new QLineEdit(frame10);
adresse_2->setObjectName(QString::fromUtf8("adresse_2"));
sizePolicy5.setHeightForWidth(adresse_2->sizePolicy().hasHeightForWidth());
adresse_2->setSizePolicy(sizePolicy5);
adresse_2->setMinimumSize(QSize(0, 30));
adresse_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_6->setWidget(4, QFormLayout::FieldRole, adresse_2);
label_27 = new QLabel(frame10);
label_27->setObjectName(QString::fromUtf8("label_27"));
sizePolicy4.setHeightForWidth(label_27->sizePolicy().hasHeightForWidth());
label_27->setSizePolicy(sizePolicy4);
label_27->setMinimumSize(QSize(120, 20));
label_27->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_27->setAlignment(Qt::AlignCenter);
formLayout_6->setWidget(5, QFormLayout::LabelRole, label_27);
telephone_2 = new QLineEdit(frame10);
telephone_2->setObjectName(QString::fromUtf8("telephone_2"));
sizePolicy5.setHeightForWidth(telephone_2->sizePolicy().hasHeightForWidth());
telephone_2->setSizePolicy(sizePolicy5);
telephone_2->setMinimumSize(QSize(200, 30));
telephone_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_6->setWidget(5, QFormLayout::FieldRole, telephone_2);
cin_2 = new QLineEdit(frame10);
cin_2->setObjectName(QString::fromUtf8("cin_2"));
sizePolicy5.setHeightForWidth(cin_2->sizePolicy().hasHeightForWidth());
cin_2->setSizePolicy(sizePolicy5);
cin_2->setMinimumSize(QSize(0, 30));
cin_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_6->setWidget(3, QFormLayout::FieldRole, cin_2);
verticalLayout_18->addLayout(formLayout_6);
horizontalLayout_12 = new QHBoxLayout();
horizontalLayout_12->setObjectName(QString::fromUtf8("horizontalLayout_12"));
savereturn_4 = new QPushButton(frame10);
savereturn_4->setObjectName(QString::fromUtf8("savereturn_4"));
QSizePolicy sizePolicy7(QSizePolicy::Minimum, QSizePolicy::Fixed);
sizePolicy7.setHorizontalStretch(0);
sizePolicy7.setVerticalStretch(0);
sizePolicy7.setHeightForWidth(savereturn_4->sizePolicy().hasHeightForWidth());
savereturn_4->setSizePolicy(sizePolicy7);
savereturn_4->setMinimumSize(QSize(0, 35));
savereturn_4->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_12->addWidget(savereturn_4);
return_8 = new QPushButton(frame10);
return_8->setObjectName(QString::fromUtf8("return_8"));
return_8->setMinimumSize(QSize(0, 35));
return_8->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_12->addWidget(return_8);
verticalLayout_18->addLayout(horizontalLayout_12);
verticalLayout_19->addWidget(frame10, 0, Qt::AlignHCenter);
stackedWidget->addWidget(modclientmenu);
deletecar = new QWidget();
deletecar->setObjectName(QString::fromUtf8("deletecar"));
verticalLayout_21 = new QVBoxLayout(deletecar);
verticalLayout_21->setObjectName(QString::fromUtf8("verticalLayout_21"));
frame11 = new QFrame(deletecar);
frame11->setObjectName(QString::fromUtf8("frame11"));
sizePolicy2.setHeightForWidth(frame11->sizePolicy().hasHeightForWidth());
frame11->setSizePolicy(sizePolicy2);
frame11->setMinimumSize(QSize(300, 180));
frame11->setFrameShape(QFrame::StyledPanel);
frame11->setFrameShadow(QFrame::Raised);
verticalLayout_22 = new QVBoxLayout(frame11);
verticalLayout_22->setObjectName(QString::fromUtf8("verticalLayout_22"));
list = new QLabel(frame11);
list->setObjectName(QString::fromUtf8("list"));
list->setMinimumSize(QSize(0, 150));
list->setStyleSheet(QString::fromUtf8("padding-left: 5px;\n"
"padding-right: 5px;\n"
"font:10px;\n"
"\n"
""));
list->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
verticalLayout_22->addWidget(list);
formLayout_7 = new QFormLayout();
formLayout_7->setObjectName(QString::fromUtf8("formLayout_7"));
label_29 = new QLabel(frame11);
label_29->setObjectName(QString::fromUtf8("label_29"));
sizePolicy4.setHeightForWidth(label_29->sizePolicy().hasHeightForWidth());
label_29->setSizePolicy(sizePolicy4);
label_29->setMinimumSize(QSize(150, 0));
label_29->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_29->setAlignment(Qt::AlignCenter);
formLayout_7->setWidget(0, QFormLayout::LabelRole, label_29);
idcar = new QLineEdit(frame11);
idcar->setObjectName(QString::fromUtf8("idcar"));
QSizePolicy sizePolicy8(QSizePolicy::Preferred, QSizePolicy::Maximum);
sizePolicy8.setHorizontalStretch(0);
sizePolicy8.setVerticalStretch(0);
sizePolicy8.setHeightForWidth(idcar->sizePolicy().hasHeightForWidth());
idcar->setSizePolicy(sizePolicy8);
idcar->setMinimumSize(QSize(0, 20));
idcar->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_7->setWidget(0, QFormLayout::FieldRole, idcar);
verticalLayout_22->addLayout(formLayout_7);
deletecar_2 = new QPushButton(frame11);
deletecar_2->setObjectName(QString::fromUtf8("deletecar_2"));
sizePolicy2.setHeightForWidth(deletecar_2->sizePolicy().hasHeightForWidth());
deletecar_2->setSizePolicy(sizePolicy2);
deletecar_2->setMinimumSize(QSize(120, 0));
deletecar_2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_22->addWidget(deletecar_2, 0, Qt::AlignHCenter);
delmsg = new QLabel(frame11);
delmsg->setObjectName(QString::fromUtf8("delmsg"));
delmsg->setStyleSheet(QString::fromUtf8(""));
delmsg->setAlignment(Qt::AlignCenter);
verticalLayout_22->addWidget(delmsg);
return_5 = new QPushButton(frame11);
return_5->setObjectName(QString::fromUtf8("return_5"));
sizePolicy6.setHeightForWidth(return_5->sizePolicy().hasHeightForWidth());
return_5->setSizePolicy(sizePolicy6);
return_5->setMinimumSize(QSize(120, 20));
return_5->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_22->addWidget(return_5, 0, Qt::AlignHCenter);
verticalLayout_21->addWidget(frame11, 0, Qt::AlignHCenter);
stackedWidget->addWidget(deletecar);
deleteclient = new QWidget();
deleteclient->setObjectName(QString::fromUtf8("deleteclient"));
verticalLayout_33 = new QVBoxLayout(deleteclient);
verticalLayout_33->setObjectName(QString::fromUtf8("verticalLayout_33"));
frame12 = new QFrame(deleteclient);
frame12->setObjectName(QString::fromUtf8("frame12"));
sizePolicy2.setHeightForWidth(frame12->sizePolicy().hasHeightForWidth());
frame12->setSizePolicy(sizePolicy2);
frame12->setMinimumSize(QSize(300, 180));
frame12->setFrameShape(QFrame::StyledPanel);
frame12->setFrameShadow(QFrame::Raised);
verticalLayout_32 = new QVBoxLayout(frame12);
verticalLayout_32->setObjectName(QString::fromUtf8("verticalLayout_32"));
list_3 = new QLabel(frame12);
list_3->setObjectName(QString::fromUtf8("list_3"));
list_3->setMinimumSize(QSize(0, 150));
list_3->setStyleSheet(QString::fromUtf8("padding-left: 5px;\n"
"padding-right: 5px;\n"
"font:10px;"));
list_3->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
verticalLayout_32->addWidget(list_3);
formLayout_13 = new QFormLayout();
formLayout_13->setObjectName(QString::fromUtf8("formLayout_13"));
label_44 = new QLabel(frame12);
label_44->setObjectName(QString::fromUtf8("label_44"));
sizePolicy4.setHeightForWidth(label_44->sizePolicy().hasHeightForWidth());
label_44->setSizePolicy(sizePolicy4);
label_44->setMinimumSize(QSize(150, 0));
label_44->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_44->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
formLayout_13->setWidget(0, QFormLayout::LabelRole, label_44);
idclient_3 = new QLineEdit(frame12);
idclient_3->setObjectName(QString::fromUtf8("idclient_3"));
sizePolicy8.setHeightForWidth(idclient_3->sizePolicy().hasHeightForWidth());
idclient_3->setSizePolicy(sizePolicy8);
idclient_3->setMinimumSize(QSize(0, 20));
idclient_3->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_13->setWidget(0, QFormLayout::FieldRole, idclient_3);
verticalLayout_32->addLayout(formLayout_13);
deleteclient_2 = new QPushButton(frame12);
deleteclient_2->setObjectName(QString::fromUtf8("deleteclient_2"));
sizePolicy2.setHeightForWidth(deleteclient_2->sizePolicy().hasHeightForWidth());
deleteclient_2->setSizePolicy(sizePolicy2);
deleteclient_2->setMinimumSize(QSize(120, 0));
deleteclient_2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_32->addWidget(deleteclient_2, 0, Qt::AlignHCenter);
delmsg_3 = new QLabel(frame12);
delmsg_3->setObjectName(QString::fromUtf8("delmsg_3"));
delmsg_3->setStyleSheet(QString::fromUtf8(""));
delmsg_3->setAlignment(Qt::AlignCenter);
verticalLayout_32->addWidget(delmsg_3);
return_4 = new QPushButton(frame12);
return_4->setObjectName(QString::fromUtf8("return_4"));
sizePolicy6.setHeightForWidth(return_4->sizePolicy().hasHeightForWidth());
return_4->setSizePolicy(sizePolicy6);
return_4->setMinimumSize(QSize(120, 20));
return_4->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_32->addWidget(return_4, 0, Qt::AlignHCenter);
verticalLayout_33->addWidget(frame12, 0, Qt::AlignHCenter);
stackedWidget->addWidget(deleteclient);
idcheck = new QWidget();
idcheck->setObjectName(QString::fromUtf8("idcheck"));
idcheck->setStyleSheet(QString::fromUtf8("QLabel{\n"
"color:rgb(45, 41, 38);\n"
"font: 9pt \"Segoe UI\";\n"
"padding-right:10px;\n"
"padding-left:10px;\n"
"}"));
verticalLayout_34 = new QVBoxLayout(idcheck);
verticalLayout_34->setObjectName(QString::fromUtf8("verticalLayout_34"));
frame13 = new QFrame(idcheck);
frame13->setObjectName(QString::fromUtf8("frame13"));
sizePolicy2.setHeightForWidth(frame13->sizePolicy().hasHeightForWidth());
frame13->setSizePolicy(sizePolicy2);
frame13->setMinimumSize(QSize(200, 0));
frame13->setFrameShape(QFrame::StyledPanel);
frame13->setFrameShadow(QFrame::Raised);
verticalLayout_36 = new QVBoxLayout(frame13);
verticalLayout_36->setObjectName(QString::fromUtf8("verticalLayout_36"));
verticalLayout_35 = new QVBoxLayout();
verticalLayout_35->setObjectName(QString::fromUtf8("verticalLayout_35"));
label_51 = new QLabel(frame13);
label_51->setObjectName(QString::fromUtf8("label_51"));
sizePolicy.setHeightForWidth(label_51->sizePolicy().hasHeightForWidth());
label_51->setSizePolicy(sizePolicy);
label_51->setMinimumSize(QSize(120, 25));
label_51->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_51->setAlignment(Qt::AlignCenter);
verticalLayout_35->addWidget(label_51);
id_client = new QLineEdit(frame13);
id_client->setObjectName(QString::fromUtf8("id_client"));
sizePolicy5.setHeightForWidth(id_client->sizePolicy().hasHeightForWidth());
id_client->setSizePolicy(sizePolicy5);
id_client->setMinimumSize(QSize(0, 30));
id_client->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
id_client->setFrame(true);
verticalLayout_35->addWidget(id_client);
label_52 = new QLabel(frame13);
label_52->setObjectName(QString::fromUtf8("label_52"));
sizePolicy.setHeightForWidth(label_52->sizePolicy().hasHeightForWidth());
label_52->setSizePolicy(sizePolicy);
label_52->setMinimumSize(QSize(120, 25));
label_52->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_52->setAlignment(Qt::AlignCenter);
verticalLayout_35->addWidget(label_52);
id_car = new QLineEdit(frame13);
id_car->setObjectName(QString::fromUtf8("id_car"));
sizePolicy5.setHeightForWidth(id_car->sizePolicy().hasHeightForWidth());
id_car->setSizePolicy(sizePolicy5);
id_car->setMinimumSize(QSize(0, 30));
id_car->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
verticalLayout_35->addWidget(id_car);
verticalLayout_36->addLayout(verticalLayout_35);
search = new QPushButton(frame13);
search->setObjectName(QString::fromUtf8("search"));
sizePolicy1.setHeightForWidth(search->sizePolicy().hasHeightForWidth());
search->setSizePolicy(sizePolicy1);
search->setMinimumSize(QSize(180, 35));
search->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_36->addWidget(search);
return_10 = new QPushButton(frame13);
return_10->setObjectName(QString::fromUtf8("return_10"));
return_10->setMinimumSize(QSize(0, 35));
return_10->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_36->addWidget(return_10);
searchresult = new QLabel(frame13);
searchresult->setObjectName(QString::fromUtf8("searchresult"));
searchresult->setMinimumSize(QSize(0, 50));
searchresult->setAlignment(Qt::AlignCenter);
verticalLayout_36->addWidget(searchresult);
verticalLayout_34->addWidget(frame13, 0, Qt::AlignHCenter);
stackedWidget->addWidget(idcheck);
showcontrat = new QWidget();
showcontrat->setObjectName(QString::fromUtf8("showcontrat"));
verticalLayout_24 = new QVBoxLayout(showcontrat);
verticalLayout_24->setObjectName(QString::fromUtf8("verticalLayout_24"));
frame14 = new QFrame(showcontrat);
frame14->setObjectName(QString::fromUtf8("frame14"));
QSizePolicy sizePolicy9(QSizePolicy::Fixed, QSizePolicy::Maximum);
sizePolicy9.setHorizontalStretch(0);
sizePolicy9.setVerticalStretch(0);
sizePolicy9.setHeightForWidth(frame14->sizePolicy().hasHeightForWidth());
frame14->setSizePolicy(sizePolicy9);
frame14->setMinimumSize(QSize(300, 180));
frame14->setFrameShape(QFrame::StyledPanel);
frame14->setFrameShadow(QFrame::Raised);
verticalLayout_23 = new QVBoxLayout(frame14);
verticalLayout_23->setObjectName(QString::fromUtf8("verticalLayout_23"));
formLayout_8 = new QFormLayout();
formLayout_8->setObjectName(QString::fromUtf8("formLayout_8"));
formLayout_8->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
formLayout_8->setHorizontalSpacing(6);
formLayout_8->setVerticalSpacing(2);
label_28 = new QLabel(frame14);
label_28->setObjectName(QString::fromUtf8("label_28"));
sizePolicy4.setHeightForWidth(label_28->sizePolicy().hasHeightForWidth());
label_28->setSizePolicy(sizePolicy4);
label_28->setMinimumSize(QSize(120, 20));
label_28->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_28->setAlignment(Qt::AlignCenter);
formLayout_8->setWidget(0, QFormLayout::LabelRole, label_28);
numcontrat = new QLineEdit(frame14);
numcontrat->setObjectName(QString::fromUtf8("numcontrat"));
sizePolicy5.setHeightForWidth(numcontrat->sizePolicy().hasHeightForWidth());
numcontrat->setSizePolicy(sizePolicy5);
numcontrat->setMinimumSize(QSize(0, 30));
numcontrat->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
numcontrat->setFrame(true);
formLayout_8->setWidget(0, QFormLayout::FieldRole, numcontrat);
label_33 = new QLabel(frame14);
label_33->setObjectName(QString::fromUtf8("label_33"));
sizePolicy4.setHeightForWidth(label_33->sizePolicy().hasHeightForWidth());
label_33->setSizePolicy(sizePolicy4);
label_33->setMinimumSize(QSize(120, 20));
label_33->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_33->setAlignment(Qt::AlignCenter);
formLayout_8->setWidget(1, QFormLayout::LabelRole, label_33);
id_car_2 = new QLineEdit(frame14);
id_car_2->setObjectName(QString::fromUtf8("id_car_2"));
sizePolicy5.setHeightForWidth(id_car_2->sizePolicy().hasHeightForWidth());
id_car_2->setSizePolicy(sizePolicy5);
id_car_2->setMinimumSize(QSize(0, 30));
id_car_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_8->setWidget(1, QFormLayout::FieldRole, id_car_2);
label_30 = new QLabel(frame14);
label_30->setObjectName(QString::fromUtf8("label_30"));
sizePolicy4.setHeightForWidth(label_30->sizePolicy().hasHeightForWidth());
label_30->setSizePolicy(sizePolicy4);
label_30->setMinimumSize(QSize(120, 20));
label_30->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_30->setAlignment(Qt::AlignCenter);
formLayout_8->setWidget(2, QFormLayout::LabelRole, label_30);
id_client_2 = new QLineEdit(frame14);
id_client_2->setObjectName(QString::fromUtf8("id_client_2"));
sizePolicy5.setHeightForWidth(id_client_2->sizePolicy().hasHeightForWidth());
id_client_2->setSizePolicy(sizePolicy5);
id_client_2->setMinimumSize(QSize(0, 30));
id_client_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_8->setWidget(2, QFormLayout::FieldRole, id_client_2);
horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setSpacing(6);
horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
horizontalLayout_2->setSizeConstraint(QLayout::SetFixedSize);
debutjj = new QLineEdit(frame14);
debutjj->setObjectName(QString::fromUtf8("debutjj"));
debutjj->setMinimumSize(QSize(20, 20));
debutjj->setMaximumSize(QSize(65, 16777215));
debutjj->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_2->addWidget(debutjj);
debutmm = new QLineEdit(frame14);
debutmm->setObjectName(QString::fromUtf8("debutmm"));
debutmm->setMinimumSize(QSize(20, 20));
debutmm->setMaximumSize(QSize(65, 16777215));
debutmm->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_2->addWidget(debutmm);
debutaa = new QLineEdit(frame14);
debutaa->setObjectName(QString::fromUtf8("debutaa"));
QSizePolicy sizePolicy10(QSizePolicy::Expanding, QSizePolicy::Fixed);
sizePolicy10.setHorizontalStretch(0);
sizePolicy10.setVerticalStretch(0);
sizePolicy10.setHeightForWidth(debutaa->sizePolicy().hasHeightForWidth());
debutaa->setSizePolicy(sizePolicy10);
debutaa->setMinimumSize(QSize(20, 20));
debutaa->setMaximumSize(QSize(65, 16777215));
debutaa->setBaseSize(QSize(0, 0));
debutaa->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_2->addWidget(debutaa);
formLayout_8->setLayout(3, QFormLayout::FieldRole, horizontalLayout_2);
label_32 = new QLabel(frame14);
label_32->setObjectName(QString::fromUtf8("label_32"));
sizePolicy4.setHeightForWidth(label_32->sizePolicy().hasHeightForWidth());
label_32->setSizePolicy(sizePolicy4);
label_32->setMinimumSize(QSize(120, 20));
label_32->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_32->setAlignment(Qt::AlignCenter);
formLayout_8->setWidget(4, QFormLayout::LabelRole, label_32);
label_31 = new QLabel(frame14);
label_31->setObjectName(QString::fromUtf8("label_31"));
sizePolicy4.setHeightForWidth(label_31->sizePolicy().hasHeightForWidth());
label_31->setSizePolicy(sizePolicy4);
label_31->setMinimumSize(QSize(120, 20));
label_31->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_31->setAlignment(Qt::AlignCenter);
formLayout_8->setWidget(3, QFormLayout::LabelRole, label_31);
horizontalLayout = new QHBoxLayout();
horizontalLayout->setSpacing(6);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
finjj = new QLineEdit(frame14);
finjj->setObjectName(QString::fromUtf8("finjj"));
finjj->setMinimumSize(QSize(20, 20));
finjj->setMaximumSize(QSize(65, 16777215));
finjj->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout->addWidget(finjj);
finmm = new QLineEdit(frame14);
finmm->setObjectName(QString::fromUtf8("finmm"));
finmm->setMinimumSize(QSize(20, 20));
finmm->setMaximumSize(QSize(65, 16777215));
finmm->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout->addWidget(finmm);
finaa = new QLineEdit(frame14);
finaa->setObjectName(QString::fromUtf8("finaa"));
finaa->setMinimumSize(QSize(20, 20));
finaa->setMaximumSize(QSize(65, 16777215));
finaa->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout->addWidget(finaa);
formLayout_8->setLayout(4, QFormLayout::FieldRole, horizontalLayout);
cout = new QLineEdit(frame14);
cout->setObjectName(QString::fromUtf8("cout"));
sizePolicy5.setHeightForWidth(cout->sizePolicy().hasHeightForWidth());
cout->setSizePolicy(sizePolicy5);
cout->setMinimumSize(QSize(0, 30));
cout->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_8->setWidget(5, QFormLayout::FieldRole, cout);
label_34 = new QLabel(frame14);
label_34->setObjectName(QString::fromUtf8("label_34"));
sizePolicy4.setHeightForWidth(label_34->sizePolicy().hasHeightForWidth());
label_34->setSizePolicy(sizePolicy4);
label_34->setMinimumSize(QSize(120, 20));
label_34->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_34->setAlignment(Qt::AlignCenter);
formLayout_8->setWidget(5, QFormLayout::LabelRole, label_34);
verticalLayout_23->addLayout(formLayout_8);
return_2 = new QPushButton(frame14);
return_2->setObjectName(QString::fromUtf8("return_2"));
sizePolicy3.setHeightForWidth(return_2->sizePolicy().hasHeightForWidth());
return_2->setSizePolicy(sizePolicy3);
return_2->setMinimumSize(QSize(150, 35));
return_2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_23->addWidget(return_2, 0, Qt::AlignHCenter);
verticalLayout_24->addWidget(frame14, 0, Qt::AlignHCenter);
stackedWidget->addWidget(showcontrat);
louervoiture = new QWidget();
louervoiture->setObjectName(QString::fromUtf8("louervoiture"));
verticalLayout_27 = new QVBoxLayout(louervoiture);
verticalLayout_27->setObjectName(QString::fromUtf8("verticalLayout_27"));
frame15 = new QFrame(louervoiture);
frame15->setObjectName(QString::fromUtf8("frame15"));
sizePolicy2.setHeightForWidth(frame15->sizePolicy().hasHeightForWidth());
frame15->setSizePolicy(sizePolicy2);
frame15->setMinimumSize(QSize(200, 120));
frame15->setFrameShape(QFrame::NoFrame);
frame15->setFrameShadow(QFrame::Plain);
verticalLayout_26 = new QVBoxLayout(frame15);
verticalLayout_26->setSpacing(0);
verticalLayout_26->setObjectName(QString::fromUtf8("verticalLayout_26"));
verticalLayout_26->setSizeConstraint(QLayout::SetFixedSize);
verticalLayout_26->setContentsMargins(1, 1, 1, 1);
formLayout_10 = new QFormLayout();
formLayout_10->setObjectName(QString::fromUtf8("formLayout_10"));
clientsearch = new QLineEdit(frame15);
clientsearch->setObjectName(QString::fromUtf8("clientsearch"));
sizePolicy3.setHeightForWidth(clientsearch->sizePolicy().hasHeightForWidth());
clientsearch->setSizePolicy(sizePolicy3);
clientsearch->setMinimumSize(QSize(0, 20));
clientsearch->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_10->setWidget(0, QFormLayout::FieldRole, clientsearch);
label_35 = new QLabel(frame15);
label_35->setObjectName(QString::fromUtf8("label_35"));
sizePolicy4.setHeightForWidth(label_35->sizePolicy().hasHeightForWidth());
label_35->setSizePolicy(sizePolicy4);
label_35->setMinimumSize(QSize(80, 0));
label_35->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_35->setAlignment(Qt::AlignCenter);
formLayout_10->setWidget(0, QFormLayout::LabelRole, label_35);
verticalLayout_26->addLayout(formLayout_10);
findclient = new QPushButton(frame15);
findclient->setObjectName(QString::fromUtf8("findclient"));
sizePolicy6.setHeightForWidth(findclient->sizePolicy().hasHeightForWidth());
findclient->setSizePolicy(sizePolicy6);
findclient->setMinimumSize(QSize(140, 30));
findclient->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_26->addWidget(findclient, 0, Qt::AlignHCenter);
feedback = new QLabel(frame15);
feedback->setObjectName(QString::fromUtf8("feedback"));
feedback->setMinimumSize(QSize(0, 50));
feedback->setStyleSheet(QString::fromUtf8(""));
feedback->setAlignment(Qt::AlignHCenter|Qt::AlignTop);
verticalLayout_26->addWidget(feedback);
addcar2_2 = new QPushButton(frame15);
addcar2_2->setObjectName(QString::fromUtf8("addcar2_2"));
sizePolicy2.setHeightForWidth(addcar2_2->sizePolicy().hasHeightForWidth());
addcar2_2->setSizePolicy(sizePolicy2);
addcar2_2->setMinimumSize(QSize(200, 40));
addcar2_2->setCursor(QCursor(Qt::PointingHandCursor));
addcar2_2->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_26->addWidget(addcar2_2);
return4_3 = new QPushButton(frame15);
return4_3->setObjectName(QString::fromUtf8("return4_3"));
sizePolicy2.setHeightForWidth(return4_3->sizePolicy().hasHeightForWidth());
return4_3->setSizePolicy(sizePolicy2);
return4_3->setMinimumSize(QSize(200, 40));
return4_3->setCursor(QCursor(Qt::PointingHandCursor));
return4_3->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_26->addWidget(return4_3);
quit2_3 = new QPushButton(frame15);
quit2_3->setObjectName(QString::fromUtf8("quit2_3"));
sizePolicy2.setHeightForWidth(quit2_3->sizePolicy().hasHeightForWidth());
quit2_3->setSizePolicy(sizePolicy2);
quit2_3->setMinimumSize(QSize(200, 40));
quit2_3->setCursor(QCursor(Qt::PointingHandCursor));
quit2_3->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 11pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_26->addWidget(quit2_3);
verticalLayout_27->addWidget(frame15, 0, Qt::AlignHCenter);
stackedWidget->addWidget(louervoiture);
renttime = new QWidget();
renttime->setObjectName(QString::fromUtf8("renttime"));
verticalLayout_38 = new QVBoxLayout(renttime);
verticalLayout_38->setObjectName(QString::fromUtf8("verticalLayout_38"));
frame16 = new QFrame(renttime);
frame16->setObjectName(QString::fromUtf8("frame16"));
sizePolicy9.setHeightForWidth(frame16->sizePolicy().hasHeightForWidth());
frame16->setSizePolicy(sizePolicy9);
frame16->setMinimumSize(QSize(300, 180));
frame16->setFrameShape(QFrame::StyledPanel);
frame16->setFrameShadow(QFrame::Raised);
verticalLayout_37 = new QVBoxLayout(frame16);
verticalLayout_37->setObjectName(QString::fromUtf8("verticalLayout_37"));
label_50 = new QLabel(frame16);
label_50->setObjectName(QString::fromUtf8("label_50"));
QSizePolicy sizePolicy11(QSizePolicy::Fixed, QSizePolicy::Preferred);
sizePolicy11.setHorizontalStretch(0);
sizePolicy11.setVerticalStretch(0);
sizePolicy11.setHeightForWidth(label_50->sizePolicy().hasHeightForWidth());
label_50->setSizePolicy(sizePolicy11);
label_50->setMinimumSize(QSize(200, 20));
label_50->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_50->setAlignment(Qt::AlignCenter);
verticalLayout_37->addWidget(label_50, 0, Qt::AlignHCenter);
horizontalLayout_6 = new QHBoxLayout();
horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6"));
label_46 = new QLabel(frame16);
label_46->setObjectName(QString::fromUtf8("label_46"));
QSizePolicy sizePolicy12(QSizePolicy::Minimum, QSizePolicy::Preferred);
sizePolicy12.setHorizontalStretch(0);
sizePolicy12.setVerticalStretch(0);
sizePolicy12.setHeightForWidth(label_46->sizePolicy().hasHeightForWidth());
label_46->setSizePolicy(sizePolicy12);
label_46->setMinimumSize(QSize(120, 0));
label_46->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_46->setAlignment(Qt::AlignCenter);
horizontalLayout_6->addWidget(label_46);
carsearch = new QLineEdit(frame16);
carsearch->setObjectName(QString::fromUtf8("carsearch"));
carsearch->setMinimumSize(QSize(0, 20));
carsearch->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_6->addWidget(carsearch);
verticalLayout_37->addLayout(horizontalLayout_6);
validate = new QPushButton(frame16);
validate->setObjectName(QString::fromUtf8("validate"));
validate->setMinimumSize(QSize(100, 0));
validate->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_37->addWidget(validate, 0, Qt::AlignHCenter);
availablecars = new QLabel(frame16);
availablecars->setObjectName(QString::fromUtf8("availablecars"));
availablecars->setStyleSheet(QString::fromUtf8(""));
availablecars->setAlignment(Qt::AlignCenter);
verticalLayout_37->addWidget(availablecars);
label_45 = new QLabel(frame16);
label_45->setObjectName(QString::fromUtf8("label_45"));
sizePolicy1.setHeightForWidth(label_45->sizePolicy().hasHeightForWidth());
label_45->setSizePolicy(sizePolicy1);
label_45->setMinimumSize(QSize(200, 20));
label_45->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_45->setAlignment(Qt::AlignCenter);
verticalLayout_37->addWidget(label_45, 0, Qt::AlignHCenter);
formLayout_9 = new QFormLayout();
formLayout_9->setObjectName(QString::fromUtf8("formLayout_9"));
formLayout_9->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
formLayout_9->setHorizontalSpacing(6);
formLayout_9->setVerticalSpacing(2);
label_36 = new QLabel(frame16);
label_36->setObjectName(QString::fromUtf8("label_36"));
sizePolicy4.setHeightForWidth(label_36->sizePolicy().hasHeightForWidth());
label_36->setSizePolicy(sizePolicy4);
label_36->setMinimumSize(QSize(120, 30));
label_36->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_36->setAlignment(Qt::AlignCenter);
formLayout_9->setWidget(0, QFormLayout::LabelRole, label_36);
label_49 = new QLabel(frame16);
label_49->setObjectName(QString::fromUtf8("label_49"));
sizePolicy4.setHeightForWidth(label_49->sizePolicy().hasHeightForWidth());
label_49->setSizePolicy(sizePolicy4);
label_49->setMinimumSize(QSize(120, 20));
label_49->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_49->setAlignment(Qt::AlignCenter);
formLayout_9->setWidget(1, QFormLayout::LabelRole, label_49);
horizontalLayout_4 = new QHBoxLayout();
horizontalLayout_4->setSpacing(4);
horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4"));
horizontalLayout_4->setSizeConstraint(QLayout::SetFixedSize);
debutjj_2 = new QLineEdit(frame16);
debutjj_2->setObjectName(QString::fromUtf8("debutjj_2"));
debutjj_2->setMinimumSize(QSize(0, 20));
debutjj_2->setMaximumSize(QSize(65, 16777215));
debutjj_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_4->addWidget(debutjj_2);
debutmm_2 = new QLineEdit(frame16);
debutmm_2->setObjectName(QString::fromUtf8("debutmm_2"));
debutmm_2->setMinimumSize(QSize(0, 20));
debutmm_2->setMaximumSize(QSize(65, 16777215));
debutmm_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_4->addWidget(debutmm_2);
debutaa_2 = new QLineEdit(frame16);
debutaa_2->setObjectName(QString::fromUtf8("debutaa_2"));
sizePolicy10.setHeightForWidth(debutaa_2->sizePolicy().hasHeightForWidth());
debutaa_2->setSizePolicy(sizePolicy10);
debutaa_2->setMinimumSize(QSize(0, 20));
debutaa_2->setMaximumSize(QSize(65, 16777215));
debutaa_2->setBaseSize(QSize(0, 0));
debutaa_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_4->addWidget(debutaa_2);
formLayout_9->setLayout(1, QFormLayout::FieldRole, horizontalLayout_4);
label_47 = new QLabel(frame16);
label_47->setObjectName(QString::fromUtf8("label_47"));
sizePolicy4.setHeightForWidth(label_47->sizePolicy().hasHeightForWidth());
label_47->setSizePolicy(sizePolicy4);
label_47->setMinimumSize(QSize(120, 20));
label_47->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_47->setAlignment(Qt::AlignCenter);
formLayout_9->setWidget(2, QFormLayout::LabelRole, label_47);
horizontalLayout_5 = new QHBoxLayout();
horizontalLayout_5->setSpacing(4);
horizontalLayout_5->setObjectName(QString::fromUtf8("horizontalLayout_5"));
horizontalLayout_5->setSizeConstraint(QLayout::SetFixedSize);
finjj_2 = new QLineEdit(frame16);
finjj_2->setObjectName(QString::fromUtf8("finjj_2"));
QSizePolicy sizePolicy13(QSizePolicy::Expanding, QSizePolicy::Preferred);
sizePolicy13.setHorizontalStretch(0);
sizePolicy13.setVerticalStretch(0);
sizePolicy13.setHeightForWidth(finjj_2->sizePolicy().hasHeightForWidth());
finjj_2->setSizePolicy(sizePolicy13);
finjj_2->setMinimumSize(QSize(50, 20));
finjj_2->setMaximumSize(QSize(65, 16777215));
finjj_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_5->addWidget(finjj_2);
finmm_2 = new QLineEdit(frame16);
finmm_2->setObjectName(QString::fromUtf8("finmm_2"));
sizePolicy13.setHeightForWidth(finmm_2->sizePolicy().hasHeightForWidth());
finmm_2->setSizePolicy(sizePolicy13);
finmm_2->setMinimumSize(QSize(40, 20));
finmm_2->setMaximumSize(QSize(65, 16777215));
finmm_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_5->addWidget(finmm_2);
finaa_2 = new QLineEdit(frame16);
finaa_2->setObjectName(QString::fromUtf8("finaa_2"));
sizePolicy13.setHeightForWidth(finaa_2->sizePolicy().hasHeightForWidth());
finaa_2->setSizePolicy(sizePolicy13);
finaa_2->setMinimumSize(QSize(40, 20));
finaa_2->setMaximumSize(QSize(65, 16777215));
finaa_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_5->addWidget(finaa_2);
formLayout_9->setLayout(2, QFormLayout::FieldRole, horizontalLayout_5);
label_48 = new QLabel(frame16);
label_48->setObjectName(QString::fromUtf8("label_48"));
sizePolicy4.setHeightForWidth(label_48->sizePolicy().hasHeightForWidth());
label_48->setSizePolicy(sizePolicy4);
label_48->setMinimumSize(QSize(120, 30));
label_48->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_48->setAlignment(Qt::AlignCenter);
formLayout_9->setWidget(3, QFormLayout::LabelRole, label_48);
cout_2 = new QLineEdit(frame16);
cout_2->setObjectName(QString::fromUtf8("cout_2"));
sizePolicy5.setHeightForWidth(cout_2->sizePolicy().hasHeightForWidth());
cout_2->setSizePolicy(sizePolicy5);
cout_2->setMinimumSize(QSize(0, 30));
cout_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_9->setWidget(3, QFormLayout::FieldRole, cout_2);
numcontrat_2 = new QLineEdit(frame16);
numcontrat_2->setObjectName(QString::fromUtf8("numcontrat_2"));
sizePolicy5.setHeightForWidth(numcontrat_2->sizePolicy().hasHeightForWidth());
numcontrat_2->setSizePolicy(sizePolicy5);
numcontrat_2->setMinimumSize(QSize(0, 30));
numcontrat_2->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
numcontrat_2->setFrame(true);
formLayout_9->setWidget(0, QFormLayout::FieldRole, numcontrat_2);
verticalLayout_37->addLayout(formLayout_9);
horizontalLayout_13 = new QHBoxLayout();
horizontalLayout_13->setObjectName(QString::fromUtf8("horizontalLayout_13"));
saverent = new QPushButton(frame16);
saverent->setObjectName(QString::fromUtf8("saverent"));
sizePolicy7.setHeightForWidth(saverent->sizePolicy().hasHeightForWidth());
saverent->setSizePolicy(sizePolicy7);
saverent->setMinimumSize(QSize(0, 35));
saverent->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_13->addWidget(saverent);
return_9 = new QPushButton(frame16);
return_9->setObjectName(QString::fromUtf8("return_9"));
return_9->setMinimumSize(QSize(0, 35));
return_9->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_13->addWidget(return_9);
verticalLayout_37->addLayout(horizontalLayout_13);
verticalLayout_38->addWidget(frame16, 0, Qt::AlignHCenter);
stackedWidget->addWidget(renttime);
modcontractmenu = new QWidget();
modcontractmenu->setObjectName(QString::fromUtf8("modcontractmenu"));
verticalLayout_29 = new QVBoxLayout(modcontractmenu);
verticalLayout_29->setObjectName(QString::fromUtf8("verticalLayout_29"));
frame17 = new QFrame(modcontractmenu);
frame17->setObjectName(QString::fromUtf8("frame17"));
sizePolicy9.setHeightForWidth(frame17->sizePolicy().hasHeightForWidth());
frame17->setSizePolicy(sizePolicy9);
frame17->setMinimumSize(QSize(300, 180));
frame17->setFrameShape(QFrame::StyledPanel);
frame17->setFrameShadow(QFrame::Raised);
verticalLayout_28 = new QVBoxLayout(frame17);
verticalLayout_28->setObjectName(QString::fromUtf8("verticalLayout_28"));
horizontalLayout_7 = new QHBoxLayout();
horizontalLayout_7->setObjectName(QString::fromUtf8("horizontalLayout_7"));
label_53 = new QLabel(frame17);
label_53->setObjectName(QString::fromUtf8("label_53"));
sizePolicy12.setHeightForWidth(label_53->sizePolicy().hasHeightForWidth());
label_53->setSizePolicy(sizePolicy12);
label_53->setMinimumSize(QSize(120, 0));
label_53->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_53->setAlignment(Qt::AlignCenter);
horizontalLayout_7->addWidget(label_53);
id_voit = new QLineEdit(frame17);
id_voit->setObjectName(QString::fromUtf8("id_voit"));
id_voit->setMinimumSize(QSize(0, 20));
id_voit->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_7->addWidget(id_voit);
verticalLayout_28->addLayout(horizontalLayout_7);
contratsearch = new QPushButton(frame17);
contratsearch->setObjectName(QString::fromUtf8("contratsearch"));
sizePolicy1.setHeightForWidth(contratsearch->sizePolicy().hasHeightForWidth());
contratsearch->setSizePolicy(sizePolicy1);
contratsearch->setMinimumSize(QSize(100, 25));
contratsearch->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_28->addWidget(contratsearch, 0, Qt::AlignHCenter);
modcontratsearch = new QLabel(frame17);
modcontratsearch->setObjectName(QString::fromUtf8("modcontratsearch"));
modcontratsearch->setStyleSheet(QString::fromUtf8(""));
modcontratsearch->setAlignment(Qt::AlignCenter);
verticalLayout_28->addWidget(modcontratsearch);
formLayout_11 = new QFormLayout();
formLayout_11->setObjectName(QString::fromUtf8("formLayout_11"));
formLayout_11->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
formLayout_11->setHorizontalSpacing(6);
formLayout_11->setVerticalSpacing(2);
label_38 = new QLabel(frame17);
label_38->setObjectName(QString::fromUtf8("label_38"));
QSizePolicy sizePolicy14(QSizePolicy::Fixed, QSizePolicy::Expanding);
sizePolicy14.setHorizontalStretch(0);
sizePolicy14.setVerticalStretch(0);
sizePolicy14.setHeightForWidth(label_38->sizePolicy().hasHeightForWidth());
label_38->setSizePolicy(sizePolicy14);
label_38->setMinimumSize(QSize(120, 0));
label_38->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_38->setAlignment(Qt::AlignCenter);
formLayout_11->setWidget(2, QFormLayout::LabelRole, label_38);
idclient_4 = new QLineEdit(frame17);
idclient_4->setObjectName(QString::fromUtf8("idclient_4"));
idclient_4->setMinimumSize(QSize(0, 30));
idclient_4->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_11->setWidget(2, QFormLayout::FieldRole, idclient_4);
label_39 = new QLabel(frame17);
label_39->setObjectName(QString::fromUtf8("label_39"));
label_39->setMinimumSize(QSize(120, 20));
label_39->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_39->setAlignment(Qt::AlignCenter);
formLayout_11->setWidget(3, QFormLayout::LabelRole, label_39);
idvoit_3 = new QLineEdit(frame17);
idvoit_3->setObjectName(QString::fromUtf8("idvoit_3"));
idvoit_3->setMinimumSize(QSize(0, 30));
idvoit_3->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_11->setWidget(3, QFormLayout::FieldRole, idvoit_3);
label_54 = new QLabel(frame17);
label_54->setObjectName(QString::fromUtf8("label_54"));
sizePolicy4.setHeightForWidth(label_54->sizePolicy().hasHeightForWidth());
label_54->setSizePolicy(sizePolicy4);
label_54->setMinimumSize(QSize(120, 0));
label_54->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_54->setAlignment(Qt::AlignCenter);
formLayout_11->setWidget(4, QFormLayout::LabelRole, label_54);
horizontalLayout_8 = new QHBoxLayout();
horizontalLayout_8->setSpacing(6);
horizontalLayout_8->setObjectName(QString::fromUtf8("horizontalLayout_8"));
horizontalLayout_8->setSizeConstraint(QLayout::SetFixedSize);
debutjj_3 = new QLineEdit(frame17);
debutjj_3->setObjectName(QString::fromUtf8("debutjj_3"));
debutjj_3->setMinimumSize(QSize(0, 20));
debutjj_3->setMaximumSize(QSize(65, 16777215));
debutjj_3->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_8->addWidget(debutjj_3);
debutmm_3 = new QLineEdit(frame17);
debutmm_3->setObjectName(QString::fromUtf8("debutmm_3"));
debutmm_3->setMinimumSize(QSize(0, 20));
debutmm_3->setMaximumSize(QSize(65, 16777215));
debutmm_3->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
debutmm_3->setClearButtonEnabled(false);
horizontalLayout_8->addWidget(debutmm_3);
debutaa_3 = new QLineEdit(frame17);
debutaa_3->setObjectName(QString::fromUtf8("debutaa_3"));
sizePolicy10.setHeightForWidth(debutaa_3->sizePolicy().hasHeightForWidth());
debutaa_3->setSizePolicy(sizePolicy10);
debutaa_3->setMinimumSize(QSize(0, 20));
debutaa_3->setMaximumSize(QSize(65, 16777215));
debutaa_3->setBaseSize(QSize(0, 0));
debutaa_3->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_8->addWidget(debutaa_3);
formLayout_11->setLayout(4, QFormLayout::FieldRole, horizontalLayout_8);
label_55 = new QLabel(frame17);
label_55->setObjectName(QString::fromUtf8("label_55"));
sizePolicy4.setHeightForWidth(label_55->sizePolicy().hasHeightForWidth());
label_55->setSizePolicy(sizePolicy4);
label_55->setMinimumSize(QSize(120, 20));
label_55->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_55->setAlignment(Qt::AlignCenter);
formLayout_11->setWidget(5, QFormLayout::LabelRole, label_55);
horizontalLayout_9 = new QHBoxLayout();
horizontalLayout_9->setSpacing(6);
horizontalLayout_9->setObjectName(QString::fromUtf8("horizontalLayout_9"));
horizontalLayout_9->setSizeConstraint(QLayout::SetFixedSize);
finjj_3 = new QLineEdit(frame17);
finjj_3->setObjectName(QString::fromUtf8("finjj_3"));
sizePolicy13.setHeightForWidth(finjj_3->sizePolicy().hasHeightForWidth());
finjj_3->setSizePolicy(sizePolicy13);
finjj_3->setMinimumSize(QSize(0, 20));
finjj_3->setMaximumSize(QSize(65, 16777215));
finjj_3->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_9->addWidget(finjj_3);
finmm_3 = new QLineEdit(frame17);
finmm_3->setObjectName(QString::fromUtf8("finmm_3"));
sizePolicy13.setHeightForWidth(finmm_3->sizePolicy().hasHeightForWidth());
finmm_3->setSizePolicy(sizePolicy13);
finmm_3->setMinimumSize(QSize(0, 20));
finmm_3->setMaximumSize(QSize(65, 16777215));
finmm_3->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_9->addWidget(finmm_3);
finaa_3 = new QLineEdit(frame17);
finaa_3->setObjectName(QString::fromUtf8("finaa_3"));
sizePolicy13.setHeightForWidth(finaa_3->sizePolicy().hasHeightForWidth());
finaa_3->setSizePolicy(sizePolicy13);
finaa_3->setMinimumSize(QSize(0, 20));
finaa_3->setMaximumSize(QSize(65, 16777215));
finaa_3->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
horizontalLayout_9->addWidget(finaa_3);
formLayout_11->setLayout(5, QFormLayout::FieldRole, horizontalLayout_9);
label_56 = new QLabel(frame17);
label_56->setObjectName(QString::fromUtf8("label_56"));
sizePolicy4.setHeightForWidth(label_56->sizePolicy().hasHeightForWidth());
label_56->setSizePolicy(sizePolicy4);
label_56->setMinimumSize(QSize(120, 20));
label_56->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_56->setAlignment(Qt::AlignCenter);
formLayout_11->setWidget(6, QFormLayout::LabelRole, label_56);
cout_3 = new QLineEdit(frame17);
cout_3->setObjectName(QString::fromUtf8("cout_3"));
sizePolicy5.setHeightForWidth(cout_3->sizePolicy().hasHeightForWidth());
cout_3->setSizePolicy(sizePolicy5);
cout_3->setMinimumSize(QSize(0, 30));
cout_3->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_11->setWidget(6, QFormLayout::FieldRole, cout_3);
numcontrat_3 = new QLineEdit(frame17);
numcontrat_3->setObjectName(QString::fromUtf8("numcontrat_3"));
sizePolicy5.setHeightForWidth(numcontrat_3->sizePolicy().hasHeightForWidth());
numcontrat_3->setSizePolicy(sizePolicy5);
numcontrat_3->setMinimumSize(QSize(0, 30));
numcontrat_3->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
numcontrat_3->setFrame(true);
formLayout_11->setWidget(1, QFormLayout::FieldRole, numcontrat_3);
label_37 = new QLabel(frame17);
label_37->setObjectName(QString::fromUtf8("label_37"));
sizePolicy4.setHeightForWidth(label_37->sizePolicy().hasHeightForWidth());
label_37->setSizePolicy(sizePolicy4);
label_37->setMinimumSize(QSize(120, 20));
label_37->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_37->setAlignment(Qt::AlignCenter);
formLayout_11->setWidget(1, QFormLayout::LabelRole, label_37);
verticalLayout_28->addLayout(formLayout_11);
horizontalLayout_15 = new QHBoxLayout();
horizontalLayout_15->setObjectName(QString::fromUtf8("horizontalLayout_15"));
save = new QPushButton(frame17);
save->setObjectName(QString::fromUtf8("save"));
sizePolicy7.setHeightForWidth(save->sizePolicy().hasHeightForWidth());
save->setSizePolicy(sizePolicy7);
save->setMinimumSize(QSize(0, 35));
save->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_15->addWidget(save);
return_11 = new QPushButton(frame17);
return_11->setObjectName(QString::fromUtf8("return_11"));
return_11->setMinimumSize(QSize(0, 35));
return_11->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
horizontalLayout_15->addWidget(return_11);
verticalLayout_28->addLayout(horizontalLayout_15);
verticalLayout_29->addWidget(frame17, 0, Qt::AlignHCenter);
stackedWidget->addWidget(modcontractmenu);
delcontractmenu = new QWidget();
delcontractmenu->setObjectName(QString::fromUtf8("delcontractmenu"));
verticalLayout_31 = new QVBoxLayout(delcontractmenu);
verticalLayout_31->setObjectName(QString::fromUtf8("verticalLayout_31"));
frame18 = new QFrame(delcontractmenu);
frame18->setObjectName(QString::fromUtf8("frame18"));
sizePolicy2.setHeightForWidth(frame18->sizePolicy().hasHeightForWidth());
frame18->setSizePolicy(sizePolicy2);
frame18->setMinimumSize(QSize(300, 180));
frame18->setFrameShape(QFrame::StyledPanel);
frame18->setFrameShadow(QFrame::Raised);
verticalLayout_30 = new QVBoxLayout(frame18);
verticalLayout_30->setObjectName(QString::fromUtf8("verticalLayout_30"));
list_2 = new QLabel(frame18);
list_2->setObjectName(QString::fromUtf8("list_2"));
list_2->setMinimumSize(QSize(0, 150));
list_2->setStyleSheet(QString::fromUtf8("\n"
"font: 10pt \"Segoe UI\";\n"
"padding-left: 5px;\n"
"padding-right: 5px;\n"
"\n"
""));
verticalLayout_30->addWidget(list_2);
formLayout_12 = new QFormLayout();
formLayout_12->setObjectName(QString::fromUtf8("formLayout_12"));
label_43 = new QLabel(frame18);
label_43->setObjectName(QString::fromUtf8("label_43"));
sizePolicy4.setHeightForWidth(label_43->sizePolicy().hasHeightForWidth());
label_43->setSizePolicy(sizePolicy4);
label_43->setMinimumSize(QSize(150, 0));
label_43->setStyleSheet(QString::fromUtf8("background-color: rgb(45, 41, 38);\n"
"color:rgb(233, 75, 60);\n"
"font: 8pt \"Segoe UI\",;\n"
"font-weight:bold;\n"
"border-radius:9px;"));
label_43->setAlignment(Qt::AlignCenter);
formLayout_12->setWidget(0, QFormLayout::LabelRole, label_43);
idvoitcontrat = new QLineEdit(frame18);
idvoitcontrat->setObjectName(QString::fromUtf8("idvoitcontrat"));
sizePolicy8.setHeightForWidth(idvoitcontrat->sizePolicy().hasHeightForWidth());
idvoitcontrat->setSizePolicy(sizePolicy8);
idvoitcontrat->setMinimumSize(QSize(0, 20));
idvoitcontrat->setStyleSheet(QString::fromUtf8("QLineEdit{\n"
" border-style:solid;\n"
" border-width:1px;\n"
" border-radius:10px;\n"
" padding-right:10px;\n"
" padding-left:10px;\n"
" font: \"Segoe UI\";\n"
"}\n"
"QLineEdit:hover{\n"
" border-style:solid;\n"
" border-color:rgb(252, 249, 81);\n"
"}\n"
""));
formLayout_12->setWidget(0, QFormLayout::FieldRole, idvoitcontrat);
verticalLayout_30->addLayout(formLayout_12);
delcontrat = new QPushButton(frame18);
delcontrat->setObjectName(QString::fromUtf8("delcontrat"));
sizePolicy2.setHeightForWidth(delcontrat->sizePolicy().hasHeightForWidth());
delcontrat->setSizePolicy(sizePolicy2);
delcontrat->setMinimumSize(QSize(120, 0));
delcontrat->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_30->addWidget(delcontrat, 0, Qt::AlignHCenter);
delmsg_2 = new QLabel(frame18);
delmsg_2->setObjectName(QString::fromUtf8("delmsg_2"));
delmsg_2->setStyleSheet(QString::fromUtf8(""));
delmsg_2->setAlignment(Qt::AlignCenter);
verticalLayout_30->addWidget(delmsg_2);
return_12 = new QPushButton(frame18);
return_12->setObjectName(QString::fromUtf8("return_12"));
return_12->setMinimumSize(QSize(120, 0));
return_12->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}"));
verticalLayout_30->addWidget(return_12, 0, Qt::AlignHCenter);
verticalLayout_31->addWidget(frame18, 0, Qt::AlignHCenter);
stackedWidget->addWidget(delcontractmenu);
page = new QWidget();
page->setObjectName(QString::fromUtf8("page"));
page->setStyleSheet(QString::fromUtf8("QPushButton {\n"
" color:rgb(45, 41, 38);\n"
" background-color:rgb(233, 75, 60);\n"
" border-style:solid;\n"
" border-width:2px;\n"
" border-color:rgb(45, 41, 38);\n"
" border-radius:10px;\n"
" font: 10pt \"Segoe UI\";\n"
"}\n"
"QPushButton:hover {\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" border-color:rgb(233, 75, 60);\n"
"}\n"
"QPushButton:pressed {\n"
" background-color:rgb(252, 249, 81);\n"
" color:rgb(45, 41, 38);\n"
" border-style:solid;\n"
" border-color:rgba(255, 255, 255, 0);\n"
"}\n"
"QLabel{\n"
" background-color: rgb(45, 41, 38);\n"
" color:rgb(233, 75, 60);\n"
" font: 12pt \"Segoe UI\",;\n"
" font-weight:bold;\n"
" border-radius:9px;\n"
"}"));
verticalLayout_39 = new QVBoxLayout(page);
verticalLayout_39->setObjectName(QString::fromUtf8("verticalLayout_39"));
label_40 = new QLabel(page);
label_40->setObjectName(QString::fromUtf8("label_40"));
sizePolicy8.setHeightForWidth(label_40->sizePolicy().hasHeightForWidth());
label_40->setSizePolicy(sizePolicy8);
label_40->setMinimumSize(QSize(100, 50));
label_40->setAlignment(Qt::AlignCenter);
verticalLayout_39->addWidget(label_40, 0, Qt::AlignHCenter);
frame = new QFrame(page);
frame->setObjectName(QString::fromUtf8("frame"));
sizePolicy8.setHeightForWidth(frame->sizePolicy().hasHeightForWidth());
frame->setSizePolicy(sizePolicy8);
frame->setMinimumSize(QSize(0, 80));
frame->setFrameShape(QFrame::StyledPanel);
frame->setFrameShadow(QFrame::Raised);
verticalLayout_43 = new QVBoxLayout(frame);
verticalLayout_43->setObjectName(QString::fromUtf8("verticalLayout_43"));
pushButton_12 = new QPushButton(frame);
pushButton_12->setObjectName(QString::fromUtf8("pushButton_12"));
sizePolicy6.setHeightForWidth(pushButton_12->sizePolicy().hasHeightForWidth());
pushButton_12->setSizePolicy(sizePolicy6);
pushButton_12->setMinimumSize(QSize(180, 30));
verticalLayout_43->addWidget(pushButton_12);
pushButton_13 = new QPushButton(frame);
pushButton_13->setObjectName(QString::fromUtf8("pushButton_13"));
sizePolicy6.setHeightForWidth(pushButton_13->sizePolicy().hasHeightForWidth());
pushButton_13->setSizePolicy(sizePolicy6);
pushButton_13->setMinimumSize(QSize(180, 30));
verticalLayout_43->addWidget(pushButton_13, 0, Qt::AlignHCenter);
verticalLayout_39->addWidget(frame, 0, Qt::AlignHCenter);
stackedWidget->addWidget(page);
verticalLayout_25->addWidget(stackedWidget);
GestionLocation->setCentralWidget(centralwidget);
retranslateUi(GestionLocation);
QObject::connect(quit, &QPushButton::clicked, GestionLocation, qOverload<>(&QMainWindow::close));
QObject::connect(quit2, &QPushButton::clicked, GestionLocation, qOverload<>(&QMainWindow::close));
QObject::connect(quit2_2, &QPushButton::clicked, GestionLocation, qOverload<>(&QMainWindow::close));
QObject::connect(quit2_3, &QPushButton::clicked, GestionLocation, qOverload<>(&QMainWindow::close));
QObject::connect(pushButton_13, &QPushButton::clicked, GestionLocation, qOverload<>(&QMainWindow::close));
stackedWidget->setCurrentIndex(0);
QMetaObject::connectSlotsByName(GestionLocation);
} // setupUi
void retranslateUi(QMainWindow *GestionLocation)
{
GestionLocation->setWindowTitle(QCoreApplication::translate("GestionLocation", "GestionLocation", nullptr));
maintitle->setText(QCoreApplication::translate("GestionLocation", "Menu Principal", nullptr));
rental->setText(QCoreApplication::translate("GestionLocation", "Location", nullptr));
managecar->setText(QCoreApplication::translate("GestionLocation", "Gestion Voiture", nullptr));
manageclient->setText(QCoreApplication::translate("GestionLocation", "Gestion Client", nullptr));
quit->setText(QCoreApplication::translate("GestionLocation", "Quitter", nullptr));
carrental->setText(QCoreApplication::translate("GestionLocation", "Location d'une Voiture", nullptr));
showcontract->setText(QCoreApplication::translate("GestionLocation", "Visualiser Contrat", nullptr));
rentcar->setText(QCoreApplication::translate("GestionLocation", "Louer Voiture", nullptr));
returncar->setText(QCoreApplication::translate("GestionLocation", "Retourner Voiture", nullptr));
modcontract->setText(QCoreApplication::translate("GestionLocation", "Modifier Contrat", nullptr));
delcontract->setText(QCoreApplication::translate("GestionLocation", "Supprimer Contrat", nullptr));
return2->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
cartitle->setText(QCoreApplication::translate("GestionLocation", "Gestion des Voitures", nullptr));
listcar->setText(QCoreApplication::translate("GestionLocation", "Liste des Voitures", nullptr));
addcar->setText(QCoreApplication::translate("GestionLocation", "Ajouter Voiture", nullptr));
modcar->setText(QCoreApplication::translate("GestionLocation", "Modifier Voiture", nullptr));
delcar->setText(QCoreApplication::translate("GestionLocation", "Supprimer Voiture", nullptr));
return1->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
client->setText(QCoreApplication::translate("GestionLocation", "Gestion des Clients", nullptr));
listclient->setText(QCoreApplication::translate("GestionLocation", "Liste des Clients", nullptr));
addclient->setText(QCoreApplication::translate("GestionLocation", "Ajouter Client", nullptr));
modclient->setText(QCoreApplication::translate("GestionLocation", "Modifier Client", nullptr));
delclient->setText(QCoreApplication::translate("GestionLocation", "Supprimer Client", nullptr));
return3->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
carlist->setText(QString());
addcar2->setText(QCoreApplication::translate("GestionLocation", "Ajouter Voiture", nullptr));
return4->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
quit2->setText(QCoreApplication::translate("GestionLocation", "Quitter", nullptr));
label->setText(QCoreApplication::translate("GestionLocation", "ID Voiture", nullptr));
idvoit->setPlaceholderText(QString());
label_2->setText(QCoreApplication::translate("GestionLocation", "Marque", nullptr));
marque->setPlaceholderText(QString());
label_3->setText(QCoreApplication::translate("GestionLocation", "Nom Voiture", nullptr));
label_4->setText(QCoreApplication::translate("GestionLocation", "Couleur", nullptr));
label_5->setText(QCoreApplication::translate("GestionLocation", "Nombre des Places", nullptr));
label_6->setText(QCoreApplication::translate("GestionLocation", "Prix Jour", nullptr));
savereturn->setText(QCoreApplication::translate("GestionLocation", "Enregistrer", nullptr));
return_3->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
label_13->setText(QCoreApplication::translate("GestionLocation", "Modifier Voiture", nullptr));
label_14->setText(QCoreApplication::translate("GestionLocation", "ID de Voiture pour modifier", nullptr));
recherche->setText(QCoreApplication::translate("GestionLocation", "Rechercher", nullptr));
result->setText(QString());
label_7->setText(QCoreApplication::translate("GestionLocation", "ID Voiture", nullptr));
idvoit_2->setPlaceholderText(QString());
label_8->setText(QCoreApplication::translate("GestionLocation", "Marque", nullptr));
label_9->setText(QCoreApplication::translate("GestionLocation", "Nom Voiture", nullptr));
label_10->setText(QCoreApplication::translate("GestionLocation", "Couleur", nullptr));
label_11->setText(QCoreApplication::translate("GestionLocation", "Nombre des Places", nullptr));
label_12->setText(QCoreApplication::translate("GestionLocation", "Prix Jour", nullptr));
marque_2->setPlaceholderText(QString());
savereturn_2->setText(QCoreApplication::translate("GestionLocation", "Enregistrer", nullptr));
return_6->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
clientlist->setText(QCoreApplication::translate("GestionLocation", "TextLabel", nullptr));
addclient_2->setText(QCoreApplication::translate("GestionLocation", "Ajouter Client", nullptr));
return4_2->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
quit2_2->setText(QCoreApplication::translate("GestionLocation", "Quitter", nullptr));
label_15->setText(QCoreApplication::translate("GestionLocation", "ID Client", nullptr));
idclient->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Taper ici", nullptr));
label_16->setText(QCoreApplication::translate("GestionLocation", "Nom", nullptr));
nom->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Taper ici", nullptr));
label_17->setText(QCoreApplication::translate("GestionLocation", "Prenom", nullptr));
label_18->setText(QCoreApplication::translate("GestionLocation", "CIN", nullptr));
cin->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Taper ici", nullptr));
label_19->setText(QCoreApplication::translate("GestionLocation", "Adresse", nullptr));
adresse->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Taper ici", nullptr));
label_20->setText(QCoreApplication::translate("GestionLocation", "Telephone", nullptr));
telephone->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Taper ici", nullptr));
prenom->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Taper ici", nullptr));
savereturn_3->setText(QCoreApplication::translate("GestionLocation", "Enregistrer", nullptr));
return_7->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
label_21->setText(QCoreApplication::translate("GestionLocation", "ID de Client pour modifier", nullptr));
recherche_2->setText(QCoreApplication::translate("GestionLocation", "Rechercher", nullptr));
result_2->setText(QString());
label_22->setText(QCoreApplication::translate("GestionLocation", "ID Client", nullptr));
idclient_2->setPlaceholderText(QString());
label_23->setText(QCoreApplication::translate("GestionLocation", "Nom", nullptr));
nom_2->setPlaceholderText(QString());
label_24->setText(QCoreApplication::translate("GestionLocation", "Prenom", nullptr));
label_25->setText(QCoreApplication::translate("GestionLocation", "CIN", nullptr));
label_26->setText(QCoreApplication::translate("GestionLocation", "Adresse", nullptr));
label_27->setText(QCoreApplication::translate("GestionLocation", "Telephone", nullptr));
savereturn_4->setText(QCoreApplication::translate("GestionLocation", "Enregistrer", nullptr));
return_8->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
list->setText(QString());
label_29->setText(QCoreApplication::translate("GestionLocation", "ID de voiture pour supprimer", nullptr));
deletecar_2->setText(QCoreApplication::translate("GestionLocation", "Supprimer", nullptr));
delmsg->setText(QString());
return_5->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
list_3->setText(QString());
label_44->setText(QCoreApplication::translate("GestionLocation", "ID de client pour supprimer", nullptr));
deleteclient_2->setText(QCoreApplication::translate("GestionLocation", "Supprimer", nullptr));
delmsg_3->setText(QString());
return_4->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
label_51->setText(QCoreApplication::translate("GestionLocation", "ID Client", nullptr));
id_client->setPlaceholderText(QString());
label_52->setText(QCoreApplication::translate("GestionLocation", "ID Voiture", nullptr));
id_car->setPlaceholderText(QString());
search->setText(QCoreApplication::translate("GestionLocation", "Recherche", nullptr));
return_10->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
searchresult->setText(QString());
label_28->setText(QCoreApplication::translate("GestionLocation", "Numero du Contrat", nullptr));
numcontrat->setPlaceholderText(QString());
label_33->setText(QCoreApplication::translate("GestionLocation", "ID Voiture", nullptr));
label_30->setText(QCoreApplication::translate("GestionLocation", "ID Client", nullptr));
id_client_2->setPlaceholderText(QString());
debutjj->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Jour", nullptr));
debutmm->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Mois", nullptr));
debutaa->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Annee", nullptr));
label_32->setText(QCoreApplication::translate("GestionLocation", "Date Fin", nullptr));
label_31->setText(QCoreApplication::translate("GestionLocation", "Date Debut", nullptr));
finjj->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Jour", nullptr));
finmm->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Mois", nullptr));
finaa->setPlaceholderText(QCoreApplication::translate("GestionLocation", "Annee", nullptr));
label_34->setText(QCoreApplication::translate("GestionLocation", "Cout", nullptr));
return_2->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
label_35->setText(QCoreApplication::translate("GestionLocation", "ID Client", nullptr));
findclient->setText(QCoreApplication::translate("GestionLocation", "Recherche", nullptr));
feedback->setText(QString());
addcar2_2->setText(QCoreApplication::translate("GestionLocation", "Ajouter Voiture", nullptr));
return4_3->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
quit2_3->setText(QCoreApplication::translate("GestionLocation", "Quitter", nullptr));
label_50->setText(QCoreApplication::translate("GestionLocation", "Voiture Valable", nullptr));
label_46->setText(QCoreApplication::translate("GestionLocation", "Saisir ID de Voiture", nullptr));
validate->setText(QCoreApplication::translate("GestionLocation", "Valider", nullptr));
availablecars->setText(QString());
label_45->setText(QCoreApplication::translate("GestionLocation", "Saisir La duree de la location", nullptr));
label_36->setText(QCoreApplication::translate("GestionLocation", "Numero du Contrat", nullptr));
label_49->setText(QCoreApplication::translate("GestionLocation", "Date Debut", nullptr));
label_47->setText(QCoreApplication::translate("GestionLocation", "Date Fin", nullptr));
label_48->setText(QCoreApplication::translate("GestionLocation", "Cout", nullptr));
numcontrat_2->setPlaceholderText(QString());
saverent->setText(QCoreApplication::translate("GestionLocation", "Enregistrer", nullptr));
return_9->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
label_53->setText(QCoreApplication::translate("GestionLocation", "Entrez ID de votre voiture", nullptr));
contratsearch->setText(QCoreApplication::translate("GestionLocation", "Recherche", nullptr));
modcontratsearch->setText(QString());
label_38->setText(QCoreApplication::translate("GestionLocation", "ID Client", nullptr));
label_39->setText(QCoreApplication::translate("GestionLocation", "ID Voiture", nullptr));
label_54->setText(QCoreApplication::translate("GestionLocation", "Date Debut", nullptr));
label_55->setText(QCoreApplication::translate("GestionLocation", "Date Fin", nullptr));
label_56->setText(QCoreApplication::translate("GestionLocation", "Cout", nullptr));
numcontrat_3->setPlaceholderText(QString());
label_37->setText(QCoreApplication::translate("GestionLocation", "Numero du Contrat", nullptr));
save->setText(QCoreApplication::translate("GestionLocation", "Enregistrer", nullptr));
return_11->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
list_2->setText(QString());
label_43->setText(QCoreApplication::translate("GestionLocation", "ID de voiture pour supprimer", nullptr));
delcontrat->setText(QCoreApplication::translate("GestionLocation", "Supprimer", nullptr));
delmsg_2->setText(QString());
return_12->setText(QCoreApplication::translate("GestionLocation", "Retour", nullptr));
label_40->setText(QCoreApplication::translate("GestionLocation", "ERREUR", nullptr));
pushButton_12->setText(QCoreApplication::translate("GestionLocation", "Retour au menu principal", nullptr));
pushButton_13->setText(QCoreApplication::translate("GestionLocation", "Quitter", nullptr));
} // retranslateUi
};
namespace Ui {
class GestionLocation: public Ui_GestionLocation {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_GESTIONLOCATION_H
| [
"noreply@github.com"
] | noreply@github.com |
75e87773d1f1e7518c6a2a0b8940c808690df597 | 4f471ce9ef3d95180587030e4e9c246601a0421a | /src/vecutils.h | 1a666059652cedeb6c64df45a8d1d6f0fa660490 | [
"MIT"
] | permissive | alexanderlarin/pynocchio | f7078e06f65d4dbed15af7e58f1a08c611874407 | 9efaeac3363a2dc6cbfeea88ff52b10c4678728a | refs/heads/master | 2020-05-24T16:50:03.108624 | 2019-06-03T14:04:10 | 2019-06-03T14:04:10 | 187,369,655 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,547 | h | /* This file is part of the Pinocchio automatic rigging library.
Copyright (C) 2007 Ilya Baran (ibaran@mit.edu)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef VECUTILS_H
#define VECUTILS_H
#include "vector.h"
template<class Real>
void getBasis(const Vector<Real, 3> &n, Vector<Real, 3> &v1, Vector<Real, 3> &v2)
{
if(n.lengthsq() < Real(1e-16)) {
v1 = Vector<Real, 3>(1., 0., 0.);
v2 = Vector<Real, 3>(0., 1., 0.);
return;
}
if(fabs(n[0]) <= fabs(n[1]) && fabs(n[0]) <= fabs(n[2]))
v2 = Vector<Real, 3>(1., 0., 0.);
else if(fabs(n[1]) <= fabs(n[2]))
v2 = Vector<Real, 3>(0., 1., 0.);
else
v2 = Vector<Real, 3>(0., 0., 1.);
v1 = (n % v2).normalize(); //first basis vector
v2 = (n % v1).normalize(); //second basis vector
}
template<class Real, int Dim>
Real distsqToLine(const Vector<Real, Dim> &v, const Vector<Real, Dim> &l, const Vector<Real, Dim> &dir)
{
return max(Real(), (v - l).lengthsq() - SQR((v - l) * dir) / dir.lengthsq());
}
template<class Real, int Dim>
Vector<Real, Dim> projToLine(const Vector<Real, Dim> &v, const Vector<Real, Dim> &l, const Vector<Real, Dim> &dir)
{
return l + (((v - l) * dir) / dir.lengthsq()) * dir;
}
template<class Real, int Dim>
Real distsqToSeg(const Vector<Real, Dim> &v, const Vector<Real, Dim> &p1, const Vector<Real, Dim> &p2)
{
typedef Vector<Real, Dim> Vec;
Vec dir = p2 - p1;
Vec difp2 = p2 - v;
if(difp2 * dir < Real())
return difp2.lengthsq();
Vec difp1 = v - p1;
Real dot = difp1 * dir;
if(dot <= Real())
return difp1.lengthsq();
return max(Real(), difp1.lengthsq() - SQR(dot) / dir.lengthsq());
}
template<class Real, int Dim>
Vector<Real, Dim> projToSeg(const Vector<Real, Dim> &v, const Vector<Real, Dim> &p1, const Vector<Real, Dim> &p2)
{
typedef Vector<Real, Dim> Vec;
Vec dir = p2 - p1;
if((p2 - v) * dir < Real())
return p2;
Real dot = (v - p1) * dir;
if(dot <= Real())
return p1;
return p1 + (dot / dir.lengthsq()) * dir;
}
//d is distance between centers, r1 and r2 are radii
template<class Real>
Real getCircleIntersectionArea(const Real &d, const Real &r1, const Real &r2)
{
Real tol(1e-8);
if(r1 + r2 <= d + tol)
return Real();
if(r1 + d <= r2 + tol)
return Real(M_PI) * SQR(r1);
if(r2 + d <= r1 + tol)
return Real(M_PI) * SQR(r2);
Real sqrdif = SQR(r1) - SQR(r2);
Real dsqrdif = SQR(d) - sqrdif; //d^2 - r1^2 + r2^2
Real a1 = SQR(r1) * acos((SQR(d) + sqrdif) / (Real(2.) * r1 * d));
Real a2 = SQR(r2) * acos(dsqrdif / (Real(2.) * r2 * d));
return a1 + a2 - Real(0.5) * sqrt(SQR(Real(2.) * d * r2) - SQR(dsqrdif));
}
template<class Real>
Vector<Real, 3> projToTri(const Vector<Real, 3> &from, const Vector<Real, 3> &p1, const Vector<Real, 3> &p2, const Vector<Real, 3> &p3)
{
typedef Vector<Real, 3> Vec;
Real tolsq(1e-16);
Vec p2p1 = (p2 - p1);
Vec p3p1 = (p3 - p1);
Vec normal = p2p1 % p3p1;
if((p2p1 % (from - p1)) * normal >= Real()) { //inside s1
bool s2 = ((p3 - p2) % (from - p2)) * normal >= Real();
bool s3 = (p3p1 % (from - p3)) * normal <= Real();
if(s2 && s3) {
if(normal.lengthsq() < tolsq)
return p1; //incorrect, but whatever...
double dot = (from - p3) * normal;
return from - (dot / normal.lengthsq()) * normal;
}
if(!s3 && (s2 || (from - p3) * p3p1 >= Real()))
return projToSeg(from, p3, p1);
return projToSeg(from, p2, p3);
}
//outside s1
if((from - p1) * p2p1 < Real())
return projToSeg(from, p3, p1);
if((from - p2) * p2p1 > Real())
return projToSeg(from, p2, p3);
return projToLine(from, p1, p2p1);
}
#endif //VECUTILS_H
| [
"ekzebox@gmail.com"
] | ekzebox@gmail.com |
8f4d146d3fc755f3dd979638a0261ea96ca2abc8 | 134c459eaff6fc653726123d54e8f2f198865e16 | /gooseEscapeGamePlay.cpp | f4f668601ddf2d176fe3f32c461ea40eb89b077b | [] | no_license | jdumanski/Goose-Escape-Game-C- | 142413068c070a764e2277eae2ba27d4c06231e6 | eb4d9a492af0eac7af635b24ec8b4d1d6d2f8fbe | refs/heads/main | 2023-04-12T07:19:35.141362 | 2021-05-10T03:19:42 | 2021-05-10T03:19:42 | 365,329,874 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,809 | cpp | //THIS THE START OF THE gooseEscapeGamePlay.cpp FILE
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#include <BearLibTerminal.h>
#include "gooseEscapeUtil.hpp"
#include "gooseEscapeActors.hpp"
#include "gooseEscapeConsole.hpp"
#include "gooseEscapeGamePlay.hpp"
extern Console out;
void print(int gameBoard[NUM_BOARD_Y][NUM_BOARD_X])
{
for(int coord_Y = 0; coord_Y < NUM_BOARD_Y; coord_Y++)
{
for(int coord_X = 0; coord_X < NUM_BOARD_X; coord_X++)
{
if(gameBoard[coord_Y][coord_X]==SHALL_NOT_PASS)
{
terminal_put(coord_X, coord_Y, WALL_CHAR);
}
else if(gameBoard[coord_Y][coord_X]==WINNER)
{
terminal_put(coord_X, coord_Y, WIN_CHAR);
}
}
}
}
//this function ends the game and outputs a message when the player is caught
bool captured(Actor const & player, Actor const & monster)
{
bool capture = false;
if(player.get_x() == monster.get_x() && player.get_y() == monster.get_y())
{
out.writeLine("The geese have eaten you :/");
capture = true;
}
return capture;
}
void randomLocation(int & randXcoord, int & randYcoord, int gameBoard[NUM_BOARD_Y][NUM_BOARD_X])
{
bool search = true;
srand(time(0));
do
{
randXcoord = (rand()%NUM_BOARD_X);
randYcoord = (rand()%NUM_BOARD_Y);
if((randXcoord > WALL4X+WALLTHICK || randXcoord < WALL2X) &&
(randYcoord > WALL3Y+WALLTHICK || randYcoord < WALL1Y))
{
search = false;
}
}
while(search);
}
void playerHitSpeedPow(Actor & player, Actor & powerUp, int & turnCount,
int & powSpeedCounter)
{
if(powerUp.get_active()==true)
{
powSpeedCounter++;
player.changeSpeed(SPEED2);
turnCount = POWER_UP_LENGTH;
powerUp.set_active(false);
}
}
//this functions moves the player depending of the user input using the arrow keys
void movePlayer(int key, Actor & player, int gameBoard[NUM_BOARD_Y][NUM_BOARD_X])
{
int yMove = 0, xMove = 0;
int pSpeed = player.get_speed();
if (key == TK_UP)
yMove = -pSpeed;
else if (key == TK_DOWN)
yMove = pSpeed;
else if (key == TK_LEFT)
xMove = -pSpeed;
else if (key == TK_RIGHT)
xMove = pSpeed;
/*this if statement only allows the player to move to valid locations. The
player cannot go through walls or off of the screen*/
if (player.can_move(xMove, yMove)
&& gameBoard[player.get_y()+yMove][player.get_x()+xMove] != SHALL_NOT_PASS)
player.update_location(xMove, yMove);
}
/*this function ends the game and outputs a message when the player
reaches the safe space and wins*/
bool win(Actor const & player)
{
bool win = false;
if((player.get_x() == WINX && player.get_y() == WINY))
{
out.writeLine("you win :)");
win = true;
}
return win;
}
//sets up the wall obstacles
void wallSet(int row, int col, int thickness, int wall_length,
int gameBoard[NUM_BOARD_Y][NUM_BOARD_X], char action)
{
for(int count = 0; count < thickness; count++)
{
int store = col;
while(store < col+wall_length)
{
if(action=='P')
{
gameBoard[row+count][store] = SHALL_NOT_PASS;
}
else if(action=='D')
{
gameBoard[row+count][store] = EMPTY;
terminal_clear_area(col, row, wall_length, thickness);
}
store++;
}
}
}
//this function contains an algorithm that makes the monster chase the player
void chasingPerson(Actor const & player, Actor & monster,
int gameBoard[NUM_BOARD_Y][NUM_BOARD_X])
{
int mSpeed = monster.get_speed();
if(monster.get_x()>player.get_x()) // Monster is to the right of player
{
if(monster.get_y()>player.get_y()) // Monster is below player
{
monster.update_location(-mSpeed,-mSpeed);
}
else if(monster.get_y()<player.get_y()) // Monster is above player
{
monster.update_location(-mSpeed,mSpeed);
}
else // Monster is leveled horizontally with player
{
monster.update_location(-mSpeed,0);
}
}
else if(monster.get_x()<player.get_x()) // Monster is to the left of player
{
if(monster.get_y()>player.get_y()) // Monster is below player
{
monster.update_location(mSpeed,-mSpeed);
}
else if(monster.get_y()<player.get_y()) // Monster is above player
{
monster.update_location(mSpeed,mSpeed);
}
else // monster is leveled with player horizontally
{
monster.update_location(mSpeed,0);
}
}
else // Monster is aligned vertically with the player
{
// Monster is below the player
if(monster.get_y()>player.get_y())
{
monster.update_location(0,-mSpeed);
}
// Monster is above the player
else if(monster.get_y()<player.get_y())
{
monster.update_location(0,mSpeed);
}
}
}
//THIS THE END OF THE gooseEscapeGamePlay.cpp FILE
| [
"noreply@github.com"
] | noreply@github.com |
f34d560d399926b22f824bde2b95e6f1a3cf1422 | 8f56fa3043804b33363c7805e6b84b50b1114aca | /Armazon/ThreadColaAlisto.h | 4d0ac2867565e630a34c8316eb637c634ef2101b | [] | no_license | Stuart-Sandi/data_structures_simulation | e5d1adb6201a5cad87cfef9119e2a90f34d6d18c | 79077809c3f679f925699162b3cd678a078fea04 | refs/heads/master | 2022-11-11T08:23:37.127445 | 2020-06-23T00:14:53 | 2020-06-23T00:14:53 | 269,738,206 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 745 | h | #ifndef THREADCOLAALISTO_H
#define THREADCOLAALISTO_H
#include <QtCore>
#include <QList>
#include <ColaPedidos.h>
#include <funcionesArchivos.h>
#include <QMutex>
class ThreadColaAlisto : public QThread
{
Q_OBJECT
public:
bool pausa;
QList <Pedido*> * pedidos;
ColaPedidos * colaAlisto;
int finalizados;
QMutex * mutex1;
funcionesArchivos * fA;
ThreadColaAlisto(QList <Pedido*>*,ColaPedidos*,QMutex*);
void run() override;
signals:
void datosBalanceador(QString,QString);
void datosCola(QString,QString);//ASIGNA LOS DATOS DE PEDIDOS ATENDIDOS Y CANTIDAD EN COLA
void datosCola2(QString, QString);//ASIGNA LOS DATOS DE CANTIDAD EN COLA Y CANTIDAD DESENCOLADOS
};
#endif // THREADCOLAALISTO_H
| [
"stuartsandi43@gmail.com"
] | stuartsandi43@gmail.com |
94b2bbd5c3e938b51acabe6066e5455c72b64dc4 | 46d4712c82816290417d611a75b604d51b046ecc | /Samples/Win7Samples/winbase/imapi/imapi2sample/DataWriter2Event.cpp | 37ac6d636ee6b3f2846102c1716c5034a492a223 | [
"MIT"
] | permissive | ennoherr/Windows-classic-samples | 00edd65e4808c21ca73def0a9bb2af9fa78b4f77 | a26f029a1385c7bea1c500b7f182d41fb6bcf571 | refs/heads/master | 2022-12-09T20:11:56.456977 | 2022-12-04T16:46:55 | 2022-12-04T16:46:55 | 156,835,248 | 1 | 0 | NOASSERTION | 2022-12-04T16:46:55 | 2018-11-09T08:50:41 | null | UTF-8 | C++ | false | false | 3,167 | cpp | /* Copyright (c) Microsoft Corporation. All rights reserved. */
#include "DataWriter2Event.h"
STDMETHODIMP_(VOID) CTestDataWriter2Event::Update(IDispatch* objectDispatch, IDispatch* progressDispatch)
{
//UNREFERENCED_PARAMETER (objectDispatch);
HRESULT hr = S_OK;
IDiscFormat2DataEventArgs* progress = NULL;
IDiscFormat2Data* object = NULL;
LONG elapsedTime = 0;
LONG remainingTime = 0;
LONG totalTime = 0;
IMAPI_FORMAT2_DATA_WRITE_ACTION currentAction = IMAPI_FORMAT2_DATA_WRITE_ACTION_VALIDATING_MEDIA;
LONG startLba = 0;
LONG sectorCount = 0;
LONG lastReadLba = 0;
LONG lastWrittenLba = 0;
LONG totalSystemBuffer = 0;
LONG usedSystemBuffer = 0;
LONG freeSystemBuffer = 0;
hr = progressDispatch->QueryInterface(IID_PPV_ARGS(&progress));
hr = objectDispatch->QueryInterface(IID_PPV_ARGS(&object));
if ((SUCCEEDED(progress->get_ElapsedTime(&elapsedTime) )) &&
(SUCCEEDED(progress->get_RemainingTime(&remainingTime) )) &&
(SUCCEEDED(progress->get_TotalTime(&totalTime) )) &&
(SUCCEEDED(progress->get_CurrentAction(¤tAction) )) &&
(SUCCEEDED(progress->get_StartLba(&startLba) )) &&
(SUCCEEDED(progress->get_SectorCount(§orCount) )) &&
(SUCCEEDED(progress->get_LastReadLba(&lastReadLba) )) &&
(SUCCEEDED(progress->get_LastWrittenLba(&lastWrittenLba) )) &&
(SUCCEEDED(progress->get_TotalSystemBuffer(&totalSystemBuffer))) &&
(SUCCEEDED(progress->get_UsedSystemBuffer(&usedSystemBuffer) )) &&
(SUCCEEDED(progress->get_FreeSystemBuffer(&freeSystemBuffer) ))
)
{
if (currentAction == IMAPI_FORMAT2_DATA_WRITE_ACTION_VALIDATING_MEDIA)
{
DeleteCurrentLine();
printf("Validating media... ");
}
else if (currentAction == IMAPI_FORMAT2_DATA_WRITE_ACTION_FORMATTING_MEDIA)
{
DeleteCurrentLine();
printf("Formatting media... ");
}
else if (currentAction == IMAPI_FORMAT2_DATA_WRITE_ACTION_INITIALIZING_HARDWARE)
{
DeleteCurrentLine();
printf("Initializing hardware... ");
}
else if (currentAction == IMAPI_FORMAT2_DATA_WRITE_ACTION_CALIBRATING_POWER)
{
DeleteCurrentLine();
printf("Calibrating power... ");
}
else if (currentAction == IMAPI_FORMAT2_DATA_WRITE_ACTION_WRITING_DATA)
{
DeleteCurrentLine();
printf("[%08x..%08x] ", startLba, startLba + sectorCount);
UpdatePercentageDisplay(lastWrittenLba - startLba, sectorCount);
}
else if (currentAction == IMAPI_FORMAT2_DATA_WRITE_ACTION_FINALIZATION)
{
DeleteCurrentLine();
OverwriteCurrentLine();
DeleteCurrentLine();
printf("Finishing writing operation...");
}
else if (currentAction == IMAPI_FORMAT2_DATA_WRITE_ACTION_COMPLETED)
{
printf("Write has completed!\n");
}
}
return;
}
| [
"chrisg@microsoft.com"
] | chrisg@microsoft.com |
2a37d747fed78a4f3f837d285fa90d8cfb301667 | 7f4d0c606321e31b23e32aaaa21213f503016c4f | /103-Binary Tree Zigzag Level Order Traversal.cpp | 8964943d4616c9f678c3d0612e7a7ce10883b478 | [] | no_license | fangpan2018/Algorithm-Camp | 943d720beaa7668cd34ffaaf4d756ebac1b3322e | 87acbf3ec8eedeacde580fa7c7e85b45ff283c8c | refs/heads/master | 2021-01-07T20:08:34.201480 | 2020-05-05T14:15:26 | 2020-05-05T14:15:26 | 241,808,189 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,167 | cpp | // faster than 100.00%
// less than 79.07%
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
vector<vector<int>> zigzagLevelOrder(TreeNode* root) {
if (!root) return {};
queue<TreeNode*> q;
vector<vector<int>> ret;
q.push(root);
int level = 0;
while (!q.empty()) {
int sz = q.size();
vector<int> curr(sz);
for (int i = 0; i < sz; i++) {
TreeNode* tmp = q.front();
q.pop();
if (level == 0) {
curr[i] = tmp->val;
} else {
curr[sz - i - 1] = tmp->val;
}
if (tmp->left) q.push(tmp->left);
if (tmp->right) q.push(tmp->right);
}
ret.push_back(curr);
level = !level;
}
return ret;
}
}; | [
"pan@MacBook-Pro.local"
] | pan@MacBook-Pro.local |
2f9113754150e3594b086128227e36da2370b8f9 | 352c846e5fea449ffbdb6a88f6448bb14439cbf8 | /Source/MainComponent.cpp | d09d70d1c18f343beb3536a7a242b9ed5dec335f | [] | no_license | lfreites/NewProject | adbe865f3b085ebee84cb9951168610869906e48 | 7982d2307153842baf1c2e8aa7a131e6e934d41f | refs/heads/master | 2021-04-22T21:39:18.225162 | 2020-04-02T17:45:16 | 2020-04-02T17:45:16 | 249,876,020 | 0 | 0 | null | 2020-04-02T17:45:18 | 2020-03-25T03:15:51 | C++ | UTF-8 | C++ | false | false | 1,059 | cpp | /*
==============================================================================
This file was auto-generated!
==============================================================================
*/
#include "MainComponent.h"
//==============================================================================
MainComponent::MainComponent()
{
setSize (600, 400);
}
MainComponent::~MainComponent()
{
}
//==============================================================================
void MainComponent::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
g.setFont (Font (16.0f));
g.setColour (Colours::forestgreen);
g.drawText ("Hello World!", getLocalBounds(), Justification::centredLeft, true);
}
void MainComponent::resized()
{
// This is called when the MainComponent is resized.
// If you add any child components, this is where you should
// update their positions.
}
| [
"lucas_freites@hotmail.com"
] | lucas_freites@hotmail.com |
aca26aaaebd0347bb671df6f576f1448e33d4bdc | 13e5f410ab11d883f2a3c8040bf87a6aa76bfa05 | /count_inversions.cpp | c99a618940f8847062be3a35671ffcc9640e6631 | [] | no_license | gitynity/Cpp_Collection | ad8e5555ed5616f9d03c786a34faf836a378a416 | 68e0fc47130eed9a6a0b86ae672c9da2d671982c | refs/heads/master | 2023-09-03T18:11:32.913869 | 2021-11-06T09:19:04 | 2021-11-06T09:19:04 | 73,297,672 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,073 | cpp | //https://www.geeksforgeeks.org/counting-inversions/
#include <bits/stdc++.h>
using namespace std;
int inv_count = 0;
void merge_count(int *a, int l, int m, int r)
{
int n1 = m - l + 1;
int n2 = r - m;
int left[n1], right[n2];
for (int i = 0; i < n1; i++)
left[i] = a[i+l];
for (int j = 0; j < n2; j++)
right[j] = a[j+m+1];
int i = 0, j = 0, k = l;
while (i < n1 and j < n2)
{
if (left[i] < right[j])
{
a[k++] = left[i++];
}
else if (left[i] > right[j])
{
a[k++] = right[j++];
inv_count += n1 - i;
}
}
while (i < n1)
{
a[k++] = left[i++];
}
while (j < n2)
{
a[k++] = right[j++];
}
}
void count_inverse(int *a, int l, int r)
{
if (r > l)
{
int m = l + (r - l) / 2;
count_inverse(a, l, m);
count_inverse(a, m + 1, r);
merge_count(a, l, m, r);
}
}
int main()
{
int a[] = {2, 5, 4, 1, 3};
count_inverse(a, 0, 4);
cout << inv_count;
}
| [
"noreply@github.com"
] | noreply@github.com |
231b73e2238fc42540b92e25d47dcad90372b4e1 | ee9b28d3198fd25cf3813836c28955fd8b334454 | /euler.cpp | e99118d086c1ecfcb7336054fea5fe0475f72ee0 | [] | no_license | AliTaheriNastooh/Text_for_contest | 4742db75c91ee9a5a2d33b0011cf0aadb0d98fcf | c975837c948a04aae2903f18c9a2aead57ce4d94 | refs/heads/master | 2021-04-29T12:12:05.302243 | 2018-02-16T07:25:15 | 2018-02-16T07:25:15 | 121,724,486 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,980 | cpp | Euler Circuit in a Directed Graph
1) All vertices with nonzero degree belong to a single strongly connected component.
2) In degree and out degree of every vertex is same.
O(V + E)
#include<iostream>
#include <list>
#define CHARS 26
using namespace std;
class Graph
{
int V; // No. of vertices
list<int> *adj; // A dynamic array of adjacency lists
int *in;
public:
// Constructor and destructor
Graph(int V);
~Graph() { delete [] adj; delete [] in; }
void addEdge(int v, int w) { adj[v].push_back(w); (in[w])++; }
bool isEulerianCycle();
bool isSC();
void DFSUtil(int v, bool visited[]);
Graph getTranspose();
};
Graph::Graph(int V)
{
this->V = V;
adj = new list<int>[V];
in = new int[V];
for (int i = 0; i < V; i++)
in[i] = 0;
}
bool Graph::isEulerianCycle()
{
if (isSC() == false)
return false;
for (int i = 0; i < V; i++)
if (adj[i].size() != in[i])
return false;
return true;
}
void Graph::DFSUtil(int v, bool visited[])
{
visited[v] = true;
list<int>::iterator i;
for (i = adj[v].begin(); i != adj[v].end(); ++i)
if (!visited[*i])
DFSUtil(*i, visited);
}
Graph Graph::getTranspose()
{
Graph g(V);
for (int v = 0; v < V; v++)
{
list<int>::iterator i;
for(i = adj[v].begin(); i != adj[v].end(); ++i)
{
g.adj[*i].push_back(v);
(g.in[v])++;
}
}
return g;
}
bool Graph::isSC()
{
bool visited[V];
for (int i = 0; i < V; i++)
visited[i] = false;
int n;
for (n = 0; n < V; n++)
if (adj[n].size() > 0)
break;
DFSUtil(n, visited);
for (int i = 0; i < V; i++)
if (adj[i].size() > 0 && visited[i] == false)
return false;
Graph gr = getTranspose();
for (int i = 0; i < V; i++)
visited[i] = false;
gr.DFSUtil(n, visited);
for (int i = 0; i < V; i++)
if (adj[i].size() > 0 && visited[i] == false)
return false;
return true;
}
int main()
{
// Create a graph given in the above diagram
Graph g(5);
g.addEdge(1, 0);
g.addEdge(0, 2);
g.addEdge(2, 1);
g.addEdge(0, 3);
g.addEdge(3, 4);
g.addEdge(4, 0);
if (g.isEulerianCycle())
cout << "Given directed graph is eulerian n";
else
cout << "Given directed graph is NOT eulerian n";
return 0;
}
------------------------------------------------------------
Eulerian path and circuit for undirected graph
Eulerian Cycle
….a) All vertices with non-zero degree are connected. We don’t care about vertices with zero degree because they don’t belong to Eulerian Cycle or Path (we only consider all edges).
….b) All vertices have even degree.
Eulerian Path
….a) Same as condition (a) for Eulerian Cycle
….b) If zero or two vertices have odd degree and all other vertices have even degree.
O(V+E)
#include<iostream>
#include <list>
using namespace std;
class Graph
{
int V; // No. of vertices
list<int> *adj; // A dynamic array of adjacency lists
public:
Graph(int V) {this->V = V; adj = new list<int>[V]; }
~Graph() { delete [] adj; } // To avoid memory leak
void addEdge(int v, int w);
int isEulerian();
bool isConnected();
void DFSUtil(int v, bool visited[]);
};
void Graph::addEdge(int v, int w)
{
adj[v].push_back(w);
adj[w].push_back(v); // Note: the graph is undirected
}
void Graph::DFSUtil(int v, bool visited[])
{
visited[v] = true;
list<int>::iterator i;
for (i = adj[v].begin(); i != adj[v].end(); ++i)
if (!visited[*i])
DFSUtil(*i, visited);
}
bool Graph::isConnected()
{
bool visited[V];
int i;
for (i = 0; i < V; i++)
visited[i] = false;
for (i = 0; i < V; i++)
if (adj[i].size() != 0)
break;
if (i == V)
return true;
DFSUtil(i, visited);
for (i = 0; i < V; i++)
if (visited[i] == false && adj[i].size() > 0)
return false;
return true;
}
int Graph::isEulerian()
{
if (isConnected() == false)
return 0;
int odd = 0;
for (int i = 0; i < V; i++)
if (adj[i].size() & 1)
odd++;
if (odd > 2)
return 0;
return (odd)? 1 : 2;
}
void test(Graph &g)
{
int res = g.isEulerian();
if (res == 0)
cout << "graph is not Eulerian\n";
else if (res == 1)
cout << "graph has a Euler path\n";
else
cout << "graph has a Euler cycle\n";
}
int main()
{
Graph g1(5);
g1.addEdge(1, 0);
g1.addEdge(0, 2);
g1.addEdge(2, 1);
g1.addEdge(0, 3);
g1.addEdge(3, 4);
test(g1);
Graph g2(5);
g2.addEdge(1, 0);
g2.addEdge(0, 2);
g2.addEdge(2, 1);
g2.addEdge(0, 3);
g2.addEdge(3, 4);
g2.addEdge(4, 0);
test(g2);
Graph g3(5);
g3.addEdge(1, 0);
g3.addEdge(0, 2);
g3.addEdge(2, 1);
g3.addEdge(0, 3);
g3.addEdge(3, 4);
g3.addEdge(1, 3);
test(g3);
Graph g4(3);
g4.addEdge(0, 1);
g4.addEdge(1, 2);
g4.addEdge(2, 0);
test(g4);
Graph g5(3);
test(g5);
return 0;
}
---------------------------------------------------------------
Hierholzer’s Algorithm for directed graph print
http://www.geeksforgeeks.org/hierholzers-algorithm-directed-graph/
O(V+E).
void printCircuit(vector< vector<int> > adj)
{
unordered_map<int,int> edge_count;
for (int i=0; i<adj.size(); i++)
{
//find the count of edges to keep track
//of unused edges
edge_count[i] = adj[i].size();
}
if (!adj.size())
return; //empty graph
stack<int> curr_path;
vector<int> circuit;
curr_path.push(0);
int curr_v = 0; // Current vertex
while (!curr_path.empty())
{
// If there's remaining edge
if (edge_count[curr_v])
{
curr_path.push(curr_v);
int next_v = adj[curr_v].back();
edge_count[curr_v]--;
adj[curr_v].pop_back();
curr_v = next_v;
}
else
{
circuit.push_back(curr_v);
curr_v = curr_path.top();
curr_path.pop();
}
}
for (int i=circuit.size()-1; i>=0; i--)
{
cout << circuit[i];
if (i)
cout<<" -> ";
}
}
int main()
{
vector< vector<int> > adj1, adj2;
// Input Graph 1
adj1.resize(3);
// Build the edges
adj1[0].push_back(1);
adj1[1].push_back(2);
adj1[2].push_back(0);
printCircuit(adj1);
cout << endl;
// Input Graph 2
adj2.resize(7);
adj2[0].push_back(1);
adj2[0].push_back(6);
adj2[1].push_back(2);
adj2[2].push_back(0);
adj2[2].push_back(3);
adj2[3].push_back(4);
adj2[4].push_back(2);
adj2[4].push_back(5);
adj2[5].push_back(0);
adj2[6].push_back(4);
printCircuit(adj2);
return 0;
}
-----------------------------------------------------------------------------------------------------------
Fleury’s Algorithm for printing Eulerian Path or Circuit
O((V+E)*(V+E)) which can be written as O(E2) for a connected graph.
1. Make sure the graph has either 0 or 2 odd vertices.
2. If there are 0 odd vertices, start anywhere. If there are 2 odd vertices, start at one of them.
3. Follow edges one at a time. If you have a choice between a bridge and a non-bridge, always choose the non-bridge.
4. Stop when you run out of edges.
The idea is, “don’t burn bridges“
#include <iostream>
#include <string.h>
#include <algorithm>
#include <list>
using namespace std;
class Graph
{
int V; // No. of vertices
list<int> *adj; // A dynamic array of adjacency lists
public:
Graph(int V) { this->V = V; adj = new list<int>[V]; }
~Graph() { delete [] adj; }
void addEdge(int u, int v) { adj[u].push_back(v); adj[v].push_back(u); }
void rmvEdge(int u, int v);
void printEulerTour();
void printEulerUtil(int s);
int DFSCount(int v, bool visited[]);
bool isValidNextEdge(int u, int v);
};
void Graph::printEulerTour()
{
int u = 0;
for (int i = 0; i < V; i++)
if (adj[i].size() & 1)
{ u = i; break; }
printEulerUtil(u);
cout << endl;
}
void Graph::printEulerUtil(int u)
{
list<int>::iterator i;
for (i = adj[u].begin(); i != adj[u].end(); ++i)
{
int v = *i;
if (v != -1 && isValidNextEdge(u, v))
{
cout << u << "-" << v << " ";
rmvEdge(u, v);
printEulerUtil(v);
}
}
}
bool Graph::isValidNextEdge(int u, int v)
{
int count = 0; // To store count of adjacent vertices
list<int>::iterator i;
for (i = adj[u].begin(); i != adj[u].end(); ++i)
if (*i != -1)
count++;
if (count == 1)
return true;
bool visited[V];
memset(visited, false, V);
int count1 = DFSCount(u, visited);
rmvEdge(u, v);
memset(visited, false, V);
int count2 = DFSCount(u, visited);
addEdge(u, v);
return (count1 > count2)? false: true;
}
void Graph::rmvEdge(int u, int v)
{
list<int>::iterator iv = find(adj[u].begin(), adj[u].end(), v);
*iv = -1;
list<int>::iterator iu = find(adj[v].begin(), adj[v].end(), u);
*iu = -1;
}
int Graph::DFSCount(int v, bool visited[])
{
visited[v] = true;
int count = 1;
list<int>::iterator i;
for (i = adj[v].begin(); i != adj[v].end(); ++i)
if (*i != -1 && !visited[*i])
count += DFSCount(*i, visited);
return count;
}
int main()
{
Graph g1(4);
g1.addEdge(0, 1);
g1.addEdge(0, 2);
g1.addEdge(1, 2);
g1.addEdge(2, 3);
g1.printEulerTour();
Graph g2(3);
g2.addEdge(0, 1);
g2.addEdge(1, 2);
g2.addEdge(2, 0);
g2.printEulerTour();
Graph g3(5);
g3.addEdge(1, 0);
g3.addEdge(0, 2);
g3.addEdge(2, 1);
g3.addEdge(0, 3);
g3.addEdge(3, 4);
g3.addEdge(3, 2);
g3.addEdge(3, 1);
g3.addEdge(2, 4);
g3.printEulerTour();
return 0;
}
| [
"ali.taherinastooh@gmail.com"
] | ali.taherinastooh@gmail.com |
d943ad75be5d32d2e855dd26b791b720bf19b312 | 81c66c9c0b78f8e9c698dcbb8507ec2922efc8b7 | /src/kernel/StringState.cc | fa0d894a1c090ba127478272262672e43c03aafc | [
"MIT-Modern-Variant"
] | permissive | Argonnite/ptolemy | 3394f95d3f58e0170995f926bd69052e6e8909f2 | 581de3a48a9b4229ee8c1948afbf66640568e1e6 | refs/heads/master | 2021-01-13T00:53:43.646959 | 2015-10-21T20:49:36 | 2015-10-21T20:49:36 | 44,703,423 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,713 | cc | static const char file_id[] = "StringState.cc";
/**************************************************************************
Version identification:
@(#)StringState.cc 2.25 03/28/96
Copyright (c) 1990-1997 The Regents of the University of California.
All rights reserved.
Permission is hereby granted, without written agreement and without
license or royalty fees, to use, copy, modify, and distribute this
software and its documentation for any purpose, provided that the
above copyright notice and the following two paragraphs appear in all
copies of this software.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
ENHANCEMENTS, OR MODIFICATIONS.
PT_COPYRIGHT_VERSION_2
COPYRIGHTENDKEY
Programmer: I. Kuroda and J. Buck
Date of creation: 5/26/90
Revisions:
Support value substitution in StringStates, with the syntax
state foo = {foo}
State names within braces are replaced by their values.
Functions for class StringState
**************************************************************************/
#ifdef __GNUG__
#pragma implementation
#endif
#include <std.h>
#include "miscFuncs.h"
#include "StringState.h"
#include "Tokenizer.h"
#define ASCII_CONTROL_B_CHAR 2
/*************************************************************************
class StringState methods
**************************************************************************/
StringState :: StringState() : val(0) {}
const char* StringState :: className() const { return "StringState"; }
const char* StringState :: type() const { return "STRING"; }
void StringState :: initialize() {
// Delete the previously parsed value (set to zero in case of error)
LOG_DEL; delete [] val;
val = 0;
// Make sure that the initial string is not null;
const char* initString = initValue();
if (initString == 0 || *initString == 0) {
val = savestring("");
return;
}
// Parse the initial string
// -- Substitute parameters that fall in between curly braces {}
// -- Zero out the white space characters so string info is unaltered,
// but Tokenizer assumes that the white space string is not empty
const char* specialChars = "!{}";
const char* whiteSpace = "\002";
Tokenizer lexer(initString, specialChars, whiteSpace);
char unprintableChar = ASCII_CONTROL_B_CHAR;
StringList parsedString = "";
// -- Do not treat double quotes as the quotation character:
// we reset the quotation character to be an unprintable character
lexer.setQuoteChar(unprintableChar);
// -- Do not support # for comments: it is used to represent
// frame numbers in video files and to represent port names
// e.g. input#1
lexer.setCommentChar(unprintableChar);
int errorFlag = FALSE;
while (TRUE) {
ParseToken t = getParseToken(lexer, T_STRING);
if (t.tok == T_EOF || t.tok == T_ERROR) {
errorFlag = ( t.tok == T_ERROR );
break;
}
parsedString << t.sval;
delete [] t.sval;
}
if ( errorFlag ) {
StringList msg = "Error parsing the string state: ";
msg << "parsed up to '" << parsedString << "' successfully";
parseError(msg);
}
val = savestring(parsedString);
}
StringState& StringState :: operator=(const char* newStr) {
LOG_DEL; delete [] val;
val = savestring(newStr);
return *this;
}
StringState& StringState :: operator=(StringList& newStrList) {
// Strictly speaking this is not required, but I dont
// really trust two much automatic type conversion.
// Note that we might modify newStrList in the call below
const char* newStr = newStrList;
return (*this = newStr);
}
StringState& StringState :: operator=(const State& newState) {
// Strictly speaking this is not required, but I dont
// really trust two much automatic type conversion.
StringList newStrList = newState.currentValue();
return (*this = newStrList);
}
StringList StringState :: currentValue() const {
StringList res;
if (val) res = val;
return res;
}
State* StringState :: clone() const {
LOG_NEW; return new StringState;
}
StringState :: ~StringState() {
LOG_DEL; delete [] val;
}
// make known state entry
static StringState proto;
static KnownState entry(proto,"STRING");
ISA_FUNC(StringState,State);
| [
"dermalin3k@hotmail.com"
] | dermalin3k@hotmail.com |
188d94480e035a48c09101080d0a076c813f2a6a | 8dc84558f0058d90dfc4955e905dab1b22d12c08 | /chrome/browser/ui/app_list/app_list_client_impl.h | 5d4cabb3b9062c3c53c9b64b6bed50ff60f990d8 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | meniossin/src | 42a95cc6c4a9c71d43d62bc4311224ca1fd61e03 | 44f73f7e76119e5ab415d4593ac66485e65d700a | refs/heads/master | 2022-12-16T20:17:03.747113 | 2020-09-03T10:43:12 | 2020-09-03T10:43:12 | 263,710,168 | 1 | 0 | BSD-3-Clause | 2020-05-13T18:20:09 | 2020-05-13T18:20:08 | null | UTF-8 | C++ | false | false | 5,254 | h | // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_CLIENT_IMPL_H_
#define CHROME_BROWSER_UI_APP_LIST_APP_LIST_CLIENT_IMPL_H_
#include <stdint.h>
#include <memory>
#include <string>
#include "ash/public/interfaces/app_list.mojom.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "chrome/browser/ui/app_list/app_list_controller_impl.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_engines/template_url_service_observer.h"
#include "components/user_manager/user_manager.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace app_list {
class SearchController;
class SearchResourceManager;
} // namespace app_list
class AppListModelUpdater;
class AppSyncUIStateWatcher;
class Profile;
class AppListClientImpl
: public ash::mojom::AppListClient,
public user_manager::UserManager::UserSessionStateObserver,
public TemplateURLServiceObserver {
public:
AppListClientImpl();
~AppListClientImpl() override;
static AppListClientImpl* GetInstance();
// ash::mojom::AppListClient:
void StartSearch(const base::string16& raw_query) override;
void OpenSearchResult(const std::string& result_id, int event_flags) override;
void InvokeSearchResultAction(const std::string& result_id,
int action_index,
int event_flags) override;
void GetSearchResultContextMenuModel(
const std::string& result_id,
GetContextMenuModelCallback callback) override;
void SearchResultContextMenuItemSelected(const std::string& result_id,
int command_id,
int event_flags) override;
void ViewClosing() override;
void ViewShown(int64_t display_id) override;
void ActivateItem(const std::string& id, int event_flags) override;
void GetContextMenuModel(const std::string& id,
GetContextMenuModelCallback callback) override;
void ContextMenuItemSelected(const std::string& id,
int command_id,
int event_flags) override;
void OnAppListTargetVisibilityChanged(bool visible) override;
void OnAppListVisibilityChanged(bool visible) override;
void StartVoiceInteractionSession() override;
void ToggleVoiceInteractionSession() override;
void OnFolderCreated(ash::mojom::AppListItemMetadataPtr item) override;
void OnFolderDeleted(ash::mojom::AppListItemMetadataPtr item) override;
void OnItemUpdated(ash::mojom::AppListItemMetadataPtr item) override;
// user_manager::UserManager::UserSessionStateObserver:
void ActiveUserChanged(const user_manager::User* active_user) override;
// Associates this client with the current active user, called when this
// client is accessed or active user is changed.
void UpdateProfile();
// Shows the app list if it isn't already showing and switches to |state|,
// unless it is |INVALID_STATE| (in which case, opens on the default state).
void ShowAndSwitchToState(ash::AppListState state);
void ShowAppList();
void DismissAppList();
bool app_list_target_visibility() const {
return app_list_target_visibility_;
}
bool app_list_visible() const { return app_list_visible_; }
// Returns a pointer to control the app list views in ash.
ash::mojom::AppListController* GetAppListController() const;
AppListControllerDelegate* GetControllerDelegate();
Profile* GetCurrentAppListProfile() const;
app_list::SearchController* GetSearchControllerForTest();
// Flushes all pending mojo call to Ash for testing.
void FlushMojoForTesting();
private:
// Overridden from TemplateURLServiceObserver:
void OnTemplateURLServiceChanged() override;
// Configures the AppList for the given |profile|.
void SetProfile(Profile* profile);
// Updates the speech webview and start page for the current |profile_|.
void SetUpSearchUI();
// Unowned pointer to the associated profile. May change if SetProfile is
// called.
Profile* profile_ = nullptr;
// Unowned pointer to the model updater owned by AppListSyncableService.
// Will change if |profile_| changes.
AppListModelUpdater* model_updater_ = nullptr;
std::unique_ptr<app_list::SearchResourceManager> search_resource_manager_;
std::unique_ptr<app_list::SearchController> search_controller_;
std::unique_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_;
ScopedObserver<TemplateURLService, AppListClientImpl>
template_url_service_observer_;
mojo::Binding<ash::mojom::AppListClient> binding_;
ash::mojom::AppListControllerPtr app_list_controller_;
AppListControllerDelegateImpl controller_delegate_;
bool app_list_target_visibility_ = false;
bool app_list_visible_ = false;
base::WeakPtrFactory<AppListClientImpl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(AppListClientImpl);
};
#endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_CLIENT_IMPL_H_
| [
"arnaud@geometry.ee"
] | arnaud@geometry.ee |
574711427477d298c6dcd0914af474d8e74d6eba | 7b9b73f430e422e6420fba5534afcee7b1eb044c | /leetcode/377.combination-sum-iv.cpp | 47517694b1f3f0a7e84e8a5b9f1c47943f0d2c8f | [] | no_license | imsong52/Q.solution | 5a5b26f0be8a0b49acd9932378b228792a775e4a | 47b732e28c61ba242c96db245f49eb0c8498ebf6 | refs/heads/master | 2020-04-30T14:18:57.482616 | 2018-10-28T02:14:09 | 2018-10-28T02:14:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,429 | cpp | /*
* [377] Combination Sum IV
*
* https://leetcode.com/problems/combination-sum-iv
*
* Medium (41.68%)
* Total Accepted: 30457
* Total Submissions: 73046
* Testcase Example: '[1,2,3]\n4'
*
* Given an integer array with all positive numbers and no duplicates, find
* the number of possible combinations that add up to a positive integer
* target.
*
* Example:
*
* nums = [1, 2, 3]
* target = 4
*
* The possible combination ways are:
* (1, 1, 1, 1)
* (1, 1, 2)
* (1, 2, 1)
* (1, 3)
* (2, 1, 1)
* (2, 2)
* (3, 1)
*
* Note that different sequences are counted as different combinations.
*
* Therefore the output is 7.
*
*
*
* Follow up:
* What if negative numbers are allowed in the given array?
* How does it change the problem?
* What limitation we need to add to the question to allow negative numbers?
*
* Credits:Special thanks to @pbrother for adding this problem and creating all
* test cases.
*/
class Solution {
public:
vector<int> v;
unordered_map<int, int> m;
int next(int n) {
if (m.find(n) != m.end()) return m[n];
int x = 0;
for (int i = 0; i < v.size(); ++i) {
if (n < v[i]) continue;
if (n == v[i]) ++x;
else x += next(n - v[i]);
}
return m[n] = x;
}
int combinationSum4(vector<int>& nums, int target) {
v = nums;
return next(target);
}
};
| [
"skygragon@gmail.com"
] | skygragon@gmail.com |
e04f72b642bba29f82a0fe2a3ab40228b52350b3 | dd9edc493099e7e6b5534329c7204d81f023b5b5 | /types.inc.cpp | 8bd9f11500a4d2404912da02684204f5185572ab | [] | no_license | jaz303/menace | 5b569ded238e93d41491fbb570086a75e6dcd96d | 28a928e7ea26ce84d342829b90165a4d7d04b26e | refs/heads/master | 2023-08-12T23:32:59.778197 | 2015-12-21T21:26:39 | 2015-12-21T21:26:39 | 17,179,631 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 325 | cpp | enum {
AST_LIST,
AST_ASSIGN,
AST_SEND,
AST_UNARY_MSG,
AST_MSG_PART
};
enum {
T_NIL,
T_AST,
T_INT,
T_STRING,
T_IDENT,
T_TRUE,
T_FALSE
};
typedef struct {
int length;
char str[0];
} mc_string_t;
typedef struct val {
int type;
union {
ast_node_t *ast;
int32_t ival;
mc_string_t *str;
};
} val_t;
| [
"jason@onehackoranother.com"
] | jason@onehackoranother.com |
5080e19cea1196874242806410d170f8f59a1387 | 23e393f8c385a4e0f8f3d4b9e2d80f98657f4e1f | /Exploring C++ 11/chapter22/list2202.cpp | 6756881b680fbb5f5b78b57e41c059417398d24f | [] | no_license | IgorYunusov/Mega-collection-cpp-1 | c7c09e3c76395bcbf95a304db6462a315db921ba | 42d07f16a379a8093b6ddc15675bf777eb10d480 | refs/heads/master | 2020-03-24T10:20:15.783034 | 2018-06-12T13:19:05 | 2018-06-12T13:19:05 | 142,653,486 | 3 | 1 | null | 2018-07-28T06:36:35 | 2018-07-28T06:36:35 | null | UTF-8 | C++ | false | false | 2,841 | cpp | // Listing 22-2. New main Function That Sets the Global Locale
#include <iomanip>
#include <iostream>
#include <locale>
#include <map>
#include <string>
typedef std::map<std::string, int> count_map; ///< Map words to counts
typedef count_map::value_type count_pair; ///< pair of a word and a count
typedef std::string::size_type str_size; ///< String size type
/** Initialize the I/O streams by imbuing them with
* the global locale. Use this function to imbue the streams
* with the native locale. C++ initially imbues streams with
* the classic locale.
*/
void initialize_streams()
{
std::cin.imbue(std::locale{});
std::cout.imbue(std::locale{});
}
/** Find the longest key in a map.
* @param map the map to search
* @returns the size of the longest key in @p map
*/
str_size get_longest_key(count_map const& map)
{
str_size result{0};
for (auto pair : map)
if (pair.first.size() > result)
result = pair.first.size();
return result;
}
/** Print the word, count, newline. Keep the columns neatly aligned.
* Rather than the tedious operation of measuring the magnitude of all
* the counts and then determining the necessary number of columns, just
* use a sufficiently large value for the counts column.
* @param pair a word/count pair
* @param longest the size of the longest key; pad all keys to this size
*/
void print_pair(count_pair const& pair, str_size longest)
{
int const count_size{10}; // Number of places for printing the count
std::cout << std::setw(longest) << std::left << pair.first <<
std::setw(count_size) << std::right << pair.second << '\n';
}
/** Print the results in neat columns.
* @param counts the map of all the counts
*/
void print_counts(count_map counts)
{
str_size longest{get_longest_key(counts)};
// For each word/count pair...
for (count_pair pair: counts)
print_pair(pair, longest);
}
/** Sanitize a string by keeping only alphabetic characters.
* @param str the original string
* @return a santized copy of the string
*/
std::string sanitize(std::string const& str)
{
std::string result{};
for (char c : str)
if (std::isalnum(c, std::locale{}))
result.push_back(std::tolower(c, std::locale{}));
return result;
}
/** Main program to count unique words in the standard input. */
int main()
{
// Set the global locale to the native locale.
std::locale::global(std::locale{""});
initialize_streams();
count_map counts{};
// Read words from the standard input and count the number of times
// each word occurs.
std::string word{};
while (std::cin >> word)
{
std::string copy{sanitize(word)};
// The "word" might be all punctuation, so the copy would be empty.
// Don't count empty strings.
if (not copy.empty())
++counts[copy];
}
print_counts(counts);
}
| [
"wyrover@gmail.com"
] | wyrover@gmail.com |
7e022c15466dce0b5a3b122ea95e12268716cf03 | 92d6188aa68681d5e518538f03cda09aa4ecfaab | /Source/Utils/NonCopyable.h | f706552d2d3822da09f5a2ca0f3c9b769dbcd359 | [] | no_license | scsewell/Mantis | c768ab1cfb9324a9653b64bba415649ab225bca6 | 146d149cf3323f684abe3073c1a8d4be4fda3c95 | refs/heads/master | 2020-05-05T06:29:35.928276 | 2019-11-12T15:37:23 | 2019-11-12T15:37:23 | 179,790,395 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 527 | h | #pragma once
namespace Mantis
{
/// <summary>
/// A class that removes the copy constructor and operator from derived classes while leaving move.
/// </summary>
class NonCopyable
{
protected:
NonCopyable() = default;
virtual ~NonCopyable() = default;
public:
NonCopyable(const NonCopyable&) = delete;
NonCopyable(NonCopyable&&) = default;
NonCopyable& operator=(const NonCopyable&) = delete;
NonCopyable& operator=(NonCopyable&&) = default;
};
} | [
"scott.sewell@mail.mcgill.ca"
] | scott.sewell@mail.mcgill.ca |
bb2165741b4a01816b917be8a4fa1bfb3ac023de | c2135a1cefebc0b230bed71595f5b2b1cec6e304 | /~2017/2294.cpp | b631ed0f13cdd875c893d3d88b6ec02b87436ce2 | [] | no_license | pbysu/BOJ | d9df7a4b1a4aa440282f607a428e290f0e284e20 | 7c24608b4636f9203b2be14429850817ec6ea427 | refs/heads/master | 2020-03-07T17:23:29.706432 | 2018-06-01T10:48:46 | 2018-06-01T10:48:46 | 127,609,935 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 605 | cpp | #include<iostream>
#include<algorithm>
#include<vector>
#define INF 987654321
using namespace std;
vector<int> v;
int dp[10001];
int n, k;
int func(int num, int cnt) {
if (num < 0)
return INF;
if (num == 0)
return 0;
int &ret = dp[num];
if (ret != 0)
return ret;
int temp = INF;
for (int i = cnt; i < n; i++) {
temp = min(func(num - v[i], cnt), temp);
}
ret += temp + 1;
return ret;
}
int main() {
scanf("%d %d", &n, &k);
v.resize(k);
for (int i = 0; i < n; i++) {
scanf("%d", &v[i]);
}
int ans = func(k, 0);
if (ans == INF + 1)
ans = -1;
printf("%d", ans);
return 0;
} | [
"park.bysu@gmail.com"
] | park.bysu@gmail.com |
2c14ddb66ff0149c345142c9132ca59439f059b6 | 4037f87720586bc9b6d131b9593c6f8069266c82 | /bms_final/BMS/src/ManaUserItem.h | 4f0c86cbb99cb5c5f8c249d935d2a313cfbdfcf9 | [] | no_license | fanglelegood/Books_Management_System_Qt | e6be5b36e95c0f05c906bc22fe66b29b274b2dca | f7e40ed476f541a08e5a8a97c6dd7602f0d31a0e | refs/heads/main | 2023-07-03T10:01:07.454539 | 2021-08-01T15:02:48 | 2021-08-01T15:02:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 361 | h | #pragma once
#include <QtGui>
#include <QListWidgetItem>
#include "ui_ManaUserItem.h"
#include "GBK.h"
class ManaUserItem : public QWidget
{
Q_OBJECT
public:
ManaUserItem(QListWidgetItem *tItem, QWidget *parent = Q_NULLPTR);
~ManaUserItem();
Ui::ManaUserItem ui;
private slots:
void OnToolButtonChecked();
private:
QListWidgetItem *tempUserInfo;
};
| [
"luxiantao1998@163.com"
] | luxiantao1998@163.com |
fc421f9048fe104495b02721626d987bf44ae316 | 55fab91653b140edc6d0fc4950492faef2267e02 | /libemgucv-includes/opencv_contrib/opencv2/rapid.hpp | 72f8f39d199f6c254e13e484ec8fa41aacfe247b | [] | no_license | smbape/node-emgucv-autoit-generator | afd1705f90d557148b1b85fa241ae103a409db37 | be65936f8c0d6b8786e4b19aca921e487a4ed423 | refs/heads/master | 2023-07-14T21:19:33.411134 | 2021-08-28T10:19:14 | 2021-08-28T10:19:14 | 394,654,274 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,714 | hpp | // This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_RAPID_HPP_
#define OPENCV_RAPID_HPP_
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
/**
@defgroup rapid silhouette based 3D object tracking
implements "RAPID-a video rate object tracker" @cite harris1990rapid with the dynamic control point extraction of @cite drummond2002real
*/
namespace cv
{
namespace rapid
{
//! @addtogroup rapid
//! @{
/**
* Debug draw markers of matched correspondences onto a lineBundle
* @param bundle the lineBundle
* @param cols column coordinates in the line bundle
* @param colors colors for the markers. Defaults to white.
*/
CV_EXPORTS_W void drawCorrespondencies(InputOutputArray bundle, InputArray cols,
InputArray colors = noArray());
/**
* Debug draw search lines onto an image
* @param img the output image
* @param locations the source locations of a line bundle
* @param color the line color
*/
CV_EXPORTS_W void drawSearchLines(InputOutputArray img, InputArray locations, const Scalar& color);
/**
* Draw a wireframe of a triangle mesh
* @param img the output image
* @param pts2d the 2d points obtained by @ref projectPoints
* @param tris triangle face connectivity
* @param color line color
* @param type line type. See @ref LineTypes.
* @param cullBackface enable back-face culling based on CCW order
*/
CV_EXPORTS_W void drawWireframe(InputOutputArray img, InputArray pts2d, InputArray tris,
const Scalar& color, int type = LINE_8, bool cullBackface = false);
/**
* Extract control points from the projected silhouette of a mesh
*
* see @cite drummond2002real Sec 2.1, Step b
* @param num number of control points
* @param len search radius (used to restrict the ROI)
* @param pts3d the 3D points of the mesh
* @param rvec rotation between mesh and camera
* @param tvec translation between mesh and camera
* @param K camera intrinsic
* @param imsize size of the video frame
* @param tris triangle face connectivity
* @param ctl2d the 2D locations of the control points
* @param ctl3d matching 3D points of the mesh
*/
CV_EXPORTS_W void extractControlPoints(int num, int len, InputArray pts3d, InputArray rvec, InputArray tvec,
InputArray K, const Size& imsize, InputArray tris, OutputArray ctl2d,
OutputArray ctl3d);
/**
* Extract the line bundle from an image
* @param len the search radius. The bundle will have `2*len + 1` columns.
* @param ctl2d the search lines will be centered at this points and orthogonal to the contour defined by
* them. The bundle will have as many rows.
* @param img the image to read the pixel intensities values from
* @param bundle line bundle image with size `ctl2d.rows() x (2 * len + 1)` and the same type as @p img
* @param srcLocations the source pixel locations of @p bundle in @p img as CV_16SC2
*/
CV_EXPORTS_W void extractLineBundle(int len, InputArray ctl2d, InputArray img, OutputArray bundle,
OutputArray srcLocations);
/**
* Find corresponding image locations by searching for a maximal sobel edge along the search line (a single
* row in the bundle)
* @param bundle the line bundle
* @param cols correspondence-position per line in line-bundle-space
* @param response the sobel response for the selected point
*/
CV_EXPORTS_W void findCorrespondencies(InputArray bundle, OutputArray cols,
OutputArray response = noArray());
/**
* Collect corresponding 2d and 3d points based on correspondencies and mask
* @param cols correspondence-position per line in line-bundle-space
* @param srcLocations the source image location
* @param pts2d 2d points
* @param pts3d 3d points
* @param mask mask containing non-zero values for the elements to be retained
*/
CV_EXPORTS_W void convertCorrespondencies(InputArray cols, InputArray srcLocations, OutputArray pts2d,
InputOutputArray pts3d = noArray(), InputArray mask = noArray());
/**
* High level function to execute a single rapid @cite harris1990rapid iteration
*
* 1. @ref extractControlPoints
* 2. @ref extractLineBundle
* 3. @ref findCorrespondencies
* 4. @ref convertCorrespondencies
* 5. @ref solvePnPRefineLM
*
* @param img the video frame
* @param num number of search lines
* @param len search line radius
* @param pts3d the 3D points of the mesh
* @param tris triangle face connectivity
* @param K camera matrix
* @param rvec rotation between mesh and camera. Input values are used as an initial solution.
* @param tvec translation between mesh and camera. Input values are used as an initial solution.
* @param rmsd the 2d reprojection difference
* @return ratio of search lines that could be extracted and matched
*/
CV_EXPORTS_W float rapid(InputArray img, int num, int len, InputArray pts3d, InputArray tris, InputArray K,
InputOutputArray rvec, InputOutputArray tvec, CV_OUT double* rmsd = 0);
/// Abstract base class for stateful silhouette trackers
class CV_EXPORTS_W Tracker : public Algorithm
{
public:
virtual ~Tracker();
CV_WRAP virtual float
compute(InputArray img, int num, int len, InputArray K, InputOutputArray rvec, InputOutputArray tvec,
const TermCriteria& termcrit = TermCriteria(TermCriteria::MAX_ITER | TermCriteria::EPS, 5, 1.5)) = 0;
CV_WRAP virtual void clearState() = 0;
};
/// wrapper around @ref rapid function for uniform access
class CV_EXPORTS_W Rapid : public Tracker
{
public:
CV_WRAP static Ptr<Rapid> create(InputArray pts3d, InputArray tris);
};
/** implements "Optimal local searching for fast and robust textureless 3D object tracking in highly
* cluttered backgrounds" @cite seo2013optimal
*/
class CV_EXPORTS_W OLSTracker : public Tracker
{
public:
CV_WRAP static Ptr<OLSTracker> create(InputArray pts3d, InputArray tris, int histBins = 8, uchar sobelThesh = 10);
};
/** implements "Global optimal searching for textureless 3D object tracking" @cite wang2015global
*/
class CV_EXPORTS_W GOSTracker : public Tracker
{
public:
CV_WRAP static Ptr<OLSTracker> create(InputArray pts3d, InputArray tris, int histBins = 4, uchar sobelThesh = 10);
};
//! @}
} /* namespace rapid */
} /* namespace cv */
#endif /* OPENCV_RAPID_HPP_ */
| [
"smbape@yahoo.fr"
] | smbape@yahoo.fr |
7541b51943123e71e688df396b97712a65f4f881 | c623b735b06b0eff005e4b9a71b5d983da924a38 | /bj_10950.cpp | 4bf4985d95de5f5de5332097af8b5fee7ae7300a | [] | no_license | WALDOISCOMING/BJ_Algorithm | dc7d4015716d6ed8ebb0c0146560c370530d8a5c | 66fa99a59d0366b9dce20006828a62e0e6c5a0c2 | refs/heads/master | 2020-04-17T04:46:27.440159 | 2019-03-03T12:03:33 | 2019-03-03T12:03:33 | 166,245,478 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 187 | cpp | #include <iostream>
#include <cstdio>
using namespace std;
int main() {
int input;
cin >> input;
while (input--) {
int a, b;
cin >> a >> b;
cout << a + b << endl;
}
return 0;
} | [
"forallabouttest@gmail.com"
] | forallabouttest@gmail.com |
e204e478957a2e5f2bf0a9f13c933a050e62d2b9 | dc68b05c1a7c656669400a91640257bda4715b21 | /labs/lab6/ListNode.h | 2692734dee7eec12faa8194a1e9228f1bce51974 | [] | no_license | Aurillon/UMD-Duluth-CS1521 | 0e38b72a42e73448ed445985befb1cecbce45830 | 97487ea8b963a728b9029aa2f009a7762478f2e9 | refs/heads/main | 2023-03-15T04:37:15.441071 | 2021-03-30T06:48:37 | 2021-03-30T06:48:37 | 352,879,962 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,169 | h | /** @file
*
* @course CS1521
* @section 1
* @term Spring 2019
*
* Header file for the LinkedList::ListNode nested class.
*
* Adapted from page 443 in Carrano 7e.
*
* @author Frank M. Carrano
* @author Timothy Henry
* @author Steve Holtz
*
* @date 29 Mar 2019
*
* @version 7.0 */
#ifndef LIST_NODE_
#define LIST_NODE_
#include <memory>
// Everything is declared public here as the type itself is a
// protected member of the LinkedList class template, and thus,
// clients do not have access to any of the members. Making the
// constructors and destructor public is critical because the
// make_shared function must have access to the constructors to be
// able to build ListNodes; and the shared_ptr class must have access
// to the destructor in order to properly destroy objects of this
// type.
template <typename ItemType>
class LinkedList<ItemType>::ListNode {
public:
ItemType item;
ListNodePtr next;
ListNode() = default;
ListNode(const ItemType& anItem,
ListNodePtr nextNodePtr);
#ifdef DTOR_TEST
virtual ~ListNode();
#else
virtual ~ListNode() = default;
#endif
};
#include "ListNode.cpp"
#endif
| [
"noreply@github.com"
] | noreply@github.com |
24c30efb729ca01bce3cd3dd34086da9c63bbfcd | 8487a4d75d21b42a3c9a91477ec9a6ab623c4e0b | /xls/fuzzer/sample.cc | c32a2eef12192e119983fc04568d948333587f8d | [
"Apache-2.0"
] | permissive | jbampton/xls | e22202283a9b78a78b1a6281f205f75e811d3f3d | cce6ea1f834be991f8b20f26c9a4d77202dc9bb0 | refs/heads/main | 2023-04-04T09:38:26.485139 | 2021-04-13T21:19:22 | 2021-04-13T21:20:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,573 | cc | // Copyright 2021 The XLS Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "xls/fuzzer/sample.h"
#include "absl/strings/str_join.h"
#include "absl/strings/str_split.h"
#include "xls/dslx/ir_converter.h"
#include "xls/fuzzer/scrub_crasher.h"
#include "xls/ir/ir_parser.h"
#include "re2/re2.h"
namespace xls {
using dslx::InterpValue;
static absl::StatusOr<InterpValue> InterpValueFromString(absl::string_view s) {
XLS_ASSIGN_OR_RETURN(Value value, Parser::ParseTypedValue(s));
return dslx::ValueToInterpValue(value);
}
absl::StatusOr<std::vector<InterpValue>> ParseArgs(
absl::string_view args_text) {
args_text = absl::StripAsciiWhitespace(args_text);
std::vector<InterpValue> args;
if (args_text.empty()) {
return args;
}
for (absl::string_view piece : absl::StrSplit(args_text, ';')) {
piece = absl::StripAsciiWhitespace(piece);
XLS_ASSIGN_OR_RETURN(InterpValue value, InterpValueFromString(piece));
args.push_back(value);
}
return args;
}
absl::StatusOr<std::vector<std::vector<InterpValue>>> ParseArgsBatch(
absl::string_view args_text) {
args_text = absl::StripAsciiWhitespace(args_text);
std::vector<std::vector<InterpValue>> args_batch;
if (args_text.empty()) {
return args_batch;
}
for (absl::string_view line : absl::StrSplit(args_text, '\n')) {
XLS_ASSIGN_OR_RETURN(auto args, ParseArgs(line));
args_batch.push_back(std::move(args));
}
return args_batch;
}
std::string ArgsBatchToText(
const std::vector<std::vector<InterpValue>>& args_batch) {
return absl::StrJoin(
args_batch, "\n",
[](std::string* out, const std::vector<InterpValue>& args) {
absl::StrAppend(
out, absl::StrJoin(args, ";",
[](std::string* out, const InterpValue& v) {
absl::StrAppend(out, v.ToString());
}));
});
}
/* static */ absl::StatusOr<SampleOptions> SampleOptions::FromJson(
absl::string_view json_text) {
std::string err;
json11::Json parsed = json11::Json::parse(std::string(json_text), err);
SampleOptions options;
#define HANDLE_BOOL(__name) \
if (!parsed[#__name].is_null()) { \
options.__name##_ = parsed[#__name].bool_value(); \
}
HANDLE_BOOL(input_is_dslx);
HANDLE_BOOL(convert_to_ir);
HANDLE_BOOL(optimize_ir);
HANDLE_BOOL(use_jit);
HANDLE_BOOL(codegen);
HANDLE_BOOL(simulate);
HANDLE_BOOL(use_system_verilog);
#undef HANDLE_BOOL
if (!parsed["codegen_args"].is_null()) {
std::vector<std::string> codegen_args;
for (const json11::Json& item : parsed["codegen_args"].array_items()) {
codegen_args.push_back(item.string_value());
}
options.codegen_args_ = std::move(codegen_args);
}
if (!parsed["simulator"].is_null()) {
options.simulator_ = parsed["simulator"].string_value();
}
return options;
}
json11::Json SampleOptions::ToJson() const {
absl::flat_hash_map<std::string, json11::Json> json;
#define HANDLE_BOOL(__name) json[#__name] = __name##_;
HANDLE_BOOL(input_is_dslx);
HANDLE_BOOL(convert_to_ir);
HANDLE_BOOL(optimize_ir);
HANDLE_BOOL(use_jit);
HANDLE_BOOL(codegen);
HANDLE_BOOL(simulate);
HANDLE_BOOL(use_system_verilog);
#undef HANDLE_BOOL
if (codegen_args_) {
json["codegen_args"] = *codegen_args_;
} else {
json["codegen_args"] = nullptr;
}
if (simulator_) {
json["simulator"] = *simulator_;
} else {
json["simulator"] = nullptr;
}
return json11::Json(json);
}
bool Sample::ArgsBatchEqual(const Sample& other) const {
if (args_batch_.size() != other.args_batch_.size()) {
return false;
}
auto args_equal = [](const std::vector<InterpValue>& lhs,
const std::vector<InterpValue>& rhs) {
if (lhs.size() != rhs.size()) {
return false;
}
for (int64_t i = 0; i < lhs.size(); ++i) {
if (!lhs[i].Eq(rhs[i])) {
return false;
}
}
return true;
};
for (int64_t i = 0; i < args_batch_.size(); ++i) {
if (!args_equal(args_batch_[i], other.args_batch_[i])) {
return false;
}
}
return true;
}
/* static */ absl::StatusOr<Sample> Sample::Deserialize(absl::string_view s) {
s = absl::StripAsciiWhitespace(s);
absl::optional<SampleOptions> options;
std::vector<std::vector<InterpValue>> args_batch;
std::vector<absl::string_view> input_lines;
for (absl::string_view line : absl::StrSplit(s, '\n')) {
if (RE2::FullMatch(line, "\\s*//\\s*options:(.*)", &line)) {
XLS_ASSIGN_OR_RETURN(options, SampleOptions::FromJson(line));
} else if (RE2::FullMatch(line, "\\s*//\\s*args:(.*)", &line)) {
XLS_ASSIGN_OR_RETURN(auto args, ParseArgs(line));
args_batch.push_back(std::move(args));
} else {
input_lines.push_back(line);
}
}
if (!options.has_value()) {
return absl::InvalidArgumentError(
"Crasher did not have sample 'options' comment line.");
}
std::string input_text = absl::StrJoin(input_lines, "\n");
return Sample(std::move(input_text), *std::move(options),
std::move(args_batch));
}
std::string Sample::Serialize() const {
std::vector<std::string> lines;
lines.push_back(absl::StrCat("// options: ", options_.ToJsonText()));
for (const std::vector<InterpValue>& args : args_batch_) {
std::string args_str =
absl::StrJoin(args, "; ", [](std::string* out, const InterpValue& v) {
absl::StrAppend(out, v.ToString());
});
lines.push_back(absl::StrCat("// args: ", args_str));
}
std::string header = absl::StrJoin(lines, "\n");
return absl::StrCat(header, "\n", input_text_, "\n");
}
std::string Sample::ToCrasher(absl::string_view error_message) const {
absl::civil_year_t year =
absl::ToCivilYear(absl::Now(), absl::TimeZone()).year();
std::vector<std::string> lines = {
absl::StrFormat(R"(// Copyright %d The XLS Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
)",
year)};
lines.push_back("// Exception:");
for (absl::string_view line : absl::StrSplit(error_message, '\n')) {
lines.push_back(absl::StrCat("// ", line));
}
// Split the D.N.S string to avoid triggering presubmit checks.
lines.push_back(std::string("// Issue: DO NOT ") +
"SUBMIT Insert link to GitHub issue here.");
lines.push_back("//");
std::string header = absl::StrJoin(lines, "\n");
return ScrubCrasher(absl::StrCat(header, "\n", Serialize()));
}
} // namespace xls
| [
"copybara-worker@google.com"
] | copybara-worker@google.com |
4a4bba187b809f5ea8723626d061973e4286d973 | 415e1b24dd4c3058026ed48303267087f004efb4 | /examples/packet-table/generated.h | 50ed31264ca02a32b2aad524c2962e51e21cd6af | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"NCSA",
"LicenseRef-scancode-hdf5",
"LicenseRef-scancode-llnl",
"LicenseRef-scancode-hdf4"
] | permissive | toth7667/h5cpp | 04acd4636187dd036a1b8879465e650c35577bcb | 1444cf87cc2953c473129eeb2217b483aa4ffcc1 | refs/heads/master | 2023-08-14T22:15:54.325209 | 2021-06-09T13:21:26 | 2021-06-09T13:21:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,615 | h | /* Copyright (c) 2018 vargaconsulting, Toronto,ON Canada
* Author: Varga, Steven <steven@vargaconsulting.ca>
*/
#ifndef H5CPP_GUARD_irGVX
#define H5CPP_GUARD_irGVX
namespace h5{
//template specialization of sn::example::Record to create HDF5 COMPOUND type
template<> hid_t inline register_struct<sn::example::Record>(){
hsize_t at_00_[] ={7}; hid_t at_00 = H5Tarray_create(H5T_NATIVE_FLOAT,1,at_00_);
hsize_t at_01_[] ={3}; hid_t at_01 = H5Tarray_create(H5T_NATIVE_DOUBLE,1,at_01_);
hid_t ct_00 = H5Tcreate(H5T_COMPOUND, sizeof (sn::typecheck::Record));
H5Tinsert(ct_00, "_char", HOFFSET(sn::typecheck::Record,_char),H5T_NATIVE_CHAR);
H5Tinsert(ct_00, "_uchar", HOFFSET(sn::typecheck::Record,_uchar),H5T_NATIVE_UCHAR);
H5Tinsert(ct_00, "_short", HOFFSET(sn::typecheck::Record,_short),H5T_NATIVE_SHORT);
H5Tinsert(ct_00, "_ushort", HOFFSET(sn::typecheck::Record,_ushort),H5T_NATIVE_USHORT);
H5Tinsert(ct_00, "_int", HOFFSET(sn::typecheck::Record,_int),H5T_NATIVE_INT);
H5Tinsert(ct_00, "_uint", HOFFSET(sn::typecheck::Record,_uint),H5T_NATIVE_UINT);
H5Tinsert(ct_00, "_long", HOFFSET(sn::typecheck::Record,_long),H5T_NATIVE_LONG);
H5Tinsert(ct_00, "_ulong", HOFFSET(sn::typecheck::Record,_ulong),H5T_NATIVE_ULONG);
H5Tinsert(ct_00, "_llong", HOFFSET(sn::typecheck::Record,_llong),H5T_NATIVE_LLONG);
H5Tinsert(ct_00, "_ullong", HOFFSET(sn::typecheck::Record,_ullong),H5T_NATIVE_ULLONG);
H5Tinsert(ct_00, "_float", HOFFSET(sn::typecheck::Record,_float),H5T_NATIVE_FLOAT);
H5Tinsert(ct_00, "_double", HOFFSET(sn::typecheck::Record,_double),H5T_NATIVE_DOUBLE);
H5Tinsert(ct_00, "_ldouble", HOFFSET(sn::typecheck::Record,_ldouble),H5T_NATIVE_LDOUBLE);
H5Tinsert(ct_00, "_bool", HOFFSET(sn::typecheck::Record,_bool),H5T_NATIVE_HBOOL);
hsize_t at_02_[] ={4}; hid_t at_02 = H5Tarray_create(ct_00,1,at_02_);
hid_t ct_01 = H5Tcreate(H5T_COMPOUND, sizeof (sn::other::Record));
H5Tinsert(ct_01, "idx", HOFFSET(sn::other::Record,idx),H5T_NATIVE_ULLONG);
H5Tinsert(ct_01, "aa", HOFFSET(sn::other::Record,aa),H5T_NATIVE_ULLONG);
H5Tinsert(ct_01, "field_02", HOFFSET(sn::other::Record,field_02),at_01);
H5Tinsert(ct_01, "field_03", HOFFSET(sn::other::Record,field_03),at_02);
hsize_t at_03_[] ={5}; hid_t at_03 = H5Tarray_create(ct_01,1,at_03_);
hsize_t at_04_[] ={8}; hid_t at_04 = H5Tarray_create(ct_01,1,at_04_);
hsize_t at_05_[] ={3}; hid_t at_05 = H5Tarray_create(at_04,1,at_05_);
hid_t ct_02 = H5Tcreate(H5T_COMPOUND, sizeof (sn::example::Record));
H5Tinsert(ct_02, "idx", HOFFSET(sn::example::Record,idx),H5T_NATIVE_ULLONG);
H5Tinsert(ct_02, "field_02", HOFFSET(sn::example::Record,field_02),at_00);
H5Tinsert(ct_02, "field_03", HOFFSET(sn::example::Record,field_03),at_03);
H5Tinsert(ct_02, "field_04", HOFFSET(sn::example::Record,field_04),at_03);
H5Tinsert(ct_02, "field_05", HOFFSET(sn::example::Record,field_05),at_05);
//closing all hid_t allocations to prevent resource leakage
H5Tclose(at_00); H5Tclose(at_01); H5Tclose(ct_00); H5Tclose(at_02); H5Tclose(ct_01);
H5Tclose(at_03); H5Tclose(at_04); H5Tclose(at_05);
//if not used with h5cpp framework, but as a standalone code generator then
//the returned 'hid_t ct_02' must be closed: H5Tclose(ct_02);
return ct_02;
};
}
H5CPP_REGISTER_STRUCT(sn::example::Record);
#endif
| [
"steven@vargaconsulting.ca"
] | steven@vargaconsulting.ca |
ecfee1cc8b7ad1cac3b395fc78ca35fcfa1055be | bf035aad3b2c5ced2ef528cc91c8ab6f9c97c100 | /designing_and_programming_a_control_system_to_an_arm_1.ino | 014e6f7708068ad5d6fdc6692482f1e3fe850bd8 | [] | no_license | Mojahed-nour/THE-ROBOT-KINEMATICS | d187a4e68b1a976bcf0f6e0cbd5875e444ce2fbd | 562f8ee7f4671b3f3c7a4258c569517df314aa92 | refs/heads/master | 2022-11-15T03:49:15.775849 | 2020-07-13T15:54:41 | 2020-07-13T15:54:41 | 279,327,538 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,372 | ino |
#include <Keypad.h>
int Ll=40,L2=45,CHECK;
float ANG1, ANG2 ,ANGL1, ANGL2,X,Y,ALLANG=50,INVANG;
#include <Servo.h>
Servo motor1 ;
Servo motor2 ;
char hexakeys[4][3]=
{{'1','2','3'},{'4','5','6'},{'7','8','9'},{' ','9',' '}};
byte rows [4]={A2 ,A3 , A4, A5};
byte cols [3]={5,6,7};
Keypad userINPUTS = Keypad( ' ',rows,cols,4,3);
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
motor1.attach(7);
motor2.attach(6);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
int ANGL11,ANGL12,ANGL1,
ANGL21,ANGL22,ANGL2;
int X1l=0,X12=0,X
,Y11,Y12,Y;
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
lcd.clear(); //clear word on led
CHECK=forwaORinver();
if (CHECK==1) {
int ANGL11,ANGL12,ANGL1,
ANGL21,ANGL22,ANGL2;
lcd.clear();
lcd.print ("Enter anlgle 1");
while (ANGL11==0) {ANGL11=userINPUTS.getKey();} //wait user to enter first number of Q1
lcd.setCursor (0,1);
ANGL11=ANGL1-48; // CONVERT THE Number From ASCII
lcd.print(ANGL11);
while (ANGL12==0) {ANGL12=userINPUTS.getKey();} //wait user to enter second number of Q1
delay (500);
ANGL2=ANGL21*10+ANGL22;
forward(); // CallING forward function
}
else{
int ANGL12,ANGL11;
ANGL12=ANGL12-48;
lcd. print (ANGL12);
delay (500);
ANGL1=ANGL11*10+ANGL12;
lcd.clear();
lcd.print ("Enter anlgle 2");
while (ANGL21==0) {ANGL21=userINPUTS.getKey();} //wait user to enter first number of Q1
lcd.setCursor (0,1);
ANGL21=ANGL21-48; // CONVERT THE Number From ASCII
lcd.print(ANGL21);
while (ANGL22==0) {ANGL22=userINPUTS.getKey();} //wait user to enter second number of Q1
ANGL22=ANGL22-48;
lcd. print (ANGL22);
int X1l,X12,X
,Y11,Y12,Y;
lcd.clear();
lcd.print ("Enter value of X. postion");
while (X1l==0) {X11=userINPUTS.getKey();}
X1l=X1l-48;
lcd.setCursor (0,1);
lcd. print (1l);
while (X12==0) {X12=userINPUTS.getKey();}
X12=X12-48;
lcd. print (X12);
delay (500);
X=1l*10+X12;
lcd.clear();
lcd.print ("Enter value of Y");
while (Y1l==0)
{Y1l=userINPUTS.getKey();}
Y1l=Y1l-48;
lcd.setCursor (0,1);
lcd. print (Y1l);
while (Y12==0)
{Y12=userINPUTS.getKey();}
Y12=Y12-48;
lcd. print (Y12);
delay (500);
Y=Y1l*10+Y12;
invers(); //call invers function
}
}
int forwaORinver(){
// THE function to let the user choose type of control the arm forward/inverse kineme
char IND=0;
motol.write (0);
moto2.write (0);
lcd.clear();
lcd.print ("Press 1 FOR forward ");
lcd. setCursor (0,1);
lcd.print ("or 2 FOR Inverse");
while (IND==0)
{ IND = userINPUTS.getKey();}
IND=IND-48;
if (IND==1) {
lcd.clear();
lcd.print ("Forward Kinematic");
lcd. setCursor (0,1);
lcd.print (1);
delay (2000);
return 1;}
else if (IND==2) {
lcd.clear();
lcd.print ("Inverse Kinemitic");
lcd. setCursor (0,1);
lcd.print (2);
delay (2000);
return 2;}
else
{
lcd.clear();
lcd.print ("TRY again only 1 ,2 ");}
}
void forward () {
//this function to calculate Q1 &Q2
motol.write (ANGL1);
moto2.write (ANGL2);
lcd.clear();
ANG1=ANGL1*PI/180;//Degree to radian
ANG2=ANGL2*PI/180;: //Degree to radian
X=(L1*cos (ANG1) ) + (L2* cos (ANG1+ANG2));
Y=(L1*sin(ANG1))+(L2*sin(ANG1+ANG2));
lcd.print ("The postion of the end effector");
lcd.setCurser(5, 1);
lcd.print(":");
lcd.setCurser(0, 1);
lcd. print (X);
lcd.setCurser(6, 1);
lcd.print (Y);
Serial.print ("ANG1");
Serial.println(ql);
Serial.print ("ANG2");
Serial.println(q2);
delay (7000);
}
void invers() {
// this fuction to determine end effector of arm depending on value of x, y
lcd.clear();
INVANG= (pow (X, 2) tpow (X, 2) -pow (L1, 2) -pow (L2, 2) ) / (2*L1*L2);
ANGL2=acos (INVANG);
ANG2=ANGL2*180/PI;
ANG1=ALLANG-ANG2;
lcd.print ("Angle of Arm:");
lcd.setCurser (0,1);
lcd. print ("ANG1=");
lcd.print (ANG1);
cd.setCurseor (0,1);
lcd. print ("&");
lcd.setCurser (9,1);
lcd. print ("ANG2=");
lcd.print (ANG2);
Serial.print(ANG1);
motol.write(ANG1);
moto2.write(ANG2);
delay (7000);
}
| [
"noreply@github.com"
] | noreply@github.com |
1d030db58b51a79c1064dd0b278f6264cdd826bf | fc7d9bbe049114ad5a94a6107321bdc09d3ccf53 | /.history/Maze_20210921074031.cpp | 3e1a6f5da904a8aea79a6a086f8a5f5957b6a211 | [] | no_license | xich4932/3010_maze | 2dbf7bb0f2be75d014a384cbefc4095779d525b5 | 72be8a7d9911efed5bc78be681486b2532c08ad8 | refs/heads/main | 2023-08-11T00:42:18.085853 | 2021-09-22T03:29:40 | 2021-09-22T03:29:40 | 408,272,071 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,600 | cpp | #include<iostream>
#include<vector>
#include<cstdlib>
#include<array>
#include"Maze.h"
//#include"Player.h"
#include<time.h>
#include<cstring>
//using namespace std;
//return true when the path is in the vector
bool checkInPath(const int num, const std::vector<int> &vec){
for(int d =0; d < vec.size(); d++){
if(vec[d] == num) return true;
}
return false;
}
inline std::string SquareTypeStringify(SquareType sq){
switch (sq)
{
case SquareType::Wall :
/* code */
return "Wall";
case SquareType::Exit :
/* code */
return "Exit";
case SquareType::Empty :
/* code */
return "Empty";
case SquareType::Human :
return "Human";
case SquareType::Enemy :
/* code */
return "Enemy";
default:
return "Treasure";
}
}
Board::Board(){
rows_ = 4;
cols_ = 4;
generate();
}
Board::Board(int c, int r){
rows_ = r;
cols_ = c;
generate();
}
void Board::displayUpdated(){
for(int i = 0; i < rows_; i++){
for(int d = 0; d < cols_; d++){
if(checkInPath(4*i +d, path)){
std::cout<< "*";
}else{
std::cout << "+" ;
}
}
std::cout << std::endl;
}
}
Maze::Maze(int r, int c, std::string name){
//generate (board_);
board_ = new Board(c,r);
while(board_->generate()){
std::cout << "creating path"<<std::endl;
}
players_.push_back(new Player(name ,1)); //0
players_.push_back(new Player("clown_face1" ,0)); //1
players_.push_back(new Player("clown_face2" ,0)); //2
players_.push_back(new Player("pear_1" ,0)); //3
players_.push_back(new Player("pear_2" ,0)); //4
players_.push_back(new Player("wall_1",0)); //5
players_.push_back(new Player("wall_2" ,0)); //6
players_.push_back(new Player("wall_3" ,0)); //7
players_.push_back(new Player("exit" ,0)); //8
std::vector<int> temp_path = board_->getPath();
//initialize the board with empty
for(int e =0; e < board_->get_cols(); e++){
for(int p = 0; p < board_->get_rows(); p++){
board_->SetSquareValue(Position(e, p), SquareType::Empty);
}
}
std::cout << "emtpy set "<< std::endl;
//put wall on the board
std::vector<int> path = board_->getPath();
for(int d = 5; d < 8; d++){
int temp_r = 0, temp_c=0;
while(checkInPath(4*temp_c + temp_r, path)){
int s = rand() % (r * c);
temp_r = s % r;
temp_c = s / r;
}
path[temp_c, temp_r] = 1;
players_[d]->SetPosition(Position(temp_c, temp_r));
board_->SetSquareValue(Position(temp_c, temp_r), SquareType::Wall);
}
std::cout << "emtpy wall "<< std::endl;
//set treasure
for(int d = 5; d < 8; d++){
int temp_r = 0, temp_c=0;
while(checkInPath(4*temp_c + temp_r, path)){
int s = rand() % (r * c);
temp_r = s % r;
temp_c = s / r;
}
path[temp_c, temp_r] = 1;
players_[d]->SetPosition(Position(temp_c, temp_r));
board_->SetSquareValue(Position(temp_c, temp_r), SquareType::Treasure);
}
std::cout << "emtpy treasure "<< std::endl;
//set enemy
for(int d = 1; d < 2; d++){
int temp_r = 0, temp_c=0;
while(checkInPath(4*temp_c + temp_r, path)){
int s = rand() % (r * c);
temp_r = s % r;
temp_c = s / r;
}
path[temp_c, temp_r] = 1;
players_[d]->SetPosition(Position(temp_c, temp_r));
board_->SetSquareValue(Position(temp_c, temp_r), SquareType::Enemy);
}
std::cout << "emtpy enemy "<< std::endl;
board_->SetSquareValue(Position(0,0), SquareType::Human);
board_->SetSquareValue(Position(board_->get_cols()-1,board_->get_rows()-1), SquareType::Exit);
std::cout << "everything set "<< std::endl;
}
/*
Maze::~Maze(){
delete board_;
} */
std::vector<int> getDirection(int point, int max_r, int max_c){
//{col,row} up left down right
//int direction[4][2] ={{1,0},{0,1},{-1,0},{0,-1}};
std::vector< int > ret;
ret.push_back(point - max_r); //up
ret.push_back(point + 1); //right
ret.push_back(point + max_r); //down
ret.push_back(point - 1); //left
int r = point % max_r;
int c = point / max_r;
if(r == 0){
ret.erase(ret.begin()+3);
}else if(r == max_r - 1){
ret.erase(ret.begin()+1);
}
if(c == 0){
ret.erase(ret.begin());
}else if(c == max_c - 1){
ret.erase(ret.begin()+2);
}
/* std::cout << "ret: " << point << std::endl;
for(int i = 0; i < ret.size() ; i++)
std::cout << ret[i] << " ";
std::cout << std::endl; */
return ret;
}
void printer(std::vector<int> pri){
for(int i =0 ; i< pri.size(); i++){
std::cout << pri[i] <<" ";
}
std::cout << std::endl;
}
void printer1(std::vector<std::array<int, 2>> pri){
for(int d =0; d < pri.size(); d++){
std::cout<<pri[d][0] <<" " << pri[d][1] <<std::endl;
}
}
bool Maze::IsGameOver(){
if(players_[0]->get_position() == players_[8]->get_position()){
return true;
}else if(players_[0]->get_position() == players_[1]->get_position() ||
players_[0]->get_position() == players_[2]->get_position()){
return true;
}
return false;
}
bool Board::generate(){
int max_step = 1; //max step to reach exit is 8
int visited[cols_][rows_] ;
//visited[0][0] = 0;
memset(visited, 0, sizeof(visited));
/* for(int d =0 ;d < cols_; d++){
for(int f = 0; f < rows_; f++){
std::cout << visited[d][f] << " ";
}
std::cout << std::endl;
} */
//vector<int> path;
path.push_back(0);
srand((unsigned ) time(NULL));
int max = rows_ * cols_;
visited[0][0] = 1;
int start_r = 0;
int start_c = 0;
int end_c = cols_ - 1;
int end_r = rows_ - 1;
while( path[path.size()-1] != 15 && path.size() < 13 && max_step < 16){
std::vector<int> direction = getDirection(path[path.size()-1], rows_, cols_);
//printer1(direction);
int curr = rand()%direction.size();
int temp_r = direction[curr] % rows_;
int temp_c = direction[curr] / rows_;
//std::cout << direction[curr][0] << " " << direction[curr][1] << std::endl;
if(visited[temp_c][temp_r]) continue;
//std::cout << "tmp_point " << temp_r << " " << temp_c << std::endl;
//std::cout << "tmp_c " << temp_c << std::endl;
//std::cout <<"-------------"<<std::endl;
/* for(int t =0; t < cols_; t++){
for(int y =0; y < rows_; y++){
if(t == temp_c && y == temp_r){
std::cout << 2 << " ";
}else{
std::cout << visited[t][y] << " ";
}
//std::cout << visited[t][y] << " ";
}
std::cout << std::endl;
} */
// std::cout <<"-------------"<<std::endl;
path.push_back(direction[curr]);
max_step ++;
//start_c += direction[curr][0];
//start_r += direction[curr][1];
visited[temp_c][temp_r] = 1;
direction.clear();
//displayUpdated();
}
//printer(path);
if(start_r == end_r && start_c == end_c) return true;
return false;
}
SquareType Board::get_square_value(Position pos) const {
return arr_[pos.col][pos.row];
};
// TODO: you MUST implement the following functions
// set the value of a square to the given SquareType
void Board::SetSquareValue(Position pos, SquareType value){
arr_[pos.col][pos.row] = value;
}
// get the possible Positions that a Player could move to
// (not off the board or into a wall)
std::vector<Position> Board::GetMoves(Player *p){
std::vector<Position> ret;
Position temp_pos = p->get_position();
if(temp_pos.col == 0){
if(SquareTypeStringify(arr_[temp_pos.col + 1][temp_pos.row]) != "Wall" &&
SquareTypeStringify(arr_[temp_pos.col + 1][temp_pos.row]) != "Enemy")
ret.push_back(Position(temp_pos.col + 1, temp_pos.row));
}else if(temp_pos.col == cols_ - 1){
if(SquareTypeStringify(arr_[temp_pos.col - 1][temp_pos.row]) != "Wall" &&
SquareTypeStringify(arr_[temp_pos.col - 1][temp_pos.row]) != "Enemy")
ret.push_back(Position(temp_pos.col - 1, temp_pos.row));
}else{
if(SquareTypeStringify(arr_[temp_pos.col + 1][temp_pos.row]) != "Wall" &&
SquareTypeStringify(arr_[temp_pos.col + 1][temp_pos.row]) != "Enemy")
ret.push_back(Position(temp_pos.col + 1, temp_pos.row));
if(SquareTypeStringify(arr_[temp_pos.col - 1][temp_pos.row]) != "Wall" &&
SquareTypeStringify(arr_[temp_pos.col - 1][temp_pos.row]) != "Enemy")
ret.push_back(Position(temp_pos.col - 1, temp_pos.row));
}
if(temp_pos.row == 0){
if(SquareTypeStringify(arr_[temp_pos.col ][temp_pos.row + 1]) != "Wall" &&
SquareTypeStringify(arr_[temp_pos.col ][temp_pos.row + 1]) != "Enemy")
ret.push_back(Position(temp_pos.col , temp_pos.row + 1));
}else if(temp_pos.row == rows_ - 1){
if(SquareTypeStringify(arr_[temp_pos.col ][temp_pos.row - 1]) != "Wall" &&
SquareTypeStringify(arr_[temp_pos.col ][temp_pos.row - 1]) != "Enemy")
ret.push_back(Position(temp_pos.col , temp_pos.row - 1));
}else{
if(SquareTypeStringify(arr_[temp_pos.col ][temp_pos.row + 1]) != "Wall" &&
SquareTypeStringify(arr_[temp_pos.col ][temp_pos.row + 1]) != "Enemy")
ret.push_back(Position(temp_pos.col , temp_pos.row + 1));
if(SquareTypeStringify(arr_[temp_pos.col ][temp_pos.row - 1]) != "Wall" &&
SquareTypeStringify(arr_[temp_pos.col ][temp_pos.row - 1]) != "Enemy")
ret.push_back(Position(temp_pos.col , temp_pos.row - 1));
}
return ret;
}
// Move a player to a new position on the board. Return
// true if they moved successfully, false otherwise.
bool Board::MovePlayer(Player *p, Position pos){
if(SquareTypeStringify(arr_[pos.col][pos.row]) != "Wall"){
p->set_position(pos.row, pos.col);
SquareType temp = arr_[p->get_position().col][p->get_position().row];
arr_[p->get_position().col][p->get_position().row] = arr_[pos.col][pos.row];
arr_[pos.col][pos.row] = temp;
return true;
}
return false;
}
// Get the square type of the exit square∏
SquareType Board::GetExitOccupant(){
return SquareType::Exit;
}
// You probably want to implement this
std::ostream& operator<<(std::ostream& os, const Board &b){
//Board *b = m.board_;
for(int i = 0; i < b.cols_; i++){
for(int e = 0; e < b.rows_; e++){
//Position p =Position(i,e);
std::string temp_str = SquareTypeStringify(b.arr_[i][e]);
if(temp_str == "Wall"){
std::cout << "❌";
}else if(temp_str == "Exit"){
std::cout << "✅";
}else if(temp_str == "Empty"){
std::cout << "⬜️";
}else if(temp_str == "Human"){
std::cout << "🦉";
}else if(temp_str == "Enemy"){
std::cout << "🤡";
}else{
std::cout << "🍐";
}
}
std::cout << std::endl;
}
}
std::ostream& operator<<(std::ostream& os, const Maze &m){
std::cout << *m.board_ << std::endl;
}
| [
"70279863+xich4932@users.noreply.github.com"
] | 70279863+xich4932@users.noreply.github.com |
106c56160a4574cc39e9dd7070d1820b53031401 | 7e562242374d4661fb6bf2bd1f38431c2b652b34 | /QListWidgetThumbnailViewer/TemplateWidgetDelegate.h | 3ae335497b49e0818553059dac3b5f1c5219e805 | [] | no_license | nvwo/qt_material | 1b7828c878b531986dcc600652a9ba2049467c93 | c59bd405433abe384da8495588b53bfe8e97b51d | refs/heads/main | 2023-07-02T16:40:46.917857 | 2021-08-04T16:27:03 | 2021-08-04T16:27:03 | 384,177,015 | 0 | 0 | null | 2021-07-24T13:09:02 | 2021-07-08T15:54:56 | C++ | UTF-8 | C++ | false | false | 2,539 | h | #include <QStyledItemDelegate>
#include <QPainter>
template <class T>
class WidgetDelegate : public QStyledItemDelegate{
#ifdef Q_COMPILER_STATIC_ASSERT
static_assert(std::is_base_of<QWidget,T>::value,"Template argument must be a QWidget");
#endif
Q_DISABLE_COPY(WidgetDelegate)
public:
explicit WidgetDelegate(QObject* parent = Q_NULLPTR)
:QStyledItemDelegate(parent)
, m_baseWid(new T)
{}
~WidgetDelegate(){
delete m_baseWid;
}
void paint(QPainter *painter, const QStyleOptionViewItem &option,const QModelIndex &index) const Q_DECL_OVERRIDE{
setSubEditorData(m_baseWid,index);
m_baseWid->resize(option.rect.size());
QPixmap pixmap(option.rect.size());
m_baseWid->render(&pixmap);
painter->drawPixmap(option.rect,pixmap);
}
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE{
Q_UNUSED(option);
setSubEditorData(m_baseWid,index);
return m_baseWid->sizeHint();
}
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE Q_DECL_FINAL {
Q_UNUSED(option);
Q_UNUSED(index);
T* editor = new T;
editor->setParent(parent);
return editor;
}
virtual void setSubEditorData(T* editor, const QModelIndex &index) const =0;
void setEditorData(QWidget* editor, const QModelIndex &index) const Q_DECL_OVERRIDE Q_DECL_FINAL {
T* subEdit = qobject_cast<T*>(editor);
Q_ASSERT(subEdit);
return setSubEditorData(subEdit,index);
}
private:
T* m_baseWid;
};
// An example usage would be:
#include <QLabel>
class LabelDelegate : public WidgetDelegate<QLabel>{
Q_OBJECT
Q_DISABLE_COPY(LabelDelegate)
public:
explicit LabelDelegate(QObject* parent=Q_NULLPTR)
:WidgetDelegate<QLabel>(parent)
{}
void setSubEditorData(QLabel* editor, const QModelIndex &index) const Q_DECL_OVERRIDE{
editor->setText("Content: <b>" + displayText(index.data(), editor->locale()) + "</b>");
}
};
//int main(int argc, char *argv[])
//{
// QApplication app(argc,argv);
// QListWidget w;
// w.model()->insertColumns(0,2);
// w.model()->insertRows(0,2);
// w.model()->setData(w.model()->index(0,0),"0,0");
// w.model()->setData(w.model()->index(1,0),"1,0");
// LabelDelegate* tempDelegate = new LabelDelegate(&w);
// w.setItemDelegate(tempDelegate);
// w.show();
// return app.exec();
//}
| [
"1138824393@qq.com"
] | 1138824393@qq.com |
f69f743104650760eca6a9b82de1701e43f5ce5d | 80c314286bf7476dcf9cfd983c41f6a58a2b68ed | /graduation/proj.win32/Automobile.cpp | 3b03f54224c218c8feacc49fa1953b0424061600 | [] | no_license | BellyABC123/graduation | 2b3a0edeea04125a3687e7d18d578528c772e7af | 30e9a7974009a269c8f5d230fff6a5423312791c | refs/heads/master | 2021-05-26T21:32:10.307137 | 2013-05-23T22:04:35 | 2013-05-23T22:04:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,653 | cpp |
#include "Automobile.h"
Automobile::Automobile(PhysicsWorld* physics, float x, float y)
{
this->physics = physics;
motorSpeed = 2 * 3.1425 * 2;
maxMotorTorque = 999;
createAutomobile(x,y);
}
void Automobile::createAutomobile(float x, float y)
{
float meterPerPixel = physics->getMeterPerPixel();
b2World* world = physics->getWorld();
x *= meterPerPixel;
y *= meterPerPixel;
float carBodyWidth = 150 * meterPerPixel;
float carBodyHeight = 10 * meterPerPixel;
float wheelRadius = 25 * meterPerPixel;
b2Vec2 localAnchorFixWheel1 = b2Vec2(-60*meterPerPixel,0);
b2Vec2 localAnchorFixWheel2 = b2Vec2(+60*meterPerPixel,0);
PhysicsBody physicsBody(world);
b2Body* carBody = physicsBody.newBody()
->setBodyPosition(b2Vec2(x, y))
->setBodyType(b2BodyType::b2_dynamicBody)
->setPolygonShapeASBox(carBodyWidth/2,carBodyHeight/2)
->setFixtureDensity(1)
->createFixture()
->createBody();
b2Body* wheel1 = physicsBody.newBody()
->newBody()
->setBodyType(b2BodyType::b2_dynamicBody)
->setBodyPosition(b2Vec2(x,y))
->setCircleShape(wheelRadius)
->setFixtureDensity(1)
->setFixtureFriction(1)
->createFixture()
->createBody();
b2Body* wheel2 = physicsBody.newBody()
->newBody()
->setBodyType(b2BodyType::b2_dynamicBody)
->setBodyPosition(b2Vec2(x,y))
->setCircleShape(wheelRadius)
->setFixtureDensity(1)
->setFixtureFriction(1)
->createFixture()
->createBody();
b2RevoluteJointDef revoluteJointDef;
revoluteJointDef.collideConnected = false;
revoluteJointDef.bodyA = carBody;
revoluteJointDef.bodyB = wheel1;
revoluteJointDef.localAnchorA = localAnchorFixWheel1;
revoluteJointDef.localAnchorB = b2Vec2(0,0);
revoluteJoints[0] = (b2RevoluteJoint*)world->CreateJoint(&revoluteJointDef);
revoluteJointDef.bodyB = wheel2;
revoluteJointDef.localAnchorA = localAnchorFixWheel2;
revoluteJoints[1] = (b2RevoluteJoint*)world->CreateJoint(&revoluteJointDef);
}
void Automobile::forward()
{
for(int i=0;i<2;i++)
{
revoluteJoints[i]->EnableMotor(true);
revoluteJoints[i]->SetMotorSpeed(motorSpeed);
revoluteJoints[i]->SetMaxMotorTorque(maxMotorTorque);
}
}
void Automobile::backward()
{
for(int i=0;i<2;i++)
{
revoluteJoints[i]->EnableMotor(true);
revoluteJoints[i]->SetMotorSpeed(-motorSpeed);
revoluteJoints[i]->SetMaxMotorTorque(maxMotorTorque);
}
}
void Automobile::stop()
{
for(int i=0;i<2;i++)
{
revoluteJoints[i]->EnableMotor(false);
}
}
| [
"1194451658@qq.com"
] | 1194451658@qq.com |
27a0dec136346c3515a6a6e2a3b27c5a74e54819 | 0b3f76cd73f763994b3069f328bc286b3017fd6b | /Classes/Scene/DNGameSceneLayer/DNObstecleSprite/DNObstecleSprite.hpp | 49c84aa54755e87065767fea971b8e1c8ebf04f3 | [] | no_license | yathiraj-karkera/SSR | 2952ca8a3815e69a90d62eb1534a0779638b33ce | 6b4bab5e3b4b2f04923fe60caaeeef71db4e305a | refs/heads/master | 2022-11-09T10:40:48.320224 | 2020-06-17T07:43:46 | 2020-06-17T07:43:46 | 271,547,740 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 497 | hpp | //
// DNObstecleSprite.hpp
// DesiNinja
//
// Created by Yathiraj on 02/08/17.
//
//
#ifndef DNObstecleSprite_hpp
#define DNObstecleSprite_hpp
#include <stdio.h>
#include "cocos2d.h"
#include <spine/spine-cocos2dx.h>
class DNObstecleSprite: public cocos2d::Sprite
{
DNObstecleSprite();
~DNObstecleSprite();
public :
static DNObstecleSprite *create(const char *FileName);
bool isScoreSet ;
bool isScoreDeducted ;
};
#endif /* DNObstecleSprite_hpp */
| [
"yathirajKarkera@juegostudio.net"
] | yathirajKarkera@juegostudio.net |
fe7fb7c0a9f008939c3bcfd500c32fbcc98623d7 | be73d215e09d715ba55f90be72dd2a69b42df077 | /customer.cpp | 4158e004efbadef94a74dd8fbad92e97fd719cb3 | [] | no_license | cdr98f/Final-Program | 753cd3191414807a5a003ec7e3794ae1c9162109 | 17e7adf95c5c58dc3742485df347a11925162707 | refs/heads/master | 2020-04-08T10:49:08.608452 | 2018-12-02T16:51:03 | 2018-12-02T16:51:03 | 159,283,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,391 | cpp | //Programmers: Carson Ripple, Marshall Vacarro //Date: 12/05/2018
//File: customer.cpp
//Purpose: To simulate a burger eating contest and determine a winner.
#include "customer.h"
#include <iostream>
#include <fstream>
using namespace std;
//constructor
Customer :: Customer()
{
static int count = 0; //increments every time a cust is made
int loop = 0;
ifstream fin;
fin.open("simpson_names.dat");
//Increasing the number of times a customer is created every time ensures
//unique names.
getline(fin, m_custName);
while(!fin.eof() && loop < count)
{
getline(fin, m_custName);
loop++;
}
//program will exit if it goes off the file
if(loop > count)
{
cout << "No more names! You've tried to create too many customers";
exit(3);
}
fin.close();
m_wallet = static_cast <float> (rand() % ((MAX_WALLET - MIN_WALLET + 1) *
100)) / 100 + MIN_WALLET;
m_weight = (rand() % (MAX_POUNDS - MIN_POUNDS + 1)) + MIN_WALLET;
m_chol = (rand() % (MAX_CHOL - MIN_CHOL + 1)) + MIN_CHOL;
m_health = (rand() % (MAX_HEALTH - MIN_HEALTH + 1)) + MIN_HEALTH;
m_isContestant = true;
m_weightGain = 0;
count++;
}
//insertion
ostream & operator << (ostream & os, const Customer & cust)
{
os << cust.m_custName << ", $" << cust.m_wallet
<< ", " << cust.m_weight << " lbs, "
<< cust.m_chol << " chol";
if (cust.m_isAlive)
os << "ALIVE";
else
os << "DEAD";
return os;
}
void Customer::eat(const Burger & b1, bool & vomit)
{
if(b1.getVirus())
{
if((rand() % 101 + 1) > m_health)
{
m_health = 0;
m_isAlive = false;
m_isContestant = false;
cout << m_custName << " just died!" << endl;
}
else
{
vomit = true;
m_health = m_health/2;
}
}
m_chol += 2.5 * b1.getBacon() + (PI/2)*b1.getPatties()
+ static_cast <float> (m_weight)/((b1.getPickles() + 1) * 10);
m_weight += 0.5*b1.getPatties() * b1.getPatties() + .125 * b1.getBacon()
* b1.getBacon() - static_cast <float> (b1.getPickles())/4
+ CHEESEGAIN + SAUCEGAIN;
m_weightGain += 0.5*b1.getPatties() * b1.getPatties() + .125 * b1.getBacon()
* b1.getBacon() - static_cast <float> (b1.getPickles())/4
+ CHEESEGAIN + SAUCEGAIN;
m_wallet = m_wallet - b1.getPrice();
m_health -= 2;
cout << m_custName << " has eaten a " << b1.getName() << ", wt "
<< m_weight << ", chol " << m_chol;
if (m_isAlive)
cout << "ALIVE" << endl;
else
cout << "DEAD" << endl;
return;
}
//Output done here
//I made index constant. It should be so you keep track of the center of the loops
void Customer::turn(Customer people[], Burgermeister & Krusty,
const int index, bool & eaten)
{
int i = index;
bool ifVomit = false;
bool continueChain = true;
Burger newBurger;
if ((m_wallet > newBurger.getPrice()) && m_isAlive && m_isContestant)
{
Krusty += newBurger.getPrice();
eaten = true;
eat(newBurger, ifVomit);
m_isAlive = checkAlive(); //not sure it this is necessary since you checked in eat
if (!m_isAlive)
Krusty -= FUNERAL_FEE;
}
//vomit sequence
if(ifVomit)
cout << m_custName << " has vomited." << endl;
//can you explain the use of index here
if (ifVomit && (index < AMNT_CUSTOMERS - 1) && (m_isAlive))
{
i = index + 1;
do
{
continueChain = vomit(people, i, Krusty);
if (continueChain)
cout << people[i] << " has vomited. "<< endl;
i++;
}
while ((continueChain) && (index < AMNT_CUSTOMERS));
i = index - 1;
do
{
continueChain = vomit(people, i, Krusty);
if (continueChain)
cout << people[i] << " has vomited." << endl;
i--;
}
while ((continueChain) && (i >= 0));
}
return;
}
bool Customer::checkAlive()
{
bool alive = true;
if (m_health <= DEATH_HEALTH)
{
cout << m_custName << " just died!" << endl;
alive = false;
}
else if (m_chol > MAX_CHOL)
{
cout << m_custName << " had a heart attack!" << endl;
alive = false;
}
else if (m_weightGain > MAX_WEIGHT_GAIN)
{
cout << m_custName << " exploded!" << endl;
alive = false;
}
if(!alive)
m_isContestant = false;
else
m_isContestant = true;
return alive;
}
bool Customer::getAlive() const
{
return m_isAlive;
}
//no need for output, vomit loop is taken care of elsewhere
bool Customer:: vomit(Customer people[], const int index, Burgermeister & Krusty)
{
bool contVomit = false;
if (rand()%2 == 1 && people[index].getAlive())
contVomit = true;
else if ((rand() % 10) < 7 && people[index].getAlive())
people[index].toss(people, index, Krusty);
return contVomit;
}
//have output for food fight now
void Customer:: toss(Customer contestants[], const int place, Burgermeister & Krusty)
{
//calling customer threw the burger
int personHit;
burger thrownBurg;
bool isThrown = (rand() % 10) < 8)
personHit = rand() % (AMNT_CUSTOMERS + 1);
//if the thrown burger hit krusty
if (personHit == KRUSTY_NUM && m_isAlive && isThrown)
{
cout << "\t" << m_custName << " has thrown a burger at Krusty!" << endl;
cout << "\t" << m_custName << " is disqualified." << endl;
m_isContestant = false;
Krusty += m_wallet;
}
//if the
else if (personHit != place && isAlive && isThrown)
{
cout << "\t" << m_custName << " has thrown a burger at " << contestants[personHit].m_custName;
Krusty += thrownBurg.getPrice(); //Not sure on this function
m_wallet -= thrownBurg.getPrice(); //Transaction for the burgers
contestants[personHit].toss(contestants, personHit, Krusty);
}
else if (personHit == place && isAlive && isThrown)// so user knows the fight ended
{
m_wallet -= thrownBurg.getPrice(); //Transaction for the burgers
cout << "\t" << m_custName << " threw a burger on themself." << endl;
}
else if (!isAlive)
{
cout << "\t" << m_custname << " is dead and can't participate." << endl;
}
else
cout << "\t" << m_custName << " chose not to throw." << endl;
return;
}
| [
"noreply@github.com"
] | noreply@github.com |
d54c736e2d7ec52db73fb65745c259c275cfea43 | c776476e9d06b3779d744641e758ac3a2c15cddc | /examples/litmus/c/run-scripts/tmp_1/Z6.2+poonceonce+poonceonce+pooncerelease.c.cbmc_out.cpp | 3e581d31fd045b61520e689abca266a1fc6a1928 | [] | no_license | ashutosh0gupta/llvm_bmc | aaac7961c723ba6f7ffd77a39559e0e52432eade | 0287c4fb180244e6b3c599a9902507f05c8a7234 | refs/heads/master | 2023-08-02T17:14:06.178723 | 2023-07-31T10:46:53 | 2023-07-31T10:46:53 | 143,100,825 | 3 | 4 | null | 2023-05-25T05:50:55 | 2018-08-01T03:47:00 | C++ | UTF-8 | C++ | false | false | 39,929 | cpp | // 0:vars:3
// 3:atom_1_X0_1:1
// 4:atom_2_X0_1:1
// 5:thr0:1
// 6:thr1:1
// 7:thr2:1
#define ADDRSIZE 8
#define NPROC 4
#define NCONTEXT 1
#define ASSUME(stmt) __CPROVER_assume(stmt)
#define ASSERT(stmt) __CPROVER_assert(stmt, "error")
#define max(a,b) (a>b?a:b)
char __get_rng();
char get_rng( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
char get_rng_th( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
int main(int argc, char **argv) {
// declare arrays for intial value version in contexts
int meminit_[ADDRSIZE*NCONTEXT];
#define meminit(x,k) meminit_[(x)*NCONTEXT+k]
int coinit_[ADDRSIZE*NCONTEXT];
#define coinit(x,k) coinit_[(x)*NCONTEXT+k]
int deltainit_[ADDRSIZE*NCONTEXT];
#define deltainit(x,k) deltainit_[(x)*NCONTEXT+k]
// declare arrays for running value version in contexts
int mem_[ADDRSIZE*NCONTEXT];
#define mem(x,k) mem_[(x)*NCONTEXT+k]
int co_[ADDRSIZE*NCONTEXT];
#define co(x,k) co_[(x)*NCONTEXT+k]
int delta_[ADDRSIZE*NCONTEXT];
#define delta(x,k) delta_[(x)*NCONTEXT+k]
// declare arrays for local buffer and observed writes
int buff_[NPROC*ADDRSIZE];
#define buff(x,k) buff_[(x)*ADDRSIZE+k]
int pw_[NPROC*ADDRSIZE];
#define pw(x,k) pw_[(x)*ADDRSIZE+k]
// declare arrays for context stamps
char cr_[NPROC*ADDRSIZE];
#define cr(x,k) cr_[(x)*ADDRSIZE+k]
char iw_[NPROC*ADDRSIZE];
#define iw(x,k) iw_[(x)*ADDRSIZE+k]
char cw_[NPROC*ADDRSIZE];
#define cw(x,k) cw_[(x)*ADDRSIZE+k]
char cx_[NPROC*ADDRSIZE];
#define cx(x,k) cx_[(x)*ADDRSIZE+k]
char is_[NPROC*ADDRSIZE];
#define is(x,k) is_[(x)*ADDRSIZE+k]
char cs_[NPROC*ADDRSIZE];
#define cs(x,k) cs_[(x)*ADDRSIZE+k]
char crmax_[NPROC*ADDRSIZE];
#define crmax(x,k) crmax_[(x)*ADDRSIZE+k]
char sforbid_[ADDRSIZE*NCONTEXT];
#define sforbid(x,k) sforbid_[(x)*NCONTEXT+k]
// declare arrays for synchronizations
int cl[NPROC];
int cdy[NPROC];
int cds[NPROC];
int cdl[NPROC];
int cisb[NPROC];
int caddr[NPROC];
int cctrl[NPROC];
int cstart[NPROC];
int creturn[NPROC];
// declare arrays for contexts activity
int active[NCONTEXT];
int ctx_used[NCONTEXT];
int r0= 0;
char creg_r0;
int r1= 0;
char creg_r1;
int r2= 0;
char creg_r2;
int r3= 0;
char creg_r3;
int r4= 0;
char creg_r4;
int r5= 0;
char creg_r5;
int r6= 0;
char creg_r6;
int r7= 0;
char creg_r7;
int r8= 0;
char creg_r8;
int r9= 0;
char creg_r9;
int r10= 0;
char creg_r10;
int r11= 0;
char creg_r11;
char old_cctrl= 0;
char old_cr= 0;
char old_cdy= 0;
char old_cw= 0;
char new_creg= 0;
buff(0,0) = 0;
pw(0,0) = 0;
cr(0,0) = 0;
iw(0,0) = 0;
cw(0,0) = 0;
cx(0,0) = 0;
is(0,0) = 0;
cs(0,0) = 0;
crmax(0,0) = 0;
buff(0,1) = 0;
pw(0,1) = 0;
cr(0,1) = 0;
iw(0,1) = 0;
cw(0,1) = 0;
cx(0,1) = 0;
is(0,1) = 0;
cs(0,1) = 0;
crmax(0,1) = 0;
buff(0,2) = 0;
pw(0,2) = 0;
cr(0,2) = 0;
iw(0,2) = 0;
cw(0,2) = 0;
cx(0,2) = 0;
is(0,2) = 0;
cs(0,2) = 0;
crmax(0,2) = 0;
buff(0,3) = 0;
pw(0,3) = 0;
cr(0,3) = 0;
iw(0,3) = 0;
cw(0,3) = 0;
cx(0,3) = 0;
is(0,3) = 0;
cs(0,3) = 0;
crmax(0,3) = 0;
buff(0,4) = 0;
pw(0,4) = 0;
cr(0,4) = 0;
iw(0,4) = 0;
cw(0,4) = 0;
cx(0,4) = 0;
is(0,4) = 0;
cs(0,4) = 0;
crmax(0,4) = 0;
buff(0,5) = 0;
pw(0,5) = 0;
cr(0,5) = 0;
iw(0,5) = 0;
cw(0,5) = 0;
cx(0,5) = 0;
is(0,5) = 0;
cs(0,5) = 0;
crmax(0,5) = 0;
buff(0,6) = 0;
pw(0,6) = 0;
cr(0,6) = 0;
iw(0,6) = 0;
cw(0,6) = 0;
cx(0,6) = 0;
is(0,6) = 0;
cs(0,6) = 0;
crmax(0,6) = 0;
buff(0,7) = 0;
pw(0,7) = 0;
cr(0,7) = 0;
iw(0,7) = 0;
cw(0,7) = 0;
cx(0,7) = 0;
is(0,7) = 0;
cs(0,7) = 0;
crmax(0,7) = 0;
cl[0] = 0;
cdy[0] = 0;
cds[0] = 0;
cdl[0] = 0;
cisb[0] = 0;
caddr[0] = 0;
cctrl[0] = 0;
cstart[0] = get_rng(0,NCONTEXT-1);
creturn[0] = get_rng(0,NCONTEXT-1);
buff(1,0) = 0;
pw(1,0) = 0;
cr(1,0) = 0;
iw(1,0) = 0;
cw(1,0) = 0;
cx(1,0) = 0;
is(1,0) = 0;
cs(1,0) = 0;
crmax(1,0) = 0;
buff(1,1) = 0;
pw(1,1) = 0;
cr(1,1) = 0;
iw(1,1) = 0;
cw(1,1) = 0;
cx(1,1) = 0;
is(1,1) = 0;
cs(1,1) = 0;
crmax(1,1) = 0;
buff(1,2) = 0;
pw(1,2) = 0;
cr(1,2) = 0;
iw(1,2) = 0;
cw(1,2) = 0;
cx(1,2) = 0;
is(1,2) = 0;
cs(1,2) = 0;
crmax(1,2) = 0;
buff(1,3) = 0;
pw(1,3) = 0;
cr(1,3) = 0;
iw(1,3) = 0;
cw(1,3) = 0;
cx(1,3) = 0;
is(1,3) = 0;
cs(1,3) = 0;
crmax(1,3) = 0;
buff(1,4) = 0;
pw(1,4) = 0;
cr(1,4) = 0;
iw(1,4) = 0;
cw(1,4) = 0;
cx(1,4) = 0;
is(1,4) = 0;
cs(1,4) = 0;
crmax(1,4) = 0;
buff(1,5) = 0;
pw(1,5) = 0;
cr(1,5) = 0;
iw(1,5) = 0;
cw(1,5) = 0;
cx(1,5) = 0;
is(1,5) = 0;
cs(1,5) = 0;
crmax(1,5) = 0;
buff(1,6) = 0;
pw(1,6) = 0;
cr(1,6) = 0;
iw(1,6) = 0;
cw(1,6) = 0;
cx(1,6) = 0;
is(1,6) = 0;
cs(1,6) = 0;
crmax(1,6) = 0;
buff(1,7) = 0;
pw(1,7) = 0;
cr(1,7) = 0;
iw(1,7) = 0;
cw(1,7) = 0;
cx(1,7) = 0;
is(1,7) = 0;
cs(1,7) = 0;
crmax(1,7) = 0;
cl[1] = 0;
cdy[1] = 0;
cds[1] = 0;
cdl[1] = 0;
cisb[1] = 0;
caddr[1] = 0;
cctrl[1] = 0;
cstart[1] = get_rng(0,NCONTEXT-1);
creturn[1] = get_rng(0,NCONTEXT-1);
buff(2,0) = 0;
pw(2,0) = 0;
cr(2,0) = 0;
iw(2,0) = 0;
cw(2,0) = 0;
cx(2,0) = 0;
is(2,0) = 0;
cs(2,0) = 0;
crmax(2,0) = 0;
buff(2,1) = 0;
pw(2,1) = 0;
cr(2,1) = 0;
iw(2,1) = 0;
cw(2,1) = 0;
cx(2,1) = 0;
is(2,1) = 0;
cs(2,1) = 0;
crmax(2,1) = 0;
buff(2,2) = 0;
pw(2,2) = 0;
cr(2,2) = 0;
iw(2,2) = 0;
cw(2,2) = 0;
cx(2,2) = 0;
is(2,2) = 0;
cs(2,2) = 0;
crmax(2,2) = 0;
buff(2,3) = 0;
pw(2,3) = 0;
cr(2,3) = 0;
iw(2,3) = 0;
cw(2,3) = 0;
cx(2,3) = 0;
is(2,3) = 0;
cs(2,3) = 0;
crmax(2,3) = 0;
buff(2,4) = 0;
pw(2,4) = 0;
cr(2,4) = 0;
iw(2,4) = 0;
cw(2,4) = 0;
cx(2,4) = 0;
is(2,4) = 0;
cs(2,4) = 0;
crmax(2,4) = 0;
buff(2,5) = 0;
pw(2,5) = 0;
cr(2,5) = 0;
iw(2,5) = 0;
cw(2,5) = 0;
cx(2,5) = 0;
is(2,5) = 0;
cs(2,5) = 0;
crmax(2,5) = 0;
buff(2,6) = 0;
pw(2,6) = 0;
cr(2,6) = 0;
iw(2,6) = 0;
cw(2,6) = 0;
cx(2,6) = 0;
is(2,6) = 0;
cs(2,6) = 0;
crmax(2,6) = 0;
buff(2,7) = 0;
pw(2,7) = 0;
cr(2,7) = 0;
iw(2,7) = 0;
cw(2,7) = 0;
cx(2,7) = 0;
is(2,7) = 0;
cs(2,7) = 0;
crmax(2,7) = 0;
cl[2] = 0;
cdy[2] = 0;
cds[2] = 0;
cdl[2] = 0;
cisb[2] = 0;
caddr[2] = 0;
cctrl[2] = 0;
cstart[2] = get_rng(0,NCONTEXT-1);
creturn[2] = get_rng(0,NCONTEXT-1);
buff(3,0) = 0;
pw(3,0) = 0;
cr(3,0) = 0;
iw(3,0) = 0;
cw(3,0) = 0;
cx(3,0) = 0;
is(3,0) = 0;
cs(3,0) = 0;
crmax(3,0) = 0;
buff(3,1) = 0;
pw(3,1) = 0;
cr(3,1) = 0;
iw(3,1) = 0;
cw(3,1) = 0;
cx(3,1) = 0;
is(3,1) = 0;
cs(3,1) = 0;
crmax(3,1) = 0;
buff(3,2) = 0;
pw(3,2) = 0;
cr(3,2) = 0;
iw(3,2) = 0;
cw(3,2) = 0;
cx(3,2) = 0;
is(3,2) = 0;
cs(3,2) = 0;
crmax(3,2) = 0;
buff(3,3) = 0;
pw(3,3) = 0;
cr(3,3) = 0;
iw(3,3) = 0;
cw(3,3) = 0;
cx(3,3) = 0;
is(3,3) = 0;
cs(3,3) = 0;
crmax(3,3) = 0;
buff(3,4) = 0;
pw(3,4) = 0;
cr(3,4) = 0;
iw(3,4) = 0;
cw(3,4) = 0;
cx(3,4) = 0;
is(3,4) = 0;
cs(3,4) = 0;
crmax(3,4) = 0;
buff(3,5) = 0;
pw(3,5) = 0;
cr(3,5) = 0;
iw(3,5) = 0;
cw(3,5) = 0;
cx(3,5) = 0;
is(3,5) = 0;
cs(3,5) = 0;
crmax(3,5) = 0;
buff(3,6) = 0;
pw(3,6) = 0;
cr(3,6) = 0;
iw(3,6) = 0;
cw(3,6) = 0;
cx(3,6) = 0;
is(3,6) = 0;
cs(3,6) = 0;
crmax(3,6) = 0;
buff(3,7) = 0;
pw(3,7) = 0;
cr(3,7) = 0;
iw(3,7) = 0;
cw(3,7) = 0;
cx(3,7) = 0;
is(3,7) = 0;
cs(3,7) = 0;
crmax(3,7) = 0;
cl[3] = 0;
cdy[3] = 0;
cds[3] = 0;
cdl[3] = 0;
cisb[3] = 0;
caddr[3] = 0;
cctrl[3] = 0;
cstart[3] = get_rng(0,NCONTEXT-1);
creturn[3] = get_rng(0,NCONTEXT-1);
// Dumping initializations
mem(0+0,0) = 0;
mem(0+1,0) = 0;
mem(0+2,0) = 0;
mem(3+0,0) = 0;
mem(4+0,0) = 0;
mem(5+0,0) = 0;
mem(6+0,0) = 0;
mem(7+0,0) = 0;
// Dumping context matching equalities
co(0,0) = 0;
delta(0,0) = -1;
co(1,0) = 0;
delta(1,0) = -1;
co(2,0) = 0;
delta(2,0) = -1;
co(3,0) = 0;
delta(3,0) = -1;
co(4,0) = 0;
delta(4,0) = -1;
co(5,0) = 0;
delta(5,0) = -1;
co(6,0) = 0;
delta(6,0) = -1;
co(7,0) = 0;
delta(7,0) = -1;
// Dumping thread 1
int ret_thread_1 = 0;
cdy[1] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[1] >= cstart[1]);
T1BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !35, metadata !DIExpression()), !dbg !44
// br label %label_1, !dbg !45
goto T1BLOCK1;
T1BLOCK1:
// call void @llvm.dbg.label(metadata !43), !dbg !46
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !36, metadata !DIExpression()), !dbg !47
// call void @llvm.dbg.value(metadata i64 2, metadata !39, metadata !DIExpression()), !dbg !47
// store atomic i64 2, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !48
// ST: Guess
iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW
old_cw = cw(1,0+1*1);
cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM
// Check
ASSUME(active[iw(1,0+1*1)] == 1);
ASSUME(active[cw(1,0+1*1)] == 1);
ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(cw(1,0+1*1) >= iw(1,0+1*1));
ASSUME(cw(1,0+1*1) >= old_cw);
ASSUME(cw(1,0+1*1) >= cr(1,0+1*1));
ASSUME(cw(1,0+1*1) >= cl[1]);
ASSUME(cw(1,0+1*1) >= cisb[1]);
ASSUME(cw(1,0+1*1) >= cdy[1]);
ASSUME(cw(1,0+1*1) >= cdl[1]);
ASSUME(cw(1,0+1*1) >= cds[1]);
ASSUME(cw(1,0+1*1) >= cctrl[1]);
ASSUME(cw(1,0+1*1) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0+1*1) = 2;
mem(0+1*1,cw(1,0+1*1)) = 2;
co(0+1*1,cw(1,0+1*1))+=1;
delta(0+1*1,cw(1,0+1*1)) = -1;
ASSUME(creturn[1] >= cw(1,0+1*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !40, metadata !DIExpression()), !dbg !49
// call void @llvm.dbg.value(metadata i64 1, metadata !42, metadata !DIExpression()), !dbg !49
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !50
// ST: Guess
iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW
old_cw = cw(1,0);
cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM
// Check
ASSUME(active[iw(1,0)] == 1);
ASSUME(active[cw(1,0)] == 1);
ASSUME(sforbid(0,cw(1,0))== 0);
ASSUME(iw(1,0) >= 0);
ASSUME(iw(1,0) >= 0);
ASSUME(cw(1,0) >= iw(1,0));
ASSUME(cw(1,0) >= old_cw);
ASSUME(cw(1,0) >= cr(1,0));
ASSUME(cw(1,0) >= cl[1]);
ASSUME(cw(1,0) >= cisb[1]);
ASSUME(cw(1,0) >= cdy[1]);
ASSUME(cw(1,0) >= cdl[1]);
ASSUME(cw(1,0) >= cds[1]);
ASSUME(cw(1,0) >= cctrl[1]);
ASSUME(cw(1,0) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0) = 1;
mem(0,cw(1,0)) = 1;
co(0,cw(1,0))+=1;
delta(0,cw(1,0)) = -1;
ASSUME(creturn[1] >= cw(1,0));
// ret i8* null, !dbg !51
ret_thread_1 = (- 1);
// Dumping thread 2
int ret_thread_2 = 0;
cdy[2] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[2] >= cstart[2]);
T2BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !54, metadata !DIExpression()), !dbg !68
// br label %label_2, !dbg !51
goto T2BLOCK1;
T2BLOCK1:
// call void @llvm.dbg.label(metadata !67), !dbg !70
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !57, metadata !DIExpression()), !dbg !71
// %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !54
// LD: Guess
old_cr = cr(2,0);
cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM
// Check
ASSUME(active[cr(2,0)] == 2);
ASSUME(cr(2,0) >= iw(2,0));
ASSUME(cr(2,0) >= 0);
ASSUME(cr(2,0) >= cdy[2]);
ASSUME(cr(2,0) >= cisb[2]);
ASSUME(cr(2,0) >= cdl[2]);
ASSUME(cr(2,0) >= cl[2]);
// Update
creg_r0 = cr(2,0);
crmax(2,0) = max(crmax(2,0),cr(2,0));
caddr[2] = max(caddr[2],0);
if(cr(2,0) < cw(2,0)) {
r0 = buff(2,0);
} else {
if(pw(2,0) != co(0,cr(2,0))) {
ASSUME(cr(2,0) >= old_cr);
}
pw(2,0) = co(0,cr(2,0));
r0 = mem(0,cr(2,0));
}
ASSUME(creturn[2] >= cr(2,0));
// call void @llvm.dbg.value(metadata i64 %0, metadata !59, metadata !DIExpression()), !dbg !71
// %conv = trunc i64 %0 to i32, !dbg !55
// call void @llvm.dbg.value(metadata i32 %conv, metadata !55, metadata !DIExpression()), !dbg !68
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !60, metadata !DIExpression()), !dbg !74
// call void @llvm.dbg.value(metadata i64 1, metadata !62, metadata !DIExpression()), !dbg !74
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !57
// ST: Guess
iw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW
old_cw = cw(2,0+2*1);
cw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM
// Check
ASSUME(active[iw(2,0+2*1)] == 2);
ASSUME(active[cw(2,0+2*1)] == 2);
ASSUME(sforbid(0+2*1,cw(2,0+2*1))== 0);
ASSUME(iw(2,0+2*1) >= 0);
ASSUME(iw(2,0+2*1) >= 0);
ASSUME(cw(2,0+2*1) >= iw(2,0+2*1));
ASSUME(cw(2,0+2*1) >= old_cw);
ASSUME(cw(2,0+2*1) >= cr(2,0+2*1));
ASSUME(cw(2,0+2*1) >= cl[2]);
ASSUME(cw(2,0+2*1) >= cisb[2]);
ASSUME(cw(2,0+2*1) >= cdy[2]);
ASSUME(cw(2,0+2*1) >= cdl[2]);
ASSUME(cw(2,0+2*1) >= cds[2]);
ASSUME(cw(2,0+2*1) >= cctrl[2]);
ASSUME(cw(2,0+2*1) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,0+2*1) = 1;
mem(0+2*1,cw(2,0+2*1)) = 1;
co(0+2*1,cw(2,0+2*1))+=1;
delta(0+2*1,cw(2,0+2*1)) = -1;
ASSUME(creturn[2] >= cw(2,0+2*1));
// %cmp = icmp eq i32 %conv, 1, !dbg !58
// %conv1 = zext i1 %cmp to i32, !dbg !58
// call void @llvm.dbg.value(metadata i32 %conv1, metadata !63, metadata !DIExpression()), !dbg !68
// call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !64, metadata !DIExpression()), !dbg !77
// %1 = zext i32 %conv1 to i64
// call void @llvm.dbg.value(metadata i64 %1, metadata !66, metadata !DIExpression()), !dbg !77
// store atomic i64 %1, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !60
// ST: Guess
iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW
old_cw = cw(2,3);
cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM
// Check
ASSUME(active[iw(2,3)] == 2);
ASSUME(active[cw(2,3)] == 2);
ASSUME(sforbid(3,cw(2,3))== 0);
ASSUME(iw(2,3) >= max(creg_r0,0));
ASSUME(iw(2,3) >= 0);
ASSUME(cw(2,3) >= iw(2,3));
ASSUME(cw(2,3) >= old_cw);
ASSUME(cw(2,3) >= cr(2,3));
ASSUME(cw(2,3) >= cl[2]);
ASSUME(cw(2,3) >= cisb[2]);
ASSUME(cw(2,3) >= cdy[2]);
ASSUME(cw(2,3) >= cdl[2]);
ASSUME(cw(2,3) >= cds[2]);
ASSUME(cw(2,3) >= cctrl[2]);
ASSUME(cw(2,3) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,3) = (r0==1);
mem(3,cw(2,3)) = (r0==1);
co(3,cw(2,3))+=1;
delta(3,cw(2,3)) = -1;
ASSUME(creturn[2] >= cw(2,3));
// ret i8* null, !dbg !61
ret_thread_2 = (- 1);
// Dumping thread 3
int ret_thread_3 = 0;
cdy[3] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[3] >= cstart[3]);
T3BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !82, metadata !DIExpression()), !dbg !95
// br label %label_3, !dbg !51
goto T3BLOCK1;
T3BLOCK1:
// call void @llvm.dbg.label(metadata !94), !dbg !97
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !84, metadata !DIExpression()), !dbg !98
// %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !54
// LD: Guess
old_cr = cr(3,0+2*1);
cr(3,0+2*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM
// Check
ASSUME(active[cr(3,0+2*1)] == 3);
ASSUME(cr(3,0+2*1) >= iw(3,0+2*1));
ASSUME(cr(3,0+2*1) >= 0);
ASSUME(cr(3,0+2*1) >= cdy[3]);
ASSUME(cr(3,0+2*1) >= cisb[3]);
ASSUME(cr(3,0+2*1) >= cdl[3]);
ASSUME(cr(3,0+2*1) >= cl[3]);
// Update
creg_r1 = cr(3,0+2*1);
crmax(3,0+2*1) = max(crmax(3,0+2*1),cr(3,0+2*1));
caddr[3] = max(caddr[3],0);
if(cr(3,0+2*1) < cw(3,0+2*1)) {
r1 = buff(3,0+2*1);
} else {
if(pw(3,0+2*1) != co(0+2*1,cr(3,0+2*1))) {
ASSUME(cr(3,0+2*1) >= old_cr);
}
pw(3,0+2*1) = co(0+2*1,cr(3,0+2*1));
r1 = mem(0+2*1,cr(3,0+2*1));
}
ASSUME(creturn[3] >= cr(3,0+2*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !86, metadata !DIExpression()), !dbg !98
// %conv = trunc i64 %0 to i32, !dbg !55
// call void @llvm.dbg.value(metadata i32 %conv, metadata !83, metadata !DIExpression()), !dbg !95
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !87, metadata !DIExpression()), !dbg !101
// call void @llvm.dbg.value(metadata i64 1, metadata !89, metadata !DIExpression()), !dbg !101
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) release, align 8, !dbg !57
// ST: Guess
// : Release
iw(3,0+1*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW
old_cw = cw(3,0+1*1);
cw(3,0+1*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM
// Check
ASSUME(active[iw(3,0+1*1)] == 3);
ASSUME(active[cw(3,0+1*1)] == 3);
ASSUME(sforbid(0+1*1,cw(3,0+1*1))== 0);
ASSUME(iw(3,0+1*1) >= 0);
ASSUME(iw(3,0+1*1) >= 0);
ASSUME(cw(3,0+1*1) >= iw(3,0+1*1));
ASSUME(cw(3,0+1*1) >= old_cw);
ASSUME(cw(3,0+1*1) >= cr(3,0+1*1));
ASSUME(cw(3,0+1*1) >= cl[3]);
ASSUME(cw(3,0+1*1) >= cisb[3]);
ASSUME(cw(3,0+1*1) >= cdy[3]);
ASSUME(cw(3,0+1*1) >= cdl[3]);
ASSUME(cw(3,0+1*1) >= cds[3]);
ASSUME(cw(3,0+1*1) >= cctrl[3]);
ASSUME(cw(3,0+1*1) >= caddr[3]);
ASSUME(cw(3,0+1*1) >= cr(3,0+0));
ASSUME(cw(3,0+1*1) >= cr(3,0+1));
ASSUME(cw(3,0+1*1) >= cr(3,0+2));
ASSUME(cw(3,0+1*1) >= cr(3,3+0));
ASSUME(cw(3,0+1*1) >= cr(3,4+0));
ASSUME(cw(3,0+1*1) >= cr(3,5+0));
ASSUME(cw(3,0+1*1) >= cr(3,6+0));
ASSUME(cw(3,0+1*1) >= cr(3,7+0));
ASSUME(cw(3,0+1*1) >= cw(3,0+0));
ASSUME(cw(3,0+1*1) >= cw(3,0+1));
ASSUME(cw(3,0+1*1) >= cw(3,0+2));
ASSUME(cw(3,0+1*1) >= cw(3,3+0));
ASSUME(cw(3,0+1*1) >= cw(3,4+0));
ASSUME(cw(3,0+1*1) >= cw(3,5+0));
ASSUME(cw(3,0+1*1) >= cw(3,6+0));
ASSUME(cw(3,0+1*1) >= cw(3,7+0));
// Update
caddr[3] = max(caddr[3],0);
buff(3,0+1*1) = 1;
mem(0+1*1,cw(3,0+1*1)) = 1;
co(0+1*1,cw(3,0+1*1))+=1;
delta(0+1*1,cw(3,0+1*1)) = -1;
is(3,0+1*1) = iw(3,0+1*1);
cs(3,0+1*1) = cw(3,0+1*1);
ASSUME(creturn[3] >= cw(3,0+1*1));
// %cmp = icmp eq i32 %conv, 1, !dbg !58
// %conv1 = zext i1 %cmp to i32, !dbg !58
// call void @llvm.dbg.value(metadata i32 %conv1, metadata !90, metadata !DIExpression()), !dbg !95
// call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !91, metadata !DIExpression()), !dbg !104
// %1 = zext i32 %conv1 to i64
// call void @llvm.dbg.value(metadata i64 %1, metadata !93, metadata !DIExpression()), !dbg !104
// store atomic i64 %1, i64* @atom_2_X0_1 seq_cst, align 8, !dbg !60
// ST: Guess
iw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW
old_cw = cw(3,4);
cw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM
// Check
ASSUME(active[iw(3,4)] == 3);
ASSUME(active[cw(3,4)] == 3);
ASSUME(sforbid(4,cw(3,4))== 0);
ASSUME(iw(3,4) >= max(creg_r1,0));
ASSUME(iw(3,4) >= 0);
ASSUME(cw(3,4) >= iw(3,4));
ASSUME(cw(3,4) >= old_cw);
ASSUME(cw(3,4) >= cr(3,4));
ASSUME(cw(3,4) >= cl[3]);
ASSUME(cw(3,4) >= cisb[3]);
ASSUME(cw(3,4) >= cdy[3]);
ASSUME(cw(3,4) >= cdl[3]);
ASSUME(cw(3,4) >= cds[3]);
ASSUME(cw(3,4) >= cctrl[3]);
ASSUME(cw(3,4) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,4) = (r1==1);
mem(4,cw(3,4)) = (r1==1);
co(4,cw(3,4))+=1;
delta(4,cw(3,4)) = -1;
ASSUME(creturn[3] >= cw(3,4));
// ret i8* null, !dbg !61
ret_thread_3 = (- 1);
// Dumping thread 0
int ret_thread_0 = 0;
cdy[0] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[0] >= cstart[0]);
T0BLOCK0:
// %thr0 = alloca i64, align 8
// %thr1 = alloca i64, align 8
// %thr2 = alloca i64, align 8
// call void @llvm.dbg.value(metadata i32 %argc, metadata !114, metadata !DIExpression()), !dbg !152
// call void @llvm.dbg.value(metadata i8** %argv, metadata !115, metadata !DIExpression()), !dbg !152
// %0 = bitcast i64* %thr0 to i8*, !dbg !79
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !79
// call void @llvm.dbg.declare(metadata i64* %thr0, metadata !116, metadata !DIExpression()), !dbg !154
// %1 = bitcast i64* %thr1 to i8*, !dbg !81
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !81
// call void @llvm.dbg.declare(metadata i64* %thr1, metadata !120, metadata !DIExpression()), !dbg !156
// %2 = bitcast i64* %thr2 to i8*, !dbg !83
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !83
// call void @llvm.dbg.declare(metadata i64* %thr2, metadata !121, metadata !DIExpression()), !dbg !158
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !122, metadata !DIExpression()), !dbg !159
// call void @llvm.dbg.value(metadata i64 0, metadata !124, metadata !DIExpression()), !dbg !159
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !86
// ST: Guess
iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,0+2*1);
cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,0+2*1)] == 0);
ASSUME(active[cw(0,0+2*1)] == 0);
ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(cw(0,0+2*1) >= iw(0,0+2*1));
ASSUME(cw(0,0+2*1) >= old_cw);
ASSUME(cw(0,0+2*1) >= cr(0,0+2*1));
ASSUME(cw(0,0+2*1) >= cl[0]);
ASSUME(cw(0,0+2*1) >= cisb[0]);
ASSUME(cw(0,0+2*1) >= cdy[0]);
ASSUME(cw(0,0+2*1) >= cdl[0]);
ASSUME(cw(0,0+2*1) >= cds[0]);
ASSUME(cw(0,0+2*1) >= cctrl[0]);
ASSUME(cw(0,0+2*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+2*1) = 0;
mem(0+2*1,cw(0,0+2*1)) = 0;
co(0+2*1,cw(0,0+2*1))+=1;
delta(0+2*1,cw(0,0+2*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+2*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !125, metadata !DIExpression()), !dbg !161
// call void @llvm.dbg.value(metadata i64 0, metadata !127, metadata !DIExpression()), !dbg !161
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !88
// ST: Guess
iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,0+1*1);
cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,0+1*1)] == 0);
ASSUME(active[cw(0,0+1*1)] == 0);
ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(cw(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cw(0,0+1*1) >= old_cw);
ASSUME(cw(0,0+1*1) >= cr(0,0+1*1));
ASSUME(cw(0,0+1*1) >= cl[0]);
ASSUME(cw(0,0+1*1) >= cisb[0]);
ASSUME(cw(0,0+1*1) >= cdy[0]);
ASSUME(cw(0,0+1*1) >= cdl[0]);
ASSUME(cw(0,0+1*1) >= cds[0]);
ASSUME(cw(0,0+1*1) >= cctrl[0]);
ASSUME(cw(0,0+1*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+1*1) = 0;
mem(0+1*1,cw(0,0+1*1)) = 0;
co(0+1*1,cw(0,0+1*1))+=1;
delta(0+1*1,cw(0,0+1*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+1*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !128, metadata !DIExpression()), !dbg !163
// call void @llvm.dbg.value(metadata i64 0, metadata !130, metadata !DIExpression()), !dbg !163
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !90
// ST: Guess
iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,0);
cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,0)] == 0);
ASSUME(active[cw(0,0)] == 0);
ASSUME(sforbid(0,cw(0,0))== 0);
ASSUME(iw(0,0) >= 0);
ASSUME(iw(0,0) >= 0);
ASSUME(cw(0,0) >= iw(0,0));
ASSUME(cw(0,0) >= old_cw);
ASSUME(cw(0,0) >= cr(0,0));
ASSUME(cw(0,0) >= cl[0]);
ASSUME(cw(0,0) >= cisb[0]);
ASSUME(cw(0,0) >= cdy[0]);
ASSUME(cw(0,0) >= cdl[0]);
ASSUME(cw(0,0) >= cds[0]);
ASSUME(cw(0,0) >= cctrl[0]);
ASSUME(cw(0,0) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0) = 0;
mem(0,cw(0,0)) = 0;
co(0,cw(0,0))+=1;
delta(0,cw(0,0)) = -1;
ASSUME(creturn[0] >= cw(0,0));
// call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !131, metadata !DIExpression()), !dbg !165
// call void @llvm.dbg.value(metadata i64 0, metadata !133, metadata !DIExpression()), !dbg !165
// store atomic i64 0, i64* @atom_1_X0_1 monotonic, align 8, !dbg !92
// ST: Guess
iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,3);
cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,3)] == 0);
ASSUME(active[cw(0,3)] == 0);
ASSUME(sforbid(3,cw(0,3))== 0);
ASSUME(iw(0,3) >= 0);
ASSUME(iw(0,3) >= 0);
ASSUME(cw(0,3) >= iw(0,3));
ASSUME(cw(0,3) >= old_cw);
ASSUME(cw(0,3) >= cr(0,3));
ASSUME(cw(0,3) >= cl[0]);
ASSUME(cw(0,3) >= cisb[0]);
ASSUME(cw(0,3) >= cdy[0]);
ASSUME(cw(0,3) >= cdl[0]);
ASSUME(cw(0,3) >= cds[0]);
ASSUME(cw(0,3) >= cctrl[0]);
ASSUME(cw(0,3) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,3) = 0;
mem(3,cw(0,3)) = 0;
co(3,cw(0,3))+=1;
delta(3,cw(0,3)) = -1;
ASSUME(creturn[0] >= cw(0,3));
// call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !134, metadata !DIExpression()), !dbg !167
// call void @llvm.dbg.value(metadata i64 0, metadata !136, metadata !DIExpression()), !dbg !167
// store atomic i64 0, i64* @atom_2_X0_1 monotonic, align 8, !dbg !94
// ST: Guess
iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,4);
cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,4)] == 0);
ASSUME(active[cw(0,4)] == 0);
ASSUME(sforbid(4,cw(0,4))== 0);
ASSUME(iw(0,4) >= 0);
ASSUME(iw(0,4) >= 0);
ASSUME(cw(0,4) >= iw(0,4));
ASSUME(cw(0,4) >= old_cw);
ASSUME(cw(0,4) >= cr(0,4));
ASSUME(cw(0,4) >= cl[0]);
ASSUME(cw(0,4) >= cisb[0]);
ASSUME(cw(0,4) >= cdy[0]);
ASSUME(cw(0,4) >= cdl[0]);
ASSUME(cw(0,4) >= cds[0]);
ASSUME(cw(0,4) >= cctrl[0]);
ASSUME(cw(0,4) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,4) = 0;
mem(4,cw(0,4)) = 0;
co(4,cw(0,4))+=1;
delta(4,cw(0,4)) = -1;
ASSUME(creturn[0] >= cw(0,4));
// %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !95
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[1] >= cdy[0]);
// %call9 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !96
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[2] >= cdy[0]);
// %call10 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !97
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[3] >= cdy[0]);
// %3 = load i64, i64* %thr0, align 8, !dbg !98, !tbaa !99
// LD: Guess
old_cr = cr(0,5);
cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,5)] == 0);
ASSUME(cr(0,5) >= iw(0,5));
ASSUME(cr(0,5) >= 0);
ASSUME(cr(0,5) >= cdy[0]);
ASSUME(cr(0,5) >= cisb[0]);
ASSUME(cr(0,5) >= cdl[0]);
ASSUME(cr(0,5) >= cl[0]);
// Update
creg_r3 = cr(0,5);
crmax(0,5) = max(crmax(0,5),cr(0,5));
caddr[0] = max(caddr[0],0);
if(cr(0,5) < cw(0,5)) {
r3 = buff(0,5);
} else {
if(pw(0,5) != co(5,cr(0,5))) {
ASSUME(cr(0,5) >= old_cr);
}
pw(0,5) = co(5,cr(0,5));
r3 = mem(5,cr(0,5));
}
ASSUME(creturn[0] >= cr(0,5));
// %call11 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !103
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[1]);
// %4 = load i64, i64* %thr1, align 8, !dbg !104, !tbaa !99
// LD: Guess
old_cr = cr(0,6);
cr(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,6)] == 0);
ASSUME(cr(0,6) >= iw(0,6));
ASSUME(cr(0,6) >= 0);
ASSUME(cr(0,6) >= cdy[0]);
ASSUME(cr(0,6) >= cisb[0]);
ASSUME(cr(0,6) >= cdl[0]);
ASSUME(cr(0,6) >= cl[0]);
// Update
creg_r4 = cr(0,6);
crmax(0,6) = max(crmax(0,6),cr(0,6));
caddr[0] = max(caddr[0],0);
if(cr(0,6) < cw(0,6)) {
r4 = buff(0,6);
} else {
if(pw(0,6) != co(6,cr(0,6))) {
ASSUME(cr(0,6) >= old_cr);
}
pw(0,6) = co(6,cr(0,6));
r4 = mem(6,cr(0,6));
}
ASSUME(creturn[0] >= cr(0,6));
// %call12 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !105
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[2]);
// %5 = load i64, i64* %thr2, align 8, !dbg !106, !tbaa !99
// LD: Guess
old_cr = cr(0,7);
cr(0,7) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,7)] == 0);
ASSUME(cr(0,7) >= iw(0,7));
ASSUME(cr(0,7) >= 0);
ASSUME(cr(0,7) >= cdy[0]);
ASSUME(cr(0,7) >= cisb[0]);
ASSUME(cr(0,7) >= cdl[0]);
ASSUME(cr(0,7) >= cl[0]);
// Update
creg_r5 = cr(0,7);
crmax(0,7) = max(crmax(0,7),cr(0,7));
caddr[0] = max(caddr[0],0);
if(cr(0,7) < cw(0,7)) {
r5 = buff(0,7);
} else {
if(pw(0,7) != co(7,cr(0,7))) {
ASSUME(cr(0,7) >= old_cr);
}
pw(0,7) = co(7,cr(0,7));
r5 = mem(7,cr(0,7));
}
ASSUME(creturn[0] >= cr(0,7));
// %call13 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !107
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[3]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !138, metadata !DIExpression()), !dbg !182
// %6 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) seq_cst, align 8, !dbg !109
// LD: Guess
old_cr = cr(0,0+1*1);
cr(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,0+1*1)] == 0);
ASSUME(cr(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cr(0,0+1*1) >= 0);
ASSUME(cr(0,0+1*1) >= cdy[0]);
ASSUME(cr(0,0+1*1) >= cisb[0]);
ASSUME(cr(0,0+1*1) >= cdl[0]);
ASSUME(cr(0,0+1*1) >= cl[0]);
// Update
creg_r6 = cr(0,0+1*1);
crmax(0,0+1*1) = max(crmax(0,0+1*1),cr(0,0+1*1));
caddr[0] = max(caddr[0],0);
if(cr(0,0+1*1) < cw(0,0+1*1)) {
r6 = buff(0,0+1*1);
} else {
if(pw(0,0+1*1) != co(0+1*1,cr(0,0+1*1))) {
ASSUME(cr(0,0+1*1) >= old_cr);
}
pw(0,0+1*1) = co(0+1*1,cr(0,0+1*1));
r6 = mem(0+1*1,cr(0,0+1*1));
}
ASSUME(creturn[0] >= cr(0,0+1*1));
// call void @llvm.dbg.value(metadata i64 %6, metadata !140, metadata !DIExpression()), !dbg !182
// %conv = trunc i64 %6 to i32, !dbg !110
// call void @llvm.dbg.value(metadata i32 %conv, metadata !137, metadata !DIExpression()), !dbg !152
// %cmp = icmp eq i32 %conv, 2, !dbg !111
// %conv14 = zext i1 %cmp to i32, !dbg !111
// call void @llvm.dbg.value(metadata i32 %conv14, metadata !141, metadata !DIExpression()), !dbg !152
// call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !143, metadata !DIExpression()), !dbg !186
// %7 = load atomic i64, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !113
// LD: Guess
old_cr = cr(0,3);
cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,3)] == 0);
ASSUME(cr(0,3) >= iw(0,3));
ASSUME(cr(0,3) >= 0);
ASSUME(cr(0,3) >= cdy[0]);
ASSUME(cr(0,3) >= cisb[0]);
ASSUME(cr(0,3) >= cdl[0]);
ASSUME(cr(0,3) >= cl[0]);
// Update
creg_r7 = cr(0,3);
crmax(0,3) = max(crmax(0,3),cr(0,3));
caddr[0] = max(caddr[0],0);
if(cr(0,3) < cw(0,3)) {
r7 = buff(0,3);
} else {
if(pw(0,3) != co(3,cr(0,3))) {
ASSUME(cr(0,3) >= old_cr);
}
pw(0,3) = co(3,cr(0,3));
r7 = mem(3,cr(0,3));
}
ASSUME(creturn[0] >= cr(0,3));
// call void @llvm.dbg.value(metadata i64 %7, metadata !145, metadata !DIExpression()), !dbg !186
// %conv18 = trunc i64 %7 to i32, !dbg !114
// call void @llvm.dbg.value(metadata i32 %conv18, metadata !142, metadata !DIExpression()), !dbg !152
// call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !147, metadata !DIExpression()), !dbg !189
// %8 = load atomic i64, i64* @atom_2_X0_1 seq_cst, align 8, !dbg !116
// LD: Guess
old_cr = cr(0,4);
cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,4)] == 0);
ASSUME(cr(0,4) >= iw(0,4));
ASSUME(cr(0,4) >= 0);
ASSUME(cr(0,4) >= cdy[0]);
ASSUME(cr(0,4) >= cisb[0]);
ASSUME(cr(0,4) >= cdl[0]);
ASSUME(cr(0,4) >= cl[0]);
// Update
creg_r8 = cr(0,4);
crmax(0,4) = max(crmax(0,4),cr(0,4));
caddr[0] = max(caddr[0],0);
if(cr(0,4) < cw(0,4)) {
r8 = buff(0,4);
} else {
if(pw(0,4) != co(4,cr(0,4))) {
ASSUME(cr(0,4) >= old_cr);
}
pw(0,4) = co(4,cr(0,4));
r8 = mem(4,cr(0,4));
}
ASSUME(creturn[0] >= cr(0,4));
// call void @llvm.dbg.value(metadata i64 %8, metadata !149, metadata !DIExpression()), !dbg !189
// %conv22 = trunc i64 %8 to i32, !dbg !117
// call void @llvm.dbg.value(metadata i32 %conv22, metadata !146, metadata !DIExpression()), !dbg !152
// %and = and i32 %conv18, %conv22, !dbg !118
creg_r9 = max(creg_r7,creg_r8);
ASSUME(active[creg_r9] == 0);
r9 = r7 & r8;
// call void @llvm.dbg.value(metadata i32 %and, metadata !150, metadata !DIExpression()), !dbg !152
// %and23 = and i32 %conv14, %and, !dbg !119
creg_r10 = max(max(creg_r6,0),creg_r9);
ASSUME(active[creg_r10] == 0);
r10 = (r6==2) & r9;
// call void @llvm.dbg.value(metadata i32 %and23, metadata !151, metadata !DIExpression()), !dbg !152
// %cmp24 = icmp eq i32 %and23, 1, !dbg !120
// br i1 %cmp24, label %if.then, label %if.end, !dbg !122
old_cctrl = cctrl[0];
cctrl[0] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[0] >= old_cctrl);
ASSUME(cctrl[0] >= creg_r10);
ASSUME(cctrl[0] >= 0);
if((r10==1)) {
goto T0BLOCK1;
} else {
goto T0BLOCK2;
}
T0BLOCK1:
// call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0), i32 noundef 68, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !123
// unreachable, !dbg !123
r11 = 1;
T0BLOCK2:
// %9 = bitcast i64* %thr2 to i8*, !dbg !126
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !126
// %10 = bitcast i64* %thr1 to i8*, !dbg !126
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !126
// %11 = bitcast i64* %thr0 to i8*, !dbg !126
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #7, !dbg !126
// ret i32 0, !dbg !127
ret_thread_0 = 0;
ASSERT(r11== 0);
}
| [
"tuan-phong.ngo@it.uu.se"
] | tuan-phong.ngo@it.uu.se |
84117a0c2c6cd034d6794823c8e5fb4203670dd5 | 28be0e4d7104992d421d4d1942359fe54ca6a987 | /read_GMO.h | 5343624958c6c031f01fc6ae3b20ee203ab25ca5 | [] | no_license | newfishofgit/void-pro | e409b37d7de326d58748e66db439ba6bfc52234c | d2577979b4203c53344df5527854524acfda47c5 | refs/heads/master | 2021-07-11T02:41:49.369147 | 2017-10-11T11:21:07 | 2017-10-11T11:21:07 | 106,543,985 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,783 | h | #ifndef _read_GMO_H
#define _read_GMO_H
#include "global_variables.h"
#ifndef MaxChar
#define MaxChar 10
#endif
#ifndef MaxLine
#define MaxLine 1000
#endif
//#ifndef MaxObs
//#define MaxObs 20
//#endif
//#ifndef SumSys
//#define SumSys 2
//for system number, 0 - GPS, 1 - GLONASS
//#endif
/*typedef struct tag_obs_type
{
char system_type[MaxChar];
int sum_obs_type;
vector<string> obs_type;
tag_obs_type()
{
for(int i = 0;i<MaxChar;i++)
{
system_type[i] = '\0';
}
sum_obs_type = 0;
}
}ObsType;*/
typedef struct tag_meta_obs_type {
char system_type;
int sum_obs_type;
vector<string> meas_type;
} meta_obs_type;
typedef struct tag_obs_type {
vector<meta_obs_type> obs_type;
int return_designated_sum_obs_type(char prn, int &designated) {
int sum = 0;
designated = 0;
for(int i = 0;i < obs_type.size();i++) {
if(obs_type[i].system_type == prn) {
sum = obs_type[i].sum_obs_type;
designated = i;
break;
}
}
return sum;
}
}ObsType;
typedef struct tag_GMO_head
{
double rinex_version;
CRDCARTESIAN approx_pos; //approximate position (WGS84)
//ObsType obs_types[SumSys]; //observation type;0-GPS
ObsType obs_types;
double interval; //interval (s)
UTTime start_time; //start time
UTTime end_time; //end time
int leap_second; //leap second
tag_GMO_head()
{
rinex_version = 0.0;
interval = 0.0;
leap_second = 0;
}
}GMOHrd;
typedef struct tag_record_header
{
UTTime epoch;
int epoch_tag;
int sum_sat; //satellite sum
//int sum_prn;
//vector<int> gps_prn; //list of satellite
vector<string> sat_prn;
tag_record_header()
{
sum_sat = 0;
//sum_prn = 0;
epoch_tag = 0;
}
}GMORecHrd;
typedef struct tag_GPS_observation
{
vector<double> obs;
//vector<int> tag1;
//vector<int> tag2;
}RecGPSObs;
typedef struct tag_GMO_record
{
GMORecHrd hrd;
vector<RecGPSObs> GPS_obs;
}GMORecord;
typedef struct tag_GMO
{
GMOHrd header;
vector<GMORecord> record;
}GMO;
class GMOReader
{
private:
//read file data
static int read_GMO_record(FILE *fp ,vector<GMORecord> &record, GMOHrd header);
//read data of one epoch
static bool read_epoch_record(FILE *fp, GMORecord *epoch_record, GMOHrd header);
public:
//read file header
static int read_GMO_head(FILE *fp ,GMOHrd *header);
//read data before end_epoch; if this is the end of file, return false
static bool read_epochs_record(FILE *fp, GMJulianDay end_mjd, vector<GMORecord> &record, GMOHrd header);
//succeed return 1; fail return 0
static int read_GMO(string filename, GMO *GMO_data);
};
#endif
| [
"ys@ys.com"
] | ys@ys.com |
2b51eac884545d86fe304f49d39126dc301e2402 | 36c5ff3396bb095f8ab957fcee6cbce78bb86cd1 | /esp32/SerialTopics/instructions.cpp | df22f305fd0dbad86db36a1394c29b2bed54f235 | [] | no_license | clubrobot/team-2020 | 97ecf6aed46f57f86dac79205858c486378a87a6 | 96e9b0f29b50e8651dfe81b5f6083aa99e96bf58 | refs/heads/master | 2020-07-28T17:54:11.873367 | 2020-07-01T07:39:11 | 2020-07-01T07:39:11 | 209,484,853 | 3 | 1 | null | 2020-04-09T07:31:39 | 2019-09-19T07:01:35 | C++ | UTF-8 | C++ | false | false | 251 | cpp | #include "instructions.h"
#include <SerialTalks.h>
void ON(SerialTalks &inst, Deserializer &input, Serializer &output)
{
digitalWrite(2, HIGH);
}
void OFF(SerialTalks &inst, Deserializer &input, Serializer &output)
{
digitalWrite(2, LOW);
} | [
"matlecr35@gmail.com"
] | matlecr35@gmail.com |
26521849c75096e491c6799d1f7f3a8e975d81f5 | 066bb193e21c841b617ade6dbb0047f19d613c28 | /avisynth258MT/src/plugins/TCPDeliver/TCPCommon.cpp | bd2d06948895d5743d6b020e73b8b8e388c4196f | [] | no_license | XhmikosR/avisynth-mt | 2943c862d8ade21a6391b9838faffd2c2a1e08ec | 90fc1a32abe64fdc0aa83b99c7a9381c86550418 | refs/heads/master | 2020-07-21T19:55:52.305264 | 2017-08-26T22:06:36 | 2017-08-26T22:06:36 | 34,184,306 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,998 | cpp | // Avisynth v2.5.
// http://www.avisynth.org
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
// http://www.gnu.org/copyleft/gpl.html .
//
// Linking Avisynth statically or dynamically with other modules is making a
// combined work based on Avisynth. Thus, the terms and conditions of the GNU
// General Public License cover the whole combination.
//
// As a special exception, the copyright holders of Avisynth give you
// permission to link Avisynth with independent modules that communicate with
// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license
// terms of these independent modules, and to copy and distribute the
// resulting combined work under terms of your choice, provided that
// every copy of the combined work is accompanied by a complete copy of
// the source code of Avisynth (the version of Avisynth used to produce the
// combined work), being distributed under the terms of the GNU General
// Public License plus this exception. An independent module is a module
// which is not derived from or based on Avisynth, such as 3rd-party filters,
// import and export plugins, or graphical user interfaces.
// TCPDeliver (c) 2004 by Klaus Post
#include "TCPCommon.h"
#include "avisynth.h"
#define TCPD_DO1(buf,i) {s1 += buf[i]; s2 += s1;}
#define TCPD_DO2(buf,i) TCPD_DO1(buf,i); TCPD_DO1(buf,i+1);
#define TCPD_DO4(buf,i) TCPD_DO2(buf,i); TCPD_DO2(buf,i+2);
#define TCPD_DO8(buf,i) TCPD_DO4(buf,i); TCPD_DO4(buf,i+4);
#define TCPD_DO16(buf,i) TCPD_DO8(buf,i); TCPD_DO8(buf,i+8);
unsigned int adler32(unsigned int adler, const char* buf, unsigned int len)
{
unsigned int s1 = adler & 0xffff;
unsigned int s2 = (adler >> 16) & 0xffff;
int k;
if (buf == NULL)
return 1;
while (len > 0)
{
k = len < TCPD_NMAX ? (int) len : TCPD_NMAX;
len -= k;
if (k >= 16) do
{
TCPD_DO16(buf,0);
buf += 16;
k -= 16;
} while (k >= 16);
if (k != 0) do
{
s1 += *buf++;
s2 += s1;
} while (--k > 0);
s1 %= TCPD_BASE;
s2 %= TCPD_BASE;
}
return (s2 << 16) | s1;
}
/*
BOOL APIENTRY DllMain(HANDLE hModule, ULONG ulReason, LPVOID lpReserved) {
switch(ulReason) {
case DLL_PROCESS_ATTACH:
hInstance=(HINSTANCE)hModule;
_RPT0(0,"Process attach\n");
break;
case DLL_PROCESS_DETACH:
_RPT0(0,"Process detach\n");
break;
}
return TRUE;
}
*/ | [
"xhmikosr@gmail.com"
] | xhmikosr@gmail.com |
a43774a488f36c96d6f2c59b3b9c7d48434fd00f | 4f673693b02094bfb8327d6a7a5fe0548ade1245 | /node_controller_dump.h | 38656aea804378534ea2e78b39981df161fd39f4 | [] | no_license | Renat060888/dss_node | 04d8c01a2ad8fa5501e3d2454ea48a78e04bc942 | afac38245046b15a2c707c97c082ec74b1e69d6b | refs/heads/master | 2021-02-08T02:54:16.847977 | 2020-09-12T18:49:42 | 2020-09-12T18:49:42 | 244,101,246 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 162 | h | #ifndef NODE_CONTROLLER_DUMP_H
#define NODE_CONTROLLER_DUMP_H
class NodeControllerDump
{
public:
NodeControllerDump();
};
#endif // NODE_CONTROLLER_DUMP_H
| [
"renat@desktop.home"
] | renat@desktop.home |
6248b6b1383f38101afcddc7a4b2d3d38fcc6975 | 14ad35d2c152bb2b6a0ee52b304282dea22999b0 | /OpenGL Framework/window.h | 8fcc08736cb842bdcfefc76044754b6c042a0295 | [] | no_license | ivanmontero/opengl-framework | 2b077ae6db9e94879fe8ca8964af77d9ebbc9c43 | 0390e0ee62a8430e05f1370eef6be6edbe418507 | refs/heads/master | 2021-07-06T20:41:50.605560 | 2017-10-03T01:36:24 | 2017-10-03T01:36:24 | 105,603,515 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 859 | h | #pragma once
#include <GLFW/glfw3.h>
typedef struct SIZE {
int width;
int height;
};
class Window {
private:
static GLFWwindow* window;
public:
static bool Initialize(int width, int height);
static void Resize(int width, int height);
static void Show();
static void Hide();
static void Dispose();
static void Poll();
static void SwapBuffers();
static void SetVSync(bool vsync);
static void SetShouldClose(bool close);
static bool ShouldClose();
static SIZE GetSize();
};
void ResizeCallback(GLFWwindow* window, int width, int height);
void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mode);
void CursorCallback(GLFWwindow* window, double xpos, double ypos);
void MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
void ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
| [
"ivanspmontero@gmail.com"
] | ivanspmontero@gmail.com |
1b08312115f3505e25ab0dae04ff2f2d037abba8 | 5d3b17e59b458815d15c7072368d5ca014bffe82 | /qtworkplace/QTimeLineTest/widget.cpp | 53152ccd1850d3cb7648f8f30be0fa63068a44e9 | [] | no_license | wushengjun85/QtcreatorWorkplace | 274d75331bbdeec57f11f9bb1b59c35c551b3ae4 | 2366644909f2dce2e5640d7cd67fbee447740bea | refs/heads/master | 2021-01-19T23:50:12.348968 | 2017-12-25T08:40:55 | 2017-12-25T08:40:55 | 89,039,956 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 725 | cpp | #include "widget.h"
#include "ui_widget.h"
#include<QPropertyAnimation>
#include<QPushButton>
#include<QLabel>
#include<QDebug>
#include<QTimeLine>
static int i;
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QTimeLine *timeline=new QTimeLine(10000);
timeline->setFrameRange(0, 100);
timeline->setLoopCount(1);
//timeline->setUpdateInterval(2);
timeline->setCurveShape(QTimeLine::EaseOutCurve);
connect(timeline,SIGNAL(frameChanged(int)),ui->progressBar,SLOT(setValue(int)));
//connect(timeline,SIGNAL(frameChanged(int)),this,SLOT(paintEvent()));
timeline->start();
}
Widget::~Widget()
{
delete ui;
}
void Widget::shanhua()
{
}
| [
"wushengjun85@163.com"
] | wushengjun85@163.com |
a3a1ad9d96aa79e6be458990288c0d86facb2246 | 9d6e7657ef109d4131a239ccd21b665a92f3b17b | /Strategy/Duck.hpp | 57d7b17a14c865a10d3542fdc6ac77b9f86d9160 | [] | no_license | CtfChan/DesignPatternsCpp | 380f445887156c5d356a4de14f503710bd080480 | 1ca4288b907e0b711b4d5418ff0dc0ade72b25f0 | refs/heads/master | 2022-07-06T02:16:10.142991 | 2020-05-19T19:05:45 | 2020-05-19T19:05:45 | 264,729,319 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,227 | hpp | #pragma once
#include "FlyBehaviour.hpp"
#include "QuackBehaviour.hpp"
#include <memory>
class Duck {
private:
std::unique_ptr<FlyBehaviour> fly_behaviour_;
std::unique_ptr<QuackBehaviour> quack_behaviour_;
public:
Duck(std::unique_ptr<FlyBehaviour> fly_behaviour, std::unique_ptr<QuackBehaviour> quack_behavior);
virtual ~Duck() = default;
void swim() const;
virtual void display() const = 0;
void performQuack() const;
void performFly() const;
// Note: these set functions will move the function input ptr to private ptr
void setFlyBehaviour(std::unique_ptr<FlyBehaviour> fly_behaviour);
void setQuackBehaviour(std::unique_ptr<QuackBehaviour> quack_behavior);
};
class MallardDuck : public Duck {
public:
MallardDuck();
void display() const override;
};
class RedheadDuck : public Duck {
public:
RedheadDuck();
void display() const override;
};
class RubberDuck : public Duck {
public:
RubberDuck();
void display() const override;
};
class DecoyDuck : public Duck {
public:
DecoyDuck();
void display() const override;
};
class ModelDuck : public Duck {
public:
ModelDuck();
void display() const override;
};
| [
"christophertzechan@gmail.com"
] | christophertzechan@gmail.com |
c42d6d7b9ea90c3eb36a19092f905e0dcaddc70f | 75f38387af3bd51a862157258a0949081eb297b7 | /src/test/ns.cpp | 6a1a604beaf1e891a910aff2ab722c03b8906345 | [
"MIT"
] | permissive | ifritJP/lctags | 64475963352074d0fb58eed7fca92c91d485ec6e | bb13d6f627ba58a79f798dbd40a9f48ae24447d3 | refs/heads/master | 2023-07-24T13:23:13.184676 | 2023-07-23T00:59:59 | 2023-07-23T00:59:59 | 81,969,676 | 20 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 281 | cpp | #include <stdio.h>
namespace ns1 {
int val1 = 1;
int val2 = 2;
namespace ns2 {
int val2 = -2;
namespace ns3 {
int val3 = 3;
}
void sub() {
printf( "%d, %d, %d, %d\n", val1, val2, ns1::val2, ns3::val3 );
}
}
}
main()
{
ns1::ns2::sub();
}
| [
"15117169+ifritJP@users.noreply.github.com"
] | 15117169+ifritJP@users.noreply.github.com |
f837fd43ab6b461d0eccf345fae84902a3c86b36 | faa5d1d27a89cba2657f6fe53d9106630ef2c104 | /洛谷/P2658.cpp | 1aff594e7896a07426f562085aa98096ea0f0871 | [] | no_license | xiao-lin52/My-Codes | f4feef04a05b1904a1f31e0e5a04e0a48ee61cb9 | d8fc530ade2bbac32c016a731c667c4189e3c6c7 | refs/heads/main | 2023-03-12T23:32:55.219341 | 2021-03-07T07:31:32 | 2021-03-07T07:31:32 | 304,806,222 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,037 | cpp | #include<cstdio>
#include<cmath>
using namespace std;
struct q
{
int x;
int y;
};
q a[250001];
int n,m,l,r,mid,sum,map[501][501],v[501][501],next[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int bfs()
{
int s=0,head=0,tail=1,visit[501][501]={0};
visit[1][1]=1;
if(v[1][1])
s++;
while(head<tail)
{
int nx,ny;
for(int i=0;i<=3;i++)
{
nx=a[head].x+next[i][0];
ny=a[head].y+next[i][1];
if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&!visit[nx][ny]&&abs(map[nx][ny]-map[a[head].x][a[head].y])<=mid)
{
if(v[nx][ny])
s++;
a[tail].x=nx;
a[tail].y=ny;
visit[nx][ny]=1;
tail++;
}
}
head++;
}
if(s==sum)
return 1;
else
return 0;
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
scanf("%d",&map[i][j]);
r=r>map[i][j]? r:map[i][j];
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
scanf("%d",&v[i][j]);
sum+=v[i][j];
}
l=0;
a[0].x=1;
a[0].y=1;
while(l<r)
{
mid=(l+r)/2;
if(bfs())
r=mid;
else
l=mid+1;
}
printf("%d",l);
return 0;
}
| [
"2492043904@qq.com"
] | 2492043904@qq.com |
99d2260e27c96f0234d20f2c60688663297283af | e393fad837587692fa7dba237856120afbfbe7e8 | /prac/first/ABC_095_B-Bitter-Alchemy.cpp | 87ec17aaacadd2bc89f97e586330edc91949b9b9 | [] | no_license | XapiMa/procon | 83e36c93dc55f4270673ac459f8c59bacb8c6924 | e679cd5d3c325496490681c9126b8b6b546e0f27 | refs/heads/master | 2020-05-03T20:18:47.783312 | 2019-05-31T12:33:33 | 2019-05-31T12:33:33 | 178,800,254 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 390 | cpp | #define rep(i,N) for (int i = 0; i < N; i++)
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int N,X;
int m[100];
int minn = 2000;
int sum = 0;
cin >> N >> X;
rep(i,N) cin >> m[i];
rep(i,N) minn = min(minn,m[i]);
rep(i,N) sum += m[i];
cout << (X-sum)/minn + N << endl;
return 0;
}
| [
"k905672@kansai-u.ac.jp"
] | k905672@kansai-u.ac.jp |
0f60300fcde3314f8829185f55ff5a164f78ed0a | 8c0ab1c1d40cf86e3435168f15618f69b3d65d92 | /Q7-kthmin.cpp | 12e5ec01ace5134a54467e9f765870bf1dfc6dae | [] | no_license | KruttikaBhat/COM210P-Object-Oriented-Design-and-Analysis-Practise | 58f331483c116c06a6ff960bc9860b1912b05b00 | 50b9a59a9a109be02ff723df1893837eec087771 | refs/heads/master | 2022-01-26T07:13:05.043274 | 2019-07-16T10:03:11 | 2019-07-16T10:03:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,582 | cpp | #include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
int findMed(int arr[],int num)
{
sort(arr,arr+num);
return(arr[num/2]);
}
void swap(int *a,int *b)
{
int temp=*a;
*a=*b;
*b=temp;
}
int partition(int arr[],int l,int r,int x)
{
int i,j;
for(i=l;i<r;i++)
{
if(arr[i]==x)
break;
}
swap(&arr[i],&arr[r]);
i=l;
for(j=l;j<=r-1;j++)
{
if(arr[j]<=x)
{
swap(&arr[j],&arr[i]);
i++;
}
}
swap(&arr[i],&arr[r]);
return i;
}
int kthmin(int arr[],int l,int r,int k)
{
if(k>0 && k<=r-l+1)
{
int n=r-l+1,MedofMed,i;
int median[(n+4)/5];
for(i=0;i<n/5;i++)
median[i]=findMed(arr+l+i*5,5);
if(i*5<n)
{
median[i]=findMed(arr+l+i*5,n%5);
i++;
}
if(i==1)
MedofMed=median[i-1];
else
MedofMed=kthmin(median,0,i-1,i/2);
int p=partition(arr,l,r,MedofMed);
if(p-l==k-1)
return arr[p];
if(p-l>k-1)
return kthmin(arr,l,p-1,k);
return kthmin(arr,p+1,r,k-p+l-1);
}
return INT_MAX;
}
int main()
{
int n;
cout<<"Enter the number of elements"<<endl;
cin>>n;
int arr[n],k;
cout<<"Enter the elements"<<endl;
for(int i=0;i<n;i++)
cin>>arr[i];
cout<<"Enter the value of k"<<endl;
cin>>k;
int val=kthmin(arr,0,n-1,k);
cout<<"The kth min is "<<val<<endl;
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
1af4215771a44e179697acea1b0e07b117188c23 | 2d5c4c38b5de82148a1f5fc55bfd14248e43ce34 | /util.cpp | 5349a5865569cf6fcb65d185b6c916aa0ee8d121 | [] | no_license | iynaur/Daedalus | b64bbf38411c8bfcd261b39d81a6086184bbf99b | e6dd17bc02386aad2d1065e69937a2c0fc22b751 | refs/heads/master | 2020-12-27T10:42:59.429134 | 2020-02-03T02:59:44 | 2020-02-03T02:59:44 | 237,873,994 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,423 | cpp | /*
** Daedalus (Version 3.3) File: util.cpp
** By Walter D. Pullen, Astara@msn.com, http://www.astrolog.org/labyrnth.htm
**
** IMPORTANT NOTICE: Daedalus and all Maze generation and general
** graphics routines used in this program are Copyright (C) 1998-2018 by
** Walter D. Pullen. Permission is granted to freely use, modify, and
** distribute these routines provided these credits and notices remain
** unmodified with any altered or distributed versions of the program.
** The user does have all rights to Mazes and other graphic output
** they make in Daedalus, like a novel created in a word processor.
**
** More formally: This program is free software; you can redistribute it
** and/or modify it under the terms of the GNU General Public License as
** published by the Free Software Foundation; either version 2 of the
** License, or (at your option) any later version. This program is
** distributed in the hope that it will be useful and inspiring, but
** WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details, a copy of which is in the
** LICENSE.HTM included with Daedalus, and at http://www.gnu.org
**
** This file contains generic utilities. Nothing here is related to graphics
** or any other part of Daedalus.
**
** Created: 6/4/1993.
** Last code change: 11/29/2018.
*/
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include "util.h"
US us = {fTrue, 0L, 0L, 0L};
/*
******************************************************************************
** General Routines
******************************************************************************
*/
// Global new and delete operator implementations.
void *operator new(size_t cb)
{
void *pv;
pv = PAllocate((long)cb);
return pv;
}
void operator delete(void *pv)
{
DeallocateP(pv);
}
#ifndef PC
void *operator new(size_t cb, void *pv)
{
return pv;
}
void operator delete(void *pv, void *pv2)
{
}
#endif
// Change the size of a memory allocation, containing a list of cElem items of
// cbElem size, to a list of cElemNew items of cbElem size.
void *ReallocateArray(void *rgElem, int cElem, int cbElem, int cElemNew)
{
void *rgElemNew;
rgElemNew = PAllocate(cElemNew * cbElem);
if (rgElemNew == NULL)
return NULL;
ClearPb(rgElemNew, cElemNew * cbElem);
if (rgElem != NULL)
CopyPb(rgElem, rgElemNew, cElem * cbElem);
return rgElemNew;
}
// Display a string with an integer parameter embedded in it.
int PrintSzNCore(CONST char *sz, int n, int nPriority)
{
char szT[cchSzDef];
sprintf(S(szT), sz, n);
return PrintSzCore(szT, nPriority);
}
// Display a string with two integer parameters embedded in it.
int PrintSzNNCore(CONST char *sz, int n1, int n2, int nPriority)
{
char szT[cchSzDef];
sprintf(S(szT), sz, n1, n2);
return PrintSzCore(szT, nPriority);
}
// Display a string with a long integer parameter embedded in it.
int PrintSzLCore(CONST char *sz, long l, int nPriority)
{
char szT[cchSzDef];
sprintf(S(szT), sz, l);
return PrintSzCore(szT, nPriority);
}
// Return whether n is in the range from n1 to n2, inclusive. If not, display
// a suitable warning message.
flag FErrorRange(CONST char *sz, int n, int n1, int n2)
{
char szT[cchSzDef];
if (n < n1 || n > n2) {
sprintf(S(szT), "%s value %d is out of range from %d to %d.\n",
sz, n, n1, n2);
PrintSz_W(szT);
return fTrue;
}
return fFalse;
}
// Copy bytes from one buffer to another. The buffers shouldn't overlap.
void CopyRgb(CONST char *pbFrom, char *pbTo, long cb)
{
while (cb--)
*pbTo++ = *pbFrom++;
}
// Return length of a zero terminated string, not including the terminator.
int CchSz(CONST char *sz)
{
CONST char *pch = sz;
while (*pch)
pch++;
return PD(pch - sz);
}
// Compare two strings case sensitively. Return 0 if equal, negative number if
// first less than second, and positive number if first greater than second.
int CompareSz(CONST char *sz1, CONST char *sz2)
{
while (*sz1 && (*sz1 == *sz2))
sz1++, sz2++;
return (int)*sz1 - *sz2;
}
// Compare two strings case insensitively. Return 0 if equal, negative number
// if first less than second, and positive if first greater than second.
int CompareSzI(CONST char *sz1, CONST char *sz2)
{
while (*sz1 && (ChCap(*sz1) == ChCap(*sz2)))
sz1++, sz2++;
return (int)ChCap(*sz1) - ChCap(*sz2);
}
// Compare two ranges of characters case sensitively. Return 0 if equal,
// negative if first less than second, and positive if greater than second.
int CompareRgch(CONST char *rgch1, int cch1, CONST char *rgch2, int cch2)
{
while (cch1 > 0 && cch2 > 0 && *rgch1 == *rgch2)
rgch1++, rgch2++, cch1--, cch2--;
return cch1 > 0 ? (cch2 > 0 ? (int)*rgch1 - *rgch2 : (int)*rgch1) :
cch2 == 0 ? 0 : -(int)*rgch2;
}
// Compare two ranges of characters case insensitively. Return 0 if equal,
// negative if first less than second, and positive if greater than second.
int CompareRgchI(CONST char *rgch1, int cch1, CONST char *rgch2, int cch2)
{
while (cch1 > 0 && cch2 > 0 && ChCap(*rgch1) == ChCap(*rgch2))
rgch1++, rgch2++, cch1--, cch2--;
return cch1 > 0 ? (cch2 > 0 ? (int)ChCap(*rgch1) - ChCap(*rgch2) :
(int)ChCap(*rgch1)) : cch2 == 0 ? 0 : -(int)ChCap(*rgch2);
}
// Return whether a zero terminated string is equal to a range of characters,
// case sensitively.
flag FCompareSzRgch(CONST char *sz, CONST char *pch, int cch)
{
if (sz[0] == chNull) // Note the empty string is NOT equal.
return fFalse;
while (cch > 0 && *sz == *pch)
sz++, pch++, cch--;
return cch == 0 && sz[0] == chNull;
}
// Return whether a zero terminated string is equal to a range of characters,
// case insensitively.
flag FCompareSzRgchI(CONST char *sz, CONST char *pch, int cch)
{
if (sz[0] == chNull) // Note the empty string is NOT equal.
return fFalse;
while (cch > 0 && ChCap(*sz) == ChCap(*pch))
sz++, pch++, cch--;
return cch == 0 && sz[0] == chNull;
}
// Search for and return the position of a character within a string.
int FindCh(CONST char *pch, int cch, char ch)
{
int ich;
for (ich = 0; ich < cch; ich++)
if (*pch++ == ch)
return ich;
return -1;
}
// Copy a range of characters and zero terminate it. If there are too many
// characters to fit in the destination buffer, the string is truncated.
void CopyRgchToSz(CONST char *pch, int cch, char *sz, int cchMax)
{
cch = Min(cch, cchMax-1);
CopyRgb(pch, sz, cch);
sz[cch] = chNull;
}
// Convert a range of characters to upper case.
void UpperRgch(char *rgch, int cch)
{
while (cch > 0) {
*rgch = ChCap(*rgch);
rgch++, cch--;
}
}
// Parse and return a number contained in a range of characters.
long LFromRgch(CONST char *rgch, int cch)
{
char sz[cchSzDef], *pch;
long l;
flag fBinary;
CopyRgchToSz(rgch, cch, sz, cchSzDef);
if (*sz != '#')
return atol(sz);
fBinary = (*(sz+1) == '#');
// Strings starting with "#" are considered hexadecimal numbers.
// Strings starting with "##" are considered binary numbers.
l = 0;
for (pch = sz+1+fBinary; *pch; pch++)
l = fBinary ? ((l << 1) | (*pch == '1')) :
((l << 4) | NHex2(ChCap(*pch)));
return l;
}
// Parse a real number contained in a range of characters, returning it as an
// fixed point integer with the decimal point at the specified power of ten.
long LFromRgch2(CONST char *rgch, int cch, int nDecimal)
{
char sz[cchSzDef];
real r;
long l;
CopyRgchToSz(rgch, cch, sz, cchSzDef);
r = atof(sz);
l = LPower(10, NAbs(nDecimal));
if (nDecimal >= 0)
r *= (real)l;
else
r /= (real)l;
return (long)r;
}
// Return the smaller of two integers.
int NMin(int n1, int n2)
{
return Min(n1, n2);
}
// Return the larger of two integers.
int NMax(int n1, int n2)
{
return Max(n1, n2);
}
// Return the smaller of two floating point numbers.
real RMin(real n1, real n2)
{
return Min(n1, n2);
}
// Return the larger of two floating point numbers.
real RMax(real n1, real n2)
{
return Max(n1, n2);
}
// Ensure n1 < n2. If not, swap them.
void SortN(int *n1, int *n2)
{
if (*n1 > *n2)
SwapN(*n1, *n2);
}
// Open a file.
FILE *FileOpen(CONST char *sz, CONST char *szMode)
{
#ifdef SECURECRT
FILE *file;
if (fopen_s(&file, sz, szMode))
file = NULL;
return file;
#else
return fopen(sz, szMode);
#endif
}
// Write a string to a file.
void WriteSz(FILE *file, CONST char *sz)
{
CONST char *pch;
for (pch = sz; *pch; pch++) {
if (*pch == '\n') // Translate LF to CRLF for PC's
putc('\r', file);
putc(*pch, file);
}
}
// Read a 16 bit word from a file.
word WRead(FILE *file)
{
byte b1, b2;
b1 = getbyte(); b2 = getbyte();
return WFromBB(b1, b2);
}
// Read a 32 bit long from a file.
dword LRead(FILE *file)
{
byte b1, b2, b3, b4;
b1 = getbyte(); b2 = getbyte(); b3 = getbyte(); b4 = getbyte();
return LFromWW(WFromBB(b1, b2), WFromBB(b3, b4));
}
// Multiplication function. Return x*y, checking for overflow.
long LMul(long x, long y)
{
long z = x * y;
if (y != 0 && z / y != x)
return 0x80000000;
return z;
}
// Division function. Return x/y, checking for illegal parameters.
long LDiv(long x, long y)
{
if (y == 0) // Dividing by 0 is assumed to be 0.
return 0;
else if (x == 0x80000000 && y == -1) // This will crash on x86 too.
return x;
return x / y;
}
// Modulus function. Return remainder of x/y.
long LMod(long x, long y)
{
if (y == 0) // Remainder when dividing by 0 is assumed to be 0.
return 0;
else if (x == 0x80000000 && y == -1) // This will crash on x86 too.
return 0;
return x % y;
}
// Integer power raising function. Return x^y.
long LPower(long x, long y)
{
long pow;
if (y < 1)
return 1;
if (y == 1 || x == 0 || x == 1)
return x;
if (x == -1)
return FOdd(y) ? -1 : 1;
for (pow = x; y > 1; y--) {
if (pow * x / x != pow) // Return 0 if overflow 32 bits.
return 0;
pow *= x;
}
return pow;
}
// Division function. Return x/y, checking for illegal parameters.
real RDiv(real x, real y)
{
if (y >= 0.0) {
if (y < rMinute)
y = rMinute;
} else {
if (y > -rMinute)
y = -rMinute;
}
return x / y;
}
// Calculate x and y coordinates along a circle or ellipse, given a center
// point, radius, and angle.
void AngleR(int *h, int *v, int x, int y, real rx, real ry, real d)
{
*h = x + (int)(rx*RCosD(d));
*v = y + (int)(ry*RSinD(d));
}
// Return the angle of the line between two points.
real GetAngle(int x1, int y1, int x2, int y2)
{
real d;
if (x1 != x2) {
d = RAtnD((real)(y2 - y1) / (real)(x2 - x1));
if (d < 0.0)
d += rDegQuad;
} else
d = 0.0;
if (x2 <= x1 && y2 > y1)
d += rDegQuad;
else if (x2 < x1 && y2 <= y1)
d += rDegHalf;
else if (x2 >= x1 && y2 < y1)
d += rDeg34;
Assert(FBetween(d, 0.0, rDegMax));
return d;
}
// Rotate a point around the origin by the given number of degrees.
void RotateR(real *h, real *v, real d)
{
real m = *h, n = *v, rS, rC;
rS = RSinD(d); rC = RCosD(d);
*h = m*rC - n*rS;
*v = n*rC + m*rS;
}
// Fast version of RotateR that assumes the slow trigonometry values have
// already been computed. Useful when rotating many points by the same angle.
void RotateR2(real *h, real *v, real rS, real rC)
{
real m = *h, n = *v;
*h = m*rC - n*rS;
*v = n*rC + m*rS;
}
/*
******************************************************************************
** Vector Routines
******************************************************************************
*/
// Assign the value of a vector given its components along each axis.
void CVector::Set(real x, real y, real z)
{
m_x = x;
m_y = y;
m_z = z;
}
// Multiply or stretch a vector by a factor.
void CVector::Mul(real len)
{
m_x *= len;
m_y *= len;
m_z *= len;
}
// Return the length of a vector.
real CVector::Length() CONST
{
return RSqr(m_x*m_x + m_y*m_y + m_z*m_z);
}
// Create a unit length vector given spherical coordinate angles.
void CVector::Sphere(real theta, real phi)
{
real r;
m_x = RCosD(theta);
m_y = RSinD(theta);
r = RCosD(phi);
m_z = RSinD(phi);
m_x *= r; m_y *= r;
}
// Return the dot product of two vectors.
real CVector::Dot(CONST CVector &v2) CONST
{
return m_x*v2.m_x + m_y*v2.m_y + m_z*v2.m_z;
}
// Determine the cross product of two vectors, i.e. create a new vector that's
// perpendicular to both.
void CVector::Cross(CONST CVector &v1, CONST CVector &v2)
{
Set(v1.m_y*v2.m_z - v1.m_z*v2.m_y, v1.m_z*v2.m_x - v1.m_x*v2.m_z,
v1.m_x*v2.m_y - v1.m_y*v2.m_x);
}
// Return the angle between two vectors.
real CVector::Angle(CONST CVector &v2) CONST
{
real angle, len1, len2;
len1 = Length();
len2 = v2.Length();
if (len1 != 0.0 && len2 != 0.0) {
angle = Dot(v2)/len1/len2;
if (angle == 0.0)
return rPiHalf;
else if (angle <= -1.0)
return rPi;
angle = RAtn(RSqr(1.0 - angle*angle)/angle);
if (angle >= 0.0)
return angle;
else
return angle + rPi;
} else
return rPiHalf;
}
// Create a normal vector to a plane, i.e. a vector perpendicular to the plane
// passing through three coordinates.
void CVector::Normal(real x1, real y1, real z1, real x2, real y2, real z2,
real x3, real y3, real z3)
{
CVector v1, v2;
v1.Set(x2 - x1, y2 - y1, z2 - z1);
v2.Set(x3 - x1, y3 - y1, z3 - z1);
Cross(v1, v2);
}
/*
******************************************************************************
** Trie Tree Routines
******************************************************************************
*/
// Return whether two ranges of characters are equal. Either string ending
// prematurely with a zero terminator makes the strings not equal.
flag FEqRgch(CONST char *rgch1, CONST char *rgch2, int cch, flag fInsensitive)
{
int ich;
if (!fInsensitive) {
for (ich = 0; ich < cch; ich++) {
if (rgch1[ich] == '\0' || rgch1[ich] != rgch2[ich])
return fFalse;
}
} else {
for (ich = 0; ich < cch; ich++) {
if (rgch1[ich] == '\0' || ChCap(rgch1[ich]) != ChCap(rgch2[ich]))
return fFalse;
}
}
return fTrue;
}
// Create a trie tree within the buffer rgsOut of size csTrieMax. Returns the
// size of the trie in shorts, or -1 on failure. The input list of strings is
// used to create the trie. It does not have to be in sorted order. Trie
// lookups on strings will return the index they are in the original list. No
// two strings should be the same. Individual strings shouldn't be longer than
// 255 characters, or rather trailing unique substrings can't be longer than
// 255. With signed 16 bit indexes, these tries can't be larger than 32K
// shorts, or 64K bytes. That can store about 2500 strings.
//
// The trie format is a sequence of nodes. "Pointers" to other nodes are
// indexes into the array of shorts. There are two types of nodes: Standard
// nodes which handle all the branches from a particular leading substring,
// and leaf nodes for unique trailing substrings. Standard node format:
//
// Short 0: 0 = No string ends at this point. Non-zero = Payload + 1 for
// substring leading up to this node.
// Short 1: High byte = Highest character covered by this node. Low byte =
// Lowest character covered. If high character is 0, this is a leaf node.
// Short 2+: Pointers to nodes for the range of low through high characters.
// 0 = null pointer. Less than 0 means a string ends with this character,
// where value contains -(Payload + 1).
//
// Leaf node format:
// Short 0: Same as standard node.
// Short 1: Length of trailing substring.
// Short 2: Payload for the string ending after this point.
// Short 3+: Range of characters storing final substring to compare against.
int CsCreateTrie(CONST uchar *rgszIn[], int cszIn, TRIE rgsOut, int csTrieMax,
flag fInsensitive)
{
uchar rgchStack[cchSzMax];
int rgisStack[cchSzMax];
long rgchUsed[256], iUsed = 0;
int iStack, csOut = 0, isz, ich, chLo, chHi, chT, is, cch, isT,
isRemember = 0, csz, iszSav;
for (ich = 0; ich < 256; ich++)
rgchUsed[ich] = 0;
for (iStack = 0;; iStack++) {
if (iStack >= cchSzMax) {
Assert(fFalse);
return -1;
}
rgisStack[iStack] = csOut;
chLo = 255, chHi = 0, iUsed++, csz = 0;
// Count how many strings match the current leading substring. Also
// get the low and high character for these strings.
for (isz = 0; isz < cszIn; isz++) {
if (FEqRgch((CONST char *)rgszIn[isz], (CONST char *)rgchStack, iStack,
fInsensitive)) {
chT = rgszIn[isz][iStack];
if (chT != 0) {
if (fInsensitive)
chT = ChCap(chT);
csz++;
iszSav = isz;
rgchUsed[chT] = iUsed;
if (chT < chLo)
chLo = chT;
if (chT > chHi)
chHi = chT;
}
}
}
// If no strings match, back up to an earlier node.
if (csz <= 0) {
LPop:
loop {
// Pop the stack to the parent node.
iStack--;
if (iStack < 0)
goto LDone;
is = rgisStack[iStack];
chLo = (word)rgsOut[is + 1] & 255;
chHi = (word)rgsOut[is + 1] >> 8;
// Scan for a pointer that hasn't been filled out yet.
for (ich = chLo + 1; ich <= chHi; ich++) {
if (rgsOut[is + 2 + (ich - chLo)] == 1) {
chT = ich;
goto LPush;
}
}
}
}
// Since there's at least one string, there will be a new node. Set the
// pointer in the parent node to here.
rgsOut[isRemember] = csOut;
if (csOut >= csTrieMax - 1) {
Assert(fFalse);
return -1;
}
rgsOut[csOut++] = 0; // Short 0
// If exactly one string matches, create a leaf node.
if (csz == 1) {
for (ich = iStack; rgszIn[iszSav][ich] != 0; ich++)
;
cch = ich - iStack;
if (cch > 255) {
Assert(fFalse);
return -1;
}
if (csOut >= csTrieMax - 2 - ((cch + 1) >> 1)) {
Assert(fFalse);
return -1;
}
rgsOut[csOut++] = cch; // Short 1
rgsOut[csOut++] = 0; // Short 2
CopyRgb((char *)&rgszIn[iszSav][iStack], (char *)&rgsOut[csOut],
(cch + 1) & ~1);
if (fInsensitive)
UpperRgch((char *)&rgsOut[csOut], cch);
csOut += (cch + 1) >> 1;
goto LPop;
}
// Create a standard node.
if (csOut >= csTrieMax - 1 - (chHi - chLo + 1)) {
Assert(fFalse);
return -1;
}
rgsOut[csOut++] = (chHi << 8) | chLo; // Short 1
// Set those characters in use to the temporary pointer value 1, which
// will be filled out later.
for (ich = chLo; ich <= chHi; ich++)
rgsOut[csOut++] = (rgchUsed[ich] == iUsed);
chT = chLo;
LPush:
rgchStack[iStack] = chT;
isRemember = rgisStack[iStack] + 2 + (chT - chLo);
rgsOut[isRemember] = -1;
}
LDone:
// Fill out payloads. For each string in the input list, walk the trie and
// set the appropriate point in it to the string's index in the input list.
Assert(csOut != 0);
for (isz = 0; isz < cszIn; isz++) {
is = 0;
for (ich = 0;; ich++) {
if (rgszIn[isz][ich] == '\0') {
// Handle the substring case (short 0).
Assert(rgsOut[is] == 0 || !fInsensitive);
rgsOut[is] = isz+1;
break;
}
chLo = (word)rgsOut[is + 1] & 255;
chHi = (word)rgsOut[is + 1] >> 8;
if (chHi == 0) {
// Handle the leaf node case (short 2).
Assert(rgsOut[is + 2] == 0 && FEqRgch((char *)&rgsOut[is+3],
(char *)&rgszIn[isz][ich], chLo, fInsensitive));
rgsOut[is + 2] = isz;
break;
}
chT = rgszIn[isz][ich];
if (fInsensitive)
chT = ChCap(chT);
Assert(chT >= chLo && chT <= chHi);
isT = rgsOut[is + 2 + (chT - chLo)];
Assert(isT != 0);
if (isT <= 0) {
// Handle the payload pointer within standard node case.
Assert(rgszIn[isz][ich + 1] == '\0');
rgsOut[is + 2 + (chT - chLo)] = -(isz+1);
break;
}
is = isT;
}
}
return csOut;
}
// Lookup a string in a trie created with CsCreateTrie. Return -1 if string
// not found, otherwise return the index of the string in the original list
// used to create the trie. This lookup is very fast, and not much slower than
// a single string compare. For strings not in the list, usually don't even
// have to look at all of its characters before knowing it's not in the trie.
int ILookupTrie(CONST TRIE rgsIn, CONST char *rgch, int cch,
flag fInsensitive)
{
int is = 0, chLo, chHi, ch, cchT;
CONST char *pchEnd = rgch + cch, *pch, *pch1, *pch2;
// Walk the input string, while going from node to node in the trie.
for (pch = rgch;; pch++) {
if (pch >= pchEnd) {
// At end of input string. Check whether current node has a payload.
if (rgsIn[is] != 0)
return rgsIn[is]-1;
else
return -1;
}
chLo = (word)rgsIn[is + 1];
chHi = chLo >> 8;
if (chHi == 0) {
// Leaf node. Compare rest of input string with substring in node.
pch1 = (char *)&rgsIn[is + 3], pch2 = pch, cchT = chLo;
if (!fInsensitive) {
while (cchT > 0 && *pch1 == *pch2) {
Assert(*pch1 != '\0');
pch1++, pch2++, cchT--;
}
} else {
while (cchT > 0 && *pch1 == ChCap(*pch2)) {
Assert(*pch1 != '\0');
pch1++, pch2++, cchT--;
}
}
if (cchT > 0 || pch + chLo < pchEnd)
return -1;
else
return rgsIn[is + 2];
}
// Standard node. Get pointer to appropriate child node.
chLo &= 255;
ch = *pch;
if (fInsensitive)
ch = ChCap(ch);
if (ch < chLo || ch > chHi)
return -1;
is = rgsIn[is + 2 + (ch - chLo)];
if (is < 0) {
if (pch + 1 == pchEnd)
return -is-1;
else
return -1;
} else if (is == 0)
return -1;
}
}
/*
******************************************************************************
** Random Number Routines
******************************************************************************
*/
// C code for MT19937, with initialization improved Jan 26, 2002.
// Coded by Takuji Nishimura and Makoto Matsumoto.
// http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
// Copyright (C) 1997-2002 by Makoto Matsumoto and Takuji Nishimura,
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1) Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2) Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3) The names of its contributors may not be used to endorse or promote
// products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// Period parameters
#define N 624
#define M 397
#define MATRIX_A 0x9908b0dfUL // Constant vector a
#define UPPER_MASK 0x80000000UL // Most significant w-r bits
#define LOWER_MASK 0x7fffffffUL // Least significant r bits
ulong mt[N]; // The array for the state vector
int imt = N+1; // imt == N+1 means mt[N] is not initialized
// Initialize mt[N] with a seed.
void InitRndL(ulong l)
{
if (us.fRndOld) {
srand(l);
return;
}
mt[0] = l & 0xffffffffUL;
for (imt = 1; imt < N; imt++) {
mt[imt] = 1812433253UL * (mt[imt-1] ^ (mt[imt-1] >> 30)) + imt;
// See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. In the previous
// versions, MSBs of the seed affect only MSBs of the array mt[].
// Modified by Makoto Matsumoto, Jan 9, 2002.
}
}
// Initialize by an array with array-length; rgl is the array for
// initializing keys; cl is its length. Slight change for C++, Feb 26, 2004.
void InitRndRgl(ulong rgl[], int cl)
{
int i = 1, j = 0, c;
InitRndL(19650218UL);
c = (N > cl ? N : cl);
for (; c; c--) {
mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL)) +
rgl[j] + j; // Non-linear
i++, j++;
if (i >= N) {
mt[0] = mt[N-1]; i=1;
}
if (j >= cl)
j = 0;
}
for (c = N-1; c; c--) {
mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL)) -
i; // Non-linear
i++;
if (i >= N) {
mt[0] = mt[N-1]; i = 1;
}
}
mt[0] = 0x80000000UL; // MSB is 1; assuring non-zero initial array
}
// Generate a random 32 bit number on interval [0,0xffffffff].
ulong LRnd(void)
{
// mag01[x] = x * MATRIX_A for x=0,1.
CONST ulong mag01[2] = {0x0UL, MATRIX_A};
ulong l;
if (imt >= N) { // Generate N longs at one time.
int kk;
if (imt == N+1) // If InitRndL() has not been called,
InitRndL(5489UL); // a default initial seed is used.
for (kk = 0; kk < N-M; kk++) {
l = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
mt[kk] = mt[kk+M] ^ (l >> 1) ^ mag01[l & 0x1UL];
}
for (; kk < N-1; kk++) {
l = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
mt[kk] = mt[kk+(M-N)] ^ (l >> 1) ^ mag01[l & 0x1UL];
}
l = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK);
mt[N-1] = mt[M-1] ^ (l >> 1) ^ mag01[l & 0x1UL];
imt = 0;
}
l = mt[imt++];
// Tempering
l ^= (l >> 11);
l ^= (l << 7) & 0x9d2c5680UL;
l ^= (l << 15) & 0xefc60000UL;
l ^= (l >> 18);
return l;
}
// Return a random integer between n1 and n2, inclusive.
int Rnd(int n1, int n2)
{
int d, r, n, nT;
if (n1 > n2) {
if (n1 == lHighest && n2 == (int)0x80000000)
return LRnd();
SwapN(n1, n2);
}
d = n2 - n1 + 1;
if (d <= 16384) {
// Old way of computing compatible with previous versions.
if (us.fRndOld)
return NMultShift(rand() & 16383, d, 14) + n1;
// For ranges that are a power of 2, equal probability across range.
if (FPower2(d))
return NMultShift(LRnd() >> 18, d, 14) + n1;
} else if (FPower2(d)) {
// Start with a random number between 0 and 2^31-1.
r = LRnd() >> 1;
// Compute (r * d / 2^31) without overflowing a 32 bit long.
return LMultShift(r, d, 31) + n1;
}
// For irregular ranges, recalculate random numbers within remainder.
n = lHighest / d;
do {
r = LRnd() >> 1;
nT = r / n;
} while (nT >= d);
return nT + n1;
}
/* util.cpp */
| [
"iynaur87@sina.com"
] | iynaur87@sina.com |
e4e4b4871f5d92b1ee46535b4cbb4bd061fd1392 | 9545ee6c604c44e683716d77026017451393f0b4 | /495 - Fibonacci Freeze.cpp | c98a2b79fed227763e2f8e671706338501df8e9d | [] | no_license | HT1225/UVa-training | 3bd49be87d4caa512efd34c1aabbe31f64a945b6 | fdf74788c9e6e184b75fa93eec4d83e4dcebb804 | refs/heads/master | 2016-09-06T05:08:32.789886 | 2015-08-20T15:59:57 | 2015-08-20T15:59:57 | 22,687,514 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,370 | cpp | /*20150223 hanting*/
#include <iostream>
using namespace std;
struct BigNum
{
int num[1200];
int digit;
BigNum()
{
fill(num,num+1200,0);
digit=0;
}
int digitCount()
{
for(int i=1200;i>=0;i--)
{
if(num[i]) return i+1;
}
}
void operator=(int n)
{
if(n==0) digit++;
while(n)
{
num[digit++]=n%10;
n/=10;
}
}
BigNum operator+(BigNum a)
{
BigNum sum;
for(int i=0;i<1200;i++)
{
sum.num[i]=num[i]+a.num[i];
}
for(int i=1;i<1200;i++)
{
sum.num[i]+=sum.num[i-1]/10;
sum.num[i-1]%=10;
}
sum.digit=sum.digitCount();
return sum;
}
friend ostream& operator<<(ostream& bout,BigNum b)
{
bout<<b.num[b.digit-1];
for(int i=b.digit-2;i>=0;i--)
{
bout<<b.num[i];
}
return bout;
}
};
BigNum DP[5001];
BigNum f(int N)
{
if(DP[N].digit) return DP[N];
else
{
DP[N]=f(N-1)+f(N-2);
return DP[N];
}
}
int main()
{
DP[0]=0;
DP[1]=1;
for(int i=200;i<=5000;i+=200)
{
DP[i]=f(i);
}
int N;
while(cin>>N)
{
cout<<"The Fibonacci number for "<<N<<" is "<<f(N)<<endl;
}
return 0;
}
| [
"tim12251225@gmail.com"
] | tim12251225@gmail.com |
dc1ab67ef623a9170a7175265f2ea344cb82e79b | ba4db75b9d1f08c6334bf7b621783759cd3209c7 | /src_main/engine/sv_master.cpp | 1eb4ba638303da72392339d0b490ab99e9486037 | [] | no_license | equalent/source-2007 | a27326c6eb1e63899e3b77da57f23b79637060c0 | d07be8d02519ff5c902e1eb6430e028e1b302c8b | refs/heads/master | 2020-03-28T22:46:44.606988 | 2017-03-27T18:05:57 | 2017-03-27T18:05:57 | 149,257,460 | 2 | 0 | null | 2018-09-18T08:52:10 | 2018-09-18T08:52:09 | null | WINDOWS-1252 | C++ | false | false | 3,471 | cpp | //========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Workfile: $
// $Date: $
// $NoKeywords: $
//=============================================================================//
#include "server_pch.h"
#include "server.h"
#include "master.h"
#include "proto_oob.h"
#include "sv_main.h" // SV_GetFakeClientCount()
#include "tier0/icommandline.h"
#include "FindSteamServers.h"
#include "filesystem_engine.h"
#include "tier0/vcrmode.h"
#include "sv_steamauth.h"
#include "hltvserver.h"
#include "sv_master_legacy.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
bool g_bEnableMasterServerUpdater = true;
void SetMaster_f( const CCommand &args )
{
if ( IsUsingMasterLegacyMode() )
{
master->SetMaster_Legacy_f( args );
return;
}
#ifndef NO_STEAM
ISteamMasterServerUpdater *s = SteamMasterServerUpdater();
#else
ISteamMasterServerUpdater *s = NULL;
#endif
if ( !s )
return;
char szMasterAddress[128]; // IP:Port string of master
const char *pszCmd = NULL;
int count = args.ArgC();
// Usage help
if ( count < 2 )
{
ConMsg("Usage:\nsetmaster <add | remove | enable | disable> <IP:port>\n");
if ( s->GetNumMasterServers() == 0 )
{
ConMsg("Current: None\n");
}
else
{
ConMsg("Current:\n");
for ( int i=0; i < s->GetNumMasterServers(); i++ )
{
char szAdr[512];
if ( s->GetMasterServerAddress( i, szAdr, sizeof( szAdr ) ) != 0 )
ConMsg( " %i: %s\n", i+1, szAdr );
}
}
return;
}
pszCmd = args[1];
if ( !pszCmd || !pszCmd[0] )
return;
// Check for disabling...
if ( !Q_stricmp( pszCmd, "disable") )
{
g_bEnableMasterServerUpdater = false;
}
else if (!Q_stricmp( pszCmd, "enable") )
{
g_bEnableMasterServerUpdater = true;
}
else if ( !Q_stricmp( pszCmd, "add" ) || !Q_stricmp( pszCmd, "remove" ) )
{
// Figure out what they want to do.
// build master address
szMasterAddress[0] = 0;
for ( int i= 2; i<count; i++ )
{
Q_strcat( szMasterAddress, args[i], sizeof( szMasterAddress ) );
}
if ( !Q_stricmp( pszCmd, "add" ) )
{
if ( s->AddMasterServer( szMasterAddress ) )
{
ConMsg ( "Adding master at %s\n", szMasterAddress );
}
else
{
ConMsg ( "Master at %s already in list\n", szMasterAddress );
}
// If we get here, masters are definitely being used.
g_bEnableMasterServerUpdater = true;
}
else
{
// Find master server
if ( !s->RemoveMasterServer( szMasterAddress ) )
{
ConMsg( "Can't remove master %s, not in list\n", szMasterAddress );
}
}
}
else
{
ConMsg( "Invalid setmaster command\n" );
}
// Resend the rules just in case we added a new server.
sv.SetMasterServerRulesDirty();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void Heartbeat_f()
{
if ( IsUsingMasterLegacyMode() )
{
master->Heartbeat_Legacy_f();
return;
}
#ifndef NO_STEAM
SteamMasterServerUpdater()->ForceHeartbeat();
#endif
}
static ConCommand setmaster( "setmaster", SetMaster_f, "add/remove/enable/disable master servers", 0 );
static ConCommand heartbeat( "heartbeat", Heartbeat_f, "Force heartbeat of master servers", 0 );
| [
"sean@csnxs.uk"
] | sean@csnxs.uk |
7e68de8d28d2b2a47079a08309770475c73c2fce | 11971fb9d9bdf3d4ed2af558e5cf08a5d006af64 | /conveyor_belt/src/conveyor_belt_server.cpp | 949a13ee126759066e9f11be595d8c75653ddb15 | [] | no_license | moriarty/rockin-networked-devices | 4a28b3007e275f56a3ff453d56ac3664eadf56f8 | efbf76164ac110287286063eaa640a35d1ce8518 | refs/heads/master | 2021-01-10T22:11:43.398743 | 2014-11-26T12:44:14 | 2014-11-26T12:44:14 | 31,027,042 | 0 | 0 | null | 2015-02-19T17:24:51 | 2015-02-19T17:24:51 | null | UTF-8 | C++ | false | false | 3,969 | cpp | /*
* conveyor_belt_server.cpp
*
* Created on: Aug 26, 2014
* Author: Frederik Hegger
*/
#include <conveyor_belt_server.h>
ConveyorBeltServer::ConveyorBeltServer() :
zmq_context_(NULL), zmq_publisher_(NULL), zmq_subscriber_(NULL), isZmqCommunicationInitalized_(false)
{
zmq_context_ = new zmq::context_t(1);
conveyor_device_ = new ConveyorBeltKfD44();
}
ConveyorBeltServer::~ConveyorBeltServer()
{
if (zmq_context_ != NULL)
delete zmq_context_;
if (zmq_publisher_ != NULL)
delete zmq_publisher_;
if (zmq_subscriber_ != NULL)
delete zmq_subscriber_;
}
bool ConveyorBeltServer::connectConveyorBelt(std::string device_name)
{
if (conveyor_device_->connect(device_name) == 0)
return true;
return false;
}
bool ConveyorBeltServer::startPublisher(const std::string ip_address, const unsigned int status_msg_port)
{
uint64_t hwm = 1;
// add publisher to send status messages
try
{
zmq_publisher_ = new zmq::socket_t(*zmq_context_, ZMQ_PUB);
zmq_publisher_->setsockopt(ZMQ_HWM, &hwm, sizeof(hwm));
zmq_publisher_->bind(std::string("tcp://" + ip_address + ":" + boost::lexical_cast<std::string>(status_msg_port)).c_str());
isZmqCommunicationInitalized_ = true;
} catch (...)
{
isZmqCommunicationInitalized_ = false;
}
return isZmqCommunicationInitalized_;
}
void ConveyorBeltServer::stopPublisher()
{
isZmqCommunicationInitalized_ = false;
zmq_publisher_->close();
}
bool ConveyorBeltServer::startSubscriber(const std::string ip_address, const unsigned int command_msg_port)
{
uint64_t hwm = 1;
// add subscriber to receive command messages from a client
try
{
zmq_subscriber_ = new zmq::socket_t(*zmq_context_, ZMQ_SUB);
zmq_subscriber_->setsockopt(ZMQ_SUBSCRIBE, "", 0);
zmq_subscriber_->setsockopt(ZMQ_HWM, &hwm, sizeof(hwm));
zmq_subscriber_->connect(std::string("tcp://" + ip_address + ":" + boost::lexical_cast<std::string>(command_msg_port)).c_str());
isZmqCommunicationInitalized_ = true;
} catch (...)
{
isZmqCommunicationInitalized_ = false;
}
return isZmqCommunicationInitalized_;
}
void ConveyorBeltServer::stopSubscriber()
{
isZmqCommunicationInitalized_ = false;
zmq_subscriber_->close();
}
bool ConveyorBeltServer::isCommunctionInitialized()
{
return isZmqCommunicationInitalized_;
}
void ConveyorBeltServer::receiveAndProcessData()
{
zmq::message_t zmq_message;
ConveyorBeltCommand conveyor_command_msg = ConveyorBeltCommand();
// check if a new a new message has arrived and if it is a conveyor belt command message
if (zmq_subscriber_->recv(&zmq_message, ZMQ_NOBLOCK) && conveyor_command_msg.ParseFromArray(zmq_message.data(), zmq_message.size()))
setConveyorBeltParameters(conveyor_command_msg);
}
void ConveyorBeltServer::sendStatusMessage()
{
ConveyorBeltStatus status_msg = ConveyorBeltStatus();
std::string serialized_string;
status_msg.set_is_device_connected(conveyor_device_->is_connected());
if (conveyor_device_->getRunState() == ConveyorBeltKfD44::STARTED)
status_msg.set_mode(START);
else
status_msg.set_mode(STOP);
status_msg.SerializeToString(&serialized_string);
zmq::message_t *reply = new zmq::message_t(serialized_string.length());
memcpy(reply->data(), serialized_string.c_str(), serialized_string.length());
zmq_publisher_->send(*reply);
delete reply;
}
void ConveyorBeltServer::setConveyorBeltParameters(ConveyorBeltCommand msg)
{
quantity<si::frequency> default_frequency = 75 * si::hertz;
if (msg.has_mode())
{
if (msg.mode() == START)
{
conveyor_device_->setFrequency(default_frequency);
conveyor_device_->start(ConveyorBeltKfD44::FORWARD);
} else if (msg.mode() == STOP)
conveyor_device_->stop();
}
}
| [
"frederik.hegger@h-brs.de"
] | frederik.hegger@h-brs.de |
a316a2492b512d91fd698364fdfe7b4a3360695e | c85c2a8cea5bb68f1cc366343569b2dc1eb78c84 | /10-4/multipleEG.cpp | 43ce71df57dd0761fb9288006e00bf733b4defc0 | [] | no_license | Vikashdeviktech/LPU_Code | d87b4481bf412d5ab65efbb00705d311b5df35b2 | 53ad97cdc2599e5ab8aa0c13b93422273a6bb22f | refs/heads/master | 2023-04-26T22:58:23.581619 | 2021-05-10T13:30:51 | 2021-05-10T13:30:51 | 334,947,155 | 8 | 5 | null | 2021-04-14T15:53:17 | 2021-02-01T12:44:59 | C++ | UTF-8 | C++ | false | false | 446 | cpp | #include<iostream>
#include<string>
using namespace std;
class First{ // first Parent
public:
string firstName="Vikash";
};
class Last{ // second parent
public:
string lastName="Dubey";
};
class Full:public First,public Last{ // full name
public:
void printName(){
cout<<firstName<<" "<<lastName;
}
};
int main(){
Full obj;
obj.printName();
} | [
"dubey.amansus@gmail.com"
] | dubey.amansus@gmail.com |
6d8a4503fd7642dd597d7b6a58b3135502bfc474 | af770ee5aacae717e02bfa9a642e6b7350faf9b8 | /08/VMTranslator/VMT.h | 40f4ff29f70ef0e4ead956f1640ede588c9a77c7 | [] | no_license | HUMANIAM/From_NANDgate_to_TetrisGame | 29efad59ef0f9f8ae9a01865fe74bdf527753f14 | 657517f3079685cb146527a7ccc6b19cafb2a7ef | refs/heads/master | 2020-03-18T00:07:58.118824 | 2018-10-02T16:29:24 | 2018-10-02T16:29:24 | 134,079,361 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 895 | h | #ifndef VMT_H_INCLUDED
#define VMT_H_INCLUDED
#include "Parser.h"
using namespace std;
extern vector<string> memo_segm_ops;
extern vector<string> arthim_logic_ops;
extern vector<string> function_ops;
extern vector<string> brancing_ops;
extern vector<string> components;
extern ifstream inputfile;
extern ofstream outputfile;
extern string lastoperation;
extern string vmfilename;
extern char infile[200];
extern char outfile[200];
extern int operorder;
extern string lastfn;
extern int nextaddress;
class VM_Translator{
private:
Parser p;
char path[120];
public:
VM_Translator(char*);
void StartTranslation();
void VM_Into_ASM(string );
string Basename();
string Getinfile(string );
bool Isfile(string);
void Setoutputpath();
bool ReadAllfiles(vector<string>&);
};
#endif // VMT_H_INCLUDED
| [
"="
] | = |
db96199961cf367b309111708936c94e398b3cc0 | 7e90a1f8280618b97729d0b49b80c6814d0466e2 | /workspace_pc/catkin_ws/devel_isolated/turtlebot3_example/include/turtlebot3_example/Turtlebot3Goal.h | cf18d8123c5013e1f43edff5ad4851c2b1984578 | [] | no_license | IreneYIN7/Map-Tracer | 91909f4649a8b65afed56ae3803f0c0602dd89ff | cbbe9acf067757116ec74c3aebdd672fd3df62ed | refs/heads/master | 2022-04-02T09:53:15.650365 | 2019-12-19T07:31:31 | 2019-12-19T07:31:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,128 | h | // Generated by gencpp from file turtlebot3_example/Turtlebot3Goal.msg
// DO NOT EDIT!
#ifndef TURTLEBOT3_EXAMPLE_MESSAGE_TURTLEBOT3GOAL_H
#define TURTLEBOT3_EXAMPLE_MESSAGE_TURTLEBOT3GOAL_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
#include <geometry_msgs/Vector3.h>
namespace turtlebot3_example
{
template <class ContainerAllocator>
struct Turtlebot3Goal_
{
typedef Turtlebot3Goal_<ContainerAllocator> Type;
Turtlebot3Goal_()
: goal() {
}
Turtlebot3Goal_(const ContainerAllocator& _alloc)
: goal(_alloc) {
(void)_alloc;
}
typedef ::geometry_msgs::Vector3_<ContainerAllocator> _goal_type;
_goal_type goal;
typedef boost::shared_ptr< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> const> ConstPtr;
}; // struct Turtlebot3Goal_
typedef ::turtlebot3_example::Turtlebot3Goal_<std::allocator<void> > Turtlebot3Goal;
typedef boost::shared_ptr< ::turtlebot3_example::Turtlebot3Goal > Turtlebot3GoalPtr;
typedef boost::shared_ptr< ::turtlebot3_example::Turtlebot3Goal const> Turtlebot3GoalConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace turtlebot3_example
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False}
// {'turtlebot3_example': ['/home/gse5/catkin_ws/devel_isolated/turtlebot3_example/share/turtlebot3_example/msg'], 'actionlib_msgs': ['/opt/ros/melodic/share/actionlib_msgs/cmake/../msg'], 'std_msgs': ['/opt/ros/melodic/share/std_msgs/cmake/../msg'], 'geometry_msgs': ['/opt/ros/melodic/share/geometry_msgs/cmake/../msg']}
// !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types']
template <class ContainerAllocator>
struct IsFixedSize< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> >
{
static const char* value()
{
return "8ad3bd0e46ff6777ce7cd2fdd945cb9e";
}
static const char* value(const ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x8ad3bd0e46ff6777ULL;
static const uint64_t static_value2 = 0xce7cd2fdd945cb9eULL;
};
template<class ContainerAllocator>
struct DataType< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> >
{
static const char* value()
{
return "turtlebot3_example/Turtlebot3Goal";
}
static const char* value(const ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> >
{
static const char* value()
{
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n"
"# Define the goal\n"
"geometry_msgs/Vector3 goal\n"
"\n"
"================================================================================\n"
"MSG: geometry_msgs/Vector3\n"
"# This represents a vector in free space. \n"
"# It is only meant to represent a direction. Therefore, it does not\n"
"# make sense to apply a translation to it (e.g., when applying a \n"
"# generic rigid transformation to a Vector3, tf2 will only apply the\n"
"# rotation). If you want your data to be translatable too, use the\n"
"# geometry_msgs/Point message instead.\n"
"\n"
"float64 x\n"
"float64 y\n"
"float64 z\n"
;
}
static const char* value(const ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.goal);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct Turtlebot3Goal_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::turtlebot3_example::Turtlebot3Goal_<ContainerAllocator>& v)
{
s << indent << "goal: ";
s << std::endl;
Printer< ::geometry_msgs::Vector3_<ContainerAllocator> >::stream(s, indent + " ", v.goal);
}
};
} // namespace message_operations
} // namespace ros
#endif // TURTLEBOT3_EXAMPLE_MESSAGE_TURTLEBOT3GOAL_H
| [
"sh9339@outlook.com"
] | sh9339@outlook.com |
15b473a8a965a31280c327a5c42c752c9b8bc378 | f5ef2adabb3b1fbc42a87f5b6ffda96929a42a1f | /src/wallet.h | ae464950579c924a8b3ee7859041fade31b0f865 | [
"MIT"
] | permissive | SocialNodeProtocol/smn-coin | 864026b6923a5318abb279514ded6e8443b9a6b6 | 8de65eac391751415a49ec54a62f7bc2296c9327 | refs/heads/master | 2020-06-04T08:14:25.678905 | 2019-06-21T07:32:27 | 2019-06-21T07:32:27 | 191,940,754 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 50,936 | h | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_WALLET_H
#define BITCOIN_WALLET_H
#include "amount.h"
#include "base58.h"
#include "crypter.h"
#include "kernel.h"
#include "key.h"
#include "keystore.h"
#include "main.h"
#include "primitives/block.h"
#include "primitives/transaction.h"
#include "primitives/zerocoin.h"
#include "ui_interface.h"
#include "util.h"
#include "validationinterface.h"
#include "wallet_ismine.h"
#include "walletdb.h"
#include <algorithm>
#include <map>
#include <set>
#include <stdexcept>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
/**
* Settings
*/
extern CFeeRate payTxFee;
extern CAmount maxTxFee;
extern unsigned int nTxConfirmTarget;
extern bool bSpendZeroConfChange;
extern bool bdisableSystemnotifications;
extern bool fSendFreeTransactions;
extern bool fPayAtLeastCustomFee;
//! -paytxfee default
static const CAmount DEFAULT_TRANSACTION_FEE = 0;
//! -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB
static const CAmount nHighTransactionFeeWarning = 0.1 * COIN;
//! -maxtxfee default
static const CAmount DEFAULT_TRANSACTION_MAXFEE = 1 * COIN;
//! -maxtxfee will warn if called with a higher fee than this amount (in satoshis)
static const CAmount nHighTransactionMaxFeeWarning = 100 * nHighTransactionFeeWarning;
//! Largest (in bytes) free transaction we're willing to create
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000;
// Zerocoin denomination which creates exactly one of each denominations:
// 6666 = 1*5000 + 1*1000 + 1*500 + 1*100 + 1*50 + 1*10 + 1*5 + 1
static const int ZQ_6666 = 6666;
class CAccountingEntry;
class CCoinControl;
class COutput;
class CReserveKey;
class CScript;
class CWalletTx;
/** (client) version numbers for particular wallet features */
enum WalletFeature {
FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getinfo's clientversion output)
FEATURE_WALLETCRYPT = 40000, // wallet encryption
FEATURE_COMPRPUBKEY = 60000, // compressed public keys
FEATURE_LATEST = 61000
};
enum AvailableCoinsType {
ALL_COINS = 1,
ONLY_DENOMINATED = 2,
ONLY_NOT10000IFMN = 3,
ONLY_NONDENOMINATED_NOT10000IFMN = 4, // ONLY_NONDENOMINATED and not 10000 SocialNode at the same time
ONLY_10000 = 5, // find masternode outputs including locked ones (use with caution)
STAKABLE_COINS = 6 // UTXO's that are valid for staking
};
// Possible states for zSMN send
enum ZerocoinSpendStatus {
ZSocialNode_SPEND_OKAY = 0, // No error
ZSocialNode_SPEND_ERROR = 1, // Unspecified class of errors, more details are (hopefully) in the returning text
ZSocialNode_WALLET_LOCKED = 2, // Wallet was locked
ZSocialNode_COMMIT_FAILED = 3, // Commit failed, reset status
ZSocialNode_ERASE_SPENDS_FAILED = 4, // Erasing spends during reset failed
ZSocialNode_ERASE_NEW_MINTS_FAILED = 5, // Erasing new mints during reset failed
ZSocialNode_TRX_FUNDS_PROBLEMS = 6, // Everything related to available funds
ZSocialNode_TRX_CREATE = 7, // Everything related to create the transaction
ZSocialNode_TRX_CHANGE = 8, // Everything related to transaction change
ZSocialNode_TXMINT_GENERAL = 9, // General errors in MintToTxIn
ZSocialNode_INVALID_COIN = 10, // Selected mint coin is not valid
ZSocialNode_FAILED_ACCUMULATOR_INITIALIZATION = 11, // Failed to initialize witness
ZSocialNode_INVALID_WITNESS = 12, // Spend coin transaction did not verify
ZSocialNode_BAD_SERIALIZATION = 13, // Transaction verification failed
ZSocialNode_SPENT_USED_ZSocialNode = 14 // Coin has already been spend
};
struct CompactTallyItem {
CBitcoinAddress address;
CAmount nAmount;
std::vector<CTxIn> vecTxIn;
CompactTallyItem()
{
nAmount = 0;
}
};
/** A key pool entry */
class CKeyPool
{
public:
int64_t nTime;
CPubKey vchPubKey;
CKeyPool();
CKeyPool(const CPubKey& vchPubKeyIn);
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
READWRITE(nTime);
READWRITE(vchPubKey);
}
};
/** Address book data */
class CAddressBookData
{
public:
std::string name;
std::string purpose;
CAddressBookData()
{
purpose = "unknown";
}
typedef std::map<std::string, std::string> StringMap;
StringMap destdata;
};
/**
* A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,
* and provides the ability to create new transactions.
*/
class CWallet : public CCryptoKeyStore, public CValidationInterface
{
private:
bool SelectCoins(const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*, unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl = NULL, AvailableCoinsType coin_type = ALL_COINS, bool useIX = true) const;
//it was public bool SelectCoins(int64_t nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = true) const;
CWalletDB* pwalletdbEncryption;
//! the current wallet version: clients below this version are not able to load the wallet
int nWalletVersion;
//! the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
int nWalletMaxVersion;
int64_t nNextResend;
int64_t nLastResend;
/**
* Used to keep track of spent outpoints, and
* detect and report conflicts (double-spends or
* mutated transactions where the mutant gets mined).
*/
typedef std::multimap<COutPoint, uint256> TxSpends;
TxSpends mapTxSpends;
void AddToSpends(const COutPoint& outpoint, const uint256& wtxid);
void AddToSpends(const uint256& wtxid);
void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>);
public:
bool MintableCoins();
bool SelectStakeCoins(std::set<std::pair<const CWalletTx*, unsigned int> >& setCoins, CAmount nTargetAmount) const;
bool SelectCoinsDark(CAmount nValueMin, CAmount nValueMax, std::vector<CTxIn>& setCoinsRet, CAmount& nValueRet, int nObfuscationRoundsMin, int nObfuscationRoundsMax) const;
bool SelectCoinsByDenominations(int nDenom, CAmount nValueMin, CAmount nValueMax, std::vector<CTxIn>& vCoinsRet, std::vector<COutput>& vCoinsRet2, CAmount& nValueRet, int nObfuscationRoundsMin, int nObfuscationRoundsMax);
bool SelectCoinsDarkDenominated(CAmount nTargetValue, std::vector<CTxIn>& setCoinsRet, CAmount& nValueRet) const;
bool HasCollateralInputs(bool fOnlyConfirmed = true) const;
bool IsCollateralAmount(CAmount nInputAmount) const;
int CountInputsWithAmount(CAmount nInputAmount);
bool SelectCoinsCollateral(std::vector<CTxIn>& setCoinsRet, CAmount& nValueRet) const;
// Zerocoin additions
bool CreateZerocoinMintTransaction(const CAmount nValue, CMutableTransaction& txNew, vector<CZerocoinMint>& vMints, CReserveKey* reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl = NULL, const bool isZCSpendChange = false);
bool CreateZerocoinSpendTransaction(CAmount nValue, int nSecurityLevel, CWalletTx& wtxNew, CReserveKey& reserveKey, CZerocoinSpendReceipt& receipt, vector<CZerocoinMint>& vSelectedMints, vector<CZerocoinMint>& vNewMints, bool fMintChange, bool fMinimizeChange, CBitcoinAddress* address = NULL);
bool MintToTxIn(CZerocoinMint zerocoinSelected, int nSecurityLevel, const uint256& hashTxOut, CTxIn& newTxIn, CZerocoinSpendReceipt& receipt);
std::string MintZerocoin(CAmount nValue, CWalletTx& wtxNew, vector<CZerocoinMint>& vMints, const CCoinControl* coinControl = NULL);
bool SpendZerocoin(CAmount nValue, int nSecurityLevel, CWalletTx& wtxNew, CZerocoinSpendReceipt& receipt, vector<CZerocoinMint>& vMintsSelected, bool fMintChange, bool fMinimizeChange, CBitcoinAddress* addressTo = NULL);
std::string ResetMintZerocoin(bool fExtendedSearch);
std::string ResetSpentZerocoin();
void ReconsiderZerocoins(std::list<CZerocoinMint>& listMintsRestored);
void ZSocialNodeBackupWallet();
/** Zerocin entry changed.
* @note called with lock cs_wallet held.
*/
boost::signals2::signal<void(CWallet* wallet, const std::string& pubCoin, const std::string& isUsed, ChangeType status)> NotifyZerocoinChanged;
/*
* Main wallet lock.
* This lock protects all the fields added by CWallet
* except for:
* fFileBacked (immutable after instantiation)
* strWalletFile (immutable after instantiation)
*/
mutable CCriticalSection cs_wallet;
bool fFileBacked;
bool fWalletUnlockAnonymizeOnly;
std::string strWalletFile;
bool fBackupMints;
std::set<int64_t> setKeyPool;
std::map<CKeyID, CKeyMetadata> mapKeyMetadata;
typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
MasterKeyMap mapMasterKeys;
unsigned int nMasterKeyMaxID;
// Stake Settings
unsigned int nHashDrift;
unsigned int nHashInterval;
uint64_t nStakeSplitThreshold;
int nStakeSetUpdateTime;
//MultiSend
std::vector<std::pair<std::string, int> > vMultiSend;
bool fMultiSendStake;
bool fMultiSendMasternodeReward;
bool fMultiSendNotify;
std::string strMultiSendChangeAddress;
int nLastMultiSendHeight;
std::vector<std::string> vDisabledAddresses;
//Auto Combine Inputs
bool fCombineDust;
CAmount nAutoCombineThreshold;
CWallet()
{
SetNull();
}
CWallet(std::string strWalletFileIn)
{
SetNull();
strWalletFile = strWalletFileIn;
fFileBacked = true;
}
~CWallet()
{
delete pwalletdbEncryption;
}
void SetNull()
{
nWalletVersion = FEATURE_BASE;
nWalletMaxVersion = FEATURE_BASE;
fFileBacked = false;
nMasterKeyMaxID = 0;
pwalletdbEncryption = NULL;
nOrderPosNext = 0;
nNextResend = 0;
nLastResend = 0;
nTimeFirstKey = 0;
fWalletUnlockAnonymizeOnly = false;
fBackupMints = false;
// Stake Settings
nHashDrift = 45;
nStakeSplitThreshold = 12;
nHashInterval = 22;
nStakeSetUpdateTime = 300; // 5 minutes
//MultiSend
vMultiSend.clear();
fMultiSendStake = false;
fMultiSendMasternodeReward = false;
fMultiSendNotify = false;
strMultiSendChangeAddress = "";
nLastMultiSendHeight = 0;
vDisabledAddresses.clear();
//Auto Combine Dust
fCombineDust = false;
nAutoCombineThreshold = 0;
}
bool isZeromintEnabled()
{
return fEnableZeromint;
}
void setZSocialNodeAutoBackups(bool fEnabled)
{
fBackupMints = fEnabled;
}
bool isMultiSendEnabled()
{
return fMultiSendMasternodeReward || fMultiSendStake;
}
void setMultiSendDisabled()
{
fMultiSendMasternodeReward = false;
fMultiSendStake = false;
}
std::map<uint256, CWalletTx> mapWallet;
int64_t nOrderPosNext;
std::map<uint256, int> mapRequestCount;
std::map<CTxDestination, CAddressBookData> mapAddressBook;
CPubKey vchDefaultKey;
std::set<COutPoint> setLockedCoins;
int64_t nTimeFirstKey;
const CWalletTx* GetWalletTx(const uint256& hash) const;
//! check whether we are allowed to upgrade (or already support) to the named feature
bool CanSupportFeature(enum WalletFeature wf)
{
AssertLockHeld(cs_wallet);
return nWalletMaxVersion >= wf;
}
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed = true, const CCoinControl* coinControl = NULL, bool fIncludeZeroValue = false, AvailableCoinsType nCoinType = ALL_COINS, bool fUseIX = false) const;
std::map<CBitcoinAddress, std::vector<COutput> > AvailableCoinsByAddress(bool fConfirmed = true, CAmount maxCoinValue = 0);
bool SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*, unsigned int> >& setCoinsRet, CAmount& nValueRet) const;
/// Get 1000DASH output and keys which can be used for the Masternode
bool GetMasternodeVinAndKeys(CTxIn& txinRet, CPubKey& pubKeyRet, CKey& keyRet, std::string strTxHash = "", std::string strOutputIndex = "");
/// Extract txin information and keys from output
bool GetVinAndKeysFromOutput(COutput out, CTxIn& txinRet, CPubKey& pubKeyRet, CKey& keyRet);
bool IsSpent(const uint256& hash, unsigned int n) const;
bool IsLockedCoin(uint256 hash, unsigned int n) const;
void LockCoin(COutPoint& output);
void UnlockCoin(COutPoint& output);
void UnlockAllCoins();
void ListLockedCoins(std::vector<COutPoint>& vOutpts);
CAmount GetTotalValue(std::vector<CTxIn> vCoins);
// keystore implementation
// Generate a new key
CPubKey GenerateNewKey();
//! Adds a key to the store, and saves it to disk.
bool AddKeyPubKey(const CKey& key, const CPubKey& pubkey);
//! Adds a key to the store, without saving it to disk (used by LoadWallet)
bool LoadKey(const CKey& key, const CPubKey& pubkey) { return CCryptoKeyStore::AddKeyPubKey(key, pubkey); }
//! Load metadata (used by LoadWallet)
bool LoadKeyMetadata(const CPubKey& pubkey, const CKeyMetadata& metadata);
bool LoadMinVersion(int nVersion)
{
AssertLockHeld(cs_wallet);
nWalletVersion = nVersion;
nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion);
return true;
}
//! Adds an encrypted key to the store, and saves it to disk.
bool AddCryptedKey(const CPubKey& vchPubKey, const std::vector<unsigned char>& vchCryptedSecret);
//! Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
bool LoadCryptedKey(const CPubKey& vchPubKey, const std::vector<unsigned char>& vchCryptedSecret);
bool AddCScript(const CScript& redeemScript);
bool LoadCScript(const CScript& redeemScript);
//! Adds a destination data tuple to the store, and saves it to disk
bool AddDestData(const CTxDestination& dest, const std::string& key, const std::string& value);
//! Erases a destination data tuple in the store and on disk
bool EraseDestData(const CTxDestination& dest, const std::string& key);
//! Adds a destination data tuple to the store, without saving it to disk
bool LoadDestData(const CTxDestination& dest, const std::string& key, const std::string& value);
//! Look up a destination data tuple in the store, return true if found false otherwise
bool GetDestData(const CTxDestination& dest, const std::string& key, std::string* value) const;
//! Adds a watch-only address to the store, and saves it to disk.
bool AddWatchOnly(const CScript& dest);
bool RemoveWatchOnly(const CScript& dest);
//! Adds a watch-only address to the store, without saving it to disk (used by LoadWallet)
bool LoadWatchOnly(const CScript& dest);
//! Adds a MultiSig address to the store, and saves it to disk.
bool AddMultiSig(const CScript& dest);
bool RemoveMultiSig(const CScript& dest);
//! Adds a MultiSig address to the store, without saving it to disk (used by LoadWallet)
bool LoadMultiSig(const CScript& dest);
bool Unlock(const SecureString& strWalletPassphrase, bool anonimizeOnly = false);
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
bool EncryptWallet(const SecureString& strWalletPassphrase);
void GetKeyBirthTimes(std::map<CKeyID, int64_t>& mapKeyBirth) const;
/**
* Increment the next transaction order id
* @return next transaction order id
*/
int64_t IncOrderPosNext(CWalletDB* pwalletdb = NULL);
typedef std::pair<CWalletTx*, CAccountingEntry*> TxPair;
typedef std::multimap<int64_t, TxPair> TxItems;
/**
* Get the wallet's activity log
* @return multimap of ordered transactions and accounting entries
* @warning Returned pointers are *only* valid within the scope of passed acentries
*/
TxItems OrderedTxItems(std::list<CAccountingEntry>& acentries, std::string strAccount = "");
void MarkDirty();
bool AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet = false);
void SyncTransaction(const CTransaction& tx, const CBlock* pblock);
bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate);
void EraseFromWallet(const uint256& hash);
int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false);
void ReacceptWalletTransactions();
void ResendWalletTransactions();
CAmount GetBalance() const;
CAmount GetZerocoinBalance(bool fMatureOnly) const;
CAmount GetUnconfirmedZerocoinBalance() const;
CAmount GetImmatureZerocoinBalance() const;
CAmount GetLockedCoins() const;
CAmount GetUnlockedCoins() const;
std::map<libzerocoin::CoinDenomination, CAmount> GetMyZerocoinDistribution() const;
CAmount GetUnconfirmedBalance() const;
CAmount GetImmatureBalance() const;
CAmount GetAnonymizableBalance() const;
CAmount GetAnonymizedBalance() const;
double GetAverageAnonymizedRounds() const;
CAmount GetNormalizedAnonymizedBalance() const;
CAmount GetDenominatedBalance(bool unconfirmed = false) const;
CAmount GetWatchOnlyBalance() const;
CAmount GetUnconfirmedWatchOnlyBalance() const;
CAmount GetImmatureWatchOnlyBalance() const;
bool CreateTransaction(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl);
bool CreateTransaction(const std::vector<std::pair<CScript, CAmount> >& vecSend,
CWalletTx& wtxNew,
CReserveKey& reservekey,
CAmount& nFeeRet,
std::string& strFailReason,
const CCoinControl* coinControl = NULL,
AvailableCoinsType coin_type = ALL_COINS,
bool useIX = false,
CAmount nFeePay = 0);
bool CreateTransaction(CScript scriptPubKey, const CAmount& nValue, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl = NULL, AvailableCoinsType coin_type = ALL_COINS, bool useIX = false, CAmount nFeePay = 0);
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, std::string strCommand = "tx");
std::string PrepareObfuscationDenominate(int minRounds, int maxRounds);
int GenerateObfuscationOutputs(int nTotalValue, std::vector<CTxOut>& vout);
bool CreateCollateralTransaction(CMutableTransaction& txCollateral, std::string& strReason);
bool ConvertList(std::vector<CTxIn> vCoins, std::vector<int64_t>& vecAmounts);
bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CMutableTransaction& txNew, unsigned int& nTxNewTime);
bool MultiSend();
void AutoCombineDust();
void AutoZeromint();
static CFeeRate minTxFee;
static CAmount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool);
bool NewKeyPool();
bool TopUpKeyPool(unsigned int kpSize = 0);
void ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool);
void KeepKey(int64_t nIndex);
void ReturnKey(int64_t nIndex);
bool GetKeyFromPool(CPubKey& key);
int64_t GetOldestKeyPoolTime();
void GetAllReserveKeys(std::set<CKeyID>& setAddress) const;
std::set<std::set<CTxDestination> > GetAddressGroupings();
std::map<CTxDestination, CAmount> GetAddressBalances();
std::set<CTxDestination> GetAccountAddresses(std::string strAccount) const;
bool GetBudgetSystemCollateralTX(CTransaction& tx, uint256 hash, bool useIX);
bool GetBudgetSystemCollateralTX(CWalletTx& tx, uint256 hash, bool useIX);
// get the Obfuscation chain depth for a given input
int GetRealInputObfuscationRounds(CTxIn in, int rounds) const;
// respect current settings
int GetInputObfuscationRounds(CTxIn in) const;
bool IsDenominated(const CTxIn& txin) const;
bool IsDenominated(const CTransaction& tx) const;
bool IsDenominatedAmount(CAmount nInputAmount) const;
isminetype IsMine(const CTxIn& txin) const;
CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
isminetype IsMine(const CTxOut& txout) const
{
return ::IsMine(*this, txout.scriptPubKey);
}
bool IsMyZerocoinSpend(const CBigNum& bnSerial) const;
CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const
{
if (!MoneyRange(txout.nValue))
throw std::runtime_error("CWallet::GetCredit() : value out of range");
return ((IsMine(txout) & filter) ? txout.nValue : 0);
}
bool IsChange(const CTxOut& txout) const;
CAmount GetChange(const CTxOut& txout) const
{
if (!MoneyRange(txout.nValue))
throw std::runtime_error("CWallet::GetChange() : value out of range");
return (IsChange(txout) ? txout.nValue : 0);
}
bool IsMine(const CTransaction& tx) const
{
BOOST_FOREACH (const CTxOut& txout, tx.vout)
if (IsMine(txout))
return true;
return false;
}
/** should probably be renamed to IsRelevantToMe */
bool IsFromMe(const CTransaction& tx) const
{
return (GetDebit(tx, ISMINE_ALL) > 0);
}
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const
{
CAmount nDebit = 0;
BOOST_FOREACH (const CTxIn& txin, tx.vin) {
nDebit += GetDebit(txin, filter);
if (!MoneyRange(nDebit))
throw std::runtime_error("CWallet::GetDebit() : value out of range");
}
return nDebit;
}
CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const
{
CAmount nCredit = 0;
BOOST_FOREACH (const CTxOut& txout, tx.vout) {
nCredit += GetCredit(txout, filter);
if (!MoneyRange(nCredit))
throw std::runtime_error("CWallet::GetCredit() : value out of range");
}
return nCredit;
}
CAmount GetChange(const CTransaction& tx) const
{
CAmount nChange = 0;
BOOST_FOREACH (const CTxOut& txout, tx.vout) {
nChange += GetChange(txout);
if (!MoneyRange(nChange))
throw std::runtime_error("CWallet::GetChange() : value out of range");
}
return nChange;
}
void SetBestChain(const CBlockLocator& loc);
DBErrors LoadWallet(bool& fFirstRunRet);
DBErrors ZapWalletTx(std::vector<CWalletTx>& vWtx);
bool SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& purpose);
bool DelAddressBook(const CTxDestination& address);
bool UpdatedTransaction(const uint256& hashTx);
void Inventory(const uint256& hash)
{
{
LOCK(cs_wallet);
std::map<uint256, int>::iterator mi = mapRequestCount.find(hash);
if (mi != mapRequestCount.end())
(*mi).second++;
}
}
unsigned int GetKeyPoolSize()
{
AssertLockHeld(cs_wallet); // setKeyPool
return setKeyPool.size();
}
bool SetDefaultKey(const CPubKey& vchPubKey);
//! signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVersion if those are lower
bool SetMinVersion(enum WalletFeature, CWalletDB* pwalletdbIn = NULL, bool fExplicit = false);
//! change which version we're allowed to upgrade to (note that this does not immediately imply upgrading to that format)
bool SetMaxVersion(int nVersion);
//! get the current wallet format (the oldest client version guaranteed to understand this wallet)
int GetVersion()
{
LOCK(cs_wallet);
return nWalletVersion;
}
//! Get wallet transactions that conflict with given transaction (spend same outputs)
std::set<uint256> GetConflicts(const uint256& txid) const;
/**
* Address book entry changed.
* @note called with lock cs_wallet held.
*/
boost::signals2::signal<void(CWallet* wallet, const CTxDestination& address, const std::string& label, bool isMine, const std::string& purpose, ChangeType status)> NotifyAddressBookChanged;
/**
* Wallet transaction added, removed or updated.
* @note called with lock cs_wallet held.
*/
boost::signals2::signal<void(CWallet* wallet, const uint256& hashTx, ChangeType status)> NotifyTransactionChanged;
/** Show progress e.g. for rescan */
boost::signals2::signal<void(const std::string& title, int nProgress)> ShowProgress;
/** Watch-only address added */
boost::signals2::signal<void(bool fHaveWatchOnly)> NotifyWatchonlyChanged;
/** MultiSig address added */
boost::signals2::signal<void(bool fHaveMultiSig)> NotifyMultiSigChanged;
};
/** A key allocated from the key pool. */
class CReserveKey
{
protected:
CWallet* pwallet;
int64_t nIndex;
CPubKey vchPubKey;
public:
CReserveKey(CWallet* pwalletIn)
{
nIndex = -1;
pwallet = pwalletIn;
}
~CReserveKey()
{
ReturnKey();
}
void ReturnKey();
bool GetReservedKey(CPubKey& pubkey);
void KeepKey();
};
typedef std::map<std::string, std::string> mapValue_t;
static void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue)
{
if (!mapValue.count("n")) {
nOrderPos = -1; // TODO: calculate elsewhere
return;
}
nOrderPos = atoi64(mapValue["n"].c_str());
}
static void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue)
{
if (nOrderPos == -1)
return;
mapValue["n"] = i64tostr(nOrderPos);
}
struct COutputEntry {
CTxDestination destination;
CAmount amount;
int vout;
};
/** A transaction with a merkle branch linking it to the block chain. */
class CMerkleTx : public CTransaction
{
private:
int GetDepthInMainChainINTERNAL(const CBlockIndex*& pindexRet) const;
public:
uint256 hashBlock;
std::vector<uint256> vMerkleBranch;
int nIndex;
// memory only
mutable bool fMerkleVerified;
CMerkleTx()
{
Init();
}
CMerkleTx(const CTransaction& txIn) : CTransaction(txIn)
{
Init();
}
void Init()
{
hashBlock = 0;
nIndex = -1;
fMerkleVerified = false;
}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{
READWRITE(*(CTransaction*)this);
nVersion = this->nVersion;
READWRITE(hashBlock);
READWRITE(vMerkleBranch);
READWRITE(nIndex);
}
int SetMerkleBranch(const CBlock& block);
/**
* Return depth of transaction in blockchain:
* -1 : not in blockchain, and not in memory pool (conflicted transaction)
* 0 : in memory pool, waiting to be included in a block
* >=1 : this many blocks deep in the main chain
*/
int GetDepthInMainChain(const CBlockIndex*& pindexRet, bool enableIX = true) const;
int GetDepthInMainChain(bool enableIX = true) const
{
const CBlockIndex* pindexRet;
return GetDepthInMainChain(pindexRet, enableIX);
}
bool IsInMainChain() const
{
const CBlockIndex* pindexRet;
return GetDepthInMainChainINTERNAL(pindexRet) > 0;
}
int GetBlocksToMaturity() const;
bool AcceptToMemoryPool(bool fLimitFree = true, bool fRejectInsaneFee = true, bool ignoreFees = false);
int GetTransactionLockSignatures() const;
bool IsTransactionLockTimedOut() const;
};
/**
* A transaction with a bunch of additional info that only the owner cares about.
* It includes any unrecorded transactions needed to link it back to the block chain.
*/
class CWalletTx : public CMerkleTx
{
private:
const CWallet* pwallet;
public:
mapValue_t mapValue;
std::vector<std::pair<std::string, std::string> > vOrderForm;
unsigned int fTimeReceivedIsTxTime;
unsigned int nTimeReceived; //! time received by this node
unsigned int nTimeSmart;
char fFromMe;
std::string strFromAccount;
int64_t nOrderPos; //! position in ordered transaction list
// memory only
mutable bool fDebitCached;
mutable bool fCreditCached;
mutable bool fImmatureCreditCached;
mutable bool fAvailableCreditCached;
mutable bool fAnonymizableCreditCached;
mutable bool fAnonymizedCreditCached;
mutable bool fDenomUnconfCreditCached;
mutable bool fDenomConfCreditCached;
mutable bool fWatchDebitCached;
mutable bool fWatchCreditCached;
mutable bool fImmatureWatchCreditCached;
mutable bool fAvailableWatchCreditCached;
mutable bool fChangeCached;
mutable CAmount nDebitCached;
mutable CAmount nCreditCached;
mutable CAmount nImmatureCreditCached;
mutable CAmount nAvailableCreditCached;
mutable CAmount nAnonymizableCreditCached;
mutable CAmount nAnonymizedCreditCached;
mutable CAmount nDenomUnconfCreditCached;
mutable CAmount nDenomConfCreditCached;
mutable CAmount nWatchDebitCached;
mutable CAmount nWatchCreditCached;
mutable CAmount nImmatureWatchCreditCached;
mutable CAmount nAvailableWatchCreditCached;
mutable CAmount nChangeCached;
CWalletTx()
{
Init(NULL);
}
CWalletTx(const CWallet* pwalletIn)
{
Init(pwalletIn);
}
CWalletTx(const CWallet* pwalletIn, const CMerkleTx& txIn) : CMerkleTx(txIn)
{
Init(pwalletIn);
}
CWalletTx(const CWallet* pwalletIn, const CTransaction& txIn) : CMerkleTx(txIn)
{
Init(pwalletIn);
}
void Init(const CWallet* pwalletIn)
{
pwallet = pwalletIn;
mapValue.clear();
vOrderForm.clear();
fTimeReceivedIsTxTime = false;
nTimeReceived = 0;
nTimeSmart = 0;
fFromMe = false;
strFromAccount.clear();
fDebitCached = false;
fCreditCached = false;
fImmatureCreditCached = false;
fAvailableCreditCached = false;
fAnonymizableCreditCached = false;
fAnonymizedCreditCached = false;
fDenomUnconfCreditCached = false;
fDenomConfCreditCached = false;
fWatchDebitCached = false;
fWatchCreditCached = false;
fImmatureWatchCreditCached = false;
fAvailableWatchCreditCached = false;
fChangeCached = false;
nDebitCached = 0;
nCreditCached = 0;
nImmatureCreditCached = 0;
nAvailableCreditCached = 0;
nAnonymizableCreditCached = 0;
nAnonymizedCreditCached = 0;
nDenomUnconfCreditCached = 0;
nDenomConfCreditCached = 0;
nWatchDebitCached = 0;
nWatchCreditCached = 0;
nAvailableWatchCreditCached = 0;
nImmatureWatchCreditCached = 0;
nChangeCached = 0;
nOrderPos = -1;
}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{
if (ser_action.ForRead())
Init(NULL);
char fSpent = false;
if (!ser_action.ForRead()) {
mapValue["fromaccount"] = strFromAccount;
WriteOrderPos(nOrderPos, mapValue);
if (nTimeSmart)
mapValue["timesmart"] = strprintf("%u", nTimeSmart);
}
READWRITE(*(CMerkleTx*)this);
std::vector<CMerkleTx> vUnused; //! Used to be vtxPrev
READWRITE(vUnused);
READWRITE(mapValue);
READWRITE(vOrderForm);
READWRITE(fTimeReceivedIsTxTime);
READWRITE(nTimeReceived);
READWRITE(fFromMe);
READWRITE(fSpent);
if (ser_action.ForRead()) {
strFromAccount = mapValue["fromaccount"];
ReadOrderPos(nOrderPos, mapValue);
nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0;
}
mapValue.erase("fromaccount");
mapValue.erase("version");
mapValue.erase("spent");
mapValue.erase("n");
mapValue.erase("timesmart");
}
//! make sure balances are recalculated
void MarkDirty()
{
fCreditCached = false;
fAvailableCreditCached = false;
fAnonymizableCreditCached = false;
fAnonymizedCreditCached = false;
fDenomUnconfCreditCached = false;
fDenomConfCreditCached = false;
fWatchDebitCached = false;
fWatchCreditCached = false;
fAvailableWatchCreditCached = false;
fImmatureWatchCreditCached = false;
fDebitCached = false;
fChangeCached = false;
}
void BindWallet(CWallet* pwalletIn)
{
pwallet = pwalletIn;
MarkDirty();
}
//! filter decides which addresses will count towards the debit
CAmount GetDebit(const isminefilter& filter) const
{
if (vin.empty())
return 0;
CAmount debit = 0;
if (filter & ISMINE_SPENDABLE) {
if (fDebitCached)
debit += nDebitCached;
else {
nDebitCached = pwallet->GetDebit(*this, ISMINE_SPENDABLE);
fDebitCached = true;
debit += nDebitCached;
}
}
if (filter & ISMINE_WATCH_ONLY) {
if (fWatchDebitCached)
debit += nWatchDebitCached;
else {
nWatchDebitCached = pwallet->GetDebit(*this, ISMINE_WATCH_ONLY);
fWatchDebitCached = true;
debit += nWatchDebitCached;
}
}
return debit;
}
CAmount GetCredit(const isminefilter& filter) const
{
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
CAmount credit = 0;
if (filter & ISMINE_SPENDABLE) {
// GetBalance can assume transactions in mapWallet won't change
if (fCreditCached)
credit += nCreditCached;
else {
nCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE);
fCreditCached = true;
credit += nCreditCached;
}
}
if (filter & ISMINE_WATCH_ONLY) {
if (fWatchCreditCached)
credit += nWatchCreditCached;
else {
nWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY);
fWatchCreditCached = true;
credit += nWatchCreditCached;
}
}
return credit;
}
CAmount GetImmatureCredit(bool fUseCache = true) const
{
if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0 && IsInMainChain()) {
if (fUseCache && fImmatureCreditCached)
return nImmatureCreditCached;
nImmatureCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE);
fImmatureCreditCached = true;
return nImmatureCreditCached;
}
return 0;
}
CAmount GetAvailableCredit(bool fUseCache = true) const
{
if (pwallet == 0)
return 0;
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
if (fUseCache && fAvailableCreditCached)
return nAvailableCreditCached;
CAmount nCredit = 0;
uint256 hashTx = GetHash();
for (unsigned int i = 0; i < vout.size(); i++) {
if (!pwallet->IsSpent(hashTx, i)) {
const CTxOut& txout = vout[i];
nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE);
if (!MoneyRange(nCredit))
throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range");
}
}
nAvailableCreditCached = nCredit;
fAvailableCreditCached = true;
return nCredit;
}
CAmount GetAnonymizableCredit(bool fUseCache = true) const
{
if (pwallet == 0)
return 0;
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
if (fUseCache && fAnonymizableCreditCached)
return nAnonymizableCreditCached;
CAmount nCredit = 0;
uint256 hashTx = GetHash();
for (unsigned int i = 0; i < vout.size(); i++) {
const CTxOut& txout = vout[i];
const CTxIn vin = CTxIn(hashTx, i);
if (pwallet->IsSpent(hashTx, i) || pwallet->IsLockedCoin(hashTx, i)) continue;
if (fMasterNode && vout[i].nValue == GetMstrNodCollateral(chainActive.Height())*COIN) continue; // do not count MN-like outputs
const int rounds = pwallet->GetInputObfuscationRounds(vin);
if (rounds >= -2 && rounds < nZeromintPercentage) {
nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE);
if (!MoneyRange(nCredit))
throw std::runtime_error("CWalletTx::GetAnonamizableCredit() : value out of range");
}
}
nAnonymizableCreditCached = nCredit;
fAnonymizableCreditCached = true;
return nCredit;
}
CAmount GetAnonymizedCredit(bool fUseCache = true) const
{
if (pwallet == 0)
return 0;
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
if (fUseCache && fAnonymizedCreditCached)
return nAnonymizedCreditCached;
CAmount nCredit = 0;
uint256 hashTx = GetHash();
for (unsigned int i = 0; i < vout.size(); i++) {
const CTxOut& txout = vout[i];
const CTxIn vin = CTxIn(hashTx, i);
if (pwallet->IsSpent(hashTx, i) || !pwallet->IsDenominated(vin)) continue;
const int rounds = pwallet->GetInputObfuscationRounds(vin);
if (rounds >= nZeromintPercentage) {
nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE);
if (!MoneyRange(nCredit))
throw std::runtime_error("CWalletTx::GetAnonymizedCredit() : value out of range");
}
}
nAnonymizedCreditCached = nCredit;
fAnonymizedCreditCached = true;
return nCredit;
}
// Return sum of unlocked coins
CAmount GetUnlockedCredit() const
{
if (pwallet == 0)
return 0;
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
CAmount nCredit = 0;
uint256 hashTx = GetHash();
for (unsigned int i = 0; i < vout.size(); i++) {
const CTxOut& txout = vout[i];
if (pwallet->IsSpent(hashTx, i) || pwallet->IsLockedCoin(hashTx, i)) continue;
if (fMasterNode && vout[i].nValue == GetMstrNodCollateral(chainActive.Height())*COIN) continue; // do not count MN-like outputs
nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE);
if (!MoneyRange(nCredit))
throw std::runtime_error("CWalletTx::GetUnlockedCredit() : value out of range");
}
return nCredit;
}
// Return sum of unlocked coins
CAmount GetLockedCredit() const
{
if (pwallet == 0)
return 0;
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
CAmount nCredit = 0;
uint256 hashTx = GetHash();
for (unsigned int i = 0; i < vout.size(); i++) {
const CTxOut& txout = vout[i];
// Skip spent coins
if (pwallet->IsSpent(hashTx, i)) continue;
// Add locked coins
if (pwallet->IsLockedCoin(hashTx, i)) {
nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE);
}
// Add masternode collaterals which are handled likc locked coins
if (fMasterNode && vout[i].nValue == GetMstrNodCollateral(chainActive.Height())*COIN) {
nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE);
}
if (!MoneyRange(nCredit))
throw std::runtime_error("CWalletTx::GetLockedCredit() : value out of range");
}
return nCredit;
}
CAmount GetDenominatedCredit(bool unconfirmed, bool fUseCache = true) const
{
if (pwallet == 0)
return 0;
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
int nDepth = GetDepthInMainChain(false);
if (nDepth < 0) return 0;
bool isUnconfirmed = !IsFinalTx(*this) || (!IsTrusted() && nDepth == 0);
if (unconfirmed != isUnconfirmed) return 0;
if (fUseCache) {
if (unconfirmed && fDenomUnconfCreditCached)
return nDenomUnconfCreditCached;
else if (!unconfirmed && fDenomConfCreditCached)
return nDenomConfCreditCached;
}
CAmount nCredit = 0;
uint256 hashTx = GetHash();
for (unsigned int i = 0; i < vout.size(); i++) {
const CTxOut& txout = vout[i];
if (pwallet->IsSpent(hashTx, i) || !pwallet->IsDenominatedAmount(vout[i].nValue)) continue;
nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE);
if (!MoneyRange(nCredit))
throw std::runtime_error("CWalletTx::GetDenominatedCredit() : value out of range");
}
if (unconfirmed) {
nDenomUnconfCreditCached = nCredit;
fDenomUnconfCreditCached = true;
} else {
nDenomConfCreditCached = nCredit;
fDenomConfCreditCached = true;
}
return nCredit;
}
CAmount GetImmatureWatchOnlyCredit(const bool& fUseCache = true) const
{
if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain()) {
if (fUseCache && fImmatureWatchCreditCached)
return nImmatureWatchCreditCached;
nImmatureWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY);
fImmatureWatchCreditCached = true;
return nImmatureWatchCreditCached;
}
return 0;
}
CAmount GetAvailableWatchOnlyCredit(const bool& fUseCache = true) const
{
if (pwallet == 0)
return 0;
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
if (fUseCache && fAvailableWatchCreditCached)
return nAvailableWatchCreditCached;
CAmount nCredit = 0;
for (unsigned int i = 0; i < vout.size(); i++) {
if (!pwallet->IsSpent(GetHash(), i)) {
const CTxOut& txout = vout[i];
nCredit += pwallet->GetCredit(txout, ISMINE_WATCH_ONLY);
if (!MoneyRange(nCredit))
throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range");
}
}
nAvailableWatchCreditCached = nCredit;
fAvailableWatchCreditCached = true;
return nCredit;
}
CAmount GetChange() const
{
if (fChangeCached)
return nChangeCached;
nChangeCached = pwallet->GetChange(*this);
fChangeCached = true;
return nChangeCached;
}
void GetAmounts(std::list<COutputEntry>& listReceived,
std::list<COutputEntry>& listSent,
CAmount& nFee,
std::string& strSentAccount,
const isminefilter& filter) const;
void GetAccountAmounts(const std::string& strAccount, CAmount& nReceived, CAmount& nSent, CAmount& nFee, const isminefilter& filter) const;
bool IsFromMe(const isminefilter& filter) const
{
return (GetDebit(filter) > 0);
}
bool InMempool() const;
bool IsTrusted() const
{
// Quick answer in most cases
if (!IsFinalTx(*this))
return false;
int nDepth = GetDepthInMainChain();
if (nDepth >= 1)
return true;
if (nDepth < 0)
return false;
if (!bSpendZeroConfChange || !IsFromMe(ISMINE_ALL)) // using wtx's cached debit
return false;
// Trusted if all inputs are from us and are in the mempool:
BOOST_FOREACH (const CTxIn& txin, vin) {
// Transactions not sent by us: not trusted
const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash);
if (parent == NULL)
return false;
const CTxOut& parentOut = parent->vout[txin.prevout.n];
if (pwallet->IsMine(parentOut) != ISMINE_SPENDABLE)
return false;
}
return true;
}
bool WriteToDisk();
int64_t GetTxTime() const;
int64_t GetComputedTxTime() const;
int GetRequestCount() const;
void RelayWalletTransaction(std::string strCommand = "tx");
std::set<uint256> GetConflicts() const;
};
class COutput
{
public:
const CWalletTx* tx;
int i;
int nDepth;
bool fSpendable;
COutput(const CWalletTx* txIn, int iIn, int nDepthIn, bool fSpendableIn)
{
tx = txIn;
i = iIn;
nDepth = nDepthIn;
fSpendable = fSpendableIn;
}
//Used with Obfuscation. Will return largest nondenom, then denominations, then very small inputs
int Priority() const
{
BOOST_FOREACH (CAmount d, obfuScationDenominations)
if (tx->vout[i].nValue == d) return 10000;
if (tx->vout[i].nValue < 1 * COIN) return 20000;
//nondenom return largest first
return -(tx->vout[i].nValue / COIN);
}
CAmount Value() const
{
return tx->vout[i].nValue;
}
std::string ToString() const;
};
/** Private key that includes an expiration date in case it never gets used. */
class CWalletKey
{
public:
CPrivKey vchPrivKey;
int64_t nTimeCreated;
int64_t nTimeExpires;
std::string strComment;
//! todo: add something to note what created it (user, getnewaddress, change)
//! maybe should have a map<string, string> property map
CWalletKey(int64_t nExpires = 0);
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
READWRITE(vchPrivKey);
READWRITE(nTimeCreated);
READWRITE(nTimeExpires);
READWRITE(LIMITED_STRING(strComment, 65536));
}
};
/**
* Account information.
* Stored in wallet with key "acc"+string account name.
*/
class CAccount
{
public:
CPubKey vchPubKey;
CAccount()
{
SetNull();
}
void SetNull()
{
vchPubKey = CPubKey();
}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
READWRITE(vchPubKey);
}
};
/**
* Internal transfers.
* Database key is acentry<account><counter>.
*/
class CAccountingEntry
{
public:
std::string strAccount;
CAmount nCreditDebit;
int64_t nTime;
std::string strOtherAccount;
std::string strComment;
mapValue_t mapValue;
int64_t nOrderPos; //! position in ordered transaction list
uint64_t nEntryNo;
CAccountingEntry()
{
SetNull();
}
void SetNull()
{
nCreditDebit = 0;
nTime = 0;
strAccount.clear();
strOtherAccount.clear();
strComment.clear();
nOrderPos = -1;
nEntryNo = 0;
}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
//! Note: strAccount is serialized as part of the key, not here.
READWRITE(nCreditDebit);
READWRITE(nTime);
READWRITE(LIMITED_STRING(strOtherAccount, 65536));
if (!ser_action.ForRead()) {
WriteOrderPos(nOrderPos, mapValue);
if (!(mapValue.empty() && _ssExtra.empty())) {
CDataStream ss(nType, nVersion);
ss.insert(ss.begin(), '\0');
ss << mapValue;
ss.insert(ss.end(), _ssExtra.begin(), _ssExtra.end());
strComment.append(ss.str());
}
}
READWRITE(LIMITED_STRING(strComment, 65536));
size_t nSepPos = strComment.find("\0", 0, 1);
if (ser_action.ForRead()) {
mapValue.clear();
if (std::string::npos != nSepPos) {
CDataStream ss(std::vector<char>(strComment.begin() + nSepPos + 1, strComment.end()), nType, nVersion);
ss >> mapValue;
_ssExtra = std::vector<char>(ss.begin(), ss.end());
}
ReadOrderPos(nOrderPos, mapValue);
}
if (std::string::npos != nSepPos)
strComment.erase(nSepPos);
mapValue.erase("n");
}
private:
std::vector<char> _ssExtra;
};
#endif // BITCOIN_WALLET_H
| [
"nero@gmail.com"
] | nero@gmail.com |
7d9b36c32658381d52945e0516b881b460e98e12 | acf660c0741f972479300d76ff9c35d0f2e07046 | /MultiplyTwoNumbers.cpp | 77bded54e3ae326c911bd59e05cf8aad02e03188 | [] | no_license | Jyoti-prakash-rout/cpp-basic | d379a2d29d35956c7a0fa138e5807fc739a4756a | edc7f05414f14bac132cbb126ec19c49d2970a8f | refs/heads/master | 2023-09-01T23:40:35.765154 | 2021-10-25T15:17:33 | 2021-10-25T15:17:33 | 419,198,819 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 163 | cpp | #include<iostream>
using namespace std;
int main()
{
double num1, num2, product1, product2;
cout<< "Enter two number";
cout<< "Product=" <<product;
return 0;
} | [
"jyotiprakashrout574@gmail.com"
] | jyotiprakashrout574@gmail.com |
f5f8a873b480866b5bc8535219ac61d62c49f884 | d94793f442e4b94d0f65ff81af2eef658c7a1fb9 | /samples/client/petstore/cpp-ue4/Private/OpenAPIUserApiOperations.cpp | 7352577a79ef73aba6f3bd4b066867db7f36e5f8 | [
"Apache-2.0"
] | permissive | elans3/openapi-generator | 34dd9591413650112fb724946253be2b5a24d98b | 51b15be61eca79a3f82dcbc9cbb883a1c8fd5ab8 | refs/heads/master | 2021-06-22T12:08:12.189159 | 2021-05-26T23:11:48 | 2021-05-26T23:11:48 | 135,164,215 | 1 | 1 | Apache-2.0 | 2018-09-05T04:44:34 | 2018-05-28T13:24:21 | HTML | UTF-8 | C++ | false | false | 12,931 | cpp | /**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* https://github.com/OpenAPITools/openapi-generator
* Do not edit the class manually.
*/
#include "OpenAPIUserApiOperations.h"
#include "OpenAPIModule.h"
#include "OpenAPIHelpers.h"
#include "Dom/JsonObject.h"
#include "Templates/SharedPointer.h"
#include "HttpModule.h"
#include "PlatformHttp.h"
namespace OpenAPI
{
FString OpenAPIUserApi::CreateUserRequest::ComputePath() const
{
FString Path(TEXT("/user"));
return Path;
}
void OpenAPIUserApi::CreateUserRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray<FString> Consumes = { };
//static const TArray<FString> Produces = { };
HttpRequest->SetVerb(TEXT("POST"));
// Default to Json Body request
if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json")))
{
// Body parameters
FString JsonBody;
JsonWriter Writer = TJsonWriterFactory<>::Create(&JsonBody);
WriteJsonValue(Writer, Body);
Writer->Close();
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json; charset=utf-8"));
HttpRequest->SetContentAsString(JsonBody);
}
else if (Consumes.Contains(TEXT("multipart/form-data")))
{
UE_LOG(LogOpenAPI, Error, TEXT("Body parameter (body) was ignored, not supported in multipart form"));
}
else if (Consumes.Contains(TEXT("application/x-www-form-urlencoded")))
{
UE_LOG(LogOpenAPI, Error, TEXT("Body parameter (body) was ignored, not supported in urlencoded requests"));
}
else
{
UE_LOG(LogOpenAPI, Error, TEXT("Request ContentType not supported (%s)"), *FString::Join(Consumes, TEXT(",")));
}
}
void OpenAPIUserApi::CreateUserResponse::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
Response::SetHttpResponseCode(InHttpResponseCode);
switch ((int)InHttpResponseCode)
{
case 0:
default:
SetResponseString(TEXT("successful operation"));
break;
}
}
bool OpenAPIUserApi::CreateUserResponse::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
return true;
}
FString OpenAPIUserApi::CreateUsersWithArrayInputRequest::ComputePath() const
{
FString Path(TEXT("/user/createWithArray"));
return Path;
}
void OpenAPIUserApi::CreateUsersWithArrayInputRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray<FString> Consumes = { };
//static const TArray<FString> Produces = { };
HttpRequest->SetVerb(TEXT("POST"));
// Default to Json Body request
if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json")))
{
// Body parameters
FString JsonBody;
JsonWriter Writer = TJsonWriterFactory<>::Create(&JsonBody);
WriteJsonValue(Writer, Body);
Writer->Close();
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json; charset=utf-8"));
HttpRequest->SetContentAsString(JsonBody);
}
else if (Consumes.Contains(TEXT("multipart/form-data")))
{
UE_LOG(LogOpenAPI, Error, TEXT("Body parameter (body) was ignored, not supported in multipart form"));
}
else if (Consumes.Contains(TEXT("application/x-www-form-urlencoded")))
{
UE_LOG(LogOpenAPI, Error, TEXT("Body parameter (body) was ignored, not supported in urlencoded requests"));
}
else
{
UE_LOG(LogOpenAPI, Error, TEXT("Request ContentType not supported (%s)"), *FString::Join(Consumes, TEXT(",")));
}
}
void OpenAPIUserApi::CreateUsersWithArrayInputResponse::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
Response::SetHttpResponseCode(InHttpResponseCode);
switch ((int)InHttpResponseCode)
{
case 0:
default:
SetResponseString(TEXT("successful operation"));
break;
}
}
bool OpenAPIUserApi::CreateUsersWithArrayInputResponse::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
return true;
}
FString OpenAPIUserApi::CreateUsersWithListInputRequest::ComputePath() const
{
FString Path(TEXT("/user/createWithList"));
return Path;
}
void OpenAPIUserApi::CreateUsersWithListInputRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray<FString> Consumes = { };
//static const TArray<FString> Produces = { };
HttpRequest->SetVerb(TEXT("POST"));
// Default to Json Body request
if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json")))
{
// Body parameters
FString JsonBody;
JsonWriter Writer = TJsonWriterFactory<>::Create(&JsonBody);
WriteJsonValue(Writer, Body);
Writer->Close();
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json; charset=utf-8"));
HttpRequest->SetContentAsString(JsonBody);
}
else if (Consumes.Contains(TEXT("multipart/form-data")))
{
UE_LOG(LogOpenAPI, Error, TEXT("Body parameter (body) was ignored, not supported in multipart form"));
}
else if (Consumes.Contains(TEXT("application/x-www-form-urlencoded")))
{
UE_LOG(LogOpenAPI, Error, TEXT("Body parameter (body) was ignored, not supported in urlencoded requests"));
}
else
{
UE_LOG(LogOpenAPI, Error, TEXT("Request ContentType not supported (%s)"), *FString::Join(Consumes, TEXT(",")));
}
}
void OpenAPIUserApi::CreateUsersWithListInputResponse::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
Response::SetHttpResponseCode(InHttpResponseCode);
switch ((int)InHttpResponseCode)
{
case 0:
default:
SetResponseString(TEXT("successful operation"));
break;
}
}
bool OpenAPIUserApi::CreateUsersWithListInputResponse::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
return true;
}
FString OpenAPIUserApi::DeleteUserRequest::ComputePath() const
{
TMap<FString, FStringFormatArg> PathParams = {
{ TEXT("username"), ToStringFormatArg(Username) } };
FString Path = FString::Format(TEXT("/user/{username}"), PathParams);
return Path;
}
void OpenAPIUserApi::DeleteUserRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray<FString> Consumes = { };
//static const TArray<FString> Produces = { };
HttpRequest->SetVerb(TEXT("DELETE"));
// Default to Json Body request
if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json")))
{
}
else if (Consumes.Contains(TEXT("multipart/form-data")))
{
}
else if (Consumes.Contains(TEXT("application/x-www-form-urlencoded")))
{
}
else
{
UE_LOG(LogOpenAPI, Error, TEXT("Request ContentType not supported (%s)"), *FString::Join(Consumes, TEXT(",")));
}
}
void OpenAPIUserApi::DeleteUserResponse::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
Response::SetHttpResponseCode(InHttpResponseCode);
switch ((int)InHttpResponseCode)
{
case 400:
SetResponseString(TEXT("Invalid username supplied"));
break;
case 404:
SetResponseString(TEXT("User not found"));
break;
}
}
bool OpenAPIUserApi::DeleteUserResponse::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
return true;
}
FString OpenAPIUserApi::GetUserByNameRequest::ComputePath() const
{
TMap<FString, FStringFormatArg> PathParams = {
{ TEXT("username"), ToStringFormatArg(Username) } };
FString Path = FString::Format(TEXT("/user/{username}"), PathParams);
return Path;
}
void OpenAPIUserApi::GetUserByNameRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray<FString> Consumes = { };
//static const TArray<FString> Produces = { TEXT("application/xml"), TEXT("application/json") };
HttpRequest->SetVerb(TEXT("GET"));
// Default to Json Body request
if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json")))
{
}
else if (Consumes.Contains(TEXT("multipart/form-data")))
{
}
else if (Consumes.Contains(TEXT("application/x-www-form-urlencoded")))
{
}
else
{
UE_LOG(LogOpenAPI, Error, TEXT("Request ContentType not supported (%s)"), *FString::Join(Consumes, TEXT(",")));
}
}
void OpenAPIUserApi::GetUserByNameResponse::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
Response::SetHttpResponseCode(InHttpResponseCode);
switch ((int)InHttpResponseCode)
{
case 200:
SetResponseString(TEXT("successful operation"));
break;
case 400:
SetResponseString(TEXT("Invalid username supplied"));
break;
case 404:
SetResponseString(TEXT("User not found"));
break;
}
}
bool OpenAPIUserApi::GetUserByNameResponse::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
return TryGetJsonValue(JsonValue, Content);
}
FString OpenAPIUserApi::LoginUserRequest::ComputePath() const
{
FString Path(TEXT("/user/login"));
TArray<FString> QueryParams;
QueryParams.Add(FString(TEXT("username=")) + ToUrlString(Username));
QueryParams.Add(FString(TEXT("password=")) + ToUrlString(Password));
Path += TCHAR('?');
Path += FString::Join(QueryParams, TEXT("&"));
return Path;
}
void OpenAPIUserApi::LoginUserRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray<FString> Consumes = { };
//static const TArray<FString> Produces = { TEXT("application/xml"), TEXT("application/json") };
HttpRequest->SetVerb(TEXT("GET"));
// Default to Json Body request
if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json")))
{
}
else if (Consumes.Contains(TEXT("multipart/form-data")))
{
}
else if (Consumes.Contains(TEXT("application/x-www-form-urlencoded")))
{
}
else
{
UE_LOG(LogOpenAPI, Error, TEXT("Request ContentType not supported (%s)"), *FString::Join(Consumes, TEXT(",")));
}
}
void OpenAPIUserApi::LoginUserResponse::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
Response::SetHttpResponseCode(InHttpResponseCode);
switch ((int)InHttpResponseCode)
{
case 200:
SetResponseString(TEXT("successful operation"));
break;
case 400:
SetResponseString(TEXT("Invalid username/password supplied"));
break;
}
}
bool OpenAPIUserApi::LoginUserResponse::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
return TryGetJsonValue(JsonValue, Content);
}
FString OpenAPIUserApi::LogoutUserRequest::ComputePath() const
{
FString Path(TEXT("/user/logout"));
return Path;
}
void OpenAPIUserApi::LogoutUserRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray<FString> Consumes = { };
//static const TArray<FString> Produces = { };
HttpRequest->SetVerb(TEXT("GET"));
// Default to Json Body request
if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json")))
{
}
else if (Consumes.Contains(TEXT("multipart/form-data")))
{
}
else if (Consumes.Contains(TEXT("application/x-www-form-urlencoded")))
{
}
else
{
UE_LOG(LogOpenAPI, Error, TEXT("Request ContentType not supported (%s)"), *FString::Join(Consumes, TEXT(",")));
}
}
void OpenAPIUserApi::LogoutUserResponse::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
Response::SetHttpResponseCode(InHttpResponseCode);
switch ((int)InHttpResponseCode)
{
case 0:
default:
SetResponseString(TEXT("successful operation"));
break;
}
}
bool OpenAPIUserApi::LogoutUserResponse::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
return true;
}
FString OpenAPIUserApi::UpdateUserRequest::ComputePath() const
{
TMap<FString, FStringFormatArg> PathParams = {
{ TEXT("username"), ToStringFormatArg(Username) } };
FString Path = FString::Format(TEXT("/user/{username}"), PathParams);
return Path;
}
void OpenAPIUserApi::UpdateUserRequest::SetupHttpRequest(const FHttpRequestRef& HttpRequest) const
{
static const TArray<FString> Consumes = { };
//static const TArray<FString> Produces = { };
HttpRequest->SetVerb(TEXT("PUT"));
// Default to Json Body request
if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json")))
{
// Body parameters
FString JsonBody;
JsonWriter Writer = TJsonWriterFactory<>::Create(&JsonBody);
WriteJsonValue(Writer, Body);
Writer->Close();
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json; charset=utf-8"));
HttpRequest->SetContentAsString(JsonBody);
}
else if (Consumes.Contains(TEXT("multipart/form-data")))
{
UE_LOG(LogOpenAPI, Error, TEXT("Body parameter (body) was ignored, not supported in multipart form"));
}
else if (Consumes.Contains(TEXT("application/x-www-form-urlencoded")))
{
UE_LOG(LogOpenAPI, Error, TEXT("Body parameter (body) was ignored, not supported in urlencoded requests"));
}
else
{
UE_LOG(LogOpenAPI, Error, TEXT("Request ContentType not supported (%s)"), *FString::Join(Consumes, TEXT(",")));
}
}
void OpenAPIUserApi::UpdateUserResponse::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
Response::SetHttpResponseCode(InHttpResponseCode);
switch ((int)InHttpResponseCode)
{
case 400:
SetResponseString(TEXT("Invalid user supplied"));
break;
case 404:
SetResponseString(TEXT("User not found"));
break;
}
}
bool OpenAPIUserApi::UpdateUserResponse::FromJson(const TSharedPtr<FJsonValue>& JsonValue)
{
return true;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
9f68bed0f4f83b3a878ad62c695b49a4ab001914 | a85a1e6c776e0433c30aa5830aa353a82f4c8833 | /coregame_interface/client_clustermap.cpp | 71b968c67caf0f8900c26b676b5a18161922baa6 | [] | no_license | IceCube-22/darkreign2 | fe97ccb194b9eacf849d97b2657e7bd1c52d2916 | 9ce9da5f21604310a997f0c41e9cd383f5e292c3 | refs/heads/master | 2023-03-20T02:27:03.321950 | 2018-10-04T10:06:38 | 2018-10-04T10:06:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,412 | cpp | ///////////////////////////////////////////////////////////////////////////////
//
// Copyright 1997-1999 Pandemic Studios, Dark Reign II
//
// Client Cluster Maps
//
// 19-AUG-1998
//
///////////////////////////////////////////////////////////////////////////////
//
// Includes
//
#include "client_clustermap.h"
#include "varsys.h"
#include "console.h"
#include "regionobj.h"
#include "team.h"
#include "armourclass.h"
#include "iface.h"
///////////////////////////////////////////////////////////////////////////////
//
// Definitions
//
#define CLUSTERMAP_MAXSIZE 150
#define CLUSTERMAP_DEFAULT_REFRESH 1000
#define CLUSTERMAP_THREAT_ALL 0xFFFFFFFF
#define CLUSTERMAP_DEFENSE_ALL 0xFFFFFFFF
#define CLUSTERMAP_PAIN_ALL 0xFFFFFFFF
///////////////////////////////////////////////////////////////////////////////
//
// NameSpace Client
//
namespace Client
{
///////////////////////////////////////////////////////////////////////////////
//
// Class ClientClusterMap
//
///////////////////////////////////////////////////////////////////////////////
//
// Internal Data
//
BinTree<ClusterMap::Map> ClusterMap::maps;
//
// CallbackResource
//
Color ClusterMap::CallbackResource(void *, U32 x, U32 y)
{
MapCluster *cluster = WorldCtrl::GetCluster(x, y);
U32 value = cluster->ai.GetResource();
if (value)
{
F64 fvalue = 11.090354889 * log((F64) value);
if (fvalue < 256)
{
return (Color(0, (U32) fvalue, 0));
}
else
{
fvalue -= 256;
return (Color((U32) fvalue, 255, (U32) fvalue));
}
}
else
{
return (Color(0.0f, 0.0f, 0.0f));
}
}
//
// CallbackOccupation
//
Color ClusterMap::CallbackOccupation(void *context, U32 x, U32 y)
{
Occupation *occupation = (Occupation *) context;
MapCluster *cluster = WorldCtrl::GetCluster(x, y);
U32 value;
ASSERT(occupation)
ASSERT(cluster)
value = cluster->ai.GetOccupation(occupation->team);
if (value)
{
F32 fval = F32(value) * AI::Map::GetOccupationInv(occupation->team);
// Move onto a quadratic curve
fval = 1.0f - (1.0f - fval) * (1.0f - fval);
return (Color(fval * 0.5f, fval, fval * 0.5f));
}
else
{
return (Color(0.0f, 0.0f, 0.0f));
}
}
//
// CallbackDisruption
//
Color ClusterMap::CallbackDisruption(void *, U32 x, U32 y)
{
MapCluster *cluster = WorldCtrl::GetCluster(x, y);
U32 value;
ASSERT(cluster)
value = cluster->ai.GetDisruption();
if (value)
{
F32 fval = F32(value) * AI::Map::GetDisruptionInv();
fval *= 0.7f;
fval += 0.3f;
fval = 1.0f - (1.0f - fval) * (1.0f - fval);
return (Color(0.0f, fval * 0.5f, fval));
}
else
{
return (Color(0.0f, 0.0f, 0.0f));
}
}
//
// CallbackThreat
//
Color ClusterMap::CallbackThreat(void *context, U32 x, U32 y)
{
Threat *threat = (Threat *) context;
MapCluster *cluster = WorldCtrl::GetCluster(x, y);
U32 value;
ASSERT(threat)
ASSERT(cluster)
if (threat->armourClass == CLUSTERMAP_THREAT_ALL)
{
value = AI::Map::GetTotalThreat(threat->team) ? cluster->ai.GetTotalThreat(threat->team) : 0;
}
else
{
value = AI::Map::GetThreat(threat->team, threat->armourClass) ? cluster->ai.GetThreat(threat->team, threat->armourClass) : 0;
}
if (value)
{
F64 fvalue = 16.6355323334 * log((F64) value);
if (fvalue < 256)
{
return (Color((U32) fvalue, 0, 0));
}
else if (fvalue < 512)
{
return (Color(255, (U32) (fvalue - 256), 0));
}
else
{
return (Color(255, 255, (U32) (fvalue - 512)));
}
}
else
{
return (Color(0.0f, 0.0f, 0.0f));
}
}
//
// CallBackDefense
//
Color ClusterMap::CallbackDefense(void *context, U32 x, U32 y)
{
Defense *defense = (Defense *) context;
MapCluster *cluster = WorldCtrl::GetCluster(x, y);
U32 value;
ASSERT(defense)
ASSERT(cluster)
if (defense->damageId == CLUSTERMAP_DEFENSE_ALL)
{
value = AI::Map::GetTotalDefense(defense->team) ?
cluster->ai.GetTotalDefense(defense->team) * 768 / AI::Map::GetTotalDefense(defense->team) : 0;
}
else
{
value = AI::Map::GetDefense(defense->team, defense->damageId) ?
cluster->ai.GetDefense(defense->team, defense->damageId) * 768 / AI::Map::GetDefense(defense->team, defense->damageId) : 0;
}
if (value < 256)
{
return (Color(0, 0, value));
}
else if (value < 512)
{
return (Color(0, value, 255));
}
else
{
return (Color(value, 255, 255));
}
}
//
// CallbackPain
//
Color ClusterMap::CallbackPain(void *context, U32 x, U32 y)
{
Pain *pain = (Pain *) context;
MapCluster *cluster = WorldCtrl::GetCluster(x, y);
U32 value;
ASSERT(pain)
ASSERT(cluster)
if (pain->armourClass == CLUSTERMAP_PAIN_ALL)
{
value = AI::Map::GetTotalPain(pain->team) ? cluster->ai.GetTotalPain(pain->team) : 0;
}
else
{
value = AI::Map::GetPain(pain->team, pain->armourClass) ? cluster->ai.GetPain(pain->team, pain->armourClass) : 0;
}
if (value)
{
F64 fvalue = 16.6355323334 * log((F64) value);
if (fvalue < 256)
{
return (Color(0, (U32) fvalue, 0));
}
else if (fvalue < 512)
{
return (Color(0, 255, (U32) (fvalue - 256)));
}
else
{
return (Color((U32) (fvalue - 512), 255, 255));
}
}
else
{
return (Color(0.0f, 0.0f, 0.0f));
}
}
//
// CallBackRegion
//
Color ClusterMap::CallbackRegion(void *context, U32 x, U32 y)
{
Region *region = (Region *) context;
MapCluster *cluster = WorldCtrl::GetCluster(x, y);
ASSERT(region)
ASSERT(cluster)
/*
// If this cluster is in the list of clusters for the region then make it yellow
if (region->region->clusters.InList(cluster))
{
return (Color(255, 255, 0));
}
// Otherwise make it black
else */
{
return (Color(U32(0), U32(0), U32(0)));
}
}
//
// CreateCommads
//
void ClusterMap::CreateCommands()
{
// Register command handlers
VarSys::RegisterHandler("client.clustermap", CmdHandler);
VarSys::RegisterHandler("client.clustermap.ai", CmdHandler);
#ifdef DEVELOPMENT
// ClusterMap Commands
VarSys::CreateCmd("client.clustermap.create");
// AI ClusterMap Commands
VarSys::CreateCmd("client.clustermap.ai.addthreat");
VarSys::CreateCmd("client.clustermap.ai.removethreat");
VarSys::CreateCmd("client.clustermap.ai.adddefense");
VarSys::CreateCmd("client.clustermap.ai.removedefense");
#endif
}
//
// DeleteCommands
//
void ClusterMap::DeleteCommands()
{
// Delete the clustermap scope
VarSys::DeleteItem("client.clustermap");
}
//
// CmdHandler
//
void ClusterMap::CmdHandler(U32 pathCrc)
{
switch (pathCrc)
{
case 0xBCBF9D4F: // "client.clustermap.create"
{
char *type;
if (!Console::GetArgString(1, (const char *&)type))
{
CON_ERR(("client.clustermap.create type [params]"))
}
else
{
switch (Crc::CalcStr(type))
{
case 0x4CD1BE27: // "resource"
{
// Create the cluster map
U32 width = WorldCtrl::ClusterMapX();
U32 height = WorldCtrl::ClusterMapZ();
// Determine the scale
U32 scale = Min(CLUSTERMAP_MAXSIZE / width, CLUSTERMAP_MAXSIZE / height);
// Create the grid control
ICGridWindow *grid = new ICGridWindow
(
"Resources", WorldCtrl::ClusterMapX(), WorldCtrl::ClusterMapZ(), scale, scale
);
// Set grid callback and context
ICGrid &g = grid->Grid();
g.SetCellCallBack(CallbackResource);
g.SetPollInterval(5000);
g.SetAxisFlip(FALSE, TRUE);
IFace::ToggleActive(grid->Name());
maps.Add(Crc::CalcStr("Resources"), new Map(grid, NULL));
break;
}
case 0x6B45E01B: // "occupation"
{
char *teamName;
// Test params
if (!Console::GetArgString(2, (const char *&)teamName))
{
CON_ERR(("client.clustermap.create 'occupation' team"))
break;
}
// Convert team name into a team
Team *team = Team::Name2Team(teamName);
if (!team)
{
CON_ERR(("Unknown team '%s'", teamName))
break;
}
// Create the cluster map
char name[256];
Utils::Sprintf(name, 256, "Occupation [%s]", teamName);
// Create the occupation
void *context = new Occupation(team->GetId());
U32 width = WorldCtrl::ClusterMapX();
U32 height = WorldCtrl::ClusterMapZ();
// Determine the scale
U32 scale = Min(CLUSTERMAP_MAXSIZE / width, CLUSTERMAP_MAXSIZE / height);
// Create the grid control
ICGridWindow *grid = new ICGridWindow
(
name, WorldCtrl::ClusterMapX(), WorldCtrl::ClusterMapZ(), scale, scale
);
// Set grid callback and context
ICGrid &g = grid->Grid();
g.SetCellCallBack(CallbackOccupation);
g.SetContext(context);
g.SetPollInterval(5000);
g.SetAxisFlip(FALSE, TRUE);
IFace::ToggleActive(grid->Name());
maps.Add(Crc::CalcStr(name), new Map(grid, context));
break;
}
case 0x6FDCD1BD: // "disruption"
{
// Create the cluster map
char name[256];
Utils::Sprintf(name, 256, "Disruption");
U32 width = WorldCtrl::ClusterMapX();
U32 height = WorldCtrl::ClusterMapZ();
// Determine the scale
U32 scale = Min(CLUSTERMAP_MAXSIZE / width, CLUSTERMAP_MAXSIZE / height);
// Create the grid control
ICGridWindow *grid = new ICGridWindow
(
name, WorldCtrl::ClusterMapX(), WorldCtrl::ClusterMapZ(), scale, scale
);
// Set grid callback and context
ICGrid &g = grid->Grid();
g.SetCellCallBack(CallbackDisruption);
g.SetContext(NULL);
g.SetPollInterval(5000);
g.SetAxisFlip(FALSE, TRUE);
IFace::ToggleActive(grid->Name());
maps.Add(Crc::CalcStr(name), new Map(grid, NULL));
break;
}
case 0x98D9AF2E: // "threat"
{
char *teamName;
char *armourClassName;
// Test params
if (!Console::GetArgString(2, (const char *&)teamName) || !Console::GetArgString(3, (const char *&)armourClassName))
{
CON_ERR(("client.clustermap.create 'threat' team *|armourclass"))
break;
}
// Convert team name into a team
Team *team = Team::Name2Team(teamName);
if (!team)
{
CON_ERR(("Unknown team '%s'", teamName))
break;
}
// Convert armour class name into an armour class
U32 armourClass;
if (!Utils::Strcmp(armourClassName, "*"))
{
armourClass = CLUSTERMAP_THREAT_ALL;
}
else if (ArmourClass::ArmourClassExists(armourClassName))
{
armourClass = ArmourClass::Name2ArmourClassId(armourClassName);
}
else
{
CON_ERR(("Unknown armour class '%s'", armourClassName))
break;
}
// Create the cluster map
char name[256];
Utils::Sprintf(name, 256, "Threat [%s] [%s]", teamName, armourClassName);
U32 width = WorldCtrl::ClusterMapX();
U32 height = WorldCtrl::ClusterMapZ();
// Determine the scale
U32 scale = Min(CLUSTERMAP_MAXSIZE / width, CLUSTERMAP_MAXSIZE / height);
// Create the threat
void *context = new Threat(team->GetId(), armourClass);
// Create the grid control
ICGridWindow *grid = new ICGridWindow
(
name, WorldCtrl::ClusterMapX(), WorldCtrl::ClusterMapZ(), scale, scale
);
// Set grid callback and context
ICGrid &g = grid->Grid();
g.SetCellCallBack(CallbackThreat);
g.SetContext(context);
g.SetPollInterval(5000);
g.SetAxisFlip(FALSE, TRUE);
IFace::ToggleActive(grid->Name());
maps.Add(Crc::CalcStr(name), new Map(grid, context));
break;
}
case 0x07B0615D: // "defense"
{
char *teamName;
char *damageName;
// Test params
if (!Console::GetArgString(2, (const char *&)teamName) || !Console::GetArgString(3, (const char *&)damageName))
{
CON_ERR(("client.clustermap.create 'defense' team *|damage"))
break;
}
// Convert team name into a team
Team *team = Team::Name2Team(teamName);
if (!team)
{
CON_ERR(("Unknown team '%s'", teamName))
break;
}
// Convert damage name into a damage id
U32 damageId;
if (!Utils::Strcmp(damageName, "*"))
{
damageId = CLUSTERMAP_DEFENSE_ALL;
}
else if (ArmourClass::DamageExists(damageName))
{
damageId = ArmourClass::Name2DamageId(damageName);
}
else
{
CON_ERR(("Unknown damage '%s'", damageName))
break;
}
// Create the cluster map
char name[256];
Utils::Sprintf(name, 256, "Defense [%s] [%s]", teamName, damageName);
U32 width = WorldCtrl::ClusterMapX();
U32 height = WorldCtrl::ClusterMapZ();
// Determine the scale
U32 scale = Min(CLUSTERMAP_MAXSIZE / width, CLUSTERMAP_MAXSIZE / height);
void *context = new Defense(team->GetId(), damageId);
// Create the grid control
ICGridWindow *grid = new ICGridWindow
(
name, WorldCtrl::ClusterMapX(), WorldCtrl::ClusterMapZ(), scale, scale
);
// Set the callback and context
ICGrid &g = grid->Grid();
g.SetCellCallBack(CallbackDefense);
g.SetContext(context);
g.SetPollInterval(5000);
g.SetAxisFlip(FALSE, TRUE);
IFace::ToggleActive(grid->Name());
maps.Add(Crc::CalcStr(name), new Map(grid, context));
break;
}
case 0x116C7A5D: // "pain"
{
char *teamName;
char *armourClassName;
// Test params
if (!Console::GetArgString(2, (const char *&)teamName) || !Console::GetArgString(3, (const char *&)armourClassName))
{
CON_ERR(("client.clustermap.create 'pain' team *|armourclass"))
break;
}
// Convert team name into a team
Team *team = Team::Name2Team(teamName);
if (!team)
{
CON_ERR(("Unknown team '%s'", teamName))
break;
}
// Convert armour class name into an armour class
U32 armourClass;
if (!Utils::Strcmp(armourClassName, "*"))
{
armourClass = CLUSTERMAP_PAIN_ALL;
}
else if (ArmourClass::ArmourClassExists(armourClassName))
{
armourClass = ArmourClass::Name2ArmourClassId(armourClassName);
}
else
{
CON_ERR(("Unknown armour class '%s'", armourClassName))
break;
}
// Create the cluster map
char name[256];
Utils::Sprintf(name, 256, "Pain [%s] [%s]", teamName, armourClassName);
U32 width = WorldCtrl::ClusterMapX();
U32 height = WorldCtrl::ClusterMapZ();
// Determine the scale
U32 scale = Min(CLUSTERMAP_MAXSIZE / width, CLUSTERMAP_MAXSIZE / height);
// Create the pain
void *context = new Pain(team->GetId(), armourClass);
// Create the grid control
ICGridWindow *grid = new ICGridWindow
(
name, WorldCtrl::ClusterMapX(), WorldCtrl::ClusterMapZ(), scale, scale
);
// Set grid callback and context
ICGrid &g = grid->Grid();
g.SetCellCallBack(CallbackPain);
g.SetContext(context);
g.SetPollInterval(5000);
g.SetAxisFlip(FALSE, TRUE);
IFace::ToggleActive(grid->Name());
maps.Add(Crc::CalcStr(name), new Map(grid, context));
break;
}
case 0xB817BF51: // "region"
{
char *regionName;
// Test params
if (!Console::GetArgString(2, (const char *&)regionName))
{
CON_ERR(("client.clustermap.create 'region' region"))
break;
}
// Find the region
RegionObj *region = RegionObj::FindRegion(regionName);
if (!region)
{
CON_ERR(("Unknown region '%s'", regionName))
break;
}
// Create the cluster map
char name[256];
Utils::Sprintf(name, 256, "Region [%s]", regionName);
U32 width = WorldCtrl::ClusterMapX();
U32 height = WorldCtrl::ClusterMapZ();
// Determine the scale
U32 scale = Min(CLUSTERMAP_MAXSIZE / width, CLUSTERMAP_MAXSIZE / height);
void *context = new Region(region);
// Create the grid control
ICGridWindow *grid = new ICGridWindow
(
name, WorldCtrl::ClusterMapX(), WorldCtrl::ClusterMapZ(), scale, scale
);
// Set the callback and context
ICGrid &g = grid->Grid();
g.SetCellCallBack(CallbackRegion);
g.SetContext(context);
IFace::ToggleActive(grid->Name());
maps.Add(Crc::CalcStr(name), new Map(grid, context));
break;
}
default:
CON_ERR(("Unknown clustermap type '%s'", type))
break;
}
}
break;
}
case 0xA8B5E6F4: // "client.clustermap.ai.addthreat"
{
U32 x, z, amount;
char *teamName;
char *armourClassName;
if (!Console::GetArgInteger(1, (S32 &) x) ||
!Console::GetArgInteger(2, (S32 &) z) ||
!Console::GetArgString(3, (const char *&)teamName) ||
!Console::GetArgString(4, (const char *&)armourClassName) ||
!Console::GetArgInteger(5, (S32 &) amount))
{
CON_ERR(("client.clustermap.ai.addthreat x z team armourclass amount"))
}
else
{
if (x >= WorldCtrl::ClusterMapX())
{
CON_ERR(("x value is out of range [0..%d]", WorldCtrl::ClusterMapX() - 1))
break;
}
if (z >= WorldCtrl::ClusterMapZ())
{
CON_ERR(("z value is out of range [0..%d]", WorldCtrl::ClusterMapZ() - 1))
break;
}
// Convert team name into a team
Team *team = Team::Name2Team(teamName);
if (!team)
{
CON_ERR(("Unknown team '%s'", teamName))
break;
}
// Test Armour Class
U32 armourClass;
if (ArmourClass::ArmourClassExists(armourClassName))
{
armourClass = ArmourClass::Name2ArmourClassId(armourClassName);
}
else
{
CON_ERR(("Unknown armour class '%s'", armourClassName))
break;
}
MapCluster *cluster = WorldCtrl::GetCluster(x, z);
ASSERT(cluster)
cluster->ai.AddThreat(team->GetId(), armourClass, amount);
}
break;
}
case 0xC692B49A: // "client.clustermap.ai.removethreat"
{
U32 x, z, amount;
char *teamName;
char *armourClassName;
if (!Console::GetArgInteger(1, (S32 &) x) ||
!Console::GetArgInteger(2, (S32 &) z) ||
!Console::GetArgString(3, (const char *&)teamName) ||
!Console::GetArgString(4, (const char *&)armourClassName) ||
!Console::GetArgInteger(5, (S32 &) amount))
{
CON_ERR(("client.clustermap.ai.addremove x z team armourclass amount"))
}
else
{
if (x >= WorldCtrl::ClusterMapX())
{
CON_ERR(("x value is out of range [0..%d]", WorldCtrl::ClusterMapX() - 1))
break;
}
if (z >= WorldCtrl::ClusterMapZ())
{
CON_ERR(("z value is out of range [0..%d]", WorldCtrl::ClusterMapZ() - 1))
break;
}
// Convert team name into a team
Team *team = Team::Name2Team(teamName);
if (!team)
{
CON_ERR(("Unknown team '%s'", teamName))
break;
}
// Test Armour Class
U32 armourClass;
if (ArmourClass::ArmourClassExists(armourClassName))
{
armourClass = ArmourClass::Name2ArmourClassId(armourClassName);
}
else
{
CON_ERR(("Unknown armour class '%s'", armourClassName))
break;
}
MapCluster *cluster = WorldCtrl::GetCluster(x, z);
ASSERT(cluster)
cluster->ai.RemoveThreat(team->GetId(), armourClass, amount);
}
break;
}
case 0xBFCBD6CD: // "client.clustermap.ai.adddefense"
{
U32 x, z, amount;
char *teamName;
char *damageName;
if (!Console::GetArgInteger(1, (S32 &) x) ||
!Console::GetArgInteger(2, (S32 &) z) ||
!Console::GetArgString(3, (const char *&)teamName) ||
!Console::GetArgString(4, (const char *&)damageName) ||
!Console::GetArgInteger(5, (S32 &) amount))
{
CON_ERR(("client.clustermap.ai.adddefense x z team damage amount"))
}
else
{
if (x >= WorldCtrl::ClusterMapX())
{
CON_ERR(("x value is out of range [0..%d]", WorldCtrl::ClusterMapX() - 1))
break;
}
if (z >= WorldCtrl::ClusterMapZ())
{
CON_ERR(("z value is out of range [0..%d]", WorldCtrl::ClusterMapZ() - 1))
break;
}
// Convert team name into a team
Team *team = Team::Name2Team(teamName);
if (!team)
{
CON_ERR(("Unknown team '%s'", teamName))
break;
}
// Test Armour Class
U32 damageId;
if (ArmourClass::DamageExists(damageName))
{
damageId = ArmourClass::Name2DamageId(damageName);
}
else
{
CON_ERR(("Unknown damage '%s'", damageName))
break;
}
MapCluster *cluster = WorldCtrl::GetCluster(x, z);
ASSERT(cluster)
cluster->ai.AddDefense(team->GetId(), damageId, amount);
}
break;
}
case 0x1D5FE45D: // "cliiet.clustermap.ai.removedefense"
{
U32 x, z, amount;
char *teamName;
char *damageName;
if (!Console::GetArgInteger(1, (S32 &) x) ||
!Console::GetArgInteger(2, (S32 &) z) ||
!Console::GetArgString(3, (const char *&)teamName) ||
!Console::GetArgString(4, (const char *&)damageName) ||
!Console::GetArgInteger(5, (S32 &) amount))
{
CON_ERR(("client.clustermap.ai.removedefense x z team damage amount"))
}
else
{
if (x >= WorldCtrl::ClusterMapX())
{
CON_ERR(("x value is out of range [0..%d]", WorldCtrl::ClusterMapX() - 1))
break;
}
if (z >= WorldCtrl::ClusterMapZ())
{
CON_ERR(("z value is out of range [0..%d]", WorldCtrl::ClusterMapZ() - 1))
break;
}
// Convert team name into a team
Team *team = Team::Name2Team(teamName);
if (!team)
{
CON_ERR(("Unknown team '%s'", teamName))
break;
}
// Test Armour Class
U32 damageId;
if (ArmourClass::DamageExists(damageName))
{
damageId = ArmourClass::Name2DamageId(damageName);
}
else
{
CON_ERR(("Unknown damage '%s'", damageName))
break;
}
MapCluster *cluster = WorldCtrl::GetCluster(x, z);
ASSERT(cluster)
cluster->ai.RemoveDefense(team->GetId(), damageId, amount);
}
break;
}
}
};
//
// DeleteMaps
//
void ClusterMap::DeleteMaps()
{
maps.DisposeAll();
}
}
| [
"eider@protonmail.com"
] | eider@protonmail.com |
9ab126e48fe409b43a5dbcff791a17ffa244e403 | d990c3156cb331faa05778b3cbbd53764041a837 | /Niguiri on Attack/Jogo.cpp | 39f934282994fbf437bac5e166c4011937640443 | [] | no_license | edu060/TabalhoSuperGemeosGB | 2788b1b5af3aa41731b189de7097cf55632296ac | 38cd23432c5db7fb67e07cb3a54bea185aca009f | refs/heads/master | 2020-04-10T04:19:49.199823 | 2018-12-07T08:40:10 | 2018-12-07T08:40:10 | 160,795,199 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 841 | cpp | #include "Jogo.h"
Jogo::Jogo()
{
}
Jogo::~Jogo()
{
}
void Jogo::inicializar()
{
uniInicializar(800, 600, false);
//Inicializando o Carregador de Assets
this->mapa_assets.open("..\\mapa_assets.txt", ios::in);
if (!mapa_assets) {
gDebug.erro("não abriu o arquivo", this);
}
CarregadorDeAssets * cda_carregador_assets = new CarregadorDeAssets;
if (!cda_carregador_assets->CarregarAssets(mapa_assets)) {
gDebug.erro("Falha no carregamento de recursos");
}
menu->inicializar();
}
void Jogo::finalizar()
{
// O resto da finalização vem aqui (provavelmente, em ordem inversa a inicialização)!
// ...
uniFinalizar();
}
void Jogo::executar()
{
while(!gTeclado.soltou[TECLA_ESC] && !gEventos.sair)
{
uniIniciarFrame();
// Seu código vem aqui!
// ...
menu->atualizarMenus();
uniTerminarFrame();
}
} | [
"noreply@github.com"
] | noreply@github.com |
e3daf618aff2d7dabb28dde8458bbeb8b093867f | 541714826fd5e51abfd12ae18eacb6e50fbf0809 | /Source/TensorflowJs/Private/TensorflowJs.cpp | 9fed9d2a27962a3eb301b160487bc1d7e2b1e5b6 | [
"MIT"
] | permissive | ahsanMuzaheed/tensorflowjs-ue4 | cd775eae20587d92a6d469511dbd2850bb7a3eb8 | 3b6d7f94340a10fa0128ce9dea91b063d5ef5b85 | refs/heads/master | 2020-12-29T05:55:02.821561 | 2019-09-27T14:50:30 | 2019-09-27T14:50:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 653 | cpp | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "TensorflowJs.h"
DEFINE_LOG_CATEGORY(TensorflowJsLog);
#define LOCTEXT_NAMESPACE "FTensorflowJsModule"
void FTensorflowJsModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
}
void FTensorflowJsModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FTensorflowJsModule, TensorflowJs) | [
"getnamo@gmail.com"
] | getnamo@gmail.com |
41993e72bbd609514d232c08abca3bce67c34eb1 | 6819d5c9083ad9258f59ddb9cfe1d3bafc9a7b32 | /examen.cpp | a6bc23c87b11c6b7e00777b5b3916a4b246595cf | [] | no_license | Ricardo23cc/examen | 3ce8c7fcd1534f66aa0df39b3029847c941f9f8f | ada67f2d9797077882144e801e42731f478da803 | refs/heads/master | 2020-03-29T22:40:13.708563 | 2018-09-26T13:51:17 | 2018-09-26T13:51:17 | 150,434,078 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 517 | cpp | #include <iostream>
#include <conio.h>
#include <stdlib.h>
using namespace std;
void pedirNumeros();
void mostrarN();
int nd, *n, *puntero;
int main()
{
pedirNumeros();
mostrarN();
delete[] n;
getch();
return 0;
}
void pedirNumeros()
{
cout<<"ingrese la cantidad de numeros "; cin>>nd;
n=new int[nd];
for(int i=0; i<nd; i++){
cout<<"dame el numero "; cin>>n[i];
}
}
void mostrarN()
{
punterr=n;
cout<<"\n ESTOS SON LOS NUMEROS."<<endl;
for(int i=0 ; i<nd; i++)
{
cout<<*puntero++<<endl;
}
}
| [
"ricardosancvanbasten23cc@gmail.com"
] | ricardosancvanbasten23cc@gmail.com |
cb79f771b7c9a04a922ffcc9b21f8602150316d1 | a91796ab826878e54d91c32249f45bb919e0c149 | /modules/gapi/src/streaming/onevpl/accelerators/accel_policy_dx11.cpp | 9fc1f4dc7286524958ed1e97a1b0c2e4e8392b59 | [
"Apache-2.0"
] | permissive | opencv/opencv | 8f1c8b5a16980f78de7c6e73a4340d302d1211cc | a308dfca9856574d37abe7628b965e29861fb105 | refs/heads/4.x | 2023-09-01T12:37:49.132527 | 2023-08-30T06:53:59 | 2023-08-30T06:53:59 | 5,108,051 | 68,495 | 62,910 | Apache-2.0 | 2023-09-14T17:37:48 | 2012-07-19T09:40:17 | C++ | UTF-8 | C++ | false | false | 20,051 | cpp | // This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2021 Intel Corporation
#ifdef HAVE_ONEVPL
#include <opencv2/gapi/util/compiler_hints.hpp>
#include "streaming/onevpl/accelerators/accel_policy_dx11.hpp"
#include "streaming/onevpl/accelerators/surface/dx11_frame_adapter.hpp"
#include "streaming/onevpl/accelerators/surface/surface.hpp"
#include "streaming/onevpl/utils.hpp"
#include "logger.hpp"
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
#define D3D11_NO_HELPERS
#include <d3d11.h>
#include <d3d11_4.h>
#include <codecvt>
#include "opencv2/core/directx.hpp"
#ifdef HAVE_OPENCL
#include <CL/cl_d3d11.h>
#endif
namespace cv {
namespace gapi {
namespace wip {
namespace onevpl {
VPLDX11AccelerationPolicy::VPLDX11AccelerationPolicy(device_selector_ptr_t selector) :
VPLAccelerationPolicy(selector),
hw_handle(),
device_context(),
allocator()
{
// setup dx11 device
IDeviceSelector::DeviceScoreTable devices = get_device_selector()->select_devices();
GAPI_Assert(devices.size() == 1 && "Multiple(or zero) acceleration devices case is unsupported");
AccelType accel_type = devices.begin()->second.get_type();
GAPI_Assert(accel_type == AccelType::DX11 &&
"Unexpected device AccelType while is waiting AccelType::DX11");
hw_handle = reinterpret_cast<ID3D11Device*>(devices.begin()->second.get_ptr());
// setup dx11 context
IDeviceSelector::DeviceContexts contexts = get_device_selector()->select_context();
GAPI_Assert(contexts.size() == 1 && "Multiple(or zero) acceleration context case is unsupported");
accel_type = contexts.begin()->get_type();
GAPI_Assert(accel_type == AccelType::DX11 &&
"Unexpected context AccelType while is waiting AccelType::DX11");
device_context = reinterpret_cast<ID3D11DeviceContext*>(contexts.begin()->get_ptr());
// setup dx11 allocator
memset(&allocator, 0, sizeof(mfxFrameAllocator));
allocator.Alloc = alloc_cb;
allocator.Lock = lock_cb;
allocator.Unlock = unlock_cb;
allocator.GetHDL = get_hdl_cb;
allocator.Free = free_cb;
allocator.pthis = this;
}
VPLDX11AccelerationPolicy::~VPLDX11AccelerationPolicy()
{
for (auto& allocation_pair : allocation_table) {
allocation_pair.second.reset();
}
GAPI_LOG_INFO(nullptr, "destroyed");
}
void VPLDX11AccelerationPolicy::init(session_t session) {
mfxStatus sts = MFXVideoCORE_SetHandle(session, MFX_HANDLE_D3D11_DEVICE,
static_cast<mfxHDL>(hw_handle));
if (sts != MFX_ERR_NONE)
{
throw std::logic_error("Cannot create VPLDX11AccelerationPolicy, MFXVideoCORE_SetHandle error: " +
mfxstatus_to_string(sts));
}
sts = MFXVideoCORE_SetFrameAllocator(session, &allocator);
if (sts != MFX_ERR_NONE)
{
throw std::logic_error("Cannot create VPLDX11AccelerationPolicy, MFXVideoCORE_SetFrameAllocator error: " +
mfxstatus_to_string(sts));
}
GAPI_LOG_INFO(nullptr, "VPLDX11AccelerationPolicy initialized, session: " << session);
}
void VPLDX11AccelerationPolicy::deinit(session_t session) {
GAPI_LOG_INFO(nullptr, "deinitialize session: " << session);
}
VPLDX11AccelerationPolicy::pool_key_t
VPLDX11AccelerationPolicy::create_surface_pool(const mfxFrameAllocRequest& alloc_req,
mfxFrameInfo& info) {
// allocate textures by explicit request
mfxFrameAllocResponse mfxResponse;
mfxStatus sts = on_alloc(&alloc_req, &mfxResponse);
if (sts != MFX_ERR_NONE)
{
throw std::logic_error("Cannot create allocated memory for surfaces, error: " +
mfxstatus_to_string(sts));
}
// get reference pointer
auto table_it = allocation_table.find(alloc_req.AllocId);
GAPI_DbgAssert (allocation_table.end() != table_it);
mfxU16 numSurfaces = alloc_req.NumFrameSuggested;
// NB: create pool with numSurfaces reservation
pool_t pool(numSurfaces);
for (int i = 0; i < numSurfaces; i++) {
std::unique_ptr<mfxFrameSurface1> handle(new mfxFrameSurface1 {});
handle->Info = info;
handle->Data.MemId = mfxResponse.mids[i];
pool.push_back(Surface::create_surface(std::move(handle), table_it->second));
}
// remember pool by key
pool_key_t key = reinterpret_cast<pool_key_t>(table_it->second.get());
GAPI_LOG_INFO(nullptr, "New pool allocated, key: " << key <<
", surface count: " << pool.total_size());
try {
if (!pool_table.emplace(key, std::move(pool)).second) {
throw std::runtime_error(std::string("VPLDX11AccelerationPolicy::create_surface_pool - ") +
"cannot insert pool, table size: " + std::to_string(pool_table.size()));
}
} catch (const std::exception&) {
throw;
}
return key;
}
VPLDX11AccelerationPolicy::surface_weak_ptr_t VPLDX11AccelerationPolicy::get_free_surface(pool_key_t key) {
auto pool_it = pool_table.find(key);
if (pool_it == pool_table.end()) {
std::stringstream ss;
ss << "key is not found: " << key << ", table size: " << pool_table.size();
const std::string& str = ss.str();
GAPI_LOG_WARNING(nullptr, str);
throw std::runtime_error(std::string(__FUNCTION__) + " - " + str);
}
pool_t& requested_pool = pool_it->second;
return requested_pool.find_free();
}
size_t VPLDX11AccelerationPolicy::get_free_surface_count(pool_key_t) const {
GAPI_Error("get_free_surface_count() is not implemented");
}
size_t VPLDX11AccelerationPolicy::get_surface_count(pool_key_t key) const {
auto pool_it = pool_table.find(key);
if (pool_it == pool_table.end()) {
std::stringstream ss;
ss << "key is not found: " << key << ", table size: " << pool_table.size();
const std::string& str = ss.str();
GAPI_LOG_WARNING(nullptr, str);
throw std::runtime_error(std::string(__FUNCTION__) + " - " + str);
}
return pool_it->second.total_size();
}
cv::MediaFrame::AdapterPtr
VPLDX11AccelerationPolicy::create_frame_adapter(pool_key_t key,
const FrameConstructorArgs ¶ms) {
auto pool_it = pool_table.find(key);
if (pool_it == pool_table.end()) {
std::stringstream ss;
ss << "key is not found: " << key << ", table size: " << pool_table.size();
const std::string& str = ss.str();
GAPI_LOG_WARNING(nullptr, str);
throw std::runtime_error(std::string(__FUNCTION__) + " - " + str);
}
pool_t& requested_pool = pool_it->second;
return cv::MediaFrame::AdapterPtr{new VPLMediaFrameDX11Adapter(requested_pool.find_by_handle(params.assoc_surface),
params.assoc_handle)};
}
mfxStatus VPLDX11AccelerationPolicy::alloc_cb(mfxHDL pthis, mfxFrameAllocRequest *request,
mfxFrameAllocResponse *response) {
if (!pthis) {
return MFX_ERR_MEMORY_ALLOC;
}
VPLDX11AccelerationPolicy *self = static_cast<VPLDX11AccelerationPolicy *>(pthis);
return self->on_alloc(request, response);
}
mfxStatus VPLDX11AccelerationPolicy::lock_cb(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr) {
VPLDX11AccelerationPolicy *self = static_cast<VPLDX11AccelerationPolicy *>(pthis);
GAPI_LOG_DEBUG(nullptr, "called from: " << self ? "Policy" : "Resource");
cv::util::suppress_unused_warning(self);
return on_lock(mid, ptr);
}
mfxStatus VPLDX11AccelerationPolicy::unlock_cb(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr) {
VPLDX11AccelerationPolicy *self = static_cast<VPLDX11AccelerationPolicy *>(pthis);
GAPI_LOG_DEBUG(nullptr, "called from: " << self ? "Policy" : "Resource");
cv::util::suppress_unused_warning(self);
return on_unlock(mid, ptr);
}
mfxStatus VPLDX11AccelerationPolicy::get_hdl_cb(mfxHDL pthis, mfxMemId mid, mfxHDL *handle) {
VPLDX11AccelerationPolicy *self = static_cast<VPLDX11AccelerationPolicy *>(pthis);
GAPI_LOG_DEBUG(nullptr, "called from: " << self ? "Policy" : "Resource");
cv::util::suppress_unused_warning(self);
return on_get_hdl(mid, handle);
}
mfxStatus VPLDX11AccelerationPolicy::free_cb(mfxHDL pthis, mfxFrameAllocResponse *response) {
if (!pthis) {
return MFX_ERR_MEMORY_ALLOC;
}
VPLDX11AccelerationPolicy *self = static_cast<VPLDX11AccelerationPolicy *>(pthis);
return self->on_free(response);
}
mfxStatus VPLDX11AccelerationPolicy::on_alloc(const mfxFrameAllocRequest *request,
mfxFrameAllocResponse *response) {
GAPI_LOG_DEBUG(nullptr, "Requested allocation id: " << std::to_string(request->AllocId) <<
", type: " << ext_mem_frame_type_to_cstr(request->Type) <<
", size: " << request->Info.Width << "x" << request->Info.Height <<
", frames minimum count: " << request->NumFrameMin <<
", frames suggested count: " << request->NumFrameSuggested);
auto table_it = allocation_table.find(request->AllocId);
if (allocation_table.end() != table_it) {
GAPI_LOG_WARNING(nullptr, "Allocation already exists, id: " + std::to_string(request->AllocId) +
". Total allocation size: " + std::to_string(allocation_table.size()));
// TODO cache
allocation_t &resources_array = table_it->second;
response->AllocId = request->AllocId;
GAPI_DbgAssert(static_cast<size_t>(std::numeric_limits<mfxU16>::max()) > resources_array->size() &&
"Invalid num frames: overflow");
response->NumFrameActual = static_cast<mfxU16>(resources_array->size());
response->mids = reinterpret_cast<mfxMemId *>(resources_array->data());
return MFX_ERR_NONE;
}
DXGI_FORMAT colorFormat = VPLMediaFrameDX11Adapter::get_dx11_color_format(request->Info.FourCC);
if (DXGI_FORMAT_UNKNOWN == colorFormat || colorFormat != DXGI_FORMAT_NV12) {
GAPI_LOG_WARNING(nullptr, "Unsupported fourcc :" << request->Info.FourCC);
return MFX_ERR_UNSUPPORTED;
}
D3D11_TEXTURE2D_DESC desc = { 0 };
desc.Width = request->Info.Width;
desc.Height = request->Info.Height;
desc.MipLevels = 1;
// single texture with subresources
desc.ArraySize = request->NumFrameSuggested;
desc.Format = colorFormat;
desc.SampleDesc.Count = 1;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.MiscFlags = 0;
desc.BindFlags = D3D11_BIND_DECODER;
if ((MFX_MEMTYPE_FROM_VPPIN & request->Type) && (DXGI_FORMAT_YUY2 == desc.Format) ||
(DXGI_FORMAT_B8G8R8A8_UNORM == desc.Format) ||
(DXGI_FORMAT_R10G10B10A2_UNORM == desc.Format) ||
(DXGI_FORMAT_R16G16B16A16_UNORM == desc.Format)) {
desc.BindFlags = D3D11_BIND_RENDER_TARGET;
}
if ((MFX_MEMTYPE_FROM_VPPOUT & request->Type) ||
(MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET & request->Type)) {
desc.BindFlags = D3D11_BIND_RENDER_TARGET;
}
if (request->Type & MFX_MEMTYPE_SHARED_RESOURCE) {
desc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
}
if (DXGI_FORMAT_P8 == desc.Format) {
desc.BindFlags = 0;
}
/* NB:
* On the one hand current OpenVINO API doesn't support texture array and
* D3D11 API doesn't allow to address specific texture element in array.
* On the other hand using textures array should be more performant case
* in applications (according to community experience)
* So, to be compliant with OV let's turn off textures array feature, but keep
* this code in commented section to consider such "optimization" in future
*/
#if 0
size_t main_textures_count = 1;
if (D3D11_BIND_RENDER_TARGET & desc.BindFlags) {
GAPI_LOG_DEBUG(nullptr, "Use array of testures instead of texture array");
desc.ArraySize = 1;
main_textures_count = request->NumFrameSuggested;
}
#else
// enforcement to use array of textures
size_t main_textures_count = request->NumFrameSuggested;
// enforcement to do not use texture array as subresources as part of a single texture
desc.ArraySize = 1;
#endif
// create GPU textures
HRESULT err = S_OK;
std::vector<ComPtrGuard<ID3D11Texture2D>> main_textures;
main_textures.reserve(main_textures_count);
for (size_t i = 0; i < main_textures_count; i++) {
ComPtrGuard<ID3D11Texture2D> main_texture = createCOMPtrGuard<ID3D11Texture2D>();
{
ID3D11Texture2D *pTexture2D = nullptr;
err = hw_handle->CreateTexture2D(&desc, nullptr, &pTexture2D);
if (FAILED(err)) {
GAPI_LOG_WARNING(nullptr, "Cannot create texture by index: " << i <<
", error: " << std::to_string(HRESULT_CODE(err)));
return MFX_ERR_MEMORY_ALLOC;
}
main_texture.reset(pTexture2D);
}
main_textures.push_back(std::move(main_texture));
}
// create staging texture to read it from
desc.ArraySize = 1;
desc.Usage = D3D11_USAGE_STAGING;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
desc.BindFlags = 0;
desc.MiscFlags = 0;
std::vector<ComPtrGuard<ID3D11Texture2D>> staging_textures;
staging_textures.reserve(request->NumFrameSuggested);
for (int i = 0; i < request->NumFrameSuggested; i++ ) {
ID3D11Texture2D *staging_texture_2d = nullptr;
err = hw_handle->CreateTexture2D(&desc, NULL, &staging_texture_2d);
if (FAILED(err)) {
GAPI_LOG_WARNING(nullptr, "Cannot create staging texture, error: " + std::to_string(HRESULT_CODE(err)));
return MFX_ERR_MEMORY_ALLOC;
}
staging_textures.push_back(createCOMPtrGuard(staging_texture_2d));
}
// for multiple subresources initialize allocation array
auto cand_resource_it = allocation_table.end();
{
// insert into global table
auto inserted_it =
allocation_table.emplace(request->AllocId,
DX11AllocationRecord::create(request->NumFrameSuggested,
device_context,
allocator,
std::move(main_textures),
std::move(staging_textures)));
if (!inserted_it.second) {
GAPI_LOG_WARNING(nullptr, "Cannot assign allocation by id: " + std::to_string(request->AllocId) +
" - aldeady exist. Total allocation size: " + std::to_string(allocation_table.size()));
return MFX_ERR_MEMORY_ALLOC;
}
GAPI_LOG_DEBUG(nullptr, "allocation by id: " << request->AllocId <<
" was created, total allocations count: " << allocation_table.size());
cand_resource_it = inserted_it.first;
}
// fill out response
GAPI_DbgAssert(cand_resource_it != allocation_table.end() && "Invalid cand_resource_it");
allocation_t &resources_array = cand_resource_it->second;
response->AllocId = request->AllocId;
response->NumFrameActual = request->NumFrameSuggested;
response->mids = reinterpret_cast<mfxMemId *>(resources_array->data());
return MFX_ERR_NONE;
}
mfxStatus VPLDX11AccelerationPolicy::on_lock(mfxMemId mid, mfxFrameData *ptr) {
DX11AllocationRecord::AllocationId data = reinterpret_cast<DX11AllocationRecord::AllocationId>(mid);
if (!data) {
GAPI_LOG_WARNING(nullptr, "Allocation record is empty");
return MFX_ERR_LOCK_MEMORY;
}
return data->acquire_access(ptr);
}
mfxStatus VPLDX11AccelerationPolicy::on_unlock(mfxMemId mid, mfxFrameData *ptr) {
DX11AllocationRecord::AllocationId data = reinterpret_cast<DX11AllocationRecord::AllocationId>(mid);
if (!data) {
return MFX_ERR_LOCK_MEMORY;
}
return data->release_access(ptr);
}
mfxStatus VPLDX11AccelerationPolicy::on_get_hdl(mfxMemId mid, mfxHDL *handle) {
DX11AllocationRecord::AllocationId data = reinterpret_cast<DX11AllocationRecord::AllocationId>(mid);
if (!data) {
return MFX_ERR_INVALID_HANDLE;
}
mfxHDLPair *pPair = reinterpret_cast<mfxHDLPair *>(handle);
pPair->first = data->get_texture_ptr();
pPair->second = static_cast<mfxHDL>(reinterpret_cast<DX11AllocationItem::subresource_id_t *>(
static_cast<uint64_t>(data->get_subresource())));
GAPI_LOG_DEBUG(nullptr, "ID3D11Texture2D : " << pPair->first << ", sub id: " << pPair->second);
return MFX_ERR_NONE;
}
mfxStatus VPLDX11AccelerationPolicy::on_free(mfxFrameAllocResponse *response) {
GAPI_LOG_DEBUG(nullptr, "Allocations count before: " << allocation_table.size() <<
", requested id: " << response->AllocId);
auto table_it = allocation_table.find(response->AllocId);
if (allocation_table.end() == table_it) {
GAPI_LOG_WARNING(nullptr, "Cannot find allocation id: " + std::to_string(response->AllocId) +
". Total allocation size: " + std::to_string(allocation_table.size()));
return MFX_ERR_MEMORY_ALLOC;
}
allocation_table.erase(table_it);
GAPI_LOG_DEBUG(nullptr, "Allocation by requested id: " << response->AllocId <<
" has been erased");
return MFX_ERR_NONE;
}
} // namespace onevpl
} // namespace wip
} // namespace gapi
} // namespace cv
#else // #if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
namespace cv {
namespace gapi {
namespace wip {
namespace onevpl {
VPLDX11AccelerationPolicy::VPLDX11AccelerationPolicy(device_selector_ptr_t selector) :
VPLAccelerationPolicy(selector) {
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
}
VPLDX11AccelerationPolicy::~VPLDX11AccelerationPolicy() = default;
void VPLDX11AccelerationPolicy::init(session_t ) {
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
}
void VPLDX11AccelerationPolicy::deinit(session_t) {
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
}
VPLDX11AccelerationPolicy::pool_key_t VPLDX11AccelerationPolicy::create_surface_pool(const mfxFrameAllocRequest&,
mfxFrameInfo&) {
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
}
VPLDX11AccelerationPolicy::surface_weak_ptr_t VPLDX11AccelerationPolicy::get_free_surface(pool_key_t) {
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
}
size_t VPLDX11AccelerationPolicy::get_free_surface_count(pool_key_t) const {
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
}
size_t VPLDX11AccelerationPolicy::get_surface_count(pool_key_t) const {
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
}
cv::MediaFrame::AdapterPtr VPLDX11AccelerationPolicy::create_frame_adapter(pool_key_t,
const FrameConstructorArgs &) {
GAPI_Error("VPLDX11AccelerationPolicy unavailable in current configuration");
}
} // namespace onevpl
} // namespace wip
} // namespace gapi
} // namespace cv
#endif // #if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
#endif // HAVE_ONEVPL
| [
"noreply@github.com"
] | noreply@github.com |
26f931972bbfdd2a8e9639d77594978a44c81b80 | 1aa43354b5133464231b262aba7b6e38fe3039db | /tokenizer.cpp | ea195a437431bcfacdd5e35812ff795b54a3824f | [] | no_license | sachinhosmani/RA-Parser | 1c7cdccb75fb964999d4cc5bb4b0788b6501a5bc | 782e9e57ef81bb06d7cd551b652cf74258dc2c45 | refs/heads/master | 2021-01-10T21:20:49.128699 | 2013-12-09T06:55:14 | 2013-12-09T06:55:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 655 | cpp | #include "tokenizer.h"
Tokenizer::Tokenizer(const string &in) {
input = in;
boost::trim(input);
ss.str(input);
}
string Tokenizer::next_token() {
try {
char first, last;
string token = "";
ss >> first;
token += first;
if (first != '(') {
ss.unget();
ss >> token;
}
last = token[token.length() - 1];
while (last == ')' || last == ',') {
if (token.length() > 1) {
ss.unget();
token.erase(token.length() - 1);
last = token[token.length() - 1];
} else {
return token;
}
}
return token;
} catch (EOF_ERROR e) {
throw EOF_ERROR();
}
return string("");
}
bool Tokenizer::eof() {
return ss.eof();
}
| [
"sachinhosmani@gmail.com"
] | sachinhosmani@gmail.com |
5b5ab454cfa8b00dc297f8b3ca6e5e7d6a479b79 | 6b024b41ba720a4b0fdff41407004609267b4d01 | /Source/Engine/World/Public/Components/IBLComponent.h | d37686f365cded033137efec94be3fe03de16c67 | [
"MIT"
] | permissive | MORTAL2000/AngieEngine | 3e72003d1182468ce4ebbc256d626b92a76cd224 | 53f4022cc05a1cc8a577910a63d8c4bea36c026f | refs/heads/master | 2023-02-10T13:07:51.887569 | 2021-01-04T23:23:20 | 2021-01-04T23:23:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,111 | h | /*
Angie Engine Source Code
MIT License
Copyright (C) 2017-2021 Alexander Samusev.
This file is part of the Angie Engine Source Code.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include "PunctualLightComponent.h"
class AIBLComponent : public APunctualLightComponent {
AN_COMPONENT( AIBLComponent, APunctualLightComponent )
public:
void SetRadius( float _Radius );
float GetRadius() const { return Radius; }
void SetIrradianceMap( int _Index );
int GetIrradianceMap() const { return IrradianceMap; }
void SetReflectionMap( int _Index );
int GetReflectionMap() const { return ReflectionMap; }
BvSphere const & GetSphereWorldBounds() const { return SphereWorldBounds; }
void PackProbe( Float4x4 const & InViewMatrix, struct SProbeParameters & Probe );
protected:
AIBLComponent();
void OnTransformDirty() override;
void DrawDebug( ADebugRenderer * InRenderer ) override;
private:
void UpdateWorldBounds();
BvSphere SphereWorldBounds;
BvOrientedBox OBBWorldBounds;
float Radius;
int IrradianceMap = 0;
int ReflectionMap = 0;
};
| [
"alsamusev@list.ru"
] | alsamusev@list.ru |
56d8051ad20ab23f2759d7df4edfbe715a845a60 | 95c6618b37e3a616b2ee95d40fa1983f7cf30256 | /list.h | c2365c9dfc48e30183513aa00230a531e20541a4 | [] | no_license | ssdemajia/ministl | f38ab3bb10101f03f2a2cf4a6b3559739080c361 | 93d94ebcdadb704739139ac095711f97c656cdb9 | refs/heads/master | 2020-12-02T21:26:03.488530 | 2017-09-28T12:57:02 | 2017-09-28T12:57:02 | 96,316,803 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 410 | h | #ifndef _LIST_H
#define _LIST_H
#include "leetcode/inc.h"
#include <iostream>
#include <vector>
#include <memory>
struct ListNode{
int val;
ListNode * next;
ListNode(int x):val(x),next(NULL){}
};
class List
{
public:
List(std::vector<int> source);
~List();
ListNode * getHead() const;
void setHead(ListNode* x);
void displayList() const;
private:
ListNode* list;
};
#endif
| [
"787178638@qq.com"
] | 787178638@qq.com |
5dd3559ac94ca43b26c33b5a9b3601f937fc2545 | ad4c14879a0ea76ab2a42d4dca27fbfafc914df6 | /test_Text/src/ofApp.cpp | feb213e8268de17250638323a1702f24f87205c0 | [
"MIT"
] | permissive | Bentleyj/Textsplosion | 0efd9db4d5a3782a9a3a6070193ba90d8d1f8ffc | d410be2340f850ff0a19fedaaa52c062807bf5ff | refs/heads/master | 2021-01-19T06:42:43.676956 | 2017-07-04T12:09:02 | 2017-07-04T12:09:02 | 63,073,838 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,104 | cpp | #include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
font = new ofTrueTypeFont();
font->load("fonts/Plain-Light.ttf", 50, true, true, true);
light.setPosition(0, 0, 0);
cam.lookAt(ofVec3f(0, 0, 0));
cam.disableMouseMiddleButton();
ofSetDataPathRoot("../Resources/data/");
noiseOffset1 = 0;
noiseOffset2 = 1000;
noiseOffset3 = 2000;
noiseOffset4 = 3000;
noise = 0;
textIndex = 0;
ofSetLogLevel(OF_LOG_ERROR);
cameraPosTarget = ofVec3f(0, 0, 600);
camUpVectorTarget = ofVec3f(0, 1, 0);
ofBackground(ofColor(0));
vector<string> names;
names.push_back("META-LOOPS");
names.push_back("INTERACTION");
names.push_back("COMMERCIAL");
names.push_back("PETE");
names.push_back("JOEL");
names.push_back("AMALIE");
names.push_back("SAM");
names.push_back("MARGAUX");
texts.resize(names.size());
for(int i = 0; i < names.size(); i++) {
texts[i].setFont(font);
texts[i].setCam(&cam);
texts[i].setText(names[i]);
texts[i].setViewPosition(ofVec3f(ofRandom(-1.0, 1.0), ofRandom(-1.0, 1.0), 0.0));
}
}
//--------------------------------------------------------------
void ofApp::update(){
float newX = ofLerp(cam.getPosition().x, cameraPosTarget.x, 0.05);
float newY = ofLerp(cam.getPosition().y, cameraPosTarget.y, 0.05);
float newZ = ofLerp(cam.getPosition().z, cameraPosTarget.z, 0.05);
cam.setPosition(newX, newY, newZ);
float newUpX = ofLerp(cam.getUpDir().x, camUpVectorTarget.x, 0.05);
float newUpY = ofLerp(cam.getUpDir().y, camUpVectorTarget.y, 0.05);
float newUpZ = ofLerp(cam.getUpDir().z, camUpVectorTarget.z, 0.05);
cam.lookAt(ofVec3f(0, 0, 0), ofVec3f(newUpX, newUpY, newUpZ));
for(int i = 0; i < texts.size(); i++) {
texts[i].update();
}
}
//--------------------------------------------------------------
void ofApp::draw(){
cam.begin();
// ofEnableDepthTest();
//light.enable();
float highestPercentage = 0.0;
float lowestPercentage = 1.0;
float highestTheta;
int highestPercentageIndex;
for(int i = 0; i < texts.size(); i++) {
ofVec3f currentViewPos = cam.getPosition().normalize();
ofVec3f textViewPos = texts[i].getViewPosition().normalize();
float diff = (currentViewPos - textViewPos).length();
float percent = ofMap(diff, 0.0, 2.0, 1.0, 0.0, true);
if(percent > highestPercentage) {
highestPercentage = percent;
highestPercentageIndex = i;
} else if(percent < lowestPercentage) {
lowestPercentage = percent;
}
}
// if(ofGetKeyPressed()) {
float distance = 600;//(cam.getPosition() - ofVec3f(0, 0, 0)).length();
cameraPosTarget = distance * texts[highestPercentageIndex].getViewPosition();
camUpVectorTarget = texts[highestPercentageIndex].getUpVector();
for(int i = 0; i < texts.size(); i++) {
ofColor col = ofColor(0, 0, 0);
if(i == highestPercentageIndex) {
texts[i].setIsSelected(true);
//col.lerp(ofColor(255, 255, 255), highestPercentage);
} else {
texts[i].setIsSelected(false);
//col.lerp(ofColor(127, 127, 127), 0.0);
}
texts[i].setColor(col.r, col.g, col.b);
if(i != highestPercentageIndex) {
texts[i].draw();
}
}
texts[highestPercentageIndex].draw();
// ofDrawAxis(10);
cam.end();
if(animating) {
noise += 0.01;
}
gui.draw();
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if(key == ' ') {
textIndex++;
textIndex %= texts.size();
float distance = (cam.getPosition() - ofVec3f(0, 0, 0)).length();
cameraPosTarget = distance * texts[textIndex].getViewPosition();
camUpVectorTarget = texts[textIndex].getUpVector();
cout<<"camUpVectorTarget: "<<camUpVectorTarget.x<<", "<<camUpVectorTarget.y<<", "<<camUpVectorTarget.z<<endl;
}
if(key == 'a') {
animating = !animating;
}
if(key == 'f') {
ofToggleFullscreen();
}
}
//--------------------------------------------------------------
ofVec3f ofApp::drawText(string text, ofVec3f viewPositionNorm) {
ofPushMatrix();
float theta = atan(viewPositionNorm.y/viewPositionNorm.x);
float phi = atan(sqrt(viewPositionNorm.x * viewPositionNorm.x + viewPositionNorm.y * viewPositionNorm.y)/(viewPositionNorm.z));
ofRotateX(theta * 180 / PI);
ofRotateY(phi * 180 / PI);
ofSetColor(0, 255, 255);
float dist = (ofVec3f(0, 0, 0) - cam.getPosition()).length();
ofRectangle rect = font->getStringBoundingBox(text, 0, 0);
vector<ofTTFCharacter> characters = font->getStringAsPoints(text);
ofMesh mesh;
for(int j = 0; j < characters.size(); j++) {
vector<ofPolyline> lines = characters[j].getOutline();
ofRectangle lineRect = lines[0].getBoundingBox();
vector<ofPoint> points = lines[0].getVertices();
for(int i = 0; i < points.size(); i++) {
ofColor col = ofColor(0, 255, 255/*ofMap(i, 0, points.size(), 0, 255), 0, 0*/);
mesh.addVertex(ofVec3f(points[i].x - rect.width/2, -points[i].y - lineRect.getHeight() + rect.height/2, 0));
mesh.addColor(col);
mesh.addVertex(ofVec3f(points[(i+1)%points.size()].x - rect.width/2, -points[(i+1)%points.size()].y - lineRect.getHeight() + rect.height/2, 0));
mesh.addColor(col);
}
}
float zOffset = ofMap(ofNoise(noise), 0, 1, 50, -50);
for(int i = 0; i < mesh.getNumVertices(); i++) {
ofVec3f vertex = mesh.getVertex(i);
if(i%2 == 0) zOffset = ofMap(ofNoise(noise + i), 0, 1, 500, -500);
vertex.z += zOffset;
float distanceToTarget = (cam.getPosition() - ofVec3f(0, 0, 0)).length();
float distanceToObject = distanceToTarget - zOffset;
float scale = distanceToObject / distanceToTarget;
vertex.x *= scale;
vertex.y *= scale;
mesh.setVertex(i, vertex);
}
ofSetLineWidth(3);
mesh.setMode(OF_PRIMITIVE_LINES);
mesh.draw();
ofPopMatrix();
return viewPositionNorm;
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
//cameraPosTarget = cam.getPosition();
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
//--------------------------------------------------------------
void ofApp::drawSquares() {
float distanceToTarget = (cam.getPosition() - ofVec3f(0, 0, 0)).length();
float minDist = 100;
float maxDist = -100;
ofSetColor(0, 0, 255);
float zOffset = ofMap(ofNoise(noise + noiseOffset1), 0, 1.0, minDist, maxDist);
float distanceToObject = distanceToTarget - zOffset;
float scale = distanceToObject / distanceToTarget;
ofDrawBox(12.5*scale, 12.5*scale, zOffset, 25*scale, 25*scale, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset2), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(-12.5*scale, 12.5*scale, zOffset, 25*scale, 25*scale, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset3), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(-12.5*scale, -12.5*scale, zOffset, 25*scale, 25*scale, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset4), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(12.5*scale, -12.5*scale, zOffset, 25*scale, 25*scale, 0);
ofRotate(90, 1, 0, 0);
ofSetColor(0, 255, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset1), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(12.5*scale, 12.5*scale, zOffset, 25*scale, 25*scale, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset2), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(-12.5*scale, 12.5*scale, zOffset, 25*scale, 25*scale, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset3), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(-12.5*scale, -12.5*scale, zOffset, 25*scale, 25*scale, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset4), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(12.5*scale, -12.5*scale, zOffset, 25*scale, 25*scale, 0);
ofRotate(90, 0, 1, 0);
ofSetColor(255, 0, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset1), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(12.5*scale, 12.5*scale, zOffset, 25*scale, 25*scale, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset2), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(-12.5*scale, 12.5*scale, zOffset, 25*scale, 25*scale, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset3), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(-12.5*scale, -12.5*scale, zOffset, 25*scale, 25*scale, 0);
zOffset = ofMap(ofNoise(noise + noiseOffset4), 0, 1.0, minDist, maxDist);
distanceToObject = distanceToTarget - zOffset;
scale = distanceToObject / distanceToTarget;
ofDrawBox(12.5*scale, -12.5*scale, zOffset, 25*scale, 25*scale, 0);
}
| [
"jgbentley10@gmail.com"
] | jgbentley10@gmail.com |
4d0cc9c0a573facbe9176f23fd79f55efcc86c68 | 7efaa0e97588a3c677b22e9e1220f72e37063e07 | /src/sst/elements/vanadis/inst/vbcmpi.h | ac91ccac15a3a2ff24cec3d720c92ce09eb46cd9 | [
"BSD-3-Clause"
] | permissive | amroawad2/sst-elements | 6e3e67e47fa5a891cdb3d68cc2d0728b9a1abcf2 | dd1bf1d32dd2b4800a92b93103e297224bcdb120 | refs/heads/master | 2021-06-25T20:53:03.966249 | 2020-12-21T02:10:35 | 2020-12-21T02:10:35 | 133,526,382 | 0 | 0 | NOASSERTION | 2019-05-09T15:33:43 | 2018-05-15T14:14:02 | C++ | UTF-8 | C++ | false | false | 2,591 | h |
#ifndef _H_VANADIS_BRANCH_REG_COMPARE_IMM
#define _H_VANADIS_BRANCH_REG_COMPARE_IMM
#include "inst/vspeculate.h"
#include "inst/vcmptype.h"
#include "util/vcmpop.h"
namespace SST {
namespace Vanadis {
class VanadisBranchRegCompareImmInstruction : public VanadisSpeculatedInstruction {
public:
VanadisBranchRegCompareImmInstruction(
const uint64_t addr,
const uint32_t hw_thr,
const VanadisDecoderOptions* isa_opts,
const uint16_t src_1,
const int64_t imm,
const int64_t offst,
const VanadisDelaySlotRequirement delayT,
const VanadisRegisterCompareType cType,
const VanadisRegisterFormat fmt
) :
VanadisSpeculatedInstruction(addr, hw_thr, isa_opts, 1, 0, 1, 0, 0, 0, 0, 0, delayT),
compareType(cType), imm_value(imm), offset(offst), reg_format(fmt) {
isa_int_regs_in[0] = src_1;
}
VanadisBranchRegCompareImmInstruction* clone() {
return new VanadisBranchRegCompareImmInstruction( *this );
}
virtual const char* getInstCode() const { return "BCMPI"; }
virtual void printToBuffer(char* buffer, size_t buffer_size ) {
snprintf( buffer, buffer_size, "BCMPI isa-in: %" PRIu16 " / phys-in: %" PRIu16 " / imm: %" PRId64 " / offset: %" PRId64 "\n",
isa_int_regs_in[0], phys_int_regs_in[0], imm_value, offset);
}
virtual void execute( SST::Output* output, VanadisRegisterFile* regFile ) {
output->verbose(CALL_INFO, 16, 0, "Execute: (addr=0x%0llx) BCMPI isa-in: %" PRIu16 " / phys-in: %" PRIu16 " / imm: %" PRId64 " / offset: %" PRId64 "\n",
getInstructionAddress(), isa_int_regs_in[0], phys_int_regs_in[0], imm_value, offset );
bool compare_result = false;
switch( reg_format ) {
case VANADIS_FORMAT_INT64:
{
compare_result = registerCompareImm<int64_t>( compareType, regFile, this, output, phys_int_regs_in[0], imm_value );
}
break;
case VANADIS_FORMAT_INT32:
{
compare_result = registerCompareImm<int32_t>( compareType, regFile, this, output, phys_int_regs_in[0], static_cast<int32_t>(imm_value) );
}
break;
default:
{
flagError();
}
break;
}
if( compare_result ) {
const int64_t instruction_address = getInstructionAddress();
const int64_t ins_addr_and_offset = instruction_address + offset + VANADIS_SPECULATE_JUMP_ADDR_ADD;
takenAddress = static_cast<uint64_t>( ins_addr_and_offset );
} else {
takenAddress = calculateStandardNotTakenAddress();
}
markExecuted();
}
protected:
const int64_t offset;
const int64_t imm_value;
VanadisRegisterCompareType compareType;
VanadisRegisterFormat reg_format;
};
}
}
#endif
| [
"sdhammo@sandia.gov"
] | sdhammo@sandia.gov |
2c6f9e9e1b0dce53a62c9e6c920136483c0b33cb | 47f69fd1e7d5c9e17d8fb6c99e1b17bb11d3aebd | /Haffer_C867_PA/src/roster.h | a9cfe7fc6004df48a9a10643f85d3963dc92f019 | [] | no_license | rhaffer/Student-Management | ab0c8e876ad38b978cf03203dbe8d7bf7be88d4d | bf5faa96b4686004ccfb69bbfb86294bc32fbc40 | refs/heads/master | 2023-04-08T03:38:10.719253 | 2021-04-23T18:14:31 | 2021-04-23T18:14:31 | 246,637,297 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,098 | h | /*
* roster.h
* Author: rhaffer
*/
#include <iostream>
#include "student.h"
#include "degree.h"
#ifndef ROSTER_H_
#define ROSTER_H_
const std::string studentData[] =
{"A1,John,Smith,John1989@gm ail.com,20,30,35,40,SECURITY",
"A2,Suzan,Erickson,Erickson_1990@gmailcom,19,50,30,40,NETWORK",
"A3,Jack,Napoli,The_lawyer99yahoo.com,19,20,40,33,SOFTWARE",
"A4,Erin,Black,Erin.black@comcast.net,22,50,58,40,SECURITY",
"A5,Rick,Haffer,rhaffer@wgu.edu,27,3,5,12,SOFTWARE"};
const int NUMCOLUMNS = 9;
const int NUMSTUDENTS = sizeof(studentData)/sizeof(studentData[0]);
class Roster{
public:
Student* classRosterArray[NUMSTUDENTS] = {nullptr, nullptr, nullptr, nullptr, nullptr};
void add(std::string studentID, std::string firstName, std::string lastName, std::string emailAddress, int age,
int daysInCourse1, int daysInCourse2, int daysInCourse3, Degree degree);
void remove(std::string studentID);
void printAll();
void printDaysInCourse(std::string studentID);
void printInvalidEmails();
void printByDegreeProgram();
};
#endif /* ROSTER_H_ */
| [
"noreply@github.com"
] | noreply@github.com |
da9852402d83ac4fb41add303fddeba1ada7b301 | fe5d44081787245e352f4b2a0e6a1415553db8f3 | /ysu/node/lmdb/lmdb.cpp | 1dd8a02bd99f94e4373998eaa9b170894acf3a55 | [
"BSD-3-Clause"
] | permissive | lik2129/ysu_coin | eadda56b049e011e36841b2717e7969d670d01b6 | 47e40ed5d4000fc59566099929bd08a9ae16a4c1 | refs/heads/master | 2022-12-26T20:26:41.050159 | 2020-09-30T04:45:43 | 2020-09-30T04:45:43 | 291,059,733 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 45,585 | cpp | #include <ysu/crypto_lib/random_pool.hpp>
#include <ysu/lib/utility.hpp>
#include <ysu/node/common.hpp>
#include <ysu/node/lmdb/lmdb.hpp>
#include <ysu/node/lmdb/lmdb_iterator.hpp>
#include <ysu/node/lmdb/wallet_value.hpp>
#include <ysu/secure/buffer.hpp>
#include <ysu/secure/versioning.hpp>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <boost/polymorphic_cast.hpp>
#include <queue>
namespace ysu
{
template <>
void * mdb_val::data () const
{
return value.mv_data;
}
template <>
size_t mdb_val::size () const
{
return value.mv_size;
}
template <>
mdb_val::db_val (size_t size_a, void * data_a) :
value ({ size_a, data_a })
{
}
template <>
void mdb_val::convert_buffer_to_value ()
{
value = { buffer->size (), const_cast<uint8_t *> (buffer->data ()) };
}
}
ysu::mdb_store::mdb_store (ysu::logger_mt & logger_a, boost::filesystem::path const & path_a, ysu::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, ysu::lmdb_config const & lmdb_config_a, bool backup_before_upgrade_a) :
logger (logger_a),
env (error, path_a, ysu::mdb_env::options::make ().set_config (lmdb_config_a).set_use_no_mem_init (true)),
mdb_txn_tracker (logger_a, txn_tracking_config_a, block_processor_batch_max_time_a),
txn_tracking_enabled (txn_tracking_config_a.enable)
{
if (!error)
{
auto is_fully_upgraded (false);
auto is_fresh_db (false);
{
auto transaction (tx_begin_read ());
auto err = mdb_dbi_open (env.tx (transaction), "meta", 0, &meta);
is_fresh_db = err != MDB_SUCCESS;
if (err == MDB_SUCCESS)
{
is_fully_upgraded = (version_get (transaction) == version);
mdb_dbi_close (env, meta);
}
}
// Only open a write lock when upgrades are needed. This is because CLI commands
// open inactive nodes which can otherwise be locked here if there is a long write
// (can be a few minutes with the --fast_bootstrap flag for instance)
if (!is_fully_upgraded)
{
ysu::network_constants network_constants;
if (!is_fresh_db)
{
if (!network_constants.is_dev_network ())
{
std::cout << "Upgrade in progress..." << std::endl;
}
if (backup_before_upgrade_a)
{
create_backup_file (env, path_a, logger_a);
}
}
auto needs_vacuuming = false;
{
auto transaction (tx_begin_write ());
open_databases (error, transaction, MDB_CREATE);
if (!error)
{
error |= do_upgrades (transaction, needs_vacuuming);
}
}
if (needs_vacuuming && !network_constants.is_dev_network ())
{
logger.always_log ("Preparing vacuum...");
auto vacuum_success = vacuum_after_upgrade (path_a, lmdb_config_a);
logger.always_log (vacuum_success ? "Vacuum succeeded." : "Failed to vacuum. (Optional) Ensure enough disk space is available for a copy of the database and try to vacuum after shutting down the node");
}
}
else
{
auto transaction (tx_begin_read ());
open_databases (error, transaction, 0);
}
}
}
bool ysu::mdb_store::vacuum_after_upgrade (boost::filesystem::path const & path_a, ysu::lmdb_config const & lmdb_config_a)
{
// Vacuum the database. This is not a required step and may actually fail if there isn't enough storage space.
auto vacuum_path = path_a.parent_path () / "vacuumed.ldb";
auto vacuum_success = copy_db (vacuum_path);
if (vacuum_success)
{
// Need to close the database to release the file handle
mdb_env_sync (env.environment, true);
mdb_env_close (env.environment);
env.environment = nullptr;
// Replace the ledger file with the vacuumed one
boost::filesystem::rename (vacuum_path, path_a);
// Set up the environment again
auto options = ysu::mdb_env::options::make ()
.set_config (lmdb_config_a)
.set_use_no_mem_init (true);
env.init (error, path_a, options);
if (!error)
{
auto transaction (tx_begin_read ());
open_databases (error, transaction, 0);
}
}
else
{
// The vacuum file can be in an inconsistent state if there wasn't enough space to create it
boost::filesystem::remove (vacuum_path);
}
return vacuum_success;
}
void ysu::mdb_store::serialize_mdb_tracker (boost::property_tree::ptree & json, std::chrono::milliseconds min_read_time, std::chrono::milliseconds min_write_time)
{
mdb_txn_tracker.serialize_json (json, min_read_time, min_write_time);
}
void ysu::mdb_store::serialize_memory_stats (boost::property_tree::ptree & json)
{
MDB_stat stats;
auto status (mdb_env_stat (env.environment, &stats));
release_assert (status == 0);
json.put ("branch_pages", stats.ms_branch_pages);
json.put ("depth", stats.ms_depth);
json.put ("entries", stats.ms_entries);
json.put ("leaf_pages", stats.ms_leaf_pages);
json.put ("overflow_pages", stats.ms_overflow_pages);
json.put ("page_size", stats.ms_psize);
}
ysu::write_transaction ysu::mdb_store::tx_begin_write (std::vector<ysu::tables> const &, std::vector<ysu::tables> const &)
{
return env.tx_begin_write (create_txn_callbacks ());
}
ysu::read_transaction ysu::mdb_store::tx_begin_read ()
{
return env.tx_begin_read (create_txn_callbacks ());
}
std::string ysu::mdb_store::vendor_get () const
{
return boost::str (boost::format ("LMDB %1%.%2%.%3%") % MDB_VERSION_MAJOR % MDB_VERSION_MINOR % MDB_VERSION_PATCH);
}
ysu::mdb_txn_callbacks ysu::mdb_store::create_txn_callbacks ()
{
ysu::mdb_txn_callbacks mdb_txn_callbacks;
if (txn_tracking_enabled)
{
mdb_txn_callbacks.txn_start = ([& mdb_txn_tracker = mdb_txn_tracker](const ysu::transaction_impl * transaction_impl) {
mdb_txn_tracker.add (transaction_impl);
});
mdb_txn_callbacks.txn_end = ([& mdb_txn_tracker = mdb_txn_tracker](const ysu::transaction_impl * transaction_impl) {
mdb_txn_tracker.erase (transaction_impl);
});
}
return mdb_txn_callbacks;
}
void ysu::mdb_store::open_databases (bool & error_a, ysu::transaction const & transaction_a, unsigned flags)
{
error_a |= mdb_dbi_open (env.tx (transaction_a), "frontiers", flags, &frontiers) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "unchecked", flags, &unchecked) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "vote", flags, &vote) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "online_weight", flags, &online_weight) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "meta", flags, &meta) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "peers", flags, &peers) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "pruned", flags, &pruned) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "confirmation_height", flags, &confirmation_height) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "accounts", flags, &accounts_v0) != 0;
accounts = accounts_v0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "pending", flags, &pending_v0) != 0;
pending = pending_v0;
auto version_l = version_get (transaction_a);
if (version_l < 19)
{
// These legacy (and state) block databases are no longer used, but need opening so they can be deleted during an upgrade
error_a |= mdb_dbi_open (env.tx (transaction_a), "send", flags, &send_blocks) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "receive", flags, &receive_blocks) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "open", flags, &open_blocks) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "change", flags, &change_blocks) != 0;
if (version_l >= 15)
{
error_a |= mdb_dbi_open (env.tx (transaction_a), "state_blocks", flags, &state_blocks) != 0;
state_blocks_v0 = state_blocks;
}
}
else
{
error_a |= mdb_dbi_open (env.tx (transaction_a), "blocks", MDB_CREATE, &blocks) != 0;
}
if (version_l < 16)
{
// The representation database is no longer used, but needs opening so that it can be deleted during an upgrade
error_a |= mdb_dbi_open (env.tx (transaction_a), "representation", flags, &representation) != 0;
}
if (version_l < 15)
{
// These databases are no longer used, but need opening so they can be deleted during an upgrade
error_a |= mdb_dbi_open (env.tx (transaction_a), "state", flags, &state_blocks_v0) != 0;
state_blocks = state_blocks_v0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "accounts_v1", flags, &accounts_v1) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "pending_v1", flags, &pending_v1) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "state_v1", flags, &state_blocks_v1) != 0;
}
}
bool ysu::mdb_store::do_upgrades (ysu::write_transaction & transaction_a, bool & needs_vacuuming)
{
auto error (false);
auto version_l = version_get (transaction_a);
switch (version_l)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
logger.always_log (boost::str (boost::format ("The version of the ledger (%1%) is lower than the minimum (%2%) which is supported for upgrades. Either upgrade to a v19, v20 or v21 node first or delete the ledger.") % version_l % minimum_version));
error = true;
break;
case 14:
upgrade_v14_to_v15 (transaction_a);
needs_vacuuming = true;
case 15:
// Upgrades to v16, v17 & v18 are all part of the v21 node release
upgrade_v15_to_v16 (transaction_a);
case 16:
upgrade_v16_to_v17 (transaction_a);
case 17:
upgrade_v17_to_v18 (transaction_a);
needs_vacuuming = true;
case 18:
upgrade_v18_to_v19 (transaction_a);
needs_vacuuming = true;
case 19:
upgrade_v19_to_v20 (transaction_a);
case 20:
break;
default:
logger.always_log (boost::str (boost::format ("The version of the ledger (%1%) is too high for this node") % version_l));
error = true;
break;
}
return error;
}
void ysu::mdb_store::upgrade_v14_to_v15 (ysu::write_transaction & transaction_a)
{
logger.always_log ("Preparing v14 to v15 database upgrade...");
std::vector<std::pair<ysu::account, ysu::account_info>> account_infos;
upgrade_counters account_counters (count (transaction_a, accounts_v0), count (transaction_a, accounts_v1));
account_infos.reserve (account_counters.before_v0 + account_counters.before_v1);
ysu::mdb_merge_iterator<ysu::account, ysu::account_info_v14> i_account (transaction_a, accounts_v0, accounts_v1);
ysu::mdb_merge_iterator<ysu::account, ysu::account_info_v14> n_account{};
for (; i_account != n_account; ++i_account)
{
ysu::account account (i_account->first);
ysu::account_info_v14 account_info_v14 (i_account->second);
// Upgrade rep block to representative account
auto rep_block = block_get_v14 (transaction_a, account_info_v14.rep_block);
release_assert (rep_block != nullptr);
account_infos.emplace_back (account, ysu::account_info{ account_info_v14.head, rep_block->representative (), account_info_v14.open_block, account_info_v14.balance, account_info_v14.modified, account_info_v14.block_count, i_account.from_first_database ? ysu::epoch::epoch_0 : ysu::epoch::epoch_1 });
// Move confirmation height from account_info database to its own table
mdb_put (env.tx (transaction_a), confirmation_height, ysu::mdb_val (account), ysu::mdb_val (account_info_v14.confirmation_height), MDB_APPEND);
i_account.from_first_database ? ++account_counters.after_v0 : ++account_counters.after_v1;
}
logger.always_log ("Finished extracting confirmation height to its own database");
debug_assert (account_counters.are_equal ());
// No longer need accounts_v1, keep v0 but clear it
mdb_drop (env.tx (transaction_a), accounts_v1, 1);
mdb_drop (env.tx (transaction_a), accounts_v0, 0);
for (auto const & account_account_info_pair : account_infos)
{
auto const & account_info (account_account_info_pair.second);
mdb_put (env.tx (transaction_a), accounts, ysu::mdb_val (account_account_info_pair.first), ysu::mdb_val (account_info), MDB_APPEND);
}
logger.always_log ("Epoch merge upgrade: Finished accounts, now doing state blocks");
account_infos.clear ();
// Have to create a new database as we are iterating over the existing ones and want to use MDB_APPEND for quick insertion
MDB_dbi state_blocks_new;
mdb_dbi_open (env.tx (transaction_a), "state_blocks", MDB_CREATE, &state_blocks_new);
upgrade_counters state_counters (count (transaction_a, state_blocks_v0), count (transaction_a, state_blocks_v1));
ysu::mdb_merge_iterator<ysu::block_hash, ysu::state_block_w_sideband_v14> i_state (transaction_a, state_blocks_v0, state_blocks_v1);
ysu::mdb_merge_iterator<ysu::block_hash, ysu::state_block_w_sideband_v14> n_state{};
auto num = 0u;
for (; i_state != n_state; ++i_state, ++num)
{
ysu::block_hash hash (i_state->first);
ysu::state_block_w_sideband_v14 state_block_w_sideband_v14 (i_state->second);
auto & sideband_v14 = state_block_w_sideband_v14.sideband;
ysu::block_sideband_v18 sideband (sideband_v14.account, sideband_v14.successor, sideband_v14.balance, sideband_v14.height, sideband_v14.timestamp, i_state.from_first_database ? ysu::epoch::epoch_0 : ysu::epoch::epoch_1, false, false, false);
// Write these out
std::vector<uint8_t> data;
{
ysu::vectorstream stream (data);
state_block_w_sideband_v14.state_block->serialize (stream);
sideband.serialize (stream, sideband_v14.type);
}
ysu::mdb_val value{ data.size (), (void *)data.data () };
auto s = mdb_put (env.tx (transaction_a), state_blocks_new, ysu::mdb_val (hash), value, MDB_APPEND);
release_assert (success (s));
// Every so often output to the log to indicate progress
constexpr auto output_cutoff = 1000000;
if (num % output_cutoff == 0 && num != 0)
{
logger.always_log (boost::str (boost::format ("Database epoch merge upgrade %1% million state blocks upgraded") % (num / output_cutoff)));
}
i_state.from_first_database ? ++state_counters.after_v0 : ++state_counters.after_v1;
}
debug_assert (state_counters.are_equal ());
logger.always_log ("Epoch merge upgrade: Finished state blocks, now doing pending blocks");
state_blocks = state_blocks_new;
// No longer need states v0/v1 databases
mdb_drop (env.tx (transaction_a), state_blocks_v1, 1);
mdb_drop (env.tx (transaction_a), state_blocks_v0, 1);
state_blocks_v0 = state_blocks;
upgrade_counters pending_counters (count (transaction_a, pending_v0), count (transaction_a, pending_v1));
std::vector<std::pair<ysu::pending_key, ysu::pending_info>> pending_infos;
pending_infos.reserve (pending_counters.before_v0 + pending_counters.before_v1);
ysu::mdb_merge_iterator<ysu::pending_key, ysu::pending_info_v14> i_pending (transaction_a, pending_v0, pending_v1);
ysu::mdb_merge_iterator<ysu::pending_key, ysu::pending_info_v14> n_pending{};
for (; i_pending != n_pending; ++i_pending)
{
ysu::pending_info_v14 info (i_pending->second);
pending_infos.emplace_back (ysu::pending_key (i_pending->first), ysu::pending_info{ info.source, info.amount, i_pending.from_first_database ? ysu::epoch::epoch_0 : ysu::epoch::epoch_1 });
i_pending.from_first_database ? ++pending_counters.after_v0 : ++pending_counters.after_v1;
}
debug_assert (pending_counters.are_equal ());
// No longer need the pending v1 table
mdb_drop (env.tx (transaction_a), pending_v1, 1);
mdb_drop (env.tx (transaction_a), pending_v0, 0);
for (auto const & pending_key_pending_info_pair : pending_infos)
{
mdb_put (env.tx (transaction_a), pending, ysu::mdb_val (pending_key_pending_info_pair.first), ysu::mdb_val (pending_key_pending_info_pair.second), MDB_APPEND);
}
version_put (transaction_a, 15);
logger.always_log ("Finished epoch merge upgrade");
}
void ysu::mdb_store::upgrade_v15_to_v16 (ysu::write_transaction const & transaction_a)
{
// Representation table is no longer used
debug_assert (representation != 0);
if (representation != 0)
{
auto status (mdb_drop (env.tx (transaction_a), representation, 1));
release_assert (status == MDB_SUCCESS);
representation = 0;
}
version_put (transaction_a, 16);
}
void ysu::mdb_store::upgrade_v16_to_v17 (ysu::write_transaction const & transaction_a)
{
logger.always_log ("Preparing v16 to v17 database upgrade...");
auto account_info_i = accounts_begin (transaction_a);
auto account_info_n = accounts_end ();
// Set the confirmed frontier for each account in the confirmation height table
std::vector<std::pair<ysu::account, ysu::confirmation_height_info>> confirmation_height_infos;
auto num = 0u;
for (ysu::mdb_iterator<ysu::account, uint64_t> i (transaction_a, confirmation_height), n (ysu::mdb_iterator<ysu::account, uint64_t>{}); i != n; ++i, ++account_info_i, ++num)
{
ysu::account account (i->first);
uint64_t confirmation_height (i->second);
// Check account hashes matches both the accounts table and confirmation height table
debug_assert (account == account_info_i->first);
auto const & account_info = account_info_i->second;
if (confirmation_height == 0)
{
confirmation_height_infos.emplace_back (account, confirmation_height_info{ 0, ysu::block_hash (0) });
}
else
{
if (account_info_i->second.block_count / 2 >= confirmation_height)
{
// The confirmation height of the account is closer to the bottom of the chain, so start there and work up
auto block = block_get_v18 (transaction_a, account_info.open_block);
debug_assert (block);
auto height = 1;
while (height != confirmation_height)
{
block = block_get_v18 (transaction_a, block->sideband ().successor);
debug_assert (block);
++height;
}
debug_assert (block->sideband ().height == confirmation_height);
confirmation_height_infos.emplace_back (account, confirmation_height_info{ confirmation_height, block->hash () });
}
else
{
// The confirmation height of the account is closer to the top of the chain so start there and work down
auto block = block_get_v18 (transaction_a, account_info.head);
auto height = block->sideband ().height;
while (height != confirmation_height)
{
block = block_get_v18 (transaction_a, block->previous ());
debug_assert (block);
--height;
}
confirmation_height_infos.emplace_back (account, confirmation_height_info{ confirmation_height, block->hash () });
}
}
// Every so often output to the log to indicate progress (every 200k accounts)
constexpr auto output_cutoff = 200000;
if (num % output_cutoff == 0 && num != 0)
{
logger.always_log (boost::str (boost::format ("Confirmation height frontier set for %1%00k accounts") % ((num / output_cutoff) * 2)));
}
}
// Clear it then append
auto status (mdb_drop (env.tx (transaction_a), confirmation_height, 0));
release_assert (status == MDB_SUCCESS);
for (auto const & confirmation_height_info_pair : confirmation_height_infos)
{
mdb_put (env.tx (transaction_a), confirmation_height, ysu::mdb_val (confirmation_height_info_pair.first), ysu::mdb_val (confirmation_height_info_pair.second), MDB_APPEND);
}
version_put (transaction_a, 17);
logger.always_log ("Finished upgrading confirmation height frontiers");
}
void ysu::mdb_store::upgrade_v17_to_v18 (ysu::write_transaction const & transaction_a)
{
logger.always_log ("Preparing v17 to v18 database upgrade...");
auto count_pre (count (transaction_a, state_blocks));
auto num = 0u;
for (ysu::mdb_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::state_block>> state_i (transaction_a, state_blocks), state_n{}; state_i != state_n; ++state_i, ++num)
{
ysu::block_w_sideband_v18<ysu::state_block> block_w_sideband (state_i->second);
auto & block (block_w_sideband.block);
auto & sideband (block_w_sideband.sideband);
bool is_send{ false };
bool is_receive{ false };
bool is_epoch{ false };
ysu::amount prev_balance (0);
if (!block->hashables.previous.is_zero ())
{
prev_balance = block_balance_v18 (transaction_a, block->hashables.previous);
}
if (block->hashables.balance == prev_balance && network_params.ledger.epochs.is_epoch_link (block->hashables.link))
{
is_epoch = true;
}
else if (block->hashables.balance < prev_balance)
{
is_send = true;
}
else if (!block->hashables.link.is_zero ())
{
is_receive = true;
}
ysu::block_sideband_v18 new_sideband (sideband.account, sideband.successor, sideband.balance, sideband.height, sideband.timestamp, sideband.details.epoch, is_send, is_receive, is_epoch);
// Write these out
std::vector<uint8_t> data;
{
ysu::vectorstream stream (data);
block->serialize (stream);
new_sideband.serialize (stream, block->type ());
}
ysu::mdb_val value{ data.size (), (void *)data.data () };
auto s = mdb_cursor_put (state_i.cursor, state_i->first, value, MDB_CURRENT);
release_assert (success (s));
// Every so often output to the log to indicate progress
constexpr auto output_cutoff = 1000000;
if (num > 0 && num % output_cutoff == 0)
{
logger.always_log (boost::str (boost::format ("Database sideband upgrade %1% million state blocks upgraded (out of %2%)") % (num / output_cutoff) % count_pre));
}
}
auto count_post (count (transaction_a, state_blocks));
release_assert (count_pre == count_post);
version_put (transaction_a, 18);
logger.always_log ("Finished upgrading the sideband");
}
void ysu::mdb_store::upgrade_v18_to_v19 (ysu::write_transaction const & transaction_a)
{
logger.always_log ("Preparing v18 to v19 database upgrade...");
auto count_pre (count (transaction_a, state_blocks) + count (transaction_a, send_blocks) + count (transaction_a, receive_blocks) + count (transaction_a, change_blocks) + count (transaction_a, open_blocks));
// Combine in order of likeliness of counts
std::map<ysu::block_hash, ysu::block_w_sideband> legacy_open_receive_change_blocks;
for (auto i (ysu::store_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::change_block>> (std::make_unique<ysu::mdb_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::change_block>>> (transaction_a, change_blocks))), n (ysu::store_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::change_block>> (nullptr)); i != n; ++i)
{
ysu::block_sideband_v18 const & old_sideband (i->second.sideband);
ysu::block_sideband new_sideband (old_sideband.account, old_sideband.successor, old_sideband.balance, old_sideband.height, old_sideband.timestamp, ysu::epoch::epoch_0, false, false, false, ysu::epoch::epoch_0);
legacy_open_receive_change_blocks[i->first] = { ysu::block_w_sideband{ i->second.block, new_sideband } };
}
for (auto i (ysu::store_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::open_block>> (std::make_unique<ysu::mdb_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::open_block>>> (transaction_a, open_blocks))), n (ysu::store_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::open_block>> (nullptr)); i != n; ++i)
{
ysu::block_sideband_v18 const & old_sideband (i->second.sideband);
ysu::block_sideband new_sideband (old_sideband.account, old_sideband.successor, old_sideband.balance, old_sideband.height, old_sideband.timestamp, ysu::epoch::epoch_0, false, false, false, ysu::epoch::epoch_0);
legacy_open_receive_change_blocks[i->first] = { ysu::block_w_sideband{ i->second.block, new_sideband } };
}
for (auto i (ysu::store_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::receive_block>> (std::make_unique<ysu::mdb_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::receive_block>>> (transaction_a, receive_blocks))), n (ysu::store_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::receive_block>> (nullptr)); i != n; ++i)
{
ysu::block_sideband_v18 const & old_sideband (i->second.sideband);
ysu::block_sideband new_sideband (old_sideband.account, old_sideband.successor, old_sideband.balance, old_sideband.height, old_sideband.timestamp, ysu::epoch::epoch_0, false, false, false, ysu::epoch::epoch_0);
legacy_open_receive_change_blocks[i->first] = { ysu::block_w_sideband{ i->second.block, new_sideband } };
}
release_assert (!mdb_drop (env.tx (transaction_a), receive_blocks, 1));
receive_blocks = 0;
release_assert (!mdb_drop (env.tx (transaction_a), open_blocks, 1));
open_blocks = 0;
release_assert (!mdb_drop (env.tx (transaction_a), change_blocks, 1));
change_blocks = 0;
logger.always_log ("Write legacy open/receive/change to new format");
MDB_dbi temp_legacy_open_receive_change_blocks;
{
mdb_dbi_open (env.tx (transaction_a), "temp_legacy_open_receive_change_blocks", MDB_CREATE, &temp_legacy_open_receive_change_blocks);
for (auto const & legacy_block : legacy_open_receive_change_blocks)
{
std::vector<uint8_t> data;
{
ysu::vectorstream stream (data);
ysu::serialize_block (stream, *legacy_block.second.block);
legacy_block.second.sideband.serialize (stream, legacy_block.second.block->type ());
}
ysu::mdb_val value{ data.size (), (void *)data.data () };
auto s = mdb_put (env.tx (transaction_a), temp_legacy_open_receive_change_blocks, ysu::mdb_val (legacy_block.first), value, MDB_APPEND);
release_assert (success (s));
}
}
logger.always_log ("Write legacy send to new format");
// Write send blocks to a new table (this was not done in memory as it would push us above memory requirements)
MDB_dbi temp_legacy_send_blocks;
{
mdb_dbi_open (env.tx (transaction_a), "temp_legacy_send_blocks", MDB_CREATE, &temp_legacy_send_blocks);
for (auto i (ysu::store_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::send_block>> (std::make_unique<ysu::mdb_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::send_block>>> (transaction_a, send_blocks))), n (ysu::store_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::send_block>> (nullptr)); i != n; ++i)
{
auto const & block_w_sideband_v18 (i->second);
std::vector<uint8_t> data;
{
ysu::vectorstream stream (data);
ysu::serialize_block (stream, *block_w_sideband_v18.block);
block_w_sideband_v18.sideband.serialize (stream, ysu::block_type::send); // Equal to new version for legacy blocks
}
ysu::mdb_val value{ data.size (), (void *)data.data () };
auto s = mdb_put (env.tx (transaction_a), temp_legacy_send_blocks, ysu::mdb_val (i->first), value, MDB_APPEND);
release_assert (success (s));
}
}
release_assert (!mdb_drop (env.tx (transaction_a), send_blocks, 1));
send_blocks = 0;
logger.always_log ("Merge legacy open/receive/change with legacy send blocks");
MDB_dbi temp_legacy_send_open_receive_change_blocks;
{
mdb_dbi_open (env.tx (transaction_a), "temp_legacy_send_open_receive_change_blocks", MDB_CREATE, &temp_legacy_send_open_receive_change_blocks);
ysu::mdb_merge_iterator<ysu::block_hash, ysu::block_w_sideband> i (transaction_a, temp_legacy_open_receive_change_blocks, temp_legacy_send_blocks);
ysu::mdb_merge_iterator<ysu::block_hash, ysu::block_w_sideband> n{};
for (; i != n; ++i)
{
auto s = mdb_put (env.tx (transaction_a), temp_legacy_send_open_receive_change_blocks, ysu::mdb_val (i->first), ysu::mdb_val (i->second), MDB_APPEND);
release_assert (success (s));
}
// Delete tables
mdb_drop (env.tx (transaction_a), temp_legacy_send_blocks, 1);
mdb_drop (env.tx (transaction_a), temp_legacy_open_receive_change_blocks, 1);
}
logger.always_log ("Write state blocks to new format");
// Write state blocks to a new table (this was not done in memory as it would push us above memory requirements)
MDB_dbi temp_state_blocks;
{
auto type_state (ysu::block_type::state);
mdb_dbi_open (env.tx (transaction_a), "temp_state_blocks", MDB_CREATE, &temp_state_blocks);
for (auto i (ysu::store_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::state_block>> (std::make_unique<ysu::mdb_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::state_block>>> (transaction_a, state_blocks))), n (ysu::store_iterator<ysu::block_hash, ysu::block_w_sideband_v18<ysu::state_block>> (nullptr)); i != n; ++i)
{
auto const & block_w_sideband_v18 (i->second);
ysu::block_sideband_v18 const & old_sideband (block_w_sideband_v18.sideband);
ysu::epoch source_epoch (ysu::epoch::epoch_0);
// Source block v18 epoch
if (old_sideband.details.is_receive)
{
auto db_val (block_raw_get_by_type_v18 (transaction_a, block_w_sideband_v18.block->link ().as_block_hash (), type_state));
if (db_val.is_initialized ())
{
ysu::bufferstream stream (reinterpret_cast<uint8_t const *> (db_val.get ().data ()), db_val.get ().size ());
auto source_block (ysu::deserialize_block (stream, type_state));
release_assert (source_block != nullptr);
ysu::block_sideband_v18 source_sideband;
auto error (source_sideband.deserialize (stream, type_state));
release_assert (!error);
source_epoch = source_sideband.details.epoch;
}
}
ysu::block_sideband new_sideband (old_sideband.account, old_sideband.successor, old_sideband.balance, old_sideband.height, old_sideband.timestamp, old_sideband.details.epoch, old_sideband.details.is_send, old_sideband.details.is_receive, old_sideband.details.is_epoch, source_epoch);
std::vector<uint8_t> data;
{
ysu::vectorstream stream (data);
ysu::serialize_block (stream, *block_w_sideband_v18.block);
new_sideband.serialize (stream, ysu::block_type::state);
}
ysu::mdb_val value{ data.size (), (void *)data.data () };
auto s = mdb_put (env.tx (transaction_a), temp_state_blocks, ysu::mdb_val (i->first), value, MDB_APPEND);
release_assert (success (s));
}
}
release_assert (!mdb_drop (env.tx (transaction_a), state_blocks, 1));
state_blocks = 0;
logger.always_log ("Merging all legacy blocks with state blocks");
// Merge all legacy blocks with state blocks into the final table
ysu::mdb_merge_iterator<ysu::block_hash, ysu::block_w_sideband> i (transaction_a, temp_legacy_send_open_receive_change_blocks, temp_state_blocks);
ysu::mdb_merge_iterator<ysu::block_hash, ysu::block_w_sideband> n{};
mdb_dbi_open (env.tx (transaction_a), "blocks", MDB_CREATE, &blocks);
for (; i != n; ++i)
{
auto s = mdb_put (env.tx (transaction_a), blocks, ysu::mdb_val (i->first), ysu::mdb_val (i->second), MDB_APPEND);
release_assert (success (s));
}
// Delete tables
mdb_drop (env.tx (transaction_a), temp_legacy_send_open_receive_change_blocks, 1);
mdb_drop (env.tx (transaction_a), temp_state_blocks, 1);
auto count_post (count (transaction_a, blocks));
release_assert (count_pre == count_post);
version_put (transaction_a, 19);
logger.always_log ("Finished upgrading all blocks to new blocks database");
}
void ysu::mdb_store::upgrade_v19_to_v20 (ysu::write_transaction const & transaction_a)
{
logger.always_log ("Preparing v19 to v20 database upgrade...");
mdb_dbi_open (env.tx (transaction_a), "pruned", MDB_CREATE, &pruned);
version_put (transaction_a, 20);
logger.always_log ("Finished creating new pruned table");
}
/** Takes a filepath, appends '_backup_<timestamp>' to the end (but before any extension) and saves that file in the same directory */
void ysu::mdb_store::create_backup_file (ysu::mdb_env & env_a, boost::filesystem::path const & filepath_a, ysu::logger_mt & logger_a)
{
auto extension = filepath_a.extension ();
auto filename_without_extension = filepath_a.filename ().replace_extension ("");
auto orig_filepath = filepath_a;
auto & backup_path = orig_filepath.remove_filename ();
auto backup_filename = filename_without_extension;
backup_filename += "_backup_";
backup_filename += std::to_string (std::chrono::system_clock::now ().time_since_epoch ().count ());
backup_filename += extension;
auto backup_filepath = backup_path / backup_filename;
auto start_message (boost::str (boost::format ("Performing %1% backup before database upgrade...") % filepath_a.filename ()));
logger_a.always_log (start_message);
std::cout << start_message << std::endl;
auto error (mdb_env_copy (env_a, backup_filepath.string ().c_str ()));
if (error)
{
auto error_message (boost::str (boost::format ("%1% backup failed") % filepath_a.filename ()));
logger_a.always_log (error_message);
std::cerr << error_message << std::endl;
std::exit (1);
}
else
{
auto success_message (boost::str (boost::format ("Backup created: %1%") % backup_filename));
logger_a.always_log (success_message);
std::cout << success_message << std::endl;
}
}
std::vector<ysu::unchecked_info> ysu::mdb_store::unchecked_get (ysu::transaction const & transaction_a, ysu::block_hash const & hash_a)
{
std::vector<ysu::unchecked_info> result;
for (auto i (unchecked_begin (transaction_a, ysu::unchecked_key (hash_a, 0))), n (unchecked_end ()); i != n && i->first.key () == hash_a; ++i)
{
ysu::unchecked_info const & unchecked_info (i->second);
result.push_back (unchecked_info);
}
return result;
}
void ysu::mdb_store::version_put (ysu::write_transaction const & transaction_a, int version_a)
{
ysu::uint256_union version_key (1);
ysu::uint256_union version_value (version_a);
auto status (mdb_put (env.tx (transaction_a), meta, ysu::mdb_val (version_key), ysu::mdb_val (version_value), 0));
release_assert (status == 0);
}
bool ysu::mdb_store::exists (ysu::transaction const & transaction_a, tables table_a, ysu::mdb_val const & key_a) const
{
ysu::mdb_val junk;
auto status = get (transaction_a, table_a, key_a, junk);
release_assert (status == MDB_SUCCESS || status == MDB_NOTFOUND);
return (status == MDB_SUCCESS);
}
int ysu::mdb_store::get (ysu::transaction const & transaction_a, tables table_a, ysu::mdb_val const & key_a, ysu::mdb_val & value_a) const
{
return mdb_get (env.tx (transaction_a), table_to_dbi (table_a), key_a, value_a);
}
int ysu::mdb_store::put (ysu::write_transaction const & transaction_a, tables table_a, ysu::mdb_val const & key_a, const ysu::mdb_val & value_a) const
{
return (mdb_put (env.tx (transaction_a), table_to_dbi (table_a), key_a, value_a, 0));
}
int ysu::mdb_store::del (ysu::write_transaction const & transaction_a, tables table_a, ysu::mdb_val const & key_a) const
{
return (mdb_del (env.tx (transaction_a), table_to_dbi (table_a), key_a, nullptr));
}
int ysu::mdb_store::drop (ysu::write_transaction const & transaction_a, tables table_a)
{
return clear (transaction_a, table_to_dbi (table_a));
}
int ysu::mdb_store::clear (ysu::write_transaction const & transaction_a, MDB_dbi handle_a)
{
return mdb_drop (env.tx (transaction_a), handle_a, 0);
}
uint64_t ysu::mdb_store::count (ysu::transaction const & transaction_a, tables table_a) const
{
return count (transaction_a, table_to_dbi (table_a));
}
uint64_t ysu::mdb_store::count (ysu::transaction const & transaction_a, MDB_dbi db_a) const
{
MDB_stat stats;
auto status (mdb_stat (env.tx (transaction_a), db_a, &stats));
release_assert (status == 0);
return (stats.ms_entries);
}
MDB_dbi ysu::mdb_store::table_to_dbi (tables table_a) const
{
switch (table_a)
{
case tables::frontiers:
return frontiers;
case tables::accounts:
return accounts;
case tables::blocks:
return blocks;
case tables::pending:
return pending;
case tables::unchecked:
return unchecked;
case tables::vote:
return vote;
case tables::online_weight:
return online_weight;
case tables::meta:
return meta;
case tables::peers:
return peers;
case tables::pruned:
return pruned;
case tables::confirmation_height:
return confirmation_height;
default:
release_assert (false);
return peers;
}
}
bool ysu::mdb_store::not_found (int status) const
{
return (status_code_not_found () == status);
}
bool ysu::mdb_store::success (int status) const
{
return (MDB_SUCCESS == status);
}
int ysu::mdb_store::status_code_not_found () const
{
return MDB_NOTFOUND;
}
bool ysu::mdb_store::copy_db (boost::filesystem::path const & destination_file)
{
return !mdb_env_copy2 (env.environment, destination_file.string ().c_str (), MDB_CP_COMPACT);
}
void ysu::mdb_store::rebuild_db (ysu::write_transaction const & transaction_a)
{
// Tables with uint256_union key
std::vector<MDB_dbi> tables = { accounts, blocks, vote, pruned, confirmation_height };
for (auto const & table : tables)
{
MDB_dbi temp;
mdb_dbi_open (env.tx (transaction_a), "temp_table", MDB_CREATE, &temp);
// Copy all values to temporary table
for (auto i (ysu::store_iterator<ysu::uint256_union, ysu::mdb_val> (std::make_unique<ysu::mdb_iterator<ysu::uint256_union, ysu::mdb_val>> (transaction_a, table))), n (ysu::store_iterator<ysu::uint256_union, ysu::mdb_val> (nullptr)); i != n; ++i)
{
auto s = mdb_put (env.tx (transaction_a), temp, ysu::mdb_val (i->first), i->second, MDB_APPEND);
release_assert (success (s));
}
release_assert (count (transaction_a, table) == count (transaction_a, temp));
// Clear existing table
mdb_drop (env.tx (transaction_a), table, 0);
// Put values from copy
for (auto i (ysu::store_iterator<ysu::uint256_union, ysu::mdb_val> (std::make_unique<ysu::mdb_iterator<ysu::uint256_union, ysu::mdb_val>> (transaction_a, temp))), n (ysu::store_iterator<ysu::uint256_union, ysu::mdb_val> (nullptr)); i != n; ++i)
{
auto s = mdb_put (env.tx (transaction_a), table, ysu::mdb_val (i->first), i->second, MDB_APPEND);
release_assert (success (s));
}
release_assert (count (transaction_a, table) == count (transaction_a, temp));
// Remove temporary table
mdb_drop (env.tx (transaction_a), temp, 1);
}
// Pending table
{
MDB_dbi temp;
mdb_dbi_open (env.tx (transaction_a), "temp_table", MDB_CREATE, &temp);
// Copy all values to temporary table
for (auto i (ysu::store_iterator<ysu::pending_key, ysu::pending_info> (std::make_unique<ysu::mdb_iterator<ysu::pending_key, ysu::pending_info>> (transaction_a, pending))), n (ysu::store_iterator<ysu::pending_key, ysu::pending_info> (nullptr)); i != n; ++i)
{
auto s = mdb_put (env.tx (transaction_a), temp, ysu::mdb_val (i->first), ysu::mdb_val (i->second), MDB_APPEND);
release_assert (success (s));
}
release_assert (count (transaction_a, pending) == count (transaction_a, temp));
mdb_drop (env.tx (transaction_a), pending, 0);
// Put values from copy
for (auto i (ysu::store_iterator<ysu::pending_key, ysu::pending_info> (std::make_unique<ysu::mdb_iterator<ysu::pending_key, ysu::pending_info>> (transaction_a, temp))), n (ysu::store_iterator<ysu::pending_key, ysu::pending_info> (nullptr)); i != n; ++i)
{
auto s = mdb_put (env.tx (transaction_a), pending, ysu::mdb_val (i->first), ysu::mdb_val (i->second), MDB_APPEND);
release_assert (success (s));
}
release_assert (count (transaction_a, pending) == count (transaction_a, temp));
mdb_drop (env.tx (transaction_a), temp, 1);
}
}
bool ysu::mdb_store::init_error () const
{
return error;
}
std::shared_ptr<ysu::block> ysu::mdb_store::block_get_v18 (ysu::transaction const & transaction_a, ysu::block_hash const & hash_a) const
{
ysu::block_type type;
auto value (block_raw_get_v18 (transaction_a, hash_a, type));
std::shared_ptr<ysu::block> result;
if (value.size () != 0)
{
ysu::bufferstream stream (reinterpret_cast<uint8_t const *> (value.data ()), value.size ());
result = ysu::deserialize_block (stream, type);
release_assert (result != nullptr);
ysu::block_sideband_v18 sideband;
auto error = (sideband.deserialize (stream, type));
release_assert (!error);
result->sideband_set (ysu::block_sideband (sideband.account, sideband.successor, sideband.balance, sideband.height, sideband.timestamp, sideband.details.epoch, sideband.details.is_send, sideband.details.is_receive, sideband.details.is_epoch, ysu::epoch::epoch_0));
}
return result;
}
ysu::mdb_val ysu::mdb_store::block_raw_get_v18 (ysu::transaction const & transaction_a, ysu::block_hash const & hash_a, ysu::block_type & type_a) const
{
ysu::mdb_val result;
// Table lookups are ordered by match probability
ysu::block_type block_types[]{ ysu::block_type::state, ysu::block_type::send, ysu::block_type::receive, ysu::block_type::open, ysu::block_type::change };
for (auto current_type : block_types)
{
auto db_val (block_raw_get_by_type_v18 (transaction_a, hash_a, current_type));
if (db_val.is_initialized ())
{
type_a = current_type;
result = db_val.get ();
break;
}
}
return result;
}
boost::optional<ysu::mdb_val> ysu::mdb_store::block_raw_get_by_type_v18 (ysu::transaction const & transaction_a, ysu::block_hash const & hash_a, ysu::block_type & type_a) const
{
ysu::mdb_val value;
ysu::mdb_val hash (hash_a);
int status = status_code_not_found ();
switch (type_a)
{
case ysu::block_type::send:
{
status = mdb_get (env.tx (transaction_a), send_blocks, hash, value);
break;
}
case ysu::block_type::receive:
{
status = mdb_get (env.tx (transaction_a), receive_blocks, hash, value);
break;
}
case ysu::block_type::open:
{
status = mdb_get (env.tx (transaction_a), open_blocks, hash, value);
break;
}
case ysu::block_type::change:
{
status = mdb_get (env.tx (transaction_a), change_blocks, hash, value);
break;
}
case ysu::block_type::state:
{
status = mdb_get (env.tx (transaction_a), state_blocks, hash, value);
break;
}
case ysu::block_type::invalid:
case ysu::block_type::not_a_block:
{
break;
}
}
release_assert (success (status) || not_found (status));
boost::optional<ysu::mdb_val> result;
if (success (status))
{
result = value;
}
return result;
}
ysu::uint128_t ysu::mdb_store::block_balance_v18 (ysu::transaction const & transaction_a, ysu::block_hash const & hash_a) const
{
auto block (block_get_v18 (transaction_a, hash_a));
release_assert (block);
ysu::uint128_t result (block_balance_calculated (block));
return result;
}
// All the v14 functions below are only needed during upgrades
size_t ysu::mdb_store::block_successor_offset_v14 (ysu::transaction const & transaction_a, size_t entry_size_a, ysu::block_type type_a) const
{
return entry_size_a - ysu::block_sideband_v14::size (type_a);
}
ysu::block_hash ysu::mdb_store::block_successor_v14 (ysu::transaction const & transaction_a, ysu::block_hash const & hash_a) const
{
ysu::block_type type;
auto value (block_raw_get_v14 (transaction_a, hash_a, type));
ysu::block_hash result;
if (value.size () != 0)
{
debug_assert (value.size () >= result.bytes.size ());
ysu::bufferstream stream (reinterpret_cast<uint8_t const *> (value.data ()) + block_successor_offset_v14 (transaction_a, value.size (), type), result.bytes.size ());
auto error (ysu::try_read (stream, result.bytes));
(void)error;
debug_assert (!error);
}
else
{
result.clear ();
}
return result;
}
ysu::mdb_val ysu::mdb_store::block_raw_get_v14 (ysu::transaction const & transaction_a, ysu::block_hash const & hash_a, ysu::block_type & type_a, bool * is_state_v1) const
{
ysu::mdb_val result;
// Table lookups are ordered by match probability
ysu::block_type block_types[]{ ysu::block_type::state, ysu::block_type::send, ysu::block_type::receive, ysu::block_type::open, ysu::block_type::change };
for (auto current_type : block_types)
{
auto db_val (block_raw_get_by_type_v14 (transaction_a, hash_a, current_type, is_state_v1));
if (db_val.is_initialized ())
{
type_a = current_type;
result = db_val.get ();
break;
}
}
return result;
}
boost::optional<ysu::mdb_val> ysu::mdb_store::block_raw_get_by_type_v14 (ysu::transaction const & transaction_a, ysu::block_hash const & hash_a, ysu::block_type & type_a, bool * is_state_v1) const
{
ysu::mdb_val value;
ysu::mdb_val hash (hash_a);
int status = status_code_not_found ();
switch (type_a)
{
case ysu::block_type::send:
{
status = mdb_get (env.tx (transaction_a), send_blocks, hash, value);
break;
}
case ysu::block_type::receive:
{
status = mdb_get (env.tx (transaction_a), receive_blocks, hash, value);
break;
}
case ysu::block_type::open:
{
status = mdb_get (env.tx (transaction_a), open_blocks, hash, value);
break;
}
case ysu::block_type::change:
{
status = mdb_get (env.tx (transaction_a), change_blocks, hash, value);
break;
}
case ysu::block_type::state:
{
status = mdb_get (env.tx (transaction_a), state_blocks_v1, hash, value);
if (is_state_v1 != nullptr)
{
*is_state_v1 = success (status);
}
if (not_found (status))
{
status = mdb_get (env.tx (transaction_a), state_blocks_v0, hash, value);
}
break;
}
case ysu::block_type::invalid:
case ysu::block_type::not_a_block:
{
break;
}
}
release_assert (success (status) || not_found (status));
boost::optional<ysu::mdb_val> result;
if (success (status))
{
result = value;
}
return result;
}
std::shared_ptr<ysu::block> ysu::mdb_store::block_get_v14 (ysu::transaction const & transaction_a, ysu::block_hash const & hash_a, ysu::block_sideband_v14 * sideband_a, bool * is_state_v1) const
{
ysu::block_type type;
auto value (block_raw_get_v14 (transaction_a, hash_a, type, is_state_v1));
std::shared_ptr<ysu::block> result;
if (value.size () != 0)
{
ysu::bufferstream stream (reinterpret_cast<uint8_t const *> (value.data ()), value.size ());
result = ysu::deserialize_block (stream, type);
debug_assert (result != nullptr);
if (sideband_a)
{
sideband_a->type = type;
bool error = sideband_a->deserialize (stream);
(void)error;
debug_assert (!error);
}
}
return result;
}
ysu::mdb_store::upgrade_counters::upgrade_counters (uint64_t count_before_v0, uint64_t count_before_v1) :
before_v0 (count_before_v0),
before_v1 (count_before_v1)
{
}
bool ysu::mdb_store::upgrade_counters::are_equal () const
{
return (before_v0 == after_v0) && (before_v1 == after_v1);
}
unsigned ysu::mdb_store::max_block_write_batch_num () const
{
return std::numeric_limits<unsigned>::max ();
}
// Explicitly instantiate
template class ysu::block_store_partial<MDB_val, ysu::mdb_store>;
| [
"i5@f4x.ru"
] | i5@f4x.ru |
f9ddcd49395da76acc931f82034f70532c8d25f9 | efce24cfed25c19944f4cb74566b4de0d3473d32 | /30 Days of Code/Day 1 Data Types.cpp | 61fcafd885de1266336413ff954988286706f265 | [] | no_license | johngillard15/HackerRank | b60830b73d79642847924cb383c6ab0d99136289 | ee2c44f0243fab9a558d88104f659ad5cdcfe91c | refs/heads/master | 2023-08-17T08:03:13.774586 | 2021-09-26T19:49:42 | 2021-09-26T19:49:42 | 379,402,797 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 902 | cpp | #include <iostream>
#include <iomanip>
#include <limits>
using namespace std;
int main() {
int i = 4;
double d = 4.0;
string s = "HackerRank ";
// Declare second integer, double, and String variables.
int x;
double y;
string z;
// Read and save an integer, double, and String to your variables.
// Note: If you have trouble reading the entire string, please go back and review the Tutorial closely.
cin >> x;
cin >> y;
cin.ignore();
getline(cin, z);
// Print the sum of both integer variables on a new line.
cout << i + x << endl;
// Print the sum of the double variables on a new line.
cout << fixed << setprecision(1)
<< d + y << endl;
// Concatenate and print the String variables on a new line
// The 's' variable above should be printed first.
cout << s + z << endl;
return 0; | [
"johngillard15@gmail.com"
] | johngillard15@gmail.com |
c5e596be4b15133db5629773cdb1315c81fde591 | c398aca1cd9806b1ec74667115e63a5c211b495a | /Classes/HelloWorldScene.h | aef198e477ca4744c0b0aa27cced96d031944f48 | [] | no_license | loathehao/FinalGame | bc34b4a0c0575c244a55e6fc699009d5a8e86527 | 7f581dfbc429119ba3f3d15969dc7578137c84a6 | refs/heads/master | 2020-07-17T19:52:13.046061 | 2017-06-14T12:13:54 | 2017-06-14T12:13:54 | 94,323,123 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 636 | h | #ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
class HelloWorld : public cocos2d::Layer
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
void menuPrintCallback();
void menuItemToggle(Ref* pSender);
void menuItemStartCallback(Ref* pSender);
void menuItemSettingCallback(Ref* pSender);
void menuItemLevelCallback(Ref* pSender);
void menuItemAboutCallback(Ref* pSender);
void menuCloseCallback(cocos2d::Ref* pSender);
// implement the "static create()" method manually
CREATE_FUNC(HelloWorld);
};
#endif // __HELLOWORLD_SCENE_H__
| [
"981985938@qq.com"
] | 981985938@qq.com |
b0b841c170371c302269ff3a6d53eb2ccfbcd15a | f06630352a79b74d250b1f34b3ea8720571ad58e | /src/petra/dev/src/OneFile/datastructures/queues/FAAArrayQueue.hpp | ba09b7b449ad945be2d73a974cbc9281d0587cbd | [
"MIT"
] | permissive | CLPeterson/DurableCorrectness | b57f3d28ce4cdb932506964b40b06bdb39ba843a | 5e3ae0c09f6ac9415850ae389672c50cb743262d | refs/heads/master | 2023-01-28T10:55:23.083481 | 2020-09-22T13:30:34 | 2020-09-22T13:30:34 | 285,900,349 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,066 | hpp | /******************************************************************************
* Copyright (c) 2014-2016, Pedro Ramalhete, Andreia Correia
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Concurrency Freaks nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************
*/
#ifndef _FAA_ARRAY_QUEUE_HP_H_
#define _FAA_ARRAY_QUEUE_HP_H_
#include <atomic>
#include <stdexcept>
#include "HazardPointers.hpp"
/**
* <h1> Fetch-And-Add Array Queue </h1>
*
* Each node has one array but we don't search for a vacant entry. Instead, we
* use FAA to obtain an index in the array, for enqueueing or dequeuing.
*
* There are some similarities between this queue and the basic queue in YMC:
* http://chaoran.me/assets/pdf/wfq-ppopp16.pdf
* but it's not the same because the queue in listing 1 is obstruction-free, while
* our algorithm is lock-free.
* In FAAArrayQueue eventually a new node will be inserted (using Michael-Scott's
* algorithm) and it will have an item pre-filled in the first position, which means
* that at most, after BUFFER_SIZE steps, one item will be enqueued (and it can then
* be dequeued). This kind of progress is lock-free.
*
* Each entry in the array may contain one of three possible values:
* - A valid item that has been enqueued;
* - nullptr, which means no item has yet been enqueued in that position;
* - taken, a special value that means there was an item but it has been dequeued;
*
* Enqueue algorithm: FAA + CAS(null,item)
* Dequeue algorithm: FAA + CAS(item,taken)
* Consistency: Linearizable
* enqueue() progress: lock-free
* dequeue() progress: lock-free
* Memory Reclamation: Hazard Pointers (lock-free)
* Uncontended enqueue: 1 FAA + 1 CAS + 1 HP
* Uncontended dequeue: 1 FAA + 1 CAS + 1 HP
*
*
* <p>
* Lock-Free Linked List as described in Maged Michael and Michael Scott's paper:
* {@link http://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf}
* <a href="http://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf">
* Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms</a>
* <p>
* The paper on Hazard Pointers is named "Hazard Pointers: Safe Memory
* Reclamation for Lock-Free objects" and it is available here:
* http://web.cecs.pdx.edu/~walpole/class/cs510/papers/11.pdf
*
* @author Pedro Ramalhete
* @author Andreia Correia
*/
template<typename T>
class FAAArrayQueue {
static const long BUFFER_SIZE = 1024; // 1024
private:
struct Node {
alignas(128) std::atomic<int> deqidx;
alignas(128) std::atomic<T*> items[BUFFER_SIZE];
alignas(128) std::atomic<int> enqidx;
alignas(128) std::atomic<Node*> next;
// Start with the first entry pre-filled and enqidx at 1
Node(T* item) : deqidx{0}, enqidx{1}, next{nullptr} {
items[0].store(item, std::memory_order_relaxed);
for (long i = 1; i < BUFFER_SIZE; i++) {
items[i].store(nullptr, std::memory_order_relaxed);
}
}
bool casNext(Node *cmp, Node *val) {
return next.compare_exchange_strong(cmp, val);
}
};
bool casTail(Node *cmp, Node *val) {
return tail.compare_exchange_strong(cmp, val);
}
bool casHead(Node *cmp, Node *val) {
return head.compare_exchange_strong(cmp, val);
}
// Pointers to head and tail of the list
alignas(128) std::atomic<Node*> head;
alignas(128) std::atomic<Node*> tail;
static const int MAX_THREADS = 128;
const int maxThreads;
T* taken = (T*)new int(); // Muuuahahah !
// We need just one hazard pointer
HazardPointers<Node> hp {1, maxThreads};
const int kHpTail = 0;
const int kHpHead = 0;
public:
FAAArrayQueue(int maxThreads=MAX_THREADS) : maxThreads{maxThreads} {
Node* sentinelNode = new Node(nullptr);
sentinelNode->enqidx.store(0, std::memory_order_relaxed);
head.store(sentinelNode, std::memory_order_relaxed);
tail.store(sentinelNode, std::memory_order_relaxed);
}
~FAAArrayQueue() {
while (dequeue(0) != nullptr); // Drain the queue
delete head.load(); // Delete the last node
delete (int*)taken;
}
static std::string className() { return "FAAArrayQueue"; }
void enqueue(T* item, const int tid) {
if (item == nullptr) throw std::invalid_argument("item can not be nullptr");
while (true) {
Node* ltail = hp.protect(kHpTail, tail, tid);
const int idx = ltail->enqidx.fetch_add(1);
if (idx > BUFFER_SIZE-1) { // This node is full
if (ltail != tail.load()) continue;
Node* lnext = ltail->next.load();
if (lnext == nullptr) {
Node* newNode = new Node(item);
if (ltail->casNext(nullptr, newNode)) {
casTail(ltail, newNode);
hp.clear(tid);
return;
}
delete newNode;
} else {
casTail(ltail, lnext);
}
continue;
}
T* itemnull = nullptr;
if (ltail->items[idx].compare_exchange_strong(itemnull, item)) {
hp.clear(tid);
return;
}
}
}
T* dequeue(const int tid) {
while (true) {
Node* lhead = hp.protect(kHpHead, head, tid);
if (lhead->deqidx.load() >= lhead->enqidx.load() && lhead->next.load() == nullptr) break;
const int idx = lhead->deqidx.fetch_add(1);
if (idx > BUFFER_SIZE-1) { // This node has been drained, check if there is another one
Node* lnext = lhead->next.load();
if (lnext == nullptr) break; // No more nodes in the queue
if (casHead(lhead, lnext)) hp.retire(lhead, tid);
continue;
}
T* item = lhead->items[idx].load();
if (item != nullptr) {
hp.clear(tid);
return item;
}
item = lhead->items[idx].exchange(taken);
if (item == nullptr) continue;
hp.clear(tid);
return item;
}
hp.clear(tid);
return nullptr;
}
};
#endif /* _FAA_ARRAY_QUEUE_HP_H_ */
| [
"r.izadpanah@knights.ucf.edu"
] | r.izadpanah@knights.ucf.edu |
f90ce797014ec793c5c92dd65bd44e9ce53f29aa | ba743f4b8259d96c7e3cceb24b37551942a93f89 | /savepanel.cpp | 5677972cb2d06cd1cf7dec3b611cb13f49ff66d7 | [] | no_license | younasiqw/cr0nus | b2eb1ccbba3d2f2fc14f7d79ae0580561ef132c5 | 87cf353501017091e1b344006a0f06cbff108af9 | refs/heads/master | 2021-05-10T11:15:35.352329 | 2017-10-08T11:48:42 | 2017-10-08T11:48:42 | 118,406,444 | 1 | 0 | null | 2018-01-22T04:32:08 | 2018-01-22T04:32:08 | null | UTF-8 | C++ | false | false | 13,048 | cpp | #include "sdk.h"
#include "controls.h"
#include "dirent.h"
#include "Render.h"
#include "Menu.h"
char* KeyStringsSave[254] = { "Not Bound", "Left Mouse", "Right Mouse", "Control+Break", "Middle Mouse", "Mouse 4", "Mouse 5",
nullptr, "Backspace", "TAB", nullptr, nullptr, nullptr, "ENTER", nullptr, nullptr, "SHIFT", "CTRL", "ALT", "PAUSE",
"CAPS LOCK", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "ESC", nullptr, nullptr, nullptr, nullptr, "SPACEBAR",
"PG UP", "PG DOWN", "END", "HOME", "Left", "Up", "Right", "Down", nullptr, "Print", nullptr, "Print Screen", "Insert",
"Delete", nullptr, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X",
"Y", "Z", "Left Windows", "Right Windows", nullptr, nullptr, nullptr, "NUM 0", "NUM 1", "NUM 2", "NUM 3", "NUM 4", "NUM 5", "NUM 6",
"NUM 7", "NUM 8", "NUM 9", "*", "+", "_", "-", ".", "/", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12",
"F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, "NUM LOCK", "SCROLL LOCK", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, "LSHIFT", "RSHIFT", "LCONTROL", "RCONTROL", "LMENU", "RMENU", nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "Next Track", "Previous Track", "Stop", "Play/Pause", nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, ";", "+", ",", "-", ".", "/?", "~", nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "[{", "\\|", "}]", "'\"", nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
void MSavePanel::HandleKeys(int key)
{
switch (key)
{
case VK_LSHIFT:
case VK_RSHIFT:
case VK_LCONTROL:
case VK_RCONTROL:
case VK_LEFT:
case VK_RIGHT:
case VK_CAPITAL:
case VK_LBUTTON:
case VK_RBUTTON:
return;
case VK_RETURN:
case VK_ESCAPE:
textboxactive = false;
return;
case VK_SPACE:
command.append(" ");
return;
case VK_BACK:
if (command.length() > 0)
{
command.erase(command.length() - 1);
return;
}
default:
char* KeyName = "0";
KeyName = KeyStringsSave[key];
//if (GetKeyNameText(key << 16, KeyName, 127))
if (KeyName != "Backspace" && KeyName != "SHIFT" && KeyName != "CTRL" && KeyName != "ALT")
command.append(KeyName);
return;
}
}
MSavePanel::MSavePanel(MBaseElement* parent)
{
this->parent = parent;
this->parent->AddChildControl(this);
}
char* stringToLower(char *string)
{
int i;
int len = strlen(string);
for (i = 0; i<len; i++) {
if (string[i] >= 'A' && string[i] <= 'Z') {
string[i] += 32;
}
}
return string;
}
bool bIsDigitInString(std::string pszString)
{
for (int ax = 0; ax < 9; ax++)
{
char buf[MAX_PATH];
_snprintf_s(buf, (size_t)255, "%d", ax);
if (strstr(pszString.c_str(), buf))
{
return true;
}
}
return false;
}
void MSavePanel::Draw()
{
static std::string strPath, BasePath;
static bool doOnce = true;
if (doOnce)
{
char* szPath = new char[255];
GetModuleFileNameA(GetModuleHandle(NULL), szPath, 255);
for (int i = strlen(szPath); i > 0; i--)
{
if (szPath[i] == '\\')
{
szPath[i + 1] = 0;
break;
}
}
strPath = szPath;
delete[] szPath;
BasePath = strPath;
doOnce = false;
}
int alpha = m_pMenu->alpha;
//this->position = m_pMenu->MainWindow->position;
//this->position.x += 10;
//this->position.y += m_pMenu->MainWindow->dragYoffset + 10;
//this->size.x = (m_pMenu->MainWindow->size.x - 20) / 2; //left, right and middle shit offsets
this->position = this->parent->position;
this->position.x += 10;
this->position.y += 10;
this->size.y = this->parent->size.y - 20;
/*textbox*/
int textbox_x = position.x;
int textbox_y = position.y;
int textbox_h = 20;
int textbox_w = 150;
bool bTexthover = m_pMenu->MainWindow->InBounds(Vector(textbox_x, textbox_y, 0), Vector(textbox_w, textbox_h, 0));
if (!this->textboxactive && bTexthover && m_pMenu->MainWindow->bMouse1released)
{
this->textboxactive = !this->textboxactive;
}
if (textboxactive)
g_pRender->FilledBoxOutlined(textbox_x , textbox_y , textbox_w, textbox_h, D3DCOLOR_ARGB(alpha, 55, 55, 55), BLACK(alpha));
else if (bTexthover)
g_pRender->FilledBoxOutlined(textbox_x , textbox_y, textbox_w, textbox_h , D3DCOLOR_ARGB(alpha, 45, 45, 45), BLACK(alpha));
else
g_pRender->FilledBoxOutlined(textbox_x, textbox_y, textbox_w, textbox_h, D3DCOLOR_ARGB(alpha, 35, 35, 35), BLACK(alpha));
if (this->textboxactive)
{
for (int i = 0; i < 255; i++)
{
if (m_pMenu->MainWindow->ToggleButton(i))
{
HandleKeys(i);
}
}
if (m_pMenu->MainWindow->bMouse1pressed && !m_pMenu->MainWindow->InBounds(Vector(textbox_x, textbox_y, 0), Vector(textbox_w, textbox_h, 0)))
{
this->textboxactive = false;
}
}
if (command.empty() && !(bTexthover && m_pMenu->MainWindow->bMouse1pressed) && !textboxactive)
g_pRender->Text("...New Config Name...", textbox_x + textbox_w / 2, textbox_y + textbox_h / 2 - g_pRender->menu_control_size / 2, centered, g_pRender->Fonts.menu_control, true, WHITE(alpha), BLACK(alpha));
g_pRender->Text((char*)command.c_str(), textbox_x + textbox_w/2, textbox_y +textbox_h/2 - g_pRender->menu_control_size/2, centered, g_pRender->Fonts.menu_control, true, WHITE(alpha), BLACK(alpha));
/*end textbox*/
/*save button*/
int save_new_button_x = position.x;
int save_new_button_y = position.y + 30;
int save_new_button_h = 20;
int save_new_button_w = 150;
bool save_new_button_hover = m_pMenu->MainWindow->InBounds(Vector(save_new_button_x, save_new_button_y, 0), Vector(save_new_button_w, save_new_button_h, 0));
if (save_new_button_hover && m_pMenu->MainWindow->bMouse1pressed)
g_pRender->FilledBoxOutlined(save_new_button_x, save_new_button_y, save_new_button_w, save_new_button_h, D3DCOLOR_ARGB(alpha, 55, 55, 55), BLACK(alpha));
else if (save_new_button_hover)
g_pRender->FilledBoxOutlined(save_new_button_x, save_new_button_y, save_new_button_w, save_new_button_h, D3DCOLOR_ARGB(alpha, 45, 45, 45), BLACK(alpha));
else
g_pRender->FilledBoxOutlined(save_new_button_x, save_new_button_y, save_new_button_w, save_new_button_h, D3DCOLOR_ARGB(alpha, 35, 35, 35), BLACK(alpha));
g_pRender->Text("Save new config", save_new_button_x + save_new_button_w/2, save_new_button_y + save_new_button_h/2 - g_pRender->menu_control_size/2, centered, g_pRender->Fonts.menu_control, true, WHITE(alpha), BLACK(alpha));
if (!this->textboxactive && save_new_button_hover && m_pMenu->MainWindow->bMouse1released)
{
m_pMenu->SaveWindowState(command);
command.clear();
}
/*end save button*/
/*config list getting*/
strPath = BasePath;
std::vector<string> ConfigList;
DIR *pDIR;
struct dirent *entry;
std::string buffer;
if (pDIR = opendir(strPath.c_str()))
{
while (entry = readdir(pDIR))
{
if (strstr(entry->d_name, ".xml"))
{
buffer = entry->d_name;
if (!buffer.find("_walkbot") != std::string::npos)
{
string str2 = buffer.substr(0, buffer.length() - 4);
ConfigList.push_back(str2);
}
}
}
closedir(pDIR);
}
/*end config list getting*/
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
/*config list*/
int list_x = position.x + 160;
int list_y = position.y;
int list_w = 200;
int list_item_h = 20;
for (int i = 0; i < ConfigList.size(); i++)
{
if (m_pMenu->MainWindow->bMouse1pressed && m_pMenu->MainWindow->InBounds(Vector(list_x, list_y + list_item_h * i, 0), Vector(list_w,list_item_h, 0)))
{
this->SelectIndex = i;
}
if (i == this->SelectIndex)
g_pRender->FilledBoxOutlined(list_x, list_y + list_item_h * i, list_w, list_item_h, D3DCOLOR_ARGB(alpha, 55, 55, 55), BLACK(alpha));
else
{
if (m_pMenu->MainWindow->InBounds(Vector(list_x, list_y + list_item_h * i, 0), Vector(200, 20, 0)))
g_pRender->FilledBoxOutlined(list_x, list_y + list_item_h * i, list_w, list_item_h, D3DCOLOR_ARGB(alpha, 45, 45, 45), BLACK(alpha));
else
g_pRender->FilledBox(list_x, list_y + list_item_h * i, list_w, list_item_h, D3DCOLOR_ARGB(alpha, 35, 35, 35));
}
g_pRender->Text((char*)ConfigList.at(i).c_str(), list_x + list_w / 2, list_y + list_item_h * i + list_item_h / 2 - g_pRender->menu_control_size / 2, centered, g_pRender->Fonts.menu_control, true, WHITE(alpha), BLACK(alpha));
}
g_pRender->BorderedBox(list_x, list_y, list_w, list_item_h * 23, BLACK(alpha));
/*end config list*/
/*current config*/
g_pRender->Text((char*)current_config.c_str(), position.x, position.y + size.y / 2 - g_pRender->menu_control_size, lefted, g_pRender->Fonts.menu_control, true, WHITE(alpha), BLACK(alpha));
/*end current config*/
/*save button*/
int save_button_w = 150;
int save_button_h = 20;
int save_button_x = position.x;
int save_button_y = position.y + size.y - save_button_h*3 - 10 - 10 ;
bool save_button_hover = m_pMenu->MainWindow->InBounds(Vector(save_button_x, save_button_y, 0), Vector(save_button_w, save_button_h, 0));
if (save_button_hover && m_pMenu->MainWindow->bMouse1pressed)
g_pRender->FilledBoxOutlined(save_button_x, save_button_y, save_button_w, save_button_h, D3DCOLOR_ARGB(alpha, 55, 55, 55), BLACK(alpha));
else if (save_button_hover)
g_pRender->FilledBoxOutlined(save_button_x, save_button_y, save_button_w, save_button_h, D3DCOLOR_ARGB(alpha, 45, 45, 45), BLACK(alpha));
else
g_pRender->FilledBoxOutlined(save_button_x, save_button_y, save_button_w, save_button_h, D3DCOLOR_ARGB(alpha, 35, 35, 35), BLACK(alpha));
g_pRender->Text("Save", save_button_x + save_button_w / 2, save_button_y + save_button_h / 2 - g_pRender->menu_control_size / 2, centered, g_pRender->Fonts.menu_control, true, WHITE(alpha), BLACK(alpha));
if (save_button_hover && m_pMenu->MainWindow->bMouse1released)
{
m_pMenu->SaveWindowState(ConfigList.at(this->SelectIndex));
}
/*end save button*/
/*load button*/
int load_button_w = 150;
int load_button_h = 20;
int load_button_x = position.x;
int load_button_y = position.y + size.y - load_button_h*2 - 10 ;
bool load_button_button_hover = m_pMenu->MainWindow->InBounds(Vector(load_button_x, load_button_y, 0), Vector(load_button_w, load_button_h, 0));
if (load_button_button_hover && m_pMenu->MainWindow->bMouse1pressed)
g_pRender->FilledBoxOutlined(load_button_x, load_button_y, load_button_w, load_button_h, D3DCOLOR_ARGB(alpha, 55, 55, 55), BLACK(alpha));
else if (load_button_button_hover)
g_pRender->FilledBoxOutlined(load_button_x, load_button_y, load_button_w, load_button_h, D3DCOLOR_ARGB(alpha, 45, 45, 45), BLACK(alpha));
else
g_pRender->FilledBoxOutlined(load_button_x, load_button_y, load_button_w, load_button_h, D3DCOLOR_ARGB(alpha, 35, 35, 35), BLACK(alpha));
g_pRender->Text("Load", load_button_x + load_button_w / 2, load_button_y + load_button_h / 2 - g_pRender->menu_control_size / 2, centered, g_pRender->Fonts.menu_control, true, WHITE(alpha), BLACK(alpha));
if (load_button_button_hover && m_pMenu->MainWindow->bMouse1released)
{
m_pMenu->LoadWindowState(ConfigList.at(this->SelectIndex));
current_config = ConfigList.at(this->SelectIndex);
}
/*end load button*/
/*delete button*/
int delete_w = 150;
int delete_h = 20;
int delete_x = position.x;
int delete_y = position.y + size.y - delete_h;
bool delete_button_hover = m_pMenu->MainWindow->InBounds(Vector(delete_x, delete_y, 0), Vector(delete_w, delete_h, 0));
if (delete_button_hover && m_pMenu->MainWindow->bMouse1pressed)
g_pRender->FilledBoxOutlined(delete_x, delete_y, delete_w, delete_h, D3DCOLOR_ARGB(alpha, 55, 55, 55), BLACK(alpha));
else if (delete_button_hover)
g_pRender->FilledBoxOutlined(delete_x, delete_y, delete_w, delete_h, D3DCOLOR_ARGB(alpha, 45, 45, 45), BLACK(alpha));
else
g_pRender->FilledBoxOutlined(delete_x, delete_y, delete_w, delete_h, D3DCOLOR_ARGB(alpha, 35, 35, 35), BLACK(alpha));
g_pRender->Text("Delete", delete_x + delete_w / 2, delete_y + delete_h / 2 - g_pRender->menu_control_size / 2, centered, g_pRender->Fonts.menu_control, true, WHITE(alpha), BLACK(alpha));
if (delete_button_hover && m_pMenu->MainWindow->bMouse1released)
{
std::string buf = strPath;
buf.append("\\");
buf.append(ConfigList.at(this->SelectIndex));
buf.append(".xml");
DeleteFileA(buf.c_str());
}
} | [
"johannesjohs@hotmail.com"
] | johannesjohs@hotmail.com |
d226ba9f8d43d28593a28380e8addb9efb8b9d86 | aedae5e0386d77955272f6f3f4f8872e26e2955c | /src/xfy_trace.h | d360997f66e60d1aedc04ed3278c6551c41ef1d0 | [
"MIT"
] | permissive | sadgood/tcua-itk-trace | 0b22c61c9a9bfb39ca04d88dc1b0377cedbba195 | 4513fec43bfe4e3f6ac953417ace3d5ea4ac4f9a | refs/heads/master | 2021-06-21T11:29:29.763990 | 2017-08-03T16:28:19 | 2017-08-03T16:28:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,212 | h | #ifndef XFY_TRACE_H_
#define XFY_TRACE_H_
#include <time.h>
#include <stdarg.h>
#ifdef __cplusplus
#ifdef XFYUSELIB
#ifdef XFYLIB
#define XFY_API __declspec(dllexport)
#else
#define XFY_API __declspec(dllimport)
#endif
#else
#define XFY_API
#endif
namespace XFY {
typedef void (*TRACEVALUE)(const char *, void*, int);
typedef struct {
TRACEVALUE fx;
void * pvalue;
int elements;
const char *pszName; } SOutputParamm;
// scope object for every tracing function
class XFY_API TraceFce
{
// Constructors
public:
TraceFce( const char *fceName );
// Operations
public:
void registerOutputParam ( const char *pszName, void *pvalue, TRACEVALUE fx );
void setOutputArraySize ( const char *pszName, const int iSize );
void closeJournalling() { m_bJournallingClosed = true; };
// Implementation
public:
~TraceFce();
int m_retValue;
protected:
const char * m_pszFceName;
private:
SOutputParamm m_asOutList[8];
int m_iOutCount;
time_t m_lStart;
protected:
bool m_bJournallingClosed; // if the function returned value yet
};
// global object for tracing
class XFY_API Trace
{
public:
enum eVALUE_TYPE { eVT_V = 0, eVT_V_END,
eVT_I, eVT_O, eVT_IO,
eVT_IN, eVT_ON, eVT_ION,
eVT_NYI,
eVT_O_RET, eVT_UF, eVT_T_RET,
eVT_V_EX,
eVT_EMPTY,
eVT_COUNT /*must be last*/ };
enum eOUTPUT_MODE { eOM_DEBUGING = 0x01, eOM_JOURNALING = 0x02 };
private:
enum eOutputItem { eOI_FCE_CALL = 0x0001, eOI_ENTRY = 0x0002, eOI_PARAM = 0x0004,
eOI_VALUES = 0x0008, eOI_MESSAGES = 0x0010, eOI_MEMORY = 0x0020,
eOI_JOURNAL = 0x4000,
eOI_ALL = eOI_FCE_CALL | eOI_ENTRY | eOI_PARAM |
eOI_VALUES | eOI_MESSAGES | eOI_MEMORY };
// Constructors
public:
Trace();
~Trace ();
// Attributes
public:
void* getOutputFile();
const int getLevel() { return m_iFceLevel << 1; };
static const char *getHelpMessage ();
static const char *s_pszNULL;
static const int *s_piNULL;
static const eVALUE_TYPE translateValueType ( const char *pszType );
// Operations
public:
const char * functionStart ( const char *pszName );
void functionEnd ( const char *pszName, const time_t lStartTime, const void *pMemoryStruct );
void setAppName( const char * pszName );
static void setAppVersion ( const char *AppVersion );
int putMessage ( const char *format, ... ) const;
int putMessageVA ( const char *format, va_list ap ) const;
int reportFceCall ( const char *ufName, const char *fileName, const int lineNum, const int iRetVal );
void reportFceCall ( const char *ufName, const char *fileName, const int lineNum );
const int showMessage () const { return m_iActFlag & ( eOI_MESSAGES | eOI_JOURNAL ); };
const int showValues () const { return m_iActFlag & ( eOI_VALUES | eOI_JOURNAL ); };
const int showParam () const { return m_iActFlag & ( eOI_PARAM | eOI_JOURNAL ); };
const int showEntry () const { return m_iActFlag & ( eOI_ENTRY | eOI_JOURNAL ); };
const int showUfCall () const { return m_iActFlag & ( eOI_FCE_CALL | eOI_JOURNAL ); };
const int showMemory () const { return m_iActFlag & ( eOI_MEMORY | eOI_JOURNAL ); };
const int getOutMode () const;
const char* getTraceFileName() const { return m_szOutFile; };
static void finishFunctionHeader(); // ends the function header in journal file
#define XFY_TRACE_VAL(ptype) static void putVariable ( const char *Name, const ptype &Value, Trace::eVALUE_TYPE eVT = eVT_V, TraceFce *pzrhFce = NULL )
#define XFY_TRACE_PVAL(ptype) static void putVariable ( const char *Name, const ptype *const &Value, Trace::eVALUE_TYPE eVT = eVT_V, TraceFce *pzrhFce = NULL, int iDeep = -1 )
XFY_TRACE_VAL ( char );
XFY_TRACE_PVAL ( char );
XFY_TRACE_VAL ( short );
XFY_TRACE_PVAL ( short );
XFY_TRACE_VAL ( int );
XFY_TRACE_PVAL ( int );
#ifndef _SUN
XFY_TRACE_VAL ( bool );
XFY_TRACE_PVAL ( bool );
#endif
XFY_TRACE_VAL ( long );
XFY_TRACE_PVAL ( long );
XFY_TRACE_VAL ( unsigned short );
XFY_TRACE_PVAL ( unsigned short );
XFY_TRACE_VAL ( unsigned int );
XFY_TRACE_PVAL ( unsigned int );
XFY_TRACE_VAL ( unsigned long );
XFY_TRACE_PVAL ( unsigned long );
XFY_TRACE_VAL ( unsigned long long );
XFY_TRACE_PVAL ( unsigned long long );
XFY_TRACE_VAL ( float );
XFY_TRACE_PVAL ( float );
XFY_TRACE_VAL ( double );
XFY_TRACE_PVAL ( double );
#undef XFY_TRACE_VAL
#undef XFY_TRACE_PVAL
static void putVariable ( const char *Name, const void *const &Value, Trace::eVALUE_TYPE eVT = eVT_V, TraceFce *pzrhFce = NULL );
#ifndef _AIX
static void putVariable ( const char *Name, char *const &Value, Trace::eVALUE_TYPE eVT = eVT_V, TraceFce *pzrhFce = NULL, int iDeep = -1 );
#endif
static void putVariable ( const char *Name, char ** const &Value, Trace::eVALUE_TYPE eVT = eVT_V, TraceFce *pzrhFce = NULL, int iDeep = -1 );
static void putVariable ( const char *Name, const char ** const &Value, Trace::eVALUE_TYPE eVT = eVT_V, TraceFce *pzrhFce = NULL, int iDeep = -1 );
#ifdef _WIN32
static void putVariable ( const char *Name, char * &Value, Trace::eVALUE_TYPE eVT = eVT_V, TraceFce *pzrhFce = NULL, int iDeep = -1 );
static void putVariable ( const char *Name, char ** &Value, Trace::eVALUE_TYPE eVT = eVT_V, TraceFce *pzrhFce = NULL, int iDeep = -1 );
#endif
//static void putTraceVal ( const char *Name, XFY::TraceObject &Object, XFY::Trace::eVALUE_TYPE eVT = eVT_V, XFY::TraceFce *pzrhFce = NULL, int iDeep = -1 );
#define RETURNS_VAL(ptype) ptype putFceReturns ( const ptype &Value, const TraceFce *pzrhFce = NULL )
#define RETURNS_PVAL(ptype) ptype putFceReturns ( const ptype const &Value, const TraceFce *pzrhFce = NULL )
RETURNS_PVAL ( void* );
#ifndef _SUN
RETURNS_VAL ( bool );
RETURNS_PVAL ( bool* );
#endif
RETURNS_VAL ( int );
RETURNS_PVAL ( int* );
RETURNS_VAL ( unsigned int );
RETURNS_PVAL ( unsigned int* );
RETURNS_VAL ( long );
RETURNS_PVAL ( long* );
RETURNS_VAL ( unsigned long );
RETURNS_PVAL ( unsigned long* );
RETURNS_VAL ( unsigned long long );
RETURNS_PVAL ( unsigned long long* );
RETURNS_VAL ( double );
RETURNS_PVAL ( double* );
RETURNS_VAL ( float );
RETURNS_PVAL ( float* );
RETURNS_VAL ( char );
RETURNS_PVAL ( char* );
#undef RETURNS_VAL
#undef RETURNS_PVAL
// print out the exception message
void doFceThrows ( const char *Msg );
// print out error code translation
int putErrorReturns ( const int &Value, const XFY::TraceFce *pOutItem = NULL );
// Implementations
protected:
int m_iActFlag; // active debug flag
char m_szOutFile[256]; // output file
char m_szAppName[32]; // application name
void *m_pFile; // output file handle
int m_iUseTraceFunction; // function tracking is active
char m_szTraceFunction[256]; // function for tracing
int m_iTraceFunctionFlag; // flags for function tracing
int m_iSavedFlag; // flags to be switched back
int m_iJournalingFlag; // jornaling flag before entry of tracking function
int m_iStopLevel; // level to set function tracking back
int m_iUseFlush; // use flush after every file access
void putFileBreak(); // draw stars and time into output file
// put a translated message into the output
void putErrorMessage ( const int iMessage );
// File Name Syntax Parse
size_t transFileName ( const char *pszFrom, char *pszTo,
const int iBufferLen, const int isTransAll ) const;
private:
int m_iFceLevel; // level of the current function
};
// global object definition for tracing
extern XFY_API Trace g_XFYTrace;
} /* namespace XFY */
#endif
#ifdef XFY_API
#undef XFY_API
#endif
#endif /* XFY_TRACE_H_ */
| [
"scoufal@users.noreply.github.com"
] | scoufal@users.noreply.github.com |
d68428e0364373c146f8221410029d1bebab56b8 | 9f63086ea2a50683474fd19e0cd65c34ecaecfe6 | /Lecture6/pattern.cpp | 576e898270d93374e7ccfd124fe25290d4bc2c56 | [] | no_license | aryangulati/launchpadNS19 | f60b2b528a05e3a6c9477b5d303a55a813622d31 | 96b3fb00c5175e1c6239e1d8ed57afdd2000ffb9 | refs/heads/master | 2020-08-09T13:43:41.580409 | 2019-10-10T06:14:57 | 2019-10-10T06:14:57 | 214,099,719 | 0 | 0 | null | 2019-10-10T06:04:28 | 2019-10-10T06:04:23 | null | UTF-8 | C++ | false | false | 513 | cpp | #include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
for(int line=1;line<=n;line++)
{
for(int stars=1;stars<=line;stars++)
{
cout<<"*";
}
cout<<" ";
for(int stars=1;stars<=n-line+1;stars++)
{
cout<<"*";
}
cout<<" ";
for(int stars=1;stars<=n-line+1;stars++)
{
cout<<"*";
}
cout<<" ";
for(int stars=1;stars<=line;stars++)
{
cout<<"*";
}
cout<<endl;
}
return 0;
} | [
"itidiamond24@gmail.com"
] | itidiamond24@gmail.com |
0bc344dea1cb7658f6f74957a982a25fb981d479 | 6a8df6af23a249302654783df73cfcda76d81fb6 | /src/gps_agent_pkg/msg_gen/cpp/include/gps_agent_pkg/ControllerParams.h | 7f250c50e5ac71995021ba168ec6e4987ede9800 | [
"BSD-2-Clause"
] | permissive | amoliu/GPS-Multi-Targets | 1e5a36c55b8e85aa8cc6e6123e0d296acd6259d3 | beca5d4fed1c13240a130fe10591c070eca1cc41 | refs/heads/master | 2021-01-22T20:21:41.436407 | 2017-03-10T14:33:27 | 2017-03-10T14:33:27 | 85,314,396 | 3 | 0 | null | 2017-03-17T13:26:57 | 2017-03-17T13:26:57 | null | UTF-8 | C++ | false | false | 6,014 | h | /* Auto-generated by genmsg_cpp for file /home/chentao/software/gps/src/gps_agent_pkg/msg/ControllerParams.msg */
#ifndef GPS_AGENT_PKG_MESSAGE_CONTROLLERPARAMS_H
#define GPS_AGENT_PKG_MESSAGE_CONTROLLERPARAMS_H
#include <string>
#include <vector>
#include <map>
#include <ostream>
#include "ros/serialization.h"
#include "ros/builtin_message_traits.h"
#include "ros/message_operations.h"
#include "ros/time.h"
#include "ros/macros.h"
#include "ros/assert.h"
#include "gps_agent_pkg/CaffeParams.h"
#include "gps_agent_pkg/LinGaussParams.h"
#include "gps_agent_pkg/TfParams.h"
namespace gps_agent_pkg
{
template <class ContainerAllocator>
struct ControllerParams_ {
typedef ControllerParams_<ContainerAllocator> Type;
ControllerParams_()
: controller_to_execute(0)
, caffe()
, lingauss()
, tf()
{
}
ControllerParams_(const ContainerAllocator& _alloc)
: controller_to_execute(0)
, caffe(_alloc)
, lingauss(_alloc)
, tf(_alloc)
{
}
typedef int8_t _controller_to_execute_type;
int8_t controller_to_execute;
typedef ::gps_agent_pkg::CaffeParams_<ContainerAllocator> _caffe_type;
::gps_agent_pkg::CaffeParams_<ContainerAllocator> caffe;
typedef ::gps_agent_pkg::LinGaussParams_<ContainerAllocator> _lingauss_type;
::gps_agent_pkg::LinGaussParams_<ContainerAllocator> lingauss;
typedef ::gps_agent_pkg::TfParams_<ContainerAllocator> _tf_type;
::gps_agent_pkg::TfParams_<ContainerAllocator> tf;
typedef boost::shared_ptr< ::gps_agent_pkg::ControllerParams_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::gps_agent_pkg::ControllerParams_<ContainerAllocator> const> ConstPtr;
}; // struct ControllerParams
typedef ::gps_agent_pkg::ControllerParams_<std::allocator<void> > ControllerParams;
typedef boost::shared_ptr< ::gps_agent_pkg::ControllerParams> ControllerParamsPtr;
typedef boost::shared_ptr< ::gps_agent_pkg::ControllerParams const> ControllerParamsConstPtr;
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::gps_agent_pkg::ControllerParams_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::gps_agent_pkg::ControllerParams_<ContainerAllocator> >::stream(s, "", v);
return s;}
} // namespace gps_agent_pkg
namespace ros
{
namespace message_traits
{
template<class ContainerAllocator> struct IsMessage< ::gps_agent_pkg::ControllerParams_<ContainerAllocator> > : public TrueType {};
template<class ContainerAllocator> struct IsMessage< ::gps_agent_pkg::ControllerParams_<ContainerAllocator> const> : public TrueType {};
template<class ContainerAllocator>
struct MD5Sum< ::gps_agent_pkg::ControllerParams_<ContainerAllocator> > {
static const char* value()
{
return "b21eed6449b84a548fab33a89f3b3c3b";
}
static const char* value(const ::gps_agent_pkg::ControllerParams_<ContainerAllocator> &) { return value(); }
static const uint64_t static_value1 = 0xb21eed6449b84a54ULL;
static const uint64_t static_value2 = 0x8fab33a89f3b3c3bULL;
};
template<class ContainerAllocator>
struct DataType< ::gps_agent_pkg::ControllerParams_<ContainerAllocator> > {
static const char* value()
{
return "gps_agent_pkg/ControllerParams";
}
static const char* value(const ::gps_agent_pkg::ControllerParams_<ContainerAllocator> &) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::gps_agent_pkg::ControllerParams_<ContainerAllocator> > {
static const char* value()
{
return "int8 controller_to_execute # controller enum, defined in gps_pb2\n\
\n\
CaffeParams caffe\n\
LinGaussParams lingauss\n\
TfParams tf\n\
\n\
================================================================================\n\
MSG: gps_agent_pkg/CaffeParams\n\
string net_param # Serialized net parameter with weights (equivalent of prototxt file)\n\
float32[] bias\n\
float32[] scale\n\
float32[] noise\n\
int32 dim_bias\n\
uint32 dU\n\
\n\
================================================================================\n\
MSG: gps_agent_pkg/LinGaussParams\n\
# Time-varying Linear Gaussian controller\n\
uint32 dX\n\
uint32 dU\n\
float64[] K_t # Should be T x Du x Dx\n\
float64[] k_t # Should by T x Du\n\
\n\
================================================================================\n\
MSG: gps_agent_pkg/TfParams\n\
# Tf Params. just need to track dU.\n\
uint32 dU\n\
\n\
\n\
";
}
static const char* value(const ::gps_agent_pkg::ControllerParams_<ContainerAllocator> &) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::gps_agent_pkg::ControllerParams_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.controller_to_execute);
stream.next(m.caffe);
stream.next(m.lingauss);
stream.next(m.tf);
}
ROS_DECLARE_ALLINONE_SERIALIZER;
}; // struct ControllerParams_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::gps_agent_pkg::ControllerParams_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::gps_agent_pkg::ControllerParams_<ContainerAllocator> & v)
{
s << indent << "controller_to_execute: ";
Printer<int8_t>::stream(s, indent + " ", v.controller_to_execute);
s << indent << "caffe: ";
s << std::endl;
Printer< ::gps_agent_pkg::CaffeParams_<ContainerAllocator> >::stream(s, indent + " ", v.caffe);
s << indent << "lingauss: ";
s << std::endl;
Printer< ::gps_agent_pkg::LinGaussParams_<ContainerAllocator> >::stream(s, indent + " ", v.lingauss);
s << indent << "tf: ";
s << std::endl;
Printer< ::gps_agent_pkg::TfParams_<ContainerAllocator> >::stream(s, indent + " ", v.tf);
}
};
} // namespace message_operations
} // namespace ros
#endif // GPS_AGENT_PKG_MESSAGE_CONTROLLERPARAMS_H
| [
"chentao904@163.com"
] | chentao904@163.com |
836cbc570cc7d36bb9cfe909f8d8fd88ee96e645 | bc21a05045481b2a79cd97d42316e1db204f0e0c | /elevator_simulation_oop/MyUtil.cpp | 4d99d8a07450bf0517077d65c744748210826ee7 | [] | no_license | roberchenc/homework_oop | cd6406ea21d37f4d6e99ca7082b9c60cbb3acde7 | 8cba84b5a6528339129bd134111fee44cd495213 | refs/heads/master | 2021-10-10T07:13:38.444245 | 2019-01-08T05:33:22 | 2019-01-08T05:33:22 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,403 | cpp | #include "MyUtil.h"
#include <Windows.h>
MyUtil::MyUtil()
{
}
MyUtil::~MyUtil()
{
}
MyUtil* MyUtil::getInstance()
{
static MyUtil* myUtil;
if (myUtil == NULL)
myUtil = new MyUtil();
return myUtil;
}
int MyUtil::random(int min, int max)
{
//蠢方法
//srand((int)time(0)); //随机数种子,让每次生成的随机数都不一样
//
//cout << "普通方法" << endl;
//cout<< min + (max-min) * rand() / RAND_MAX;
//cout << endl;
//C++ 随机数的高级方法
//default_random_engine e;
//uniform_int_distribution<unsigned> u(min, max); //随机数分布对象
mt19937 rng;
rng.seed(random_device()());
uniform_int_distribution<int> u(min, max); //随机数分布对象
return u(rng);
}
//判断去某个楼层可以乘坐的电梯编号 elevatorFlag为10个bool类型,初始值为false
void MyUtil::canTakeFloor(int nowfloor, int distfloor)
{
for (int i = 0; i < 10; i++)
elevatorFlag[i] = false;
if (distfloor > 0 && distfloor <= 40)
{
elevatorFlag[0] = true;
elevatorFlag[1] = true;
if (distfloor == 1)
{
elevatorFlag[2] = true;
elevatorFlag[3] = true;
elevatorFlag[4] = true;
elevatorFlag[5] = true;
elevatorFlag[8] = true;
elevatorFlag[9] = true;
}
if (distfloor >= 25 && distfloor <= 40)
{
elevatorFlag[2] = true;
elevatorFlag[3] = true;
}
if (distfloor > 1 && distfloor <= 25)
{
elevatorFlag[4] = true;
elevatorFlag[5] = true;
}
if (distfloor % 2 == 0)
{
elevatorFlag[6] = true;
elevatorFlag[7] = true;
}
if (distfloor % 2 == 1)
{
elevatorFlag[8] = true;
elevatorFlag[9] = true;
}
}
for (int i = 0; i < 10; i++)
{
if (!canArrive(i, nowfloor))
elevatorFlag[i] = false;
}
}
//电梯运行规则
bool MyUtil::canArrive(int elevatorNum, int floorNum)
{
if (floorNum > 0 && floorNum < 41)
{
if (elevatorNum == 0 || elevatorNum == 1)
return true;
else if (elevatorNum == 2 || elevatorNum == 3)
{
if (floorNum < 2 || floorNum > 24)
return true;
}
else if (elevatorNum == 4 || elevatorNum == 5)
{
if (floorNum > 0 && floorNum < 26)
return true;
}
else if (elevatorNum == 0 || elevatorNum == 1)
{
if (floorNum < 2 || floorNum % 2 == 0)
return true;
}
else if (elevatorNum == 0 || elevatorNum == 1)
{
if (floorNum % 2 == 1)
return true;
}
else
return false;
}
else
return false;
return false;
}
| [
"1368841907@qq.com"
] | 1368841907@qq.com |
a81fbb7426d88911a3411778a4db50d423944e32 | 40ac7b3467018a97781409785d1bbfb162ee462e | /libraries/BaseLib/src/framework/platform_specific/include/CamPrevViewShaders.hpp | dcf00e8e848cf0439b2323a73599c779f96508c1 | [] | no_license | aexol/AexolGL | 611c165f53cf3ad3ae9cd7106c18a8d61a6801ba | 7fcc93d43ad329ebddadabf6a5c18bac995b060a | refs/heads/master | 2020-03-21T05:40:06.912374 | 2018-06-21T13:23:19 | 2018-06-21T13:23:19 | 138,172,393 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,955 | hpp | #ifndef CAM_PREV_VIEW_SHADERS_HPP
#define CAM_PREV_VIEW_SHADERS_HPP
// a - attribute
// u - uniform
// v - varying
const char* SimplePreviewViewVS =
"uniform mat4 uTextureTransform;\n"
"varying vec2 vTexCoord;\n"
"void main() {\n"
" vTexCoord = (uTextureTransform * vec4(aTexCoord, 0.0, 1.0)).xy;\n"
" gl_Position = aPosition;\n"
"}\n";
const char* SimplePreviewViewFS =
#ifdef BUILD_FOR_ANDROID
"//#extension GL_OES_EGL_image_external : require\n"
#endif
#ifdef BUILD_FOR_ANDROID
"uniform samplerExternalOES textureOES;\n"
#endif
#ifdef BUILD_FOR_IOS
"uniform sampler2D textureY;\n"
"uniform sampler2D textureUV;\n"
#endif
"varying vec2 vTexCoord;\n"
"\n"
"void main () { \n"
// get color from texture/s
#ifdef BUILD_FOR_ANDROID
" vec4 color = texture2D(textureOES, vTexCoord);\n"
#endif
#ifdef BUILD_FOR_IOS
" vec3 yuv; \n"
" yuv.x = texture2D(textureY, vTexCoord).r; \n"
" yuv.yz = texture2D(textureUV, vTexCoord).rg - vec2(0.5, 0.5); \n"
" vec3 rgb = mat3(1,1,1, 0,-.18732,1.8556, 1.57481,-.46813,0) * yuv; \n" // SDTV = rgb = mat3(1,1,1, 0, -.34413, 1.772, 1.402, -.71414, 0) * yuv;\n
" vec4 color = vec4(rgb, 1); \n"
#endif
" gl_FragColor = color;\n"
"}\n";
/* ++++++++++++ Noctovision +++++++++++ */
const char* NoctovisionPreviewViewFS =
#ifdef BUILD_FOR_ANDROID
"//#extension GL_OES_EGL_image_external : require\n"
#endif
#ifdef BUILD_FOR_ANDROID
"uniform samplerExternalOES textureOES;\n"
#endif
#ifdef BUILD_FOR_IOS
"uniform sampler2D textureY;\n"
"uniform sampler2D textureUV;\n"
#endif
"varying vec2 vTexCoord;\n"
"\n"
"void main () { \n"
// get color from texture/s
#ifdef BUILD_FOR_ANDROID
" vec4 color = texture2D(textureOES, vTexCoord);\n"
#endif
#ifdef BUILD_FOR_IOS
" vec3 yuv; \n"
" yuv.x = texture2D(textureY, vTexCoord).r; \n"
" yuv.yz = texture2D(textureUV, vTexCoord).rg - vec2(0.5, 0.5); \n"
" vec3 rgb = mat3(1,1,1, 0,-.18732,1.8556, 1.57481,-.46813,0) * yuv; \n"
" vec4 color = vec4(rgb, 1); \n"
#endif
" color.x = color.x / 0.2; \n" // stretching the histogram 0.0 - 0.2 area to full 0.0 - 1.0
" color.y = color.y / 0.2; \n"
" color.z = color.z / 0.2; \n"
" float green = ((color.x + color.y + color.z)*1.0)/3.0; \n"
" if(green > 1.0) green = 1.0; \n"
" float wspol = 1.0-green; \n"
" gl_FragColor = vec4(1.0 - (wspol*2.0), green, 1.0 - (wspol*2.0), 1.0);\n"
"}\n";
/* +++++++++++++ HRM ++++++++++++++++*/
const char* HRMPreviewViewFS =
#ifdef BUILD_FOR_ANDROID
"//#extension GL_OES_EGL_image_external : require\n"
#endif
#ifdef BUILD_FOR_ANDROID
"uniform samplerExternalOES textureOES;\n"
#endif
#ifdef BUILD_FOR_IOS
"uniform sampler2D textureY;\n"
"uniform sampler2D textureUV;\n"
#endif
"varying vec2 vTexCoord;\n"
"\n"
"void main () { \n"
// get color from texture/s
#ifdef BUILD_FOR_ANDROID
" vec4 color = texture2D(textureOES, vTexCoord);\n"
#endif
#ifdef BUILD_FOR_IOS
" vec3 yuv; \n"
" yuv.x = texture2D(textureY, vTexCoord).r; \n"
" yuv.yz = texture2D(textureUV, vTexCoord).rg - vec2(0.5, 0.5); \n"
" vec3 rgb = mat3(1,1,1, 0,-.18732,1.8556, 1.57481,-.46813,0) * yuv; \n"
" vec4 color = vec4(rgb, 1); \n"
#endif
" gl_FragColor = vec4(color.xyz, 1.0);\n"
"}\n";
/* ++++++++++++ Filter ++++++++++++++*/
const char* FilterPreviewViewFS =
#ifdef BUILD_FOR_ANDROID
"//#extension GL_OES_EGL_image_external : require\n"
#endif
#ifdef BUILD_FOR_ANDROID
"uniform samplerExternalOES textureOES;\n"
#endif
#ifdef BUILD_FOR_IOS
"uniform sampler2D textureY;\n"
"uniform sampler2D textureUV;\n"
#endif
"#define KERNEL_SIZE 9 \n" // this can be dinamically included before compiling (parametrize in Filter)
"uniform float uWidth; \n"
"uniform float uHeight; \n"
"uniform mat3 uKernel; \n"
"uniform float uKernelDivisor; \n"
"// uniform vec2 uOffsets[KERNEL_SIZE]; // not used, is slower when providing it from cpu \n"
"varying vec2 vTexCoord;\n"
"\n"
"void main () { \n"
" float kernel[KERNEL_SIZE]; \n"
" float step_w = (1.0/uWidth); \n"
" float step_h = (1.0/uHeight); \n"
" vec2 offset[KERNEL_SIZE]; \n"
" int i = 0; \n"
" vec4 sum = vec4(0.0); \n"
" offset[0] = vec2(-step_w, step_h); // north west \n"
" offset[1] = vec2(0.0, step_h); // north \n"
" offset[2] = vec2(step_w, step_h); // north east \n"
" offset[3] = vec2(-step_w, 0.0); // west \n"
" offset[4] = vec2(0.0, 0.0); // center \n"
" offset[5] = vec2(step_w, 0.0); // east \n"
" offset[6] = vec2(-step_w, -step_h); // south west \n"
" offset[7] = vec2(0.0, -step_h); // south \n"
" offset[8] = vec2(step_w, -step_h); // south east \n"
" kernel[0] = uKernel[0][0]; kernel[1] = uKernel[1][0]; kernel[2] = uKernel[2][0]; \n"
" kernel[3] = uKernel[0][1]; kernel[4] = uKernel[1][1]; kernel[5] = uKernel[2][1]; \n"
" kernel[6] = uKernel[0][2]; kernel[7] = uKernel[1][2]; kernel[8] = uKernel[2][2]; \n"
" for( i=0; i < KERNEL_SIZE; i++ ) \n"
" { \n"
// get color from texture/s
#ifdef BUILD_FOR_ANDROID
" vec4 color = texture2D(textureOES, vTexCoord + offset[i]);\n"
#endif
#ifdef BUILD_FOR_IOS
" vec3 yuv; \n"
" yuv.x = texture2D(textureY, vTexCoord + offset[i]).r; \n"
" yuv.yz = texture2D(textureUV, vTexCoord + offset[i]).rg - vec2(0.5, 0.5); \n"
" vec3 rgb = mat3(1,1,1, 0,-.18732,1.8556, 1.57481,-.46813,0) * yuv; \n"
" vec4 color = vec4(rgb, 1); \n"
#endif
" sum += color * kernel[i]; \n"
" } \n"
" sum /= uKernelDivisor; \n"
" sum = vec4(sum.rgb, 1.0); // to reset alpha damaged by filters \n"
" gl_FragColor = sum;\n"
"}\n";
/* +++++++++++ Movement ++++++++++++*/
const char* MovementPreviewViewFS =
#ifdef BUILD_FOR_ANDROID
"//#extension GL_OES_EGL_image_external : require\n"
#endif
#ifdef BUILD_FOR_ANDROID
"uniform samplerExternalOES textureOES;\n"
#endif
#ifdef BUILD_FOR_IOS
"uniform sampler2D textureY;\n"
"uniform sampler2D textureUV;\n"
#endif
"uniform float uMoveX; \n"
"uniform float uMoveY; \n"
"varying vec2 vTexCoord;\n"
"void main () {\n"
" vec2 movedTexCoord = vTexCoord; \n"
" movedTexCoord.x += uMoveX; \n"
" movedTexCoord.y += uMoveY; \n"
#ifdef BUILD_FOR_ANDROID
" vec4 color1 = texture2D(textureOES, vTexCoord);\n"
" vec4 color2 = texture2D(textureOES, movedTexCoord);\n"
#endif
#ifdef BUILD_FOR_IOS
" vec3 yuv; \n"
" vec3 rgb; \n"
" yuv.x = texture2D(textureY, vTexCoord).r; \n"
" yuv.yz = texture2D(textureUV, vTexCoord).rg - vec2(0.5, 0.5); \n"
" rgb = mat3(1,1,1, 0,-.18732,1.8556, 1.57481,-.46813,0) * yuv; \n"
" vec4 color1 = vec4(rgb, 1); \n"
" yuv.x = texture2D(textureY, movedTexCoord).r; \n"
" yuv.yz = texture2D(textureUV, movedTexCoord).rg - vec2(0.5, 0.5); \n"
" rgb = mat3(1,1,1, 0,-.18732,1.8556, 1.57481,-.46813,0) * yuv; \n"
" vec4 color2 = vec4(rgb, 1); \n"
#endif
" color1 = (color1 + color2) / 2.0; \n"
" gl_FragColor = color1;\n"
"}\n";
const char* SimpleChainElementVS =
"varying vec2 vTexCoord;\n"
"void main() {\n"
" vTexCoord = aTexCoord;\n"
" gl_Position = aPosition;\n"
"}\n";
const char* SimpleChainElementFS =
"uniform sampler2D uTexture;\n"
"varying vec2 vTexCoord;\n"
"void main () { \n"
" vec4 color = texture2D(uTexture, vTexCoord);\n"
" color.r += 0.2; \n"
" gl_FragColor = color;\n"
"}\n";
#endif
//const char* FilterPreviewViewFS =
//"#ifdef ANDROID \n"
//"//#extension GL_OES_EGL_image_external : require\n"
//#endif
//"#ifdef ANDROID \n"
// "uniform samplerExternalOES textureOES;\n"
//#endif
//#ifdef BUILD_FOR_IOS
// "uniform sampler2D textureY;\n"
// "uniform sampler2D textureUV;\n"
//#endif
//"uniform float uWidth; \n"
//"uniform float uHeight; \n"
//"varying vec2 vTexCoord;\n"
//
//"#define KERNEL_SIZE 9 \n"
//"float kernel[KERNEL_SIZE]; \n"
//"float step_w = (1.0/uWidth); \n"
//"float step_h = (1.0/uHeight); \n"
//"vec2 offset[KERNEL_SIZE]; \n"
//"\n"
//"void main () { \n"
//" int i = 0; \n"
//" vec4 sum = vec4(0.0); \n"
//
//" offset[0] = vec2(-step_w, step_h); // north west \n"
//" offset[1] = vec2(0.0, step_h); // north \n"
//" offset[2] = vec2(step_w, step_h); // north east \n"
//
//" offset[3] = vec2(-step_w, 0.0); // west \n"
//" offset[4] = vec2(0.0, 0.0); // center \n"
//" offset[5] = vec2(step_w, 0.0); // east \n"
//
//" offset[6] = vec2(-step_w, -step_h); // south west \n"
//" offset[7] = vec2(0.0, -step_h); // south \n"
//" offset[8] = vec2(step_w, -step_h); // south east \n"
//
//" kernel[0] = -1.0; kernel[1] = -1.0; kernel[2] = -1.0; \n"
//" kernel[3] = -1.0; kernel[4] = 9.0; kernel[5] = -1.0; \n"
//" kernel[6] = -1.0; kernel[7] = -1.0; kernel[8] = -1.0; \n"
//
//" for( i=0; i < KERNEL_SIZE; i++ ) \n"
//" { \n"
//// get color from texture/s
//"#ifdef ANDROID \n"
//" vec4 color = texture2D(textureOES, vTexCoord + offset[i]);\n"
//#endif
//#ifdef BUILD_FOR_IOS
//" vec3 yuv; \n"
//" yuv.x = texture2D(textureY, vTexCoord + offset[i]).r; \n"
//" yuv.yz = texture2D(textureUV, vTexCoord + offset[i]).rg - vec2(0.5, 0.5); \n"
//" vec3 rgb = mat3(1,1,1, 0,-.18732,1.8556, 1.57481,-.46813,0) * yuv; \n"
//" vec4 color = vec4(rgb, 1); \n"
//#endif
//" sum += color * kernel[i]; \n"
//" } \n"
//" // sum /= 3.0; \n"
//" sum = vec4(sum.rgb, 1.0); // to reset alpha damaged by filters \n"
//" gl_FragColor = sum;\n"
//"}\n";
| [
"mritke@gmail.com"
] | mritke@gmail.com |
018ca9919c33c3bd8b79a423510165a67f1aa3c2 | 2afcdd46cf0783d76b932ca87d9db21602a9361a | /Sim/Sim/Goal.h | fe6a696db58c8663f5fc55552eba21c2e00628b3 | [] | no_license | ezio3593/Passenger_sim | b17a6f92d2aadb658335c9c5da6eea07486bbbf1 | 9fdb1a5a294e696ee3227858b5f55af9fa57ee6d | refs/heads/master | 2021-01-02T08:47:44.634376 | 2014-06-08T00:27:42 | 2014-06-08T00:27:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,081 | h | #pragma once
#include <vector>
#include "Vector2D.h"
class Goal
{
Vector2D point;
Goal* nextLevelGoal;
Goal* prevLevelGoal;
std::vector<Goal*>* seatsPr;
bool isOccupied;
Vector2D seatPoint;
public:
Goal(const Vector2D& _point): point(_point), isOccupied(false),
nextLevelGoal(NULL), prevLevelGoal(NULL), seatsPr(NULL) {}
Goal* getNextLevelGoal() const { return nextLevelGoal; }
Goal* getPrevLevelGoal() const { return prevLevelGoal; }
std::vector<Goal*>* getSeatGoalPr() const { return seatsPr; }
Vector2D getPoint() const { return point; }
Vector2D getSeatPoint() const { return seatPoint; }
void setPoint(const Vector2D& _point) { point = _point; }
void setSeatPoint(const Vector2D& _seatPoint) { seatPoint = _seatPoint; }
void setNextLevelGoal(Goal* goals) { nextLevelGoal = goals; }
void setPrevLevelGoal(Goal* goals) { prevLevelGoal = goals; }
void setSeatGoalPr(std::vector<Goal*>* goals) { seatsPr = goals; }
void setIsOcuupied(bool _isOccupied) { isOccupied = _isOccupied; }
bool getIsOccupied() const { return isOccupied; }
~Goal() {}
}; | [
"kostya3593@mail.ru"
] | kostya3593@mail.ru |
f8ae2e543eddb2c6b0d67a01c2261bdfa2a1da78 | 47cf85e58dd6b05c25f4e0bfd6c6199b0eaa966d | /4. Hitung Luas/ConsoleApplication2/ConsoleApplication2/ConsoleApplication2.cpp | 304a3d39db5c5f02f24b94cef912ed8384fb8cc2 | [] | no_license | reyreyhan/4210161023_Reyhan_PraktikumPemrograman4 | 713d29bb85832f5bfc0a736b1d8eaebf8bfcfa56 | ca5cc76373c19ca968b1f3ab19f20a58177ad130 | refs/heads/master | 2021-09-15T09:14:19.545013 | 2018-05-29T16:06:57 | 2018-05-29T16:06:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 390 | cpp | // ConsoleApplication2.cpp : Defines the entry point for the console application.
//
#include "Persegi.h"
#include "Segitiga.h"
#include "Bundar.h"
#include <iostream>
using namespace std;
int main()
{
int pause;
cout << "Hitung Luas Bundar \n";
Bundar bundar;
cout << "Masukkan Jari - Jari"; cin >> bundar.jari;
bundar.LuasBundar(bundar.jari);
cin >> pause;
return 0;
}
| [
"newrey9227@gmail.com"
] | newrey9227@gmail.com |
4061c187f22c737b04ca4076fde87be95b6d912d | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_1480487_0/C++/DrX/GCJ_A.cpp | 079b1739ddcd720dbec27ee00d6549d5ebdd27ec | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 1,004 | cpp | #include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N = 400;
int s[N], n, sum;
bool chk (int x, double r) {
double v = s[x] + r * sum;
r = 1.0 - r;
bool flag = false;
for (int i = 1; i <= n; ++i) {
if (i == x || s[i] > v) continue;
else {
double f = (v - s[i]) / sum;
if (r < 0 || r + 1e-15 < f) {
flag = true;
break;
}
else r -= f;
}
}
return flag;
}
int main () {
int i, j, k, T, t, ca;
freopen ("/home/shuo/Desktop/A.in", "r", stdin);
freopen ("/home/shuo/Desktop/A.o", "w", stdout);
scanf ("%d", &T);
for (ca = 1; ca <= T; ++ca) {
scanf ("%d", &n); sum = 0;
for (i = 1; i <= n; i++) scanf ("%d", &s[i]), sum += s[i];
printf ("Case #%d:", ca);
for (i = 1; i <= n; i++) {
double up = 1.0, low = .0;
while (up > low + 1e-15) {
double mid = (up + low) / 2;
if (chk (i, mid))
up = mid;
else low = mid;
}
printf (" %.15lf", 100 * up);
}
printf ("\n");
}
return 0;
}
| [
"eewestman@gmail.com"
] | eewestman@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.