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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
227f02dff362bc3d924da898621e7fd29715dede | 5508b7eb892df56ad53d39b7d73cc26abd460ebf | /Src/Extern/SENSEI/AMReX_ParticleInSituBridge.H | 5177b44db586328466583176daf9bdfed3200752 | [
"BSD-2-Clause"
] | permissive | dwillcox/amrex | 60682e250e7cbd178878856631eab71c248d69a7 | b84d7c069cef7470f195b250926ca0e84ec46fb2 | refs/heads/development | 2022-10-01T11:55:53.286347 | 2022-09-26T23:05:10 | 2022-09-26T23:05:10 | 269,328,202 | 0 | 1 | NOASSERTION | 2020-10-23T15:51:28 | 2020-06-04T10:22:38 | C++ | UTF-8 | C++ | false | false | 3,047 | h | #ifndef AMReX_ParticleInSituBridge_H
#define AMReX_ParticleInSituBridge_H
#include <AMReX_Config.H>
#ifdef AMREX_PARTICLES
#include <AMReX_Vector.H>
#include <AMReX_AmrParticles.H>
#ifdef AMREX_USE_SENSEI_INSITU
#include <AMReX_InSituBridge.H>
#include <AMReX_ParticleDataAdaptor.H>
#include <AnalysisAdaptor.h>
#include <Profiler.h>
#include <chrono>
#endif
namespace amrex
{
/// Bridge for simulations that use amrex::ParticleContainer
/// inherits initialize and finalize from amrex::InSituBridge
class ParticleInSituBridge : public InSituBridge
{
public:
ParticleInSituBridge() {}
~ParticleInSituBridge() {}
ParticleInSituBridge(const ParticleInSituBridge&) = delete;
void operator=(const ParticleInSituBridge&) = delete;
// invoke the in situ analysis with data from an AmrMesh
// instance.
template<int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
int update(
const double time,
const int time_step,
amrex::ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt> *particles,
const std::map<std::string, std::vector<int>> & particles_rStructs = {},
const std::map<std::string, int> & particles_iStructs = {},
const std::map<std::string, std::vector<int>> & particles_rArrays = {},
const std::map<std::string, int> & particles_iArrays = {});
};
template<int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
int ParticleInSituBridge::update(
const double time,
const int time_step,
amrex::ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt> *particles,
const std::map<std::string, std::vector<int>> & particles_rStructs,
const std::map<std::string, int> & particles_iStructs,
const std::map<std::string, std::vector<int>> & particles_rArrays,
const std::map<std::string, int> & particles_iArrays)
{
int ret = 0;
#if defined(AMREX_USE_SENSEI_INSITU)
if (doUpdate())
{
sensei::TimeEvent<64> event("ParticleInSituBridge::update");
amrex::Print() << "SENSEI Particles Begin update..." << std::endl;
auto t0 = std::chrono::high_resolution_clock::now();
if (!particles)
{
SENSEI_ERROR("no particles presented at update call");
return -1;
}
ParticleDataAdaptor<NStructReal, NStructInt, NArrayReal, NArrayInt> *data_adaptor
= ParticleDataAdaptor<NStructReal, NStructInt, NArrayReal, NArrayInt>::New();
if (comm != MPI_COMM_NULL)
data_adaptor->SetCommunicator(comm);
data_adaptor->SetDataSource(particles, particles_rStructs,
particles_iStructs, particles_rArrays, particles_iArrays);
data_adaptor->SetDataTime(time);
data_adaptor->SetDataTimeStep(time_step);
ret = analysis_adaptor->Execute(data_adaptor) ? 0 : -1;
data_adaptor->ReleaseData();
data_adaptor->Delete();
auto t1 = std::chrono::high_resolution_clock::now();
auto dt = std::chrono::duration_cast<std::chrono::duration<double>>(t1 - t0);
amrex::Print() << "SENSEI update complete (" << dt.count() << " sec)" << std::endl;
}
#endif
return ret;
}
}
#endif
#endif
| [
"noreply@github.com"
] | noreply@github.com |
067bbce9ffb79919165f7885d4de632ee5095189 | d84b00ef1177af72932662cbbb1d1ab95c7e288c | /src/denomination_functions.cpp | b4183f815a136af1cf8672d6766336b0f35afacc | [
"MIT"
] | permissive | N1ppa69/Picture-ex-core | 86a0f7b48a960aee4a4eb26fa4c41c0c100c62e4 | c2beb62086f6459dc8a8cdaddb5dd677eae027e1 | refs/heads/master | 2020-12-06T09:58:42.780975 | 2019-12-25T11:20:55 | 2019-12-26T11:55:06 | 232,430,287 | 1 | 0 | MIT | 2020-01-07T22:35:33 | 2020-01-07T22:35:32 | null | UTF-8 | C++ | false | false | 19,318 | cpp | // Copyright (c) 2017-2019 The pictureex developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "denomination_functions.h"
using namespace libzerocoin;
// -------------------------------------------------------------------------------------------------------
// Number of coins used for either change or a spend given a map of coins used
// -------------------------------------------------------------------------------------------------------
int getNumberOfCoinsUsed(
const std::map<CoinDenomination, CAmount>& mapChange)
{
int nChangeCount = 0;
for (const auto& denom : zerocoinDenomList) {
nChangeCount += mapChange.at(denom);
}
return nChangeCount;
}
// -------------------------------------------------------------------------------------------------------
// Find the max CoinDenomination amongst held coins
// -------------------------------------------------------------------------------------------------------
CoinDenomination getMaxDenomHeld(
const std::map<CoinDenomination, CAmount>& mapCoinsHeld)
{
CoinDenomination maxDenom = ZQ_ERROR;
for (auto& coin : reverse_iterate(zerocoinDenomList)) {
if (mapCoinsHeld.at(coin)) {
maxDenom = coin;
break;
}
}
return maxDenom;
}
// -------------------------------------------------------------------------------------------------------
// Get Exact Amount with CoinsHeld
// -------------------------------------------------------------------------------------------------------
std::map<CoinDenomination, CAmount> getSpendCoins(const CAmount nValueTarget,
const std::map<CoinDenomination, CAmount> mapOfDenomsHeld)
{
std::map<CoinDenomination, CAmount> mapUsed;
CAmount nRemainingValue = nValueTarget;
// Initialize
for (const auto& denom : zerocoinDenomList)
mapUsed.insert(std::pair<CoinDenomination, CAmount>(denom, 0));
// Start with the Highest Denomination coin and grab coins as long as the remaining amount is greater than the
// current denomination value and we have the denom
for (auto& coin : reverse_iterate(zerocoinDenomList)) {
CAmount nValue = ZerocoinDenominationToAmount(coin);
do {
if ((nRemainingValue >= nValue) && (mapUsed.at(coin) < mapOfDenomsHeld.at(coin))) {
mapUsed.at(coin)++;
nRemainingValue -= nValue;
}
} while ((nRemainingValue >= nValue) && (mapUsed.at(coin) < mapOfDenomsHeld.at(coin)));
}
return mapUsed;
}
// -------------------------------------------------------------------------------------------------------
// Get change (no limits)
// -------------------------------------------------------------------------------------------------------
std::map<CoinDenomination, CAmount> getChange(const CAmount nValueTarget)
{
std::map<CoinDenomination, CAmount> mapChange;
CAmount nRemainingValue = nValueTarget;
// Initialize
for (const auto& denom : zerocoinDenomList)
mapChange.insert(std::pair<CoinDenomination, CAmount>(denom, 0));
// Start with the Highest Denomination coin and grab coins as long as the remaining amount is greater than the
// current denomination value
for (auto& coin : reverse_iterate(zerocoinDenomList)) {
CAmount nValue = ZerocoinDenominationToAmount(coin);
do {
if (nRemainingValue >= nValue) {
mapChange.at(coin)++;
nRemainingValue -= nValue;
}
} while (nRemainingValue >= nValue);
}
return mapChange;
}
// -------------------------------------------------------------------------------------------------------
// Attempt to use coins held to exactly reach nValueTarget, return mapOfDenomsUsed with the coin set used
// Return false if exact match is not possible
// -------------------------------------------------------------------------------------------------------
bool getIdealSpends(
const CAmount nValueTarget,
const std::list<CMintMeta>& listMints,
const std::map<CoinDenomination, CAmount> mapOfDenomsHeld,
std::map<CoinDenomination, CAmount>& mapOfDenomsUsed)
{
CAmount nRemainingValue = nValueTarget;
// Initialize
for (const auto& denom : zerocoinDenomList)
mapOfDenomsUsed.insert(std::pair<CoinDenomination, CAmount>(denom, 0));
// Start with the Highest Denomination coin and grab coins as long as the remaining amount is greater than the
// current denomination value
for (auto& coin : reverse_iterate(zerocoinDenomList)) {
for (const CMintMeta& mint : listMints) {
if (mint.isUsed) continue;
if (nRemainingValue >= ZerocoinDenominationToAmount(coin) && coin == mint.denom) {
mapOfDenomsUsed.at(coin)++;
nRemainingValue -= ZerocoinDenominationToAmount(mint.denom);
}
if (nRemainingValue < ZerocoinDenominationToAmount(coin)) break;
}
}
return (nRemainingValue == 0);
}
// -------------------------------------------------------------------------------------------------------
// Return a list of Mint coins based on mapOfDenomsUsed and the overall value in nCoinsSpentValue
// -------------------------------------------------------------------------------------------------------
std::vector<CMintMeta> getSpends(
const std::list<CMintMeta>& listMints,
std::map<CoinDenomination, CAmount>& mapOfDenomsUsed,
CAmount& nCoinsSpentValue)
{
std::vector<CMintMeta> vSelectedMints;
nCoinsSpentValue = 0;
for (auto& coin : reverse_iterate(zerocoinDenomList)) {
do {
for (const CMintMeta& mint : listMints) {
if (mint.isUsed) continue;
if (coin == mint.denom && mapOfDenomsUsed.at(coin)) {
vSelectedMints.push_back(mint);
nCoinsSpentValue += ZerocoinDenominationToAmount(coin);
mapOfDenomsUsed.at(coin)--;
}
}
} while (mapOfDenomsUsed.at(coin));
}
return vSelectedMints;
}
// -------------------------------------------------------------------------------------------------------
// Just for printing/debuggin
// -------------------------------------------------------------------------------------------------------
void listSpends(const std::vector<CZerocoinMint>& vSelectedMints)
{
std::map<libzerocoin::CoinDenomination, int64_t> mapZerocoinSupply;
for (auto& denom : libzerocoin::zerocoinDenomList)
mapZerocoinSupply.insert(std::make_pair(denom, 0));
for (const CZerocoinMint& mint : vSelectedMints) {
libzerocoin::CoinDenomination denom = mint.GetDenomination();
mapZerocoinSupply.at(denom)++;
}
CAmount nTotal = 0;
for (auto& denom : libzerocoin::zerocoinDenomList) {
LogPrint("zero", "%s %d coins for denomination %d used\n", __func__, mapZerocoinSupply.at(denom), denom);
nTotal += libzerocoin::ZerocoinDenominationToAmount(denom);
}
LogPrint("zero", "Total value of coins %d\n", nTotal);
}
// -------------------------------------------------------------------------------------------------------
// Find the CoinDenomination with the most number for a given amount
// -------------------------------------------------------------------------------------------------------
CoinDenomination getDenomWithMostCoins(
const std::map<CoinDenomination, CAmount>& mapOfDenomsUsed)
{
CoinDenomination maxCoins = ZQ_ERROR;
CAmount nMaxNumber = 0;
for (const auto& denom : zerocoinDenomList) {
CAmount amount = mapOfDenomsUsed.at(denom);
if (amount > nMaxNumber) {
nMaxNumber = amount;
maxCoins = denom;
}
}
return maxCoins;
}
// -------------------------------------------------------------------------------------------------------
// Get the next denomination above the current one. Return ZQ_ERROR if already at the highest
// -------------------------------------------------------------------------------------------------------
CoinDenomination getNextHighestDenom(const CoinDenomination& this_denom)
{
CoinDenomination nextValue = ZQ_ERROR;
for (const auto& denom : zerocoinDenomList) {
if (ZerocoinDenominationToAmount(denom) > ZerocoinDenominationToAmount(this_denom)) {
nextValue = denom;
break;
}
}
return nextValue;
}
// -------------------------------------------------------------------------------------------------------
// Get the next denomination below the current one that is also amongst those held.
// Return ZQ_ERROR if none found
// -------------------------------------------------------------------------------------------------------
CoinDenomination getNextLowerDenomHeld(const CoinDenomination& this_denom,
const std::map<CoinDenomination, CAmount>& mapCoinsHeld)
{
CoinDenomination nextValue = ZQ_ERROR;
for (auto& denom : reverse_iterate(zerocoinDenomList)) {
if ((denom < this_denom) && (mapCoinsHeld.at(denom) != 0)) {
nextValue = denom;
break;
}
}
return nextValue;
}
int minimizeChange(
int nMaxNumberOfSpends,
int nChangeCount,
const CoinDenomination nextToMaxDenom,
const CAmount nValueTarget,
const std::map<CoinDenomination, CAmount>& mapOfDenomsHeld,
std::map<CoinDenomination, CAmount>& mapOfDenomsUsed)
{
// Now find out if possible without using 1 coin such that we have more spends but less change
// First get set of coins close to value but still less than value (since not exact)
CAmount nRemainingValue = nValueTarget;
CAmount AmountUsed = 0;
int nCoinCount = 0;
// Re-clear this
std::map<CoinDenomination, CAmount> savedMapOfDenomsUsed = mapOfDenomsUsed;
for (const auto& denom : zerocoinDenomList)
mapOfDenomsUsed.at(denom) = 0;
// Find the amount this is less than total but uses up higher denoms first,
// starting at the denom that is not greater than the overall total
for (const auto& denom : reverse_iterate(zerocoinDenomList)) {
if (denom <= nextToMaxDenom) {
CAmount nValue = ZerocoinDenominationToAmount(denom);
do {
if ((nRemainingValue > nValue) && (mapOfDenomsUsed.at(denom) < mapOfDenomsHeld.at(denom))) {
mapOfDenomsUsed.at(denom)++;
nRemainingValue -= nValue;
AmountUsed += nValue;
nCoinCount++;
}
} while ((nRemainingValue > nValue) && (mapOfDenomsUsed.at(denom) < mapOfDenomsHeld.at(denom)));
}
}
// Now work way back up from the bottom filling in with the denom that we have that is just
// bigger than the remaining amount
// Shouldn't need more than one coin here?
for (const auto& denom : zerocoinDenomList) {
CAmount nValue = ZerocoinDenominationToAmount(denom);
if ((nValue > nRemainingValue) && (mapOfDenomsUsed.at(denom) < mapOfDenomsHeld.at(denom))) {
mapOfDenomsUsed.at(denom)++;
nRemainingValue -= nValue;
AmountUsed += nValue;
nCoinCount++;
}
if (nRemainingValue < 0) break;
}
// This can still result in a case where you've used an extra spend than needed.
// e.g Spend of 26, while having 1*5 + 4*10
// First stage may be 2*10+5 (i.e < 26)
// Second stage can be 3*10+5 (no more fives, so add a 10)
// So 5 is no longer needed and will become change also
CAmount nAltChangeAmount = AmountUsed - nValueTarget;
std::map<CoinDenomination, CAmount> mapAltChange = getChange(nAltChangeAmount);
// Check if there is overlap between change and spend denominations
// And if so, remove those that overlap
for (const auto& denom : zerocoinDenomList) {
do {
if (mapAltChange.at(denom) && mapOfDenomsUsed.at(denom)) {
mapOfDenomsUsed.at(denom)--;
mapAltChange.at(denom)--;
nCoinCount--;
CAmount nValue = ZerocoinDenominationToAmount(denom);
AmountUsed -= nValue;
}
} while (mapAltChange.at(denom) && mapOfDenomsUsed.at(denom));
}
// Still possible to have wrong mix. So meet exact amount found above - with least number of coins
mapOfDenomsUsed = getSpendCoins(AmountUsed, mapOfDenomsHeld);
nCoinCount = getNumberOfCoinsUsed(mapOfDenomsUsed);
// Re-calculate change
nAltChangeAmount = AmountUsed - nValueTarget;
mapAltChange = getChange(nAltChangeAmount);
int AltChangeCount = getNumberOfCoinsUsed(mapAltChange);
// Alternative method yields less mints and is less than MaxNumberOfSpends if true
if ((AltChangeCount < nChangeCount) && (nCoinCount <= nMaxNumberOfSpends)) {
return AltChangeCount;
} else {
// if we don't meet above go back to what we started with
mapOfDenomsUsed = savedMapOfDenomsUsed;
return nChangeCount;
}
}
// -------------------------------------------------------------------------------------------------------
// Couldn't meet amount exactly, will need to generate change
// returning with a 0 means either too many spends or no change
// Latter should never happen since we should only get here if exact is not possible
// -------------------------------------------------------------------------------------------------------
int calculateChange(
int nMaxNumberOfSpends,
bool fMinimizeChange,
const CAmount nValueTarget,
const std::map<CoinDenomination, CAmount>& mapOfDenomsHeld,
std::map<CoinDenomination, CAmount>& mapOfDenomsUsed)
{
CoinDenomination minDenomOverTarget = ZQ_ERROR;
// Initialize
mapOfDenomsUsed.clear();
for (const auto& denom : zerocoinDenomList)
mapOfDenomsUsed.insert(std::pair<CoinDenomination, CAmount>(denom, 0));
for (const auto& denom : zerocoinDenomList) {
if (nValueTarget < ZerocoinDenominationToAmount(denom) && mapOfDenomsHeld.at(denom)) {
minDenomOverTarget = denom;
break;
}
}
// OK so if != ZQ_ERROR we have a solution using 1 coin
if (minDenomOverTarget != ZQ_ERROR) {
mapOfDenomsUsed.at(minDenomOverTarget) = 1;
// Now find out # of coins in change
CAmount nChangeAmount = ZerocoinDenominationToAmount(minDenomOverTarget) - nValueTarget;
std::map<CoinDenomination, CAmount> mapChange = getChange(nChangeAmount);
int nChangeCount = getNumberOfCoinsUsed(mapChange);
if (fMinimizeChange) {
CoinDenomination nextToMaxDenom = getNextLowerDenomHeld(minDenomOverTarget, mapOfDenomsHeld);
int newChangeCount = minimizeChange(nMaxNumberOfSpends, nChangeCount,
nextToMaxDenom, nValueTarget,
mapOfDenomsHeld, mapOfDenomsUsed);
// Alternative method yields less mints and is less than MaxNumberOfSpends if true
if (newChangeCount < nChangeCount) return newChangeCount;
// Reclear
for (const auto& denom : zerocoinDenomList)
mapOfDenomsUsed.at(denom) = 0;
// Then reset as before previous clearing
mapOfDenomsUsed.at(minDenomOverTarget) = 1;
}
return nChangeCount;
} else {
// Try to meet a different way
for (const auto& denom : zerocoinDenomList)
mapOfDenomsUsed.at(denom) = 0;
CAmount nRemainingValue = nValueTarget;
int nCoinCount = 0;
CAmount AmountUsed = 0;
for (const auto& denom : reverse_iterate(zerocoinDenomList)) {
CAmount nValue = ZerocoinDenominationToAmount(denom);
do {
if (mapOfDenomsHeld.at(denom) && nRemainingValue > 0) {
mapOfDenomsUsed.at(denom)++;
AmountUsed += nValue;
nRemainingValue -= nValue;
nCoinCount++;
}
} while ((nRemainingValue > 0) && (mapOfDenomsUsed.at(denom) < mapOfDenomsHeld.at(denom)));
if (nRemainingValue < 0) break;
}
CAmount nChangeAmount = AmountUsed - nValueTarget;
std::map<CoinDenomination, CAmount> mapChange = getChange(nChangeAmount);
int nMaxChangeCount = getNumberOfCoinsUsed(mapChange);
// Instead get max Denom held
CoinDenomination maxDenomHeld = getMaxDenomHeld(mapOfDenomsHeld);
// Assign for size (only)
std::map<CoinDenomination, CAmount> mapOfMinDenomsUsed = mapOfDenomsUsed;
int nChangeCount = minimizeChange(nMaxNumberOfSpends, nMaxChangeCount,
maxDenomHeld, nValueTarget,
mapOfDenomsHeld, mapOfMinDenomsUsed);
int nNumSpends = getNumberOfCoinsUsed(mapOfMinDenomsUsed);
if (!fMinimizeChange && (nCoinCount < nNumSpends)) {
return nMaxChangeCount;
}
mapOfDenomsUsed = mapOfMinDenomsUsed;
return nChangeCount;
}
}
// -------------------------------------------------------------------------------------------------------
// Given a Target Spend Amount, attempt to meet it with a set of coins where less than nMaxNumberOfSpends
// 'spends' are required
// -------------------------------------------------------------------------------------------------------
std::vector<CMintMeta> SelectMintsFromList(const CAmount nValueTarget, CAmount& nSelectedValue, int nMaxNumberOfSpends, bool fMinimizeChange,
int& nCoinsReturned, const std::list<CMintMeta>& listMints,
const std::map<CoinDenomination, CAmount> mapOfDenomsHeld, int& nNeededSpends)
{
std::vector<CMintMeta> vSelectedMints;
std::map<CoinDenomination, CAmount> mapOfDenomsUsed;
nNeededSpends = 0;
bool fCanMeetExactly = getIdealSpends(nValueTarget, listMints, mapOfDenomsHeld, mapOfDenomsUsed);
if (fCanMeetExactly) {
nCoinsReturned = 0;
nSelectedValue = nValueTarget;
vSelectedMints = getSpends(listMints, mapOfDenomsUsed, nSelectedValue);
// If true, we are good and done!
if (vSelectedMints.size() <= (size_t)nMaxNumberOfSpends) {
return vSelectedMints;
}
else {
nNeededSpends = vSelectedMints.size();
}
}
// Since either too many spends needed or can not spend the exact amount,
// calculate the change needed and the map of coins used
nCoinsReturned = calculateChange(nMaxNumberOfSpends, fMinimizeChange, nValueTarget, mapOfDenomsHeld, mapOfDenomsUsed);
if (nCoinsReturned == 0) {
LogPrint("zero", "%s: Problem getting change (TBD) or Too many spends %d\n", __func__, nValueTarget);
vSelectedMints.clear();
} else {
vSelectedMints = getSpends(listMints, mapOfDenomsUsed, nSelectedValue);
LogPrint("zero", "%s: %d coins in change for %d\n", __func__, nCoinsReturned, nValueTarget);
}
return vSelectedMints;
}
| [
"ultrapoolcom@gmail.com"
] | ultrapoolcom@gmail.com |
4950d8f1b1f31b7039128c29dd63905573692d7c | c1aa670a76f768b2c686cb198246e32cadb250c6 | /vlib2/test/lib.cpp | e974ea24e94b4a04927a84bc114e591e9eb0f84f | [
"BSD-3-Clause"
] | permissive | ManiSadati/GPU_Logic_resimulator | 7679abf3247e30228f871632bfb9a42276c85011 | f2f9a911df923c25d964ef0e2b4cb120e40308e5 | refs/heads/master | 2023-01-14T13:20:58.256502 | 2020-11-14T15:05:40 | 2020-11-14T15:05:40 | 310,926,386 | 11 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,582 | cpp | #include<bits/stdc++.h>
#include"lib.h"
using namespace std;
VAL operator ! (VAL const &v1){
if(v1%3==0)
return I;
if(v1%3==1)
return O;
if(v1%3==2)
return X;
return X;
}
int num(VAL* v,int n){
int x=0;
for(int i=n-1;i>=0;i--){
x*=2;
x+=v[i]%3;
}
return x;
}
VAL operator & (VAL const &v1,VAL const &v2){
int x1=(int)(v1%3);
int x2=(int)(v2%3);
if(v1==Z)
x1=2;
if(v2==Z)
x2=2;
if(x1==0 || x2==0)
return O;
if(x1==2 || x2==2)
return X;
return I;
}
VAL operator | (VAL const &v1,VAL const &v2){
int x1=(int)(v1%3);
int x2=(int)(v2%3);
if(v1==Z)
x1=2;
if(v2==Z)
x2=2;
if(x1==1 || x2==1)
return I;
if(x1==2 || x2==2)
return X;
return O;
}
VAL operator ^ (VAL const &v1,VAL const &v2){
int x1=(int)(v1%3);
int x2=(int)(v2%3);
if(v1==Z)
x1=2;
if(v2==Z)
x2=2;
if(x1==2 || x2==2)
return X;
if(x1==x2)
return O;
return I;
}
VAL first(VAL v){
if(v==O || v==I || v==X || v==Z){
return v;
}
if(v==IO || v==IX)
return I;
if(v==OI || v==OX)
return O;
if(v==XI || v==XO)
return X;
return X;
}
VAL second(VAL v){
if(v==O || v==I || v==X || v==Z){
return v;
}
if(v==OI || v==XI)
return I;
if(v==IO || v==XO)
return O;
if(v==IX || v==OX)
return X;
return X;
}
VAL join(VAL z1,VAL z2){
if(z1==z2)
return z1;
if(z1==I && z2==O)
return IO;
if(z1==O && z2==I)
return OI;
if(z1==I && z2==X)
return IX;
if(z1==X && z2==I)
return XI;
if(z1==O && z2==X)
return OX;
if(z1==X && z2==O)
return XO;
return X;
}
bool p_edge(VAL v){
if(v==OI || v==OX || v==XI)
return true;
return false;
}
bool n_edge(VAL v){
if(v==IO || v==XO || v==IX)
return true;
return false;
}
bool pn_edge(VAL v){
if(p_edge(v) || n_edge(v))
return true;
return false;
}
VAL AND_(VAL x1,VAL x2){
VAL y1,y2;
y1=first(x1);
y2=first(x2);
VAL z1=y1&y2;
y1=second(x1);
y2=second(x2);
VAL z2=y1&y2;
return join(z1,z2);
}
VAL OR_(VAL x1,VAL x2){
VAL y1,y2;
y1=first(x1);
y2=first(x2);
VAL z1=y1|y2;
y1=second(x1);
y2=second(x2);
VAL z2=y1|y2;
return join(z1,z2);
}
VAL XOR_(VAL x1,VAL x2){
VAL y1,y2;
y1=first(x1);
y2=first(x2);
VAL z1=y1^y2;
y1=second(x1);
y2=second(x2);
VAL z2=y1^y2;
return join(z1,z2);
}
VAL NOT_(VAL x1){
VAL y1;
y1=first(x1);
VAL z1=!y1;
y1=second(x1);
VAL z2=!y1;
return join(z1,z2);
}
void AND(VAL &z,VAL x1,VAL x2,VAL x3,VAL x4){
z=AND_(AND_(AND_(x1,x2),x3),x4);
}
void OR(VAL &z,VAL x1,VAL x2,VAL x3,VAL x4){
z=OR_(OR_(OR_(x1,x2),x3),x4);
}
void NOR(VAL &z,VAL x1,VAL x2,VAL x3,VAL x4){
z=NOT_(OR_(OR_(OR_(x1,x2),x3),x4));
}
void NAND(VAL &z,VAL x1,VAL x2,VAL x3,VAL x4){
z=NOT_(AND_(AND_(AND_(x1,x2),x3),x4));
}
void NOT(VAL &z,VAL x1){
z=NOT_(x1);
}
void BUF(VAL &z,VAL x1){
if(x1==Z)
z=X;
}
void XOR(VAL &z,VAL x1,VAL x2,VAL x3,VAL x4){
z=XOR_(XOR_(XOR_(x1,x2),x3),x4);
}
void XNOR(VAL &z,VAL x1,VAL x2,VAL x3,VAL x4){
z=NOT_(XOR_(XOR_(XOR_(x1,x2),x3),x4));
}
bool part(VAL v,string s){
if(s=="0" && (v==O || v==IO || v==XO))
return true;
if(s=="1" && (v==I || v==XI || v==OI))
return true;
if(s=="x" && (v==X || v==IX || v==OX))
return true;
if(s=="?")
return true;
if(s=="*" && v!=I && v!=X && v!=O)
return true;
if(s=="b" && (v==I || v==O))
return true;
if(s=="01" && v==OI)
return true;
if(s=="10" && v==IO)
return true;
if(s=="1?" && (v==IO || v==IX))
return true;
if(s=="0?" && (v==OI || v==OX))
return true;
if(s=="?0" && (v==IO || v==XO))
return true;
if(s=="?1" && (v==OI || v==XI))
return true;
if(s=="?x" && (v==IX || v==OX))
return true;
if(s=="x?" && (v==XO || v==XI))
return true;
return false;
}
void udp_dff::function(VAL &qp,VAL d,VAL clk,VAL clr,VAL set,VAL notifier){
for(int i=0;i<17;i++){
if(part(d,s[i][0]) && part(clk,s[i][1]) && part(clr,s[i][2]) && part(set,s[i][3]) && part(notifier,s[i][4]) && part(q,s[i][5])){
if(s[i][6]=="1")
qp=I;
if(s[i][6]=="0")
qp=O;
if(s[i][6]=="x")
qp=X;
if(s[i][6]=="-")
qp=q;
return;
}
}
qp=X;
}
void udp_tlat::function(VAL &qp,VAL d,VAL clk,VAL clr,VAL set,VAL notifier){
for(int i=0;i<13;i++){
//cout<<i<<endl;
if(part(d,s[i][0]) && part(clk,s[i][1]) && part(clr,s[i][2]) && part(set,s[i][3]) && part(notifier,s[i][4]) && part(q,s[i][5])){
cout<<i<<endl;
if(s[i][6]=="1")
qp=I;
if(s[i][6]=="0")
qp=O;
if(s[i][6]=="x")
qp=X;
if(s[i][6]=="-")
qp=q;
return;
}
}
qp=X;
}
void udp_mux2::function(VAL &z,VAL i0,VAL i1,VAL S){
for(int i=0;i<6;i++){
if(part(i0,s[i][0]) && part(i1,s[i][1]) && part(S,s[i][2])){
if(s[i][3]=="1")
z=I;
if(s[i][3]=="0")
z=O;
if(s[i][3]=="x")
z=X;
return;
}
}
z=X;
}
void udp_xbuf::function(VAL &o,VAL i0,VAL check_signal){
for(int i=0;i<3;i++){
if(part(i0,s[i][0]) && part(check_signal,s[i][1])){
if(s[i][2]=="1")
o=I;
if(s[i][2]=="0")
o=O;
if(s[i][2]=="x")
o=X;
return;
}
}
o=X;
}
/*
int main(){
VAL x1,x2,x3,x4;
while(true){
int x;
cin>>x;
x1=(VAL)x;
cin>>x;
x2=(VAL)x;
cin>>x;
x3=(VAL)x;
cin>>x;
x4=(VAL)x;
VAL z;
OR(z,x1,x2,x3,x4);
cout<<z<<endl;
}
udp_tlat df;
VAL z;
VAL a[5];
while(true){
for(int i=0;i<5;i++){
int x;
cin>>x;
a[i]=(VAL)x;
}
df.function(z,a[0],a[1],a[2],a[3],a[4]);
cout<<z<<endl;
}
}
*/
| [
"sadati.man@outlook.com"
] | sadati.man@outlook.com |
3dbb9e55536f68e9874755a89d48241574a60123 | dd5356457879b9edf8c982a412e0068f94da697d | /SDK/RoCo_ChaosLauncherReticle_classes.hpp | 7393704440075daaabcf8837f504a64c9bdb03c8 | [] | no_license | ALEHACKsp/RoCo-SDK | 5ee6567294674b6933dcd0acda720f64712ccdbf | 3a9e37be3a48bc0a10aa9e4111865c996f3b5680 | refs/heads/master | 2023-05-14T16:54:49.296847 | 2021-06-08T20:09:37 | 2021-06-08T20:09:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,885 | hpp | #pragma once
// Rogue Company (0.60) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "RoCo_ChaosLauncherReticle_structs.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// WidgetBlueprintGeneratedClass ChaosLauncherReticle.ChaosLauncherReticle_C
// 0x0010 (0x0248 - 0x0238)
class UChaosLauncherReticle_C : public UUserWidget
{
public:
class UImage* Launcher; // 0x0238(0x0008) (CPF_BlueprintVisible, CPF_ExportObject, CPF_ZeroConstructor, CPF_InstancedReference, CPF_IsPlainOldData, CPF_RepSkip, CPF_NoDestructor, CPF_PersistentInstance, CPF_HasGetValueTypeHash)
float LowAmmoThreshold; // 0x0240(0x0004) (CPF_Edit, CPF_BlueprintVisible, CPF_BlueprintReadOnly, CPF_ZeroConstructor, CPF_DisableEditOnInstance, CPF_IsPlainOldData, CPF_NoDestructor, CPF_HasGetValueTypeHash)
float CriticallyLowAmmoThreshold; // 0x0244(0x0004) (CPF_Edit, CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_DisableEditOnInstance, CPF_IsPlainOldData, CPF_NoDestructor, CPF_HasGetValueTypeHash)
static UClass* StaticClass()
{
static auto ptr = UObject::FindObject<UClass>("WidgetBlueprintGeneratedClass ChaosLauncherReticle.ChaosLauncherReticle_C");
return ptr;
}
void GetAmmoState(class UKSWeaponComponent* NewParam, EAmmoState* Return_Value);
void HitConfirm();
void ForceADS(bool Active);
void GrenadeCook(bool Active, float TickPeriod);
void ChangeADS(bool Active);
void KillConfirm();
void Headshot();
void UpdateOffset(float Offset);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"30532128+pubgsdk@users.noreply.github.com"
] | 30532128+pubgsdk@users.noreply.github.com |
b4a67335f83147d6f934b375b51c2079a5d7decb | a9a7f08ebf49cf514f84f24492eea340e0efbb78 | /src/plugins/surfacedescriptors/surfacedescriptorsplugin.cpp | 4955361599fda336f8659e05e4f4edc3b7b6af76 | [
"BSD-3-Clause"
] | permissive | soplwang/chemkit | d535e91ddd2cea733554eef647dd488049dc0429 | 8d8e150160d44a4c770e343a22dee9e462b10694 | refs/heads/master | 2021-01-15T22:56:45.583833 | 2012-07-13T20:00:07 | 2012-07-13T20:00:07 | 3,108,867 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,531 | cpp | /******************************************************************************
**
** Copyright (C) 2009-2012 Kyle Lutz <kyle.r.lutz@gmail.com>
** All rights reserved.
**
** This file is a part of the chemkit project. For more information
** see <http://www.chemkit.org>.
**
** 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 chemkit project 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 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.
**
******************************************************************************/
#include <chemkit/plugin.h>
#include "surfacedescriptors.h"
class SurfaceDescriptorsPlugin : public chemkit::Plugin
{
public:
SurfaceDescriptorsPlugin()
: chemkit::Plugin("surfacedescriptors")
{
CHEMKIT_REGISTER_MOLECULAR_DESCRIPTOR("vdw-area", VanDerWallsAreaDescriptor);
CHEMKIT_REGISTER_MOLECULAR_DESCRIPTOR("vdw-volume", VanDerWallsVolumeDescriptor);
CHEMKIT_REGISTER_MOLECULAR_DESCRIPTOR("sas-area", SolventAccessibleAreaDescriptor);
CHEMKIT_REGISTER_MOLECULAR_DESCRIPTOR("sas-volume", SolventAccessibleVolumeDescriptor);
}
};
CHEMKIT_EXPORT_PLUGIN(surfacedescriptors, SurfaceDescriptorsPlugin)
| [
"kyle.r.lutz@gmail.com"
] | kyle.r.lutz@gmail.com |
06be699a4d222f08cb08f773f308b8404f19ea9c | 9d47b6f889df749a4d603e57fec591ff231db1e4 | /First_Stage/build/AnalysisCam/AnalysisCamEvent/CMakeFiles/makeAnalysisCamEventCintDict.3pl3om/AnalysisCamEventCintDict.cxx | ff8d310ea920a60fd2aca9d70688f0cb62a2abc7 | [] | no_license | mattcleigh/Masters | b9b876d430ad8a16424278a7a195381c0bfbb427 | 2e8dfee3abcff871b32fa860d946db546841b2f4 | refs/heads/master | 2022-11-30T11:13:43.596161 | 2020-08-24T17:09:00 | 2020-08-24T17:09:00 | 289,966,418 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 49,602 | cxx | // Do NOT change. Changes will be lost next time file is generated
#define R__DICTIONARY_FILENAME AnalysisCamEventCintDict
/*******************************************************************/
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define G__DICTIONARY
#include "RConfig.h"
#include "TClass.h"
#include "TDictAttributeMap.h"
#include "TInterpreter.h"
#include "TROOT.h"
#include "TBuffer.h"
#include "TMemberInspector.h"
#include "TInterpreter.h"
#include "TVirtualMutex.h"
#include "TError.h"
#ifndef G__ROOT
#define G__ROOT
#endif
#include "RtypesImp.h"
#include "TIsAProxy.h"
#include "TFileMergeInfo.h"
#include <algorithm>
#include "TCollectionProxyInfo.h"
/*******************************************************************/
#include "TDataMember.h"
// Since CINT ignores the std namespace, we need to do so in this file.
namespace std {} using namespace std;
// Header files passed as explicit arguments
#include "AnalysisCamEvent/CamObject.h"
#include "AnalysisCamEvent/CamVector.h"
#include "AnalysisCamEvent/CamDeque.h"
#include "AnalysisCamEvent/CamEvent.h"
#include "AnalysisCamEvent/CamEvent.h"
#include "AnalysisCamEvent/CamDeque.h"
#include "AnalysisCamEvent/CamVector.h"
#include "AnalysisCamEvent/CamObject.h"
// Header files passed via #pragma extra_include
namespace ROOT {
static void *new_CamObject(void *p = 0);
static void *newArray_CamObject(Long_t size, void *p);
static void delete_CamObject(void *p);
static void deleteArray_CamObject(void *p);
static void destruct_CamObject(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::CamObject*)
{
::CamObject *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::CamObject >(0);
static ::ROOT::TGenericClassInfo
instance("CamObject", ::CamObject::Class_Version(), "AnalysisCamEvent/CamObject.h", 82,
typeid(::CamObject), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&::CamObject::Dictionary, isa_proxy, 4,
sizeof(::CamObject) );
instance.SetNew(&new_CamObject);
instance.SetNewArray(&newArray_CamObject);
instance.SetDelete(&delete_CamObject);
instance.SetDeleteArray(&deleteArray_CamObject);
instance.SetDestructor(&destruct_CamObject);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::CamObject*)
{
return GenerateInitInstanceLocal((::CamObject*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const ::CamObject*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));
} // end of namespace ROOT
namespace ROOT {
static void *new_CamDeque(void *p = 0);
static void *newArray_CamDeque(Long_t size, void *p);
static void delete_CamDeque(void *p);
static void deleteArray_CamDeque(void *p);
static void destruct_CamDeque(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::CamDeque*)
{
::CamDeque *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::CamDeque >(0);
static ::ROOT::TGenericClassInfo
instance("CamDeque", ::CamDeque::Class_Version(), "AnalysisCamEvent/CamDeque.h", 11,
typeid(::CamDeque), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&::CamDeque::Dictionary, isa_proxy, 4,
sizeof(::CamDeque) );
instance.SetNew(&new_CamDeque);
instance.SetNewArray(&newArray_CamDeque);
instance.SetDelete(&delete_CamDeque);
instance.SetDeleteArray(&deleteArray_CamDeque);
instance.SetDestructor(&destruct_CamDeque);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::CamDeque*)
{
return GenerateInitInstanceLocal((::CamDeque*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const ::CamDeque*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));
} // end of namespace ROOT
namespace ROOT {
static void *new_CamVector(void *p = 0);
static void *newArray_CamVector(Long_t size, void *p);
static void delete_CamVector(void *p);
static void deleteArray_CamVector(void *p);
static void destruct_CamVector(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::CamVector*)
{
::CamVector *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::CamVector >(0);
static ::ROOT::TGenericClassInfo
instance("CamVector", ::CamVector::Class_Version(), "AnalysisCamEvent/CamVector.h", 11,
typeid(::CamVector), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&::CamVector::Dictionary, isa_proxy, 4,
sizeof(::CamVector) );
instance.SetNew(&new_CamVector);
instance.SetNewArray(&newArray_CamVector);
instance.SetDelete(&delete_CamVector);
instance.SetDeleteArray(&deleteArray_CamVector);
instance.SetDestructor(&destruct_CamVector);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::CamVector*)
{
return GenerateInitInstanceLocal((::CamVector*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const ::CamVector*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));
} // end of namespace ROOT
namespace ROOT {
static void *new_CamEvent(void *p = 0);
static void *newArray_CamEvent(Long_t size, void *p);
static void delete_CamEvent(void *p);
static void deleteArray_CamEvent(void *p);
static void destruct_CamEvent(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::CamEvent*)
{
::CamEvent *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::CamEvent >(0);
static ::ROOT::TGenericClassInfo
instance("CamEvent", ::CamEvent::Class_Version(), "AnalysisCamEvent/CamEvent.h", 19,
typeid(::CamEvent), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&::CamEvent::Dictionary, isa_proxy, 4,
sizeof(::CamEvent) );
instance.SetNew(&new_CamEvent);
instance.SetNewArray(&newArray_CamEvent);
instance.SetDelete(&delete_CamEvent);
instance.SetDeleteArray(&deleteArray_CamEvent);
instance.SetDestructor(&destruct_CamEvent);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::CamEvent*)
{
return GenerateInitInstanceLocal((::CamEvent*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const ::CamEvent*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));
} // end of namespace ROOT
//______________________________________________________________________________
atomic_TClass_ptr CamObject::fgIsA(0); // static to hold class pointer
//______________________________________________________________________________
const char *CamObject::Class_Name()
{
return "CamObject";
}
//______________________________________________________________________________
const char *CamObject::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::CamObject*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int CamObject::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::CamObject*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
TClass *CamObject::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::CamObject*)0x0)->GetClass();
return fgIsA;
}
//______________________________________________________________________________
TClass *CamObject::Class()
{
if (!fgIsA.load()) { R__LOCKGUARD(gInterpreterMutex); fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::CamObject*)0x0)->GetClass(); }
return fgIsA;
}
//______________________________________________________________________________
atomic_TClass_ptr CamDeque::fgIsA(0); // static to hold class pointer
//______________________________________________________________________________
const char *CamDeque::Class_Name()
{
return "CamDeque";
}
//______________________________________________________________________________
const char *CamDeque::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::CamDeque*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int CamDeque::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::CamDeque*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
TClass *CamDeque::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::CamDeque*)0x0)->GetClass();
return fgIsA;
}
//______________________________________________________________________________
TClass *CamDeque::Class()
{
if (!fgIsA.load()) { R__LOCKGUARD(gInterpreterMutex); fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::CamDeque*)0x0)->GetClass(); }
return fgIsA;
}
//______________________________________________________________________________
atomic_TClass_ptr CamVector::fgIsA(0); // static to hold class pointer
//______________________________________________________________________________
const char *CamVector::Class_Name()
{
return "CamVector";
}
//______________________________________________________________________________
const char *CamVector::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::CamVector*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int CamVector::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::CamVector*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
TClass *CamVector::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::CamVector*)0x0)->GetClass();
return fgIsA;
}
//______________________________________________________________________________
TClass *CamVector::Class()
{
if (!fgIsA.load()) { R__LOCKGUARD(gInterpreterMutex); fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::CamVector*)0x0)->GetClass(); }
return fgIsA;
}
//______________________________________________________________________________
atomic_TClass_ptr CamEvent::fgIsA(0); // static to hold class pointer
//______________________________________________________________________________
const char *CamEvent::Class_Name()
{
return "CamEvent";
}
//______________________________________________________________________________
const char *CamEvent::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::CamEvent*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int CamEvent::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::CamEvent*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
TClass *CamEvent::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::CamEvent*)0x0)->GetClass();
return fgIsA;
}
//______________________________________________________________________________
TClass *CamEvent::Class()
{
if (!fgIsA.load()) { R__LOCKGUARD(gInterpreterMutex); fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::CamEvent*)0x0)->GetClass(); }
return fgIsA;
}
//______________________________________________________________________________
void CamObject::Streamer(TBuffer &R__b)
{
// Stream an object of class CamObject.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(CamObject::Class(),this);
} else {
R__b.WriteClassBuffer(CamObject::Class(),this);
}
}
namespace ROOT {
// Wrappers around operator new
static void *new_CamObject(void *p) {
return p ? new(p) ::CamObject : new ::CamObject;
}
static void *newArray_CamObject(Long_t nElements, void *p) {
return p ? new(p) ::CamObject[nElements] : new ::CamObject[nElements];
}
// Wrapper around operator delete
static void delete_CamObject(void *p) {
delete ((::CamObject*)p);
}
static void deleteArray_CamObject(void *p) {
delete [] ((::CamObject*)p);
}
static void destruct_CamObject(void *p) {
typedef ::CamObject current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::CamObject
//______________________________________________________________________________
void CamDeque::Streamer(TBuffer &R__b)
{
// Stream an object of class CamDeque.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(CamDeque::Class(),this);
} else {
R__b.WriteClassBuffer(CamDeque::Class(),this);
}
}
namespace ROOT {
// Wrappers around operator new
static void *new_CamDeque(void *p) {
return p ? new(p) ::CamDeque : new ::CamDeque;
}
static void *newArray_CamDeque(Long_t nElements, void *p) {
return p ? new(p) ::CamDeque[nElements] : new ::CamDeque[nElements];
}
// Wrapper around operator delete
static void delete_CamDeque(void *p) {
delete ((::CamDeque*)p);
}
static void deleteArray_CamDeque(void *p) {
delete [] ((::CamDeque*)p);
}
static void destruct_CamDeque(void *p) {
typedef ::CamDeque current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::CamDeque
//______________________________________________________________________________
void CamVector::Streamer(TBuffer &R__b)
{
// Stream an object of class CamVector.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(CamVector::Class(),this);
} else {
R__b.WriteClassBuffer(CamVector::Class(),this);
}
}
namespace ROOT {
// Wrappers around operator new
static void *new_CamVector(void *p) {
return p ? new(p) ::CamVector : new ::CamVector;
}
static void *newArray_CamVector(Long_t nElements, void *p) {
return p ? new(p) ::CamVector[nElements] : new ::CamVector[nElements];
}
// Wrapper around operator delete
static void delete_CamVector(void *p) {
delete ((::CamVector*)p);
}
static void deleteArray_CamVector(void *p) {
delete [] ((::CamVector*)p);
}
static void destruct_CamVector(void *p) {
typedef ::CamVector current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::CamVector
//______________________________________________________________________________
void CamEvent::Streamer(TBuffer &R__b)
{
// Stream an object of class CamEvent.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(CamEvent::Class(),this);
} else {
R__b.WriteClassBuffer(CamEvent::Class(),this);
}
}
namespace ROOT {
// Wrappers around operator new
static void *new_CamEvent(void *p) {
return p ? new(p) ::CamEvent : new ::CamEvent;
}
static void *newArray_CamEvent(Long_t nElements, void *p) {
return p ? new(p) ::CamEvent[nElements] : new ::CamEvent[nElements];
}
// Wrapper around operator delete
static void delete_CamEvent(void *p) {
delete ((::CamEvent*)p);
}
static void deleteArray_CamEvent(void *p) {
delete [] ((::CamEvent*)p);
}
static void destruct_CamEvent(void *p) {
typedef ::CamEvent current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::CamEvent
namespace ROOT {
static TClass *vectorlECamObjectgR_Dictionary();
static void vectorlECamObjectgR_TClassManip(TClass*);
static void *new_vectorlECamObjectgR(void *p = 0);
static void *newArray_vectorlECamObjectgR(Long_t size, void *p);
static void delete_vectorlECamObjectgR(void *p);
static void deleteArray_vectorlECamObjectgR(void *p);
static void destruct_vectorlECamObjectgR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const vector<CamObject>*)
{
vector<CamObject> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(vector<CamObject>));
static ::ROOT::TGenericClassInfo
instance("vector<CamObject>", -2, "vector", 214,
typeid(vector<CamObject>), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&vectorlECamObjectgR_Dictionary, isa_proxy, 0,
sizeof(vector<CamObject>) );
instance.SetNew(&new_vectorlECamObjectgR);
instance.SetNewArray(&newArray_vectorlECamObjectgR);
instance.SetDelete(&delete_vectorlECamObjectgR);
instance.SetDeleteArray(&deleteArray_vectorlECamObjectgR);
instance.SetDestructor(&destruct_vectorlECamObjectgR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::Pushback< vector<CamObject> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const vector<CamObject>*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));
// Dictionary for non-ClassDef classes
static TClass *vectorlECamObjectgR_Dictionary() {
TClass* theClass =::ROOT::GenerateInitInstanceLocal((const vector<CamObject>*)0x0)->GetClass();
vectorlECamObjectgR_TClassManip(theClass);
return theClass;
}
static void vectorlECamObjectgR_TClassManip(TClass* ){
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_vectorlECamObjectgR(void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) vector<CamObject> : new vector<CamObject>;
}
static void *newArray_vectorlECamObjectgR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) vector<CamObject>[nElements] : new vector<CamObject>[nElements];
}
// Wrapper around operator delete
static void delete_vectorlECamObjectgR(void *p) {
delete ((vector<CamObject>*)p);
}
static void deleteArray_vectorlECamObjectgR(void *p) {
delete [] ((vector<CamObject>*)p);
}
static void destruct_vectorlECamObjectgR(void *p) {
typedef vector<CamObject> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class vector<CamObject>
namespace ROOT {
static TClass *vectorlECamObjectmUgR_Dictionary();
static void vectorlECamObjectmUgR_TClassManip(TClass*);
static void *new_vectorlECamObjectmUgR(void *p = 0);
static void *newArray_vectorlECamObjectmUgR(Long_t size, void *p);
static void delete_vectorlECamObjectmUgR(void *p);
static void deleteArray_vectorlECamObjectmUgR(void *p);
static void destruct_vectorlECamObjectmUgR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const vector<CamObject*>*)
{
vector<CamObject*> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(vector<CamObject*>));
static ::ROOT::TGenericClassInfo
instance("vector<CamObject*>", -2, "vector", 214,
typeid(vector<CamObject*>), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&vectorlECamObjectmUgR_Dictionary, isa_proxy, 0,
sizeof(vector<CamObject*>) );
instance.SetNew(&new_vectorlECamObjectmUgR);
instance.SetNewArray(&newArray_vectorlECamObjectmUgR);
instance.SetDelete(&delete_vectorlECamObjectmUgR);
instance.SetDeleteArray(&deleteArray_vectorlECamObjectmUgR);
instance.SetDestructor(&destruct_vectorlECamObjectmUgR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::Pushback< vector<CamObject*> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const vector<CamObject*>*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));
// Dictionary for non-ClassDef classes
static TClass *vectorlECamObjectmUgR_Dictionary() {
TClass* theClass =::ROOT::GenerateInitInstanceLocal((const vector<CamObject*>*)0x0)->GetClass();
vectorlECamObjectmUgR_TClassManip(theClass);
return theClass;
}
static void vectorlECamObjectmUgR_TClassManip(TClass* ){
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_vectorlECamObjectmUgR(void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) vector<CamObject*> : new vector<CamObject*>;
}
static void *newArray_vectorlECamObjectmUgR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) vector<CamObject*>[nElements] : new vector<CamObject*>[nElements];
}
// Wrapper around operator delete
static void delete_vectorlECamObjectmUgR(void *p) {
delete ((vector<CamObject*>*)p);
}
static void deleteArray_vectorlECamObjectmUgR(void *p) {
delete [] ((vector<CamObject*>*)p);
}
static void destruct_vectorlECamObjectmUgR(void *p) {
typedef vector<CamObject*> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class vector<CamObject*>
namespace ROOT {
static TClass *unordered_maplEstringcOstringgR_Dictionary();
static void unordered_maplEstringcOstringgR_TClassManip(TClass*);
static void *new_unordered_maplEstringcOstringgR(void *p = 0);
static void *newArray_unordered_maplEstringcOstringgR(Long_t size, void *p);
static void delete_unordered_maplEstringcOstringgR(void *p);
static void deleteArray_unordered_maplEstringcOstringgR(void *p);
static void destruct_unordered_maplEstringcOstringgR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const unordered_map<string,string>*)
{
unordered_map<string,string> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(unordered_map<string,string>));
static ::ROOT::TGenericClassInfo
instance("unordered_map<string,string>", -2, "unordered_map", 98,
typeid(unordered_map<string,string>), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&unordered_maplEstringcOstringgR_Dictionary, isa_proxy, 0,
sizeof(unordered_map<string,string>) );
instance.SetNew(&new_unordered_maplEstringcOstringgR);
instance.SetNewArray(&newArray_unordered_maplEstringcOstringgR);
instance.SetDelete(&delete_unordered_maplEstringcOstringgR);
instance.SetDeleteArray(&deleteArray_unordered_maplEstringcOstringgR);
instance.SetDestructor(&destruct_unordered_maplEstringcOstringgR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::MapInsert< unordered_map<string,string> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const unordered_map<string,string>*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));
// Dictionary for non-ClassDef classes
static TClass *unordered_maplEstringcOstringgR_Dictionary() {
TClass* theClass =::ROOT::GenerateInitInstanceLocal((const unordered_map<string,string>*)0x0)->GetClass();
unordered_maplEstringcOstringgR_TClassManip(theClass);
return theClass;
}
static void unordered_maplEstringcOstringgR_TClassManip(TClass* ){
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_unordered_maplEstringcOstringgR(void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) unordered_map<string,string> : new unordered_map<string,string>;
}
static void *newArray_unordered_maplEstringcOstringgR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) unordered_map<string,string>[nElements] : new unordered_map<string,string>[nElements];
}
// Wrapper around operator delete
static void delete_unordered_maplEstringcOstringgR(void *p) {
delete ((unordered_map<string,string>*)p);
}
static void deleteArray_unordered_maplEstringcOstringgR(void *p) {
delete [] ((unordered_map<string,string>*)p);
}
static void destruct_unordered_maplEstringcOstringgR(void *p) {
typedef unordered_map<string,string> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class unordered_map<string,string>
namespace ROOT {
static TClass *unordered_maplEstringcOboostcLcLanygR_Dictionary();
static void unordered_maplEstringcOboostcLcLanygR_TClassManip(TClass*);
static void *new_unordered_maplEstringcOboostcLcLanygR(void *p = 0);
static void *newArray_unordered_maplEstringcOboostcLcLanygR(Long_t size, void *p);
static void delete_unordered_maplEstringcOboostcLcLanygR(void *p);
static void deleteArray_unordered_maplEstringcOboostcLcLanygR(void *p);
static void destruct_unordered_maplEstringcOboostcLcLanygR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const unordered_map<string,boost::any>*)
{
unordered_map<string,boost::any> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(unordered_map<string,boost::any>));
static ::ROOT::TGenericClassInfo
instance("unordered_map<string,boost::any>", -2, "unordered_map", 98,
typeid(unordered_map<string,boost::any>), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&unordered_maplEstringcOboostcLcLanygR_Dictionary, isa_proxy, 0,
sizeof(unordered_map<string,boost::any>) );
instance.SetNew(&new_unordered_maplEstringcOboostcLcLanygR);
instance.SetNewArray(&newArray_unordered_maplEstringcOboostcLcLanygR);
instance.SetDelete(&delete_unordered_maplEstringcOboostcLcLanygR);
instance.SetDeleteArray(&deleteArray_unordered_maplEstringcOboostcLcLanygR);
instance.SetDestructor(&destruct_unordered_maplEstringcOboostcLcLanygR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::MapInsert< unordered_map<string,boost::any> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const unordered_map<string,boost::any>*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));
// Dictionary for non-ClassDef classes
static TClass *unordered_maplEstringcOboostcLcLanygR_Dictionary() {
TClass* theClass =::ROOT::GenerateInitInstanceLocal((const unordered_map<string,boost::any>*)0x0)->GetClass();
unordered_maplEstringcOboostcLcLanygR_TClassManip(theClass);
return theClass;
}
static void unordered_maplEstringcOboostcLcLanygR_TClassManip(TClass* ){
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_unordered_maplEstringcOboostcLcLanygR(void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) unordered_map<string,boost::any> : new unordered_map<string,boost::any>;
}
static void *newArray_unordered_maplEstringcOboostcLcLanygR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) unordered_map<string,boost::any>[nElements] : new unordered_map<string,boost::any>[nElements];
}
// Wrapper around operator delete
static void delete_unordered_maplEstringcOboostcLcLanygR(void *p) {
delete ((unordered_map<string,boost::any>*)p);
}
static void deleteArray_unordered_maplEstringcOboostcLcLanygR(void *p) {
delete [] ((unordered_map<string,boost::any>*)p);
}
static void destruct_unordered_maplEstringcOboostcLcLanygR(void *p) {
typedef unordered_map<string,boost::any> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class unordered_map<string,boost::any>
namespace ROOT {
static TClass *maplEstringcOCamObjectmUgR_Dictionary();
static void maplEstringcOCamObjectmUgR_TClassManip(TClass*);
static void *new_maplEstringcOCamObjectmUgR(void *p = 0);
static void *newArray_maplEstringcOCamObjectmUgR(Long_t size, void *p);
static void delete_maplEstringcOCamObjectmUgR(void *p);
static void deleteArray_maplEstringcOCamObjectmUgR(void *p);
static void destruct_maplEstringcOCamObjectmUgR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const map<string,CamObject*>*)
{
map<string,CamObject*> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(map<string,CamObject*>));
static ::ROOT::TGenericClassInfo
instance("map<string,CamObject*>", -2, "map", 96,
typeid(map<string,CamObject*>), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&maplEstringcOCamObjectmUgR_Dictionary, isa_proxy, 0,
sizeof(map<string,CamObject*>) );
instance.SetNew(&new_maplEstringcOCamObjectmUgR);
instance.SetNewArray(&newArray_maplEstringcOCamObjectmUgR);
instance.SetDelete(&delete_maplEstringcOCamObjectmUgR);
instance.SetDeleteArray(&deleteArray_maplEstringcOCamObjectmUgR);
instance.SetDestructor(&destruct_maplEstringcOCamObjectmUgR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::MapInsert< map<string,CamObject*> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const map<string,CamObject*>*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));
// Dictionary for non-ClassDef classes
static TClass *maplEstringcOCamObjectmUgR_Dictionary() {
TClass* theClass =::ROOT::GenerateInitInstanceLocal((const map<string,CamObject*>*)0x0)->GetClass();
maplEstringcOCamObjectmUgR_TClassManip(theClass);
return theClass;
}
static void maplEstringcOCamObjectmUgR_TClassManip(TClass* ){
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_maplEstringcOCamObjectmUgR(void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) map<string,CamObject*> : new map<string,CamObject*>;
}
static void *newArray_maplEstringcOCamObjectmUgR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) map<string,CamObject*>[nElements] : new map<string,CamObject*>[nElements];
}
// Wrapper around operator delete
static void delete_maplEstringcOCamObjectmUgR(void *p) {
delete ((map<string,CamObject*>*)p);
}
static void deleteArray_maplEstringcOCamObjectmUgR(void *p) {
delete [] ((map<string,CamObject*>*)p);
}
static void destruct_maplEstringcOCamObjectmUgR(void *p) {
typedef map<string,CamObject*> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class map<string,CamObject*>
namespace ROOT {
static TClass *dequelECamObjectmUgR_Dictionary();
static void dequelECamObjectmUgR_TClassManip(TClass*);
static void *new_dequelECamObjectmUgR(void *p = 0);
static void *newArray_dequelECamObjectmUgR(Long_t size, void *p);
static void delete_dequelECamObjectmUgR(void *p);
static void deleteArray_dequelECamObjectmUgR(void *p);
static void destruct_dequelECamObjectmUgR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const deque<CamObject*>*)
{
deque<CamObject*> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(deque<CamObject*>));
static ::ROOT::TGenericClassInfo
instance("deque<CamObject*>", -2, "deque", 829,
typeid(deque<CamObject*>), ::ROOT::Internal::DefineBehavior(ptr, ptr),
&dequelECamObjectmUgR_Dictionary, isa_proxy, 0,
sizeof(deque<CamObject*>) );
instance.SetNew(&new_dequelECamObjectmUgR);
instance.SetNewArray(&newArray_dequelECamObjectmUgR);
instance.SetDelete(&delete_dequelECamObjectmUgR);
instance.SetDeleteArray(&deleteArray_dequelECamObjectmUgR);
instance.SetDestructor(&destruct_dequelECamObjectmUgR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::Pushback< deque<CamObject*> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const deque<CamObject*>*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));
// Dictionary for non-ClassDef classes
static TClass *dequelECamObjectmUgR_Dictionary() {
TClass* theClass =::ROOT::GenerateInitInstanceLocal((const deque<CamObject*>*)0x0)->GetClass();
dequelECamObjectmUgR_TClassManip(theClass);
return theClass;
}
static void dequelECamObjectmUgR_TClassManip(TClass* ){
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_dequelECamObjectmUgR(void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) deque<CamObject*> : new deque<CamObject*>;
}
static void *newArray_dequelECamObjectmUgR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::Internal::TOperatorNewHelper*)p) deque<CamObject*>[nElements] : new deque<CamObject*>[nElements];
}
// Wrapper around operator delete
static void delete_dequelECamObjectmUgR(void *p) {
delete ((deque<CamObject*>*)p);
}
static void deleteArray_dequelECamObjectmUgR(void *p) {
delete [] ((deque<CamObject*>*)p);
}
static void destruct_dequelECamObjectmUgR(void *p) {
typedef deque<CamObject*> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class deque<CamObject*>
namespace {
void TriggerDictionaryInitialization_libAnalysisCamEvent_Impl() {
static const char* headers[] = {
"AnalysisCamEvent/CamObject.h",
"AnalysisCamEvent/CamVector.h",
"AnalysisCamEvent/CamDeque.h",
"AnalysisCamEvent/CamEvent.h",
0
};
static const char* includePaths[] = {
"/home/mleigh/workdir/First_Stage/source/AnalysisCam/AnalysisCamEvent",
"/home/mleigh/workdir/First_Stage/source/AnalysisCam/AnalysisCamEvent",
"/home/mleigh/workdir/First_Stage/source/AnalysisCam/AnalysisCamEvent",
"/home/mleigh/workdir/First_Stage/source/AnalysisCam/AnalysisCamEvent",
"/home/mleigh/workdir/First_Stage/source/AnalysisCam/AnalysisCamEvent",
"/home/mleigh/workdir/First_Stage/source/athena/Control/AthAnalysisBaseComps",
"/home/mleigh/workdir/First_Stage/source/athena/Control/AthAnalysisBaseComps",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/AthenaBaseComps",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/ROOT/6.12.06/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/AthenaKernel",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/GAUDI/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/usr/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/CxxUtils",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/DataModelRoot",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/ROOT/6.12.06/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/GAUDI/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/tbb/2018_U1/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/ROOT/6.12.06/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/GAUDI/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/SGTools",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/StoreGate",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/AthContainersInterfaces",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/tbb/2018_U1/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/AthAllocators",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Database/IOVDbDataModel",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Database/AthenaPOOL/AthenaPoolUtilities",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/CORAL/3_2_0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/DataModel",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/AthContainers",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/AthLinks",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Database/AthenaPOOL/DBDataModel",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/CLIDSvc",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Database/PersistentDataModel",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/CORAL/3_2_0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Python/2.7.13/x86_64-slc6-gcc62-opt/include/python2.7",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/RootUtils",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Python/2.7.13/x86_64-slc6-gcc62-opt/include/python2.7",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/AtlasTest/TestTools",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/AthenaCommon",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODMissingET",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODBase",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/ROOT/6.12.06/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODCore",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/ROOT/6.12.06/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODJet",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/ROOT/6.12.06/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODBTagging",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODTracking",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/eigen/3.2.9/x86_64-slc6-gcc62-opt/include/eigen3",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/DetectorDescription/GeoPrimitives",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/../../../../AthAnalysisExternals/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/eigen/3.2.9/x86_64-slc6-gcc62-opt/include/eigen3",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/EventPrimitives",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/../../../../AthAnalysisExternals/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/eigen/3.2.9/x86_64-slc6-gcc62-opt/include/eigen3",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODPFlow",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/ROOT/6.12.06/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODCaloEvent",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/eigen/3.2.9/x86_64-slc6-gcc62-opt/include/eigen3",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Calorimeter/CaloGeoHelpers",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODTrigger",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODEventInfo",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/PhysicsAnalysis/AnalysisCommon/PATInterfaces",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/ROOT/6.12.06/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/LCG_93/Boost/1.66.0/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/AthToolSupport/AsgTools",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/xAODRootAccess",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Event/xAOD/xAODEventFormat",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/src/Control/xAODRootAccessInterfaces",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/AthAnalysis/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/../../../../AthAnalysisExternals/21.2.31/InstallArea/x86_64-slc6-gcc62-opt/include",
"/cvmfs/atlas.cern.ch/repo/sw/software/21.2/sw/lcg/releases/ROOT/6.12.06-0f687/x86_64-slc6-gcc62-opt/include",
"/atlas/mleigh/First_Stage/build/AnalysisCam/AnalysisCamEvent/CMakeFiles/makeAnalysisCamEventCintDict.3pl3om/",
0
};
static const char* fwdDeclCode = R"DICTFWDDCLS(
#line 1 "libAnalysisCamEvent dictionary forward declarations' payload"
#pragma clang diagnostic ignored "-Wkeyword-compat"
#pragma clang diagnostic ignored "-Wignored-attributes"
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
extern int __Cling_Autoloading_Map;
class __attribute__((annotate("$clingAutoload$AnalysisCamEvent/CamEvent.h"))) CamObject;
class __attribute__((annotate("$clingAutoload$AnalysisCamEvent/CamEvent.h"))) CamDeque;
class __attribute__((annotate("$clingAutoload$AnalysisCamEvent/CamEvent.h"))) CamVector;
class __attribute__((annotate("$clingAutoload$AnalysisCamEvent/CamEvent.h"))) CamEvent;
)DICTFWDDCLS";
static const char* payloadCode = R"DICTPAYLOAD(
#line 1 "libAnalysisCamEvent dictionary payload"
#ifndef G__VECTOR_HAS_CLASS_ITERATOR
#define G__VECTOR_HAS_CLASS_ITERATOR 1
#endif
#ifndef HAVE_PRETTY_FUNCTION
#define HAVE_PRETTY_FUNCTION 1
#endif
#ifndef HAVE_64_BITS
#define HAVE_64_BITS 1
#endif
#ifndef __IDENTIFIER_64BIT__
#define __IDENTIFIER_64BIT__ 1
#endif
#ifndef ATLAS
#define ATLAS 1
#endif
#ifndef GAUDI_V20_COMPAT
#define GAUDI_V20_COMPAT 1
#endif
#ifndef ATLAS_GAUDI_V21
#define ATLAS_GAUDI_V21 1
#endif
#ifndef HAVE_GAUDI_PLUGINSVC
#define HAVE_GAUDI_PLUGINSVC 1
#endif
#ifndef XAOD_ANALYSIS
#define XAOD_ANALYSIS 1
#endif
#ifndef ROOTCORE_RELEASE_SERIES
#define ROOTCORE_RELEASE_SERIES 25
#endif
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "AnalysisCamEvent-02-00-00-branch"
#endif
#ifndef PACKAGE_VERSION_UQ
#define PACKAGE_VERSION_UQ AnalysisCamEvent-02-00-00-branch
#endif
#ifndef CLHEP_MAX_MIN_DEFINED
#define CLHEP_MAX_MIN_DEFINED 1
#endif
#ifndef CLHEP_ABS_DEFINED
#define CLHEP_ABS_DEFINED 1
#endif
#ifndef CLHEP_SQR_DEFINED
#define CLHEP_SQR_DEFINED 1
#endif
#ifndef CLHEP_MAX_MIN_DEFINED
#define CLHEP_MAX_MIN_DEFINED 1
#endif
#ifndef CLHEP_ABS_DEFINED
#define CLHEP_ABS_DEFINED 1
#endif
#ifndef CLHEP_SQR_DEFINED
#define CLHEP_SQR_DEFINED 1
#endif
#define _BACKWARD_BACKWARD_WARNING_H
#include "AnalysisCamEvent/CamObject.h"
#include "AnalysisCamEvent/CamVector.h"
#include "AnalysisCamEvent/CamDeque.h"
#include "AnalysisCamEvent/CamEvent.h"
#ifndef ANALYSISCAMEVENT_ANALYSISCAMEVENTDICT_H
#define ANALYSISCAMEVENT_ANALYSISCAMEVENTDICT_H
//this define is needed in 2.4 series, for dictionary compilation
#ifndef GAUDI_V20_COMPAT
#define GAUDI_V20_COMPAT
#endif
#include "AnalysisCamEvent/CamEvent.h"
#include "AnalysisCamEvent/CamDeque.h"
#include "AnalysisCamEvent/CamVector.h"
#include "AnalysisCamEvent/CamObject.h"
#pragma link C++ class CamObject+;
#pragma link C++ class CamVector+;
#pragma link C++ class CamDeque+;
#pragma link C++ class CamEvent+;
#endif
#undef _BACKWARD_BACKWARD_WARNING_H
)DICTPAYLOAD";
static const char* classesHeaders[]={
"CamDeque", payloadCode, "@",
"CamEvent", payloadCode, "@",
"CamObject", payloadCode, "@",
"CamVector", payloadCode, "@",
nullptr};
static bool isInitialized = false;
if (!isInitialized) {
TROOT::RegisterModule("libAnalysisCamEvent",
headers, includePaths, payloadCode, fwdDeclCode,
TriggerDictionaryInitialization_libAnalysisCamEvent_Impl, {{"namespace DataVector_detail { template <typename B> class DVLEltBase_init; }", 1},{"namespace DataVector_detail { template <typename B1, typename B2, typename B3> class VirtBases; }", 1},{"template <typename T> class DataVectorBase;", 1},{"template <typename T, typename BASE> class DataVector;", 1}}, classesHeaders);
isInitialized = true;
}
}
static struct DictInit {
DictInit() {
TriggerDictionaryInitialization_libAnalysisCamEvent_Impl();
}
} __TheDictionaryInitializer;
}
void TriggerDictionaryInitialization_libAnalysisCamEvent() {
TriggerDictionaryInitialization_libAnalysisCamEvent_Impl();
}
| [
"mattcleigh@gmail.com"
] | mattcleigh@gmail.com |
bf0162250629e05c532e0ddeb2eff034a4981384 | c0fcbf4f99099d336c2f9a1cf5b10d08be9f59d3 | /wallet/api/v6_3/v6_3_api.h | a576f795379d4affb31e4cf25454d6c9d1cb4c03 | [
"Apache-2.0"
] | permissive | unwaz/beam | 00bf13b50ffff2e2a4007b033f5696d05a8cc775 | a9aa45dce5dd759f3eb67d7d07ecdc9154aa8db0 | refs/heads/master | 2022-04-28T16:37:11.030079 | 2022-04-25T11:51:33 | 2022-04-25T11:51:33 | 204,409,378 | 0 | 0 | Apache-2.0 | 2019-08-26T06:22:27 | 2019-08-26T06:22:27 | null | UTF-8 | C++ | false | false | 1,101 | h | // Copyright 2018 The Beam Team
//
// 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.
#pragma once
#include "v6_3_api_defs.h"
#include "wallet/api/v6_1/v6_1_api.h"
namespace beam::wallet
{
class V63Api: public V61Api
{
public:
// CTOR MUST BE SAFE TO CALL FROM ANY THREAD
V63Api(IWalletApiHandler& handler, unsigned long avMajor, unsigned long avMinor, const ApiInitData& init);
~V63Api() override = default;
V6_3_API_METHODS(BEAM_API_PARSE_FUNC)
V6_3_API_METHODS(BEAM_API_RESPONSE_FUNC)
V6_3_API_METHODS(BEAM_API_HANDLE_FUNC)
};
}
| [
"chapati.th@gmail.com"
] | chapati.th@gmail.com |
a85b7942c019a0fc71b5e4f8e0c2fc782a8b446c | e6de9e6b8c3d46054eb2f89d36f67cd5c29540e6 | /include/rogue/hardware/exo/TemCmd.h | e2d3af862b97febf101740699ff0d9be2b4ae3ab | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | abunimeh/rogue | d993ea6e0390a76f23ebab2620faa0152a6d6fb1 | 5a84fa1c4bdf98f9c832f69423c992aec4b89152 | refs/heads/master | 2021-01-01T18:31:39.728362 | 2017-08-17T16:39:49 | 2017-08-17T16:39:49 | 98,356,822 | 0 | 0 | null | 2017-07-25T22:58:08 | 2017-07-25T22:58:08 | null | UTF-8 | C++ | false | false | 1,897 | h | /**
*-----------------------------------------------------------------------------
* Title : EXO TEM Base Class
* ----------------------------------------------------------------------------
* File : TemCmd.h
* Author : Ryan Herbst, rherbst@slac.stanford.edu
* Created : 2017-09-17
* Last update: 2017-09-17
* ----------------------------------------------------------------------------
* Description:
* Class for interfacing to Tem Driver.
* ----------------------------------------------------------------------------
* This file is part of the rogue software platform. It is subject to
* the license terms in the LICENSE.txt file found in the top-level directory
* of this distribution and at:
* https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
* No part of the rogue software platform, including this file, may be
* copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE.txt file.
* ----------------------------------------------------------------------------
**/
#ifndef __ROGUE_HARDWARE_EXO_TEM_CMD_H__
#define __ROGUE_HARDWARE_EXO_TEM_CMD_H__
#include <rogue/hardware/exo/Tem.h>
#include <boost/python.hpp>
#include <boost/thread.hpp>
#include <stdint.h>
namespace rogue {
namespace hardware {
namespace exo {
//! PGP Card class
class TemCmd : public rogue::hardware::exo::Tem {
public:
//! Class creation
static boost::shared_ptr<rogue::hardware::exo::TemCmd> create ();
//! Setup class in python
static void setup_python();
//! Creator
TemCmd();
//! Destructor
~TemCmd();
};
// Convienence
typedef boost::shared_ptr<rogue::hardware::exo::TemCmd> TemCmdPtr;
}
}
};
#endif
| [
"rherbst@slac.stanford.edu"
] | rherbst@slac.stanford.edu |
279433445f092d85db61dd2c08fd761e8e450c53 | b03b5980ab38905732b6e8379e661a32705c3d64 | /src/euler/permutation.hpp | 91a81621d8a71c42f335a3db705c13e8b4a0796c | [
"MIT"
] | permissive | fancidev/euler | 30e4a70c9ce32e17400cf837b3e1a78571a31cab | a74e3ddf46034718253259eac4880472c58a7b22 | refs/heads/master | 2020-03-08T10:05:47.046028 | 2018-06-26T22:43:20 | 2018-06-26T22:43:20 | 128,063,556 | 0 | 1 | MIT | 2018-04-15T06:02:51 | 2018-04-04T13:07:48 | C++ | UTF-8 | C++ | false | false | 10,698 | hpp | /**
* @defgroup Permutation Permutation Function
* @ingroup Library
*
* A permutation function is a bijection (one-to-one mapping) of a set onto
* itself. For example, consider a set containing five elements. For
* convenience, label each element with an index starting from one. A possible
* permutation is the following:
* \f[
* \begin{pmatrix}
* 1 & 2 & 3 & 4 & 5 \\
* 2 & 5 & 4 & 3 & 1
* \end{pmatrix}
* \f]
* where the first row displays the sequence of elements before permutation,
* and the second row displays the sequence of elements after premutation.
*
* A permutation can be inversed. Finding the inverse of a permutation is
* equivalent to finding the new location of each element after permutation.
* In the above example, the inverse permutation is
* \f[
* \begin{pmatrix}
* 1 & 2 & 3 & 4 & 5 \\
* 5 & 1 & 4 & 3 & 2
* \end{pmatrix}
* \f]
* which can be interpreted as element 1 moved to position 5, element 2
* moved to position 1, etc.
*
* Two permutations of the same size can be compounded to form a composite
* permutation. Let @c P be the composite of permutation
* <code>P<sub>1</sub></code> and <code>P<sub>2</sub></code>.
* The effect of applying @c P is equivalent to first applying
* <code>P<sub>1</sub></code> followed by applying <code>P<sub>2</sub></code>.
* The notation to write a composite permutation can be confusing,
* so we omit it here.
*
* More details related to permutations can be found at
* - http://en.wikipedia.org/wiki/Permutation
*
*/
#ifndef EULER_PERMUTATION_H
#define EULER_PERMUTATION_H
#include <vector>
#include <cassert>
#include "sequence.hpp"
namespace euler {
template <class IndexIt, class ValueIt>
class indexed_iterator
{
IndexIt index_it;
IndexIt index_end;
ValueIt value_it;
public:
typedef std::forward_iterator_tag iterator_category;
typedef typename ValueIt::value_type value_type;
typedef typename IndexIt::difference_type difference_type;
typedef typename ValueIt::pointer pointer;
typedef typename ValueIt::reference reference;
indexed_iterator(IndexIt current, IndexIt end, ValueIt values)
: index_it(current), index_end(end), value_it(values) { }
reference operator * () { return value_it[*index_it]; }
indexed_iterator& operator ++ () { ++index_it; return *this; }
bool operator == (const indexed_iterator &it) const
{
return index_it == it.index_it && index_end == it.index_end
&& value_it == it.value_it;
}
bool operator != (const indexed_iterator &it) const
{
return !operator == (it);
}
};
/**
* Represents a permutation function.
*
* In the implementation, each element in the original sequence is labeled
* with an index starting from zero. Then the permuted index sequence is
* stored in an array to represent the permutation.
*
* @ingroup Permutation
*/
template <typename T>
class permutation
{
// Stores the reordered sequence.
std::vector<T> perm;
public:
/// Constructs an empty permutation.
/// @complexity Constant.
permutation() { }
/// Constructs an identity permutation of a given size.
/// @param size Number of elements in the permuted sequence.
/// @complexity <code>O(size)</code>.
explicit permutation(size_t size) : perm(size)
{
for (size_t i = 0; i < size; i++)
{
perm[i] = (T)i;
}
}
/// Copy-constructs a permutation.
/// @complexity <code>O(n)</code>.
permutation(const permutation &p) : perm(p.perm) { }
/// Move-constructs a permutation.
/// @complexity Constant.
permutation(permutation &&p) : perm(std::move(p.perm)) { }
/**
* Constructs the composite of two permutations of the same size.
*
* The effect of applying the composite permutation is equivalent to
* applying the first permutation followed by applying the second
* permutation.
*
* @param p1 The first permutation to apply.
* @param p2 The second permutation to apply.
* @complexity <code>O(n)</code>.
*/
permutation(const permutation &p1, const permutation &p2)
: perm(p2.perm.size())
{
for (size_t i = 0; i < perm.size(); i++)
{
perm[i] = p1.perm[p2.perm[i]];
}
}
/// Returns the size of the permutation.
/// @complexity Constant.
size_t size() const { return perm.size(); }
/// Tests whether the permutation is empty.
/// @complexity Constant.
bool empty() const { return perm.empty(); }
/// Returns the element at a given position after permutation.
size_t operator [] (size_t pos) const { return (size_t)perm[pos]; }
/// Returns the inverse of the permutation.
/// @complexity <code>O(size)</code>.
permutation<T> inverse() const
{
permutation<T> p;
p.perm.resize(perm.size());
for (size_t i = 0; i < perm.size(); i++)
{
p.perm[perm[i]] = (T)i;
}
return p;
}
#if 0
/// Applies the permutation to a sequence of elements.
template <class RanIt>
void apply(RanIt first, RanIt last)
{
assert((size_t)(last - first) >= size());
}
#endif
typedef typename std::vector<T>::iterator iterator;
typedef typename std::vector<T>::const_iterator const_iterator;
iterator begin() { return perm.begin(); }
iterator end() { return perm.end(); }
const_iterator begin() const { return perm.begin(); }
const_iterator end() const { return perm.end(); }
/// Permutes a given sequence according to this permutation.
template <class RanIt>
sequence<indexed_iterator<const_iterator,RanIt>>
operator() (RanIt value_begin, RanIt /* value_end */) const
{
return make_sequence(
indexed_iterator<const_iterator,RanIt>(begin(), end(), value_begin),
indexed_iterator<const_iterator,RanIt>(end(), end(), value_begin));
}
public:
/**
* Computes the permutation that stable-sorts a sequence of elements.
*
* @param first Begin of the sequence.
* @param last End of the sequence.
* @param pred Predicate for comparison.
* @returns Permutation @c P such that applying @c P to the original
* sequence yields the sorted sequence.
*
* @timecomplexity <code>O(N*log(N))</code>.
* @spacecomplexity <code>O(N)</code>.
*/
template <class RanIt, class Func>
static permutation reorder(RanIt first, RanIt last, Func pred)
{
permutation<T> p(last - first);
std::sort(p.perm.begin(), p.perm.end(), [&](T a, T b) -> bool
{
if (pred(first[a], first[b]))
{
return true;
}
if (pred(first[b], first[a]))
{
return false;
}
return a < b;
});
return p;
}
/**
* Computes the permutation that stable-sorts a sequence of elements.
*
* @param first Begin of the sequence.
* @param last End of the sequence.
* @returns Permutation @c P such that applying @c P to the original
* sequence yields the sorted sequence.
*
* @timecomplexity <code>O(N*log(N))</code>.
* @spacecomplexity <code>O(N)</code>.
*/
template <class RanIt>
static permutation reorder(RanIt first, RanIt last)
{
return reorder(first, last, std::less<typename RanIt::value_type>());
}
};
/**
* Returns the lexicographical ordering of two permutations.
* @param a The first permutation to compare.
* @param b The second permutation to compare.
* @returns @c true if @c a is lexicographically less than <code>b</code>;
* @c false otherwise.
* @timecomplexity <code>O(min(size<sub>1</sub>,size<sub>2</sub>))</code>.
* @spacecomplexity Constant.
* @ingroup Permutation
*/
template <typename T>
bool operator < (const permutation<T> &a, const permutation<T> &b)
{
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
}
/**
* Outputs a permutation to a stream.
*
* This function prints the permuted sequence of elements, which are labeled
* starting from one before permuted. If there are no more than nine elements,
* the labels are printed without any separator. If there are more than nine
* elements, the labels are separated by a comma.
*
* @param os The output stream.
* @param p The permutation to output.
* @returns The output stream.
* @timecomplexity <code>O(size)</code>.
* @spacecomplexity Constant.
*
* @ingroup Permutation
*/
template <typename T>
std::ostream& operator << (std::ostream &os, const permutation<T> &p)
{
size_t n = p.size();
for (size_t i = 0; i < n; i++)
{
if (n > 9 && i > 0)
{
os << ',';
}
os << (p[i]+1);
}
return os;
}
/**
* Reorders a sequence in-place according to a permutation.
*
* @param values The sequence to be reordered.
* @param perm Permutation that stores the zero-based index of the elements
* after reordering. This permutation is not altered.
* @param n Number of elements in the sequence.
* @remarks Both the value iterator and the index iterator must support
* random-access.
* @timecomplexity <code>O(n^2)</code> operations. At most <code>(n-1)</code>
* swaps.
* @spacecomplexity Constant.
* @ingroup Permutation
*/
template <class RanItValue, class RanItIndex>
void reorder(RanItValue &values, const RanItIndex &perm, size_t n)
{
for (size_t i = 0; i < n - 1; ++i) // no need to place the last element
{
// Find the new index of the desired element.
size_t j = perm[i];
while (j < i)
{
j = (size_t)perm[j];
}
// Swap the element if not in place.
if (j > i)
{
std::swap(values[i], values[j]);
}
}
}
/**
* Reorders a sequence in-place according to a permutation.
*
* @param first Begin of the sequence to be reordered.
* @param last End of the sequence to be reordered.
* @param perm Permutation that stores the zero-based index of the elements
* after reordering. This permutation is not altered.
* @remarks Both the value iterator and the index iterator must support
* random-access.
* @timecomplexity <code>O(n^2)</code> operations. At most <code>(n-1)</code>
* swaps.
* @spacecomplexity Constant.
* @ingroup Permutation
*/
template <class RanItValue, class RanItIndex>
void reorder(RanItValue first, RanItValue last, RanItIndex perm)
{
size_t n = last - first;
for (size_t i = 0; i < n - 1; ++i) // no need to place the last element
{
// Find the new index of the desired element.
size_t j = perm[i];
while (j < i)
{
j = (size_t)perm[j];
}
// Swap the element if not in place.
if (j > i)
{
std::swap(first[i], first[j]);
}
}
}
#if 0
// permutation test
static void test_permute()
{
char s[] = "abcdefg";
int index[7]={ 0, 5, 3, 6, 4, 2, 1 };
std::cout << s << std::endl;
permute(&s[0], &s[7], index);
std::cout << s << std::endl;
}
#endif
} // namespace euler
#endif
| [
"fancidev@gmail.com"
] | fancidev@gmail.com |
f7c26711c4c2e12ad399f1d956738fddd35c88f2 | c1f7336788dc573bfc92d86261ad59f90dd2068b | /isomorphicStrings.cpp | e718133a53a5b131e9ef0d3afcc908aefd286dae | [
"MIT"
] | permissive | laxmena/CodeKata | 79722ee1c06703ad3c915b98008e05a0f7774fa4 | 6ae0b911f1a436f691dfac13a760a53beedf7405 | refs/heads/master | 2021-12-15T15:52:52.851835 | 2017-08-28T06:21:33 | 2017-08-28T06:21:33 | 97,553,209 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 447 | cpp | #include <iostream>
#include <cstdio>
#include <string>
#include <map>
using namespace std;
int main(){
string s1, s2;
cin>>s1>>s2;
int l1,l2,i;
l1 = s1.size();
l2 = s2.size();
map<char, char> subs;
if(l1 != l2){
cout<<"false";
return -1;
}
while(i < l1){
if(subs.find(s1[i]) == subs.end()){
subs[s1[i]] = s2[i];
}
else if(subs[s1[i]] != s2[i]){
cout<<"false";
return -1;
}
i++;
}
cout<<"true";
return 0;
} | [
"lakshmanan.meiyappan@gmail.com"
] | lakshmanan.meiyappan@gmail.com |
db51cf2de82291eb8ba97ed21319f5b29af0e027 | ab67cb38c565055c20f64df4e2e3df9dc925d1b6 | /include/uniform_map.hpp | fc73091d77c846a156e542518f8a5d717c550fbd | [] | no_license | kanelbullar/kraken | 17329c489f76db38a5089b467e27cf43bb6e8ed6 | 91c7cf8c27f9a628de2c67a94139711b8e46fd1d | refs/heads/master | 2022-07-13T14:01:28.509765 | 2014-09-09T13:46:46 | 2014-09-09T13:46:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,197 | hpp | #ifndef UNIFORM_MAP_HPP
#define UNIFORM_MAP_HPP
#include <map>
#include <memory>
#include <string>
#define GLM_FORCE_RADIANS
#include <GL/glew.h>
#include <glm/glm.hpp>
struct uniform_link {
inline uniform_link(GLuint id,std::string const& name) :
program_id_(id),
uniform_name_(name)
{}
GLuint program_id_;
std::string uniform_name_;
};
enum uniform_type {VEC2,VEC3,IVEC3,MAT4};
class uniform_map {
public :
void load(uniform_link const&) const;
void set(std::string const&,glm::vec2 const&);
void set(std::string const&,glm::vec3 const&);
void set(std::string const&,glm::ivec3 const&);
void set(std::string const&,glm::mat4 const&);
bool aviable(std::string const&) const;
private :
std::shared_ptr<unsigned short> const id(std::string const&);
std::map<std::string,std::shared_ptr<unsigned short> > names_;
std::map<std::shared_ptr<unsigned short>,uniform_type> types_;
std::map<std::shared_ptr<unsigned short>,glm::vec2> vec2_;
std::map<std::shared_ptr<unsigned short>,glm::vec3> vec3_;
std::map<std::shared_ptr<unsigned short>,glm::ivec3> ivec3_;
std::map<std::shared_ptr<unsigned short>,glm::mat4> mat4_;
};
#endif
| [
"tony.grochow@gmail.com"
] | tony.grochow@gmail.com |
dc3b7ed40f118a1ac6b868cde91023e13d146dfa | b38dcbfe60c4c44101a8fc8cbed985139797e547 | /machine/machine.cc | 11aaa54778bd62bd6e6bdc7c478790aa37bfa3af | [] | no_license | dantenoguera/nachOS | 63d4091026b02ba31edbf99379a0e26b87eeb3b8 | 07eff76e10553f12959f09c3a9e4c81a30c70f6e | refs/heads/main | 2022-12-30T06:25:48.764685 | 2020-10-15T23:02:39 | 2020-10-15T23:02:39 | 303,867,674 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,605 | cc | /// Routines for simulating the execution of user programs.
///
/// DO NOT CHANGE -- part of the machine emulation
///
/// Copyright (c) 1992-1993 The Regents of the University of California.
/// 2016-2020 Docentes de la Universidad Nacional de Rosario.
/// All rights reserved. See `copyright.h` for copyright notice and
/// limitation of liability and disclaimer of warranty provisions.
#include "machine.hh"
#include "threads/system.hh"
static inline bool
IsExceptionType(ExceptionType t)
{
return 0 <= t && t < NUM_EXCEPTION_TYPES;
}
/// Check to be sure that the host really uses the format it says it does,
/// for storing the bytes of an integer. Stop on error.
static void
CheckEndian()
{
union checkIt {
char charWord[4];
unsigned intWord;
} check;
check.charWord[0] = 1;
check.charWord[1] = 2;
check.charWord[2] = 3;
check.charWord[3] = 4;
#ifdef HOST_IS_BIG_ENDIAN
ASSERT(check.intWord == 0x01020304);
#else
ASSERT(check.intWord == 0x04030201);
#endif
}
/// Initialize the simulation of user program execution.
///
/// * `st` -- pointer to an object that performs single stepping, for
/// dropping into it after each user instruction is executed; if null,
/// execute normally, without single stepping.
Machine::Machine(SingleStepper *st)
{
for (unsigned i = 0; i < NUM_TOTAL_REGS; i++)
registers[i] = 0;
for (unsigned i = 0; i < NUM_EXCEPTION_TYPES; i++)
handlers[i] = nullptr;
singleStepper = st;
CheckEndian();
}
const int *
Machine::GetRegisters() const
{
return registers;
}
MMU *
Machine::GetMMU()
{
return &mmu;
}
/// Fetch or write the contents of a user program register.
int
Machine::ReadRegister(unsigned num) const
{
ASSERT(num < NUM_TOTAL_REGS);
return registers[num];
}
void
Machine::WriteRegister(unsigned num, int value)
{
ASSERT(num < NUM_TOTAL_REGS);
//DEBUG('m', "WriteRegister %u, value %d\n", num, value);
// Register 0 never changes its value: it is always 0.
if (num != 0)
registers[num] = value;
}
bool
Machine::ReadMem(unsigned addr, unsigned size, int *value)
{
ExceptionType e = mmu.ReadMem(addr, size, value);
if (e != NO_EXCEPTION) {
RaiseException(e, addr);
return false;
}
return true;
}
bool
Machine::WriteMem(unsigned addr, unsigned size, int value)
{
ExceptionType e = mmu.WriteMem(addr, size, value);
if (e != NO_EXCEPTION) {
RaiseException(e, addr);
return false;
}
return true;
}
/// Transfer control to the Nachos kernel from user mode, because the user
/// program either invoked a system call, or some exception occured (such as
/// the address translation failed).
///
/// * `et` is the cause of the kernel trap
/// * `badVaddr` is the virtual address causing the trap, if appropriate.
void
Machine::RaiseException(ExceptionType et, unsigned badVAddr)
{
ASSERT(IsExceptionType(et));
ASSERT(handlers[et] != nullptr); // There must be a handler associated.
DEBUG('m', "Exception: %s\n", ExceptionTypeToString(et));
//ASSERT(interrupt->GetStatus() == USER_MODE);
registers[BAD_VADDR_REG] = badVAddr;
DelayedLoad(0, 0); // Finish anything in progress.
// Call the associated handler with interrupts enabled in system mode.
interrupt->SetStatus(SYSTEM_MODE);
(*handlers[et])(et);
interrupt->SetStatus(USER_MODE);
}
void
Machine::SetHandler(ExceptionType et, ExceptionHandler handler)
{
ASSERT(IsExceptionType(et));
ASSERT(handler != nullptr);
handlers[et] = handler;
}
| [
"nogueradante@gmail.com"
] | nogueradante@gmail.com |
1c7608f96214f6fa81c9cb8e682b1581ac9996c7 | 7b72f026feb13197e1a0bcde545c226816a27bde | /libmolcore/src/models/moleculemodels.h | 8bb8fdc5fcb5aeaac0da257ae77f39b198fb80ab | [] | no_license | timvdm/MolCoreSandbox | 4fd6e54365a020b5a569bda70609d0bd1a35f93a | 85cca36229223722aed9f86cf7bd39ff4c8307c1 | refs/heads/master | 2016-09-06T19:31:32.618660 | 2010-11-03T17:40:54 | 2010-11-03T17:40:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,068 | h | #ifndef MC_MOLECULEMODELS_H
#define MC_MOLECULEMODELS_H
#include <molcore/models/molecule.h>
#include <molcore/models/abstractmolecule.h>
#include <boost/any.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/seq/for_each_i.hpp>
namespace molcore {
template<typename Model>
Model model_cast(Model model)
{
typedef typename boost::remove_pointer<Model>::type nonptr;
return boost::any_cast<nonptr>(model);
}
/**
* This is the only place for specifying the models
*/
#define MOLECULE_MODELS (Molecule)(AbstractMolecule)
/**
* Create mpl vector from preprocessor sequence. This mpl vector is used to
* determine the template parameters for plugin factories.
*/
#define MACRO(r, data, i, elem) BOOST_PP_COMMA_IF(i) BOOST_PP_CAT(elem, data)*
typedef boost::mpl::vector<BOOST_PP_SEQ_FOR_EACH_I(MACRO, , MOLECULE_MODELS)> molecule_models;
#undef MACRO
}
#endif
| [
"tim.vandermeersch@gmail.com"
] | tim.vandermeersch@gmail.com |
52fd01f88a45e4ed9825f0415d826c3b292db27c | 8c0fa1fdbe1d7169f366995f1885316f790dccbe | /libraries/lua-gph/lib/src/lobject.cpp | a3058dd52b9345813140f7303d3c33bf9389e5bf | [
"MIT"
] | permissive | ypenghui6test/code_review_test | cc15e1be9588014785c29960f47f04f5d530b825 | cf0d51cd4b7ed0f0f57f251ed6222a1ccffd95b6 | refs/heads/master | 2020-09-28T13:40:21.747470 | 2019-12-16T09:44:14 | 2019-12-16T09:44:14 | 226,789,403 | 0 | 2 | null | 2019-12-10T05:48:23 | 2019-12-09T05:09:59 | null | UTF-8 | C++ | false | false | 16,507 | cpp | /*
** $Id: lobject.c,v 2.113 2016/12/22 13:08:50 roberto Exp $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
#define lobject_c
#define LUA_CORE
#include "lprefix.hpp"
#include <locale.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lua.hpp"
#include "lctype.hpp"
#include "ldebug.hpp"
#include "ldo.hpp"
#include "lmem.hpp"
#include "lobject.hpp"
#include "lstate.hpp"
#include "lstring.hpp"
#include "lvm.hpp"
LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT};
/*
** converts an integer to a "floating point byte", represented as
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
** eeeee != 0 and (xxx) otherwise.
*/
int luaO_int2fb (unsigned int x) {
int e = 0; /* exponent */
if (x < 8) return x;
while (x >= (8 << 4)) { /* coarse steps */
x = (x + 0xf) >> 4; /* x = ceil(x / 16) */
e += 4;
}
while (x >= (8 << 1)) { /* fine steps */
x = (x + 1) >> 1; /* x = ceil(x / 2) */
e++;
}
return ((e+1) << 3) | (cast_int(x) - 8);
}
/* converts back */
int luaO_fb2int (int x) {
return (x < 8) ? x : ((x & 7) + 8) << ((x >> 3) - 1);
}
/*
** Computes ceil(log2(x))
*/
int luaO_ceillog2 (unsigned int x) {
static const lu_byte log_2[256] = { /* log_2[i] = ceil(log2(i - 1)) */
0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
};
int l = 0;
x--;
while (x >= 256) { l += 8; x >>= 8; }
return l + log_2[x];
}
static lua_Integer intarith (lua_State *L, int op, lua_Integer v1,
lua_Integer v2) {
switch (op) {
case LUA_OPADD: return intop(+, v1, v2);
case LUA_OPSUB:return intop(-, v1, v2);
case LUA_OPMUL:return intop(*, v1, v2);
case LUA_OPMOD: return luaV_mod(L, v1, v2);
case LUA_OPIDIV: return luaV_div(L, v1, v2);
case LUA_OPBAND: return intop(&, v1, v2);
case LUA_OPBOR: return intop(|, v1, v2);
case LUA_OPBXOR: return intop(^, v1, v2);
case LUA_OPSHL: return luaV_shiftl(v1, v2);
case LUA_OPSHR: return luaV_shiftl(v1, -v2);
case LUA_OPUNM: return intop(-, 0, v1);
case LUA_OPBNOT: return intop(^, ~l_castS2U(0), v1);
default: lua_assert(0); return 0;
}
}
static lua_Number numarith (lua_State *L, int op, lua_Number v1,
lua_Number v2) {
switch (op) {
case LUA_OPADD: return luai_numadd(L, v1, v2);
case LUA_OPSUB: return luai_numsub(L, v1, v2);
case LUA_OPMUL: return luai_nummul(L, v1, v2);
case LUA_OPDIV: return luai_numdiv(L, v1, v2);
case LUA_OPPOW: return luai_numpow(L, v1, v2);
case LUA_OPIDIV: return luai_numidiv(L, v1, v2);
case LUA_OPUNM: return luai_numunm(L, v1);
case LUA_OPMOD: {
lua_Number m;
luai_nummod(L, v1, v2, m);
return m;
}
default: lua_assert(0); return 0;
}
}
void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,
TValue *res) {
switch (op) {
case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
case LUA_OPSHL: case LUA_OPSHR:
case LUA_OPBNOT: { /* operate only on integers */
lua_Integer i1; lua_Integer i2;
if (tointeger(p1, &i1) && tointeger(p2, &i2)) {
setivalue(res, intarith(L, op, i1, i2));
return;
}
else break; /* go to the end */
}
case LUA_OPDIV: case LUA_OPPOW: { /* operate only on floats */
lua_Number n1; lua_Number n2;
if (tonumber(p1, &n1) && tonumber(p2, &n2)) {
setfltvalue(res, numarith(L, op, n1, n2));
return;
}
else break; /* go to the end */
}
default: { /* other operations */
lua_Number n1; lua_Number n2;
if (ttisinteger(p1) && ttisinteger(p2)) {
setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2)));
return;
}
else if (tonumber(p1, &n1) && tonumber(p2, &n2)) {
setfltvalue(res, numarith(L, op, n1, n2));
return;
}
else break; /* go to the end */
}
}
/* could not perform raw operation; try metamethod */
lua_assert(L != NULL); /* should not fail when folding (compile time) */
luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD));
}
int luaO_hexavalue (int c) {
if (lisdigit(c)) return c - '0';
else return (ltolower(c) - 'a') + 10;
}
static int isneg (const char **s) {
if (**s == '-') { (*s)++; return 1; }
else if (**s == '+') (*s)++;
return 0;
}
/*
** {==================================================================
** Lua's implementation for 'lua_strx2number'
** ===================================================================
*/
#if !defined(lua_strx2number)
/* maximum number of significant digits to read (to avoid overflows
even with single floats) */
#define MAXSIGDIG 30
/*
** convert an hexadecimal numeric string to a number, following
** C99 specification for 'strtod'
*/
static lua_Number lua_strx2number (const char *s, char **endptr) {
int dot = lua_getlocaledecpoint();
lua_Number r = 0.0; /* result (accumulator) */
int sigdig = 0; /* number of significant digits */
int nosigdig = 0; /* number of non-significant digits */
int e = 0; /* exponent correction */
int neg; /* 1 if number is negative */
int hasdot = 0; /* true after seen a dot */
*endptr = cast(char *, s); /* nothing is valid yet */
while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
neg = isneg(&s); /* check signal */
if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */
return 0.0; /* invalid format (no '0x') */
for (s += 2; ; s++) { /* skip '0x' and read numeral */
if (*s == dot) {
if (hasdot) break; /* second dot? stop loop */
else hasdot = 1;
}
else if (lisxdigit(cast_uchar(*s))) {
if (sigdig == 0 && *s == '0') /* non-significant digit (zero)? */
nosigdig++;
else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */
r = (r * cast_num(16.0)) + luaO_hexavalue(*s);
else e++; /* too many digits; ignore, but still count for exponent */
if (hasdot) e--; /* decimal digit? correct exponent */
}
else break; /* neither a dot nor a digit */
}
if (nosigdig + sigdig == 0) /* no digits? */
return 0.0; /* invalid format */
*endptr = cast(char *, s); /* valid up to here */
e *= 4; /* each digit multiplies/divides value by 2^4 */
if (*s == 'p' || *s == 'P') { /* exponent part? */
int exp1 = 0; /* exponent value */
int neg1; /* exponent signal */
s++; /* skip 'p' */
neg1 = isneg(&s); /* signal */
if (!lisdigit(cast_uchar(*s)))
return 0.0; /* invalid; must have at least one digit */
while (lisdigit(cast_uchar(*s))) /* read exponent */
exp1 = exp1 * 10 + *(s++) - '0';
if (neg1) exp1 = -exp1;
e += exp1;
*endptr = cast(char *, s); /* valid up to here */
}
if (neg) r = -r;
return l_mathop(ldexp)(r, e);
}
#endif
/* }====================================================== */
/* maximum length of a numeral */
#if !defined (L_MAXLENNUM)
#define L_MAXLENNUM 200
#endif
static const char *l_str2dloc (const char *s, lua_Number *result, int mode) {
char *endptr;
*result = (mode == 'x') ? lua_strx2number(s, &endptr) /* try to convert */
: lua_str2number(s, &endptr);
if (endptr == s) return NULL; /* nothing recognized? */
while (lisspace(cast_uchar(*endptr))) endptr++; /* skip trailing spaces */
return (*endptr == '\0') ? endptr : NULL; /* OK if no trailing characters */
}
/*
** Convert string 's' to a Lua number (put in 'result'). Return NULL
** on fail or the address of the ending '\0' on success.
** 'pmode' points to (and 'mode' contains) special things in the string:
** - 'x'/'X' means an hexadecimal numeral
** - 'n'/'N' means 'inf' or 'nan' (which should be rejected)
** - '.' just optimizes the search for the common case (nothing special)
** This function accepts both the current locale or a dot as the radix
** mark. If the convertion fails, it may mean number has a dot but
** locale accepts something else. In that case, the code copies 's'
** to a buffer (because 's' is read-only), changes the dot to the
** current locale radix mark, and tries to convert again.
*/
static const char *l_str2d (const char *s, lua_Number *result) {
const char *endptr;
const char *pmode = strpbrk(s, ".xXnN");
int mode = pmode ? ltolower(cast_uchar(*pmode)) : 0;
if (mode == 'n') /* reject 'inf' and 'nan' */
return NULL;
endptr = l_str2dloc(s, result, mode); /* try to convert */
if (endptr == NULL) { /* failed? may be a different locale */
char buff[L_MAXLENNUM + 1];
const char *pdot = strchr(s, '.');
if (strlen(s) > L_MAXLENNUM || pdot == NULL)
return NULL; /* string too long or no dot; fail */
strcpy(buff, s); /* copy string to buffer */
buff[pdot - s] = lua_getlocaledecpoint(); /* correct decimal point */
endptr = l_str2dloc(buff, result, mode); /* try again */
if (endptr != NULL)
endptr = s + (endptr - buff); /* make relative to 's' */
}
return endptr;
}
#define MAXBY10 cast(lua_Unsigned, LUA_MAXINTEGER / 10)
#define MAXLASTD cast_int(LUA_MAXINTEGER % 10)
static const char *l_str2int (const char *s, lua_Integer *result) {
lua_Unsigned a = 0;
int empty = 1;
int neg;
while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
neg = isneg(&s);
if (s[0] == '0' &&
(s[1] == 'x' || s[1] == 'X')) { /* hex? */
s += 2; /* skip '0x' */
for (; lisxdigit(cast_uchar(*s)); s++) {
a = a * 16 + luaO_hexavalue(*s);
empty = 0;
}
}
else { /* decimal */
for (; lisdigit(cast_uchar(*s)); s++) {
int d = *s - '0';
if (a >= MAXBY10 && (a > MAXBY10 || d > MAXLASTD + neg)) /* overflow? */
return NULL; /* do not accept it (as integer) */
a = a * 10 + d;
empty = 0;
}
}
while (lisspace(cast_uchar(*s))) s++; /* skip trailing spaces */
if (empty || *s != '\0') return NULL; /* something wrong in the numeral */
else {
*result = l_castU2S((neg) ? 0u - a : a);
return s;
}
}
size_t luaO_str2num (const char *s, TValue *o) {
lua_Integer i; lua_Number n;
const char *e;
if ((e = l_str2int(s, &i)) != NULL) { /* try as an integer */
setivalue(o, i);
}
else if ((e = l_str2d(s, &n)) != NULL) { /* else try as a float */
setfltvalue(o, n);
}
else
return 0; /* conversion failed */
return (e - s) + 1; /* success; return string size */
}
int luaO_utf8esc (char *buff, unsigned long x) {
int n = 1; /* number of bytes put in buffer (backwards) */
lua_assert(x <= 0x10FFFF);
if (x < 0x80) /* ascii? */
buff[UTF8BUFFSZ - 1] = cast(char, x);
else { /* need continuation bytes */
unsigned int mfb = 0x3f; /* maximum that fits in first byte */
do { /* add continuation bytes */
buff[UTF8BUFFSZ - (n++)] = cast(char, 0x80 | (x & 0x3f));
x >>= 6; /* remove added bits */
mfb >>= 1; /* now there is one less bit available in first byte */
} while (x > mfb); /* still needs continuation byte? */
buff[UTF8BUFFSZ - n] = cast(char, (~mfb << 1) | x); /* add first byte */
}
return n;
}
/* maximum length of the conversion of a number to a string */
#define MAXNUMBER2STR 50
/*
** Convert a number object to a string
*/
void luaO_tostring (lua_State *L, StkId obj) {
char buff[MAXNUMBER2STR];
size_t len;
lua_assert(ttisnumber(obj));
if (ttisinteger(obj))
len = lua_integer2str(buff, sizeof(buff), ivalue(obj));
else {
len = lua_number2str(buff, sizeof(buff), fltvalue(obj));
#if !defined(LUA_COMPAT_FLOATSTRING)
if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */
buff[len++] = lua_getlocaledecpoint();
buff[len++] = '0'; /* adds '.0' to result */
}
#endif
}
setsvalue2s(L, obj, luaS_newlstr(L, buff, len));
}
static void pushstr (lua_State *L, const char *str, size_t l) {
setsvalue2s(L, L->top, luaS_newlstr(L, str, l));
luaD_inctop(L);
}
/*
** this function handles only '%d', '%c', '%f', '%p', and '%s'
conventional formats, plus Lua-specific '%I' and '%U'
*/
const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
int n = 0;
for (;;) {
const char *e = strchr(fmt, '%');
if (e == NULL) break;
pushstr(L, fmt, e - fmt);
switch (*(e+1)) {
case 's': { /* zero-terminated string */
const char *s = va_arg(argp, char *);
if (s == NULL) s = "(null)";
pushstr(L, s, strlen(s));
break;
}
case 'c': { /* an 'int' as a character */
char buff = cast(char, va_arg(argp, int));
if (lisprint(cast_uchar(buff)))
pushstr(L, &buff, 1);
else /* non-printable character; print its code */
luaO_pushfstring(L, "<\\%d>", cast_uchar(buff));
break;
}
case 'd': { /* an 'int' */
setivalue(L->top, va_arg(argp, int));
goto top2str;
}
case 'I': { /* a 'lua_Integer' */
setivalue(L->top, cast(lua_Integer, va_arg(argp, l_uacInt)));
goto top2str;
}
case 'f': { /* a 'lua_Number' */
setfltvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
top2str: /* convert the top element to a string */
luaD_inctop(L);
luaO_tostring(L, L->top - 1);
break;
}
case 'p': { /* a pointer */
char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */
int l = l_sprintf(buff, sizeof(buff), "%p", va_arg(argp, void *));
pushstr(L, buff, l);
break;
}
case 'U': { /* an 'int' as a UTF-8 sequence */
char buff[UTF8BUFFSZ];
int l = luaO_utf8esc(buff, cast(long, va_arg(argp, long)));
pushstr(L, buff + UTF8BUFFSZ - l, l);
break;
}
case '%': {
pushstr(L, "%", 1);
break;
}
default: {
luaG_runerror(L, "invalid option '%%%c' to 'lua_pushfstring'",
*(e + 1));
}
}
n += 2;
fmt = e+2;
}
luaD_checkstack(L, 1);
pushstr(L, fmt, strlen(fmt));
if (n > 0) luaV_concat(L, n + 1);
return svalue(L->top - 1);
}
const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
const char *msg;
va_list argp;
va_start(argp, fmt);
msg = luaO_pushvfstring(L, fmt, argp);
va_end(argp);
return msg;
}
/* number of chars of a literal string without the ending \0 */
#define LL(x) (sizeof(x)/sizeof(char) - 1)
#define RETS "..."
#define PRE "[string \""
#define POS "\"]"
#define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) )
void luaO_chunkid (char *out, const char *source, size_t bufflen) {
size_t l = strlen(source);
if (*source == '=') { /* 'literal' source */
if (l <= bufflen) /* small enough? */
memcpy(out, source + 1, l * sizeof(char));
else { /* truncate it */
addstr(out, source + 1, bufflen - 1);
*out = '\0';
}
}
else if (*source == '@') { /* file name */
if (l <= bufflen) /* small enough? */
memcpy(out, source + 1, l * sizeof(char));
else { /* add '...' before rest of name */
addstr(out, RETS, LL(RETS));
bufflen -= LL(RETS);
memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char));
}
}
else { /* string; format as [string "source"] */
const char *nl = strchr(source, '\n'); /* find first new line (if any) */
addstr(out, PRE, LL(PRE)); /* add prefix */
bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */
if (l < bufflen && nl == NULL) { /* small one-line source? */
addstr(out, source, l); /* keep it */
}
else {
if (nl != NULL) l = nl - source; /* stop at first newline */
if (l > bufflen) l = bufflen;
addstr(out, source, l);
addstr(out, RETS, LL(RETS));
}
memcpy(out, POS, (LL(POS) + 1) * sizeof(char));
}
}
| [
"ypenghui6@163.com"
] | ypenghui6@163.com |
12b9a57de3585b3dec02bb51aca50dcefd758648 | a62342d6359a88b0aee911e549a4973fa38de9ea | /0.6.0.3/Internal/SDK/BTService_SetOutsideNPCAIState_functions.cpp | 6dbad0e22468db508d92c16e00c25d5ac8787a4d | [] | no_license | zanzo420/Medieval-Dynasty-SDK | d020ad634328ee8ee612ba4bd7e36b36dab740ce | d720e49ae1505e087790b2743506921afb28fc18 | refs/heads/main | 2023-06-20T03:00:17.986041 | 2021-07-15T04:51:34 | 2021-07-15T04:51:34 | 386,165,085 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,535 | cpp | // Name: Medieval Dynasty, Version: 0.6.0.3
#include "../pch.h"
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
// Function BTService_SetOutsideNPCAIState.BTService_SetOutsideNPCAIState_C.ReceiveTickAI
// (Event, Protected, BlueprintEvent)
// Parameters:
// class AAIController* OwnerController (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
// class APawn* ControlledPawn (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
// float DeltaSeconds (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
void UBTService_SetOutsideNPCAIState_C::ReceiveTickAI(class AAIController* OwnerController, class APawn* ControlledPawn, float DeltaSeconds)
{
static auto fn = UObject::FindObject<UFunction>("Function BTService_SetOutsideNPCAIState.BTService_SetOutsideNPCAIState_C.ReceiveTickAI");
UBTService_SetOutsideNPCAIState_C_ReceiveTickAI_Params params;
params.OwnerController = OwnerController;
params.ControlledPawn = ControlledPawn;
params.DeltaSeconds = DeltaSeconds;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function BTService_SetOutsideNPCAIState.BTService_SetOutsideNPCAIState_C.ReceiveActivationAI
// (Event, Protected, BlueprintEvent)
// Parameters:
// class AAIController* OwnerController (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
// class APawn* ControlledPawn (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
void UBTService_SetOutsideNPCAIState_C::ReceiveActivationAI(class AAIController* OwnerController, class APawn* ControlledPawn)
{
static auto fn = UObject::FindObject<UFunction>("Function BTService_SetOutsideNPCAIState.BTService_SetOutsideNPCAIState_C.ReceiveActivationAI");
UBTService_SetOutsideNPCAIState_C_ReceiveActivationAI_Params params;
params.OwnerController = OwnerController;
params.ControlledPawn = ControlledPawn;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function BTService_SetOutsideNPCAIState.BTService_SetOutsideNPCAIState_C.ExecuteUbergraph_BTService_SetOutsideNPCAIState
// (Final)
// Parameters:
// int EntryPoint (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
void UBTService_SetOutsideNPCAIState_C::ExecuteUbergraph_BTService_SetOutsideNPCAIState(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function BTService_SetOutsideNPCAIState.BTService_SetOutsideNPCAIState_C.ExecuteUbergraph_BTService_SetOutsideNPCAIState");
UBTService_SetOutsideNPCAIState_C_ExecuteUbergraph_BTService_SetOutsideNPCAIState_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"zp2kshield@gmail.com"
] | zp2kshield@gmail.com |
22021d18f623378de819e992d7168645d4307ff4 | d8951f09dbcda35427f0765d2d828e1ef3bf8287 | /SolarSystem/Source/Parsers/FormattedFileParser.h | ffba75c77d5c10a906ccb869a257b29854ed0900 | [
"MIT"
] | permissive | janwaltl/SolarSystem | b8dcf71d274626fdba26c1945d2ad61533355831 | f148ed7aef00450bda3c6ae97166678a41872bdf | refs/heads/master | 2022-11-24T07:13:35.221656 | 2020-07-24T20:02:52 | 2020-07-24T20:02:52 | 282,304,803 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,553 | h | #ifndef PARSERS_FORMATTED_FILE_PARSER
#define PARSERS_FORMATTED_FILE_PARSER
#include "Parser.h"
#include <string>
namespace solar
{
//Loads simulated data from formatted text files
//Outputed simData's values are NOT in SI units,
// - pos is in AU units, velocity in AU/Earth years and mass in multiples of Sun's mass
// - Default color is white and pos=mass=vel=0, radius=1.0
//For detailed description of format, see documentation of examples included with binaries.
//Throws 'Exception' on any failure
class FormattedFileParser :public Parser
{
public:
//Including path and extension, leave outFileName empty if you don't want to save finished simulation
FormattedFileParser(const std::string& inputFileName, const std::string& outputFileName = "");
SimData Load() override final;
void Save(const SimData& data) override final;
private:
static Unit ParseUnit(const std::string& str);
//Str must be in format of' token=<val>', where val is returned string
//Throws Exception if invalid
static std::string ParseToken(const std::string&str, const std::string& token);
static void ParsePosition(Unit& unit, const std::string& val);
static void ParseVelocity(Unit& unit, const std::string& val);
static void ParseMass(Unit& unit, const std::string& val);
static void ParseRadius(Unit& unit, const std::string& val);
static void ParseColor(Unit& unit, const std::string& val);
static void ParseName(Unit& unit, const std::string& val);
const std::string inFileName, outFileName;
std::string input;
};
}
#endif | [
"waltl.jan@gmail.com"
] | waltl.jan@gmail.com |
5b23785647e0b4f15212bf218931cdf831b52382 | 5c66adeeeffb82d309368ab106b1b15ad08a6cf9 | /Backtracking/rat and the maze.cpp | c2d14d9e9471fba9a929814b91a46940afdee48b | [] | no_license | akashfit2max/SDE-problems | c0bcf5ebbeb9ffb051e047d748177d841388e2d8 | eb486119157dd078894a83ca5f66aeb09de5df93 | refs/heads/master | 2023-07-15T16:09:36.659020 | 2021-08-14T16:22:05 | 2021-08-14T16:22:05 | 287,676,492 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 679 | cpp | void findPath(int i,int j,int m[MAX][MAX],int n,string s,vector<string> &res)
{
if(i<0 or j<0 or i>=n or j>=n or m[i][j]==0 or m[i][j]==5 )
{
return;
}
if(i==n-1 && j==n-1)
{
res.push_back(s);
return;
}
else
{
m[i][j]=5;
findPath(i+1,j,m,n,s+'D',res);
findPath(i-1,j,m,n,s+'U',res);
findPath(i,j+1,m,n,s+'R',res);
findPath(i,j-1,m,n,s+'L',res);
m[i][j]=1;
}
}
vector<string> printPath(int m[MAX][MAX], int n)
{
vector<string>res;
findPath(0,0,m,n,"",res);
sort(res.begin(),res.end());
return res;
// Your code goes here
}
| [
"noreply@github.com"
] | noreply@github.com |
f39063a32f8fd3658c475aa0163a377f536494c2 | 091afb7001e86146209397ea362da70ffd63a916 | /inst/include/nt2/operator/include/functions/scalar/unary_plus.hpp | 9172e70b4c32ab1bbe04ea63cadc19c17f66abda | [] | no_license | RcppCore/RcppNT2 | f156b58c08863243f259d1e609c9a7a8cf669990 | cd7e548daa2d679b6ccebe19744b9a36f1e9139c | refs/heads/master | 2021-01-10T16:15:16.861239 | 2016-02-02T22:18:25 | 2016-02-02T22:18:25 | 50,460,545 | 15 | 1 | null | 2019-11-15T22:08:50 | 2016-01-26T21:29:34 | C++ | UTF-8 | C++ | false | false | 261 | hpp | #ifndef NT2_OPERATOR_INCLUDE_FUNCTIONS_SCALAR_UNARY_PLUS_HPP_INCLUDED
#define NT2_OPERATOR_INCLUDE_FUNCTIONS_SCALAR_UNARY_PLUS_HPP_INCLUDED
#include <nt2/operator/functions/unary_plus.hpp>
#include <boost/simd/operator/functions/scalar/unary_plus.hpp>
#endif
| [
"kevinushey@gmail.com"
] | kevinushey@gmail.com |
0ab00d731635ce21e258ced4bb94a4609233f354 | 4485b1b13a28d75b2e340aac9568e5f2fa0632ca | /src/StreamBufs/SDPCompressionStreamBuf.cpp | 04f64943190e49b6f0439688bde6dc81edae5b59 | [
"Zlib",
"ISC",
"BSL-1.0",
"BSD-2-Clause",
"Apache-2.0"
] | permissive | Cyberunner23/libSDP-old | 2ac0d2db07f1e3fd9cb1c154ca00f9d11c8ec5d1 | 79df569cba2a269a0f42bbbc675bc14e702dacf0 | refs/heads/master | 2021-05-01T11:43:29.618302 | 2015-07-18T22:58:07 | 2015-07-18T22:58:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,379 | cpp | /*
Copyright 2015 Alex Frappier Lachapelle
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 "SDPCompressionStreamBuf.hpp"
SDPCompressionStreamBuf::SDPCompressionStreamBuf(std::shared_ptr<std::istream> compressedIn, std::shared_ptr<SDPCompressionAlgorithmBase> compressionAlgorithm){
hasFirstBlockBeenRead = false;
inStream = compressedIn;
outStream = nullptr;
if(compressionAlgorithm){
currentCompressionAlgorithmInfo = makeCompressionAlgorithmInfo(compressionAlgorithm);
currentCompressionAlgorithmInfo.compressionAlgorithm.get()->onInit();
uncompressedBuffer.resize(currentCompressionAlgorithmInfo.bufferSizeWithOverhead);
compressedBuffer.resize(currentCompressionAlgorithmInfo.bufferSize);
}else{
currentCompressionAlgorithmInfo.compressionAlgorithm = nullptr;
}
currentChunkNum = 0;
nextChar = traits_type::eof();
}
SDPCompressionStreamBuf::SDPCompressionStreamBuf(std::shared_ptr<std::ostream> compressedOut, std::shared_ptr<SDPCompressionAlgorithmBase> compressionAlgorithm){
inStream = nullptr;
outStream = compressedOut;
if(compressionAlgorithm){
currentCompressionAlgorithmInfo = makeCompressionAlgorithmInfo(compressionAlgorithm);
currentCompressionAlgorithmInfo.compressionAlgorithm.get()->onInit();
uncompressedBuffer.reserve(currentCompressionAlgorithmInfo.bufferSize);
compressedBuffer.reserve(currentCompressionAlgorithmInfo.bufferSizeWithOverhead);
}else{
currentCompressionAlgorithmInfo.compressionAlgorithm = nullptr;
}
currentChunkNum = 0;
}
SDPCompressionStreamBuf::~SDPCompressionStreamBuf(){
if(currentCompressionAlgorithmInfo.compressionAlgorithm)
currentCompressionAlgorithmInfo.compressionAlgorithm.get()->onExit();
}
void SDPCompressionStreamBuf::setCompressionAlgorithm(std::shared_ptr<SDPCompressionAlgorithmBase> compressionAlgorithm, bool resetPosCounter){
if(currentCompressionAlgorithmInfo.compressionAlgorithm != nullptr){
currentCompressionAlgorithmInfo.compressionAlgorithm.get()->onSync();
currentCompressionAlgorithmInfo.compressionAlgorithm.get()->onExit();
}
if(resetPosCounter){
currentChunkNum = 0;
}
currentCompressionAlgorithmInfo = makeCompressionAlgorithmInfo(compressionAlgorithm);
currentCompressionAlgorithmInfo.compressionAlgorithm.get()->onInit();
}
SDPCompressionStreamBuf::SDPCompressionAlgorithmInfoStruct SDPCompressionStreamBuf::getCompressionAlgorithmInfo(){
return currentCompressionAlgorithmInfo;
}
SDPCompressionStreamBuf::int_type SDPCompressionStreamBuf::overflow(int_type ch){
return setNextChar(ch);
}
SDPCompressionStreamBuf::int_type SDPCompressionStreamBuf::underflow(){
return (int_type)getNextChar(false);
}
SDPCompressionStreamBuf::int_type SDPCompressionStreamBuf::uflow(){
return (int_type)getNextChar(true);
}
SDPCompressionStreamBuf::int_type SDPCompressionStreamBuf::pbackfail(int_type ch){
return traits_type::eof();
}
int SDPCompressionStreamBuf::sync(){
//If there's anything left in the buffer, compress and write it.
if(outStream && uncompressedBuffer.size() != 0){
compressAndWriteNextChunk();
currentCompressionAlgorithmInfo.compressionAlgorithm.get()->onSync();
}
outStream->flush();
return 0;
}
SDPCompressionStreamBuf::SDPCompressionAlgorithmInfoStruct SDPCompressionStreamBuf::makeCompressionAlgorithmInfo(std::shared_ptr<SDPCompressionAlgorithmBase> compressionAlgorithm){
SDPCompressionAlgorithmInfoStruct compressionAlgorithmInfoStruct = {};
compressionAlgorithmInfoStruct.compressionAlgorithm = compressionAlgorithm;
compressionAlgorithmInfoStruct.bufferSize = compressionAlgorithm.get()->getBufferSize();
compressionAlgorithmInfoStruct.bufferSizeWithOverhead = compressionAlgorithm.get()->getBufferSizeWithOverhead();
return compressionAlgorithmInfoStruct;
}
SDPCompressionStreamBuf::int_type SDPCompressionStreamBuf::getNextChar(bool doAdvance){
if(!doAdvance){
return nextChar;
}
//fill the uncompressed buffer if we're at the end of it
//or if the first block has not been read yet
if(bufferIterator == uncompressedBuffer.end() || !hasFirstBlockBeenRead){
if(!readAndDecompressNextChunk()){
return traits_type::eof();
}
bufferIterator = uncompressedBuffer.begin();
nextChar = (*bufferIterator);
//bufferIterator++;
std::advance(bufferIterator, 1);
hasFirstBlockBeenRead = true;
return nextChar;
}else{
nextChar = *bufferIterator;
//bufferIterator++;
std::advance(bufferIterator, 1);
return nextChar;
}
}
SDPCompressionStreamBuf::int_type SDPCompressionStreamBuf::setNextChar(int_type ch){
uncompressedBuffer.emplace_back(ch);
if (uncompressedBuffer.size() == currentCompressionAlgorithmInfo.bufferSize){
compressAndWriteNextChunk();
}
return traits_type::to_int_type(ch);
}
bool SDPCompressionStreamBuf::readAndDecompressNextChunk(){
uint64 compressedDataSizeInFile;
uint64 uncompressedDataSizeInFile;
bool isDataCompressed;
uncompressedBuffer.clear();
compressedBuffer.clear();
//Read compressed data size.
if(rawFileIO.read(compressedDataSizeInFile, inStream, RawFileIO::BIG__ENDIAN) != sizeof(compressedDataSizeInFile))
return false;
//Read uncompressed data size.
if(rawFileIO.read(uncompressedDataSizeInFile, inStream, RawFileIO::BIG__ENDIAN) != sizeof(uncompressedDataSizeInFile))
return false;
//Read is data compressed tag.
uint8 isDataCompressedTag;
if(rawFileIO.read(isDataCompressedTag, inStream) != sizeof(isDataCompressed))
return false;
if(isDataCompressedTag == 0x00)
isDataCompressed = false;
else if(isDataCompressedTag == 0xFF)
isDataCompressed = true;
else
return false; //error
//Read compressed/uncompressed data.
if(isDataCompressed){
//read compressed data
compressedBuffer.resize(compressedDataSizeInFile);
inStream.get()->read((char*)compressedBuffer.data(), compressedDataSizeInFile);
if(inStream.get()->gcount() != compressedDataSizeInFile)
return false; //Assume eos/error.
//Decompress
uncompressedBuffer.resize(uncompressedDataSizeInFile);
uint64 actualUncompressedDataSize;
actualUncompressedDataSize = currentCompressionAlgorithmInfo.compressionAlgorithm.get()->decompressBuffer(compressedBuffer.data(), uncompressedBuffer.data(), compressedBuffer.size(), uncompressedDataSizeInFile, currentChunkNum);
if(actualUncompressedDataSize != uncompressedDataSizeInFile)
return false; //Uncompressed size marked in file not consistent with achtual size, error.
}else{
//read uncompressed data.
uncompressedBuffer.resize(uncompressedDataSizeInFile);
inStream.get()->read((char*)uncompressedBuffer.data(), uncompressedDataSizeInFile);
if(inStream.get()->gcount() != uncompressedDataSizeInFile)
return false;
}
currentChunkNum++;
return true;
}
void SDPCompressionStreamBuf::compressAndWriteNextChunk(){
uint64 compressedDataSize;
uint64 uncompressedDataSize;
compressedBuffer.clear();
compressedBuffer.resize(currentCompressionAlgorithmInfo.bufferSizeWithOverhead);
uncompressedDataSize = uncompressedBuffer.size();
//Compress
compressedDataSize = currentCompressionAlgorithmInfo.compressionAlgorithm.get()->compressBuffer(uncompressedBuffer.data(), compressedBuffer.data(), uncompressedDataSize, currentChunkNum);
//Write compressed data size (value will be ignored if data is incompressible.)
rawFileIO.write(compressedDataSize, outStream, RawFileIO::BIG__ENDIAN);
//Write uncompressed data size.
rawFileIO.write(uncompressedDataSize, outStream, RawFileIO::BIG__ENDIAN);
//If the compressed data is of equal size or larger than the uncompressed data.
//Assume incompressible chunk and write uncompressed data
if(compressedDataSize >= uncompressedDataSize){
//Write is data compressed tag (false).
uint8 falseTag = 0x00;
rawFileIO.write(falseTag, outStream);
//Write uncompressed data.
outStream.get()->write((char*)uncompressedBuffer.data(), uncompressedDataSize);
}else{
//Write is data compressed tag (true).
uint8 falseTag = 0xFF;
rawFileIO.write(falseTag, outStream);
//Write compressed data.
outStream.get()->write((char*)compressedBuffer.data(), compressedDataSize);
}
uncompressedBuffer.clear();
currentChunkNum++;
}
| [
"narutoxela@gmail.com"
] | narutoxela@gmail.com |
c2048e6756e00af714609f6e489cfa8b6ce64e45 | 943dd54918355e8028fdd759bae6d9dd837e11e0 | /fk/display_self_check_callbacks.h | cef1c6d302a56014b0e15c6bef889b5affba9cd4 | [
"BSD-3-Clause"
] | permissive | fieldkit/firmware | 06e920ad01c2f48142413d3a3447188bc9753004 | 45c51ce8dc51df886875e97de17980c839882adf | refs/heads/main | 2023-08-23T22:29:02.022772 | 2023-07-24T22:18:01 | 2023-07-24T22:18:01 | 183,808,180 | 11 | 1 | BSD-3-Clause | 2023-04-04T20:42:38 | 2019-04-27T18:27:51 | C++ | UTF-8 | C++ | false | false | 627 | h | #pragma once
#include "self_check.h"
#include "hal/display.h"
namespace fk {
class DisplaySelfCheckCallbacks : public SelfCheckCallbacks {
public:
constexpr static size_t NumberOfChecks = 16;
private:
SelfCheckScreen screen_;
Check checks_[NumberOfChecks]{ };
Check *queued_[NumberOfChecks + 1]{ };
size_t number_{ 0 };
public:
DisplaySelfCheckCallbacks();
public:
void update(SelfCheckStatus status) override;
void append(const char *name, CheckStatus status);
void append(const char *name, ModuleCheckStatus status);
void clear();
public:
SelfCheckScreen &screen();
};
}
| [
"jlewallen@gmail.com"
] | jlewallen@gmail.com |
2c790cfff7fde16f2d69472d572561c38ad9544e | 1290dfa87f12bbba859ba0519bd451cdcf26f672 | /冒泡排序.cpp | a2db0d2a7a493256eb6e9417cde1c10d612e568d | [] | no_license | elanyang89/sort_algorithms | 7bdab751f6240ae6d28b7f64ad6ccfc0236875bb | 8a6bac104713f04edfecd8a21dd05e3fdb23a375 | refs/heads/master | 2021-01-13T15:03:56.052950 | 2017-02-10T09:41:54 | 2017-02-10T09:41:54 | 79,431,966 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 707 | cpp | /**
冒泡排序 时间复杂度 o(n * n)
将最大的数沉到最下面
// 优化1 如果一遍遍历没有数据交互 说明已经排好序了,不用再迭代了
// 优化2 记录某次遍历最后发生数据交换的位置,这个位置之后的数据已经有序了,不用再排序了。就可以确定下次交互位置循环范围
@param arr 待排序数组
*/
void bubble_sort (int arr[]){
int length = sizeof(arr)/sizeof(arr[0]);
if(length <= 1){
return ;
}
for (int i = 0; i < length - 1; ++i)
{
for (int j = 1; j < length - i; ++j)
{
if(arr[j] < arr[j-1]){
int temp = arr[j];
arr[j] = arr [j-1];
arr[j-1] = temp;
}
}
}
}
| [
"elan@ElanyangdeiMac.local"
] | elan@ElanyangdeiMac.local |
eb89375c5fb84e205b7e9c7bcb9f738d747ae07e | 7cee40bf00f6bd0a68aff8f244551902e912103f | /Programming_References/C++/C++ Tutorial/C++Tutorial_Printing.cpp | 6c57addbd161b8a48b4ab951c412891b573833de | [] | no_license | MCKasman/archives | f2937722d724b33706f45ea2aa1f1582073778d3 | 0e8527951b3e3a675b356bc9b94dba96f33ed623 | refs/heads/master | 2021-05-26T07:02:48.805957 | 2020-08-06T04:54:42 | 2020-08-06T04:54:42 | 127,826,740 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 216 | cpp | #include <iostream>
using namespace std;
int main()
{
cout << "Hello world \n\n"; // "\n" makes a new line, you can put multiple new lines in one statement.
cout << "and good morning!";
return 0;
}
| [
"mck.kasman@gmail.com"
] | mck.kasman@gmail.com |
d7381d5f74c842afdb647d98825ff98b34c1f3eb | cdd243baa465595291a16c4fbdc9f08da3c3d609 | /ClickableButton.h | 756a09f3e98505ce6508b3408190b051a29eff26 | [] | no_license | Omnerlin/SquareGame | cb7626cf650cb90fbc71255dd0bb468e018e4f02 | 4c6c57808885c742d5b5870d33f663b892c3038f | refs/heads/master | 2021-04-26T12:31:18.597043 | 2016-12-26T05:55:32 | 2016-12-26T05:55:32 | 74,615,883 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 513 | h | #pragma once
#include "Entity.h"
class ClickableButton
{
private:
bool selected = false;
float bloatSize = 1.4;
float bloatRate = 8;
public:
sf::RectangleShape rect;
sf::Text text;
void setBloatSize(float size);
float getBloatSize();
void centerText();
void setPosition(sf::Vector2f &position);
void bloat(float deltaTime);
void deflate(float deltaTime);
void select();
void deselect();
bool getSelected();
void reset();
ClickableButton();
~ClickableButton();
};
| [
"noreply@github.com"
] | noreply@github.com |
aa21b45842d168ae76a0ba372b474ac4c2fb7ff3 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/mutt/gumtree/mutt_repos_function_1327_last_repos.cpp | d03b113d12acb4c542d6717903a9479f327a60c0 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 835 | cpp | static const char *
parse_address (const char *s,
char *token, size_t *tokenlen, size_t tokenmax,
char *comment, size_t *commentlen, size_t commentmax,
ADDRESS *addr)
{
s = parse_mailboxdomain (s, ".\"(\\",
token, tokenlen, tokenmax,
comment, commentlen, commentmax);
if (!s)
return NULL;
if (*s == '@')
{
if (*tokenlen < tokenmax)
token[(*tokenlen)++] = '@';
s = parse_mailboxdomain (s + 1, ".([]\\",
token, tokenlen, tokenmax,
comment, commentlen, commentmax);
if (!s)
return NULL;
}
terminate_string (token, *tokenlen, tokenmax);
addr->mailbox = safe_strdup (token);
if (*commentlen && !addr->personal)
{
terminate_string (comment, *commentlen, commentmax);
addr->personal = safe_strdup (comment);
}
return s;
} | [
"993273596@qq.com"
] | 993273596@qq.com |
bf6c033e0fbd8284530628323eefa52106b172c1 | 5098a5bab107adb675b394b06093ed6913921ebc | /SDK/BP_PlayerState_Tutorial_classes.h | 819041d45caf528e70a22ffcff13cb6e663e63d0 | [] | no_license | tetosama/DRG-SDK | 87af9452fa0d3aed2411a09a108f705ae427ba1e | acb72b0ee2aae332f236f99030d27f4da9113de1 | refs/heads/master | 2022-03-31T00:12:10.582553 | 2020-01-18T21:21:43 | 2020-01-18T21:21:43 | 234,783,902 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 701 | h | #pragma once
// Name: , Version: 1.0.0
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass BP_PlayerState_Tutorial.BP_PlayerState_Tutorial_C
// 0x0000 (0x0578 - 0x0578)
class ABP_PlayerState_Tutorial_C : public ABP_PlayerState_C
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_PlayerState_Tutorial.BP_PlayerState_Tutorial_C");
return ptr;
}
void UserConstructionScript();
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"39564369+tetosama@users.noreply.github.com"
] | 39564369+tetosama@users.noreply.github.com |
dd06f26cd61d9deb76a3c89d384edd3660f9abd8 | 55ea326bce9d427888abc5c24b2c4d9dadc40b42 | /1.BaiTap/BTSo2/B5.cpp | 14bedfb01f998aa44917c8de994b9945698a44d6 | [] | no_license | DuyetVu2001/Study-CPlusPlus-Language | aa19304b19db6f20bf7f2adc2a66f5ab9ca74767 | fea555a683740a5a3a2ddc4f7dfdc501675d8ccc | refs/heads/master | 2022-12-06T14:59:21.236321 | 2020-08-25T13:45:40 | 2020-08-25T13:45:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 261 | cpp | #include <iostream>
#include <cmath>
using namespace std;
int main(){
int n, s = 0, t = 1;
do{
cout << "Nhap so nguyen duong n: ";
cin >> n;
}while(n < 0);
for(int i = 1; i <= n; i++){
t *= i;
s += t;
}
cout << "S = " << s;
return 0;
}
| [
"vungocduyet24@gmail.com"
] | vungocduyet24@gmail.com |
e7aa46eabad81ff866ba4be01e76fe7588231f0f | 7b9f9fcc4127fe65eec0d8ba50fd1f77b1627eb5 | /gemdaq-testing/gemhardware/include/gem/hw/vfat/VFAT2Registers.h | 258ba99687bea88aa8f44f8d845a48aede2b439b | [] | no_license | bdorney/gem-daq-code | c69bc148f9bfc5a971dd4cdb245e275fc28264a4 | 341a05f2740f9abd15035ba85899065142441819 | refs/heads/develop | 2021-01-15T14:59:51.755617 | 2015-08-18T13:28:18 | 2015-08-18T13:28:18 | 36,812,400 | 0 | 1 | null | 2015-06-03T15:24:17 | 2015-06-03T15:24:17 | null | UTF-8 | C++ | false | false | 6,165 | h | #ifndef gem_hw_vfat_VFAT2Registers_h
#define gem_hw_vfat_VFAT2Registers_h
namespace gem {
namespace hw {
namespace vfat {
class VFAT2ChannelData;
class VFAT2Registers
{
public:
enum RunMode { //defines the run mode
SLEEP = 0x0, //sleep (default)
RUN = 0x1 //running
}
enum TriggerMode { //Trigger mode settings
NOTRIGGER = 0x0, //No trigger (default)
ONEMODE = 0x1, //One sector (S1)
FOURMODE = 0x2, //Four sectors (S1-S4)
GEMMODE = 0x3, //Eight sectors (S1-S8
SPARE0 = 0x4, //GEM mode (S1 to S8 as defined in the HitCountMode)
SPARE1 = 0x5, //GEM mode (S1 to S8 as defined in the HitCountMode)
SPARE2 = 0x6, //GEM mode (S1 to S8 as defined in the HitCountMode)
SPARE3 = 0x7, //GEM mode (S1 to S8 as defined in the HitCountMode)
}
enum CalibrationMode { //Calibration settings
NORMAL = 0x0, //Normal running (default)
VCAL = 0x1, //CalOut = VCal (programmable voltage level, possible to connect to DACo-V)
BASELINE = 0x2, //CalOut = Baseline (fixed voltage level, possible to connect to DACo-V)
EXTERNAL = 0x3, //CalOut = External calibration pulse (not possible to connect to DACoV)
}
enum MSPolarity { //Monostable input polarity, tells the monostable polarity of the input signal
POSITIVE = 0x0, //positive I/P signal (default)
NEGATIVE = 0x1 //negative I/P signal
}
enum CalPolarity { //Calibration pulse polarity, to match with the polarity of the input signal
POSITIVE = 0x0, //positive I/P signal (default)
NEGATIVE = 0x1 //negative I/P signal
}
enum LVDSPowerSave { //Enables power saving for unused LVDA sector drivers
ENABLEALL = 0x0, //Enable all sector LVDS drivers (default)
POWERSAVE = 0x1 //Enable only sector LVDS drivers needed (save power)
}
enum DACMode { //Controls DAC selecton for DCU monitoring
NORMAL = 0x0, //DACo-V "low", DACo-I "Hi Z", normal running (default)
IPREIN = 0x1, //IPreampIn to DACo-I, DACo-V "low"
IPREFEED = 0x2, //IPreampFeed to DACo-I, DACo-V "low"
IPREOUT = 0x3, //IPreampOut to DACo-I, DACo-V "low"
ISHAPER = 0x4, //IShaper to DACo-I, DACo-V "low"
ISHAPFEED = 0x5, //IShaperFeed to DACo-I, DACo-V "low"
ICOMP = 0x6, //IComp to DACo-I, DACo-V "low"
ITHRESH1 = 0x7, //IThreshold1 to DACo-I, DACo-V "low"
ITHRESH2 = 0x8, //IThreshold2 to DACo-I, DACo-V "low"
VCAL = 0x9, //VCal to DACo-V, DACo-I "Hi Z"
CALOUT = 0xa, //CalOut to DACo-V, DACo-I "Hi Z"
SPARE0 = 0xb, //Spare
SPARE1 = 0xc, //Spare
SPARE2 = 0xd, //Spare
SPARE3 = 0xe, //Spare
SPARE4 = 0xf, //Spare
}
enum HitCountMode { //Defines the input for the Hitounter
FASTOR128 = 0x0, //HitCounter counts a FastOR of all 128 channels
COUNTS1 = 0x1, //HitCounter counts S1 (4, 5, 6, 28, 29, 30, 52, 53, 54, 76, 77, 78, 100, 101, 102 )
COUNTS2 = 0x2, //HitCounter counts S2 (7, 8, 9, 31, 32, 33, 55, 56, 57, 79, 80, 81, 103, 104, 105 )
COUNTS3 = 0x3, //HitCounter counts S3 (10, 11, 12, 34, 35, 36, 58, 59, 60, 82, 83, 84, 106, 107, 108)
COUNTS4 = 0x4, //HitCounter counts S4 (13, 14, 15, 37, 38, 39, 61, 62, 63, 85, 86, 87, 109, 110, 111)
COUNTS5 = 0x5, //HitCounter counts S5 (16, 17, 18, 40, 41, 42, 64, 65, 66, 88, 89, 90, 112, 113, 114)
COUNTS6 = 0x6, //HitCounter counts S6 (19, 20, 21, 43, 44, 45, 67, 68, 69, 91, 92, 93, 115, 116, 117)
COUNTS7 = 0x7, //HitCounter counts S7 (22, 23, 24, 46, 47, 48, 70, 71, 72, 94, 95, 96, 118, 119, 120)
COUNTS8 = 0x8, //HitCounter counts S8 (25, 26, 27, 49, 50, 51, 73, 74, 75, 97, 98, 99, 121, 122, 123)
REDUNDANT0 = 0x9, //HitCounter counts S8
REDUNDANT1 = 0xa, //HitCounter counts S8
REDUNDANT2 = 0xb, //HitCounter counts S8
REDUNDANT3 = 0xc, //HitCounter counts S8
REDUNDANT4 = 0xd, //HitCounter counts S8
REDUNDANT5 = 0xe, //HitCounter counts S8
REDUNDANT6 = 0xf, //HitCounter counts S8
}
enum MSPulseLength { //Defines the length of the monostable pulse
CLOCK1 = 0x0, //pulse length is 1 clock period (default)
CLOCK2 = 0x1, //pulse length is 2 clock period
CLOCK3 = 0x2, //pulse length is 3 clock period
CLOCK4 = 0x3, //pulse length is 4 clock period
CLOCK5 = 0x4, //pulse length is 5 clock period
CLOCK6 = 0x5, //pulse length is 6 clock period
CLOCK7 = 0x6, //pulse length is 7 clock period
CLOCK8 = 0x7, //pulse length is 8 clock period
}
enum ReHitCT { //The cycle time (or number of bits) for the Hit counter
CYCLE0 = 0x0, //
CYCLE1 = 0x1, //
CYCLE2 = 0x2, //
CYCLE3 = 0x3 //
}
enum DigInSel { //Selects the input via the digital input pads (bypass of the analog frontend)
ANALOG = 0x0, //default is analog pads
DIGITAL = 0x1 //bypass the analog pads
}
enum TrimDACRange { //Adjusts the range of the TrimDACs
DEFAULT = 0x0, //default value is 0
}
enum PbBG { //Enables pad access to the bandgap output
UNCONNECTED = 0x0, //default is disconnected
CONNECTED = 0x1 //pad connected
}
enum DFTestPattern { //Predefined data packet is sent to the DataOut without need for an input signal or trigger
IDLE = 0x0, //Normal mode, sit idle
SEND = 0x1 //Send the packet
}
}; //end class VFAT2Registers
}//end namespace gem::hw::vfat
}//end namespace gem::hw
}//end namespace gem
#endif
| [
"sturdy@cern.ch"
] | sturdy@cern.ch |
96d04917447acacad5610aaf2c058f23b4712d3d | 87085b9ea3a10d92988744bd57b8f6b0621d7dbe | /oiramExporter/MaxScriptExtended.cpp | 4e60e4ff1d78f1b467b30da103d3e33c2f6530a8 | [] | no_license | fordream/oiramExporter | 85146e68a3c618a560ce563576fb3643712cce27 | 59d0ba49ee4a4f43826a9dbeebde1eea50caeed5 | refs/heads/master | 2021-01-24T19:51:34.925165 | 2015-10-31T13:34:18 | 2015-10-31T13:34:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,606 | cpp | #include "stdafx.h"
#include "MaxScriptExtended.h"
#include "Component.h"
// interface ID
#define MAXSCRIPT_EXTENDED_INTERFACE Interface_ID(0x7ef553, 0x151232)
static MaxScriptExtendedInterface msMaxScriptExtendedInterfaceDesc(
MAXSCRIPT_EXTENDED_INTERFACE, _T("oiram"), 0, NULL, FP_CORE,
MaxScriptExtendedInterface::fidOptionDialog, _T("optionDialog"), 0, TYPE_bool, 0, 0,
MaxScriptExtendedInterface::fidExport, _T("export"), 0, TYPE_bool, 0, 1,
_T("selected"), 0, TYPE_bool,
MaxScriptExtendedInterface::fidRename, _T("rename"), 0, TYPE_VOID, 0, 1,
_T("name"), 0, TYPE_STRING,
properties,
MaxScriptExtendedInterface::fidGetMerge, MaxScriptExtendedInterface::fidSetMerge, _T("merge"), 0, TYPE_BOOL,
MaxScriptExtendedInterface::fidGetResetNodeScale, MaxScriptExtendedInterface::fidSetResetNodeScale, _T("resetNodeScale"), 0, TYPE_BOOL,
end);
bool MaxScriptExtendedInterface::
OptionDialog()
{
return Component::getSingleton().OptionDialog();
}
bool MaxScriptExtendedInterface::
Export(bool selected)
{
Component& component = Component::getSingleton();
component.OnSceneModified();
return component.Export(selected);
}
void MaxScriptExtendedInterface::
Rename(MSTR name)
{
Component::getSingleton().Rename(name);
}
BOOL MaxScriptExtendedInterface::
GetMerge()
{
return mMerge;
}
void MaxScriptExtendedInterface::
SetMerge(BOOL merge)
{
mMerge = merge;
}
BOOL MaxScriptExtendedInterface::
GetResetNodeScale()
{
return mResetNodeScale;
}
void MaxScriptExtendedInterface::
SetResetNodeScale(BOOL reset)
{
mResetNodeScale = reset;
}
| [
"yangtuo0429@gmail.com"
] | yangtuo0429@gmail.com |
82c5b9c6a96168f5d120a5ad9078ee32dcf7c026 | a3304e490b4fcb66c4072c28b3ba75664a538e60 | /pongs/Ball.h | 1078afa172b413cdab897a47cb6474758ff31684 | [] | no_license | jkjaykang/CS3113-Jay-Kang | 8c44384566c029fd539185b25aa6d469d80f700c | 4685ab40d13adac76eba26cd6c2dc9ab3790a6d3 | refs/heads/master | 2022-03-15T10:18:55.714746 | 2019-11-15T01:43:32 | 2019-11-15T01:43:32 | 209,865,348 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 430 | h | #pragma once
#define GL_SILENCE_DEPRECATION
#ifdef _WINDOWS
#include <GL/glew.h>
#endif
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_image.h>
#include "glm/mat4x4.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "ShaderProgram.h"
class Ball {
public:
glm::vec3 position;
glm::vec3 movement;
float speed;
GLuint textureID;
Ball();
void Update(float deltaTime);
void Render(ShaderProgram* program);
};
| [
"yjk441@nyu.edu"
] | yjk441@nyu.edu |
8425ffcee28fb4cf2d70b0e66ac955641bca954d | 3bfe741bca4ccb928ab03958fef677662b642a32 | /include/RE/Events/ScriptEvent/TESDeathEvent.h | b6544887f8bc97dc0536a04fa4d9c526ff2dc7d5 | [
"MIT"
] | permissive | Slaynot/CommonLibSSE | 9865fc7d7e3167dd72193ef3828ac7db54858cc5 | 6b3fd268327fb630139d2a183cbd5aa5669cfc5f | refs/heads/master | 2023-08-19T00:32:11.523120 | 2021-10-05T21:02:33 | 2021-10-05T21:02:33 | 293,022,195 | 0 | 1 | MIT | 2021-10-05T19:52:10 | 2020-09-05T07:02:12 | C++ | UTF-8 | C++ | false | false | 435 | h | #pragma once
#include "RE/NetImmerse/NiSmartPointer.h"
namespace RE
{
class TESObjectREFR;
struct TESDeathEvent
{
public:
// members
NiPointer<TESObjectREFR> actorDying; // 00
NiPointer<TESObjectREFR> actorKiller; // 08
bool dead; // 10
std::uint8_t pad11{ 0 }; // 11
std::uint16_t pad12{ 0 }; // 12
std::uint32_t pad14{ 0 }; // 14
};
static_assert(sizeof(TESDeathEvent) == 0x18);
}
| [
"ryan__mckenzie@hotmail.com"
] | ryan__mckenzie@hotmail.com |
484c11002ab0ca6aaa7d193062f1a5bafd50479a | 45d38f7fbe05f3487df4f3918475d9c5e32b8c1a | /Lista 3/10298.cc | caefc72f7158dcf946cd0e5ad0960125e66e86e0 | [] | no_license | JoaoRMaia/URI | 5c2f9514666959456b4dfc51e3bd4a3105850e2a | 493c5523c5ca7def4bdd480391c84ef977f0085d | refs/heads/main | 2023-05-11T20:48:09.044570 | 2021-06-08T16:28:47 | 2021-06-08T16:28:47 | 375,072,655 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 682 | cc | #include <iostream>
#include <string>
using namespace std;
int main(int argc, char **argv)
{
string input;
string candidato;
int n;
while(1){
cin >> input;
if (input == ".") break;
for ( unsigned i = 1 ; i <= input.size() ; i++) {
candidato = string{input,0,i};
if (input.size() % i != 0) continue;
for ( unsigned j = 0 ; j < input.size()/i ; j++){
if ( j == (input.size()/i)-1) {
n = j+1;
input.clear();
break;
}
else if (!((j+1)*i < input.size() && candidato == input.substr((j+1)*i,i))) break;
}
}
if (!input.empty()) cout << "1" << endl;
else cout << n << endl;;
}
return 0;
}
| [
"joao@DESKTOP-JAV2S4U.localdomain"
] | joao@DESKTOP-JAV2S4U.localdomain |
5ae6139810dbc09fb7e0cb41f32ab818de4b9807 | 9f4e3587707edca719139257198fe0e62a2dd040 | /client/netRaven/Raven/utils.hpp | a940fdc0c7fd22af570bb81edc0bc7ada5934b9e | [
"BSD-3-Clause"
] | permissive | killvxk/raven | 69cb50d18e7927a78c95cb7936363f20e466ff62 | 7e229919a9185d1175210acb8263a67c1d7ad705 | refs/heads/master | 2020-05-25T10:15:39.098025 | 2019-08-09T04:00:54 | 2019-08-09T04:00:54 | 187,757,001 | 1 | 0 | BSD-3-Clause | 2019-08-09T04:00:56 | 2019-05-21T03:44:02 | C++ | UTF-8 | C++ | false | false | 1,615 | hpp | #pragma once
/*
MIT License
Copyright (c) 2017 Aaron
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.
*/
#ifdef _DEBUG
#include <fstream>
#define LOG(x) do {std::fstream f("LOG.txt", std::ios::app); f << __FILE__ << " : " << __LINE__ << " - " << x << std::endl; f.close();} while(0)
#define LOG_ERROR(x, y) do {std::fstream f("LOG.txt", std::ios::app); f << __FILE__ << " : " << __LINE__ << " - " << x << " - 0x" << std::hex << y << std::endl; f.close();} while(0)
#define EXCEPT(x) std::runtime_error(x)
#else
#define LOG(x) __LINE__
#define EXCEPT(x) std::runtime_error(std::to_string(__LINE__))
#define LOG_ERROR(x, y) (void*)0
#endif | [
"chris@xorrior.com"
] | chris@xorrior.com |
e0b9a2a5099968fe4ddd66d518fc5da11ed7ebc5 | 85b9ce4fb88972d9b86dce594ae4fb3acfcd0a4b | /build/Android/Preview/Global Pot/app/src/main/include/Outracks.Simulator.Reflection.Native.TryInvokeExtension.h | fb2e2a00570a30391afd5e8cfa191add71f0fdb4 | [] | no_license | bgirr/Global-Pot_App | 16431a99e26f1c60dc16223fb388d9fd525cb5fa | c96c5a8fb95acde66fc286bcd9a5cdf160ba8b1b | refs/heads/master | 2021-01-09T06:29:18.255583 | 2017-02-21T23:27:47 | 2017-02-21T23:27:47 | 80,985,681 | 0 | 0 | null | 2017-02-21T23:27:48 | 2017-02-05T10:29:14 | C++ | UTF-8 | C++ | false | false | 2,750 | h | // This file was generated based on C:\Users\EliteBook-User\AppData\Local\Fusetools\Fuse\App\app-0.33.0.10195\Packages\Outracks.Simulator.Reflection.Uno\0.0.0\native\$.uno.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.h>
namespace g{namespace Outracks{namespace Simulator{namespace Bytecode{struct TypeMemberName;}}}}
namespace g{namespace Outracks{namespace Simulator{namespace Reflection{namespace Native{struct TryInvokeExtension;}}}}}
namespace g{
namespace Outracks{
namespace Simulator{
namespace Reflection{
namespace Native{
// internal static extern class TryInvokeExtension :288
// {
uClassType* TryInvokeExtension_typeof();
void TryInvokeExtension__FindUnambiguousMethod_fn(uType* type, ::g::Outracks::Simulator::Bytecode::TypeMemberName* methodName, uArray* arguments, uObject** __retval);
void TryInvokeExtension__GetEvent_fn(uType* type, ::g::Outracks::Simulator::Bytecode::TypeMemberName* name, uType* propertyType, uObject** __retval);
void TryInvokeExtension__GetField_fn(uType* type, ::g::Outracks::Simulator::Bytecode::TypeMemberName* name, uObject** __retval);
void TryInvokeExtension__GetMethod_fn(uType* type, ::g::Outracks::Simulator::Bytecode::TypeMemberName* name, uArray* parameterTypes, uObject** __retval);
void TryInvokeExtension__GetMethods_fn(uType* type, uArray** __retval);
void TryInvokeExtension__GetProperty_fn(uType* type, ::g::Outracks::Simulator::Bytecode::TypeMemberName* name, uType* propertyType, uObject** __retval);
void TryInvokeExtension__IsInstanceOfType_fn(uType* type, uObject* obj, bool* __retval);
void TryInvokeExtension__ParametersMatch_fn(uObject* m, uArray* arguments, bool* __retval);
void TryInvokeExtension__TryInvoke_fn(uObject* mi, uObject* obj, uArray* value, uObject** __retval);
struct TryInvokeExtension : uObject
{
static uObject* FindUnambiguousMethod(uType* type, ::g::Outracks::Simulator::Bytecode::TypeMemberName* methodName, uArray* arguments);
static uObject* GetEvent(uType* type, ::g::Outracks::Simulator::Bytecode::TypeMemberName* name, uType* propertyType);
static uObject* GetField(uType* type, ::g::Outracks::Simulator::Bytecode::TypeMemberName* name);
static uObject* GetMethod(uType* type, ::g::Outracks::Simulator::Bytecode::TypeMemberName* name, uArray* parameterTypes);
static uArray* GetMethods(uType* type);
static uObject* GetProperty(uType* type, ::g::Outracks::Simulator::Bytecode::TypeMemberName* name, uType* propertyType);
static bool IsInstanceOfType(uType* type, uObject* obj);
static bool ParametersMatch(uObject* m, uArray* arguments);
static uObject* TryInvoke(uObject* mi, uObject* obj, uArray* value);
};
// }
}}}}} // ::g::Outracks::Simulator::Reflection::Native
| [
"girr.benjamin@gmail.com"
] | girr.benjamin@gmail.com |
b099ab76a8905e8484ecc5a0f2338c6bad7b1172 | 67f988dedfd8ae049d982d1a8213bb83233d90de | /external/chromium/chrome/browser/profiles/profile_shortcut_manager_win.h | 7737b02331834febdb29e6d8c31d17a5eb63c69b | [
"BSD-3-Clause"
] | permissive | opensourceyouthprogramming/h5vcc | 94a668a9384cc3096a365396b5e4d1d3e02aacc4 | d55d074539ba4555e69e9b9a41e5deb9b9d26c5b | refs/heads/master | 2020-04-20T04:57:47.419922 | 2019-02-12T00:56:14 | 2019-02-12T00:56:14 | 168,643,719 | 1 | 1 | null | 2019-02-12T00:49:49 | 2019-02-01T04:47:32 | C++ | UTF-8 | C++ | false | false | 3,139 | h | // Copyright (c) 2012 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_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_
#define CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_
#include "chrome/browser/profiles/profile_shortcut_manager.h"
class BrowserDistribution;
// Internal free-standing functions that are exported here for testing.
namespace profiles {
namespace internal {
// Name of the badged icon file generated for a given profile.
extern const char kProfileIconFileName[];
// Returns the default shortcut filename for the given profile name,
// given |distribution|. Returns a filename appropriate for a
// single-user installation if |profile_name| is empty.
string16 GetShortcutFilenameForProfile(const string16& profile_name,
BrowserDistribution* distribution);
// Returns the command-line flags to launch Chrome with the given profile.
string16 CreateProfileShortcutFlags(const FilePath& profile_path);
} // namespace internal
} // namespace profiles
class ProfileShortcutManagerWin : public ProfileShortcutManager,
public ProfileInfoCacheObserver {
public:
// Specifies whether a new shortcut should be created if none exist.
enum CreateOrUpdateMode {
UPDATE_EXISTING_ONLY,
CREATE_WHEN_NONE_FOUND,
};
// Specifies whether non-profile shortcuts should be updated.
enum NonProfileShortcutAction {
IGNORE_NON_PROFILE_SHORTCUTS,
UPDATE_NON_PROFILE_SHORTCUTS,
};
explicit ProfileShortcutManagerWin(ProfileManager* manager);
virtual ~ProfileShortcutManagerWin();
// ProfileShortcutManager implementation:
virtual void CreateProfileShortcut(const FilePath& profile_path) OVERRIDE;
// ProfileInfoCacheObserver implementation:
virtual void OnProfileAdded(const FilePath& profile_path) OVERRIDE;
virtual void OnProfileWillBeRemoved(const FilePath& profile_path) OVERRIDE;
virtual void OnProfileWasRemoved(const FilePath& profile_path,
const string16& profile_name) OVERRIDE;
virtual void OnProfileNameChanged(const FilePath& profile_path,
const string16& old_profile_name) OVERRIDE;
virtual void OnProfileAvatarChanged(const FilePath& profile_path) OVERRIDE;
private:
void StartProfileShortcutNameChange(const FilePath& profile_path,
const string16& old_profile_name);
// Gives the profile path of an alternate profile than |profile_path|.
// Must only be called when the number profiles is 2.
FilePath GetOtherProfilePath(const FilePath& profile_path);
void CreateOrUpdateShortcutsForProfileAtPath(const FilePath& profile_path,
CreateOrUpdateMode create_mode,
NonProfileShortcutAction action);
ProfileManager* profile_manager_;
DISALLOW_COPY_AND_ASSIGN(ProfileShortcutManagerWin);
};
#endif // CHROME_BROWSER_PROFILES_PROFILE_SHORTCUT_MANAGER_WIN_H_
| [
"rjogrady@google.com"
] | rjogrady@google.com |
3a69e25be6df17fbaf4b763e7edc37a87d2a13c0 | f81c6264cbc20b49e19d4fb892dacf17dc2216fb | /MiningGoldEasy.cpp | 821efdcfe4e370de6be8f1040c1f7533383b0f37 | [] | no_license | fhlove/topcoder | cc8de25b0996fa1b2456e534fbacf8468205863f | ea0e5e77fc009d6c26c2ef8dd09f162f6929540d | refs/heads/master | 2021-01-20T11:22:33.406030 | 2014-06-06T10:30:12 | 2014-06-06T10:30:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,567 | cpp | // BEGIN CUT HERE
// END CUT HERE
#line 5 "MiningGoldEasy.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;
const int NM=60;
class MiningGoldEasy
{
public:
int dp[NM][NM][NM];
vector<int> vi,vj;
int n;
int N,M;
int calc(int x,int y,int cont)
{
if(cont==n) return 0;
int &res=dp[x][y][cont];
if(res!=-1) return res;
res=0;
int val=N+M-abs(vi[cont]-vi[x])-abs(vj[cont]-vj[y]);
//cout<<val<<endl;
for(int i=cont;i<n;i++)
res=max(res,calc(i,y,cont+1)+val);
for(int i=cont;i<n;i++)
res=max(res,calc(x,i,cont+1)+val);
return res;
}
int GetMaximumGold(int N, int M, vector <int> ei, vector <int> ej)
{
this->n=ei.size();
this->N=N;
this->M=M;
this->vi=ei;
this->vj=ej;
memset(dp,-1,sizeof(dp));
int res=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
res=max(res,calc(i,j,0));
}
}
return res;
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); if ((Case == -1) || (Case == 5)) test_case_5(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { int Arg0 = 2; int Arg1 = 2; int Arr2[] = {0}; vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); int Arr3[] = {0}; vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 4; verify_case(0, Arg4, GetMaximumGold(Arg0, Arg1, Arg2, Arg3)); }
void test_case_1() { int Arg0 = 2; int Arg1 = 2; int Arr2[] = {0, 2}; vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); int Arr3[] = {0, 1}; vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 7; verify_case(1, Arg4, GetMaximumGold(Arg0, Arg1, Arg2, Arg3)); }
void test_case_2() { int Arg0 = 3; int Arg1 = 3; int Arr2[] = {0, 3, 3}; vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); int Arr3[] = {0, 3, 0}; vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 15; verify_case(2, Arg4, GetMaximumGold(Arg0, Arg1, Arg2, Arg3)); }
void test_case_3() { int Arg0 = 3; int Arg1 = 4; int Arr2[] = {0, 3}; vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); int Arr3[] = {4, 1}; vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 11; verify_case(3, Arg4, GetMaximumGold(Arg0, Arg1, Arg2, Arg3)); }
void test_case_4() { int Arg0 = 5; int Arg1 = 6; int Arr2[] = {0, 4, 2, 5, 0}; vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); int Arr3[] = {3, 4, 5, 6, 0}; vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 48; verify_case(4, Arg4, GetMaximumGold(Arg0, Arg1, Arg2, Arg3)); }
void test_case_5() { int Arg0 = 557; int Arg1 = 919; int Arr2[] = {81, 509, 428, 6, 448, 149, 77, 142, 40, 405, 109, 247}; vector <int> Arg2(Arr2, Arr2 + (sizeof(Arr2) / sizeof(Arr2[0]))); int Arr3[] = {653, 887, 770, 477, 53, 637, 201, 863, 576, 393, 512, 243}; vector <int> Arg3(Arr3, Arr3 + (sizeof(Arr3) / sizeof(Arr3[0]))); int Arg4 = 16255; verify_case(5, Arg4, GetMaximumGold(Arg0, Arg1, Arg2, Arg3)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main()
{
MiningGoldEasy ___test;
___test.run_test(-1);
return 0;
}
// END CUT HERE
| [
"mengshangqi@gmail.com"
] | mengshangqi@gmail.com |
87c242f9872b9fa730d34383d6fec90cf5b63b63 | fb5b25b4fbe66c532672c14dacc520b96ff90a04 | /export/release/windows/obj/include/lime/ui/_KeyModifier/KeyModifier_Impl_.h | 489974855a812f65897153b9be2524003bc0ad0b | [
"Apache-2.0"
] | permissive | Tyrcnex/tai-mod | c3849f817fe871004ed171245d63c5e447c4a9c3 | b83152693bb3139ee2ae73002623934f07d35baf | refs/heads/main | 2023-08-15T07:15:43.884068 | 2021-09-29T23:39:23 | 2021-09-29T23:39:23 | 383,313,424 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,345 | h | #ifndef INCLUDED_lime_ui__KeyModifier_KeyModifier_Impl_
#define INCLUDED_lime_ui__KeyModifier_KeyModifier_Impl_
#ifndef HXCPP_H
#include <hxcpp.h>
#endif
HX_DECLARE_CLASS3(lime,ui,_KeyModifier,KeyModifier_Impl_)
namespace lime{
namespace ui{
namespace _KeyModifier{
class HXCPP_CLASS_ATTRIBUTES KeyModifier_Impl__obj : public ::hx::Object
{
public:
typedef ::hx::Object super;
typedef KeyModifier_Impl__obj OBJ_;
KeyModifier_Impl__obj();
public:
enum { _hx_ClassId = 0x220cb492 };
void __construct();
inline void *operator new(size_t inSize, bool inContainer=false,const char *inName="lime.ui._KeyModifier.KeyModifier_Impl_")
{ return ::hx::Object::operator new(inSize,inContainer,inName); }
inline void *operator new(size_t inSize, int extra)
{ return ::hx::Object::operator new(inSize+extra,false,"lime.ui._KeyModifier.KeyModifier_Impl_"); }
inline static ::hx::ObjectPtr< KeyModifier_Impl__obj > __new() {
::hx::ObjectPtr< KeyModifier_Impl__obj > __this = new KeyModifier_Impl__obj();
__this->__construct();
return __this;
}
inline static ::hx::ObjectPtr< KeyModifier_Impl__obj > __alloc(::hx::Ctx *_hx_ctx) {
KeyModifier_Impl__obj *__this = (KeyModifier_Impl__obj*)(::hx::Ctx::alloc(_hx_ctx, sizeof(KeyModifier_Impl__obj), false, "lime.ui._KeyModifier.KeyModifier_Impl_"));
*(void **)__this = KeyModifier_Impl__obj::_hx_vtable;
return __this;
}
static void * _hx_vtable;
static Dynamic __CreateEmpty();
static Dynamic __Create(::hx::DynamicArray inArgs);
//~KeyModifier_Impl__obj();
HX_DO_RTTI_ALL;
static bool __GetStatic(const ::String &inString, Dynamic &outValue, ::hx::PropertyAccess inCallProp);
static void __register();
bool _hx_isInstanceOf(int inClassId);
::String __ToString() const { return HX_("KeyModifier_Impl_",16,89,a5,39); }
static void __boot();
static int NONE;
static int LEFT_SHIFT;
static int RIGHT_SHIFT;
static int LEFT_CTRL;
static int RIGHT_CTRL;
static int LEFT_ALT;
static int RIGHT_ALT;
static int LEFT_META;
static int RIGHT_META;
static int NUM_LOCK;
static int CAPS_LOCK;
static int MODE;
static int CTRL;
static int SHIFT;
static int ALT;
static int META;
static bool get_altKey(int this1);
static ::Dynamic get_altKey_dyn();
static bool set_altKey(int this1,bool value);
static ::Dynamic set_altKey_dyn();
static bool get_capsLock(int this1);
static ::Dynamic get_capsLock_dyn();
static bool set_capsLock(int this1,bool value);
static ::Dynamic set_capsLock_dyn();
static bool get_ctrlKey(int this1);
static ::Dynamic get_ctrlKey_dyn();
static bool set_ctrlKey(int this1,bool value);
static ::Dynamic set_ctrlKey_dyn();
static bool get_metaKey(int this1);
static ::Dynamic get_metaKey_dyn();
static bool set_metaKey(int this1,bool value);
static ::Dynamic set_metaKey_dyn();
static bool get_numLock(int this1);
static ::Dynamic get_numLock_dyn();
static bool set_numLock(int this1,bool value);
static ::Dynamic set_numLock_dyn();
static bool get_shiftKey(int this1);
static ::Dynamic get_shiftKey_dyn();
static bool set_shiftKey(int this1,bool value);
static ::Dynamic set_shiftKey_dyn();
};
} // end namespace lime
} // end namespace ui
} // end namespace _KeyModifier
#endif /* INCLUDED_lime_ui__KeyModifier_KeyModifier_Impl_ */
| [
"72734817+khiodev@users.noreply.github.com"
] | 72734817+khiodev@users.noreply.github.com |
e60d5c2d69be59c9025541a50315f4a291f519d0 | 76859f325589b72fbb1c4bf8678505cf64a62334 | /src/tools/res_packer/cdata_packer.hpp | 566b1c3a078bd0ff7c714975bb1e3188f74fb17a | [] | no_license | yf885188/BigWorld-Engine-1.9.1 | 267d3d24c29e414308143d3b2440cd4255ec4557 | e9d5a56739eb20c0c6973653a1342000e9f699be | refs/heads/master | 2023-08-29T17:12:16.985405 | 2021-11-18T06:41:31 | 2021-11-18T06:41:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,114 | hpp | /******************************************************************************
BigWorld Technology
Copyright BigWorld Pty, Ltd.
All Rights Reserved. Commercial in confidence.
WARNING: This computer program is protected by copyright law and international
treaties. Unauthorized use, reproduction or distribution of this program, or
any portion of this program, may result in the imposition of civil and
criminal penalties as provided by law.
******************************************************************************/
#ifndef __CDATA_PACKER_HPP__
#define __CDATA_PACKER_HPP__
#include "base_packer.hpp"
/**
* This class strips the .cdata files of unwanted data. In the client, it
* removes navmesh and thumbnail sections, and in the server only the
* thumbnail section.
*/
class CDataPacker : public BasePacker
{
public:
virtual bool prepare( const std::string& src, const std::string& dst );
virtual bool print();
virtual bool pack();
static void addStripSection( const char * sectionName );
private:
DECLARE_PACKER()
std::string src_;
std::string dst_;
};
#endif // __CDATA_PACKER_HPP__
| [
"terran.erre@mail.ru"
] | terran.erre@mail.ru |
f978f0278192bb4decaf2d57117978598262262f | 981373992bcebffc7f11c96d3c3d36043bd272e4 | /Parser.hpp | fef6d83e38cb9c74ae14475b0b4d54822ae22793 | [] | no_license | EvgenyGi/Commands | a7a2a306491bab63b74dd78dbcca2db98b874cc9 | aa0b014df87392c2b91a4312f8ee4eb7d9453600 | refs/heads/main | 2023-01-19T04:11:42.885706 | 2020-11-19T16:24:06 | 2020-11-19T16:24:12 | 312,018,728 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 234 | hpp | #include <iostream>
#include <string>
#include <vector>
class Parser
{
private:
std::vector <std::string> tokens;
Parser(std::string enter_string ,std::vector <std::string> vector_string)
{
}
};
| [
"Evgeny.gesis@gmail.com"
] | Evgeny.gesis@gmail.com |
08e62f1a95ae16e94424b49dd77de7fc50801c28 | 0f255b6f67152bfb7e499918d3c649e079576c3e | /src/obfuscation.h | 7e9711ac93470fdd7d000e19e218b7404d1577f5 | [
"MIT"
] | permissive | PierreShark/BitBlocks | f216ce70cea5c46351a01380effb1910fa16c82c | 4be04f939a51c8dad2695cc2828ef88f93946798 | refs/heads/master | 2020-04-07T22:26:11.419331 | 2018-11-22T02:53:19 | 2018-11-22T02:53:19 | 158,770,043 | 1 | 0 | MIT | 2018-11-23T02:18:23 | 2018-11-23T02:18:23 | null | UTF-8 | C++ | false | false | 16,049 | h | // Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2018 LightPayCoin developers
// Copyright (c) 2018 The BitBlocks developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef OBFUSCATION_H
#define OBFUSCATION_H
#include "main.h"
#include "masternode-payments.h"
#include "masternode-sync.h"
#include "masternodeman.h"
#include "obfuscation-relay.h"
#include "sync.h"
class CTxIn;
class CObfuscationPool;
class CObfuScationSigner;
class CMasterNodeVote;
class CBitcoinAddress;
class CObfuscationQueue;
class CObfuscationBroadcastTx;
class CActiveMasternode;
// pool states for mixing
#define POOL_STATUS_UNKNOWN 0 // waiting for update
#define POOL_STATUS_IDLE 1 // waiting for update
#define POOL_STATUS_QUEUE 2 // waiting in a queue
#define POOL_STATUS_ACCEPTING_ENTRIES 3 // accepting entries
#define POOL_STATUS_FINALIZE_TRANSACTION 4 // master node will broadcast what it accepted
#define POOL_STATUS_SIGNING 5 // check inputs/outputs, sign final tx
#define POOL_STATUS_TRANSMISSION 6 // transmit transaction
#define POOL_STATUS_ERROR 7 // error
#define POOL_STATUS_SUCCESS 8 // success
// status update message constants
#define MASTERNODE_ACCEPTED 1
#define MASTERNODE_REJECTED 0
#define MASTERNODE_RESET -1
#define OBFUSCATION_QUEUE_TIMEOUT 30
#define OBFUSCATION_SIGNING_TIMEOUT 15
// used for anonymous relaying of inputs/outputs/sigs
#define OBFUSCATION_RELAY_IN 1
#define OBFUSCATION_RELAY_OUT 2
#define OBFUSCATION_RELAY_SIG 3
static const CAmount OBFUSCATION_COLLATERAL = (10 * COIN);
static const CAmount OBFUSCATION_POOL_MAX = (99999.99 * COIN);
extern CObfuscationPool obfuScationPool;
extern CObfuScationSigner obfuScationSigner;
extern std::vector<CObfuscationQueue> vecObfuscationQueue;
extern std::string strMasterNodePrivKey;
extern map<uint256, CObfuscationBroadcastTx> mapObfuscationBroadcastTxes;
extern CActiveMasternode activeMasternode;
/** Holds an Obfuscation input
*/
class CTxDSIn : public CTxIn
{
public:
bool fHasSig; // flag to indicate if signed
int nSentTimes; //times we've sent this anonymously
CTxDSIn(const CTxIn& in)
{
prevout = in.prevout;
scriptSig = in.scriptSig;
prevPubKey = in.prevPubKey;
nSequence = in.nSequence;
nSentTimes = 0;
fHasSig = false;
}
};
/** Holds an Obfuscation output
*/
class CTxDSOut : public CTxOut
{
public:
int nSentTimes; //times we've sent this anonymously
CTxDSOut(const CTxOut& out)
{
nValue = out.nValue;
nRounds = out.nRounds;
scriptPubKey = out.scriptPubKey;
nSentTimes = 0;
}
};
// A clients transaction in the obfuscation pool
class CObfuScationEntry
{
public:
bool isSet;
std::vector<CTxDSIn> sev;
std::vector<CTxDSOut> vout;
CAmount amount;
CTransaction collateral;
CTransaction txSupporting;
int64_t addedTime; // time in UTC milliseconds
CObfuScationEntry()
{
isSet = false;
collateral = CTransaction();
amount = 0;
}
/// Add entries to use for Obfuscation
bool Add(const std::vector<CTxIn> vinIn, int64_t amountIn, const CTransaction collateralIn, const std::vector<CTxOut> voutIn)
{
if (isSet) {
return false;
}
BOOST_FOREACH (const CTxIn& in, vinIn)
sev.push_back(in);
BOOST_FOREACH (const CTxOut& out, voutIn)
vout.push_back(out);
amount = amountIn;
collateral = collateralIn;
isSet = true;
addedTime = GetTime();
return true;
}
bool AddSig(const CTxIn& vin)
{
BOOST_FOREACH (CTxDSIn& s, sev) {
if (s.prevout == vin.prevout && s.nSequence == vin.nSequence) {
if (s.fHasSig) {
return false;
}
s.scriptSig = vin.scriptSig;
s.prevPubKey = vin.prevPubKey;
s.fHasSig = true;
return true;
}
}
return false;
}
bool IsExpired()
{
return (GetTime() - addedTime) > OBFUSCATION_QUEUE_TIMEOUT; // 120 seconds
}
};
/**
* A currently inprogress Obfuscation merge and denomination information
*/
class CObfuscationQueue
{
public:
CTxIn vin;
int64_t time;
int nDenom;
bool ready; //ready for submit
std::vector<unsigned char> vchSig;
CObfuscationQueue()
{
nDenom = 0;
vin = CTxIn();
time = 0;
vchSig.clear();
ready = false;
}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{
READWRITE(nDenom);
READWRITE(vin);
READWRITE(time);
READWRITE(ready);
READWRITE(vchSig);
}
bool GetAddress(CService& addr)
{
CMasternode* pmn = mnodeman.Find(vin);
if (pmn != NULL) {
addr = pmn->addr;
return true;
}
return false;
}
/// Get the protocol version
bool GetProtocolVersion(int& protocolVersion)
{
CMasternode* pmn = mnodeman.Find(vin);
if (pmn != NULL) {
protocolVersion = pmn->protocolVersion;
return true;
}
return false;
}
/** Sign this Obfuscation transaction
* \return true if all conditions are met:
* 1) we have an active Masternode,
* 2) we have a valid Masternode private key,
* 3) we signed the message successfully, and
* 4) we verified the message successfully
*/
bool Sign();
bool Relay();
/// Is this Obfuscation expired?
bool IsExpired()
{
return (GetTime() - time) > OBFUSCATION_QUEUE_TIMEOUT; // 120 seconds
}
/// Check if we have a valid Masternode address
bool CheckSignature();
};
/** Helper class to store Obfuscation transaction (tx) information.
*/
class CObfuscationBroadcastTx
{
public:
CTransaction tx;
CTxIn vin;
vector<unsigned char> vchSig;
int64_t sigTime;
};
/** Helper object for signing and checking signatures
*/
class CObfuScationSigner
{
public:
/// Is the inputs associated with this public key? (and there is 10000 BBK - checking if valid masternode)
bool IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey);
/// Set the private/public key values, returns true if successful
bool GetKeysFromSecret(std::string strSecret, CKey& keyRet, CPubKey& pubkeyRet);
/// Set the private/public key values, returns true if successful
bool SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey);
/// Sign the message, returns true if successful
bool SignMessage(std::string strMessage, std::string& errorMessage, std::vector<unsigned char>& vchSig, CKey key);
/// Verify the message, returns true if succcessful
bool VerifyMessage(CPubKey pubkey, std::vector<unsigned char>& vchSig, std::string strMessage, std::string& errorMessage);
};
/** Used to keep track of current status of Obfuscation pool
*/
class CObfuscationPool
{
private:
mutable CCriticalSection cs_obfuscation;
std::vector<CObfuScationEntry> entries; // Masternode/clients entries
CMutableTransaction finalTransaction; // the finalized transaction ready for signing
int64_t lastTimeChanged; // last time the 'state' changed, in UTC milliseconds
unsigned int state; // should be one of the POOL_STATUS_XXX values
unsigned int entriesCount;
unsigned int lastEntryAccepted;
unsigned int countEntriesAccepted;
std::vector<CTxIn> lockedCoins;
std::string lastMessage;
bool unitTest;
int sessionID;
int sessionUsers; //N Users have said they'll join
bool sessionFoundMasternode; //If we've found a compatible Masternode
std::vector<CTransaction> vecSessionCollateral;
int cachedLastSuccess;
int minBlockSpacing; //required blocks between mixes
CMutableTransaction txCollateral;
int64_t lastNewBlock;
//debugging data
std::string strAutoDenomResult;
public:
enum messages {
ERR_ALREADY_HAVE,
ERR_DENOM,
ERR_ENTRIES_FULL,
ERR_EXISTING_TX,
ERR_FEES,
ERR_INVALID_COLLATERAL,
ERR_INVALID_INPUT,
ERR_INVALID_SCRIPT,
ERR_INVALID_TX,
ERR_MAXIMUM,
ERR_MN_LIST,
ERR_MODE,
ERR_NON_STANDARD_PUBKEY,
ERR_NOT_A_MN,
ERR_QUEUE_FULL,
ERR_RECENT,
ERR_SESSION,
ERR_MISSING_TX,
ERR_VERSION,
MSG_NOERR,
MSG_SUCCESS,
MSG_ENTRIES_ADDED
};
// where collateral should be made out to
CScript collateralPubKey;
CMasternode* pSubmittedToMasternode;
int sessionDenom; //Users must submit an denom matching this
int cachedNumBlocks; //used for the overview screen
CObfuscationPool()
{
/* Obfuscation uses collateral addresses to trust parties entering the pool
to behave themselves. If they don't it takes their money. */
cachedLastSuccess = 0;
cachedNumBlocks = std::numeric_limits<int>::max();
unitTest = false;
txCollateral = CMutableTransaction();
minBlockSpacing = 0;
lastNewBlock = 0;
SetNull();
}
/** Process a Obfuscation message using the Obfuscation protocol
* \param pfrom
* \param strCommand lower case command string; valid values are:
* Command | Description
* -------- | -----------------
* dsa | Obfuscation Acceptable
* dsc | Obfuscation Complete
* dsf | Obfuscation Final tx
* dsi | Obfuscation vIn
* dsq | Obfuscation Queue
* dss | Obfuscation Signal Final Tx
* dssu | Obfuscation status update
* dssub | Obfuscation Subscribe To
* \param vRecv
*/
void ProcessMessageObfuscation(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
void InitCollateralAddress()
{
SetCollateralAddress(Params().ObfuscationPoolDummyAddress());
}
void SetMinBlockSpacing(int minBlockSpacingIn)
{
minBlockSpacing = minBlockSpacingIn;
}
bool SetCollateralAddress(std::string strAddress);
void Reset();
void SetNull();
void UnlockCoins();
bool IsNull() const
{
return state == POOL_STATUS_ACCEPTING_ENTRIES && entries.empty();
}
int GetState() const
{
return state;
}
std::string GetStatus();
int GetEntriesCount() const
{
return entries.size();
}
/// Get the time the last entry was accepted (time in UTC milliseconds)
int GetLastEntryAccepted() const
{
return lastEntryAccepted;
}
/// Get the count of the accepted entries
int GetCountEntriesAccepted() const
{
return countEntriesAccepted;
}
// Set the 'state' value, with some logging and capturing when the state changed
void UpdateState(unsigned int newState)
{
if (fMasterNode && (newState == POOL_STATUS_ERROR || newState == POOL_STATUS_SUCCESS)) {
LogPrint("obfuscation", "CObfuscationPool::UpdateState() - Can't set state to ERROR or SUCCESS as a Masternode. \n");
return;
}
LogPrintf("CObfuscationPool::UpdateState() == %d | %d \n", state, newState);
if (state != newState) {
lastTimeChanged = GetTimeMillis();
if (fMasterNode) {
RelayStatus(obfuScationPool.sessionID, obfuScationPool.GetState(), obfuScationPool.GetEntriesCount(), MASTERNODE_RESET);
}
}
state = newState;
}
/// Get the maximum number of transactions for the pool
int GetMaxPoolTransactions()
{
return Params().PoolMaxTransactions();
}
/// Do we have enough users to take entries?
bool IsSessionReady()
{
return sessionUsers >= GetMaxPoolTransactions();
}
/// Are these outputs compatible with other client in the pool?
bool IsCompatibleWithEntries(std::vector<CTxOut>& vout);
/// Is this amount compatible with other client in the pool?
bool IsCompatibleWithSession(CAmount nAmount, CTransaction txCollateral, int& errorID);
/// Passively run Obfuscation in the background according to the configuration in settings (only for QT)
bool DoAutomaticDenominating(bool fDryRun = false);
bool PrepareObfuscationDenominate();
/// Check for process in Obfuscation
void Check();
void CheckFinalTransaction();
/// Charge fees to bad actors (Charge clients a fee if they're abusive)
void ChargeFees();
/// Rarely charge fees to pay miners
void ChargeRandomFees();
void CheckTimeout();
void CheckForCompleteQueue();
/// Check to make sure a signature matches an input in the pool
bool SignatureValid(const CScript& newSig, const CTxIn& newVin);
/// If the collateral is valid given by a client
bool IsCollateralValid(const CTransaction& txCollateral);
/// Add a clients entry to the pool
bool AddEntry(const std::vector<CTxIn>& newInput, const CAmount& nAmount, const CTransaction& txCollateral, const std::vector<CTxOut>& newOutput, int& errorID);
/// Add signature to a vin
bool AddScriptSig(const CTxIn& newVin);
/// Check that all inputs are signed. (Are all inputs signed?)
bool SignaturesComplete();
/// As a client, send a transaction to a Masternode to start the denomination process
void SendObfuscationDenominate(std::vector<CTxIn>& vin, std::vector<CTxOut>& vout, CAmount amount);
/// Get Masternode updates about the progress of Obfuscation
bool StatusUpdate(int newState, int newEntriesCount, int newAccepted, int& errorID, int newSessionID = 0);
/// As a client, check and sign the final transaction
bool SignFinalTransaction(CTransaction& finalTransactionNew, CNode* node);
/// Get the last valid block hash for a given modulus
bool GetLastValidBlockHash(uint256& hash, int mod = 1, int nBlockHeight = 0);
/// Process a new block
void NewBlock();
void CompletedTransaction(bool error, int errorID);
void ClearLastMessage();
/// Used for liquidity providers
bool SendRandomPaymentToSelf();
/// Split up large inputs or make fee sized inputs
bool MakeCollateralAmounts();
bool CreateDenominated(CAmount nTotalValue);
/// Get the denominations for a list of outputs (returns a bitshifted integer)
int GetDenominations(const std::vector<CTxOut>& vout, bool fSingleRandomDenom = false);
int GetDenominations(const std::vector<CTxDSOut>& vout);
void GetDenominationsToString(int nDenom, std::string& strDenom);
/// Get the denominations for a specific amount of bitblocks.
int GetDenominationsByAmount(CAmount nAmount, int nDenomTarget = 0); // is not used anymore?
int GetDenominationsByAmounts(std::vector<CAmount>& vecAmount);
std::string GetMessageByID(int messageID);
//
// Relay Obfuscation Messages
//
void RelayFinalTransaction(const int sessionID, const CTransaction& txNew);
void RelaySignaturesAnon(std::vector<CTxIn>& vin);
void RelayInAnon(std::vector<CTxIn>& vin, std::vector<CTxOut>& vout);
void RelayIn(const std::vector<CTxDSIn>& vin, const CAmount& nAmount, const CTransaction& txCollateral, const std::vector<CTxDSOut>& vout);
void RelayStatus(const int sessionID, const int newState, const int newEntriesCount, const int newAccepted, const int errorID = MSG_NOERR);
void RelayCompletedTransaction(const int sessionID, const bool error, const int errorID);
};
void ThreadCheckObfuScationPool();
#endif
| [
"Bitblocksproject@gmail.com"
] | Bitblocksproject@gmail.com |
fd988f7ab70a871bca40863119cc8438a274ebf7 | f14436cc5186ee7ca502092642e06fd765044e11 | /src/test.cpp | 0f5ff55e57b99a157f9c860dba747e00f680518f | [] | no_license | sriramsr/dating | 39b4072c6756d29e3a1a60e75dcb2bf2f5621b58 | 1e0d1076298a826af13bf09872445a7e6f82aeb9 | refs/heads/master | 2023-01-09T06:39:11.980469 | 2016-04-21T00:25:19 | 2016-04-21T00:25:19 | 56,657,556 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 389 | cpp | #include "std.h"
#include "functions.h"
#include "data.h"
#include "io.h"
#include "fileio.h"
#include "stringfn.h"
#include "mathfn.h"
#include "snpmap.h"
#include "manip.h"
int main(int argc, char *argv[])
{
unordered_map<string, string > *pmapsnps = NULL;
pmapsnps = new unordered_map <string, string> ();
string s (argv[1]);
fileio::read_map (s, pmapsnps, 0 , 1);
}
| [
"sriram.sankararaman@gmail.com"
] | sriram.sankararaman@gmail.com |
c987b00666bd4875ddb6cb32553cc8e68fff846f | 8535e1318c84fcebe27601c50ca6a476291fd3e3 | /PaymentTerminal/stdafx.cpp | 1a0a3475f256dc95fbbfa2f4883322a6cd89121b | [] | no_license | PNjunctionShi/PaymentTerminal | dccc58df5dcf869c2f124955705b263f49ff4e20 | 31fd44b18ad750ed8e44546da72413a3fcf96a22 | refs/heads/master | 2021-01-20T00:34:59.109048 | 2017-06-11T15:28:53 | 2017-06-11T15:28:53 | 89,154,943 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 683 | cpp | // 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面
// (“Fluent UI”)。该示例仅供参考,
// 用以补充《Microsoft 基础类参考》和
// MFC C++ 库软件随附的相关电子文档。
// 复制、使用或分发 Fluent UI 的许可条款是单独提供的。
// 若要了解有关 Fluent UI 许可计划的详细信息,请访问
// http://go.microsoft.com/fwlink/?LinkId=238214。
//
// 版权所有(C) Microsoft Corporation
// 保留所有权利。
// stdafx.cpp : 只包括标准包含文件的源文件
// PaymentTerminal.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
| [
"912561600@qq.com"
] | 912561600@qq.com |
a78ff6d7d9fb64252bc830990373433aabffe0ef | 1125278516c9ee1adf6c37eb6a9076b73dc17190 | /smacc_sm_reference_library/sm_pr2_plugs/include/sm_pr2_plugs/sm_pr2_plugs.h | f1b6898f34d51ea8b8546864b85bcd9de4d88eb5 | [
"BSD-3-Clause"
] | permissive | Shashika007/SMACC | 398f485d518a1d7ba5ea8125ae3998aa8af39137 | 224ea746f68ae865ab318a90b14c1292538c0b79 | refs/heads/master | 2021-01-04T09:19:03.327662 | 2020-02-13T23:09:31 | 2020-02-13T23:09:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,260 | h | #pragma once
#include <ros/ros.h>
#include <smacc/smacc.h>
// CLIENTS
#include <ros_timer_client/cl_ros_timer.h>
#include <keyboard_client/cl_keyboard.h>
// ORTHOGONALS
#include <sm_pr2_plugs/orthogonals/or_timer.h>
#include <sm_pr2_plugs/orthogonals/or_keyboard.h>
using namespace ros_timer_client;
using namespace keyboard_client;
//CLIENT BEHAVIORS
#include <keyboard_client/client_behaviors/cb_default_keyboard_behavior.h>
#include <ros_timer_client/client_behaviors/cb_ros_timer.h>
#include <ros_timer_client/client_behaviors/cb_timer_countdown_once.h>
using namespace smacc;
using namespace ros_timer_client;
using namespace smacc::default_events;
namespace sm_pr2_plugs{
//STATES
class StFailTuckArms;
class StFailUntuck;
class StFailLowerSpine;
class StSucceedFreeBase;
class StSucceedTuck;
class StStowPlug;
class StPullBackFromWall;
class StWiggleOut;
class StClearLeftArm;
class StCloseGripper;
class StRecoverStowPlug;
class StStowLeftArm;
class StFailOpenGripper;
class StPlugIn;
class StFetchPlug;
class StNavigate;
class StGetOutletLocations;
class StSafetyTuck;
class StUntuckAtOutlet;
class StGoalIsLocal;
class StFailStillUnplugged;
class StProcessRechargeCommand;
class StNavigateToOutlet;
class StUnplug;
class StDetectOutlet;
class MsRecharge;
class MsUnplug;
// struct EvToDeep : sc::event<EvToDeep>{};
// struct EvFail : sc::event<EvFail>{};
// struct EvEStop : sc::event<EvEStop>{};
// STATE MACHINE
struct SmPR2Plugs : public smacc::SmaccStateMachineBase<SmPR2Plugs, MsRecharge>
{
using SmaccStateMachineBase::SmaccStateMachineBase;
virtual void onInitialize() override
{
this->createOrthogonal<OrTimer>();
// this->createOrthogonal<OrUpdatablePublisher>();
this->createOrthogonal<OrKeyboard>();
// this->createOrthogonal<OrSubscriber>();
}
};
} // namespace sm_pr2_plugs
// MODE STATES
#include <sm_pr2_plugs/mode_states/ms_recharge.h>
#include <sm_pr2_plugs/mode_states/ms_unplug.h>
//STATES
#include <sm_pr2_plugs/states/st_fail_tuck_arms.h>
#include <sm_pr2_plugs/states/st_fail_untuck.h>
#include <sm_pr2_plugs/states/st_fail_lower_spine.h>
#include <sm_pr2_plugs/states/st_succeed_free_base.h>
#include <sm_pr2_plugs/states/st_succeed_tuck.h>
#include <sm_pr2_plugs/states/st_stow_plug.h>
#include <sm_pr2_plugs/states/st_pull_back_from_wall.h>
#include <sm_pr2_plugs/states/st_wiggle_out.h>
#include <sm_pr2_plugs/states/st_clear_left_arm.h>
#include <sm_pr2_plugs/states/st_close_gripper.h>
#include <sm_pr2_plugs/states/st_recover_stow_plug.h>
#include <sm_pr2_plugs/states/st_stow_left_arm.h>
#include <sm_pr2_plugs/states/st_fail_open_gripper.h>
#include <sm_pr2_plugs/states/st_plug_in.h>
#include <sm_pr2_plugs/states/st_fetch_plug.h>
#include <sm_pr2_plugs/states/st_navigate.h>
#include <sm_pr2_plugs/states/st_get_outlet_locations.h>
#include <sm_pr2_plugs/states/st_safety_tuck.h>
#include <sm_pr2_plugs/states/st_untuck_at_outlet.h>
#include <sm_pr2_plugs/states/st_goal_is_local.h>
#include <sm_pr2_plugs/states/st_fail_still_unplugged.h>
#include <sm_pr2_plugs/states/st_process_recharge_command.h>
#include <sm_pr2_plugs/states/st_navigate_to_outlet.h>
#include <sm_pr2_plugs/states/st_unplug.h>
#include <sm_pr2_plugs/states/st_detect_outlet.h>
| [
"brett@reelrobotics.com"
] | brett@reelrobotics.com |
e9f73ab2cf97ab58862972d065cc0aa411e44b62 | f1585cb4b3bdfb507bd40f52800e163831bfc7da | /NRF_ER_Receiving_Code/NRF_ER_Receiving_Code.ino | c11ee396c37e40b529ccfd449151dc14360eecba | [] | no_license | rsgc-canavan-s/NRF_ER_Code | f11be5d95d21eaac03f2911594763d2a401a16b0 | c6d0975ed9123e5089dc913c2183bdff21b4ec54 | refs/heads/master | 2020-05-21T07:40:33.417314 | 2017-03-10T20:23:30 | 2017-03-10T20:23:30 | 84,597,860 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 770 | ino | #include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <LiquidCrystal.h>
uint8_t inputCharacter;
byte addresses[][6] = {"Node1", "Node2"};
RF24 radio(7, 8);
uint32_t recieved[16];
LiquidCrystal lcd (8, 9, 10, 11, 12, 13);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
radio.begin();
radio.setPALevel(RF24_PA_LOW);
radio.setChannel(110);
radio.openWritingPipe(addresses[1]);
radio.openReadingPipe(16, addresses[0]);
radio.startListening();
}
void loop() {
// put your main code here, to run repeatedly:
while (radio.available()) {
radio.read( &recieved, sizeof(recieved));
}
for (int i = 0; i < 16; i++) {
lcd.setCursor(1, 0);
lcd.print(recieved[i]);
}
}
| [
"scanavan@rsgc.on.ca"
] | scanavan@rsgc.on.ca |
2e71a5e912881a1b7a8088ad66bba748b772f171 | f338eb32c45d8d5d002a84798a7df7bb0403b3c4 | /FastSimulation/EgammaElectronAlgos/src/FastPixelHitMatcher.h | 88cb74a41b3348b3c70f73e9a3576a74dda2a5cf | [] | permissive | wouf/cmssw | 0a8a8016e6bebc611f1277379e12bef130464afb | 60da16aec83a0fc016cca9e2a5ed0768ba3b161c | refs/heads/CMSSW_7_3_X | 2022-06-30T04:35:45.380754 | 2015-05-08T17:40:17 | 2015-05-08T17:40:17 | 463,028,972 | 0 | 0 | Apache-2.0 | 2022-02-24T06:05:30 | 2022-02-24T06:05:26 | null | UTF-8 | C++ | false | false | 3,342 | h | #ifndef FastPixelHitMatcher_H
#define FastPixelHitMatcher_H
// -*- C++ -*-
//
// Package: EgammaElectronAlgos
// Class: FastPixelHitMatcher
//
/**\class FastPixelHitMatcher EgammaElectronAlgos/FastPixelHitMatcher
Description: Class to match an ECAL cluster to the pixel hits.
Two compatible hits in the pixel layers are required.
Implementation:
future redesign
*/
//
// Original Author: Patrick Janot.
//
//
#include "TrackingTools/TransientTrackingRecHit/interface/GenericTransientTrackingRecHit.h"
#include <vector>
/** Class to match an ECAL cluster to the pixel hits.
* Two compatible hits in the pixel layers are required.
*/
class TrackerGeometry;
class GeometricSearchTracker;
class TrackerInteractionGeometry;
class TrackerLayer;
class TrackerRecHit;
class TrackingRecHit;
class ParticlePropagator;
class MagneticFieldMap;
class FastPixelHitMatcher{
public:
//RC
typedef TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer;
typedef TransientTrackingRecHit::RecHitPointer RecHitPointer;
typedef TransientTrackingRecHit::RecHitContainer RecHitContainer;
FastPixelHitMatcher(float,float,float,float,float,float,float,float,float,float,float,float,bool);
virtual ~FastPixelHitMatcher();
void setES(const MagneticFieldMap* aFieldMap,
const TrackerGeometry* aTrackerGeometry,
const GeometricSearchTracker* geomSearchTracker,
const TrackerInteractionGeometry* interactionGeometry);
std::vector< std::pair<ConstRecHitPointer,ConstRecHitPointer> >
compatibleHits(const GlobalPoint& xmeas,
const GlobalPoint& vprim,
float energy,
std::vector<TrackerRecHit>& theHits);
inline double getVertex() { return vertex; }
void set1stLayer (float ephimin, float ephimax,
float pphimin, float pphimax) {
ephi1min = ephimin;
ephi1max = ephimax;
pphi1min = pphimin;
pphi1max = pphimax;
}
void set2ndLayer (float phimin, float phimax) {
phi2min = phimin;
phi2max = phimax;
}
bool isASeed(const ParticlePropagator& myElec,
const ParticlePropagator& myPosi,
const GlobalPoint& theVertex,
double rCluster,
double zCluster,
const TrackerRecHit& hit1,
const TrackerRecHit& hit2);
bool propagateToLayer(ParticlePropagator& myPart,
const GlobalPoint& theVertex,
GlobalPoint& theHit,
double phimin,
double phimax,
unsigned layer);
double zVertex(double zCluster,
double rCluster,
GlobalPoint& theHit);
bool checkRZCompatibility(double zCluster,double rCluster,
double zVertex,
float rzMin, float rzMax,
GlobalPoint& theHit,
bool forward);
void set1stLayerZRange(double zmin1, double zmax1) {
z1max = zmax1;
z1min = zmin1;
}
private:
RecHitContainer hitsInTrack;
float ephi1min, ephi1max;
float pphi1min, pphi1max;
float phi2min, phi2max;
float z1min, z1max;
float z2minB, z2maxB;
float r2minF, r2maxF;
float rMinI, rMaxI;
bool searchInTIDTEC;
const TrackerGeometry* theTrackerGeometry;
const MagneticField* theMagneticField;
const GeometricSearchTracker* theGeomSearchTracker;
const TrackerInteractionGeometry* _theGeometry;
const MagneticFieldMap* theFieldMap;
std::vector<const TrackerLayer*> thePixelLayers;
double vertex;
};
#endif
| [
"giulio.eulisse@gmail.com"
] | giulio.eulisse@gmail.com |
5e831ce6e4e0a69c3da1c05b157cc7ddfed0286a | e213a99049af2297ed455c10de07adb0199964fc | /Sources/Particles/Particle.cpp | 95579a4ade5457def81f8cc29ce32e05425fab22 | [
"MIT"
] | permissive | firedtoad/Acid | aab0541804b38775c620529b0157d61866de90d5 | ba6f1340206cd138ad4d30ac3e1a7c58af5b0c8e | refs/heads/master | 2020-04-26T19:25:54.908370 | 2019-03-02T03:08:07 | 2019-03-02T03:08:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,363 | cpp | #include "Particle.hpp"
#include <utility>
#include "Scenes/Scenes.hpp"
namespace acid
{
static const float FADE_TIME = 1.0f;
Particle::Particle(std::shared_ptr<ParticleType> particleType, const Vector3 &position, const Vector3 &velocity, const float &lifeLength,
const float &stageCycles, const float &rotation, const float &scale, const float &gravityEffect) :
m_particleType(std::move(particleType)),
m_position(position),
m_velocity(velocity),
m_lifeLength(lifeLength),
m_stageCycles(stageCycles),
m_rotation(rotation),
m_scale(scale),
m_gravityEffect(gravityEffect),
m_elapsedTime(0.0f),
m_transparency(1.0f),
m_textureBlendFactor(0.0f),
m_distanceToCamera(0.0f)
{
}
void Particle::Update()
{
float delta = Engine::Get()->GetDelta().AsSeconds();
m_velocity.m_y += -10.0f * m_gravityEffect * delta;
m_change = m_velocity;
m_change *= delta;
m_position += m_change;
m_elapsedTime += delta;
if (m_elapsedTime > m_lifeLength - FADE_TIME)
{
m_transparency -= delta / FADE_TIME;
}
if (!IsAlive() || Scenes::Get()->GetCamera() == nullptr)
{
return;
}
Vector3 cameraToParticle = Scenes::Get()->GetCamera()->GetPosition() - m_position;
m_distanceToCamera = cameraToParticle.LengthSquared();
float lifeFactor = m_stageCycles * m_elapsedTime / m_lifeLength;
if (m_particleType->GetTexture() == nullptr)
{
return;
}
auto stageCount = static_cast<int32_t>(pow(m_particleType->GetNumberOfRows(), 2));
float atlasProgression = lifeFactor * stageCount;
auto index1 = static_cast<int32_t>(std::floor(atlasProgression));
int32_t index2 = index1 < stageCount - 1 ? index1 + 1 : index1;
m_textureBlendFactor = std::fmod(atlasProgression, 1.0f);
m_textureOffset1 = CalculateTextureOffset(index1);
m_textureOffset2 = CalculateTextureOffset(index2);
}
bool Particle::operator<(const Particle &other) const
{
return m_distanceToCamera > other.m_distanceToCamera;
}
Vector2 Particle::CalculateTextureOffset(const int32_t &index) const
{
int32_t column = index % m_particleType->GetNumberOfRows();
int32_t row = index / m_particleType->GetNumberOfRows();
Vector2 result = Vector2();
result.m_x = static_cast<float>(column) / m_particleType->GetNumberOfRows();
result.m_y = static_cast<float>(row) / m_particleType->GetNumberOfRows();
return result;
}
}
| [
"mattparks5855@gmail.com"
] | mattparks5855@gmail.com |
bfb21a959c83a898c405779a8958cac3372c695c | d66f97dc47e97ef476278f93bacb3953957003f7 | /main.cpp | c7dc833aedf3b67238a1116bf1abdb4aac711b6d | [] | no_license | tfursten/Disk | 380e47d33d69950cbe04fce5321012cf11320627 | b1122c4c9c6e9d56c1a16a6ffcad91ac9f508375 | refs/heads/master | 2021-01-10T20:43:09.042611 | 2017-04-17T20:14:24 | 2017-04-17T20:14:24 | 21,591,412 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 583 | cpp | #include <iostream>
#include "disk.h"
#include "xorshift64.h"
#include <fstream>
#include <string>
using namespace std;
int main()
{
Disk d;
float sigma;
cout << "Sigma: ";
cin >> sigma;
ofstream myfile;
myfile.open("sigma"+to_string(sigma)+".txt");
d.initialize(2*sigma);
d.makeTables();
d.printTables();
xorshift64 myrand;
myrand.seed();
for(int i = 0; i<10000*sigma; i++){
pair<int,int> xy = d.disperse(myrand.get_uint64());
myfile << xy.first << " " << xy.second << endl;
}
myfile.close();
return 0;
}
| [
"tfursten@asu.edu"
] | tfursten@asu.edu |
d72497741e237343662348c58a44a0d790d45dda | 175e724e9cc27fe3000326c816c6c8a2e8ed5e48 | /jma-receipt.r_5_1_branch/cobol/copy/HCM56.INC | ec18588dba1e96734ecc107596aedd854895e4c4 | [] | no_license | Hiroaki-Inomata/ORCA-5-1 | 8ddb025ed0a9f7d4ca43503dff093722508207bf | 15c648029770cfd9b3af60ae004c65819af6b4b1 | refs/heads/master | 2022-11-08T13:33:19.410136 | 2020-06-25T13:35:13 | 2020-06-25T13:35:13 | 274,871,265 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,068 | inc | 01 HCM56.
02 HCM56-PTNUM PIC X(20).
02 HCM56-PAGE PIC X(5).
02 HCM56-RENNUM PIC X(7).
02 HCM56-KANANAME PIC X(50).
02 HCM56-NAME PIC X(40).
02 HCM56-SYOBYO
PIC X(54) OCCURS 3 TIMES.
02 HCM56-SYOSHIN
PIC X(2) OCCURS 3 TIMES.
02 HCM56-KHNTEN
PIC X(7) OCCURS 38 TIMES.
02 HCM56-KAISU
PIC X(3) OCCURS 38 TIMES.
02 HCM56-TENSU
PIC X(7) OCCURS 38 TIMES.
02 HCM56-TOUYAKUNAME PIC X(4).
02 HCM56-TOUYAKUTANI
PIC X(2) OCCURS 2 TIMES.
02 HCM56-SONOTANAME OCCURS 2 TIMES.
03 HCM56-SONOTANAME-S
PIC X(2) OCCURS 4 TIMES.
02 HCM56-SONOTATANI PIC X(2).
02 HCM56-NYUINYMD PIC X(22).
02 HCM56-HOSPSBT
PIC X(2) OCCURS 3 TIMES.
02 HCM56-NYUSYUBETSU
PIC X(10) OCCURS 10 TIMES.
02 HCM56-NYUKHNTEN
PIC X(7) OCCURS 9 TIMES.
02 HCM56-NYUKHNTENN
PIC X(10) OCCURS 9 TIMES.
02 HCM56-NYUKAISU
PIC X(3) OCCURS 9 TIMES.
02 HCM56-NYUTENSU
PIC X(7) OCCURS 9 TIMES.
02 HCM56-NYUTENSUN-G OCCURS 9 TIMES.
03 HCM56-NYUTENSUN
PIC X(2) OCCURS 6 TIMES.
02 HCM56-KAKERU
PIC X(2) OCCURS 4 TIMES.
02 HCM56-NICHI
PIC X(4) OCCURS 4 TIMES.
02 HCM56-SRYYMD
PIC X(24) OCCURS 3 TIMES.
02 HCM56-STRYMD PIC X(26).
02 HCM56-ENDYMD PIC X(26).
02 HCM56-JITSUNISSU PIC X(3).
02 HCM56-KEIKA
PIC X(54) OCCURS 5 TIMES.
02 HCM56-TENKIYMD PIC X(22).
02 HCM56-TENKI
PIC X(2) OCCURS 5 TIMES.
02 HCM56-SRYKBN
PIC X(2) OCCURS 35 TIMES.
02 HCM56-TEKIYO
PIC X(52) OCCURS 35 TIMES.
02 HCM56-SYOKJN
PIC X(4) OCCURS 4 TIMES.
02 HCM56-SYOKHNTEN
PIC X(7) OCCURS 4 TIMES.
02 HCM56-SYOKAKERU
PIC X(4) OCCURS 4 TIMES.
02 HCM56-SYOKAISU
PIC X(3) OCCURS 4 TIMES.
02 HCM56-SYONICHI
PIC X(4) OCCURS 4 TIMES.
02 HCM56-KOMUTEN PIC X(9).
02 HCM56-KOMUTENTANKA PIC X(4).
02 HCM56-KOMUKINGAKU
PIC X(10) OCCURS 3 TIMES.
02 HCM56-SEIKYUYMD PIC X(22).
02 HCM56-HOSPJYUSYO PIC X(100).
02 HCM56-HOSPNAME PIC X(120).
02 HCM56-ISYA PIC X(40).
| [
"air.h.128k.il@gmail.com"
] | air.h.128k.il@gmail.com |
c611b990c0a3cb02bb0108d796661eacf0b412a1 | a9e00e1e8648c2468b2fb6069e516540c8c96554 | /game.h | 88ad5678e96eb14fc9743d51e877084f9ddd443b | [] | no_license | mdahamshi/reversi | 7a66d0bc3499a1433e99f33e1c0bf1d51aaf09ac | a292232ead8e415b41876cf346b02a7553cb4a38 | refs/heads/master | 2021-05-01T22:33:07.932998 | 2017-04-06T14:05:16 | 2017-04-06T14:05:16 | 77,394,342 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,713 | h | #ifndef GAME_H
#define GAME_H
//#include "constants.h"
#include "player.h"
#include "liveboard.h"
class Game
{
private:
int game_type;
int algo;
int depth;
int turn;
Player blackPlayer;
Player whitePlayer;
int passRounds;
int H[SIZE][SIZE]={
{ 1000, -300, 20, 5,10,10,10,10, 5,20, -300, 1000 },
{ -300,-300, -1, -1,-1,-1,-1,-1,-1,-1, -300, -300 },
{ 20, -1, 5, 1, 2, 2, 2, 2, 1, 5, -1, 20 },
{ 5, -1, 1, -1, 1, 1, 1, 1,-1, 1, -1, 5 },
{ 10 , -1, 2, 1, 2, 2, 2, 2, 1, 2, -1, 10 },
{ 10, -1, 2, 1, 2, 1, 1, 2, 1, 2, -1, 10 },
{ 10, -1, 2, 1, 2, 1, 1, 2, 1, 2, -1, 10 },
{ 10, -1, 2, 1, 2, 2, 2, 2, 1, 2, -1, 10 },
{ 5, -1, 1, -1, 1, 1, 1, 1,-1, 1, -1, 5 },
{ 20, -1, 5, 1, 2, 2, 2, 2, 1, 5, -1, 20 },
{ -300, -300, -1, -1,-1,-1,-1,-1,-1, -1, -300, -300 },
{ 1000, -300, 20, 5,10,10,10,10, 5, 20, -300, 1000 } };
public:
enum gameType{
PLAYER_VS_PLAYER,
PLAYER_VS_PC,
PC_VS_PC
};
enum algorithm{
NONE,
MINIMAX,
ALPHA_BETA,
BOTH
};
LiveBoard *gameBoard;
Game();
Game(int blacktype, int whitetype, int blackalg, int whitealg, int blackdep, int whitedep);
int getGame_type() const;
void updatePossible();
void setGame_type(int value);
int getNextTurnColor(){return (getTurn() == Constants::BLACK ? Constants::WHITE : Constants::BLACK);}
int getAlgo() const;
void setAlgo(int value);
int getDepth() const;
bool someoneWon();
void setDepth(int value);
int getTurn() const;
int getTurnType();
int checkBoard(Move *move, int kind);
void set(Move *move,int);
int Check(Move *move, int incx, int incy, int kind , bool set);
bool isValid(Move *move, int kind) ;
void setTurn(int value);
Best alphabeta(LiveBoard board ,int depth ,int alphaBeta ,Move currentMove);
void pcMove(int c);
bool noMoveBoth();
Best getBestMove(Player player);
Best minimax(LiveBoard gameBoard ,int depth ,Move);
LiveBoard *getGameBoard() const;
void setGameBoard(LiveBoard *value);
bool legalMove(int currentRow, int currentCol ,int currentTurn);
Player getWhitePlayer() const;
void setWhitePlayer(const Player &value);
int getHeuristicAt(int i){return H[i / SIZE][i % SIZE];}
double heursticEvaluate(LiveBoard board ,int turn);
Player getBlackPlayer() const;
int getTurnDepth(){return (getTurn() == Constants::WHITE ? getWhitePlayer().getDepth() : getBlackPlayer().getDepth()); }
void setBlackPlayer(const Player &value);
signals:
void gameUpdateBoard();
};
#endif // GAME_H
| [
"mmd.0@hotmail.com"
] | mmd.0@hotmail.com |
2196488967e745fde2304aa2264c68c699fa7795 | 5456502f97627278cbd6e16d002d50f1de3da7bb | /ppapi/proxy/udp_socket_resource.h | 1d609e4d934691726befdfd76a15a5f50d61213a | [
"BSD-3-Clause",
"LicenseRef-scancode-khronos"
] | permissive | TrellixVulnTeam/Chromium_7C66 | 72d108a413909eb3bd36c73a6c2f98de1573b6e5 | c8649ab2a0f5a747369ed50351209a42f59672ee | refs/heads/master | 2023-03-16T12:51:40.231959 | 2017-12-20T10:38:26 | 2017-12-20T10:38:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,315 | h | // Copyright 2013 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 PPAPI_PROXY_UDP_SOCKET_RESOURCE_H_
#define PPAPI_PROXY_UDP_SOCKET_RESOURCE_H_
#include <stdint.h>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/proxy/udp_socket_resource_base.h"
#include "ppapi/thunk/ppb_udp_socket_api.h"
namespace ppapi {
namespace proxy {
class PPAPI_PROXY_EXPORT UDPSocketResource : public UDPSocketResourceBase,
public thunk::PPB_UDPSocket_API {
public:
UDPSocketResource(Connection connection, PP_Instance instance);
~UDPSocketResource() override;
// PluginResource implementation.
thunk::PPB_UDPSocket_API* AsPPB_UDPSocket_API() override;
// thunk::PPB_UDPSocket_API implementation.
int32_t Bind(PP_Resource addr,
scoped_refptr<TrackedCallback> callback) override;
PP_Resource GetBoundAddress() override;
int32_t RecvFrom(char* buffer,
int32_t num_bytes,
PP_Resource* addr,
scoped_refptr<TrackedCallback> callback) override;
int32_t SendTo(const char* buffer,
int32_t num_bytes,
PP_Resource addr,
scoped_refptr<TrackedCallback> callback) override;
void Close() override;
int32_t SetOption1_0(
PP_UDPSocket_Option name,
const PP_Var& value,
scoped_refptr<TrackedCallback> callback) override;
int32_t SetOption1_1(
PP_UDPSocket_Option name,
const PP_Var& value,
scoped_refptr<TrackedCallback> callback) override;
int32_t SetOption(PP_UDPSocket_Option name,
const PP_Var& value,
scoped_refptr<TrackedCallback> callback) override;
int32_t JoinGroup(PP_Resource group,
scoped_refptr<TrackedCallback> callback) override;
int32_t LeaveGroup(PP_Resource group,
scoped_refptr<TrackedCallback> callback) override;
private:
DISALLOW_COPY_AND_ASSIGN(UDPSocketResource);
};
} // namespace proxy
} // namespace ppapi
#endif // PPAPI_PROXY_UDP_SOCKET_RESOURCE_H_
| [
"lixiaodonglove7@aliyun.com"
] | lixiaodonglove7@aliyun.com |
66925ff5e22be0582f3ce3c4ed8b9cfdee5c8760 | 73ee941896043f9b3e2ab40028d24ddd202f695f | /external/chromium_org/chrome/installer/util/google_chrome_distribution.h | d3f148fc762f6f657adbd12b3d4dc34d67074b59 | [
"BSD-3-Clause"
] | permissive | CyFI-Lab-Public/RetroScope | d441ea28b33aceeb9888c330a54b033cd7d48b05 | 276b5b03d63f49235db74f2c501057abb9e79d89 | refs/heads/master | 2022-04-08T23:11:44.482107 | 2016-09-22T20:15:43 | 2016-09-22T20:15:43 | 58,890,600 | 5 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 3,378 | h | // Copyright (c) 2012 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.
//
// This file extends generic BrowserDistribution class to declare Google Chrome
// specific implementation.
#ifndef CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_
#define CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_
#include "base/gtest_prod_util.h"
#include "base/strings/string16.h"
#include "chrome/installer/util/browser_distribution.h"
namespace base {
class FilePath;
}
class GoogleChromeDistribution : public BrowserDistribution {
public:
// Opens the Google Chrome uninstall survey window.
// version refers to the version of Chrome being uninstalled.
// local_data_path is the path of the file containing json metrics that
// will be parsed. If this file indicates that the user has opted in to
// providing anonymous usage data, then some additional statistics will
// be added to the survey url.
// distribution_data contains Google Update related data that will be
// concatenated to the survey url if the file in local_data_path indicates
// the user has opted in to providing anonymous usage data.
virtual void DoPostUninstallOperations(
const Version& version,
const base::FilePath& local_data_path,
const string16& distribution_data) OVERRIDE;
virtual string16 GetActiveSetupGuid() OVERRIDE;
virtual string16 GetAppGuid() OVERRIDE;
virtual string16 GetBaseAppName() OVERRIDE;
virtual string16 GetAppShortCutName() OVERRIDE;
virtual string16 GetAlternateApplicationName() OVERRIDE;
virtual string16 GetBaseAppId() OVERRIDE;
virtual string16 GetInstallSubDir() OVERRIDE;
virtual string16 GetPublisherName() OVERRIDE;
virtual string16 GetAppDescription() OVERRIDE;
virtual std::string GetSafeBrowsingName() OVERRIDE;
virtual string16 GetStateKey() OVERRIDE;
virtual string16 GetStateMediumKey() OVERRIDE;
virtual std::string GetNetworkStatsServer() const OVERRIDE;
virtual std::string GetHttpPipeliningTestServer() const OVERRIDE;
// This method reads data from the Google Update ClientState key for
// potential use in the uninstall survey. It must be called before the
// key returned by GetVersionKey() is deleted.
virtual string16 GetDistributionData(HKEY root_key) OVERRIDE;
virtual string16 GetUninstallLinkName() OVERRIDE;
virtual string16 GetUninstallRegPath() OVERRIDE;
virtual string16 GetVersionKey() OVERRIDE;
virtual string16 GetIconFilename() OVERRIDE;
virtual bool GetCommandExecuteImplClsid(
string16* handler_class_uuid) OVERRIDE;
virtual bool AppHostIsSupported() OVERRIDE;
virtual void UpdateInstallStatus(
bool system_install,
installer::ArchiveType archive_type,
installer::InstallStatus install_status) OVERRIDE;
virtual bool ShouldSetExperimentLabels() OVERRIDE;
virtual bool HasUserExperiments() OVERRIDE;
const string16& product_guid() { return product_guid_; }
protected:
void set_product_guid(const string16& guid) { product_guid_ = guid; }
// Disallow construction from others.
GoogleChromeDistribution();
private:
friend class BrowserDistribution;
// The product ID for Google Update.
string16 product_guid_;
};
#endif // CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_
| [
"ProjectRetroScope@gmail.com"
] | ProjectRetroScope@gmail.com |
180c0c3d6ac816b96af988e7b3d22abe0360caf8 | 83e9408e7a6c21d1357594715f631865142528e6 | /luogu/1057.cpp | 6fc9261b3c2afecf477655b9e36026d4c2ee9a2d | [] | no_license | chill-cy/Data-Structure | 0027ffbbc10c765f555951c678cf28b89494cb68 | b325de5781f9f3f00aec7724dcbbb680b1e5dcc9 | refs/heads/master | 2022-03-28T15:29:37.437731 | 2020-01-12T09:01:20 | 2020-01-12T09:01:20 | 197,802,813 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 722 | cpp | /*************************************************************************
> File Name: 1057.cpp
> Author:
> Mail:
> Created Time: 2019年04月07日 星期日 16时42分32秒
************************************************************************/
#include <stdio.h>
#define MAX_N 30
int n, m;
int ans[MAX_N + 5][MAX_N + 5] = {0};
int keep[MAX_N + 5][MAX_N + 5] = {0};
int f(int set, int m) {
if (m == 0) return set == 1 ? 1 : 0;
if (ans[set][m] == 1) return keep[set][m];
keep[set][m] = f((set - 1 + n) % n , m - 1) + f((set + 1) % n, m - 1);
ans[set][m] = 1;
return keep[set][m];
}
int main() {
scanf("%d%d", &n, &m);
int ans = f(1, m);
printf("%d\n", ans);
return 0;
}mZ
| [
"2547116322@qq.com"
] | 2547116322@qq.com |
ca53635d5ae2c2520709ed862379ace61ab07ea8 | 39200d093704a2f4bc8f0bd77ce40e44a101a40f | /unreal/Source/samuraisenshi/Private/Damage_PlayerSlash.cpp | 3bdfda5175cef3b914bba916549d8cf00eeacb3f | [] | no_license | ViMaSter/p300-samuraisenshi | e05da699535ab1d972bd15e9dc8f9b0cc624c595 | 2c6646c390f4b56d1569d9f61cea3942d0c77cdb | refs/heads/master | 2021-01-01T19:43:06.761337 | 2015-04-15T13:07:11 | 2015-04-15T13:07:11 | 34,789,547 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 258 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "samuraisenshi.h"
#include "Damage_PlayerSlash.h"
UDamage_PlayerSlash::UDamage_PlayerSlash(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}
| [
"accounts@vimaster.de"
] | accounts@vimaster.de |
b4c69ca710da752a4d0ac4c4cdaf2833287ac1e6 | c9d3b10f357958d91e768d4ca8bd927968e9f22d | /src/main.cpp | 9662f1d112945d7a1168920e5a24319344973984 | [] | no_license | burakertekin/closestPointOnMesh | 3edf6d4fb7eee519439ab3a109e63244970679c2 | 41d3a0c9ab8101dc388bd2d45b44123dbecec85c | refs/heads/main | 2023-02-28T13:55:08.862164 | 2021-02-11T06:26:44 | 2021-02-11T06:26:44 | 337,934,098 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,399 | cpp | // needed once for tinyobjloader
#define TINYOBJLOADER_IMPLEMENTATION
#include <fstream>
#include "stdio.h"
#include "PointQuery.h"
int main(int argc, char** argv)
{
Mesh mesh;
const char * objFile = "../data/teapot.obj";
const char * pointQueryFile = "../data/teapot_pts.txt";
if(argc>2)
{
objFile = argv[1];
pointQueryFile = argv[2];
}
else
{
printf("No .obj file and/or query .txt file provided, using default test case\n");
}
// read obj file
if(mesh.readObj(objFile))
{
PointQuery query(mesh);
std::ifstream input(pointQueryFile);
float x, y, z, querydist, dist;
// read input query pts & distance
while(input >> x >> y >> z >> querydist)
{
std::cout << "===============================================" << std::endl;
dist = querydist;
Eigen::Vector3d queryPoint(x, y, z);
Eigen::Vector3d result = query(queryPoint, dist);
if(result != queryPoint)
{
printf("FOUND pt: %f %f %f within distance: %f to query pt: %f %f %f max search radius: %f\n", result.x(), result.y(), result.z(), dist, x, y, z, querydist);
}
else
{
printf("NOT FOUND pt within distance %f to query pt %f %f %f\n", dist, x, y, z);
}
}
}
} | [
"burakertekin"
] | burakertekin |
5f64ef79f3ca4e99c729a71a55cb75265841cf6e | 6258de2aeb36cc728c998c107013ccd3f4ec29f1 | /Programmers/Programmers/멀쩡한_사각형.cpp | fc54b1d63c5fa88ac11fc661932e79fa42a2b9a6 | [] | no_license | gihop/AlgorithmStudy | ac1f885ad03ba896d5b88334aaedc8a385d2fb48 | 281d786f4e6fc51bceb69fbc8684ab9485489012 | refs/heads/master | 2021-06-30T11:57:18.768253 | 2021-05-07T15:56:46 | 2021-05-07T15:56:46 | 230,912,854 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,052 | cpp | #include <iostream>
using namespace std;
//규칙을 알아내면 쉽게 풀어낼 수 있는 문제.
//answer = (long long)w * h; 에서 (long long)으로 미리 형변환을 해주지 않으면
//w * h 연산을 한 후에 형변환이 일어난다. 여기서 w와 h는 범위가 1억까지 포함되므로 overflow가
//발생할 수 있기 때문에 미리 형변환을 해야한다.
//유클리드 호제법을 이용하여 최대공약수를 구한다.
//a%b를 나머지 연산하고, 나머지가 0인 경우 b가 최대공약수,
//0이 아닌 경우는 a에 b값을 넣고, b에 나머지 값을 넣어서 처음부터 반복한다.
long long solution(int w, int h) {
long long answer = (long long)w * h;
int num = w, gcd = h;
int tmp;
if(num < gcd){
tmp = gcd;
gcd = num;
num = tmp;
}
while(true){
tmp = num % gcd;
if(tmp == 0) break;
num = gcd;
gcd = tmp;
}
long long square = w + h - gcd;
answer -= square;
return answer;
}
| [
"giho-p@hanmail.net"
] | giho-p@hanmail.net |
141018bb174e447c18c2451d69d4feb177064cf5 | 5888c735ac5c17601969ebe215fd8f95d0437080 | /Uva online Judge/uva-13012.cpp | bbca08a9474e8e51642bac61586094c338541d91 | [] | no_license | asad14053/My-Online-Judge-Solution | 8854dc2140ba7196b48eed23e48f0dcdb8aec83f | 20a72ea99fc8237ae90f3cad7624224be8ed4c6c | refs/heads/master | 2021-06-16T10:41:34.247149 | 2019-07-30T14:44:09 | 2019-07-30T14:44:09 | 40,115,430 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 304 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
long t,ar[100];
while(cin>>t)
{
long a,b,c,d,e=0;
cin>>ar[0]>>ar[1]>>ar[2]>>ar[3]>>ar[4];
for(int i=0; i<5; i++)
{
if(t==ar[i]) ++e;
}
cout<<e<<endl;
}
return 0;
}
| [
"asad14053@users.noreply.github.com"
] | asad14053@users.noreply.github.com |
cdd052d11cd1b13eac6194021cce1bf9ab34cb15 | dd80a584130ef1a0333429ba76c1cee0eb40df73 | /external/chromium_org/chrome/browser/policy/configuration_policy_pref_store_test.h | ef8c76414ba80491573810ddfc21b8c43727bc16 | [
"BSD-3-Clause",
"MIT"
] | permissive | karunmatharu/Android-4.4-Pay-by-Data | 466f4e169ede13c5835424c78e8c30ce58f885c1 | fcb778e92d4aad525ef7a995660580f948d40bc9 | refs/heads/master | 2021-03-24T13:33:01.721868 | 2017-02-18T17:48:49 | 2017-02-18T17:48:49 | 81,847,777 | 0 | 2 | MIT | 2020-03-09T00:02:12 | 2017-02-13T16:47:00 | null | UTF-8 | C++ | false | false | 1,503 | h | // Copyright 2013 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_POLICY_CONFIGURATION_POLICY_PREF_STORE_TEST_H_
#define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_TEST_H_
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "components/policy/core/browser/configuration_policy_handler_list.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_service_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace policy {
class PolicyMap;
class PolicyService;
class ConfigurationPolicyPrefStore;
class ConfigurationPolicyPrefStoreTest : public testing::Test {
protected:
ConfigurationPolicyPrefStoreTest();
virtual ~ConfigurationPolicyPrefStoreTest();
virtual void TearDown() OVERRIDE;
void UpdateProviderPolicy(const PolicyMap& policy);
PolicyServiceImpl::Providers providers_;
ConfigurationPolicyHandlerList handler_list_;
MockConfigurationPolicyProvider provider_;
scoped_ptr<PolicyService> policy_service_;
scoped_refptr<ConfigurationPolicyPrefStore> store_;
base::MessageLoop loop_;
private:
DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStoreTest);
};
} // namespace policy
#endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_TEST_H_
| [
"karun.matharu@gmail.com"
] | karun.matharu@gmail.com |
3e3ad12f064e0eeba1ab19b672d7353c1007b5c2 | 48602f8af4d71e14b97249328f995879d149ab69 | /inc/tp_image_utils/LoadImages.h | 55acd583d583279a82fa934f6eba3a32ca7cef3d | [
"MIT"
] | permissive | wrld3d/tp_image_utils | ddfc0bde968cc9210c290acbea7a0391fc797f12 | 79acb74dfd8b3b0fceb0324a39f790f5aea0cb63 | refs/heads/master | 2020-04-19T18:02:07.664866 | 2019-05-17T16:30:38 | 2019-05-17T16:30:38 | 168,351,561 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,681 | h | #ifndef tp_image_utils_LoadImages_h
#define tp_image_utils_LoadImages_h
#include "tp_image_utils/Globals.h"
#include "tp_image_utils/ColorMap.h"
#include "tp_image_utils/ByteMap.h"
#include "json.hpp"
#include <vector>
#include <unordered_set>
namespace tp_image_utils
{
//##################################################################################################
ColorMap loadImage(const std::string& path);
//##################################################################################################
ColorMap loadImageFromData(const std::string& data);
//##################################################################################################
std::vector<std::string> imagePaths(const std::string& path);
//##################################################################################################
std::vector<ColorMap> loadImages(const std::string& path, int64_t maxBytes=1073741824);
//##################################################################################################
std::vector<ColorMap> loadImages(const std::string& path, std::vector<std::string>& names, int64_t maxBytes=1073741824);
//##################################################################################################
ColorMap loadImageFromJson(const nlohmann::json& j);
//##################################################################################################
ByteMap loadByteMapFromJson(const nlohmann::json& j);
//##################################################################################################
std::vector<std::string> imageTypes();
//##################################################################################################
std::unordered_set<std::string> imageTypesSet();
//##################################################################################################
std::vector<float> imageToFloatRGB(const ColorMap& image);
//##################################################################################################
std::vector<std::vector<float>> imagesToFloatRGB(const std::vector<ColorMap>& images, size_t width, size_t height);
//##################################################################################################
std::vector<std::vector<uint8_t>> imagesToCharRGB(const std::vector<ColorMap>& images, size_t width, size_t height);
extern ColorMap (*loadImage_)(const std::string& path);
extern ColorMap (*loadImageFromData_)(const std::string& data);
extern std::vector<std::string> (*imagePaths_)(const std::string& path);
extern std::vector<ColorMap> (*loadImages_)(const std::string& path, std::vector<std::string>& names, int64_t maxBytes);
}
#endif
| [
"tompaynter@tdpe.co.uk"
] | tompaynter@tdpe.co.uk |
50104d068bbb9992d7d5cdf760a3df789d32f7d8 | 9c225bcece3bbd78152759251e0baf0349633579 | /AXGraphics/DirectXRenderer.cpp | 75bd516e53b6ac5f2fd723514ef0b3782f503b5d | [] | no_license | jneander/AliquiX | 830581d49d1fb47090db35dbf2e49e02cc15e6e3 | 0374e63750a879c9625b939b337ea02747a71adb | refs/heads/master | 2022-02-02T11:29:59.727970 | 2015-02-12T15:52:00 | 2015-02-12T15:52:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 33,781 | cpp | /* --------------------------------------------------------------
File: DirectXRenderer.cpp
Description: Implementation for the DirectXRenderer class. See DirectXRenderer.h for details.
Date: August 1, 2005
Author: James Long
-------------------------------------------------------------- */
#include "..\\AXCore.h"
#include "..\\AXApplication.h"
#include "..\\AXUtilities\\AXMath.h"
#include "..\\AXUtilities\\AXStringFunctions.h"
#include "..\\AXApplication\\Win32Window.h"
#include "AXResources.h"
#include "DirectXRenderer.h"
#include <dxerr9.h>
#include <string>
#include <crtdbg.h>
DirectXRenderer::DirectXRenderer() : AXRenderer(), _D3D(NULL), _D3DDevice(NULL) {
}
DirectXRenderer::~DirectXRenderer() {
}
AXResult DirectXRenderer::Initialize() {
if(_D3D) {
LOG_SYS("Failure to init, already initialized!");
return AXFAILURE;
}
Settings.ParseSettings("renderer");
ValidateSettings();
LOG_SYS("Initializing Direct3d...");
if( (_D3D = Direct3DCreate9( D3D_SDK_VERSION )) == NULL ) {
LOG_SYS("Creating D3D failed!");
return AXFAILURE;
}
for(unsigned int i=0; i<AX_MAXRENDERSTATES; i++) {
_SetRenderStates[i] = (unsigned int)-1;
}
return AXSUCCESS;
}
void DirectXRenderer::Shutdown() {
SafeRelease(_D3D);
Settings.WriteSettings();
}
AXResult DirectXRenderer::CreateDevice() {
if(_D3DDevice) return AXSUCCESS;
LOG_SYS("Creating Direct3d device...");
D3DPRESENT_PARAMETERS D3DPresParam;
std::string DevType = Settings.GetSetting<std::string>("dxDeviceType");
int VertexProcessingType = 0;
/* Get the appropriate device type according the settings */
if(DevType == "ref")
_DeviceType = D3DDEVTYPE_REF;
else
_DeviceType = D3DDEVTYPE_HAL;
/* Fill in the device caps */
_D3D->GetDeviceCaps(D3DADAPTER_DEFAULT, _DeviceType, &_D3DCaps);
/* Fill in the presentation parameter structure will all the correct values
according to settings, supported formats etc.
This also sets the internal format variables of this renderer, so we know
the formats of buffers later on */
if( AXFAILED(_GetPresentationParam(&D3DPresParam)) ) {
LOG_SYS("An error occurred while getting presentation parameters!");
return AXFAILURE;
}
/* Figure out if we can do hardware processing, or if we must do software.
We have to call GetDeviceCaps to figure this out. */
if(_D3DCaps.VertexProcessingCaps != 0) {
LOG_SYS("Using hardware vertex processing...");
VertexProcessingType |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
}
else {
LOG_SYS("Using software vertex processing...");
VertexProcessingType |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
}
/* Actually create the device with all the parameters that we've made. */
HRESULT hr;
/* If we are using DirectX, we know that we are on a Win32 machine. We need to get the HWND of the window,
and very carefully send the AXAppWindow object down the class heirarchy */
Win32Window *Window = dynamic_cast<Win32Window*>(AXBaseSystem::GetWindow());
if(!Window) {
LOG_SYS("A serious error has occurred while trying to retrieve the Win32 window.");
return AXFAILURE;
}
hr = _D3D->CreateDevice(D3DADAPTER_DEFAULT, _DeviceType, Window->GetHWND(), VertexProcessingType, &D3DPresParam, &_D3DDevice);
if(FAILED(hr)) {
LOG_SYS1("Cannot create device! (%s)", DXGetErrorString9(hr));
return AXFAILURE;
}
LOG_SYS("Creating Direct3d device successful!");
this->_IndexBufferID = (unsigned int)-1;
this->_IndexBufferOffset = 0;
_SetDXDefaults();
return AXSUCCESS;
}
void DirectXRenderer::DestroyDevice() {
if(!_D3DDevice)
return;
_FreeInternalResources();
LOG_SYS("Releasing the rendering device...");
SafeRelease(_D3DDevice);
}
AXResult DirectXRenderer::_ResetDevice() {
LOG_SYS("Resetting Direct3d device...");
if(!_D3DDevice) {
LOG_SYS("Cannot reset device, not created yet!");
return AXFAILURE;
}
_FreeInternalResources();
D3DPRESENT_PARAMETERS D3DPresParam;
if( AXFAILED(_GetPresentationParam(&D3DPresParam)) ) {
LOG_SYS("An error occurred while getting presentation parameters!");
return AXFAILURE;
}
HRESULT hr;
hr = _D3DDevice->Reset(&D3DPresParam);
if(FAILED(hr)) {
LOG_SYS1("Failed to reset the device: %s", DXGetErrorString9(hr));
return AXFAILURE;
}
LOG_SYS("Resetting Direct3d device successful!");
/* Tell the resource manager that is can request things again */
LOG_SYS("Resetting resources...");
if(AXFAILED(AXBaseSystem::GetResourceMgr()->OnReset())) {
LOG_SYS("Failed resetting resources!");
return AXFAILURE;
}
_SetDXDefaults();
return AXSUCCESS;
}
AXResult DirectXRenderer::GetResolutionList(std::vector<AXFullscreenMode> &ModeList) {
D3DFORMAT AdapterFormat = _GetCurrentAdapterFormat();
D3DDISPLAYMODE DisplayInformation;
AXFullscreenMode Mode;
ModeList.clear();
unsigned int NumModes = _D3D->GetAdapterModeCount(D3DADAPTER_DEFAULT, AdapterFormat);
for(unsigned int i=0; i<NumModes; i++) {
if( FAILED(_D3D->EnumAdapterModes(D3DADAPTER_DEFAULT, AdapterFormat, i, &DisplayInformation)) )
return AXFAILURE;
Mode.RefreshRate = DisplayInformation.RefreshRate;
Mode.Resolution = AXDimension2D(DisplayInformation.Width, DisplayInformation.Height);
ModeList.push_back(Mode);
}
return AXSUCCESS;
}
AXResult DirectXRenderer::IsResolutionSupported(const AXFullscreenMode &Mode) {
std::vector<AXFullscreenMode> ModeList;
if( AXFAILED(GetResolutionList(ModeList)) )
return AXFAILURE;
for(unsigned int i=0; i<ModeList.size(); i++) {
if(ModeList[i].Resolution.x == Mode.Resolution.x && ModeList[i].Resolution.y == Mode.Resolution.y && ModeList[i].RefreshRate == Mode.RefreshRate) {
return AXSUCCESS;
}
}
return AXFAILURE;
}
void DirectXRenderer::_FreeInternalResources() {
/* Free resources */
for(unsigned int i=0; i<(unsigned int)_VertexBuffers.size(); i++) {
DestroyVertexBuffer(i);
}
_VertexBuffers.clear();
for(unsigned int i=0; i<(unsigned int)_IndexBuffers.size(); i++) {
DestroyIndexBuffer(i);
}
_IndexBuffers.clear();
UIntVertexDeclarationMap::iterator it;
for(it = _VertexDeclarations.begin(); it != _VertexDeclarations.end(); it++) {
SafeRelease(it->second);
}
_VertexDeclarations.clear();
this->_IndexBufferID = (unsigned int)-1;
this->_IndexBufferOffset = 0;
}
/* -----------------------------------
Events
----------------------------------- */
void DirectXRenderer::OnWindowChange() {
if(!_D3DDevice)
return;
// Some properties of the window have changed,
// so we need to reset the device
if(AXFAILED(_ResetDevice())) {
LOG_SYS("An error occurred while resetting the device!");
}
}
void DirectXRenderer::Screenshot() {
if(!_D3DDevice)
return;
LOG_SYS("Taking screenshot...");
AXDimension2D ScreenSize;
IDirect3DSurface9* BackBuffer;
ScreenSize = GetScreenSize();
//_D3DDevice->CreateOffscreenPlainSurface(ScreenSize.x, ScreenSize.y, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &BackBuffer, NULL);
HRESULT hr = _D3DDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &BackBuffer);
if(FAILED(hr)) {
LOG_SYS("Failed taking screenshot!");
SafeRelease(BackBuffer);
return;
}
int Index = Settings.GetSetting<int>("screenshotIndex") + 1;
Settings.SetSetting("screenshotIndex", Index);
std::string FileName = std::string("Screenshot") + AXStringConvertFromInt(Index) + std::string(".jpg");
D3DXSaveSurfaceToFile(FileName.c_str(), D3DXIFF_BMP, BackBuffer, NULL, NULL);
SafeRelease(BackBuffer);
}
/* -----------------------------------
Rendering functions and data functions
----------------------------------- */
void DirectXRenderer::RenderPrimitives(AXPrimitiveType Type, unsigned int NumVertices) {
D3DPRIMITIVETYPE DXType;
unsigned int NumPrimitives = 0;
if(Type == AX_PRIM_TRIANGLES) {
DXType = D3DPT_TRIANGLELIST;
NumPrimitives = NumVertices/3;
}
else if(Type == AX_PRIM_TRIANGLESTRIP) {
DXType = D3DPT_TRIANGLESTRIP;
NumPrimitives = NumVertices-2;
}
else if(Type == AX_PRIM_LINES) {
DXType = D3DPT_LINELIST;
NumPrimitives = NumVertices/2;
}
else if(Type == AX_PRIM_LINESTRIP) {
DXType = D3DPT_LINELIST;
NumPrimitives = NumVertices-1;
}
// Other types aren't supported yet
_D3DDevice->DrawPrimitive(DXType, 0, NumPrimitives);
}
void DirectXRenderer::RenderIndexedPrimitives(AXPrimitiveType Type, unsigned int NumVertices, unsigned int NumIndices) {
D3DPRIMITIVETYPE DXType;
unsigned int NumPrimitives = 0;
if(Type == AX_PRIM_TRIANGLES) {
DXType = D3DPT_TRIANGLELIST;
NumPrimitives = NumIndices/3;
}
else if(Type == AX_PRIM_TRIANGLESTRIP) {
DXType = D3DPT_TRIANGLESTRIP;
NumPrimitives = NumIndices-2;
}
HRESULT hr = _D3DDevice->DrawIndexedPrimitive(DXType, 0, 0, NumVertices, _IndexBufferOffset, NumPrimitives);
if(FAILED(hr)) {
LOG_SYS1("DrawIndexedPrimitive failed! Error: %s", DXGetErrorString9(hr));
}
}
void DirectXRenderer::BeginRendering() {
_D3DDevice->BeginScene();
}
void DirectXRenderer::EndRendering() {
_D3DDevice->EndScene();
}
void DirectXRenderer::ClearBuffers(const unsigned int Buffers, const AXColorRGB Color, const float Depth, const unsigned int Stencil) {
unsigned int BufferFlags = 0;
if(Buffers & AX_BUFFER_TARGET) BufferFlags |= D3DCLEAR_TARGET;
if(Buffers & AX_BUFFER_DEPTH) BufferFlags |= D3DCLEAR_ZBUFFER;
_D3DDevice->Clear(0, NULL, BufferFlags, D3DCOLOR_XRGB(AXColorR(Color), AXColorG(Color), AXColorB(Color)), Depth, Stencil);
}
void DirectXRenderer::FlipBuffers() {
AXPROFILE("Flip buffers");
HRESULT hr;
hr = _D3DDevice->Present(NULL, NULL, NULL, NULL);
if(FAILED(hr)) {
hr = _D3DDevice->TestCooperativeLevel();
if(hr == D3DERR_DEVICENOTRESET) _ResetDevice();
}
}
void DirectXRenderer::LoadMatrix(const MatrixType Type, const AXMatrix4 *Mat) {
switch(Type) {
case AX_MATRIX_VIEW: _D3DDevice->SetTransform(D3DTS_VIEW, Mat); break;
case AX_MATRIX_WORLD: _D3DDevice->SetTransform(D3DTS_WORLD, Mat); break;
case AX_MATRIX_PROJECTION: _D3DDevice->SetTransform(D3DTS_PROJECTION, Mat); break;
}
}
unsigned int DirectXRenderer::GetRenderState(AXRenderState State) {
DWORD V = 0;
switch(State) {
case AX_RS_LIGHTING: _D3DDevice->GetRenderState(D3DRS_LIGHTING, &V); break;
case AX_RS_ZENABLE: _D3DDevice->GetRenderState(D3DRS_ZENABLE, &V); break;
case AX_RS_ZWRITE: _D3DDevice->GetRenderState(D3DRS_ZWRITEENABLE, &V); break;
case AX_RS_CULLMODE:
_D3DDevice->GetRenderState(D3DRS_CULLMODE, &V);
if(V == D3DCULL_NONE) V = AX_CULL_NONE;
else if(V == D3DCULL_CCW) V = AX_CULL_CCW;
else if(V == D3DCULL_CW) V = AX_CULL_CW;
break;
case AX_RS_FILLMODE:
_D3DDevice->GetRenderState(D3DRS_FILLMODE, &V);
if(V == D3DFILL_SOLID) V = AX_FILL_SOLID;
else if(V == D3DFILL_WIREFRAME) V = AX_FILL_WIREFRAME;
else if(V == D3DFILL_POINT) V = AX_FILL_POINT;
break;
case AX_RS_DIFFUSESOURCE:
_D3DDevice->GetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, &V);
if(V == D3DMCS_COLOR1) V = AX_COLORSOURCE_VERTEX;
else if(V == D3DMCS_MATERIAL) V = AX_COLORSOURCE_MATERIAL;
break;
}
return (unsigned int)V;
}
void DirectXRenderer::SetRenderState(AXRenderState State, unsigned int Value) {
switch(State) {
case AX_RS_LIGHTING: _D3DDevice->SetRenderState(D3DRS_LIGHTING, Value); break;
case AX_RS_ZENABLE: _D3DDevice->SetRenderState(D3DRS_ZENABLE, Value); break;
case AX_RS_ZWRITE: _D3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, Value); break;
case AX_RS_CULLMODE:
if(Value == AX_CULL_NONE)
_D3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
else if(Value == AX_CULL_CCW)
_D3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
else if(Value == AX_CULL_CW)
_D3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
break;
case AX_RS_FILLMODE:
if(Value == AX_FILL_SOLID) _D3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
else if(Value == AX_FILL_WIREFRAME) _D3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
else if(Value == AX_FILL_POINT) _D3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT);
break;
case AX_RS_DIFFUSESOURCE:
if(Value == AX_COLORSOURCE_VERTEX) _D3DDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
else _D3DDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
break;
}
_SetRenderStates[State] = Value;
}
void DirectXRenderer::SetMaterial(AXMaterial *Material) {
D3DMATERIAL9 Mat;
ZeroMemory(&Mat, sizeof(Mat));
Mat.Ambient.a = 1.0f;
Mat.Ambient.r = 1.0f;
Mat.Ambient.g = 1.0f;
Mat.Ambient.b = 1.0f;
Mat.Diffuse.a = AXColorA(Material->Diffuse);
Mat.Diffuse.r = AXColorR(Material->Diffuse);
Mat.Diffuse.g = AXColorG(Material->Diffuse);
Mat.Diffuse.b = AXColorB(Material->Diffuse);
Mat.Specular.a = AXColorA(Material->Specular);
Mat.Specular.r = AXColorR(Material->Specular);
Mat.Specular.g = AXColorG(Material->Specular);
Mat.Specular.b = AXColorB(Material->Specular);
Mat.Power = Material->Shininess;
unsigned int CurDiffuseSource = GetRenderState(AX_RS_DIFFUSESOURCE);
unsigned int CurSpecularSource = GetRenderState(AX_RS_SPECULARSOURCE);
if(Material->DiffuseSource != CurDiffuseSource) {
SetRenderState(AX_RS_DIFFUSESOURCE, Material->DiffuseSource);
}
if(Material->SpecularSource != CurSpecularSource) {
SetRenderState(AX_RS_DIFFUSESOURCE, Material->SpecularSource);
}
_D3DDevice->SetMaterial(&Mat);
}
unsigned int DirectXRenderer::GetDeviceCapability(AXDeviceCapability Cap) {
/* to be fleshed out */
switch(Cap) {
case AX_DC_NUMLIGHTS: return _D3DCaps.MaxActiveLights;
}
return 0;
}
/* -----------------------------------
Vertex and index management
----------------------------------- */
unsigned int DirectXRenderer::CreateVertexBuffer() {
for(unsigned int i=0; i<_VertexBuffers.size(); i++) {
if(_VertexBuffers[i].InUse = 0) {
_VertexBuffers[i].VertexBuffer = NULL;
_VertexBuffers[i].InUse = 1;
return i;
}
}
DirectXVertexBuffer TempBuffer;
TempBuffer.VertexBuffer = NULL;
TempBuffer.InUse = 1;
_VertexBuffers.push_back(TempBuffer);
return (unsigned int)_VertexBuffers.size()-1;
}
unsigned int DirectXRenderer::CreateIndexBuffer() {
for(unsigned int i=0; i<_IndexBuffers.size(); i++) {
if(_IndexBuffers[i].InUse = 0) {
_IndexBuffers[i].IndexBuffer = NULL;
_IndexBuffers[i].InUse = 1;
return i;
}
}
DirectXIndexBuffer TempBuffer;
TempBuffer.IndexBuffer = NULL;
TempBuffer.InUse = 1;
_IndexBuffers.push_back(TempBuffer);
return (unsigned int)_IndexBuffers.size()-1;
}
AXResult DirectXRenderer::AllocateVertexBuffer(unsigned int ID, unsigned int Size) {
if(ID >= (unsigned int)_VertexBuffers.size()) {
LOG_SYS1("Failed creating DX vertex buffer, invalid ID: %d", ID);
return AXFAILURE;
}
if(_VertexBuffers[ID].VertexBuffer != NULL) {
SafeRelease(_VertexBuffers[ID].VertexBuffer);
}
HRESULT hr = _D3DDevice->CreateVertexBuffer(Size, D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &_VertexBuffers[ID].VertexBuffer, NULL);
if(FAILED(hr)) {
LOG_SYS2("Failed creating DX vertex buffer, size: %d: %s", Size, DXGetErrorString9(hr));
return AXFAILURE;
}
return AXSUCCESS;
}
void DirectXRenderer::DestroyVertexBuffer(unsigned int ID) {
SafeRelease(_VertexBuffers[ID].VertexBuffer);
_VertexBuffers[ID].InUse = 0;
}
AXResult DirectXRenderer::AllocateIndexBuffer(unsigned int ID, unsigned int Size, unsigned int NumBytes) {
if(ID >= (unsigned int)_IndexBuffers.size()) {
LOG_SYS1("Failed creating DX index buffer, invalid ID: %d", ID);
return AXFAILURE;
}
if(_IndexBuffers[ID].IndexBuffer != NULL) {
SafeRelease(_IndexBuffers[ID].IndexBuffer);
}
HRESULT hr;
if(NumBytes == 2)
hr = _D3DDevice->CreateIndexBuffer(Size, D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &_IndexBuffers[ID].IndexBuffer, NULL);
else
hr = _D3DDevice->CreateIndexBuffer(Size, D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_DEFAULT, &_IndexBuffers[ID].IndexBuffer, NULL);
if(FAILED(hr)) {
LOG_SYS3("Failed creating DX index buffer, size: %d numbytes: %d. Error: %s", Size, NumBytes, DXGetErrorString9(hr));
return AXFAILURE;
}
return AXSUCCESS;
}
void DirectXRenderer::DestroyIndexBuffer(unsigned int ID) {
SafeRelease(_IndexBuffers[ID].IndexBuffer);
_IndexBuffers[ID].InUse = 0;
}
void* DirectXRenderer::LockVertexBuffer(unsigned int ID, unsigned int Offset, unsigned int Size) {
void* Buffer;
HRESULT hr = _VertexBuffers[ID].VertexBuffer->Lock(Offset, Size, &Buffer, 0);
if(FAILED(hr)) {
LOG_SYS1("Failed locking DX vertex buffer: %s", DXGetErrorString9(hr));
return NULL;
}
return Buffer;
}
void DirectXRenderer::UnlockVertexBuffer(unsigned int ID) {
_VertexBuffers[ID].VertexBuffer->Unlock();
}
void* DirectXRenderer::LockIndexBuffer(unsigned int ID, unsigned int Offset, unsigned int Size) {
void* Buffer;
HRESULT hr = _IndexBuffers[ID].IndexBuffer->Lock(Offset, Size, &Buffer, 0);
if(FAILED(hr)) {
LOG_SYS1("Failed locking DX index buffer:", DXGetErrorString9(hr));
return NULL;
}
return Buffer;
}
void DirectXRenderer::UnlockIndexBuffer(unsigned int ID) {
_IndexBuffers[ID].IndexBuffer->Unlock();
}
void DirectXRenderer::SetVertexSource(AXVertexBuffer *Buffer) {
if(!Buffer) return;
if(!Buffer->Stride) {
LOG_SYS("Warning - failed setting vertex source, data is not interleaved!");
return;
};
unsigned int Size = 0;
unsigned int Types = 0;
unsigned int NumElements = (unsigned int)Buffer->BufferDesc.size();
for(unsigned int i=0; i<NumElements; i++) {
Types |= Buffer->BufferDesc[i].Type;
Size += GetElementSizeInBytes(Buffer->BufferDesc[i].Format);
}
IDirect3DVertexDeclaration9 *Decl = NULL;
UIntVertexDeclarationMap::iterator it = _VertexDeclarations.find(Types);
if(it == _VertexDeclarations.end())
Decl = _CreateVertexDeclaration(Buffer);
else
Decl = it->second;
HRESULT hr = _D3DDevice->SetVertexDeclaration(Decl);
if(FAILED(hr)) {
LOG_SYS1("Failed setting DX vertex declaration: %s", DXGetErrorString9(hr));
}
hr = _D3DDevice->SetStreamSource(0, _VertexBuffers[Buffer->PoolID].VertexBuffer, Buffer->Offset, Buffer->Stride);
if(FAILED(hr)) {
LOG_SYS1("Failed setting DX stream source: %s", DXGetErrorString9(hr));
}
}
void DirectXRenderer::SetIndexSource(AXIndexBuffer *Buffer) {
if(!Buffer) return;
if(Buffer->IndexFormat == AX_FORMAT_USHORT1) {
_IndexBufferOffset = Buffer->Offset/2;
}
else if(Buffer->IndexFormat = AX_FORMAT_UINT1) {
_IndexBufferOffset = Buffer->Offset/4;
}
if(_IndexBufferID != Buffer->PoolID) {
HRESULT hr = _D3DDevice->SetIndices(_IndexBuffers[Buffer->PoolID].IndexBuffer);
if(FAILED(hr)) {
LOG_SYS1("Failed setting DX index buffer: %s", DXGetErrorString9(hr));
}
else {
_IndexBufferID = Buffer->PoolID;
}
}
}
/* -----------------------------------
Lights
----------------------------------- */
void DirectXRenderer::SetLight(unsigned int Index, AXLightEntity *Light) {
D3DLIGHT9 D3DLight;
ZeroMemory(&D3DLight, sizeof(D3DLight));
switch(Light->Type) {
case AX_LIGHT_POINT: D3DLight.Type = D3DLIGHT_POINT; break;
case AX_LIGHT_DIRECTIONAL: D3DLight.Type = D3DLIGHT_DIRECTIONAL; break;
case AX_LIGHT_SPOT: D3DLight.Type = D3DLIGHT_SPOT; break;
default:
LOG_SYS("Set light failed, invalid light type!");
return;
}
D3DLight.Diffuse.r = Light->Diffuse.r;
D3DLight.Diffuse.g = Light->Diffuse.g;
D3DLight.Diffuse.b = Light->Diffuse.b;
D3DLight.Diffuse.a = Light->Diffuse.a;
D3DLight.Specular.r = Light->Specular.r;
D3DLight.Specular.g = Light->Specular.g;
D3DLight.Specular.b = Light->Specular.b;
D3DLight.Specular.a = Light->Specular.a;
D3DLight.Ambient.r = Light->Ambient.r;
D3DLight.Ambient.g = Light->Ambient.g;
D3DLight.Ambient.b = Light->Ambient.b;
D3DLight.Ambient.a = Light->Ambient.a;
if(Light->Type != AX_LIGHT_DIRECTIONAL) {
D3DLight.Position.x = Light->Position.x;
D3DLight.Position.y = Light->Position.y;
D3DLight.Position.z = Light->Position.z;
if(Light->Range < 0)
D3DLight.Range = 0;
else
D3DLight.Range = Light->Range;
D3DLight.Attenuation0 = Light->Attenuation0/Light->Brightness;
D3DLight.Attenuation1 = Light->Attenuation1/Light->Brightness;
D3DLight.Attenuation2 = Light->Attenuation2/Light->Brightness;
}
if(Light->Type != AX_LIGHT_POINT) {
D3DLight.Direction.x = Light->Direction1.x;
D3DLight.Direction.y = Light->Direction1.y;
D3DLight.Direction.z = Light->Direction1.z;
}
if(Light->Type == AX_LIGHT_SPOT) {
D3DLight.Falloff = Light->Falloff;
D3DLight.Theta = Light->Theta;
D3DLight.Phi = Light->Phi;
}
_D3DDevice->SetLight(Index, &D3DLight);
}
void DirectXRenderer::EnableLight(unsigned int Index) {
_D3DDevice->LightEnable(Index, 1);
}
void DirectXRenderer::DisableLight(unsigned int Index) {
_D3DDevice->LightEnable(Index, 0);
}
/* -----------------------------------
Various functions
----------------------------------- */
IDirect3DVertexDeclaration9* DirectXRenderer::_CreateVertexDeclaration(AXVertexBuffer *Buffer) {
if(!Buffer->Stride) {
LOG_SYS("Warning - failed creating vertex declaration, data is not interleaved!");
return NULL;
};
unsigned int TypeFlags = 0;
unsigned int NumElements = (unsigned int)Buffer->BufferDesc.size();
/* Now we need to create the vertex declaration to tell DirectX what's in the buffer */
D3DVERTEXELEMENT9 *Elements = new D3DVERTEXELEMENT9[NumElements+1];
unsigned int ElementIndex = 0;
unsigned int ByteOffset = 0;
for(unsigned int j=0; j<NumElements; j++) {
AXElementDescription Elem = Buffer->BufferDesc[j];
D3DDECLUSAGE DXUsage;
unsigned int TypeIndex = 0;
if(Elem.Type == AX_ELEM_POSITION) {
TypeFlags |= AX_ELEM_POSITION;
DXUsage = D3DDECLUSAGE_POSITION;
}
else if(Elem.Type == AX_ELEM_NORMAL) {
TypeFlags |= AX_ELEM_NORMAL;
DXUsage = D3DDECLUSAGE_NORMAL;
}
else if(Elem.Type == AX_ELEM_DIFFUSE) {
TypeFlags |= AX_ELEM_DIFFUSE;
DXUsage = D3DDECLUSAGE_COLOR;
}
else if(Elem.Type == AX_ELEM_TEXCOORD0) {
TypeFlags |= AX_ELEM_TEXCOORD0;
DXUsage = D3DDECLUSAGE_TEXCOORD;
TypeIndex = 0;
}
else if(Elem.Type == AX_ELEM_TEXCOORD1) {
TypeFlags |= AX_ELEM_TEXCOORD1;
DXUsage = D3DDECLUSAGE_TEXCOORD;
TypeIndex = 1;
}
else if(Elem.Type == AX_ELEM_TEXCOORD2) {
TypeFlags |= AX_ELEM_TEXCOORD2;
DXUsage = D3DDECLUSAGE_TEXCOORD;
TypeIndex = 2;
}
else if(Elem.Type == AX_ELEM_TEXCOORD3) {
TypeFlags |= AX_ELEM_TEXCOORD3;
DXUsage = D3DDECLUSAGE_TEXCOORD;
TypeIndex = 3;
}
else if(Elem.Type == AX_ELEM_TEXCOORD4) {
TypeFlags |= AX_ELEM_TEXCOORD4;
DXUsage = D3DDECLUSAGE_TEXCOORD;
TypeIndex = 4;
}
else if(Elem.Type == AX_ELEM_TEXCOORD5) {
TypeFlags |= AX_ELEM_TEXCOORD5;
DXUsage = D3DDECLUSAGE_TEXCOORD;
TypeIndex = 5;
}
else if(Elem.Type == AX_ELEM_TEXCOORD6) {
TypeFlags |= AX_ELEM_TEXCOORD6;
DXUsage = D3DDECLUSAGE_TEXCOORD;
TypeIndex = 6;
}
else if(Elem.Type == AX_ELEM_TEXCOORD7) {
TypeFlags |= AX_ELEM_TEXCOORD7;
DXUsage = D3DDECLUSAGE_TEXCOORD;
TypeIndex = 7;
}
/* Map our types to DirectX's types */
D3DDECLTYPE DXType = D3DDECLTYPE_UNUSED;
AXDataFormat AXFormat = Elem.Format;
switch(AXFormat) {
case AX_FORMAT_FLOAT1: DXType = D3DDECLTYPE_FLOAT1; break;
case AX_FORMAT_FLOAT2: DXType = D3DDECLTYPE_FLOAT2; break;
case AX_FORMAT_FLOAT3: DXType = D3DDECLTYPE_FLOAT3; break;
case AX_FORMAT_FLOAT4: DXType = D3DDECLTYPE_FLOAT4; break;
case AX_FORMAT_UINT1: DXType = D3DDECLTYPE_D3DCOLOR; break;
case AX_FORMAT_UBYTE4: DXType = D3DDECLTYPE_UBYTE4; break;
case AX_FORMAT_SHORT2: DXType = D3DDECLTYPE_SHORT2; break;
case AX_FORMAT_SHORT4: DXType = D3DDECLTYPE_SHORT4; break;
default: DXType = D3DDECLTYPE_UNUSED;
}
D3DVERTEXELEMENT9 TempElem = { 0, ByteOffset, DXType, D3DDECLMETHOD_DEFAULT, DXUsage, TypeIndex };
Elements[ElementIndex++] = TempElem;
ByteOffset += GetElementSizeInBytes(Elem.Format);
}
D3DVERTEXELEMENT9 TempElem = D3DDECL_END();
Elements[ElementIndex++] = TempElem;
IDirect3DVertexDeclaration9 *Declaration;
HRESULT hr = _D3DDevice->CreateVertexDeclaration(Elements, &Declaration);
SafeDelete(Elements);
if(FAILED(hr)) {
LOG_SYS2("Failed creating vertex declaration! Types: %x Error: %s", TypeFlags, DXGetErrorString9(hr));
return NULL;
}
_VertexDeclarations[TypeFlags] = Declaration;
return Declaration;
}
/* -----------------------------------
Private internal functions
----------------------------------- */
void DirectXRenderer::_SetDXDefaults() {
AXDimension2D ScreenSize = GetScreenSize();
/* Default Matrices */
AXMatrix4 TempMatrix;
D3DXMatrixIdentity(&TempMatrix);
LoadMatrix(AX_MATRIX_WORLD, &TempMatrix);
D3DXMatrixLookAtLH(&TempMatrix, &AXVector3(0.0f, 0.0f, 0.0f), &AXVector3(0.0f, 0.0f, 1.0f), &AXVector3(0.0f, 1.0f, 0.0f));
LoadMatrix(AX_MATRIX_VIEW, &TempMatrix);
D3DXMatrixPerspectiveFovLH(&TempMatrix, 45.0f, (float)ScreenSize.x/(float)ScreenSize.y, 0.5f, 1000.0f);
LoadMatrix(AX_MATRIX_PROJECTION, &TempMatrix);
for(unsigned int i=0; i<AX_MAXRENDERSTATES; i++) {
if(_SetRenderStates[i] != (unsigned int)-1) {
SetRenderState((AXRenderState)i, _SetRenderStates[i]);
}
}
}
AXResult DirectXRenderer::_GetPresentationParam(D3DPRESENT_PARAMETERS *Present_Param) {
ZeroMemory(Present_Param, sizeof(D3DPRESENT_PARAMETERS));
D3DFORMAT BackBufferFormat;
D3DFORMAT DepthStencilFormat;
/* We do quite different things if we are in fullscreen or not */
if(AXBaseSystem::GetWindow()->Settings.GetSetting<int>("fullscreen")) {
Present_Param->BackBufferWidth = (unsigned int)AXBaseSystem::GetWindow()->Settings.GetSetting<int>("fullscreenWidth");
Present_Param->BackBufferHeight = (unsigned int)AXBaseSystem::GetWindow()->Settings.GetSetting<int>("fullscreenHeight");
Present_Param->FullScreen_RefreshRateInHz = (unsigned int)AXBaseSystem::GetWindow()->Settings.GetSetting<int>("fullscreenRefreshRate");
Present_Param->Windowed = 0;
}
else {
Present_Param->Windowed = 1;
}
/* Get the back buffer format */
BackBufferFormat = _GetBestBackBufferFormat();
if(BackBufferFormat == (D3DFORMAT)0) {
LOG_SYS("A supported back buffer format could not be found!");
return AXFAILURE;
}
_BackBufferFormat = BackBufferFormat;
/* Get the depth stencil format */
DepthStencilFormat = _GetBestDepthStencilFormat();
if(DepthStencilFormat == (D3DFORMAT)0) {
LOG_SYS("A supported depth stencil format could not be found!");
return AXFAILURE;
}
_DepthStencilFormat = DepthStencilFormat;
/* Fill in the last of the required values */
Present_Param->BackBufferFormat = BackBufferFormat;
Present_Param->EnableAutoDepthStencil = 1;
Present_Param->AutoDepthStencilFormat = DepthStencilFormat;
Present_Param->PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
Present_Param->BackBufferCount = 2;
Present_Param->SwapEffect = D3DSWAPEFFECT_DISCARD;
return AXSUCCESS;
}
D3DFORMAT DirectXRenderer::_GetCurrentAdapterFormat() {
if(AXBaseSystem::GetWindow()->Settings.GetSetting<int>("fullscreen")) {
return D3DFMT_X8R8G8B8;
}
else {
D3DDISPLAYMODE dm;
_D3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dm);
return dm.Format;
}
}
D3DFORMAT DirectXRenderer::_GetBestBackBufferFormat() {
D3DFORMAT AdapterFormat;
D3DFORMAT BackBufferFormat;
int ForcedBackBufferBpp;
AdapterFormat = _GetCurrentAdapterFormat();
ForcedBackBufferBpp = Settings.GetSetting<int>("screenBpp");
/* This gets the closest back buffer format to the adapter format */
if(ForcedBackBufferBpp == -1 && !AXBaseSystem::GetWindow()->Settings.GetSetting<int>("fullscreen")) {
if(AdapterFormat == D3DFMT_R5G6B5 || AdapterFormat == D3DFMT_X1R5G5B5)
ForcedBackBufferBpp = 16;
}
/* Figure out an appropriate screen format. This just goes through and tries every format.
Obviously we check the best formats first and go down from there. That way when it finds a supported
format, we know its the best we can get with this hardware. */
if( ForcedBackBufferBpp != 16 &&
AXSUCCEEDED(_IsBackBufferFormatAvailable(AdapterFormat, D3DFMT_A8R8G8B8)) ) {
LOG_SYS("32-bit screen format found: A8R8G8B8");
BackBufferFormat = D3DFMT_A8R8G8B8;
}
else if( ForcedBackBufferBpp != 16 &&
AXSUCCEEDED(_IsBackBufferFormatAvailable(AdapterFormat, D3DFMT_A2R10G10B10)) ) {
LOG_SYS("32-bit screen format found: A2R10G10B10");
BackBufferFormat = D3DFMT_A2R10G10B10;
}
else if( ForcedBackBufferBpp != 16 &&
AXSUCCEEDED(_IsBackBufferFormatAvailable(AdapterFormat, D3DFMT_X8R8G8B8)) ) {
LOG_SYS("32-bit screen format found: X8R8G8B8");
BackBufferFormat = D3DFMT_X8R8G8B8;
}
else if (ForcedBackBufferBpp == 32) {
LOG_SYS("Could not find a supported 32-bit back buffer format! Try changing the setting to 16-bit.");
return (D3DFORMAT)0;
}
else if( AXSUCCEEDED(_IsBackBufferFormatAvailable(AdapterFormat, D3DFMT_R5G6B5)) ) {
LOG_SYS("16-bit screen format found: R5G6B5");
BackBufferFormat = D3DFMT_R5G6B5;
}
else if( AXSUCCEEDED(_IsBackBufferFormatAvailable(AdapterFormat, D3DFMT_X1R5G5B5)) ) {
LOG_SYS("16-bit screen format found: X1R5G5B5");
BackBufferFormat = D3DFMT_X1R5G5B5;
}
else {
LOG_SYS("16-bit back buffer format could not be found. If you set 16-bits in the settings, try changing it to 32-bits.");
return (D3DFORMAT)0;
}
return BackBufferFormat;
}
D3DFORMAT DirectXRenderer::_GetBestDepthStencilFormat() {
D3DFORMAT AdapterFormat;
D3DFORMAT BackBufferFormat;
D3DFORMAT DepthStencilFormat;
int ForcedDepthStencilBpp;
AdapterFormat = _GetCurrentAdapterFormat();
BackBufferFormat = _BackBufferFormat;
ForcedDepthStencilBpp = Settings.GetSetting<int>("depthBpp");
/* Go through and test all the formats */
if( ForcedDepthStencilBpp != 16 &&
AXSUCCEEDED(_IsDepthStencilFormatAvailable(AdapterFormat, D3DFMT_D24S8)) &&
AXSUCCEEDED(_IsDepthStencilFormatCompatible(AdapterFormat, BackBufferFormat, D3DFMT_D24S8)) ) {
DepthStencilFormat = D3DFMT_D24S8;
LOG_SYS("Best 32-bit depth stencil buffer found: D24S8");
}
else if( ForcedDepthStencilBpp != 16 &&
AXSUCCEEDED(_IsDepthStencilFormatAvailable(AdapterFormat, D3DFMT_D24X4S4)) &&
AXSUCCEEDED(_IsDepthStencilFormatCompatible(AdapterFormat, BackBufferFormat, D3DFMT_D24X4S4)) ) {
DepthStencilFormat = D3DFMT_D24X4S4;
LOG_SYS("Best 32-bit depth stencil buffer found: D24X4S4");
}
else if( ForcedDepthStencilBpp != 16 &&
AXSUCCEEDED(_IsDepthStencilFormatAvailable(AdapterFormat, D3DFMT_D32)) &&
AXSUCCEEDED(_IsDepthStencilFormatCompatible(AdapterFormat, BackBufferFormat, D3DFMT_D32)) ) {
DepthStencilFormat = D3DFMT_D32;
LOG_SYS("Best 32-bit depth stencil buffer found: D32");
}
else if( ForcedDepthStencilBpp != 16 &&
AXSUCCEEDED(_IsDepthStencilFormatAvailable(AdapterFormat, D3DFMT_D24X8)) &&
AXSUCCEEDED(_IsDepthStencilFormatCompatible(AdapterFormat, BackBufferFormat, D3DFMT_D24X8)) ) {
DepthStencilFormat = D3DFMT_D24X8;
LOG_SYS("Best 32-bit depth stencil buffer found: D24X8");
}
else if(ForcedDepthStencilBpp == 32) {
LOG_SYS("Could not find supported 32-bit format for depth stencil! Try changing the 'depthBpp' setting to 16-bit, or taking it out altogether.");
return (D3DFORMAT)0;
}
else if( AXSUCCEEDED(_IsDepthStencilFormatAvailable(AdapterFormat, D3DFMT_D15S1)) &&
AXSUCCEEDED(_IsDepthStencilFormatCompatible(AdapterFormat, BackBufferFormat, D3DFMT_D15S1)) ) {
DepthStencilFormat = D3DFMT_D15S1;
LOG_SYS("Best 16-bit depth stencil buffer found: D15S1");
}
else if( AXSUCCEEDED(_IsDepthStencilFormatAvailable(AdapterFormat, D3DFMT_D16)) &&
AXSUCCEEDED(_IsDepthStencilFormatCompatible(AdapterFormat, BackBufferFormat, D3DFMT_D16)) ) {
DepthStencilFormat = D3DFMT_D16;
LOG_SYS("Best 16-bit depth stencil buffer found: D16");
}
else if(ForcedDepthStencilBpp == 16) {
LOG_SYS("Could not find supported 16-bit format for depth stencil! Try changing the 'depthBpp' setting to 32-bit, or taking it out altogether.");
return (D3DFORMAT)0;
}
else {
LOG_SYS("Could not find supported format for depth stencil!");
return (D3DFORMAT)0;
}
return DepthStencilFormat;
}
AXResult DirectXRenderer::_IsBackBufferFormatAvailable(D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat) {
HRESULT hr = _D3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, _DeviceType, AdapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, BackBufferFormat);
if(FAILED(hr))
return AXFAILURE;
return AXSUCCESS;
}
AXResult DirectXRenderer::_IsDepthStencilFormatAvailable(D3DFORMAT AdapterFormat, D3DFORMAT DepthStencilFormat) {
HRESULT hr = _D3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, _DeviceType, AdapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, DepthStencilFormat);
if(FAILED(hr))
return AXFAILURE;
return AXSUCCESS;
}
AXResult DirectXRenderer::_IsDepthStencilFormatCompatible(D3DFORMAT AdapterFormat, D3DFORMAT RenderFormat, D3DFORMAT DepthStencilFormat) {
HRESULT hr = _D3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, _DeviceType, AdapterFormat, RenderFormat, DepthStencilFormat);
if(FAILED(hr))
return AXFAILURE;
return AXSUCCESS;
}
| [
"longster@gmail.com"
] | longster@gmail.com |
d47fa6fe88fa39f6dcb1d6525e5c1efd8114bf61 | ec7dd685f5fac24e3a266d3757486336b23fd06d | /GameEngineTK/Player.cpp | 735abeff72a011535b548e9544eb5f5a63355506 | [] | no_license | Shibayama73/GameEngineTK | 507f451269e59c94aebce6244af2954b726a7e3a | 26ac4ceeadf008822df0f2f7ad322169e4bd9d06 | refs/heads/master | 2021-01-19T14:07:29.314834 | 2017-07-11T07:47:07 | 2017-07-11T07:47:07 | 88,127,978 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 9,913 | cpp | // プレイヤークラス
#include "Player.h"
using namespace DirectX;
using namespace DirectX::SimpleMath;
using Microsoft::WRL::ComPtr;
void Player::Initialize(DirectX::Keyboard* keyboard, DirectX::Keyboard::KeyboardStateTracker* tracker)
{
// キーボードの生成
m_keyboard = keyboard;
// トリガーの生成
m_tracker = tracker;
// 自機パーツの読み込み
m_ObjPlayer.resize(PLAYER_PARTS_NUM);
m_ObjPlayer[PLAYER_PARTS_TIRE].LoadModel(L"Resources/tire.cmo");
m_ObjPlayer[PLAYER_PARTS_HEAD].LoadModel(L"Resources/head.cmo");
m_ObjPlayer[PLAYER_PARTS_ARM_RIGHT].LoadModel(L"Resources/arm_right.cmo");
m_ObjPlayer[PLAYER_PARTS_ARM_LEFT].LoadModel(L"Resources/arm_right.cmo");
m_ObjPlayer[PLAYER_PARTS_TOP].LoadModel(L"Resources/top.cmo");
// 親子関係の構築(子パーツに親を設定)
m_ObjPlayer[PLAYER_PARTS_HEAD].SetObjParent(&m_ObjPlayer[PLAYER_PARTS_TIRE]);
m_ObjPlayer[PLAYER_PARTS_ARM_RIGHT].SetObjParent(&m_ObjPlayer[PLAYER_PARTS_HEAD]);
m_ObjPlayer[PLAYER_PARTS_ARM_LEFT].SetObjParent(&m_ObjPlayer[PLAYER_PARTS_HEAD]);
m_ObjPlayer[PLAYER_PARTS_TOP].SetObjParent(&m_ObjPlayer[PLAYER_PARTS_HEAD]);
// 子パーツの親からのオフセット(座標のずれ)をセット
m_ObjPlayer[PLAYER_PARTS_HEAD].SetTranslation(Vector3(0, 0.1f, 0));
m_ObjPlayer[PLAYER_PARTS_ARM_RIGHT].SetTranslation(Vector3(0.25f, 0.2f, 0));
m_ObjPlayer[PLAYER_PARTS_ARM_LEFT].SetTranslation(Vector3(-0.25f, 0.2f, 0));
m_ObjPlayer[PLAYER_PARTS_TOP].SetTranslation(Vector3(0, 0.2f, 0.3f));
// 大きさ
m_ObjPlayer[PLAYER_PARTS_TIRE].SetScale(Vector3(2, 2, 2));
// 翼の向き
m_ObjPlayer[PLAYER_PARTS_ARM_RIGHT].SetRotation(Vector3(0, -30.0f, 0));
m_ObjPlayer[PLAYER_PARTS_ARM_LEFT].SetRotation(Vector3(0, 30.0f, 0));
// 状態の初期化(オフ)
m_plsyerState = false;
// 弾丸発射フラグ(オフ)
m_bulletFlag = false;
// 弾丸発射カウント
m_bulletCount = 0;
{// 弾丸用当たり判定ノードの設定
m_CollisionNodeBullet.Initialize();
// 親パーツを設定
m_CollisionNodeBullet.SetParent(&m_ObjPlayer[PLAYER_PARTS_TOP]);
m_CollisionNodeBullet.SetTrans(Vector3(0,0.3f,0));
m_CollisionNodeBullet.SetLocalRadius(0.3f);
}
{// 本体の当たり判定ノードの設定
m_CollisionNodeBody.Initialize();
// 親パーツのを設定
m_CollisionNodeBody.SetParent(&m_ObjPlayer[PLAYER_PARTS_TIRE]);
m_CollisionNodeBody.SetTrans(Vector3(0, 0.1f, 0));
m_CollisionNodeBody.SetLocalRadius(0.1f);
}
// ジャンプフラグをオフ
m_isJump = false;
}
void Player::Update()
{
//// 自機の大きさの設定
//m_cycle += 0.1f;
//float scale = 1.0f + sinf(m_cycle);
//m_ObjPlayer[PLAYER_PARTS_HEAD].SetScale(Vector3(scale, scale, scale));
// キーボードの状態取得
Keyboard::State key = m_keyboard->GetState();
m_tracker->Update(key);
if (m_tracker->IsKeyPressed(Keyboard::Keys::Z))
{
// ジャンプする
StartJump();
}
// ジャンプ中のとき
if (m_isJump)
{
// 重力による加速
m_Velocity.y -= GRAVITY_ACC;
if (m_Velocity.y < -JUMP_SPEED_MAX)
{
m_Velocity.y = -JUMP_SPEED_MAX;
}
}
{// 速度による移動
Vector3 trans = GetTranslation();
trans += m_Velocity;
SetTranslation(trans);
}
// Xキーが押されたとき
if (m_tracker->pressed.X)
{
// 自機の状態がオフのとき
if (m_plsyerState == false)
{
// 変形する
m_ObjPlayer[PLAYER_PARTS_HEAD].SetTranslation(Vector3(0, 0.6f, 0));
m_ObjPlayer[PLAYER_PARTS_HEAD].SetRotation(Vector3(1.5f, 0, 0));
m_ObjPlayer[PLAYER_PARTS_ARM_RIGHT].SetRotation(Vector3(0, 1.5f, -1.8f));
m_ObjPlayer[PLAYER_PARTS_ARM_LEFT].SetRotation(Vector3(0, -1.5f, 1.8f));
m_ObjPlayer[PLAYER_PARTS_TOP].SetTranslation(Vector3(0, 0, -0.1f));
m_ObjPlayer[PLAYER_PARTS_TOP].SetRotation(Vector3(5.0f, 0, 0));
// 状態をオン
m_plsyerState = true;
}
else
{
// 子パーツの親からのオフセット(座標のずれ)をセット
m_ObjPlayer[PLAYER_PARTS_HEAD].SetTranslation(Vector3(0, 0.1f, 0));
m_ObjPlayer[PLAYER_PARTS_ARM_RIGHT].SetTranslation(Vector3(0.25f, 0.2f, 0));
m_ObjPlayer[PLAYER_PARTS_ARM_LEFT].SetTranslation(Vector3(-0.25f, 0.2f, 0));
m_ObjPlayer[PLAYER_PARTS_TOP].SetTranslation(Vector3(0, 0.2f, 0.3f));
// 翼の向き
m_ObjPlayer[PLAYER_PARTS_ARM_RIGHT].SetRotation(Vector3(0, -30.0f, 0));
m_ObjPlayer[PLAYER_PARTS_ARM_LEFT].SetRotation(Vector3(0, 30.0f, 0));
// 状態をオフ
m_plsyerState = false;
}
}
// Wキーが押されてるとき前進
if (key.W)
{
// 移動ベクトル(Z座標前進)
Vector3 moveV(0, 0, -0.15f);
// 回転
float angle = m_ObjPlayer[0].GetRotation().y;
Matrix rotmat = Matrix::CreateRotationY(angle);
// 移動ベクトルを自機の角度分回転させる
moveV = Vector3::TransformNormal(moveV, rotmat);
//moveV = Vector3::TransformNormal(moveV, m_worldHead);
//Matrix rotmaty = Matrix::CreateRotationY(XMConvertToRadians(headAngle));
//moveV = Vector3::TransformNormal(moveV, rotmaty);
Vector3 pos = m_ObjPlayer[0].GetTranslation();
m_ObjPlayer[0].SetTranslation(pos + moveV);
// 自機の座標を移動
m_headPos += moveV;
}
// Sキーが押されてるとき後退
if (key.S)
{
// 移動ベクトル(Z座標後退)
Vector3 moveV(0, 0, 0.1f);
// 回転
float angle = m_ObjPlayer[0].GetRotation().y;
Matrix rotmat = Matrix::CreateRotationY(angle);
// 移動ベクトルを自機の角度分回転させる
moveV = Vector3::TransformNormal(moveV, rotmat);
Vector3 pos = m_ObjPlayer[0].GetTranslation();
m_ObjPlayer[0].SetTranslation(pos + moveV);
// 移動ベクトルを自機の角度分回転させる
// moveV = Vector3::TransformNormal(moveV, m_worldHead);
//Matrix rotmaty = Matrix::CreateRotationY(XMConvertToRadians(headAngle));
//moveV = Vector3::TransformNormal(moveV, rotmaty);
// 自機の座標を移動
m_headPos += moveV;
}
// Aキーが押されてるとき左旋回
if (key.A)
{
// 左に旋回する
float angle = m_ObjPlayer[0].GetRotation().y;
m_ObjPlayer[0].SetRotation(Vector3(0, angle + 0.03f, 0));
//headAngle += 0.1f;
//// 移動ベクトル左(X座標後退)
//Vector3 moveV(-0.1f, 0, 0);
//// 自機の座標を移動
//m_headPos += moveV;
}
// Dキーが押されてるとき右旋回
if (key.D)
{
// 右に旋回する
float angle = m_ObjPlayer[0].GetRotation().y;
m_ObjPlayer[0].SetRotation(Vector3(0, angle - 0.03f, 0));
//headAngle -= 0.1f;
//// 移動ベクトル左(X座標前進)
//Vector3 moveV(0.1f, 0, 0);
//// 自機の座標を移動
//m_headPos += moveV;
}
// Spaceキーが押されたら
if(key.Space)
{
// 弾丸発射フラグをオン
m_bulletFlag = true;
}
// 弾丸発射フラグがオンのとき
if (m_bulletFlag)
{
m_bulletCount++;
// 3秒経ったら
if (m_bulletCount >= 180) {
m_bulletCount = 0;
// 弾丸発射フラグをオフ
m_bulletFlag = false;
}
// 弾丸パーツを発射
FireBullet();
// 弾丸パーツの座標の移動
Vector3 pos = m_ObjPlayer[PLAYER_PARTS_TOP].GetTranslation();
// 弾丸パーツの前進
m_ObjPlayer[PLAYER_PARTS_TOP].SetTranslation(pos + m_BulletVel);
}
// 弾丸発射フラグがオフのとき
else {
// 弾丸パーツをもとに戻す
ResetBuller();
}
this->Calc();
// デバッグ用
//FireBullet();
}
void Player::Draw()
{
// 自機オブジェクトの描画
for (std::vector<Obj3d>::iterator it = m_ObjPlayer.begin();
it != m_ObjPlayer.end();
it++)
{
it->Draw();
}
// 弾丸用当たり判定ノード
m_CollisionNodeBullet.Draw();
// 本体用当たり判定ノード
m_CollisionNodeBody.Draw();
}
void Player::FireBullet()
{
// 発射するパーツのワールド行列を取得
Matrix worldm = m_ObjPlayer[PLAYER_PARTS_TOP].GetWorld();
// 抽出した情報をしまっておく変数
Vector3 scale; //ワールドスケーリング
Quaternion rotation; //ワールド回転
Vector3 translation; //ワールド座標
// ワールド行列から各要素を抽出
worldm.Decompose(scale, rotation, translation);
// 親パーツから分離、独立させる
m_ObjPlayer[PLAYER_PARTS_TOP].SetObjParent(nullptr);
m_ObjPlayer[PLAYER_PARTS_TOP].SetScale(scale);
m_ObjPlayer[PLAYER_PARTS_TOP].SetRotationQ(rotation);
m_ObjPlayer[PLAYER_PARTS_TOP].SetTranslation(translation);
// 弾丸パーツの速度を設定
m_BulletVel = Vector3(0, 0, -0.3f);
// パーツの向きに合わせて速度ベクトルを回転
m_BulletVel = Vector3::Transform(m_BulletVel, rotation);
}
// 弾丸を最装着(リセット)
void Player::ResetBuller()
{
// 親子関係の再構築(子パーツに親を設定)
m_ObjPlayer[PLAYER_PARTS_TOP].SetObjParent(&m_ObjPlayer[PLAYER_PARTS_HEAD]);
// 子パーツの親からのオフセット(座標のずれ)をリセット
m_ObjPlayer[PLAYER_PARTS_TOP].SetTranslation(Vector3(0, 0.2f, 0.3f));
// 回転角のリセット
m_ObjPlayer[PLAYER_PARTS_TOP].SetRotation(Vector3(0, 0, 0));
// 大きさのリセット
m_ObjPlayer[PLAYER_PARTS_TOP].SetScale(Vector3(1, 1, 1));
}
void Player::Calc()
{
// 自機オブジェクトの更新
for (std::vector<Obj3d>::iterator it = m_ObjPlayer.begin();
it != m_ObjPlayer.end();
it++)
{
it->Update();
}
// 弾丸用当たり判定ノード
m_CollisionNodeBullet.Update();
// 本体用の当たり判定ノード
m_CollisionNodeBody.Update();
}
/// <summary>
/// ジャンプを開始
/// </summary>
void Player::StartJump()
{
if (!m_isJump)
{
m_Velocity.y = JUMP_SPEED_FIRST;
m_isJump = true;
}
}
/// <summary>
/// 落下を開始
/// </summary>
void Player::StartFall()
{
if (!m_isJump)
{
m_Velocity.y = 0;
m_isJump = true;
}
}
/// <summary>
/// 落下を終了
/// </summary>
void Player::StopJump()
{
m_isJump = false;
m_Velocity = Vector3::Zero;
}
| [
"jobwave2019@gmail.com"
] | jobwave2019@gmail.com |
5997ef35c20d87537d33d6ed7e7a96fbbc3c2022 | e7db57e8617bb3a8c25bb1b480c68199174bf8c9 | /codeforces/round181/empire.cpp | 956d5f22279c85d4dd886469089f325cf0e7a544 | [] | no_license | jccarvalhosa/maratona | d30901e93b10d37afa812645dbcbcb81d46780ec | ef2a353c9eee4006c314d5c8f81ff9ffbbb26537 | refs/heads/master | 2021-01-17T09:05:23.847740 | 2016-04-10T22:24:15 | 2016-04-10T22:24:15 | 7,139,493 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,202 | cpp | #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MAXN 10000001
#define MAXK 1000001
int lp[MAXN], p[MAXN], a[MAXK], s;
ll c[MAXN], m[MAXN];
void sieve(int n) {
int i, j;
s=0;
for(i=2;i<=n;i++) lp[i] = 1;
for(i=2;i<=n;i++) if(lp[i] == 1) {
p[s++] = lp[i] = i;
for(j=i+i;j<=n;j+=i) lp[j] = i;
}
}
void count(int n, int k) {
int i;
for(i=2;i<=n;i++) c[i] = m[i] = 0;
for(i=0;i<k;i++) c[a[i]]++;
for(i=n-1;i>=2;i--) c[i] += c[i+1];
for(i=n;i>=2;i--) {
m[lp[i]] += c[i];
if(lp[i] != i) c[i/lp[i]] += c[i];
}
}
ll sum(ll p, ll n) { return n==0 ? 0 : n%p + sum(p, n/p); }
ll mult(ll p, ll n) { return (n - sum(p, n))/(p-1); }
int valid(ll n) {
if(n<=0) return 0;
for(int i=0;i<s;i++) if(mult(p[i], n) < m[p[i]]) return 0;
return 1;
}
ll lower_bound(ll i, ll f) {
while(1) {
ll m = (i+f)/2;
if(valid(m)) {
if(!valid(m-1)) return m;
f = m-1;
} else {
if(valid(m+1)) return m+1;
i = m+1;
}
}
}
int main() {
int n=0, k, i;
ll sum=0;
cin>>k;
for(i=0;i<k;i++) {
cin>>a[i];
sum += a[i];
n = max(n, a[i]);
}
sieve(n);
count(n, k);
cout << lower_bound(1, sum) << endl;
return 0;
}
| [
"jocarvalhosa@gmail.com"
] | jocarvalhosa@gmail.com |
cc099c608550c0f26767daa9587b429e33ae14f8 | 0f1e3b0014c5ff62ae9591832f65600245a403e4 | /src/libseabreeze/src/vendors/OceanOptics/protocols/obp/impls/OBPAcquisitionDelayProtocol.cpp | ae8b008ba47cecfca5f949d7309bfa93d73b50ba | [
"MIT"
] | permissive | ap--/python-seabreeze | a5528f4d6043755e7f2e60ae181bb0eb4c1f38f8 | d312056d0d4c144ddd77bd783535ac9b2fb45f12 | refs/heads/main | 2023-08-17T04:10:06.552715 | 2023-07-10T22:11:03 | 2023-07-10T22:11:03 | 25,327,268 | 189 | 92 | MIT | 2023-09-11T22:39:25 | 2014-10-16T23:30:21 | C++ | UTF-8 | C++ | false | false | 2,684 | cpp | /***************************************************//**
* @file OBPAcquisitionDelayProtocol.cpp
* @date November 2015
* @author Ocean Optics, Inc.
*
* LICENSE:
*
* SeaBreeze Copyright (C) 2015, Ocean Optics Inc
*
* 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.
*******************************************************/
#include "common/globals.h"
#include "vendors/OceanOptics/protocols/obp/impls/OBPAcquisitionDelayProtocol.h"
#include "vendors/OceanOptics/protocols/obp/exchanges/OBPSetAcquisitionDelayExchange.h"
#include "vendors/OceanOptics/protocols/obp/impls/OceanBinaryProtocol.h"
#include "common/exceptions/ProtocolBusMismatchException.h"
using namespace seabreeze;
using namespace seabreeze::oceanBinaryProtocol;
using namespace std;
OBPAcquisitionDelayProtocol::OBPAcquisitionDelayProtocol()
: AcquisitionDelayProtocolInterface(new OceanBinaryProtocol()) {
}
OBPAcquisitionDelayProtocol::~OBPAcquisitionDelayProtocol() {
}
void OBPAcquisitionDelayProtocol::setAcquisitionDelayMicroseconds(
const Bus &bus, const unsigned long delayMicros) {
TransferHelper *helper;
OBPSetAcquisitionDelayExchange exchange;
helper = bus.getHelper(exchange.getHints());
if (NULL == helper) {
string error("Failed to find a helper to bridge given protocol and bus.");
throw ProtocolBusMismatchException(error);
}
exchange.setAcquisitionDelayMicros(delayMicros);
bool retval = exchange.sendCommandToDevice(helper);
if(false == retval) {
string error("Device rejected acquisition delay command. Is the value legal?");
throw ProtocolException(error);
}
}
| [
"andreas@poehlmann.io"
] | andreas@poehlmann.io |
b1203104f619eb1bae1f4e255e4edb0af4d66f9d | cf932a79552cbd7cd3769f05651055b78e4f74b8 | /FlexProject/Public/MyActorComponent.h | 1c653a3a3c54dcd2e87f0cea886ab622d835b859 | [] | no_license | TheWiselyBearded/SWISH | ab266ff370cac9e2dfc30ba41b9e001e33b350b0 | 41b3d95bbd9c08ada58b8aa43516f7a3577dfed4 | refs/heads/master | 2020-03-30T02:55:42.238632 | 2018-09-28T00:41:01 | 2018-09-28T00:41:01 | 150,658,321 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 936 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "GameFramework/Actor.h"
#include "MyActorComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class FLEXPROJECT_API UMyActorComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UMyActorComponent();
protected:
// Called when the game starts
virtual void BeginPlay() override;
virtual void BeginDestroy() override;
//virtual void UMyActorComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
//void Tick(float DeltaTime);
public:
// Called every frame
//virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};
| [
"abahrema@asu.edu"
] | abahrema@asu.edu |
1a3d843a3c134af4861fe16ee9641c75e26dda6d | d5bc5cce78d72417536aece268f1235d61b0af59 | /logger.h | 9eb838650b8c2533693e9b98c2cb8cd67638bb3a | [] | no_license | xsq000/WebServer | 92ba514ba059783fd09bcfb50ec3fcb6b7e371e9 | 5decd1268ba77d814d3c7378c7ffa93a243c4e4b | refs/heads/main | 2023-06-09T14:13:41.345349 | 2021-07-03T13:30:36 | 2021-07-03T14:36:29 | 379,845,060 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,447 | h | // 作者:xsq
// 文件内容:定义了一个日志记录器
// 文件功能:进行正常运行的日志记录及错误信息记录
#pragma once
#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <memory>
class Logger
{
private:
Logger() {}
Logger(const Logger &) {}
Logger &operator=(const Logger &) { return *this; }
static std::shared_ptr<Logger> instance_;
public:
// 获取日志记录器的实例
static std::shared_ptr<Logger> GetInstance() { return instance_; }
// 输出指定信息到日志文件中
static void Log(const std::string &message);
// 输出指定信息到错误文件中,同时也会输出到日志文件中
static void Error(const std::string &message);
private:
// 设置日志文件
static void SetLogFile(const std::string &log_filename) { Logger::log_filename_ = log_filename; }
// 设置错误信息文件
static void SetErrorFile(const std::string &error_filename) { Logger::error_filename_ = error_filename; }
static std::string GetTime();
static std::string GetDate();
static std::string log_filename_; // 运行日志文件名
static std::string error_filename_; // 错误信息日志文件名
static std::ofstream log_ofstream_; // 负责输出运行日志
static std::ofstream error_ofstream_; // 负责输出错误信息
};
| [
"13121210093@163.com"
] | 13121210093@163.com |
a3bfcbe89040f099013841e7f165156b2c9a7465 | b7e98a2cebdb230858f6daedf53ff963a44163e2 | /src/test/10_simd/main.cpp | 620ee77e2d7a893d6ba6f0ae1d392cba3c6e5692 | [
"MIT"
] | permissive | cyhunter/UGM | 68a654c0a702da57a0147a7d4cc19558b425b09f | 2f8f846d989455ddfb8ec5252d049e5c4b83c4df | refs/heads/master | 2023-02-20T00:10:17.808120 | 2021-01-20T10:28:21 | 2021-01-20T10:28:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,823 | cpp | #include <iostream>
#include <UGM/vec.h>
#include <UGM/point.h>
#include <UGM/mat.h>
using namespace Ubpa;
using namespace std;
int main(int argc, char* argv[])
{
//{// vecf4
// vecf4 a;
// vecf4 b;
// cin >> a >> b;
// cout << a + b << endl;
// cout << a.dot(b) << endl;
//}
//{// pointf4
// pointf4 p0, p1;
// cin >> p0 >> p1;
// p0 -= vecf4{ 1,1,1,1 };
// cout << p0 - p1 << endl;
//}
//{ // matrix mul
// matf4 m1, m2;
// cin >> m1 >> m2;
// auto m1m2 = m1 * m2;
// cout << m1m2 << endl;
//}
//{// matrix inverse
// matf4 m;
// cin >> m;
// (m * m.inverse()).print();
//}
//{ // cast and []
// {
// vecf4 v;
// cin >> v;
// pointf3 p = v.cast_to<pointf3>();
// cout << p << endl;
// }
// {
// vecf4 v;
// cin >> v;
// pointf3 q{ v[0], v[1], v[2] };
// cout << q << endl;
// }
//}
//{ // min
// vecf4 s;
// cin >> s;
// const vecf4 ss = s;
// auto rst = ss.min_component();
// cout << rst << endl;
//}
//{
// linef3 l;
// cin >> l;
// bboxf3 b0, b1;
// cin >> b0 >> b1;
// // 36 and have loop
// //auto [success, t0, t1] = l.intersect(b);
// // 33 and have loop without simd
// auto invdir = l.inv_dir();
// auto [success0, t00, t01] = l.intersect(b0, invdir);
// cout << success0 << t00 << t01 << endl;
// // 26
// auto [success1, t10, t11] = l.intersect(b1, invdir);
// cout << success1 << t10 << t11 << endl;
//}
/*{
vecf4 u, v;
cin >> u >> v;
cout << vecf4::v3_dot(u, v) << endl;
cout << vecf4::v3_cross(u, v) << endl;
}*/
//{
// linef3 l;
// trianglef3 tri;
// cin >> l >> tri;
// l.print();
// cout << tri << endl;
// // 103 -> 58
// auto [s, uwv, t] = l.intersect(tri);
// cout << s << endl;
// cout << uwv[0] << ", " << uwv[1] << ", " << uwv[2] << endl;
// cout << t << endl;
//}
//{
// pointf3 p;
// vecf3 d;
// cin >> p >> d;
// rayf3 r{ p,d };
// auto [isIntersect0, t0, uv] = r.intersect_std_disk();
// cout << isIntersect0 << ", " << t0 << ", " << uv[0] << ", " << uv[1] << ", " << endl;
// // 51 -> 36
// auto [isIntersect, t] = r.intersect_std_sphere();
// cout << isIntersect << endl << t << endl;
//}
{
matf4 m;
cin >> m;
auto tm = m.transpose();
cout << tm << endl;
auto m2 = m + m;
cout << m2 << endl;
}
return 0;
}
| [
"641614112@qq.com"
] | 641614112@qq.com |
bc89b833b724e28000e40641cefa15df71f9dd5a | 430a0bc072e5bbdaf8b535e8589ee7bddedd60a1 | /media/base/stream_parser.h | 4b9fa7f3e4d314f1616907c8bd1d2af16131cb6c | [
"BSD-3-Clause"
] | permissive | HyunwooCho/highweb-webcl-html5spec | 4527f01a5ebb95db8e045e1b4012a3eac567f307 | 1e7b96fc871797139b927516e94b75d730ee50c2 | refs/heads/highweb-20160310 | 2021-06-05T23:30:40.097589 | 2016-05-27T04:42:28 | 2016-05-27T04:42:28 | 70,441,565 | 0 | 0 | null | 2016-10-10T01:33:38 | 2016-10-10T01:33:36 | null | UTF-8 | C++ | false | false | 7,135 | h | // Copyright (c) 2012 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 MEDIA_BASE_STREAM_PARSER_H_
#define MEDIA_BASE_STREAM_PARSER_H_
#include <stddef.h>
#include <stdint.h>
#include <deque>
#include <map>
#include <string>
#include <vector>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "media/base/demuxer_stream.h"
#include "media/base/eme_constants.h"
#include "media/base/media_export.h"
#include "media/base/media_log.h"
namespace media {
class MediaTracks;
class StreamParserBuffer;
class TextTrackConfig;
// Abstract interface for parsing media byte streams.
class MEDIA_EXPORT StreamParser {
public:
typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue;
// Range of |TrackId| is dependent upon stream parsers. It is currently
// the key for the buffer's text track config in the applicable
// TextTrackConfigMap (which is passed in StreamParser::NewConfigCB), or
// 0 for other media types that currently allow at most one track.
// WebMTracksParser uses -1 as an invalid text track number.
// TODO(wolenetz/acolwell): Change to size_type while fixing stream parsers to
// emit validated track configuration and buffer vectors rather than max 1
// audio, max 1 video, and N text tracks in a map keyed by
// bytestream-specific-ranged track numbers. See http://crbug.com/341581.
typedef int TrackId;
// Map of text track ID to the track configuration.
typedef std::map<TrackId, TextTrackConfig> TextTrackConfigMap;
// Map of text track ID to decode-timestamp-ordered buffers for the track.
typedef std::map<TrackId, const BufferQueue> TextBufferQueueMap;
// Stream parameters passed in InitCB.
struct InitParameters {
InitParameters(base::TimeDelta duration);
// Stream duration.
base::TimeDelta duration;
// Indicates the source time associated with presentation timestamp 0. A
// null Time is returned if no mapping to Time exists.
base::Time timeline_offset;
// Indicates that timestampOffset should be updated based on the earliest
// end timestamp (audio or video) provided during each NewBuffersCB.
bool auto_update_timestamp_offset;
// Indicates live stream.
DemuxerStream::Liveness liveness;
};
// Indicates completion of parser initialization.
// params - Stream parameters.
typedef base::Callback<void(const InitParameters& params)> InitCB;
// Indicates when new stream configurations have been parsed.
// First parameter - An object containing information about media tracks as
// well as audio/video decoder configs associated with each
// track.
// Second parameter - The new text tracks configuration. If the map is empty,
// then no text tracks were parsed from the stream.
// Return value - True if the new configurations are accepted.
// False if the new configurations are not supported
// and indicates that a parsing error should be signalled.
typedef base::Callback<bool(scoped_ptr<MediaTracks>,
const TextTrackConfigMap&)>
NewConfigCB;
// New stream buffers have been parsed.
// First parameter - A queue of newly parsed audio buffers.
// Second parameter - A queue of newly parsed video buffers.
// Third parameter - A map of text track ids to queues of newly parsed inband
// text buffers. If the map is not empty, it must contain
// at least one track with a non-empty queue of text
// buffers.
// Return value - True indicates that the buffers are accepted.
// False if something was wrong with the buffers and a parsing
// error should be signalled.
typedef base::Callback<bool(const BufferQueue&,
const BufferQueue&,
const TextBufferQueueMap&)> NewBuffersCB;
// Signals the beginning of a new media segment.
typedef base::Callback<void()> NewMediaSegmentCB;
// Signals the end of a media segment.
typedef base::Callback<void()> EndMediaSegmentCB;
// A new potentially encrypted stream has been parsed.
// First parameter - The type of the initialization data associated with the
// stream.
// Second parameter - The initialization data associated with the stream.
typedef base::Callback<void(EmeInitDataType, const std::vector<uint8_t>&)>
EncryptedMediaInitDataCB;
StreamParser();
virtual ~StreamParser();
// Initializes the parser with necessary callbacks. Must be called before any
// data is passed to Parse(). |init_cb| will be called once enough data has
// been parsed to determine the initial stream configurations, presentation
// start time, and duration. If |ignore_text_track| is true, then no text
// buffers should be passed later by the parser to |new_buffers_cb|.
virtual void Init(
const InitCB& init_cb,
const NewConfigCB& config_cb,
const NewBuffersCB& new_buffers_cb,
bool ignore_text_track,
const EncryptedMediaInitDataCB& encrypted_media_init_data_cb,
const NewMediaSegmentCB& new_segment_cb,
const EndMediaSegmentCB& end_of_segment_cb,
const scoped_refptr<MediaLog>& media_log) = 0;
// Called during the reset parser state algorithm. This flushes the current
// parser and puts the parser in a state where it can receive data. This
// method does not need to invoke the EndMediaSegmentCB since the parser reset
// algorithm already resets the segment parsing state.
virtual void Flush() = 0;
// Called when there is new data to parse.
//
// Returns true if the parse succeeds.
virtual bool Parse(const uint8_t* buf, int size) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(StreamParser);
};
// Appends to |merged_buffers| the provided buffers in decode-timestamp order.
// Any previous contents of |merged_buffers| is assumed to have lower
// decode timestamps versus the provided buffers. All provided buffer queues
// are assumed to already be in decode-timestamp order.
// Returns false if any of the provided audio/video/text buffers are found
// to not be in decode timestamp order, or have a decode timestamp less than
// the last buffer, if any, in |merged_buffers|. Partial results may exist
// in |merged_buffers| in this case. Returns true on success.
// No validation of media type within the various buffer queues is done here.
// TODO(wolenetz/acolwell): Merge incrementally in parsers to eliminate
// subtle issues with tie-breaking. See http://crbug.com/338484.
MEDIA_EXPORT bool MergeBufferQueues(
const StreamParser::BufferQueue& audio_buffers,
const StreamParser::BufferQueue& video_buffers,
const StreamParser::TextBufferQueueMap& text_buffers,
StreamParser::BufferQueue* merged_buffers);
} // namespace media
#endif // MEDIA_BASE_STREAM_PARSER_H_
| [
"kimdh@infrawareglobal.com"
] | kimdh@infrawareglobal.com |
d8efe571182cf7a7fd0f3f7e3b168d184772f7dc | 61174b682eec7f7cef6c555bce5570c3347024c7 | /inc/qoccviewercontext.h | 2c1d68b20c81716669c162be848a7270c5893304 | [
"MIT"
] | permissive | Supermanyuan/qtocc | 9f51a8771bc4db8c0ee9a68f1da531149b7fa784 | 61e4367d818de64eb3040ed47481e0e3d2669bee | refs/heads/master | 2020-12-11T08:46:57.715301 | 2019-08-08T07:09:02 | 2019-08-08T07:09:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,489 | h | /****************************************************************************
**
** This file is part of the QtOPENCASCADE Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** Copyright (C) 2006, 2007, Peter Dolbey.
**
** All rights reserved.
**
****************************************************************************/
#ifndef QOCCVIEWERCONTEXT_H
#define QOCCVIEWERCONTEXT_H
#include <QtCore/QObject>
#include "qocc.h"
#include <TopAbs_ShapeEnum.hxx>
class QoccCommand;
class QoccViewWidget;
class QOCC_DECLSPEC QoccViewerContext : public QObject
{
Q_OBJECT
public:
QoccViewerContext();
QoccViewerContext( Handle_AIS_InteractiveContext context, Handle_V3d_Viewer viewer );
~QoccViewerContext();
Handle_V3d_Viewer& getViewer();
Handle_AIS_InteractiveContext& getContext();
static Handle_V3d_Viewer createViewer( const Standard_CString aDisplay,
const Standard_ExtString aName,
const Standard_CString aDomain,
const Standard_Real ViewSize );
void setLocalContext( TopAbs_ShapeEnum lcType );
void clearLocalContexts();
void deleteAllObjects();
void setGridOffset (Quantity_Length offset);
bool isCommandActive() { return !(myCommand == NULL); }
bool isDrawing();
void setCommand ( QoccCommand* command );
void clearCommand ( );
public slots:
void gridXY ( void );
void gridXZ ( void );
void gridYZ ( void );
void gridOn ( void );
void gridOff ( void );
void gridRect ( void );
void gridCirc ( void );
void clickEvent(QoccViewWidget* widget);
void moveEvent (QoccViewWidget* widget);
signals:
void error (int errorCode, QString& errorDescription);
private:
Handle_V3d_Viewer myViewer;
Handle_AIS_InteractiveContext myContext;
Aspect_GridType myGridType;
Aspect_GridDrawMode myGridMode;
Quantity_NameOfColor myGridColor;
Quantity_NameOfColor myGridTenthColor;
QoccCommand* myCommand;
bool myIsDrawing;
};
#endif // QOCCVIEWERCONTEXT_H
| [
"bennyfoo@163.com"
] | bennyfoo@163.com |
dda55e003591ad0f47dd1d924e65652f9989c76b | 3202452643cb290a2f66daf7ba4bd4640a1b57c0 | /Main-Project/Main-Project.cpp | f18c78568d5cd339541ea2a8d689d9a788feaac2 | [] | no_license | manmohanmandhana/Image-Splicing | 03db6b4474553ceda6e6b6ec1ee00103242b2210 | 34eab29ab9c65fc164fd9396e3faa3893827af75 | refs/heads/master | 2016-09-06T08:31:25.943844 | 2014-10-16T20:58:31 | 2014-10-16T20:58:31 | 25,348,107 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,715 | cpp | #include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;
/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1) 32x32 overlapping local windows. Each window will have 63 channels corrosponding to 8x8 DCT kernal
2) Estimate the image for each channel.
3) Compute 4 image moments for each of the K channels
4) Compute the varience and Kurtosis for each local window for each channel
5) Estimate local variences for each of the local windows
*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double moment1(int input[32][32]){
double sum = 0;
for(int k=0;k<32;k++){
for(int kk=0;kk<32;kk++){
sum = sum + input[k][kk];
}
}
sum = sum/(32*32);
return sum;
}
double moment2(int input[32][32){
double sum = 0;
for(int k=0;k<32;k++){
for(int kk=0;kk<32;kk++){
sum = sum + (input[k][kk])*(input[k][kk]);
}
}
sum = sum/(32*32);
return sum;
}
double moment3(int input[32][32]){
double sum = 0;
for(int k=0;k<32;k++){
for(int kk=0;kk<32;kk++){
sum = sum + (input[k][kk])*(input[k][kk])*(input[k][kk]);
}
}
sum = sum/(32*32);
return sum;
}
double moment4(int input[32][32]){
double sum = 0;
for(int k=0;k<32;k++){
for(int kk=0;kk<32;kk++){
sum = sum + (input[k][kk])*(input[k][kk])*(input[k][kk])*(input[k][kk]);
}
}
sum = sum/(32*32);
return sum;
}
// Kurtosis Computation
double compute_kurtosis(double mu1, double mu2, double mu3, double mu4){
double kurt;
kurt = mu4 - 4*mu3*mu1 + 6*mu2*mu1*mu1 - 3*mu1*mu1*mu1*mu1;
kurt = kurt/(mu2*mu2 - 2*mu2*mu1*mu1 + mu1*mu1*mu1*mu1);
kurt = kurt - 3;
return kurt;
}
// Varience Computation
double compute_varience(double mu1, double mu2){
double var;
var = mu2 - mu1*mu1;
return var;
}
// Final Estimation of local varience
double estimate_localvarience(){}
int main()
{
// Step 1 to divede the image into 8x8 DCT decomposition windows and hence K=63
// divide into 32x32 windows and then do the 8x8 window division and perform DCT decomposition
// Do we need to conver to grayscale???
Mat img_input;
img_input = imread("1.jpg",1);
cvtColor(img_input,img_input,CV_BGR2GRAY);
int totrows = img_input.rows;
int totcols = img_input.cols;
// now we need 32x32 overlapping windows for the image
// Yet to apply it on the whole of the image
Mat window_img = img_input(cv::Rect(0,0,32,32)); // the first window of 32x32
cout << window_img.rows << window_img.cols << endl;
//Mat temp = Mat::zeros( window_img.size(), window_img.type());
Mat temp8 = Mat::zeros( 8,8, window_img.type());
// this represents the stack of 64 images in each local window
double local_channels[32][32][64] = 0;
int k = 64;
int m[k];
// a local window analysis starts
for(int i = 0;i<25;i++){
for(int j = 0;j<25;j++){
temp8 = window_img(cv::Rect(i,j,8,8));
// DCT of the window here
dct(temp8,temp8,0);
// Mat to uchar array
uchar *nice = temp8.data;
for(int l=0;l<k;l++){ m[l] = nice[l]; }
// The 1st channel is redundent as it is the DC component
for(int ii=i;ii<i+8;ii++){
for(int jj=j;jj<j+8;jj++){
for(k = 0;k<64;k++){
local_channels[ii][jj][k] = local_channels[ii][jj][k] + m[k];
}
}
}
}
}
//Now we process this window through the desired functions
int temp[32][32]=0;
double m1,m2,m3,m4;
int kurt[63];
int var[63];
for(int k=1;k<64;k++){
// all 63 AC channels, compute an image for each of them first
for(int i=0;i<32;i++){
for(int j=0;j<32;j++){
temp[i][j] = local_channels[i][j][k];
}
}
// compute all the moments
m1 = moment1(temp);
m2 = moment2(temp);
m3 = moment3(temp);
m4 = moment4(temp);
// Now estimating the kurtosis and varience of the channel for this local window
var[k-1] = compute_varience(m1,m2);
kurt[k-1] = compute_kurtosis(m1,m2,m3,m4);
}
waitKey(0);
return 0;
}
| [
"riddhishb@gmail.com"
] | riddhishb@gmail.com |
eced1b0c995329554f5e9e7ecf03992bd016df4f | 9169181e12bb33e85eddcf7b7422ad3300c593b7 | /AjouterPat/patinageartistique.cpp | 1d582fb1a8cd5ea164322e2d94476122a6d13a01 | [] | no_license | EPAFprojet/Epaf | 3d9dabf5f116bbcdb9a592dd592b32f6d6b24e3e | e28de6bb78c9138f990d53e80363620a31a964af | refs/heads/master | 2021-01-19T00:39:51.477520 | 2017-04-10T20:19:30 | 2017-04-10T20:19:30 | 87,198,635 | 0 | 1 | null | 2017-04-06T14:07:28 | 2017-04-04T14:47:12 | C++ | UTF-8 | C++ | false | false | 272 | cpp | #include "patinageartistique.h"
PatinageArtistique::PatinageArtistique()
{
}
void setPatID(int id)
{
}
void setNoClub(int club)
{
}
void setNivDanse(QString danse)
{
}
void setNivStyle(QString style)
{
}
void setPAGroupe(QString groupe)
{
}
void PAtoBD()
{
}
| [
"epafprojet@gmail.com"
] | epafprojet@gmail.com |
45f4f1cafa1e43268630d69e652c19c085c98078 | 3f4f66560c936cf7c59139b48d183700cbbc6fce | /trunk/lib/qtfarmstockplugin/qtfarmstockplugin.h | 6891969c2c4b8cfb50ef86637967fb333a346a64 | [] | no_license | BackupTheBerlios/qtfarm-svn | 15c62e68f45b8ca70ec0035994024c2e6be90906 | 99239c1ce4c81dafd60d17536b098255cee88a08 | refs/heads/master | 2020-04-04T01:06:50.021447 | 2008-06-21T13:20:47 | 2008-06-21T13:20:47 | 40,804,471 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,850 | h | /**************************************************************************
** Copyright (C) 2008 by Jan Vaillant **
* jvail@gmx.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 3 *
* as published by the Free Software Foundation. *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
** **
**************************************************************************/
#ifndef QTFARMSTOCKPLUGIN_H_
#define QTFARMSTOCKPLUGIN_H_
#include <QObject>
#include <QAction>
#include <QMap>
#include "qtfarmplugininterfaces.h"
class QtFarmStockPlugin : public QObject, QtFarmStockInterface
{
Q_OBJECT
Q_INTERFACES(QtFarmStockInterface)
public:
QStringList features() const;
QMap<QtFarmStockInterface::Data, QVariant> listMap();
QMap<enum WidgetType, QWidget*> widgetMap(QWidget *parent = 0);
};
#endif /*QTFARMSTOCKPLUGIN_H_*/
| [
"jvail@da907cbf-524f-0410-a282-ea2700265cf3"
] | jvail@da907cbf-524f-0410-a282-ea2700265cf3 |
88e0cc01ac85e76f68b635e1ff1ef8af8c9cef00 | a35b30a7c345a988e15d376a4ff5c389a6e8b23a | /boost/test/detail/unit_test_parameters.hpp | fa8bfda0c2d4bd46d0cf21a54ab7302e689f7ed8 | [] | no_license | huahang/thirdparty | 55d4cc1c8a34eff1805ba90fcbe6b99eb59a7f0b | 07a5d64111a55dda631b7e8d34878ca5e5de05ab | refs/heads/master | 2021-01-15T14:29:26.968553 | 2014-02-06T07:35:22 | 2014-02-06T07:35:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 78 | hpp | #include "thirdparty/boost_1_55_0/boost/test/detail/unit_test_parameters.hpp"
| [
"liuhuahang@xiaomi.com"
] | liuhuahang@xiaomi.com |
f74c82cd97a0d1b4edf05d2508eec04b1106828e | 5df1a677af9379c9a82f1b29359a65ad8cbc385e | /CodeForces/PastContest/791/B.cpp | 52c074a61066cc6856942378d7082617b1456d19 | [] | no_license | heyshb/Competitive-Programming | 92741a4e7234e1ebce685c1b870f1287bee18f1a | 363ef78d950afb53f0e5f1d2329f27dd7b9a44c2 | refs/heads/master | 2021-12-15T03:12:37.676111 | 2021-12-01T14:32:25 | 2021-12-01T14:32:25 | 122,315,094 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 660 | cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int N,M;
vector<int> e[200010];
int d[200010];
LL sum1;
LL sum2;
vector<int> now;
bool vis[200010];
void dfs(int x)
{
vis[x] = true;
sum1++;
sum2+=LL(d[x]);
for (int i=0;i<e[x].size();i++)
if (!vis[e[x][i]])
{
dfs(e[x][i]);
}
}
int main()
{
scanf("%d%d",&N,&M);
for (int i=1;i<=M;i++)
{
int X,Y;
scanf("%d%d",&X,&Y);
e[X].push_back(Y);
e[Y].push_back(X);
d[X]++;
d[Y]++;
}
memset(vis,false,sizeof(vis));
for (int i=1;i<=N;i++)
if (!vis[i])
{
sum1 = 0;
sum2 = 0;
dfs(i);
if (sum2!=sum1*(sum1-1))
{
puts("NO");
return 0;
}
}
puts("YES");
}
| [
"heyshb@vip.qq.com"
] | heyshb@vip.qq.com |
a7fcfe0cac7ac6c1b6bc64d4c630ea2d844bf33d | 5bf5d0571806c7a5afae0ac11d3f0646804fdde6 | /xls/noc/config/examples/custom_network_config_builder_options_textproto_test.cc | 01f0c2d6bd813ba9e69e2b142e8d4ada7da3e830 | [
"Apache-2.0"
] | permissive | BuildJet/xls | d8d9326b46ad50931507764c10288a3353b1aa34 | 81529a09359f78e03d2bef517a6b316967429b4f | refs/heads/main | 2023-05-03T07:05:23.477084 | 2021-05-17T22:45:32 | 2021-05-17T22:45:32 | 368,339,764 | 0 | 1 | Apache-2.0 | 2021-05-17T22:44:12 | 2021-05-17T22:44:11 | null | UTF-8 | C++ | false | false | 5,075 | cc | // Copyright 2020 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 "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/strings/str_cat.h"
#include "xls/common/file/filesystem.h"
#include "xls/common/file/get_runfile_path.h"
#include "xls/common/status/matchers.h"
#include "xls/noc/config/network_config_builder_options.pb.h"
namespace xls::noc {
static const char* kExamplesPath = "xls/noc/config/examples/";
static absl::Status ParseTextProtoFileToNetworkConfigBuilderOptionsProto(
absl::string_view filename) {
std::string filepath = absl::StrCat(kExamplesPath, filename);
absl::StatusOr<std::filesystem::path> runfile_path =
GetXlsRunfilePath(filepath);
XLS_EXPECT_OK(runfile_path);
NetworkConfigBuilderOptionsProto proto;
return ParseTextProtoFile(runfile_path.value(), &proto);
}
// Test the format of a linear options textproto example by parsing the file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, Linear) {
const char* kFilename = "linear_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
// Test the format of a ring options textproto example by parsing the file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, Ring) {
const char* kFilename = "ring_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
// Test the format of a mesh options textproto example by parsing the file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, Mesh) {
const char* kFilename = "mesh_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
// Test the format of a torus options textproto example by parsing the file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, Torus) {
const char* kFilename = "torus_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
// Test the format of a grid with row loopback options textproto example by
// parsing the file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, GridWithRowLoopback) {
const char* kFilename =
"grid_with_row_loopback_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
// Test the format of a grid with column loopback options textproto example by
// parsing the file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, GridWithColumnLoopback) {
const char* kFilename =
"grid_with_column_loopback_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
// Test the format of a distribution tree options textproto example by parsing
// the file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, DistributionTree) {
const char* kFilename =
"distribution_tree_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
// Test the format of an aggregation tree options textproto example by parsing
// the file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, AggregationTree) {
const char* kFilename =
"aggregation_tree_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
// Test the format of a single switch options textproto example by parsing the
// file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, SingleSwitch) {
const char* kFilename =
"single_switch_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
// Test the format of a bidirectioanl tree options textproto example by parsing
// the file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, BidirectionalTree) {
const char* kFilename =
"bidirectional_tree_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
// Test the format of a fully connected options textproto example by parsing the
// file.
TEST(CustomNetworkConfigBuilderOptionsTextProtoTest, FullyConnected) {
const char* kFilename =
"fully_connected_network_config_builder_options.textproto";
XLS_EXPECT_OK(
ParseTextProtoFileToNetworkConfigBuilderOptionsProto(kFilename));
}
} // namespace xls::noc
| [
"copybara-worker@google.com"
] | copybara-worker@google.com |
f59ecc896c3353023de6b06dfe15df5e7493335e | 265d50fed777b60da85576be7c95f2991401f028 | /tutorial_ex13_array/array_initialize.cpp | 47453065d872d972d8ab5b6623ec1e6d3bc1a8e0 | [] | no_license | RioKKH/AtCoder | f2f6e38d8faa72c22566ae9f22c3e0332eff2791 | 85325829d13efaec3c5ab9442499829daf3acf94 | refs/heads/master | 2023-01-09T02:56:44.765425 | 2023-01-04T09:53:46 | 2023-01-04T09:53:46 | 197,029,295 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 249 | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> vec(3, 10); // (要素数、初期値)。{10, 10, 10}で初期化
vec = vector<int>(100, 2); // 100要素の配列{2, 2, ..., 2, 2}で上書き
cout << vec.at(99) << endl;
}
| [
"ryoichikakehi@gmail.com"
] | ryoichikakehi@gmail.com |
a1a3832fb8489c6e78b9eaefa9e1166771fe6071 | fd56db46d3fddc184c97e0cca7053e152ad982a9 | /Intermediate/Build/Android/UE4/Development/HoopBall/Module.HoopBall.cpp | 00f48a8ae65bfe64ae39302aec4747630fd81659 | [] | no_license | BadNewsHorseman/HoopBall2 | 3ca0175ae767ede3fbfa859b0c9ec35e321f0e70 | 41ec7cabe6586e94617f788e7b731f0531d26d60 | refs/heads/master | 2020-03-28T03:16:00.388108 | 2018-09-06T13:44:30 | 2018-09-06T13:44:30 | 147,632,716 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 173 | cpp | // This file is automatically generated at compile-time to include some subset of the user-created cpp files.
#include "D:\GitHub\HoopBall\Intermediate\Source\HoopBall.cpp"
| [
"stvnmuller@gmail.com"
] | stvnmuller@gmail.com |
9ec6ab3b48168571e62a38a5f9a8d54b5f09c9ee | 3253ab02abbd16d54c1b7360d2cdd35b3cbf399d | /Midterm/3 SimpleVectorPush/SimpleVector.h | ca9a0f3d5330bf49648b6e2d4c37c62bde742295 | [] | no_license | bn2595114/NguyenBryan_CSC17C_47341 | 61203a3f60c7c7020d33c57ce4a2b7c8da74edd1 | baa1b198f72a73457c404e4f70dcab7208272de0 | refs/heads/master | 2021-08-30T06:17:21.416288 | 2017-12-16T12:12:17 | 2017-12-16T12:12:17 | 103,586,580 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,011 | h | /*
* File: SimpleVectorPush.h
* Author: Dr. Mark E. Lehr
* Created on October 13, 2017, 4:32 PM
* Purpose: Simple Vector only works with Class Wrapper Objects
* Inefficient Push implemented
*/
#ifndef SIMPLEVECTORPUSH_H
#define SIMPLEVECTORPUSH_H
// SimpleVector class template
#include <iostream>
#include <new> // Needed for bad_alloc exception
#include <cstdlib> // Needed for the exit function
using namespace std;
template <class T>
class SimpleVector{
private:
int ce=0,cadd=0,csub=0,crel=0,cdiv=0,cmul=0;
T *aptr; // To point to the allocated array
int arraySize; // Number of elements in the array
void memError(); // Handles memory allocation errors
void subError(); // Handles subscripts out of range
public:
void prntC(){
cout << "ce: " << ce << endl;
cout << "cadd: " << cadd << endl;
cout << "csub: " << csub << endl;
cout << "crel: " << crel << endl;
cout << "cdiv: " << cdiv << endl;
cout << "cmul: " << cmul << endl <<endl;
}
// Default constructor
SimpleVector()
{ aptr = 0; arraySize = 0;}
// Constructor declaration
SimpleVector(int);
// Constructor declaration
SimpleVector(const T &);
// Copy constructor declaration
SimpleVector(const SimpleVector &);
// Destructor declaration
~SimpleVector();
// Access to return the array size
int size() const
{ return arraySize; }
// Access to return a specific element
T getElementAt(int position);
// Overloaded [] operator declaration
T &operator[](const int &);
void push(T&);
};
//***********************************************************
// Push the new value by allocating, copying, then adding
// new value
//***********************************************************
template <class T>
void SimpleVector<T>::push(T &val){
//Declare new array pointer
T *naptr;
// Allocate memory for the new array.
try{
naptr = new T [arraySize+1];
}catch (bad_alloc){
memError();
}
//Fill the Array
for (int count = 0; count < arraySize; count++){
ce++;crel++;cadd++;ce++;
naptr[count]=aptr[count];
ce++;
}
//Add new value and increment the array size
naptr[arraySize++]=val;
ce++;
//Delete the old array and point to new array
delete []aptr;
aptr=0;
ce++;
aptr=naptr;
ce++;
prntC();
}
//***********************************************************
// Constructor for SimpleVector class with 1 object
//***********************************************************
template <class T>
SimpleVector<T>::SimpleVector(const T &d){
arraySize = 1;
// Allocate memory for the array.
try{
aptr = new T [arraySize];
}catch (bad_alloc){
memError();
}
// Initialize the array.
for (int count = 0; count < arraySize; count++)
aptr[count]=d;
}
//***********************************************************
// Constructor for SimpleVector class. Sets the size of the *
// array and allocates memory for it. *
//***********************************************************
template <class T>
SimpleVector<T>::SimpleVector(int s){
arraySize = s;
// Allocate memory for the array.
try{
aptr = new T [s];
}catch (bad_alloc){
memError();
}
// Initialize the array.
for (int count = 0; count < arraySize; count++)
aptr[count]=T(0);
}
//*******************************************
// Copy Constructor for SimpleVector class. *
//*******************************************
template <class T>
SimpleVector<T>::SimpleVector(const SimpleVector &obj){
// Copy the array size.
arraySize = obj.arraySize;
// Allocate memory for the array.
aptr = new T [arraySize];
if (aptr == 0)
memError();
// Copy the elements of obj's array.
for(int count = 0; count < arraySize; count++)
*(aptr + count) = *(obj.aptr + count);
}
//**************************************
// Destructor for SimpleVector class. *
//**************************************
template <class T>
SimpleVector<T>::~SimpleVector(){
if (arraySize > 0)
delete [] aptr;
}
//*******************************************************
// memError function. Displays an error message and *
// terminates the program when memory allocation fails. *
//*******************************************************
template <class T>
void SimpleVector<T>::memError(){
cout << "ERROR:Cannot allocate memory.\n";
exit(EXIT_FAILURE);
}
//***********************************************************
// subError function. Displays an error message and *
// terminates the program when a subscript is out of range. *
//***********************************************************
template <class T>
void SimpleVector<T>::subError(){
cout << "ERROR: Subscript out of range.\n";
exit(EXIT_FAILURE);
}
//*******************************************************
// getElementAt function. The argument is a subscript. *
// This function returns the value stored at the sub- *
// cript in the array. *
//*******************************************************
template <class T>
T SimpleVector<T>::getElementAt(int sub){
if (sub < 0 || sub >= arraySize)
subError();
return aptr[sub];
}
//*******************************************************
// Overloaded [] operator. The argument is a subscript. *
// This function returns a reference to the element *
// in the array indexed by the subscript. *
//*******************************************************
template <class T>
T &SimpleVector<T>::operator[](const int &sub){
if (sub < 0 || sub >= arraySize)
subError();
return aptr[sub];
}
#endif /* SIMPLEVECTORPUSH_H */
| [
"cinexiii@gmail.com"
] | cinexiii@gmail.com |
5c7cd34c59ea2543fb187661053b77d3fe828c20 | 543a36b4a522d07aeec48f6b2f4c6515f26d1143 | /src/hoshizora/app/clustering_louvain.h | df56c88af209393cc97f784e7c48c1b073c49577 | [
"Apache-2.0"
] | permissive | hoshizora-project/hoshizora | d004f05c789f5bb856aceb223806c944fd3aa4c3 | 30dda85a75db8be2ce25a4667b3de10eb399456e | refs/heads/master | 2021-03-27T11:12:04.963098 | 2018-08-03T14:21:06 | 2018-08-03T14:21:06 | 93,928,498 | 10 | 1 | Apache-2.0 | 2018-08-03T14:01:16 | 2017-06-10T09:17:18 | C++ | UTF-8 | C++ | false | false | 2,929 | h | #ifndef HOSHIZORA_CLUSTERING_NEWMAN_H
#define HOSHIZORA_CLUSTERING_NEWMAN_H
#include "hoshizora/core/includes.h"
#include "hoshizora/core/kernel.h"
#include <string>
#include <vector>
namespace hoshizora {
// Like louvain, but more more stupid
template <class Graph> struct ClusteringLouvain : Kernel<Graph> {
using _Graph = Graph;
using EData = typename Graph::_EData;
using VData = typename Graph::_VData;
using ID = typename Graph::_ID;
const f64 threshold;
ClusteringLouvain(const f64 threshold) : threshold(threshold) {}
VData init(const ID src, const Graph &graph) const override {
return std::make_pair(src, 0);
}
// TODO: Introduce scatter_all
EData scatter(const ID src, const ID dst, const VData v_val,
Graph &graph) override {
// q_{src}
// Need only the beginning(=|V| times), but currently called |E| times
u32 sum = graph.v_props.empty() ? 0 : graph.v_props[src];
for (u32 i = 0, degree = graph.out_degrees(src); i < degree; ++i) {
const auto ngh = graph.out_neighbors(src)[i];
sum += graph.e_props[src].at(ngh);
}
for (u32 i = 0, deg = graph.in_degrees(src); i < deg; ++i) {
const auto ngh = graph.in_neighbors(src)[i];
sum += graph.e_props[ngh].at(src);
}
const f64 q = sum / (2.0 * graph.num_all_edges);
graph.v_data(src) = std::make_pair(src, q);
return q;
}
EData gather(const ID src, const ID dst, const EData prev_val,
const EData curr_val /*q_{src}*/,
const Graph &graph) const override {
// if no outgoing edge, not initialize at scatter
if (graph.out_degrees(dst) == 0) {
u32 sum = graph.v_props.empty() ? 0 : graph.v_props[dst];
for (u32 i = 0, deg = graph.in_degrees(dst); i < deg; ++i) {
const auto ngh = graph.in_neighbors(dst)[i];
sum += graph.e_props[ngh].at(dst);
}
const f64 q = sum / (2.0 * graph.num_all_edges);
graph.v_data(dst) = std::make_pair(dst, q);
}
return 2 * (graph.e_props[src].at(dst) / (2.0 * graph.num_all_edges) -
curr_val * graph.v_data(dst).second);
}
VData zero(const ID dst, const Graph &graph) const override {
return std::make_pair(dst, threshold);
}
VData sum(const ID src, const ID dst, const VData v_val /*gain_{src, dst}*/,
const EData e_val, Graph &graph) override {
if (e_val > v_val.second) {
graph.changed = true;
u32 new_cluster_id = std::min(src, dst);
return std::make_pair(new_cluster_id, e_val);
} else {
return v_val;
}
}
VData apply(const ID dst, const VData prev_val, const VData curr_val,
const Graph &graph) const override {
return curr_val;
}
std::vector<std::string> result(const Graph &graph) const override {
std::vector<std::string> result;
return result;
}
};
} // namespace hoshizora
#endif // HOSHIZORA_CLUSTERING_NEWMAN_H
| [
"mail@sapphire.in.net"
] | mail@sapphire.in.net |
73fb0d4a3747c26a49e4960defd72df11c356555 | ff668dccf8d9c6b8e6b88c82a1118b21f6ac3951 | /atmstate.cpp | 160c7aac8ccafa8f23c8bf051d21e591a4eec11b | [] | no_license | IlyaSirosh/ATM_client | 64419a39998f01f839a97c322aa8d37028a2713d | c7465d07a6881e2da20f7d10ca8716ec0ce1a63f | refs/heads/master | 2020-06-20T03:01:13.600722 | 2016-12-18T20:05:37 | 2016-12-18T20:05:37 | 74,885,034 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,842 | cpp | #include "atmstate.h"
ATMState ATMState::CHOOSE_STATE(true,true,false,false,false);
ATMState ATMState::GET_PIN_STATE(true,false,true,false,false);
ATMState ATMState::WORK_STATE(true,false,false,false,false);
ATMState ATMState::GET_CASH(true,false,false,true,false);
ATMState ATMState::WANT_TO_CONTINUE(true,false,false,false,true);
ATMState::ATMState(QObject *parent) :
QObject(parent),
_working(false),
_choosingOperation(false),
_gettingPIN(false),
_gettingCash(false),
_wantToContinue(false)
{
}
ATMState::ATMState(bool w,bool ch,bool p,bool c,bool cn):
QObject(0),
_working(w),
_choosingOperation(ch),
_gettingPIN(p),
_gettingCash(c),
_wantToContinue(cn)
{
}
bool ATMState::operator == (const ATMState& b)const{
return _working == b._working&&
_choosingOperation == b._choosingOperation&&
_gettingPIN == b._gettingPIN&&
_gettingCash == b._gettingCash&&
_wantToContinue == b._wantToContinue;
}
void ATMState::stopWorking(){
_wantToContinue = _gettingCash=_choosingOperation =_gettingPIN = _working = false;
}
void ATMState::startWorking(){
_working = true;
}
void ATMState::startChoose(){
_choosingOperation = true;
_gettingPIN = false;
_gettingCash = false;
_wantToContinue = false;
}
void ATMState::startGetPin(){
_gettingPIN = true;
_choosingOperation = false;
_gettingCash = false;
_wantToContinue = false;
}
void ATMState::startGetCash(){
_gettingPIN = false;
_choosingOperation = false;
_gettingCash = true;
_wantToContinue = false;
}
void ATMState::startWantToContinue(){
_gettingPIN = false;
_choosingOperation = false;
_gettingCash = false;
_wantToContinue = true;
}
bool ATMState::working()const{
return _working;
}
| [
"IlyaSirosh@users.noreply.github.com"
] | IlyaSirosh@users.noreply.github.com |
af704571690111c47036fa0d42f4d95233b20e07 | aac6e553ef443f926803a2f403af0b00bae13709 | /ch09/hough/main.cpp | 567af7482c7d9e8d74591178fd761d89c1706a51 | [] | no_license | sunkyoo/opencv4cvml | 9f4e8f9a9aa5c84f03a0a1cb834bd3f7dd7a7adb | 660989c9424544c76a150373f8ba612575c65661 | refs/heads/master | 2023-04-11T06:59:49.107308 | 2023-03-17T07:26:59 | 2023-03-17T07:26:59 | 176,041,609 | 159 | 146 | null | null | null | null | UTF-8 | C++ | false | false | 2,147 | cpp | #include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
void hough_lines();
void hough_line_segments();
void hough_circles();
int main(void)
{
hough_lines();
hough_line_segments();
hough_circles();
return 0;
}
void hough_lines()
{
Mat src = imread("building.jpg", IMREAD_GRAYSCALE);
if (src.empty()) {
cerr << "Image load failed!" << endl;
return;
}
Mat edge;
Canny(src, edge, 50, 150);
vector<Vec2f> lines;
HoughLines(edge, lines, 1, CV_PI / 180, 250);
Mat dst;
cvtColor(edge, dst, COLOR_GRAY2BGR);
for (size_t i = 0; i < lines.size(); i++) {
float rho = lines[i][0], theta = lines[i][1];
float cos_t = cos(theta), sin_t = sin(theta);
float x0 = rho * cos_t, y0 = rho * sin_t;
float alpha = 1000;
Point pt1(cvRound(x0 - alpha * sin_t), cvRound(y0 + alpha * cos_t));
Point pt2(cvRound(x0 + alpha * sin_t), cvRound(y0 - alpha * cos_t));
line(dst, pt1, pt2, Scalar(0, 0, 255), 2, LINE_AA);
}
imshow("src", src);
imshow("dst", dst);
waitKey();
destroyAllWindows();
}
void hough_line_segments()
{
Mat src = imread("building.jpg", IMREAD_GRAYSCALE);
if (src.empty()) {
cerr << "Image load failed!" << endl;
return;
}
Mat edge;
Canny(src, edge, 50, 150);
vector<Vec4i> lines;
HoughLinesP(edge, lines, 1, CV_PI / 180, 160, 50, 5);
Mat dst;
cvtColor(edge, dst, COLOR_GRAY2BGR);
for (Vec4i l : lines) {
line(dst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 2, LINE_AA);
}
imshow("src", src);
imshow("dst", dst);
waitKey();
destroyAllWindows();
}
void hough_circles()
{
Mat src = imread("coins.png", IMREAD_GRAYSCALE);
if (src.empty()) {
cerr << "Image load failed!" << endl;
return;
}
Mat blurred;
blur(src, blurred, Size(3, 3));
vector<Vec3f> circles;
HoughCircles(blurred, circles, HOUGH_GRADIENT, 1, 50, 150, 30);
Mat dst;
cvtColor(src, dst, COLOR_GRAY2BGR);
for (Vec3f c : circles) {
Point center(cvRound(c[0]), cvRound(c[1]));
int radius = cvRound(c[2]);
circle(dst, center, radius, Scalar(0, 0, 255), 2, LINE_AA);
}
imshow("src", src);
imshow("dst", dst);
waitKey();
destroyAllWindows();
}
| [
"sunkyoo.hwang@gmail.com"
] | sunkyoo.hwang@gmail.com |
f0d73b7fdee1c9722c7d08ef71ae70b655bd041a | e7f74d5683701e9552f3d476dc8f57775128f90f | /hackerrank.com/tailor-shop-TLE.cpp | ecc4c57b0123f4093111c76f09da3320ea4db783 | [
"MIT"
] | permissive | bolatov/contests | 89463675ea3114115bd921973b54eb64620c19a2 | 39654ec36e1b7ff62052e324428141a9564fd576 | refs/heads/master | 2021-01-24T11:19:53.864281 | 2018-07-12T05:37:09 | 2018-07-12T05:37:09 | 21,923,806 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,047 | cpp | #include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
int n;
int p;
cin >> n >> p;
vector<int> a(n);
for (int a_i = 0; a_i < n; a_i++) {
cin >> a[a_i];
}
sort(a.begin(), a.end());
set<int> si;
int mx = INT_MAX;
for (int i : a) {
int q = (int)ceil(i / (double)p);
q = min(mx, q);
mx = q + 1;
for (; si.find(q) != si.end(); q++)
;
si.insert(q);
printf("%d -> %d\n", i, q);
}
long long sum = 0;
for (long long i : si)
sum += i;
cout << sum << endl;
return 0;
}
| [
"almer.bolatov@gmail.com"
] | almer.bolatov@gmail.com |
f487c74e711a71dece735cf797e447efed3f8e56 | b4aee1d85320b398555b3782e872773044d4d685 | /practice/16.5/16.5.cpp | 31571d094ca8f7529cd65300ee8d1df48d918644 | [] | no_license | crazyqipython/Cpp-primer-plus | 5a455ef0e16d461d963d659ff28a61eb27374269 | 0ebfe6feec17c5e920ff56b658464685cef26af1 | refs/heads/master | 2021-01-09T06:23:22.692388 | 2016-08-29T13:09:53 | 2016-08-29T13:09:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,062 | cpp | #include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
template <class T>
int reduce(T ar[], int n)
{
sort(ar, ar + n);
const auto iter_end = unique(ar, ar + n);
return distance(ar, iter_end);
}
int main()
{
long ar[] = {1, 2, 3, 4, 5, 4, 3, 2, 1, 0};
copy(ar, ar + sizeof(ar)/sizeof(ar[0]), ostream_iterator<int>(cout, " "));
cout << endl;
int ar_size = reduce(ar, sizeof(ar)/sizeof(ar[0]));
cout << "Totally " << ar_size << " longs left.\n";
copy(ar, ar + sizeof(ar)/sizeof(ar[0]), ostream_iterator<int>(cout, " "));
cout << endl << endl;
string ar_str[] = {"hello", "the", "who", "who", "hello"};
copy(ar_str, ar_str + sizeof(ar_str)/sizeof(ar_str[0]), ostream_iterator<string>(cout, " "));
cout << endl;
int ar_str_size = reduce(ar_str, sizeof(ar_str)/sizeof(ar_str[0]));
cout << "There's " << ar_str_size << " strings left.\n";
copy(ar_str, ar_str + sizeof(ar_str) / sizeof(ar_str[0]), ostream_iterator<string>(cout, " "));
cout << endl;
return 0;
}
| [
"hblee12294@gmail.com"
] | hblee12294@gmail.com |
48ded7744df3520af7b6df5d9690b3c9dcb06db0 | 6250f3343eff1638912510b66ed936c59796635a | /src_vc141/thirdparty/stlsoft/STLSoft/include/winstl/error/last_error_scope.hpp | 04fdeb2ed1a0cf0df9a4c815d69a7dee4cc1af00 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | nneesshh/mytoolkit | b4b242307a6603bc5785bc130de8f4d3b5ea9265 | 336ae9c7077c8687a8cf8a2ce4aec804c28ab90c | refs/heads/master | 2020-04-05T15:18:07.985547 | 2018-12-17T11:36:07 | 2018-12-17T11:36:07 | 156,961,652 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 6,229 | hpp | /* /////////////////////////////////////////////////////////////////////////
* File: winstl/error/last_error_scope.hpp (originally MWTErrScp.h, ::SynesisWin)
*
* Purpose: Win32 last error scoping class.
*
* Created: 27th November 1998
* Updated: 19th February 2017
*
* Home: http://stlsoft.org/
*
* Copyright (c) 1998-2017, Matthew Wilson and Synesis Software
* 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(s) of Matthew Wilson and Synesis Software nor the
* names of any 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 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.
*
* ////////////////////////////////////////////////////////////////////// */
/** \file winstl/error/last_error_scope.hpp
*
* \brief [C++ only] Definition of the winstl::last_error_scope class
* template
* (\ref group__library__error "Error" Library).
*/
#ifndef WINSTL_INCL_WINSTL_ERROR_HPP_LAST_ERROR_SCOPE
#define WINSTL_INCL_WINSTL_ERROR_HPP_LAST_ERROR_SCOPE
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
# define WINSTL_VER_WINSTL_ERROR_HPP_LAST_ERROR_SCOPE_MAJOR 4
# define WINSTL_VER_WINSTL_ERROR_HPP_LAST_ERROR_SCOPE_MINOR 0
# define WINSTL_VER_WINSTL_ERROR_HPP_LAST_ERROR_SCOPE_REVISION 6
# define WINSTL_VER_WINSTL_ERROR_HPP_LAST_ERROR_SCOPE_EDIT 53
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
/* /////////////////////////////////////////////////////////////////////////
* compatibility
*/
/*
[DocumentationStatus:Ready]
*/
/* /////////////////////////////////////////////////////////////////////////
* includes
*/
#ifndef WINSTL_INCL_WINSTL_H_WINSTL
# include <winstl/winstl.h>
#endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
#ifdef STLSOFT_TRACE_INCLUDE
# pragma message(__FILE__)
#endif /* STLSOFT_TRACE_INCLUDE */
/* /////////////////////////////////////////////////////////////////////////
* namespace
*/
#ifndef WINSTL_NO_NAMESPACE
# if defined(STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
/* There is no stlsoft namespace, so must define ::winstl */
namespace winstl
{
# else
/* Define stlsoft::winstl_project */
namespace stlsoft
{
namespace winstl_project
{
# endif /* STLSOFT_NO_NAMESPACE */
#endif /* !WINSTL_NO_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* classes
*/
/** A \ref group__pattern__scoping_class "scoping class" that scopes
* the thread's last error.
*
* \ingroup group__library__error
*
\code
DWORD err = ::GetLastError();
{ winstl::last_error_scope scope; // Scope the error while we change it
// Some code that changes (or may change) the last error
. . .
::SetLastError(ERROR_ACCESS_DENIED); // ... we just do this for pedagogical purposes
} // End of scope - error value replaced to former value
assert(::GetLastError() == err);
\endcode
*/
class last_error_scope
{
/// \name Types
/// @{
public:
typedef last_error_scope class_type;
/// @}
/// \name Operations
/// @{
public:
/// Takes a copy of the current thread error, which will be reset
/// on destruction of this instance
last_error_scope() STLSOFT_NOEXCEPT
: m_dwErr(::GetLastError())
{}
/// Takes a copy of the current thread error, which will be reset
/// on destruction of this instance. The current thread error is
/// set to the given value.
///
/// \param dwErr The value to which the current thread error is set
ss_explicit_k last_error_scope(ws_dword_t dwErr) STLSOFT_NOEXCEPT
: m_dwErr(::GetLastError())
{
::SetLastError(dwErr);
}
/// Resets the thread error value current at the epoque of
/// construction of this instance
~last_error_scope() STLSOFT_NOEXCEPT
{
::SetLastError(m_dwErr);
}
/// @}
/// \name Operations
/// @{
public:
/// Returns the value of the recorded thread error, which will be
/// reset on destruction of this instance
operator ws_dword_t() const
{
return m_dwErr;
}
/// @}
// Members
private:
ws_dword_t m_dwErr;
// Not to be implemented
private:
last_error_scope(last_error_scope const&);
last_error_scope& operator =(last_error_scope const&);
};
/* ////////////////////////////////////////////////////////////////////// */
#ifndef WINSTL_NO_NAMESPACE
# if defined(STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} /* namespace winstl */
# else
} /* namespace winstl_project */
} /* namespace stlsoft */
# endif /* STLSOFT_NO_NAMESPACE */
#endif /* !WINSTL_NO_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* inclusion control
*/
#ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT
# pragma once
#endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */
#endif /* !WINSTL_INCL_WINSTL_ERROR_HPP_LAST_ERROR_SCOPE */
/* ///////////////////////////// end of file //////////////////////////// */
| [
"nneesshh@163.com"
] | nneesshh@163.com |
e41e0c256bf9ce2fe431031d17361dada57c26dc | 9b273539e02cca8d408e8cf793007ee84e6637d5 | /ext/bliss/retired/src/taskrunner/thread_pool.hpp | aba4d244f32cd2d56cdd66e371ebf97f2553abc7 | [
"Apache-2.0"
] | permissive | tuan1225/parconnect_sc16 | 23b82c956eed4dabe5deec8bd48cc8ead91af615 | bcd6f99101685d746cf30e22fa3c3f63ddd950c9 | refs/heads/master | 2020-12-24T12:01:13.846352 | 2016-11-07T16:51:29 | 2016-11-07T16:51:29 | 73,055,274 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,183 | hpp | /**
* bliss-Release@bliss copyright 2014 Georgia Institute of Technology
*
* @file thread_pool.hpp
* @ingroup wip
*
* @date: Mar 20, 2014
* @author: Tony Pan <tpan7@gatech.edu>
* @description
*
* inspired by https://github.com/greyfade/workqueue/blob/master/threadpool.hpp
* modifications: none yet.
*/
#ifndef THREADPOOL_H_
#define THREADPOOL_H_
#include <future>
#include <thread>
#include <deque>
#include <vector>
#include <utility>
#include <chrono>
#include <functional>
#include <type_traits>
namespace bliss
{
namespace concurrent
{
/*
* This file is licensed under the zlib/libpng license, included in this
* distribution in the file COPYING.
*/
class thread_pool {
std::vector<std::thread> pool;
bool stop;
std::mutex access;
std::condition_variable cond;
std::deque<std::function<void()>> tasks;
public:
explicit thread_pool(int nr = 1) : stop(false) {
while(--nr > 0) {
add_worker();
}
}
~thread_pool() {
stop = true;
for(std::thread &t : pool) {
t.join();
}
pool.clear();
}
template<class Rt>
auto add_task(std::packaged_task<Rt()>& pt) -> std::future<Rt> {
std::unique_lock<std::mutex> lock(access);
auto ret = pt.get_future();
tasks.push_back([&pt]{pt();});
cond.notify_one();
return ret;
}
private:
void add_worker() {
std::thread t([this]() {
while(!stop) {
std::function<void()> task;
{
std::unique_lock<std::mutex> lock(access);
if(tasks.empty()) {
cond.wait_for(lock, std::chrono::duration<int, std::milli>(5));
continue;
}
task = std::move(tasks.front());
tasks.pop_front();
}
task();
}
});
pool.push_back(std::move(t));
}
};
} /* namespace concurrent */
} /* namespace bliss */
#endif /* THREADPOOL_H_ */
| [
"tuannguyen1225@yahoo.com"
] | tuannguyen1225@yahoo.com |
d8083b9b90b02d85d8b7341cc235b9f1a07451d1 | 8a9f5c0c631fa1d72a779ae252e020f1693a1306 | /增删改查&追加-环境变量/1.cpp | 7dbf5d1ebec9e8300254ca6393b61181dde2993e | [
"MIT"
] | permissive | lilongsy/Windows-API-Example | 889cc278a332d62cb9930906d5536befe2536e40 | 5ca584d09f6040e989680d5e91c12ad772b03863 | refs/heads/master | 2023-04-05T09:04:58.110638 | 2021-04-12T07:59:41 | 2021-04-12T07:59:41 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,295 | cpp | // g++ 编译
// 编码 gb2312
#include <windows.h>
#include <iostream>
#include <stdio.h>
using namespace std;
#define BUF_SIZE 10240
DWORD AppendEnvironmentVariable(LPTSTR szName, LPTSTR szNewValue)
{
DWORD dwNewValSize;
PVOID szVal;
DWORD dwReturn;
DWORD dwErr;
dwNewValSize = lstrlen(szNewValue)+1;
szVal = HeapAlloc(GetProcessHeap(), 0, BUF_SIZE);
dwReturn = GetEnvironmentVariable(szName, (LPTSTR)szVal, BUF_SIZE);
if(dwReturn == 0)
{
dwErr = GetLastError();
if(ERROR_ENVVAR_NOT_FOUND == dwErr)
{
cout << "环境变量" << szName << "不存在" << endl;
}
else
{
cout << "append error:" << dwErr << endl;
}
HeapFree(GetProcessHeap(), 0, szVal);
return FALSE;
}
else if(dwReturn > BUF_SIZE)
{
szVal = HeapReAlloc(GetProcessHeap(), 0, szVal, dwReturn+dwNewValSize);
if(NULL == szVal)
{
cout << "Memory error" << endl;
return FALSE;
}
dwReturn = GetEnvironmentVariable(szName, (LPTSTR)szVal, dwReturn);
if(!dwReturn)
{
cout << "GetEnvironmentVariable failed:" << GetLastError() << endl;
HeapFree(GetProcessHeap(), 0, szVal);
return FALSE;
}
}
lstrcat((LPTSTR)szVal, szNewValue);
lstrcat((LPTSTR)szVal, TEXT(";"));
if(!SetEnvironmentVariable(szName, (LPTSTR)szVal))
{
cout << "Set Value Error:" << GetLastError() << endl;
return FALSE;
}
HeapFree(GetProcessHeap(), 0, szVal);
return TRUE;
}
// 显示所有环境变量
DWORD WINAPI EnumEnvironmentVariables()
{
PVOID pEv = GetEnvironmentStrings();
LPTSTR szEnvs;
for(szEnvs = (LPTSTR)pEv; *szEnvs;)
{
cout << szEnvs << endl;
while(*szEnvs++);
}
FreeEnvironmentStrings((LPCH)pEv);
return 0;
}
int main(int argc, PTCHAR argv[])
{
TCHAR szEv[BUF_SIZE];
if(0==lstrcmp("showall", argv[1]) && argc ==2)
{
EnumEnvironmentVariables();
}
else if(0 == lstrcmp("nsd", argv[1]) && argc==2)
{
cout << "添加新的环境变量" << endl;
getchar();
// 添加(此进程的环境变量)
if(!SetEnvironmentVariable(TEXT("b"), TEXT("big")))
{
cout << "添加环境变量失败 error:" << GetLastError() << endl;
return 1;
}
EnumEnvironmentVariables();
cout << "添加环境变量成功" << endl;
getchar();
cout << "修改环境变量" << endl;
getchar();
// 修改
if(!SetEnvironmentVariable(TEXT("b"), TEXT("pig")))
{
cout << "修改环境变量失败 error:" << GetLastError() << endl;
return 2;
}
EnumEnvironmentVariables();
cout << "修改环境变量成功" << endl;
getchar();
cout << "删除环境变量" << endl;
getchar();
// 删除
if(!SetEnvironmentVariable(TEXT("b"), NULL))
{
cout << "添加环境变量失败 error:" << GetLastError() << endl;
return 3;
}
EnumEnvironmentVariables();
cout << "删除环境变量成功" << endl;
}
else if(0 == lstrcmp("get", argv[1]) && argc==2)
{
if(0 == GetEnvironmentVariable(TEXT("username"), szEv, BUF_SIZE))
{
//cout << "获取环境变量失败 error:" << GetLastError() << endl;
DWORD dwErr = GetLastError();
if(ERROR_ENVVAR_NOT_FOUND == dwErr)
{
cout << "环境变量 username 不存在" << endl;
return 4;
}
}
cout << szEv << endl;
}
else if(0 == lstrcmp("append", argv[1]) && argc==2)
{
cout << "追加之前:" << endl;
EnumEnvironmentVariables();
if(!AppendEnvironmentVariable((LPTSTR)TEXT("PATH"), (LPTSTR)TEXT("d:\\demo")))
{
cout << "追加环境变量失败" << endl;
return 5;
}
cout << "追加之后:" << endl;
EnumEnvironmentVariables();
cout << szEv << endl;
}
else
{
cout << "命令错误" << endl;
}
system("pause");
return 0;
} | [
"327209194@qq.com"
] | 327209194@qq.com |
d1ed4fd7527ff67f4bebd2608d8408a0f8a19049 | 23a8341f8aeea38190f989cef99f2ae004326b14 | /Proyecto Final/Proyecto Final/Practica1/Practica1/include/glm/gtx/matrix_major_storage.hpp | e934923f8e912ebdd4e6e48052ebed068ce11a8c | [] | no_license | VanessaMtzMtz/QuintaMarettaCG | 6a803725eb3fc70964325606a6ff848c3da7a4b2 | e1d3b6a39d5d682519c63610f3650ed2f012ec62 | refs/heads/main | 2023-07-16T08:10:11.299053 | 2021-08-11T17:37:09 | 2021-08-11T17:37:09 | 394,727,870 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 129 | hpp | version https://git-lfs.github.com/spec/v1
oid sha256:ec544bb9a20aebb2f32741852521cb1a25b9eb56fab40504dff836eb2035c7ef
size 3881
| [
"78155041+VanessaMtzMtz@users.noreply.github.com"
] | 78155041+VanessaMtzMtz@users.noreply.github.com |
2b505c064d6cea22d252a2cb47f42495cda0666a | a8c87376aab4d8d207e6513d2f3bd5c2061202a3 | /SDSMath/src/colourbasis.cpp | 8b94c0df0e74efc307965bf642f84fd5ff213849 | [] | no_license | eigenbom/SDS | dd53a1532bfeec7701a303303336bf9504758e76 | d3b37fba429d597d71b84347ef9987f84e68acae | refs/heads/master | 2020-07-09T07:16:18.495976 | 2015-07-02T01:32:44 | 2015-07-02T01:32:44 | 203,913,721 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,390 | cpp | #include "colourbasis.h"
#include "hmath.h"
using namespace Math;
using std::string;
ParamList ColourBasis::mParameters;
const Parameter*
ColourBasis::getParameter(string name)
{
std::vector<Parameter>::const_iterator it = getParameters().begin();
while (it!=mParameters.end())
{
if (it->name == name) return &(*it);
it++;
}
return NULL;
}
ColourMap::ColourMap()
:mBasis(0),mSpline(0)
{
mSpline = new ColourSpline();
}
ColourMap::~ColourMap()
{
delete mSpline;
}
Colour
ColourMap::
operator()(double x, double y, double z)
{
double val = (*mBasis)(x,y,z);
return (*mSpline)(val);
}
Colour
Marble::
operator()(double x, double y, double z)
{
x += (*mBasis)(x,y,z);
if (x > 1) x -= floor(x);
return (*mSpline)(x);
}
Flagstone::Flagstone()
{}
Flagstone::~Flagstone()
{}
Colour
Flagstone::
operator()(double x, double y, double z)
{
unsigned long ref = mBasis.getCell(x,y,z);
double val = mBasis.n2n1(x,y,z);
static Colour mortar = Colour(250/255.,240/255.,215/255.);
static Colour table[4] = {Colour(236./255,168./255,134./255),
Colour(233./255,220./255,191./255),
Colour(238./255,204./255,122./255),
Colour(199./255,162./255,103./255)};
// get upper 2 bits
ref >>= 30;
return Colour::mix(table[ref]*(0.7+0.5*val)*(1+0.1*mNoise(5*x,5*y,5*z)),mortar*(1+0.05*mNoise(7.7*x,7.7*y,7.7*z)),1-Math::step(0.1,val));
}
// CMixer
CMixer::CMixer():mBasis(0),mOne(0),mTwo(0){}
Colour
CMixer::
operator()(double x, double y, double z)
{
return Colour::mix((*mOne)(x,y,z),(*mTwo)(x,y,z),(*mBasis)(x,y,z));
}
//CDarken
ParamList CDarken::mParameters;
CDarken::CDarken()
:mOne(0),mBasis(0),mAmount(0.5)
{
if (mParameters.size()==0)
{
mParameters = ColourBasis::mParameters;
mParameters.push_back(Parameter("darken",0.0f,1.0f,0.5f));
}
}
void CDarken::setParameter(string name, double f)
{
if (name=="darken")
mAmount = f;
else ColourBasis::setParameter(name,f);
}
double CDarken::getParameterf(string name)
{
if (name=="darken")
return mAmount;
else return ColourBasis::getParameterf(name);
}
Colour
CDarken::
operator()(double x, double y, double z) // returns a single double in the range [0,1]
{
return (*mOne)(x,y,z) * Math::lerp(1,(*mBasis)(x,y,z),mAmount);
}
| [
"benjamin.porter@gmail.com"
] | benjamin.porter@gmail.com |
a62a790fde6c0f784be741b98c2b8be03c46be97 | 5fc0e67f855bbc2f23139e5e550a6c5bd9244c29 | /src/map.cpp | 749fbae385b81596ce0a1119e4144862eab4f316 | [] | no_license | Intey/roguelike_tutorial | 7c9511188a832bf0f9c1d9eafbceb85b8bb28471 | 5e065eb3cc8ec0efd9f5e57bea5a62540bb6b6da | refs/heads/master | 2021-01-23T08:52:48.061315 | 2014-08-06T09:51:30 | 2014-08-06T09:51:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,537 | cpp | #include "main.hpp"
static const int ROOM_MAX_SIZE = 12;
static const int ROOM_MIN_SIZE = 6;
static const int MAX_ROOM_MONSTERS = 3;
static const int MAX_ROOM_ITEMS = 2;
class BspListener : public ITCODBspCallback {
private:
Map ↦
int roomNum;
int lastx, lasty;
public:
BspListener(Map &map) : map(map), roomNum(0) {}
bool visitNode(TCODBsp *node, void *userData) {
if ( node->isLeaf() ) {
int x, y, h, w;
TCODRandom *rng = TCODRandom::getInstance();
w=rng->getInt(ROOM_MIN_SIZE, node->w-2);
h=rng->getInt(ROOM_MIN_SIZE, node->h-2);
x=rng->getInt(node->x+1, node->x+node->w-w-1);
y=rng->getInt(node->y+1, node->y+node->h-h-1);
map.createRoom(roomNum == 0, x, y, x+w-1, y+h-1);
if ( roomNum != 0 ) {
map.dig(lastx, lasty, x+w/2, lasty);
map.dig(x+w/2, lasty, x+w/2, y+h/2);
}
lastx = x+w/2;
lasty = y+ h/2;
roomNum++;
}
return true;
}
};
Map::Map(int width, int height): width(width), height(height){
tiles = new Tile[width*height];
map = new TCODMap(width, height);
TCODBsp bsp(0, 0, width, height);
bsp.splitRecursive(NULL, 8, ROOM_MAX_SIZE, ROOM_MAX_SIZE, 1.5f, 1.5f);
BspListener listener(*this);
bsp.traverseInvertedLevelOrder(&listener, NULL);
}
Map::~Map() {
delete [] tiles;
delete map;
}
void Map::dig(int x, int y, int x1, int y1) {
if ( x1 < x) {
int tmp = x1;
x1 = x;
x = tmp;
}
if (y1 < y) {
int tmp = y1;
y1 = y;
y = tmp;
}
for (int tilex=x; tilex <= x1; tilex++ ){
for (int tiley = y; tiley <= y1; tiley++){
map->setProperties(tilex, tiley, true, true);
}
}
}
void Map::createRoom(bool first, int x1, int y1, int x2, int y2) {
dig(x1,y1,x2,y2);
//place player in center of first room
if (first) {
engine.player->x=(x1+x2)/2;
engine.player->y=(y1+y2)/2;
}else{
TCODRandom *rng=TCODRandom::getInstance();
int nbMosters = rng->getInt(0, MAX_ROOM_MONSTERS);
while ( nbMosters > 0 ) {
int x = rng->getInt(x1,x2);
int y = rng->getInt(y1,y2);
if ( isWalkable(x,y) ) {
addMonster(x,y);
}
nbMosters--;
}
int nbItems=rng->getInt(0, MAX_ROOM_ITEMS);
while( nbItems > 0 ) {
int x = rng->getInt(x1,x2);
int y = rng->getInt(y1,y2);
if ( isWalkable(x,y) ) {
addItem(x,y);
}
nbItems--;
}
}
}
bool Map::isWalkable(int x, int y) const {
return map->isWalkable(x,y);
}
void Map::render() const {
static const TCODColor darkWall( 0, 50, 50 );
static const TCODColor darkGround( 0, 0, 50 );
static const TCODColor lightWall( 50, 150, 150 );
static const TCODColor lightGround( 80, 200, 150 );
for ( int x=0; x < width; x++ ) {
for ( int y=0; y < height; y++ ) {
if ( isInFov(x,y) ) {
TCODConsole::root->setCharBackground( x, y,
isWalkable( x, y ) ? lightGround : lightWall );
}else if ( isExplored(x,y) ){
TCODConsole::root->setCharBackground( x, y,
isWalkable( x, y ) ? darkGround : darkWall );
}
}
}
}
bool Map::isExplored(int x, int y) const {
return tiles[x+y*width].explored;
}
bool Map::isInFov(int x, int y) const {
if ( x < 0 || x >= width || y < 0 || y >= height ) {
return false;
}
if ( map->isInFov(x, y)) {
tiles[x+y*width].explored=true;
return true;
}
return false;
}
void Map::computeFov() {
map->computeFov(engine.player->x,engine.player->y,
engine.fovRadius);
}
bool Map::canWalk(int x, int y) const {
if ( !isWalkable(x,y) ) return false;
for (Actor **iterator = engine.actors.begin(); iterator != engine.actors.end(); iterator++) {
Actor *actor = *iterator;
if ( actor->blocks && actor->x == x && actor->y == y ) {
return false;
}
}
return true;
}
void Map::addMonster(int x, int y) {
TCODRandom *rng = TCODRandom::getInstance();
if ( rng->getInt(0,100) < 80 ) {
Actor *orc = new Actor(x, y, 'o', "orc", TCODColor::desaturatedGreen);
orc->destructible = new MonsterDestructible(10,0,"dead orc");
orc->attacker = new Attacker(3);
orc->ai = new MonsterAi();
engine.actors.push(orc);
} else {
Actor *troll =new Actor(x,y, 'T', "troll", TCODColor::darkerGreen);
troll->destructible = new MonsterDestructible(16,1,"troll carcass");
troll->attacker = new Attacker(4);
troll->ai = new MonsterAi();
engine.actors.push(troll);
}
}
void Map::addItem(int x, int y) {
TCODRandom *rng = TCODRandom::getInstance();
int dice = rng->getInt(0, 100);
if ( dice < 50 ) {
Actor *healthPotion = new Actor(x,y,'*',"health potion", TCODColor::violet);
healthPotion->blocks = false;
healthPotion->pickable = new Healer(5);
engine.actors.push(healthPotion);
} else if ( dice < 80 ) {
Actor *scrollOfLightingBolt = new Actor(x,y,'#',"scroll of lighting bolt",
TCODColor::lightYellow);
scrollOfLightingBolt->blocks = false;
scrollOfLightingBolt->pickable=new LightingBolt(5,20);
engine.actors.push(scrollOfLightingBolt);
} else if ( dice < 90 ) {
Actor *scrollOfFireball = new Actor(x, y, '^', "scroll of fireball", TCODColor::lightYellow);
scrollOfFireball->blocks = false;
scrollOfFireball->pickable = new Fireball(3,12);
engine.actors.push(scrollOfFireball);
} else if ( dice < 95 ) {
Actor *scrollOfConfusion = new Actor(x, y, '%', "scroll of confuse", TCODColor::lightYellow);
scrollOfConfusion->blocks = false;
scrollOfConfusion->pickable = new Confuser(10,8);
engine.actors.push(scrollOfConfusion);
} else if ( dice < 100 ) {
Actor *DmgAura = new Actor(x,y,'+', "Damage totem", TCODColor::lightRed);
DmgAura->blocks = false;
DmgAura->pickable = new DamageAura(4);
engine.actors.push(DmgAura);
}
}
| [
"ziexe0@gmail.com"
] | ziexe0@gmail.com |
df3f31ed6ab1572d4d3286b5780a6636c1b428ae | d6f64231bb6b5d59b0170ee59e655039af55976b | /ModelManager.h | 278a6a229e6f817657c0865ca4fb9a694d88ffef | [] | no_license | genis/HeavyBall | 59515e7aea35688cbc275e09fcb63fe09b3e3652 | 3d679f51f9b909dd5c2d55b88b98d286d1ec3273 | refs/heads/master | 2020-07-05T06:26:28.234133 | 2013-05-14T12:00:34 | 2013-05-14T12:00:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 311 | h | #pragma once
#include "Model.h"
#include <string>
#include <map>
using namespace std;
class ModelManager
{
public:
ModelManager(void);
~ModelManager(void);
void loadModel(const string& name, const char* modelPath);
Model* getModel(const string& name) const;
private:
map<string, Model*> modelData;
};
| [
"gsolesorribes@gmail.com"
] | gsolesorribes@gmail.com |
59110bb5e749cb9a6d26238644779cba4283cb47 | 5fb63168c2c7cf3fb4096acfde4ab7a3ddd14805 | /src/test/hpcg/comp-mg.h | c552fc0f135cc4772e9c8749ac89ca89573dbeb5 | [
"MIT"
] | permissive | HExSA-Lab/nautilus | fccdb3bfa3de24df4f267d349dde578644b59514 | e6e38c41c059c6186e2c2e6ba73111bf042e2b18 | refs/heads/master | 2022-05-22T22:00:26.816844 | 2020-12-22T00:06:47 | 2020-12-22T00:06:47 | 143,364,231 | 38 | 30 | NOASSERTION | 2022-05-14T18:19:31 | 2018-08-03T01:53:57 | C | UTF-8 | C++ | false | false | 3,412 | h | /**
* Copyright (c) 2014 Los Alamos National Security, LLC
* 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.
*
* 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.
*
* LA-CC 10-123
*/
#ifndef LGNCG_COMP_MG_H_INCLUDED
#define LGNCG_COMP_MG_H_INCLUDED
#include "tids.h"
#include "vector.h"
#include "sparsemat.h"
#include "utils.h"
#include "vec-zero.h"
#include "comp-spmv.h"
#include "comp-symgs.h"
#include "comp-restriction.h"
#include "comp-prolongation.h"
namespace lgncg {
static inline void
mgPrep(SparseMatrix &A,
Vector &r,
Vector &x,
LegionRuntime::HighLevel::Context &ctx,
LegionRuntime::HighLevel::HighLevelRuntime *lrt)
{
// recursively push partition schemes on the target data structures.
if (A.mgData) {
//A.mgData->Axf.partition(A.nParts, ctx, lrt); // already partitioned
r.partition(A.nParts, ctx, lrt);
x.partition(A.nParts, ctx, lrt);
//A.Ac->partition(A.geom, ctx, lrt); // already partitioned
A.mgData->rc.partition(A.nParts, ctx, lrt);
A.mgData->xc.partition(A.nParts, ctx, lrt);
// now do the same for the next coarsest level
mgPrep(*A.Ac, A.mgData->rc, A.mgData->xc, ctx, lrt);
}
}
static inline void
mg(SparseMatrix &A,
Vector &r,
Vector &x,
LegionRuntime::HighLevel::Context &ctx,
LegionRuntime::HighLevel::HighLevelRuntime *lrt)
{
// zero out x
veczero(x, ctx, lrt);
// go to the next coarsest level if available
if (A.mgData) {
const int64_t nPresmootherSteps = A.mgData->nPresmootherSteps;
for (int64_t i = 0; i < nPresmootherSteps; ++i) {
symgs(A, x, r, ctx, lrt);
}
spmv(A, x, A.mgData->Axf, ctx, lrt);
// perform restriction operation using simple injection
restriction(A, r, ctx, lrt);
mg(*A.Ac, A.mgData->rc, A.mgData->xc, ctx, lrt);
prolongation(A, x, ctx, lrt);
const int64_t nPostsmootherSteps = A.mgData->nPostsmootherSteps;
for (int64_t i = 0; i < nPostsmootherSteps; ++i) {
symgs(A, x, r, ctx, lrt);
}
}
else {
symgs(A, x, r, ctx, lrt);
}
}
}
#endif
| [
"root@v-test-dl320e.cs.northwestern.edu"
] | root@v-test-dl320e.cs.northwestern.edu |
37833c70bdb20afd9cb4f4e6e53764686f75a8a0 | b59fee706f75c9a347c8687b1ab7110ec52a69e7 | /hphp/third_party/folly/folly/Chrono.h | 6465098be0f9b4b328f0b86cadfa4318e78ad8ef | [
"Apache-2.0",
"Zend-2.0",
"LicenseRef-scancode-unknown-license-reference",
"PHP-3.01"
] | permissive | renesugar/hiphop-php | 4391d30b4a05bad1400aa999155bc83ab1f40086 | 4eb05b745fd3018a6d9e51464cae06a4465ee142 | refs/heads/master | 2020-04-11T04:51:03.875501 | 2013-09-11T18:05:53 | 2013-09-13T19:35:48 | 136,534,446 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,030 | h | /*
* Copyright 2013 Facebook, Inc.
*
* 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.
*/
// Wrapper around <chrono> that hides away some gcc 4.6 issues
#ifndef FOLLY_CHRONO_H_
#define FOLLY_CHRONO_H_
#include <chrono>
#include "folly/Portability.h"
// gcc 4.6 uses an obsolete name for steady_clock, although the implementation
// is the same
#if __GNUC_PREREQ(4, 6) && !__GNUC_PREREQ(4, 7)
namespace std { namespace chrono {
typedef monotonic_clock steady_clock;
}} // namespaces
#endif
#endif /* FOLLY_CHRONO_H_ */
| [
"sgolemon@fb.com"
] | sgolemon@fb.com |
380683464d795f8ada15e3e9bb910b45491556e2 | e1994e2b4319e13523d4ebacd2c2a8d8fe01d83d | /FlipCompundC.cpp | 1229c63b35570106919ebcf33652fe8ea338ccd0 | [] | no_license | JeremiahKalmus/OOD-p4 | 4a6fedfc4549575e2cd13052459b175f67d40ede | 61458c27672a48c59bb5cbdf599a50bcf6267dd2 | refs/heads/master | 2020-06-06T00:02:07.437080 | 2019-06-18T17:03:17 | 2019-06-18T17:03:17 | 192,581,204 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,672 | cpp | // Author: Jeremiah Kalmus
// File: FlipCompundC.cpp
// Date: May 15th, 2019
// Version: 1.0
/*
* IMPLEMENTATION INVARIANTS:
* 1 - Reference compundC and Flip for additional functionality.
* ---------------------------------------------------------------------------------------------------------------------------------
* CLASS INVARIANTS:
* 1 - CONSTRUCTORS:
*
* One constructor takes in 4 parameter which are the encapsulated_string that will be flipped in Flip_Password when called, the default password
* length that is the p value in compundC Class (see compundC for details), the forbidden_char_input (see compundC for details), and the K number of
* state changes the object can have before permenantly preventing further state changes (see compundC for details).
* The other constructor is a default constructor that calls the default constructor in compundC and Flip classes. See compundC and Flip for further
* default constructor information.
*
* 2 - Check_Flipped_Password:
*
* Is an unsigned integer that can be any value and will take all characters in the encapsulated_string up to the flip_digit
* number character in the string and flip that part of the string. If 0 or 1 is entered, then the string will be identical
* to the dafult encapsulated_string (nothing will flip for 0 and the first character will flip with itself which is the same
* result). If the flip_digit is equal or larger than the length of the encapsulated_string, then the whole string will be flipped_string
* regardless of how much larger flip_digit is than the length of the encapsulated_string (see Flip for further information). Afterwards, the
* method will then take the returned flipped string and check that against the compundC specifications (see compundC for further information).
* ---------------------------------------------------------------------------------------------------------------------------------
*/
#include<string>
#include "FlipCompundC.h"
using namespace std;
FlipCompundC::FlipCompundC() : compundC(), Flip() {}
FlipCompundC::FlipCompundC(string input_encapsulated_string, unsigned default_password_length, char forbidden_char_input, unsigned max_state_changes)
: compundC(default_password_length, forbidden_char_input, max_state_changes),
Flip(input_encapsulated_string)
{}
// PRE: Password needs to be entered by the client
// POST: Object state may be toggled and state_counter may be incremented
bool FlipCompundC::Check_Flipped_Password(unsigned flip_digit)
{
return Password_Check(Flip_Password(flip_digit));
} | [
"noreply@github.com"
] | noreply@github.com |
7cd53521f718d5710ffacebebc5b6d67b8506384 | a31edaf4843ff669d459d3150a7eebcd24f7e579 | /Numeryczne/Lab2/main.cpp | e88510c225d0ce1028642bf42f410e42aad926ae | [] | no_license | Ginkooo/PolibudaCode | 1d57b68cd7f62feb933bc90342f6128ff991f35d | 583c2b07b6947df782a412f26b224efc5c9e4180 | refs/heads/master | 2021-01-11T01:17:09.642285 | 2018-12-13T23:50:00 | 2018-12-13T23:50:00 | 70,732,542 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 728 | cpp | #include <iostream>
using namespace std;
float lagrange(float x[], float y[], float arg)
{
int pointsCount = sizeof(x) / sizeof(*x);
float il;
float ret = 0;
for (int i = 0; i < pointsCount; i++)
{
il = 1;
for (int j = 0; j < pointsCount; j++)
{
if (j != i)
{
il*=((arg-x[j])/(x[i]-x[j]));
}
}
ret += il*y[i];
}
return ret;
}
int main()
{
float x[] = { 1, 3, 4, 6 };
float y[] = { -1, -9, 13, -59 };
float pkt;
cout << "Podaj punkt, w którym chcesz wyliczyć przybliżoną wartość funkcji: ";
cin >> pkt;
cout << "Przybliżona wartość wynosi: " << lagrange(x, y, pkt);
}
| [
"piotr_czajka@outlook.com"
] | piotr_czajka@outlook.com |
17a62286db2916a0309f04425fdc581fcc41470b | 19d987b268e24ae225e25b23024a5f0120081fd1 | /World/Space/SpaceShip.cpp | d195a62abcdead0ac9de6850b19b40aae35516cf | [
"CC0-1.0",
"MIT"
] | permissive | SaxonRah/QuestWeaver | 7da32946aa8045f631a4e1b5a0aefbd5f25bde1b | f7e7b3364942336cd2ee14a6699a448a8cd55dc5 | refs/heads/master | 2021-01-22T13:38:10.429190 | 2016-09-19T05:20:56 | 2016-09-19T05:21:22 | 68,661,827 | 1 | 0 | null | 2016-09-20T01:34:11 | 2016-09-20T01:34:11 | null | UTF-8 | C++ | false | false | 669 | cpp | //
// Created by michael on 18.07.16.
//
#include "World/Space/SpaceShip.h"
using namespace weave;
using namespace std;
const string SpaceShip::Type = "spaceShip";
std::string SpaceShip::ToString() const noexcept {
return Name;
}
SpaceShip::SpaceShip(ID id, int seed, std::string name, shared_ptr<SpaceAgent> owner) :
WorldEntity(id), Seed(seed), Name(name), Owner(owner) {
}
SpaceShip::SpaceShip(int seed, std::string name, shared_ptr<SpaceAgent> owner) :
SpaceShip(NoID, seed, name, owner) {
}
SpaceShip::SpaceShip() : SpaceShip(0, 0, "", make_shared<SpaceAgent>()) {
}
std::string SpaceShip::GetType() const noexcept {
return Type;
}
| [
"galetzka@posteo.de"
] | galetzka@posteo.de |
7a714450191e464e998040fc7185e2ab113e1075 | 991f950cc9096522cc8d1442e7689edca6288179 | /SPOJ/TTM - To the moon/2.cpp | 45e07f741193fe0a6d793bd274274fd01a8d5026 | [
"MIT"
] | permissive | tiger0132/code-backup | 1a767e8debeddc8054caa018f648c5e74ff9d6e4 | 9cb4ee5e99bf3c274e34f1e59d398ab52e51ecf7 | refs/heads/master | 2021-06-18T04:58:31.395212 | 2021-04-25T15:23:16 | 2021-04-25T15:23:16 | 160,021,239 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,705 | cpp | #include <algorithm>
#include <cstdio>
#include <cstring>
typedef long long ll;
const int N = 1e5 + 51;
struct pSGT {
#define L ch][0
#define R ch][1
#define mid (l + r) / 2
static const int M = N << 5;
int ch[M][2], nc;
ll t[M], s[M];
inline int cl(int x) {
return nc++, nc[L] = x[L], nc[R] = x[R], nc[t] = x[t], nc[s] = x[s], nc;
}
void build(int& x, int l, int r, int* a) {
if (x = ++nc, l == r) return x[s] = a[l], void();
build(x[L], l, mid, a), build(x[R], mid + 1, r, a), x[s] = x[L][s] + x[R][s];
}
ll qry(int x, int l, int r, int ql, int qr) {
if (ql == l && r == qr) return x[s] + x[t] * (r - l + 1);
ll v = (qr - ql + 1) * x[t];
if (qr <= mid) return v + qry(x[L], l, mid, ql, qr);
if (mid < ql) return v + qry(x[R], mid + 1, r, ql, qr);
return v + qry(x[L], l, mid, ql, mid) + qry(x[R], mid + 1, r, mid + 1, qr);
}
void upd(int& x, int l, int r, int ql, int qr, int y) {
if (x = cl(x), ql <= l && r <= qr) return x[t] += y, void();
if (ql <= mid) upd(x[L], l, mid, ql, qr, y);
if (mid < qr) upd(x[R], mid + 1, r, ql, qr, y);
x[s] = x[L][s] + x[R][s] + (mid - l + 1) * x[L][t] + (r - mid) * x[R][t];
}
} psgt;
int n, m, x, y, z, tp, a[N], rt[N];
char op[2];
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) scanf("%d", a + i);
psgt.build(rt[0], 1, n, a);
while (m--) {
scanf("%s%d", op, &x);
if (*op == 'C') {
scanf("%d%d", &y, &z), tp++;
psgt.upd(rt[tp] = rt[tp - 1], 1, n, x, y, z);
} else if (*op == 'Q') {
scanf("%d", &y);
printf("%lld\n", psgt.qry(rt[tp], 1, n, x, y));
} else if (*op == 'H') {
scanf("%d%d", &y, &z);
printf("%lld\n", psgt.qry(rt[z], 1, n, x, y));
} else if (*op == 'B')
tp = x;
}
} | [
"4c5948@gmail.com"
] | 4c5948@gmail.com |
785fa32f76802e8b53306de72585cc2d8450e61f | 3b93bd02e7ffffb1bb9e9c1437f06166ee39d349 | /GRAPH/Questions/Snake-and-Ladder.cpp | 5a3b071eb2852cc14aac9d6bd760beb5a9f97ec3 | [] | no_license | khusboobothra/DSA | d38371bcf8979b37b324477409c0fe52684c953d | 602c81586c87bff3b012f506514be65980eb2ed3 | refs/heads/master | 2023-08-03T10:49:02.154823 | 2021-09-06T12:00:43 | 2021-09-06T12:00:43 | 399,560,847 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,714 | cpp | //Problem : https://www.interviewbit.com/problems/snake-ladder-problem/
//Code :
int Solution::snakeLadder(vector<vector<int> > &A, vector<vector<int> > &B) {
unordered_map<int,int>snake,ladder;
for(auto it:A)
{
ladder[it[0]]=it[1];
}
for(auto it:B)
{
snake[it[0]]=it[1];
}
bool visited[101]={false};
//queue for level order traversal
queue<int>q;
q.push(1);
visited[1]=true;
int level=0;
while(!q.empty())
{
int sz=q.size();
//remove all the nodes of the current level
while(sz--)
{
int pos=q.front();
q.pop();
//if we have reached the destination
if(pos==100)
return level;
for(int i=1;i<=6;i++)
{
//check if the next position is within the boundary or not.Also visited or not
if(pos+i<=100 && visited[pos+i]==false)
{
int newPos=pos+i;
//if snake is present
if(snake.find(newPos)!=snake.end())
{
visited[newPos]=true;
newPos=snake[newPos];
}
//if ladder is present
if(ladder.find(newPos)!=ladder.end())
{
visited[newPos]=true;
newPos=ladder[newPos];
}
if(visited[newPos]==false)
{
q.push(newPos);
visited[newPos]=true;
}
}
}
}
level++;
}
return -1;
}
| [
"bothrakhushboo2405@gmail.com"
] | bothrakhushboo2405@gmail.com |
5d5ad6e5ea9d4da9f182962262ab6633846ea14d | 970dc71a9dea95273c718f3f4cba2d4f81510e9c | /GondarEngine/gsCollisionProxy.cpp | 30cb3534e33dd20f584a548643820b3cf4cd9712 | [] | no_license | ViolaTarek/GondarGameEngine | 4f72794a163ed411ec5a68d48a246c3d6b508d00 | cae7770b885127929724ba94cf37ceede23ac536 | refs/heads/master | 2020-04-05T02:18:59.262339 | 2016-11-01T19:39:18 | 2016-11-01T19:39:18 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 2,743 | cpp | #include "gsCollisionProxy.h"
bool gsCollisionProxy::broadTest(const gsCollisionProxy& a, const gsCollisionProxy& b) {
if (a.aabbMax.x < b.aabbMin.x) return false;
if (a.aabbMax.y < b.aabbMin.y) return false;
if (a.aabbMax.z < b.aabbMin.z) return false;
if (a.aabbMin.x > b.aabbMax.x) return false;
if (a.aabbMin.y > b.aabbMax.y) return false;
if (a.aabbMin.z > b.aabbMax.z) return false;
return true;
}
#define min(a, b) ((a < b) ? a : b)
#define max(a, b) ((a > b) ? a : b)
const gsCollisionInfo* gsCollisionProxy::narrowTest(const gsCollisionProxy& a, const gsCollisionProxy& b) {
gsVector3 imin, imax; // intersection min and max
// Encontrando a AABB da interseção.
imin.x = max(a.aabbMin.x, b.aabbMin.x);
imin.y = max(a.aabbMin.y, b.aabbMin.y);
imin.z = max(a.aabbMin.z, b.aabbMin.z);
imax.x = min(a.aabbMax.x, b.aabbMax.x);
imax.y = min(a.aabbMax.y, b.aabbMax.y);
imax.z = min(a.aabbMax.z, b.aabbMax.z);
// Criando os 8 pontos de contato
gsVector3 contactPoints[8];
contactPoints[0] = gsVector3(imin.x, imin.y, imin.z);
contactPoints[1] = gsVector3(imin.x, imin.y, imax.z);
contactPoints[2] = gsVector3(imin.x, imax.y, imin.z);
contactPoints[3] = gsVector3(imin.x, imax.y, imax.z);
contactPoints[4] = gsVector3(imax.x, imin.y, imin.z);
contactPoints[5] = gsVector3(imax.x, imin.y, imax.z);
contactPoints[6] = gsVector3(imax.x, imax.y, imin.z);
contactPoints[7] = gsVector3(imax.x, imax.y, imax.z);
gsVector3 pen1, pen2, icenter;
icenter = (imax - imin) / 2;
//workaround to make it all 2D
icenter.z = 5000.0f;
// Encontrando o vetor penetração no eixo de menor interseção
if(icenter.x < icenter.y) {
if(icenter.x < icenter.z) {
// x é o eixo com a interceção menor
if (a.aabbMin.x < b.aabbMin.x) {
pen1.x = -icenter.x;
pen2.x = +icenter.x;
} else {
pen1.x = +icenter.x;
pen2.x = -icenter.x;
}
} else {
// z é o eixo com a interceção menor
if (a.aabbMin.z < b.aabbMin.z) {
pen1.z = -icenter.z;
pen2.z = +icenter.z;
} else {
pen1.z = +icenter.z;
pen2.z = -icenter.z;
}
}
} else {
if(icenter.y < icenter.z) {
// y é o eixo com a interceção menor
if (a.aabbMin.y < b.aabbMin.y) {
pen1.y = -icenter.y;
pen2.y = +icenter.y;
} else {
pen1.y = +icenter.y;
pen2.y = -icenter.y;
}
} else {
// z é o eixo com a interceção menor
if (a.aabbMin.z < b.aabbMin.z) {
pen1.z = -icenter.z;
pen2.z = +icenter.z;
} else {
pen1.z = +icenter.z;
pen2.z = -icenter.z;
}
}
}
// criando o relatório da colisão
gsCollisionInfo *info = new gsCollisionInfo[2];
info[0] = gsCollisionInfo(pen1, contactPoints);
info[1] = gsCollisionInfo(pen2, contactPoints);
return info;
} | [
"ygor.reboucas@gmail.com"
] | ygor.reboucas@gmail.com |
c2c96d66c107e1f694bdc5898ffcfc5cdcc2deb1 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/curl/gumtree/curl_new_log_16316.cpp | 95c4f661086a214171c42cbe02047d405d3204d6 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 555 | cpp | fputs(
" lines and lines starting with '#' are comments and ignored; each\n"
" header can be folded by splitting between two words and starting\n"
" the continuation line with a space; embedded carriage-returns\n"
" and trailing spaces are stripped. Here is an example of a\n"
" header file contents:\n"
"\n"
" # This file contain two headers.\n"
" X-header-1: this is a header\n"
"\n"
" # The following header is folded.\n"
, stdout); | [
"993273596@qq.com"
] | 993273596@qq.com |
62942693c5fea7f798b64c8135fcb7de62060898 | b00c54389a95d81a22e361fa9f8bdf5a2edc93e3 | /hardware/qcom/display/msm8226/libhwcomposer/hwc_utils.cpp | 4377725b7b2114ac119cc38156258e2d639a6d6f | [] | no_license | mirek190/x86-android-5.0 | 9d1756fa7ff2f423887aa22694bd737eb634ef23 | eb1029956682072bb7404192a80214189f0dc73b | refs/heads/master | 2020-05-27T01:09:51.830208 | 2015-10-07T22:47:36 | 2015-10-07T22:47:36 | 41,942,802 | 15 | 20 | null | 2020-03-09T00:21:03 | 2015-09-05T00:11:19 | null | UTF-8 | C++ | false | false | 75,773 | cpp | /*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (C) 2012-2014, The Linux Foundation All rights reserved.
*
* Not a Contribution, Apache license notifications and license are retained
* for attribution purposes only.
*
* 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.
*/
#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL)
#define HWC_UTILS_DEBUG 0
#include <math.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <binder/IServiceManager.h>
#include <EGL/egl.h>
#include <cutils/properties.h>
#include <utils/Trace.h>
#include <gralloc_priv.h>
#include <overlay.h>
#include <overlayRotator.h>
#include <overlayWriteback.h>
#include "hwc_utils.h"
#include "hwc_mdpcomp.h"
#include "hwc_fbupdate.h"
#include "hwc_ad.h"
#include "mdp_version.h"
#include "hwc_copybit.h"
#include "hwc_dump_layers.h"
#include "external.h"
#include "virtual.h"
#include "hwc_qclient.h"
#include "QService.h"
#include "comptype.h"
#include "hwc_virtual.h"
#include "qd_utils.h"
using namespace qClient;
using namespace qService;
using namespace android;
using namespace overlay;
using namespace overlay::utils;
namespace ovutils = overlay::utils;
#ifdef QCOM_BSP
#ifdef __cplusplus
extern "C" {
#endif
EGLAPI EGLBoolean eglGpuPerfHintQCOM(EGLDisplay dpy, EGLContext ctx,
EGLint *attrib_list);
#define EGL_GPU_HINT_1 0x32D0
#define EGL_GPU_HINT_2 0x32D1
#define EGL_GPU_LEVEL_0 0x0
#define EGL_GPU_LEVEL_1 0x1
#define EGL_GPU_LEVEL_2 0x2
#define EGL_GPU_LEVEL_3 0x3
#define EGL_GPU_LEVEL_4 0x4
#define EGL_GPU_LEVEL_5 0x5
#ifdef __cplusplus
}
#endif
#endif
namespace qhwc {
bool isValidResolution(hwc_context_t *ctx, uint32_t xres, uint32_t yres)
{
return !((xres > qdutils::MAX_DISPLAY_DIM &&
!isDisplaySplit(ctx, HWC_DISPLAY_PRIMARY)) ||
(xres < MIN_DISPLAY_XRES || yres < MIN_DISPLAY_YRES));
}
void changeResolution(hwc_context_t *ctx, int xres_orig, int yres_orig) {
//Store original display resolution.
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres_orig = xres_orig;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres_orig = yres_orig;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].customFBSize = false;
char property[PROPERTY_VALUE_MAX] = {'\0'};
char *yptr = NULL;
if (property_get("debug.hwc.fbsize", property, NULL) > 0) {
yptr = strcasestr(property,"x");
int xres = atoi(property);
int yres = atoi(yptr + 1);
if (isValidResolution(ctx,xres,yres) &&
xres != xres_orig && yres != yres_orig) {
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres = xres;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres = yres;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].customFBSize = true;
}
}
}
static int openFramebufferDevice(hwc_context_t *ctx)
{
struct fb_fix_screeninfo finfo;
struct fb_var_screeninfo info;
int fb_fd = openFb(HWC_DISPLAY_PRIMARY);
if(fb_fd < 0) {
ALOGE("%s: Error Opening FB : %s", __FUNCTION__, strerror(errno));
return -errno;
}
if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &info) == -1) {
ALOGE("%s:Error in ioctl FBIOGET_VSCREENINFO: %s", __FUNCTION__,
strerror(errno));
close(fb_fd);
return -errno;
}
if (int(info.width) <= 0 || int(info.height) <= 0) {
// the driver doesn't return that information
// default to 160 dpi
info.width = ((info.xres * 25.4f)/160.0f + 0.5f);
info.height = ((info.yres * 25.4f)/160.0f + 0.5f);
}
float xdpi = (info.xres * 25.4f) / info.width;
float ydpi = (info.yres * 25.4f) / info.height;
#ifdef MSMFB_METADATA_GET
struct msmfb_metadata metadata;
memset(&metadata, 0 , sizeof(metadata));
metadata.op = metadata_op_frame_rate;
if (ioctl(fb_fd, MSMFB_METADATA_GET, &metadata) == -1) {
ALOGE("%s:Error retrieving panel frame rate: %s", __FUNCTION__,
strerror(errno));
close(fb_fd);
return -errno;
}
float fps = metadata.data.panel_frame_rate;
#else
//XXX: Remove reserved field usage on all baselines
//The reserved[3] field is used to store FPS by the driver.
float fps = info.reserved[3] & 0xFF;
#endif
if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &finfo) == -1) {
ALOGE("%s:Error in ioctl FBIOGET_FSCREENINFO: %s", __FUNCTION__,
strerror(errno));
close(fb_fd);
return -errno;
}
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd = fb_fd;
//xres, yres may not be 32 aligned
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].stride = finfo.line_length /(info.xres/8);
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres = info.xres;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres = info.yres;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xdpi = xdpi;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].ydpi = ydpi;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period = 1000000000l / fps;
//To change resolution of primary display
changeResolution(ctx, info.xres, info.yres);
//Unblank primary on first boot
if(ioctl(fb_fd, FBIOBLANK,FB_BLANK_UNBLANK) < 0) {
ALOGE("%s: Failed to unblank display", __FUNCTION__);
return -errno;
}
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isActive = true;
return 0;
}
void initContext(hwc_context_t *ctx)
{
openFramebufferDevice(ctx);
ctx->mMDP.version = qdutils::MDPVersion::getInstance().getMDPVersion();
ctx->mMDP.hasOverlay = qdutils::MDPVersion::getInstance().hasOverlay();
ctx->mMDP.panel = qdutils::MDPVersion::getInstance().getPanelType();
overlay::Overlay::initOverlay();
ctx->mOverlay = overlay::Overlay::getInstance();
ctx->mRotMgr = RotMgr::getInstance();
//Is created and destroyed only once for primary
//For external it could get created and destroyed multiple times depending
//on what external we connect to.
ctx->mFBUpdate[HWC_DISPLAY_PRIMARY] =
IFBUpdate::getObject(ctx, HWC_DISPLAY_PRIMARY);
// Check if the target supports copybit compostion (dyn/mdp) to
// decide if we need to open the copybit module.
int compositionType =
qdutils::QCCompositionType::getInstance().getCompositionType();
// Only MDP copybit is used
if ((compositionType & (qdutils::COMPOSITION_TYPE_DYN |
qdutils::COMPOSITION_TYPE_MDP)) &&
(qdutils::MDPVersion::getInstance().getMDPVersion() ==
qdutils::MDP_V3_0_4)) {
ctx->mCopyBit[HWC_DISPLAY_PRIMARY] = new CopyBit(ctx,
HWC_DISPLAY_PRIMARY);
}
ctx->mExtDisplay = new ExternalDisplay(ctx);
ctx->mVirtualDisplay = new VirtualDisplay(ctx);
ctx->mVirtualonExtActive = false;
ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isActive = false;
ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected = false;
ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isActive = false;
ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected = false;
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].mDownScaleMode= false;
ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].mDownScaleMode = false;
ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].mDownScaleMode = false;
ctx->mMDPComp[HWC_DISPLAY_PRIMARY] =
MDPComp::getObject(ctx, HWC_DISPLAY_PRIMARY);
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].connected = true;
ctx->mHWCVirtual = HWCVirtualBase::getObject();
for (uint32_t i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) {
ctx->mHwcDebug[i] = new HwcDebug(i);
ctx->mLayerRotMap[i] = new LayerRotMap();
ctx->mAnimationState[i] = ANIMATION_STOPPED;
ctx->dpyAttr[i].mActionSafePresent = false;
ctx->dpyAttr[i].mAsWidthRatio = 0;
ctx->dpyAttr[i].mAsHeightRatio = 0;
}
for (uint32_t i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) {
ctx->mPrevHwLayerCount[i] = 0;
}
MDPComp::init(ctx);
ctx->mAD = new AssertiveDisplay(ctx);
ctx->vstate.enable = false;
ctx->vstate.fakevsync = false;
ctx->mExtOrientation = 0;
ctx->numActiveDisplays = 1;
//Right now hwc starts the service but anybody could do it, or it could be
//independent process as well.
QService::init();
sp<IQClient> client = new QClient(ctx);
interface_cast<IQService>(
defaultServiceManager()->getService(
String16("display.qservice")))->connect(client);
// Initialize device orientation to its default orientation
ctx->deviceOrientation = 0;
ctx->mBufferMirrorMode = false;
// Read the system property to determine if downscale feature is enabled.
ctx->mMDPDownscaleEnabled = false;
char value[PROPERTY_VALUE_MAX];
if(property_get("sys.hwc.mdp_downscale_enabled", value, "false")
&& !strcmp(value, "true")) {
ctx->mMDPDownscaleEnabled = true;
}
// Initialize gpu perfomance hint related parameters
property_get("sys.hwc.gpu_perf_mode", value, "0");
#ifdef QCOM_BSP
ctx->mGPUHintInfo.mGpuPerfModeEnable = atoi(value)? true : false;
ctx->mGPUHintInfo.mEGLDisplay = NULL;
ctx->mGPUHintInfo.mEGLContext = NULL;
ctx->mGPUHintInfo.mPrevCompositionGLES = false;
ctx->mGPUHintInfo.mCurrGPUPerfMode = EGL_GPU_LEVEL_0;
#endif
ALOGI("Initializing Qualcomm Hardware Composer");
ALOGI("MDP version: %d", ctx->mMDP.version);
}
void closeContext(hwc_context_t *ctx)
{
if(ctx->mOverlay) {
delete ctx->mOverlay;
ctx->mOverlay = NULL;
}
if(ctx->mRotMgr) {
delete ctx->mRotMgr;
ctx->mRotMgr = NULL;
}
for(int i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) {
if(ctx->mCopyBit[i]) {
delete ctx->mCopyBit[i];
ctx->mCopyBit[i] = NULL;
}
}
if(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd) {
close(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd);
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd = -1;
}
if(ctx->mExtDisplay) {
delete ctx->mExtDisplay;
ctx->mExtDisplay = NULL;
}
for(int i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) {
if(ctx->mFBUpdate[i]) {
delete ctx->mFBUpdate[i];
ctx->mFBUpdate[i] = NULL;
}
if(ctx->mMDPComp[i]) {
delete ctx->mMDPComp[i];
ctx->mMDPComp[i] = NULL;
}
if(ctx->mHwcDebug[i]) {
delete ctx->mHwcDebug[i];
ctx->mHwcDebug[i] = NULL;
}
if(ctx->mLayerRotMap[i]) {
delete ctx->mLayerRotMap[i];
ctx->mLayerRotMap[i] = NULL;
}
}
if(ctx->mHWCVirtual) {
delete ctx->mHWCVirtual;
ctx->mHWCVirtual = NULL;
}
if(ctx->mAD) {
delete ctx->mAD;
ctx->mAD = NULL;
}
}
void dumpsys_log(android::String8& buf, const char* fmt, ...)
{
va_list varargs;
va_start(varargs, fmt);
buf.appendFormatV(fmt, varargs);
va_end(varargs);
}
int getExtOrientation(hwc_context_t* ctx) {
int extOrient = ctx->mExtOrientation;
if(ctx->mBufferMirrorMode)
extOrient = getMirrorModeOrientation(ctx);
return extOrient;
}
/* Calculates the destination position based on the action safe rectangle */
void getActionSafePosition(hwc_context_t *ctx, int dpy, hwc_rect_t& rect) {
// Position
int x = rect.left, y = rect.top;
int w = rect.right - rect.left;
int h = rect.bottom - rect.top;
if(!ctx->dpyAttr[dpy].mActionSafePresent)
return;
// Read action safe properties
int asWidthRatio = ctx->dpyAttr[dpy].mAsWidthRatio;
int asHeightRatio = ctx->dpyAttr[dpy].mAsHeightRatio;
float wRatio = 1.0;
float hRatio = 1.0;
float xRatio = 1.0;
float yRatio = 1.0;
int fbWidth = ctx->dpyAttr[dpy].xres;
int fbHeight = ctx->dpyAttr[dpy].yres;
if(ctx->dpyAttr[dpy].mDownScaleMode) {
// if downscale Mode is enabled for external, need to query
// the actual width and height, as that is the physical w & h
ctx->mExtDisplay->getAttributes(fbWidth, fbHeight);
}
// Since external is rotated 90, need to swap width/height
int extOrient = getExtOrientation(ctx);
if(extOrient & HWC_TRANSFORM_ROT_90)
swap(fbWidth, fbHeight);
float asX = 0;
float asY = 0;
float asW = fbWidth;
float asH = fbHeight;
// based on the action safe ratio, get the Action safe rectangle
asW = fbWidth * (1.0f - asWidthRatio / 100.0f);
asH = fbHeight * (1.0f - asHeightRatio / 100.0f);
asX = (fbWidth - asW) / 2;
asY = (fbHeight - asH) / 2;
// calculate the position ratio
xRatio = (float)x/fbWidth;
yRatio = (float)y/fbHeight;
wRatio = (float)w/fbWidth;
hRatio = (float)h/fbHeight;
//Calculate the position...
x = (xRatio * asW) + asX;
y = (yRatio * asH) + asY;
w = (wRatio * asW);
h = (hRatio * asH);
// Convert it back to hwc_rect_t
rect.left = x;
rect.top = y;
rect.right = w + rect.left;
rect.bottom = h + rect.top;
return;
}
// This function gets the destination position for Seconday display
// based on the position and aspect ratio with orientation
void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation,
hwc_rect_t& inRect, hwc_rect_t& outRect) {
hwc_rect_t viewFrame = ctx->mViewFrame[dpy];
// Physical display resolution
float fbWidth = ctx->dpyAttr[dpy].xres;
float fbHeight = ctx->dpyAttr[dpy].yres;
//display position(x,y,w,h) in correct aspectratio after rotation
int xPos = 0;
int yPos = 0;
float width = fbWidth;
float height = fbHeight;
// Width/Height used for calculation, after rotation
float actualWidth = fbWidth;
float actualHeight = fbHeight;
float wRatio = 1.0;
float hRatio = 1.0;
float xRatio = 1.0;
float yRatio = 1.0;
hwc_rect_t rect = {0, 0, (int)fbWidth, (int)fbHeight};
Dim inPos(inRect.left, inRect.top, inRect.right - inRect.left,
inRect.bottom - inRect.top);
Dim outPos(outRect.left, outRect.top, outRect.right - outRect.left,
outRect.bottom - outRect.top);
Whf whf(fbWidth, fbHeight, 0);
eTransform extorient = static_cast<eTransform>(extOrientation);
// To calculate the destination co-ordinates in the new orientation
preRotateSource(extorient, whf, inPos);
if(extOrientation & HAL_TRANSFORM_ROT_90) {
// Swap width/height for input position
swapWidthHeight(actualWidth, actualHeight);
getAspectRatioPosition(fbWidth, fbHeight, (int)actualWidth,
(int)actualHeight, rect);
xPos = rect.left;
yPos = rect.top;
width = rect.right - rect.left;
height = rect.bottom - rect.top;
// swap viewframe coordinates for 90 degree rotation.
swap(viewFrame.left, viewFrame.top);
swap(viewFrame.right, viewFrame.bottom);
}
// if viewframe left and top coordinates are non zero value then exclude it
// during the computation of xRatio and yRatio
xRatio = (inPos.x - viewFrame.left)/actualWidth;
yRatio = (inPos.y - viewFrame.top)/actualHeight;
// Use viewframe width and height to compute wRatio and hRatio.
wRatio = (float)inPos.w/(float)(viewFrame.right - viewFrame.left);
hRatio = (float)inPos.h/(float)(viewFrame.bottom - viewFrame.top);
//Calculate the position...
outPos.x = (xRatio * width) + xPos;
outPos.y = (yRatio * height) + yPos;
outPos.w = wRatio * width;
outPos.h = hRatio * height;
ALOGD_IF(HWC_UTILS_DEBUG, "%s: Calculated AspectRatio Position: x = %d,"
"y = %d w = %d h = %d", __FUNCTION__, outPos.x, outPos.y,
outPos.w, outPos.h);
// For sidesync, the dest fb will be in portrait orientation, and the crop
// will be updated to avoid the black side bands, and it will be upscaled
// to fit the dest RB, so recalculate
// the position based on the new width and height
if ((extOrientation & HWC_TRANSFORM_ROT_90) &&
isOrientationPortrait(ctx)) {
hwc_rect_t r = {0, 0, 0, 0};
//Calculate the position
xRatio = (outPos.x - xPos)/width;
// GetaspectRatio -- tricky to get the correct aspect ratio
// But we need to do this.
getAspectRatioPosition(width, height, width, height, r);
xPos = r.left;
yPos = r.top;
float tempHeight = r.bottom - r.top;
yRatio = yPos/height;
wRatio = outPos.w/width;
hRatio = tempHeight/height;
//Map the coordinates back to Framebuffer domain
outPos.x = (xRatio * fbWidth);
outPos.y = (yRatio * fbHeight);
outPos.w = wRatio * fbWidth;
outPos.h = hRatio * fbHeight;
ALOGD_IF(HWC_UTILS_DEBUG, "%s: Calculated AspectRatio for device in"
"portrait: x = %d,y = %d w = %d h = %d", __FUNCTION__,
outPos.x, outPos.y,
outPos.w, outPos.h);
}
if(ctx->dpyAttr[dpy].mDownScaleMode) {
int extW, extH;
if(dpy == HWC_DISPLAY_EXTERNAL)
ctx->mExtDisplay->getAttributes(extW, extH);
else
ctx->mVirtualDisplay->getAttributes(extW, extH);
fbWidth = ctx->dpyAttr[dpy].xres;
fbHeight = ctx->dpyAttr[dpy].yres;
//Calculate the position...
xRatio = outPos.x/fbWidth;
yRatio = outPos.y/fbHeight;
wRatio = outPos.w/fbWidth;
hRatio = outPos.h/fbHeight;
outPos.x = xRatio * extW;
outPos.y = yRatio * extH;
outPos.w = wRatio * extW;
outPos.h = hRatio * extH;
}
// Convert Dim to hwc_rect_t
outRect.left = outPos.x;
outRect.top = outPos.y;
outRect.right = outPos.x + outPos.w;
outRect.bottom = outPos.y + outPos.h;
return;
}
bool isPrimaryPortrait(hwc_context_t *ctx) {
int fbWidth = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres;
int fbHeight = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres;
if(fbWidth < fbHeight) {
return true;
}
return false;
}
bool isOrientationPortrait(hwc_context_t *ctx) {
if(isPrimaryPortrait(ctx)) {
return !(ctx->deviceOrientation & 0x1);
}
return (ctx->deviceOrientation & 0x1);
}
void calcExtDisplayPosition(hwc_context_t *ctx,
private_handle_t *hnd,
int dpy,
hwc_rect_t& sourceCrop,
hwc_rect_t& displayFrame,
int& transform,
ovutils::eTransform& orient) {
// Swap width and height when there is a 90deg transform
int extOrient = getExtOrientation(ctx);
if(dpy && !qdutils::MDPVersion::getInstance().is8x26()) {
if(!isYuvBuffer(hnd)) {
if(extOrient & HWC_TRANSFORM_ROT_90) {
int dstWidth = ctx->dpyAttr[dpy].xres;
int dstHeight = ctx->dpyAttr[dpy].yres;;
int srcWidth = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres;
int srcHeight = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres;
if(!isPrimaryPortrait(ctx)) {
swap(srcWidth, srcHeight);
} // Get Aspect Ratio for external
getAspectRatioPosition(dstWidth, dstHeight, srcWidth,
srcHeight, displayFrame);
// Crop - this is needed, because for sidesync, the dest fb will
// be in portrait orientation, so update the crop to not show the
// black side bands.
if (isOrientationPortrait(ctx)) {
sourceCrop = displayFrame;
displayFrame.left = 0;
displayFrame.top = 0;
displayFrame.right = dstWidth;
displayFrame.bottom = dstHeight;
}
}
if(ctx->dpyAttr[dpy].mDownScaleMode) {
int extW, extH;
// if downscale is enabled, map the co-ordinates to new
// domain(downscaled)
float fbWidth = ctx->dpyAttr[dpy].xres;
float fbHeight = ctx->dpyAttr[dpy].yres;
// query MDP configured attributes
if(dpy == HWC_DISPLAY_EXTERNAL)
ctx->mExtDisplay->getAttributes(extW, extH);
else
ctx->mVirtualDisplay->getAttributes(extW, extH);
//Calculate the ratio...
float wRatio = ((float)extW)/fbWidth;
float hRatio = ((float)extH)/fbHeight;
//convert Dim to hwc_rect_t
displayFrame.left *= wRatio;
displayFrame.top *= hRatio;
displayFrame.right *= wRatio;
displayFrame.bottom *= hRatio;
}
}else {
if(extOrient || ctx->dpyAttr[dpy].mDownScaleMode) {
getAspectRatioPosition(ctx, dpy, extOrient,
displayFrame, displayFrame);
}
}
// If there is a external orientation set, use that
if(extOrient) {
transform = extOrient;
orient = static_cast<ovutils::eTransform >(extOrient);
}
// Calculate the actionsafe dimensions for External(dpy = 1 or 2)
getActionSafePosition(ctx, dpy, displayFrame);
}
}
/* Returns the orientation which needs to be set on External for
* SideSync/Buffer Mirrormode
*/
int getMirrorModeOrientation(hwc_context_t *ctx) {
int extOrientation = 0;
int deviceOrientation = ctx->deviceOrientation;
if(!isPrimaryPortrait(ctx))
deviceOrientation = (deviceOrientation + 1) % 4;
if (deviceOrientation == 0)
extOrientation = HWC_TRANSFORM_ROT_270;
else if (deviceOrientation == 1)//90
extOrientation = 0;
else if (deviceOrientation == 2)//180
extOrientation = HWC_TRANSFORM_ROT_90;
else if (deviceOrientation == 3)//270
extOrientation = HWC_TRANSFORM_FLIP_V | HWC_TRANSFORM_FLIP_H;
return extOrientation;
}
bool isDownscaleRequired(hwc_layer_1_t const* layer) {
hwc_rect_t displayFrame = layer->displayFrame;
hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
int dst_w, dst_h, src_w, src_h;
dst_w = displayFrame.right - displayFrame.left;
dst_h = displayFrame.bottom - displayFrame.top;
src_w = sourceCrop.right - sourceCrop.left;
src_h = sourceCrop.bottom - sourceCrop.top;
if(((src_w > dst_w) || (src_h > dst_h)))
return true;
return false;
}
bool needsScaling(hwc_layer_1_t const* layer) {
int dst_w, dst_h, src_w, src_h;
hwc_rect_t displayFrame = layer->displayFrame;
hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
dst_w = displayFrame.right - displayFrame.left;
dst_h = displayFrame.bottom - displayFrame.top;
src_w = sourceCrop.right - sourceCrop.left;
src_h = sourceCrop.bottom - sourceCrop.top;
if(((src_w != dst_w) || (src_h != dst_h)))
return true;
return false;
}
// Checks if layer needs scaling with split
bool needsScalingWithSplit(hwc_context_t* ctx, hwc_layer_1_t const* layer,
const int& dpy) {
int src_width_l, src_height_l;
int src_width_r, src_height_r;
int dst_width_l, dst_height_l;
int dst_width_r, dst_height_r;
int hw_w = ctx->dpyAttr[dpy].xres;
int hw_h = ctx->dpyAttr[dpy].yres;
hwc_rect_t cropL, dstL, cropR, dstR;
const int lSplit = getLeftSplit(ctx, dpy);
hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
hwc_rect_t displayFrame = layer->displayFrame;
private_handle_t *hnd = (private_handle_t *)layer->handle;
cropL = sourceCrop;
dstL = displayFrame;
hwc_rect_t scissorL = { 0, 0, lSplit, hw_h };
scissorL = getIntersection(ctx->mViewFrame[dpy], scissorL);
qhwc::calculate_crop_rects(cropL, dstL, scissorL, 0);
cropR = sourceCrop;
dstR = displayFrame;
hwc_rect_t scissorR = { lSplit, 0, hw_w, hw_h };
scissorR = getIntersection(ctx->mViewFrame[dpy], scissorR);
qhwc::calculate_crop_rects(cropR, dstR, scissorR, 0);
// Sanitize Crop to stitch
sanitizeSourceCrop(cropL, cropR, hnd);
// Calculate the left dst
dst_width_l = dstL.right - dstL.left;
dst_height_l = dstL.bottom - dstL.top;
src_width_l = cropL.right - cropL.left;
src_height_l = cropL.bottom - cropL.top;
// check if there is any scaling on the left
if(((src_width_l != dst_width_l) || (src_height_l != dst_height_l)))
return true;
// Calculate the right dst
dst_width_r = dstR.right - dstR.left;
dst_height_r = dstR.bottom - dstR.top;
src_width_r = cropR.right - cropR.left;
src_height_r = cropR.bottom - cropR.top;
// check if there is any scaling on the right
if(((src_width_r != dst_width_r) || (src_height_r != dst_height_r)))
return true;
return false;
}
bool isAlphaScaled(hwc_layer_1_t const* layer) {
if(needsScaling(layer) && isAlphaPresent(layer)) {
return true;
}
return false;
}
bool isAlphaPresent(hwc_layer_1_t const* layer) {
private_handle_t *hnd = (private_handle_t *)layer->handle;
if(hnd) {
int format = hnd->format;
switch(format) {
case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_BGRA_8888:
// In any more formats with Alpha go here..
return true;
default : return false;
}
}
return false;
}
static void trimLayer(hwc_context_t *ctx, const int& dpy, const int& transform,
hwc_rect_t& crop, hwc_rect_t& dst) {
int hw_w = ctx->dpyAttr[dpy].xres;
int hw_h = ctx->dpyAttr[dpy].yres;
if(dst.left < 0 || dst.top < 0 ||
dst.right > hw_w || dst.bottom > hw_h) {
hwc_rect_t scissor = {0, 0, hw_w, hw_h };
scissor = getIntersection(ctx->mViewFrame[dpy], scissor);
qhwc::calculate_crop_rects(crop, dst, scissor, transform);
}
}
static void trimList(hwc_context_t *ctx, hwc_display_contents_1_t *list,
const int& dpy) {
for(uint32_t i = 0; i < list->numHwLayers - 1; i++) {
hwc_layer_1_t *layer = &list->hwLayers[i];
hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf);
trimLayer(ctx, dpy,
list->hwLayers[i].transform,
(hwc_rect_t&)crop,
(hwc_rect_t&)list->hwLayers[i].displayFrame);
layer->sourceCropf.left = crop.left;
layer->sourceCropf.right = crop.right;
layer->sourceCropf.top = crop.top;
layer->sourceCropf.bottom = crop.bottom;
}
}
hwc_rect_t calculateDisplayViewFrame(hwc_context_t *ctx, int dpy) {
int dstWidth = ctx->dpyAttr[dpy].xres;
int dstHeight = ctx->dpyAttr[dpy].yres;
int srcWidth = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres;
int srcHeight = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres;
// default we assume viewframe as a full frame for primary display
hwc_rect outRect = {0, 0, dstWidth, dstHeight};
if(dpy) {
// swap srcWidth and srcHeight, if the device orientation is 90 or 270.
if(ctx->deviceOrientation & 0x1) {
swap(srcWidth, srcHeight);
}
// Get Aspect Ratio for external
getAspectRatioPosition(dstWidth, dstHeight, srcWidth,
srcHeight, outRect);
}
ALOGD_IF(HWC_UTILS_DEBUG, "%s: view frame for dpy %d is [%d %d %d %d]",
__FUNCTION__, dpy, outRect.left, outRect.top,
outRect.right, outRect.bottom);
return outRect;
}
void setListStats(hwc_context_t *ctx,
hwc_display_contents_1_t *list, int dpy) {
const int prevYuvCount = ctx->listStats[dpy].yuvCount;
memset(&ctx->listStats[dpy], 0, sizeof(ListStats));
ctx->listStats[dpy].numAppLayers = list->numHwLayers - 1;
ctx->listStats[dpy].fbLayerIndex = list->numHwLayers - 1;
ctx->listStats[dpy].skipCount = 0;
ctx->listStats[dpy].preMultipliedAlpha = false;
ctx->listStats[dpy].isSecurePresent = false;
ctx->listStats[dpy].yuvCount = 0;
char property[PROPERTY_VALUE_MAX];
ctx->listStats[dpy].extOnlyLayerIndex = -1;
ctx->listStats[dpy].isDisplayAnimating = false;
ctx->listStats[dpy].roi = ovutils::Dim(0, 0,
(int)ctx->dpyAttr[dpy].xres, (int)ctx->dpyAttr[dpy].yres);
ctx->listStats[dpy].secureUI = false;
ctx->listStats[dpy].yuv4k2kCount = 0;
ctx->mViewFrame[dpy] = (hwc_rect_t){0, 0, 0, 0};
ctx->dpyAttr[dpy].mActionSafePresent = isActionSafePresent(ctx, dpy);
trimList(ctx, list, dpy);
optimizeLayerRects(list);
// Calculate view frame of ext display from primary resolution
// and primary device orientation.
ctx->mViewFrame[dpy] = calculateDisplayViewFrame(ctx, dpy);
for (size_t i = 0; i < (size_t)ctx->listStats[dpy].numAppLayers; i++) {
hwc_layer_1_t const* layer = &list->hwLayers[i];
private_handle_t *hnd = (private_handle_t *)layer->handle;
#ifdef QCOM_BSP
if (layer->flags & HWC_SCREENSHOT_ANIMATOR_LAYER) {
ctx->listStats[dpy].isDisplayAnimating = true;
}
if(isSecureDisplayBuffer(hnd)) {
ctx->listStats[dpy].secureUI = true;
}
#endif
// continue if number of app layers exceeds MAX_NUM_APP_LAYERS
if(ctx->listStats[dpy].numAppLayers > MAX_NUM_APP_LAYERS)
continue;
//reset yuv indices
ctx->listStats[dpy].yuvIndices[i] = -1;
ctx->listStats[dpy].yuv4k2kIndices[i] = -1;
if (isSecureBuffer(hnd)) {
ctx->listStats[dpy].isSecurePresent = true;
}
if (isSkipLayer(&list->hwLayers[i])) {
ctx->listStats[dpy].skipCount++;
}
if (UNLIKELY(isYuvBuffer(hnd))) {
int& yuvCount = ctx->listStats[dpy].yuvCount;
ctx->listStats[dpy].yuvIndices[yuvCount] = i;
yuvCount++;
if(UNLIKELY(is4kx2kYuvBuffer(hnd))){
int& yuv4k2kCount = ctx->listStats[dpy].yuv4k2kCount;
ctx->listStats[dpy].yuv4k2kIndices[yuv4k2kCount] = i;
yuv4k2kCount++;
}
if((layer->transform & HWC_TRANSFORM_ROT_90) &&
canUseRotator(ctx, dpy)) {
if( (dpy == HWC_DISPLAY_PRIMARY) &&
ctx->mOverlay->isPipeTypeAttached(OV_MDP_PIPE_DMA)) {
ctx->isPaddingRound = true;
}
Overlay::setDMAMode(Overlay::DMA_BLOCK_MODE);
}
}
if(layer->blending == HWC_BLENDING_PREMULT)
ctx->listStats[dpy].preMultipliedAlpha = true;
if(UNLIKELY(isExtOnly(hnd))){
ctx->listStats[dpy].extOnlyLayerIndex = i;
}
}
if(ctx->listStats[dpy].yuvCount > 0) {
if (property_get("hw.cabl.yuv", property, NULL) > 0) {
if (atoi(property) != 1) {
property_set("hw.cabl.yuv", "1");
}
}
} else {
if (property_get("hw.cabl.yuv", property, NULL) > 0) {
if (atoi(property) != 0) {
property_set("hw.cabl.yuv", "0");
}
}
}
if(dpy) {
//uncomment the below code for testing purpose.
/* char value[PROPERTY_VALUE_MAX];
property_get("sys.ext_orientation", value, "0");
// Assuming the orientation value is in terms of HAL_TRANSFORM,
// This needs mapping to HAL, if its in different convention
ctx->mExtOrientation = atoi(value); */
// Assuming the orientation value is in terms of HAL_TRANSFORM,
// This needs mapping to HAL, if its in different convention
if(ctx->mExtOrientation || ctx->mBufferMirrorMode) {
ALOGD_IF(HWC_UTILS_DEBUG, "%s: ext orientation = %d"
"BufferMirrorMode = %d", __FUNCTION__,
ctx->mExtOrientation, ctx->mBufferMirrorMode);
if(ctx->mOverlay->isPipeTypeAttached(OV_MDP_PIPE_DMA)) {
ctx->isPaddingRound = true;
}
Overlay::setDMAMode(Overlay::DMA_BLOCK_MODE);
}
}
//The marking of video begin/end is useful on some targets where we need
//to have a padding round to be able to shift pipes across mixers.
if(prevYuvCount != ctx->listStats[dpy].yuvCount) {
ctx->mVideoTransFlag = true;
}
if(dpy == HWC_DISPLAY_PRIMARY) {
ctx->mAD->markDoable(ctx, list);
}
}
static void calc_cut(double& leftCutRatio, double& topCutRatio,
double& rightCutRatio, double& bottomCutRatio, int orient) {
if(orient & HAL_TRANSFORM_FLIP_H) {
swap(leftCutRatio, rightCutRatio);
}
if(orient & HAL_TRANSFORM_FLIP_V) {
swap(topCutRatio, bottomCutRatio);
}
if(orient & HAL_TRANSFORM_ROT_90) {
//Anti clock swapping
double tmpCutRatio = leftCutRatio;
leftCutRatio = topCutRatio;
topCutRatio = rightCutRatio;
rightCutRatio = bottomCutRatio;
bottomCutRatio = tmpCutRatio;
}
}
bool isSecuring(hwc_context_t* ctx, hwc_layer_1_t const* layer) {
if((ctx->mMDP.version < qdutils::MDSS_V5) &&
(ctx->mMDP.version > qdutils::MDP_V3_0) &&
ctx->mSecuring) {
return true;
}
if (isSecureModePolicy(ctx->mMDP.version)) {
private_handle_t *hnd = (private_handle_t *)layer->handle;
if(ctx->mSecureMode) {
if (! isSecureBuffer(hnd)) {
ALOGD_IF(HWC_UTILS_DEBUG,"%s:Securing Turning ON ...",
__FUNCTION__);
return true;
}
} else {
if (isSecureBuffer(hnd)) {
ALOGD_IF(HWC_UTILS_DEBUG,"%s:Securing Turning OFF ...",
__FUNCTION__);
return true;
}
}
}
return false;
}
bool isSecureModePolicy(int mdpVersion) {
if (mdpVersion < qdutils::MDSS_V5)
return true;
else
return false;
}
// returns true if Action safe dimensions are set and target supports Actionsafe
bool isActionSafePresent(hwc_context_t *ctx, int dpy) {
// if external supports underscan, do nothing
// it will be taken care in the driver
// Disable Action safe for 8974 due to HW limitation for downscaling
// layers with overlapped region
// Disable Actionsafe for non HDMI displays.
if(!(dpy == HWC_DISPLAY_EXTERNAL) ||
qdutils::MDPVersion::getInstance().is8x74v2() ||
ctx->mExtDisplay->isCEUnderscanSupported()) {
return false;
}
char value[PROPERTY_VALUE_MAX];
// Read action safe properties
property_get("persist.sys.actionsafe.width", value, "0");
ctx->dpyAttr[dpy].mAsWidthRatio = atoi(value);
property_get("persist.sys.actionsafe.height", value, "0");
ctx->dpyAttr[dpy].mAsHeightRatio = atoi(value);
if(!ctx->dpyAttr[dpy].mAsWidthRatio && !ctx->dpyAttr[dpy].mAsHeightRatio) {
//No action safe ratio set, return
return false;
}
return true;
}
int getBlending(int blending) {
switch(blending) {
case HWC_BLENDING_NONE:
return overlay::utils::OVERLAY_BLENDING_OPAQUE;
case HWC_BLENDING_PREMULT:
return overlay::utils::OVERLAY_BLENDING_PREMULT;
case HWC_BLENDING_COVERAGE :
default:
return overlay::utils::OVERLAY_BLENDING_COVERAGE;
}
}
//Crops source buffer against destination and FB boundaries
void calculate_crop_rects(hwc_rect_t& crop, hwc_rect_t& dst,
const hwc_rect_t& scissor, int orient) {
int& crop_l = crop.left;
int& crop_t = crop.top;
int& crop_r = crop.right;
int& crop_b = crop.bottom;
int crop_w = crop.right - crop.left;
int crop_h = crop.bottom - crop.top;
int& dst_l = dst.left;
int& dst_t = dst.top;
int& dst_r = dst.right;
int& dst_b = dst.bottom;
int dst_w = abs(dst.right - dst.left);
int dst_h = abs(dst.bottom - dst.top);
const int& sci_l = scissor.left;
const int& sci_t = scissor.top;
const int& sci_r = scissor.right;
const int& sci_b = scissor.bottom;
double leftCutRatio = 0.0, rightCutRatio = 0.0, topCutRatio = 0.0,
bottomCutRatio = 0.0;
if(dst_l < sci_l) {
leftCutRatio = (double)(sci_l - dst_l) / (double)dst_w;
dst_l = sci_l;
}
if(dst_r > sci_r) {
rightCutRatio = (double)(dst_r - sci_r) / (double)dst_w;
dst_r = sci_r;
}
if(dst_t < sci_t) {
topCutRatio = (double)(sci_t - dst_t) / (double)dst_h;
dst_t = sci_t;
}
if(dst_b > sci_b) {
bottomCutRatio = (double)(dst_b - sci_b) / (double)dst_h;
dst_b = sci_b;
}
calc_cut(leftCutRatio, topCutRatio, rightCutRatio, bottomCutRatio, orient);
crop_l += (int)round((double)crop_w * leftCutRatio);
crop_t += (int)round((double)crop_h * topCutRatio);
crop_r -= (int)round((double)crop_w * rightCutRatio);
crop_b -= (int)round((double)crop_h * bottomCutRatio);
}
bool areLayersIntersecting(const hwc_layer_1_t* layer1,
const hwc_layer_1_t* layer2) {
hwc_rect_t irect = getIntersection(layer1->displayFrame,
layer2->displayFrame);
return isValidRect(irect);
}
bool isValidRect(const hwc_rect& rect)
{
return ((rect.bottom > rect.top) && (rect.right > rect.left)) ;
}
/* computes the intersection of two rects */
hwc_rect_t getIntersection(const hwc_rect_t& rect1, const hwc_rect_t& rect2)
{
hwc_rect_t res;
if(!isValidRect(rect1) || !isValidRect(rect2)){
return (hwc_rect_t){0, 0, 0, 0};
}
res.left = max(rect1.left, rect2.left);
res.top = max(rect1.top, rect2.top);
res.right = min(rect1.right, rect2.right);
res.bottom = min(rect1.bottom, rect2.bottom);
if(!isValidRect(res))
return (hwc_rect_t){0, 0, 0, 0};
return res;
}
/* computes the union of two rects */
hwc_rect_t getUnion(const hwc_rect &rect1, const hwc_rect &rect2)
{
hwc_rect_t res;
if(!isValidRect(rect1)){
return rect2;
}
if(!isValidRect(rect2)){
return rect1;
}
res.left = min(rect1.left, rect2.left);
res.top = min(rect1.top, rect2.top);
res.right = max(rect1.right, rect2.right);
res.bottom = max(rect1.bottom, rect2.bottom);
return res;
}
/* Not a geometrical rect deduction. Deducts rect2 from rect1 only if it results
* a single rect */
hwc_rect_t deductRect(const hwc_rect_t& rect1, const hwc_rect_t& rect2) {
hwc_rect_t res = rect1;
if((rect1.left == rect2.left) && (rect1.right == rect2.right)) {
if((rect1.top == rect2.top) && (rect2.bottom <= rect1.bottom))
res.top = rect2.bottom;
else if((rect1.bottom == rect2.bottom)&& (rect2.top >= rect1.top))
res.bottom = rect2.top;
}
else if((rect1.top == rect2.top) && (rect1.bottom == rect2.bottom)) {
if((rect1.left == rect2.left) && (rect2.right <= rect1.right))
res.left = rect2.right;
else if((rect1.right == rect2.right)&& (rect2.left >= rect1.left))
res.right = rect2.left;
}
return res;
}
void optimizeLayerRects(const hwc_display_contents_1_t *list) {
int i=list->numHwLayers-2;
while(i > 0) {
//see if there is no blending required.
//If it is opaque see if we can substract this region from below
//layers.
if(list->hwLayers[i].blending == HWC_BLENDING_NONE) {
int j= i-1;
hwc_rect_t& topframe =
(hwc_rect_t&)list->hwLayers[i].displayFrame;
while(j >= 0) {
if(!needsScaling(&list->hwLayers[j])) {
hwc_layer_1_t* layer = (hwc_layer_1_t*)&list->hwLayers[j];
hwc_rect_t& bottomframe = layer->displayFrame;
hwc_rect_t bottomCrop =
integerizeSourceCrop(layer->sourceCropf);
int transform =layer->transform;
hwc_rect_t irect = getIntersection(bottomframe, topframe);
if(isValidRect(irect)) {
hwc_rect_t dest_rect;
//if intersection is valid rect, deduct it
dest_rect = deductRect(bottomframe, irect);
qhwc::calculate_crop_rects(bottomCrop, bottomframe,
dest_rect, transform);
//Update layer sourceCropf
layer->sourceCropf.left = bottomCrop.left;
layer->sourceCropf.top = bottomCrop.top;
layer->sourceCropf.right = bottomCrop.right;
layer->sourceCropf.bottom = bottomCrop.bottom;
}
}
j--;
}
}
i--;
}
}
void getNonWormholeRegion(hwc_display_contents_1_t* list,
hwc_rect_t& nwr)
{
uint32_t last = list->numHwLayers - 1;
hwc_rect_t fbDisplayFrame = list->hwLayers[last].displayFrame;
//Initiliaze nwr to first frame
nwr.left = list->hwLayers[0].displayFrame.left;
nwr.top = list->hwLayers[0].displayFrame.top;
nwr.right = list->hwLayers[0].displayFrame.right;
nwr.bottom = list->hwLayers[0].displayFrame.bottom;
for (uint32_t i = 1; i < last; i++) {
hwc_rect_t displayFrame = list->hwLayers[i].displayFrame;
nwr = getUnion(nwr, displayFrame);
}
//Intersect with the framebuffer
nwr = getIntersection(nwr, fbDisplayFrame);
}
bool isExternalActive(hwc_context_t* ctx) {
return ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isActive;
}
void closeAcquireFds(hwc_display_contents_1_t* list) {
if(LIKELY(list)) {
for(uint32_t i = 0; i < list->numHwLayers; i++) {
//Close the acquireFenceFds
//HWC_FRAMEBUFFER are -1 already by SF, rest we close.
if(list->hwLayers[i].acquireFenceFd >= 0) {
close(list->hwLayers[i].acquireFenceFd);
list->hwLayers[i].acquireFenceFd = -1;
}
}
//Writeback
if(list->outbufAcquireFenceFd >= 0) {
close(list->outbufAcquireFenceFd);
list->outbufAcquireFenceFd = -1;
}
}
}
int hwc_sync(hwc_context_t *ctx, hwc_display_contents_1_t* list, int dpy,
int fd) {
ATRACE_CALL();
int ret = 0;
int acquireFd[MAX_NUM_APP_LAYERS];
int count = 0;
int releaseFd = -1;
int retireFd = -1;
int fbFd = -1;
bool swapzero = false;
struct mdp_buf_sync data;
memset(&data, 0, sizeof(data));
data.acq_fen_fd = acquireFd;
data.rel_fen_fd = &releaseFd;
data.retire_fen_fd = &retireFd;
data.flags = MDP_BUF_SYNC_FLAG_RETIRE_FENCE;
char property[PROPERTY_VALUE_MAX];
if(property_get("debug.egl.swapinterval", property, "1") > 0) {
if(atoi(property) == 0)
swapzero = true;
}
bool isExtAnimating = false;
if(dpy)
isExtAnimating = ctx->listStats[dpy].isDisplayAnimating;
//Send acquireFenceFds to rotator
for(uint32_t i = 0; i < ctx->mLayerRotMap[dpy]->getCount(); i++) {
int rotFd = ctx->mRotMgr->getRotDevFd();
int rotReleaseFd = -1;
overlay::Rotator* currRot = ctx->mLayerRotMap[dpy]->getRot(i);
hwc_layer_1_t* currLayer = ctx->mLayerRotMap[dpy]->getLayer(i);
if((currRot == NULL) || (currLayer == NULL)) {
continue;
}
struct mdp_buf_sync rotData;
memset(&rotData, 0, sizeof(rotData));
rotData.acq_fen_fd =
&currLayer->acquireFenceFd;
rotData.rel_fen_fd = &rotReleaseFd; //driver to populate this
rotData.session_id = currRot->getSessId();
int ret = 0;
ret = ioctl(rotFd, MSMFB_BUFFER_SYNC, &rotData);
if(ret < 0) {
ALOGE("%s: ioctl MSMFB_BUFFER_SYNC failed for rot sync, err=%s",
__FUNCTION__, strerror(errno));
} else {
close(currLayer->acquireFenceFd);
//For MDP to wait on.
currLayer->acquireFenceFd =
dup(rotReleaseFd);
//A buffer is free to be used by producer as soon as its copied to
//rotator
currLayer->releaseFenceFd =
rotReleaseFd;
}
}
//Accumulate acquireFenceFds for MDP Overlays
if(list->outbufAcquireFenceFd >= 0) {
//Writeback output buffer
acquireFd[count++] = list->outbufAcquireFenceFd;
}
for(uint32_t i = 0; i < list->numHwLayers; i++) {
if(list->hwLayers[i].compositionType == HWC_OVERLAY &&
list->hwLayers[i].acquireFenceFd >= 0) {
if(UNLIKELY(swapzero))
acquireFd[count++] = -1;
else
acquireFd[count++] = list->hwLayers[i].acquireFenceFd;
}
if(list->hwLayers[i].compositionType == HWC_FRAMEBUFFER_TARGET) {
if(UNLIKELY(swapzero))
acquireFd[count++] = -1;
else if(fd >= 0) {
//set the acquireFD from fd - which is coming from c2d
acquireFd[count++] = fd;
// Buffer sync IOCTL should be async when using c2d fence is
// used
data.flags &= ~MDP_BUF_SYNC_FLAG_WAIT;
} else if(list->hwLayers[i].acquireFenceFd >= 0)
acquireFd[count++] = list->hwLayers[i].acquireFenceFd;
}
}
data.acq_fen_fd_cnt = count;
fbFd = ctx->dpyAttr[dpy].fd;
//Waits for acquire fences, returns a release fence
if(LIKELY(!swapzero)) {
uint64_t start = systemTime();
ret = ioctl(fbFd, MSMFB_BUFFER_SYNC, &data);
ALOGD_IF(HWC_UTILS_DEBUG, "%s: time taken for MSMFB_BUFFER_SYNC IOCTL = %d",
__FUNCTION__, (size_t) ns2ms(systemTime() - start));
}
if(ret < 0) {
ALOGE("%s: ioctl MSMFB_BUFFER_SYNC failed, err=%s",
__FUNCTION__, strerror(errno));
ALOGE("%s: acq_fen_fd_cnt=%d flags=%d fd=%d dpy=%d numHwLayers=%d",
__FUNCTION__, data.acq_fen_fd_cnt, data.flags, fbFd,
dpy, list->numHwLayers);
}
LayerProp *layerProp = ctx->layerProp[dpy];
for(uint32_t i = 0; i < list->numHwLayers; i++) {
if(list->hwLayers[i].compositionType == HWC_OVERLAY ||
list->hwLayers[i].compositionType == HWC_FRAMEBUFFER_TARGET) {
//Populate releaseFenceFds.
if(UNLIKELY(swapzero)) {
list->hwLayers[i].releaseFenceFd = -1;
} else if(isExtAnimating) {
// Release all the app layer fds immediately,
// if animation is in progress.
list->hwLayers[i].releaseFenceFd = -1;
} else if(list->hwLayers[i].releaseFenceFd < 0 ) {
//If rotator has not already populated this field
list->hwLayers[i].releaseFenceFd = dup(releaseFd);
}
}
}
if(fd >= 0) {
close(fd);
fd = -1;
}
if (ctx->mCopyBit[dpy])
ctx->mCopyBit[dpy]->setReleaseFd(releaseFd);
//Signals when MDP finishes reading rotator buffers.
ctx->mLayerRotMap[dpy]->setReleaseFd(releaseFd);
close(releaseFd);
releaseFd = -1;
if(UNLIKELY(swapzero)) {
list->retireFenceFd = -1;
} else {
list->retireFenceFd = retireFd;
}
return ret;
}
void setMdpFlags(hwc_layer_1_t *layer,
ovutils::eMdpFlags &mdpFlags,
int rotDownscale, int transform) {
private_handle_t *hnd = (private_handle_t *)layer->handle;
MetaData_t *metadata = hnd ? (MetaData_t *)hnd->base_metadata : NULL;
if(layer->blending == HWC_BLENDING_PREMULT) {
ovutils::setMdpFlags(mdpFlags,
ovutils::OV_MDP_BLEND_FG_PREMULT);
}
if(isYuvBuffer(hnd)) {
if(isSecureBuffer(hnd)) {
ovutils::setMdpFlags(mdpFlags,
ovutils::OV_MDP_SECURE_OVERLAY_SESSION);
}
if(metadata && (metadata->operation & PP_PARAM_INTERLACED) &&
metadata->interlaced) {
ovutils::setMdpFlags(mdpFlags,
ovutils::OV_MDP_DEINTERLACE);
}
//Pre-rotation will be used using rotator.
if(transform & HWC_TRANSFORM_ROT_90) {
ovutils::setMdpFlags(mdpFlags,
ovutils::OV_MDP_SOURCE_ROTATED_90);
}
}
if(isSecureDisplayBuffer(hnd)) {
// Secure display needs both SECURE_OVERLAY and SECURE_DISPLAY_OV
ovutils::setMdpFlags(mdpFlags,
ovutils::OV_MDP_SECURE_OVERLAY_SESSION);
ovutils::setMdpFlags(mdpFlags,
ovutils::OV_MDP_SECURE_DISPLAY_OVERLAY_SESSION);
}
//No 90 component and no rot-downscale then flips done by MDP
//If we use rot then it might as well do flips
if(!(transform & HWC_TRANSFORM_ROT_90) && !rotDownscale) {
if(transform & HWC_TRANSFORM_FLIP_H) {
ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_FLIP_H);
}
if(transform & HWC_TRANSFORM_FLIP_V) {
ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_FLIP_V);
}
}
if(metadata &&
((metadata->operation & PP_PARAM_HSIC)
|| (metadata->operation & PP_PARAM_IGC)
|| (metadata->operation & PP_PARAM_SHARP2))) {
ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_PP_EN);
}
}
int configRotator(Rotator *rot, Whf& whf,
hwc_rect_t& crop, const eMdpFlags& mdpFlags,
const eTransform& orient, const int& downscale) {
// Fix alignments for TILED format
if(whf.format == MDP_Y_CRCB_H2V2_TILE ||
whf.format == MDP_Y_CBCR_H2V2_TILE) {
whf.w = utils::alignup(whf.w, 64);
whf.h = utils::alignup(whf.h, 32);
}
rot->setSource(whf);
if (qdutils::MDPVersion::getInstance().getMDPVersion() >=
qdutils::MDSS_V5) {
uint32_t crop_w = (crop.right - crop.left);
uint32_t crop_h = (crop.bottom - crop.top);
if (ovutils::isYuv(whf.format)) {
ovutils::normalizeCrop((uint32_t&)crop.left, crop_w);
ovutils::normalizeCrop((uint32_t&)crop.top, crop_h);
// For interlaced, crop.h should be 4-aligned
if ((mdpFlags & ovutils::OV_MDP_DEINTERLACE) && (crop_h % 4))
crop_h = ovutils::aligndown(crop_h, 4);
crop.right = crop.left + crop_w;
crop.bottom = crop.top + crop_h;
}
Dim rotCrop(crop.left, crop.top, crop_w, crop_h);
rot->setCrop(rotCrop);
}
rot->setFlags(mdpFlags);
rot->setTransform(orient);
rot->setDownscale(downscale);
if(!rot->commit()) return -1;
return 0;
}
int configMdp(Overlay *ov, const PipeArgs& parg,
const eTransform& orient, const hwc_rect_t& crop,
const hwc_rect_t& pos, const MetaData_t *metadata,
const eDest& dest) {
ov->setSource(parg, dest);
ov->setTransform(orient, dest);
int crop_w = crop.right - crop.left;
int crop_h = crop.bottom - crop.top;
Dim dcrop(crop.left, crop.top, crop_w, crop_h);
ov->setCrop(dcrop, dest);
int posW = pos.right - pos.left;
int posH = pos.bottom - pos.top;
Dim position(pos.left, pos.top, posW, posH);
ov->setPosition(position, dest);
if (metadata)
ov->setVisualParams(*metadata, dest);
if (!ov->commit(dest)) {
return -1;
}
return 0;
}
int configColorLayer(hwc_context_t *ctx, hwc_layer_1_t *layer,
const int& dpy, eMdpFlags& mdpFlags, eZorder& z,
eIsFg& isFg, const eDest& dest) {
hwc_rect_t dst = layer->displayFrame;
trimLayer(ctx, dpy, 0, dst, dst);
int w = ctx->dpyAttr[dpy].xres;
int h = ctx->dpyAttr[dpy].yres;
int dst_w = dst.right - dst.left;
int dst_h = dst.bottom - dst.top;
uint32_t color = layer->transform;
Whf whf(w, h, getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888), 0);
ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_SOLID_FILL);
if (layer->blending == HWC_BLENDING_PREMULT)
ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDP_BLEND_FG_PREMULT);
PipeArgs parg(mdpFlags, whf, z, isFg, static_cast<eRotFlags>(0),
layer->planeAlpha,
(ovutils::eBlending) getBlending(layer->blending));
// Configure MDP pipe for Color layer
Dim pos(dst.left, dst.top, dst_w, dst_h);
ctx->mOverlay->setSource(parg, dest);
ctx->mOverlay->setColor(color, dest);
ctx->mOverlay->setTransform(0, dest);
ctx->mOverlay->setCrop(pos, dest);
ctx->mOverlay->setPosition(pos, dest);
if (!ctx->mOverlay->commit(dest)) {
ALOGE("%s: Configure color layer failed!", __FUNCTION__);
return -1;
}
return 0;
}
void updateSource(eTransform& orient, Whf& whf,
hwc_rect_t& crop) {
Dim srcCrop(crop.left, crop.top,
crop.right - crop.left,
crop.bottom - crop.top);
orient = static_cast<eTransform>(ovutils::getMdpOrient(orient));
preRotateSource(orient, whf, srcCrop);
if (qdutils::MDPVersion::getInstance().getMDPVersion() >=
qdutils::MDSS_V5) {
// Source for overlay will be the cropped (and rotated)
crop.left = 0;
crop.top = 0;
crop.right = srcCrop.w;
crop.bottom = srcCrop.h;
// Set width & height equal to sourceCrop w & h
whf.w = srcCrop.w;
whf.h = srcCrop.h;
} else {
crop.left = srcCrop.x;
crop.top = srcCrop.y;
crop.right = srcCrop.x + srcCrop.w;
crop.bottom = srcCrop.y + srcCrop.h;
}
}
int configureNonSplit(hwc_context_t *ctx, hwc_layer_1_t *layer,
const int& dpy, eMdpFlags& mdpFlags, eZorder& z,
eIsFg& isFg, const eDest& dest, Rotator **rot) {
private_handle_t *hnd = (private_handle_t *)layer->handle;
if(!hnd) {
if (layer->flags & HWC_COLOR_FILL) {
// Configure Color layer
return configColorLayer(ctx, layer, dpy, mdpFlags, z, isFg, dest);
}
ALOGE("%s: layer handle is NULL", __FUNCTION__);
return -1;
}
MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf);
hwc_rect_t dst = layer->displayFrame;
int transform = layer->transform;
eTransform orient = static_cast<eTransform>(transform);
int downscale = 0;
int rotFlags = ovutils::ROT_FLAGS_NONE;
uint32_t format = ovutils::getMdpFormat(hnd->format, isTileRendered(hnd));
Whf whf(getWidth(hnd), getHeight(hnd), format, hnd->size);
// Handle R/B swap
if (layer->flags & HWC_FORMAT_RB_SWAP) {
if (hnd->format == HAL_PIXEL_FORMAT_RGBA_8888)
whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRA_8888);
else if (hnd->format == HAL_PIXEL_FORMAT_RGBX_8888)
whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRX_8888);
}
calcExtDisplayPosition(ctx, hnd, dpy, crop, dst, transform, orient);
if(isYuvBuffer(hnd) && ctx->mMDP.version >= qdutils::MDP_V4_2 &&
ctx->mMDP.version < qdutils::MDSS_V5) {
downscale = getDownscaleFactor(
crop.right - crop.left,
crop.bottom - crop.top,
dst.right - dst.left,
dst.bottom - dst.top);
if(downscale) {
rotFlags = ROT_DOWNSCALE_ENABLED;
}
}
setMdpFlags(layer, mdpFlags, downscale, transform);
if(isYuvBuffer(hnd) && //if 90 component or downscale, use rot
((transform & HWC_TRANSFORM_ROT_90) || downscale)) {
*rot = ctx->mRotMgr->getNext();
if(*rot == NULL) return -1;
if(!dpy)
BwcPM::setBwc(crop, dst, transform, mdpFlags);
//Configure rotator for pre-rotation
if(configRotator(*rot, whf, crop, mdpFlags, orient, downscale) < 0) {
ALOGE("%s: configRotator failed!", __FUNCTION__);
return -1;
}
ctx->mLayerRotMap[dpy]->add(layer, *rot);
whf.format = (*rot)->getDstFormat();
updateSource(orient, whf, crop);
rotFlags |= ovutils::ROT_PREROTATED;
}
//For the mdp, since either we are pre-rotating or MDP does flips
orient = OVERLAY_TRANSFORM_0;
transform = 0;
PipeArgs parg(mdpFlags, whf, z, isFg,
static_cast<eRotFlags>(rotFlags), layer->planeAlpha,
(ovutils::eBlending) getBlending(layer->blending));
if(configMdp(ctx->mOverlay, parg, orient, crop, dst, metadata, dest) < 0) {
ALOGE("%s: commit failed for low res panel", __FUNCTION__);
return -1;
}
return 0;
}
//Helper to 1) Ensure crops dont have gaps 2) Ensure L and W are even
void sanitizeSourceCrop(hwc_rect_t& cropL, hwc_rect_t& cropR,
private_handle_t *hnd) {
if(cropL.right - cropL.left) {
if(isYuvBuffer(hnd)) {
//Always safe to even down left
ovutils::even_floor(cropL.left);
//If right is even, automatically width is even, since left is
//already even
ovutils::even_floor(cropL.right);
}
//Make sure there are no gaps between left and right splits if the layer
//is spread across BOTH halves
if(cropR.right - cropR.left) {
cropR.left = cropL.right;
}
}
if(cropR.right - cropR.left) {
if(isYuvBuffer(hnd)) {
//Always safe to even down left
ovutils::even_floor(cropR.left);
//If right is even, automatically width is even, since left is
//already even
ovutils::even_floor(cropR.right);
}
}
}
int configureSplit(hwc_context_t *ctx, hwc_layer_1_t *layer,
const int& dpy, eMdpFlags& mdpFlagsL, eZorder& z,
eIsFg& isFg, const eDest& lDest, const eDest& rDest,
Rotator **rot) {
private_handle_t *hnd = (private_handle_t *)layer->handle;
if(!hnd) {
ALOGE("%s: layer handle is NULL", __FUNCTION__);
return -1;
}
MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
int hw_w = ctx->dpyAttr[dpy].xres;
int hw_h = ctx->dpyAttr[dpy].yres;
hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf);
hwc_rect_t dst = layer->displayFrame;
int transform = layer->transform;
eTransform orient = static_cast<eTransform>(transform);
const int downscale = 0;
int rotFlags = ROT_FLAGS_NONE;
uint32_t format = ovutils::getMdpFormat(hnd->format, isTileRendered(hnd));
Whf whf(getWidth(hnd), getHeight(hnd), format, hnd->size);
// Handle R/B swap
if (layer->flags & HWC_FORMAT_RB_SWAP) {
if (hnd->format == HAL_PIXEL_FORMAT_RGBA_8888)
whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRA_8888);
else if (hnd->format == HAL_PIXEL_FORMAT_RGBX_8888)
whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRX_8888);
}
/* Calculate the external display position based on MDP downscale,
ActionSafe, and extorientation features. */
calcExtDisplayPosition(ctx, hnd, dpy, crop, dst, transform, orient);
setMdpFlags(layer, mdpFlagsL, 0, transform);
if(lDest != OV_INVALID && rDest != OV_INVALID) {
//Enable overfetch
setMdpFlags(mdpFlagsL, OV_MDSS_MDP_DUAL_PIPE);
}
//Will do something only if feature enabled and conditions suitable
//hollow call otherwise
if(ctx->mAD->prepare(ctx, crop, whf, hnd)) {
overlay::Writeback *wb = overlay::Writeback::getInstance();
whf.format = wb->getOutputFormat();
}
if(isYuvBuffer(hnd) && (transform & HWC_TRANSFORM_ROT_90)) {
(*rot) = ctx->mRotMgr->getNext();
if((*rot) == NULL) return -1;
//Configure rotator for pre-rotation
if(configRotator(*rot, whf, crop, mdpFlagsL, orient, downscale) < 0) {
ALOGE("%s: configRotator failed!", __FUNCTION__);
return -1;
}
ctx->mLayerRotMap[dpy]->add(layer, *rot);
whf.format = (*rot)->getDstFormat();
updateSource(orient, whf, crop);
rotFlags |= ROT_PREROTATED;
}
eMdpFlags mdpFlagsR = mdpFlagsL;
setMdpFlags(mdpFlagsR, OV_MDSS_MDP_RIGHT_MIXER);
hwc_rect_t tmp_cropL = {0}, tmp_dstL = {0};
hwc_rect_t tmp_cropR = {0}, tmp_dstR = {0};
const int lSplit = getLeftSplit(ctx, dpy);
if(lDest != OV_INVALID) {
tmp_cropL = crop;
tmp_dstL = dst;
hwc_rect_t scissor = {0, 0, lSplit, hw_h };
scissor = getIntersection(ctx->mViewFrame[dpy], scissor);
qhwc::calculate_crop_rects(tmp_cropL, tmp_dstL, scissor, 0);
}
if(rDest != OV_INVALID) {
tmp_cropR = crop;
tmp_dstR = dst;
hwc_rect_t scissor = {lSplit, 0, hw_w, hw_h };
scissor = getIntersection(ctx->mViewFrame[dpy], scissor);
qhwc::calculate_crop_rects(tmp_cropR, tmp_dstR, scissor, 0);
}
sanitizeSourceCrop(tmp_cropL, tmp_cropR, hnd);
//When buffer is H-flipped, contents of mixer config also needs to swapped
//Not needed if the layer is confined to one half of the screen.
//If rotator has been used then it has also done the flips, so ignore them.
if((orient & OVERLAY_TRANSFORM_FLIP_H) && lDest != OV_INVALID
&& rDest != OV_INVALID && (*rot) == NULL) {
hwc_rect_t new_cropR;
new_cropR.left = tmp_cropL.left;
new_cropR.right = new_cropR.left + (tmp_cropR.right - tmp_cropR.left);
hwc_rect_t new_cropL;
new_cropL.left = new_cropR.right;
new_cropL.right = tmp_cropR.right;
tmp_cropL.left = new_cropL.left;
tmp_cropL.right = new_cropL.right;
tmp_cropR.left = new_cropR.left;
tmp_cropR.right = new_cropR.right;
}
//For the mdp, since either we are pre-rotating or MDP does flips
orient = OVERLAY_TRANSFORM_0;
transform = 0;
//configure left mixer
if(lDest != OV_INVALID) {
PipeArgs pargL(mdpFlagsL, whf, z, isFg,
static_cast<eRotFlags>(rotFlags), layer->planeAlpha,
(ovutils::eBlending) getBlending(layer->blending));
if(configMdp(ctx->mOverlay, pargL, orient,
tmp_cropL, tmp_dstL, metadata, lDest) < 0) {
ALOGE("%s: commit failed for left mixer config", __FUNCTION__);
return -1;
}
}
//configure right mixer
if(rDest != OV_INVALID) {
PipeArgs pargR(mdpFlagsR, whf, z, isFg,
static_cast<eRotFlags>(rotFlags),
layer->planeAlpha,
(ovutils::eBlending) getBlending(layer->blending));
tmp_dstR.right = tmp_dstR.right - lSplit;
tmp_dstR.left = tmp_dstR.left - lSplit;
if(configMdp(ctx->mOverlay, pargR, orient,
tmp_cropR, tmp_dstR, metadata, rDest) < 0) {
ALOGE("%s: commit failed for right mixer config", __FUNCTION__);
return -1;
}
}
return 0;
}
int configureSourceSplit(hwc_context_t *ctx, hwc_layer_1_t *layer,
const int& dpy, eMdpFlags& mdpFlagsL, eZorder& z,
eIsFg& isFg, const eDest& lDest, const eDest& rDest,
Rotator **rot) {
private_handle_t *hnd = (private_handle_t *)layer->handle;
if(!hnd) {
ALOGE("%s: layer handle is NULL", __FUNCTION__);
return -1;
}
MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf);;
hwc_rect_t dst = layer->displayFrame;
int transform = layer->transform;
eTransform orient = static_cast<eTransform>(transform);
const int downscale = 0;
int rotFlags = ROT_FLAGS_NONE;
//Splitting only YUV layer on primary panel needs different zorders
//for both layers as both the layers are configured to single mixer
eZorder lz = z;
eZorder rz = (eZorder)(z + 1);
Whf whf(getWidth(hnd), getHeight(hnd),
getMdpFormat(hnd->format), hnd->size);
/* Calculate the external display position based on MDP downscale,
ActionSafe, and extorientation features. */
calcExtDisplayPosition(ctx, hnd, dpy, crop, dst, transform, orient);
setMdpFlags(layer, mdpFlagsL, 0, transform);
trimLayer(ctx, dpy, transform, crop, dst);
if(isYuvBuffer(hnd) && (transform & HWC_TRANSFORM_ROT_90)) {
(*rot) = ctx->mRotMgr->getNext();
if((*rot) == NULL) return -1;
if(!dpy)
BwcPM::setBwc(crop, dst, transform, mdpFlagsL);
//Configure rotator for pre-rotation
if(configRotator(*rot, whf, crop, mdpFlagsL, orient, downscale) < 0) {
ALOGE("%s: configRotator failed!", __FUNCTION__);
return -1;
}
ctx->mLayerRotMap[dpy]->add(layer, *rot);
whf.format = (*rot)->getDstFormat();
updateSource(orient, whf, crop);
rotFlags |= ROT_PREROTATED;
}
eMdpFlags mdpFlagsR = mdpFlagsL;
int lSplit = dst.left + (dst.right - dst.left)/2;
hwc_rect_t tmp_cropL = {0}, tmp_dstL = {0};
hwc_rect_t tmp_cropR = {0}, tmp_dstR = {0};
if(lDest != OV_INVALID) {
tmp_cropL = crop;
tmp_dstL = dst;
hwc_rect_t scissor = {dst.left, dst.top, lSplit, dst.bottom };
qhwc::calculate_crop_rects(tmp_cropL, tmp_dstL, scissor, 0);
}
if(rDest != OV_INVALID) {
tmp_cropR = crop;
tmp_dstR = dst;
hwc_rect_t scissor = {lSplit, dst.top, dst.right, dst.bottom };
qhwc::calculate_crop_rects(tmp_cropR, tmp_dstR, scissor, 0);
}
sanitizeSourceCrop(tmp_cropL, tmp_cropR, hnd);
//When buffer is H-flipped, contents of mixer config also needs to swapped
//Not needed if the layer is confined to one half of the screen.
//If rotator has been used then it has also done the flips, so ignore them.
if((orient & OVERLAY_TRANSFORM_FLIP_H) && lDest != OV_INVALID
&& rDest != OV_INVALID && (*rot) == NULL) {
hwc_rect_t new_cropR;
new_cropR.left = tmp_cropL.left;
new_cropR.right = new_cropR.left + (tmp_cropR.right - tmp_cropR.left);
hwc_rect_t new_cropL;
new_cropL.left = new_cropR.right;
new_cropL.right = tmp_cropR.right;
tmp_cropL.left = new_cropL.left;
tmp_cropL.right = new_cropL.right;
tmp_cropR.left = new_cropR.left;
tmp_cropR.right = new_cropR.right;
}
//For the mdp, since either we are pre-rotating or MDP does flips
orient = OVERLAY_TRANSFORM_0;
transform = 0;
//configure left half
if(lDest != OV_INVALID) {
PipeArgs pargL(mdpFlagsL, whf, lz, isFg,
static_cast<eRotFlags>(rotFlags), layer->planeAlpha,
(ovutils::eBlending) getBlending(layer->blending));
if(configMdp(ctx->mOverlay, pargL, orient,
tmp_cropL, tmp_dstL, metadata, lDest) < 0) {
ALOGE("%s: commit failed for left half config", __FUNCTION__);
return -1;
}
}
//configure right half
if(rDest != OV_INVALID) {
PipeArgs pargR(mdpFlagsR, whf, rz, isFg,
static_cast<eRotFlags>(rotFlags),
layer->planeAlpha,
(ovutils::eBlending) getBlending(layer->blending));
if(configMdp(ctx->mOverlay, pargR, orient,
tmp_cropR, tmp_dstR, metadata, rDest) < 0) {
ALOGE("%s: commit failed for right half config", __FUNCTION__);
return -1;
}
}
return 0;
}
bool canUseRotator(hwc_context_t *ctx, int dpy) {
if(qdutils::MDPVersion::getInstance().is8x26() &&
isSecondaryConnected(ctx) &&
!ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isPause) {
/* 8x26 mdss driver supports multiplexing of DMA pipe
* in LINE and BLOCK modes for writeback panels.
*/
if(dpy == HWC_DISPLAY_PRIMARY)
return false;
}
if(ctx->mMDP.version == qdutils::MDP_V3_0_4)
return false;
return true;
}
int getLeftSplit(hwc_context_t *ctx, const int& dpy) {
//Default even split for all displays with high res
int lSplit = ctx->dpyAttr[dpy].xres / 2;
if(dpy == HWC_DISPLAY_PRIMARY &&
qdutils::MDPVersion::getInstance().getLeftSplit()) {
//Override if split published by driver for primary
lSplit = qdutils::MDPVersion::getInstance().getLeftSplit();
}
return lSplit;
}
bool isDisplaySplit(hwc_context_t* ctx, int dpy) {
if(ctx->dpyAttr[dpy].xres > qdutils::MAX_DISPLAY_DIM) {
return true;
}
//For testing we could split primary via device tree values
if(dpy == HWC_DISPLAY_PRIMARY &&
qdutils::MDPVersion::getInstance().getRightSplit()) {
return true;
}
return false;
}
//clear prev layer prop flags and realloc for current frame
void reset_layer_prop(hwc_context_t* ctx, int dpy, int numAppLayers) {
if(ctx->layerProp[dpy]) {
delete[] ctx->layerProp[dpy];
ctx->layerProp[dpy] = NULL;
}
ctx->layerProp[dpy] = new LayerProp[numAppLayers];
}
/* Since we fake non-Hybrid WFD solution as external display, this
* function helps us in determining the priority between external
* (hdmi/non-Hybrid WFD display) and virtual display devices(SSD/
* screenrecord). This can be removed once wfd-client migrates to
* using virtual-display api's.
*/
bool canUseMDPforVirtualDisplay(hwc_context_t* ctx,
const hwc_display_contents_1_t *list) {
/* We rely on the fact that for pure virtual display solution
* list->outbuf will be a non-NULL handle.
*
* If there are three active displays (which means there is one
* primary, one external and one virtual active display)
* we give mdss/mdp hw resources(pipes,smp,etc) for external
* display(hdmi/non-Hybrid WFD display) rather than for virtual
* display(SSD/screenrecord)
*/
if(list->outbuf and (ctx->numActiveDisplays == HWC_NUM_DISPLAY_TYPES)) {
return false;
}
return true;
}
bool isGLESComp(hwc_context_t *ctx,
hwc_display_contents_1_t* list) {
int numAppLayers = ctx->listStats[HWC_DISPLAY_PRIMARY].numAppLayers;
for(int index = 0; index < numAppLayers; index++) {
hwc_layer_1_t* layer = &(list->hwLayers[index]);
if(layer->compositionType == HWC_FRAMEBUFFER)
return true;
}
return false;
}
void setGPUHint(hwc_context_t* ctx, hwc_display_contents_1_t* list) {
struct gpu_hint_info *gpuHint = &ctx->mGPUHintInfo;
if(!gpuHint->mGpuPerfModeEnable || !ctx || !list)
return;
#ifdef QCOM_BSP
/* Set the GPU hint flag to high for MIXED/GPU composition only for
first frame after MDP -> GPU/MIXED mode transition. Set the GPU
hint to default if the previous composition is GPU or current GPU
composition is due to idle fallback */
if(!gpuHint->mEGLDisplay || !gpuHint->mEGLContext) {
gpuHint->mEGLDisplay = eglGetCurrentDisplay();
if(!gpuHint->mEGLDisplay) {
ALOGW("%s Warning: EGL current display is NULL", __FUNCTION__);
return;
}
gpuHint->mEGLContext = eglGetCurrentContext();
if(!gpuHint->mEGLContext) {
ALOGW("%s Warning: EGL current context is NULL", __FUNCTION__);
return;
}
}
if(isGLESComp(ctx, list)) {
if(!gpuHint->mPrevCompositionGLES && !MDPComp::isIdleFallback()) {
EGLint attr_list[] = {EGL_GPU_HINT_1,
EGL_GPU_LEVEL_3,
EGL_NONE };
if((gpuHint->mCurrGPUPerfMode != EGL_GPU_LEVEL_3) &&
!eglGpuPerfHintQCOM(gpuHint->mEGLDisplay,
gpuHint->mEGLContext, attr_list)) {
ALOGW("eglGpuPerfHintQCOM failed for Built in display");
} else {
gpuHint->mCurrGPUPerfMode = EGL_GPU_LEVEL_3;
gpuHint->mPrevCompositionGLES = true;
}
} else {
EGLint attr_list[] = {EGL_GPU_HINT_1,
EGL_GPU_LEVEL_0,
EGL_NONE };
if((gpuHint->mCurrGPUPerfMode != EGL_GPU_LEVEL_0) &&
!eglGpuPerfHintQCOM(gpuHint->mEGLDisplay,
gpuHint->mEGLContext, attr_list)) {
ALOGW("eglGpuPerfHintQCOM failed for Built in display");
} else {
gpuHint->mCurrGPUPerfMode = EGL_GPU_LEVEL_0;
}
}
} else {
/* set the GPU hint flag to default for MDP composition */
EGLint attr_list[] = {EGL_GPU_HINT_1,
EGL_GPU_LEVEL_0,
EGL_NONE };
if((gpuHint->mCurrGPUPerfMode != EGL_GPU_LEVEL_0) &&
!eglGpuPerfHintQCOM(gpuHint->mEGLDisplay,
gpuHint->mEGLContext, attr_list)) {
ALOGW("eglGpuPerfHintQCOM failed for Built in display");
} else {
gpuHint->mCurrGPUPerfMode = EGL_GPU_LEVEL_0;
}
gpuHint->mPrevCompositionGLES = false;
}
#endif
}
void BwcPM::setBwc(const hwc_rect_t& crop,
const hwc_rect_t& dst, const int& transform,
ovutils::eMdpFlags& mdpFlags) {
//Target doesnt support Bwc
if(!qdutils::MDPVersion::getInstance().supportsBWC()) {
return;
}
//src width > MAX mixer supported dim
if((crop.right - crop.left) > qdutils::MAX_DISPLAY_DIM) {
return;
}
//Decimation necessary, cannot use BWC. H/W requirement.
if(qdutils::MDPVersion::getInstance().supportsDecimation()) {
int src_w = crop.right - crop.left;
int src_h = crop.bottom - crop.top;
int dst_w = dst.right - dst.left;
int dst_h = dst.bottom - dst.top;
if(transform & HAL_TRANSFORM_ROT_90) {
swap(src_w, src_h);
}
float horDscale = 0.0f;
float verDscale = 0.0f;
int horzDeci = 0;
int vertDeci = 0;
ovutils::getDecimationFactor(src_w, src_h, dst_w, dst_h, horDscale,
verDscale);
//TODO Use log2f once math.h has it
if((int)horDscale)
horzDeci = (int)(log(horDscale) / log(2));
if((int)verDscale)
vertDeci = (int)(log(verDscale) / log(2));
if(horzDeci || vertDeci) return;
}
//Property
char value[PROPERTY_VALUE_MAX];
property_get("debug.disable.bwc", value, "0");
if(atoi(value)) return;
ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDSS_MDP_BWC_EN);
}
void LayerRotMap::add(hwc_layer_1_t* layer, Rotator *rot) {
if(mCount >= MAX_SESS) return;
mLayer[mCount] = layer;
mRot[mCount] = rot;
mCount++;
}
void LayerRotMap::reset() {
for (int i = 0; i < MAX_SESS; i++) {
mLayer[i] = 0;
mRot[i] = 0;
}
mCount = 0;
}
void LayerRotMap::clear() {
RotMgr::getInstance()->markUnusedTop(mCount);
reset();
}
void LayerRotMap::setReleaseFd(const int& fence) {
for(uint32_t i = 0; i < mCount; i++) {
mRot[i]->setReleaseFd(dup(fence));
}
}
};//namespace qhwc
| [
"mirek190@gmail.com"
] | mirek190@gmail.com |
9126ea0208ef586e71490507e118c695f7b5f8bb | 5c663058f6ace9047be42c44af6b7a88f4d76225 | /increasing_subseq.cpp | 4b11493590ba5a5995a8987ca7e76840d15fc57f | [] | no_license | ajay-panchal-099/my-previous-git-submission | 0cd461feabe30852dbd03e93bd256e905c42bb3f | 51a09185058acbfaafe0ac550e1d99a9f6f263a0 | refs/heads/master | 2022-07-06T15:12:59.263554 | 2020-05-19T17:47:48 | 2020-05-19T17:47:48 | 265,212,127 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 689 | cpp | #include<bits/stdc++.h>
#define int long long
#define endl "\n"
const int MOD = 1e9 + 7 ;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main(){
IOS
int n;
cin>>n;
int arr[n];
for (int i = 0; i < n; ++i) {
cin>>arr[i];
}
vector<int>dp(n,1);
for (int j = 1; j < n; ++j) {
for (int k = 0; k < j ; ++k) {
if(arr[k] < arr[j])
dp[j] = max(dp[j],dp[k]+1);
}
}
int max = -INT_MAX;
for (int l = 0; l < n; ++l) {
if(dp[l] > max)
max = dp[l];
}
cout<<max<<endl;
return 0;
}
// CHECK FOR CORNER CASES LIKE 0,1 etc.
| [
"noreply@github.com"
] | noreply@github.com |
142ffdca7ae4eb948922f2ded226804206891279 | e897d4e94cbb3a982ee249422950a3f6926f433c | /Homework/Assignment 2/Gaddis_8thEd_Chap 3_Prob 12_Celsius to Fahrenheit/main.cpp | d252d00f450254babc0045a601549c8979090265 | [] | no_license | L-Elyse/csc5_2016 | 61344a201378deacd98ccd7a40061d11517a173a | 10ec3627142d8b4a650c1c90faf08ede8a434759 | refs/heads/master | 2021-01-20T18:28:50.706767 | 2016-07-31T06:36:04 | 2016-07-31T06:36:04 | 61,777,500 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 869 | cpp | /*
* File: main.cpp
* Author: Laurie Guimont
* Created on June 28, 2016, 10:05 PM
* Purpose: Converting Celsius to Fahrenheit
*/
//System Libraries
#include <iostream> //Input/Output Stream Library
#include <iomanip> //Format Library
using namespace std;//Iostream uses the standard namespace
//User Libraries
//Global Constants
//Function Prototypes
//Execution Begins Here!
int main(int argc, char** argv) {
//Declare variables, no doubles
float F; //Degrees Fahrenheit
float C; //Degrees Celsius
//Input data
cout<<"Input the Celsius Temperature"<<endl;
cin>>C;
//Process data
F=C*(9.0/5)+32;
//Output data
cout<<fixed<<setprecision(1)<<showpoint;
cout<<C<<" degrees Celsius is equivalent to "<<F<<" degress Fahrenheit"<<endl;
//Exit Stage Right!
return 0;
} | [
"lguimont@student.rcc.edu"
] | lguimont@student.rcc.edu |
93d52313c334c796146284f95c69ee5884fc7f4b | 673f8a04474a6a11f8e85e7f8c369cd288163769 | /src/transforms/include/bin_to_hex_as_ascii_transform.h | e8fc02f7b2f682eb4d52924c7b6cf48a987b16ff | [
"Apache-2.0"
] | permissive | DavidPeet8/BinaryIO | 65f92274d75f0dfb4403803a75e831a621fd59d7 | efd251f8dc7f74d1d3a6c21488cdb1455f9de930 | refs/heads/master | 2023-07-18T06:37:05.438769 | 2021-08-27T21:15:29 | 2021-08-27T21:15:29 | 311,437,727 | 1 | 0 | null | 2020-11-22T03:37:18 | 2020-11-09T19:03:10 | C++ | UTF-8 | C++ | false | false | 425 | h | #ifndef BIN_TO_HEX_AS_ASCII_TRANSFORM_H
#define BIN_TO_HEX_AS_ASCII_TRANSFORM_H
#include <iostream>
#include "binary_reader_transform.h"
class BinToHexAsAsciiTransform final : public BinaryReaderTransform
{
public:
BinToHexAsAsciiTransform(std::istream &in, std::ostream &out, bool formatted) :
BinaryReaderTransform(in, out, formatted)
{}
private:
void readAndTransformByte(bool inRange) override;
};
#endif
| [
"davidpeetp@gmail.com"
] | davidpeetp@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.