blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 986
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 23
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 145
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 122
values | content
stringlengths 3
10.4M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
158
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3a090efa9f4094416663ce514b99fc004928038d | eec8ff4c1766c16ded0b7e8e9d51c7d6f5acb13f | /src/qt/editaddressdialog.cpp | 18b8085a33a6257d00880911618de6f6475d7a18 | [
"MIT"
] | permissive | levi989/spaceCoinLegacy | a3fb3994a14f935d80aa2fa57fd36bb7207c96e4 | f3fc90ebbefa80a603173733c383e2525358a799 | refs/heads/master | 2021-06-04T22:13:41.880763 | 2016-09-20T20:21:47 | 2016-09-20T20:21:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,291 | cpp | #include "editaddressdialog.h"
#include "ui_editaddressdialog.h"
#include "addresstablemodel.h"
#include "guiutil.h"
#include <QDataWidgetMapper>
#include <QMessageBox>
EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) :
QDialog(parent),
ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0)
{
ui->setupUi(this);
GUIUtil::setupAddressWidget(ui->addressEdit, this);
switch(mode)
{
case NewReceivingAddress:
setWindowTitle(tr("New receiving address"));
ui->addressEdit->setEnabled(false);
ui->addressEdit->setVisible(false);
ui->stealthCB->setEnabled(true);
ui->stealthCB->setVisible(true);
break;
case NewSendingAddress:
setWindowTitle(tr("New sending address"));
ui->stealthCB->setVisible(false);
break;
case EditReceivingAddress:
setWindowTitle(tr("Edit receiving address"));
ui->addressEdit->setEnabled(false);
ui->addressEdit->setVisible(true);
ui->stealthCB->setEnabled(false);
ui->stealthCB->setVisible(true);
break;
case EditSendingAddress:
setWindowTitle(tr("Edit sending address"));
ui->stealthCB->setVisible(false);
break;
}
mapper = new QDataWidgetMapper(this);
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
}
EditAddressDialog::~EditAddressDialog()
{
delete ui;
}
void EditAddressDialog::setModel(AddressTableModel *model)
{
this->model = model;
if(!model)
return;
mapper->setModel(model);
mapper->addMapping(ui->labelEdit, AddressTableModel::Label);
mapper->addMapping(ui->addressEdit, AddressTableModel::Address);
mapper->addMapping(ui->stealthCB, AddressTableModel::Type);
}
void EditAddressDialog::loadRow(int row)
{
mapper->setCurrentIndex(row);
}
bool EditAddressDialog::saveCurrentRow()
{
if(!model)
return false;
switch(mode)
{
case NewReceivingAddress:
case NewSendingAddress:
{
int typeInd = ui->stealthCB->isChecked() ? AddressTableModel::AT_Stealth : AddressTableModel::AT_Normal;
address = model->addRow(
mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive,
ui->labelEdit->text(),
ui->addressEdit->text(),
typeInd);
}
break;
case EditReceivingAddress:
case EditSendingAddress:
if(mapper->submit())
{
address = ui->addressEdit->text();
}
break;
}
return !address.isEmpty();
}
void EditAddressDialog::accept()
{
if(!model)
return;
if(!saveCurrentRow())
{
switch(model->getEditStatus())
{
case AddressTableModel::OK:
// Failed with unknown reason. Just reject.
break;
case AddressTableModel::NO_CHANGES:
// No changes were made during edit operation. Just reject.
break;
case AddressTableModel::INVALID_ADDRESS:
QMessageBox::warning(this, windowTitle(),
tr("The entered address \"%1\" is not a valid SpaceCoin address.").arg(ui->addressEdit->text()),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::DUPLICATE_ADDRESS:
QMessageBox::warning(this, windowTitle(),
tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::WALLET_UNLOCK_FAILURE:
QMessageBox::critical(this, windowTitle(),
tr("Could not unlock wallet."),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::KEY_GENERATION_FAILURE:
QMessageBox::critical(this, windowTitle(),
tr("New key generation failed."),
QMessageBox::Ok, QMessageBox::Ok);
break;
}
return;
}
QDialog::accept();
}
QString EditAddressDialog::getAddress() const
{
return address;
}
void EditAddressDialog::setAddress(const QString &address)
{
this->address = address;
ui->addressEdit->setText(address);
}
| [
"[email protected]"
] | |
46759b45d389c785179a99d39bf075368e21d9dd | 4af341026c371c8e25d37780c3d2a85063ec60ea | /CF-Grakn Forces-2020-Searchlights D - Trapping Optimal answer with the help of sorting and common sense logic.cpp | 04f11f5198fc2a81c44dc132bfab0ddeddf88940 | [] | no_license | i-am-arvinder-singh/CP | 46a32f9235a656e7d777a16ccbce980cb1eb1c63 | e4e79e4ffc636f078f16a25ce81a3095553fc060 | refs/heads/master | 2023-07-12T19:20:41.093734 | 2021-08-29T06:58:55 | 2021-08-29T06:58:55 | 266,883,239 | 1 | 1 | null | 2020-10-04T14:00:29 | 2020-05-25T21:25:39 | C++ | UTF-8 | C++ | false | false | 2,523 | cpp | #include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;//which means policy based DS
#define endl "\n"
#define ll long long
#define int long long
#define ff first
#define ss second
#define fl(i,a,b) for(int i=(int)a; i<(int)b; i++)
#define bfl(i,a,b) for(int i=(int)a-1; i>=(int)b; i--)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vt(type) vector<type>
#define omniphantom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mii map<int,int>
#define pqb priority_queue<int>
//Below is implementation of min heap
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define pw(b,p) pow(b,p) + 0.1
#define ini const int
#define sz(v) ((int)(v).size())
#define ppii pair<int,pii>
#define tup tuple<int,int,int>
#define LEFT(x) 2*x+1
#define RIGHT(x) 2*x+2
const double pi = acos(-1.0);
void solve()
{
int n,m;
cin>>n>>m;
vector<pair<int,int>> robber,searchlight,diff;
for(int i=0;i<n;i++){
int x,y;
cin>>x>>y;
robber.pb({x,y});
}
for(int i=0;i<m;i++){
int x,y;
cin>>x>>y;
searchlight.pb({x,y});
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(robber[i].ff<=searchlight[j].ff && robber[i].ss<=searchlight[j].ss){
diff.pb({searchlight[j].ff-robber[i].ff,searchlight[j].ss-robber[i].ss});
}
}
}
sort(diff.rbegin(),diff.rend());
int mx = -1;
int ans = inf;
for(int i=0;i<(int)diff.size();i++){
ans=min(ans,diff[i].ff+1 + mx+1 );
mx=max(mx,diff[i].ss);
}
ans=min(ans,mx+1);
cout<<ans<<endl;
}
int32_t main()
{
omniphantom
#if 0
w(t)
#endif // 0
solve();
return 0;
}
| [
"[email protected]"
] | |
44ba6c11ae8bbbfc18c7f5c61f8854bb3504b768 | 200d7babe9f33d0d2f3d3f36c6823a8b04b69ba2 | /Aula_2/src/Veiculo.h | c4a058f944b6c90bdb8a7d9f54b831ddd360d468 | [] | no_license | andrefmrocha/AEDA_FEUP_18_19 | 4b03a26224804bf9251dcb899a43e328692a4d76 | a5690e21c6daa0b92e7d662b96980317a0c45824 | refs/heads/master | 2020-03-29T13:54:34.775358 | 2018-12-18T15:13:19 | 2018-12-18T15:13:19 | 149,988,184 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,164 | h | #ifndef VEICULO_H_
#define VEICULO_H_
#include <string>
using namespace std;
class Veiculo {
protected:
string marca;
int mes, ano;
public:
Veiculo(string mc, int m, int a);
virtual ~Veiculo(){};
int getAno() const;
int getMes() const;
string getMarca() const;
virtual int info() const;
bool operator < (const Veiculo & v) const;
virtual float calcImposto() const = 0;
};
class Motorizado: public Veiculo {
string combustivel; int cilindrada;
public:
Motorizado(string mc, int m, int a,string c,int cil);
string getCombustivel() const;
virtual int info() const;
float calcImposto() const;
};
class Automovel: public Motorizado {
public:
Automovel(string mc, int m, int a,string c, int cil);
int info() const;
};
class Camiao: public Motorizado {
int carga_maxima;
public:
Camiao(string mc, int m, int a,string c, int cil,int cm);
int info() const;
};
class Bicicleta: public Veiculo {
string tipo;
public:
Bicicleta(string mc, int m, int a,string t);
int info() const;
float calcImposto() const;
};
#endif /* VEICULO_H_ */
| [
"[email protected]"
] | |
8eac4da0ba6f0607b4596b73682daeac67383853 | cfd0fd9c3ebec4a7939bfc5e5ed2089513bd643f | /src/04CompoundTypes/EnumTest.cpp | c24935245e234a4024eb95b1dd31715e544d5a2e | [] | no_license | truongphucanh/book-cpp-primer-plus | 44dcbcd2b5b73baf705051c476cd1bd959efd5e4 | 6b3ef12645a047fa9878c982a251bcc8d955185c | refs/heads/master | 2020-03-13T07:56:37.592238 | 2018-05-06T15:04:04 | 2018-05-06T15:04:04 | 131,034,506 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,190 | cpp | #include <iostream>
#include "EnumTest.h"
using namespace std;
void enumTest(){
Day today = sunday;
cout << "today = " << today << endl;
int int_today = today; // valid, enumerator -> int
cout << "int_today = " << int_today << endl;
// Day invalid_day = 1; // compile error, canot convert int to enum
Day valid_day = Day(2); // valid, it's monday
cout << "valid_day = " << valid_day << endl;
Day undefined_day = Day(-1);
cout << "undefined_day = " << undefined_day << endl;
}
// this code only works for positive number (minValue), the negative number is similar
void enumRangeTest(){
int minValue = 0; // nothing
int maxValue = 103; // z
int low = 0;
int high = 127;
if (minValue >= 0){
low = 0;
}
else{
// you need to find x that make -2^x <= minValue
// then low = -2^x
}
int i = 0;
// find i that make 2^i >= maxValue
while (std::pow(2, i) < maxValue){
i++;
}
// then, high = 2^i - 1
high = std::pow(2, i) - 1;
cout << "Range of enum with min value " << minValue << " and max value " << maxValue <<" is [" << low << " ," << high << "]" << endl;
}
| [
"[email protected]"
] | |
6c538e961ace8cb74f055eea65f2683f21a5e3ed | 9b86ce502728c18ef985913a7b5826c087bbb176 | /Source/SmartHamsterCage/Devices/PWM/WaterPump.h | 3bf7d50025b0384875c88bd9859fbe3b4b05c323 | [] | no_license | dpozimski/smart-hamster-cage | 68fc16f26b1b1cdc66ad8481c1818b8a44f361f1 | 74c73b987138f98e553d3184033306a09e906f26 | refs/heads/master | 2020-03-07T10:10:55.141042 | 2018-06-24T10:47:23 | 2018-06-24T10:47:23 | 127,424,888 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 330 | h | /*
* WaterPump.h
*
* Created: 15.04.2018 13:28:33
* Author: d.pozimski
*/
#ifndef WaterPump_H_
#define WaterPump_H_
#include "PWMDevice.h"
class WaterPump : public PWMDevice
{
public:
void init() override;
protected:
void updatePwmRegister(uint8_t value) override;
};
#endif /* WaterPump_H_ */ | [
"[email protected]"
] | |
c8abfb1c9330fc982dc762a88ff84efeb85d974e | eda52f00615564e818ed8de8c481d1c8c843b7a5 | /earl-2.0/src/Machine.h | 177a0b4defa2eb949899a6f4bff49750564c9dc1 | [] | no_license | pyrovski/scalasca | e54c52e8aa4a8b5cbb2294074c53d95eab1eeb7d | 726e6f85fd89f284bda6df6d8bb160276b3a297f | refs/heads/master | 2021-01-01T04:27:08.330831 | 2013-07-19T19:26:18 | 2013-07-19T19:26:18 | 11,535,489 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,621 | h | /****************************************************************************
*****************************************************************************
** Copyright (c) 1998-2013 **
** Forschungszentrum Juelich GmbH, Juelich Supercomputing Centre **
** **
** Copyright (c) 2003-2008 **
** University of Tennessee, Innovative Computing Laboratory **
** **
** See the file COPYRIGHT in the package base directory for details **
****************************************************************************/
#ifndef EARL_MACHINE_H
#define EARL_MACHINE_H
/*
*----------------------------------------------------------------------------
*
* class Machine
*
*----------------------------------------------------------------------------
*/
#include <map>
#include <string>
namespace earl
{
class Grid;
class Node;
class Machine
{
public:
Machine(long id,
std::string name) :
id(id), name(name) {}
long get_id() const { return id; }
std::string get_name() const { return name; }
long get_nnodes() const { return nodem.size() ; }
Node* get_node(long node_id) const;
private:
friend class Grid;
void add_node(Node* node);
long id;
std::string name;
std::map<long, Node*> nodem;
};
}
#endif
| [
"[email protected]"
] | |
3ba63f18a7d8745341f7b3dc49c8e850426044da | 6ab7d7675980e45e250499e245f780c48c29b8a7 | /mirsi - SistemaEmbarcado/mirsi.ino | 6f98d844b382ee9bd95e5ddeff9b7c26b1fcfc96 | [] | no_license | cicerojmm/mirsi | 19700e54f0263416456117ea55cc354b74381afa | 40c9078bc9972a60faf2bce3a80769581ca4e6b7 | refs/heads/master | 2022-12-11T21:45:44.216640 | 2019-07-27T23:17:56 | 2019-07-27T23:17:56 | 122,897,864 | 0 | 0 | null | 2022-11-16T04:11:21 | 2018-02-26T01:51:54 | TypeScript | UTF-8 | C++ | false | false | 4,762 | ino | /*
* MIRSI - Monitoramento Inteligente e Remoto da Saúde do Idoso
* Prototipo de um sistema para monitoramento remoto da saúde do idoso
* Microcontrolador: ESP866
* Plataforma: NodeMCU 1.0
* Sensores: Temperatura, Pulso e Acelerômetro
* Conexão: wi-fi
* Autor: Cícero Moura (Tudo posso naquele que me fortalece!)
* Data Inicial: 01/08/2017
* Ultima Atualização: 27/01/2017
*/
//Inclusão das bibliotecas
#include <Ticker.h>
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <MPU6050.h>
//Definição dos pinos
#define pinoPulseSensor A0
#define mpuSDA D5
#define mpuSDL D6
//Dados para conectar ao Wi-FI
const char* ssid = "wifi";
const char* senha = "senha";
//dados da API para enviar os dados
const char* urlAPI = "urlWebAPI";
const int apiPorta = 443;
WiFiClientSecure client;
// Variáveis volateis
// do sensor de Batimento cardiaco
volatile int BPM;
volatile int Signal;
volatile int IBI = 600;
volatile boolean Pulse = false;
volatile boolean QS = false;
Ticker flipper;
//Variaveis do MPU6050
MPU6050 mpu;
Vector aclNormalizado;
Vector girNormalizado;
float temperatura;
//boolean detectorQuedas = false;
/*
* Configurações iniciais
*/
void setup(){
Serial.begin(115200);
setupWiFI();
setupPulseSensor();
setupMPU();
}
/*
* Execução dedicada do sketch
*/
void loop(){
if (QS == true){
QS = false;
}
lerDadosMPU();
// detectarQuedas();
enviarDadosAPI();
delay(2000);
}
/*
* Inicializa o Wi-Fi
* NodeMCU
*/
void setupWiFI() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, senha);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
//Serial.print(".");
}
/*Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());*/
}
/*
* Inicializa o sensor de batimentos cardiaco
* Pulse Sensor Amped
*/
void setupPulseSensor() {
interruptSetup();
}
/*
* Inicializa o Acelerometro e Giroscópio
* MPU-6050
*/
void setupMPU() {
Wire.begin(mpuSDA, mpuSDL);
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) {
Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
delay(500);
}
mpu.calibrateGyro();
mpu.setThreshold(3);
/*mpu.setAccelPowerOnDelay(MPU6050_DELAY_3MS);
mpu.setIntFreeFallEnabled(true);
mpu.setIntZeroMotionEnabled(false);
mpu.setIntMotionEnabled(false);
mpu.setDHPFMode(MPU6050_DHPF_5HZ);
mpu.setFreeFallDetectionThreshold(17);
mpu.setFreeFallDetectionDuration(2);
attachInterrupt(0, doInt, RISING);*/
}
/*void doInt() {
detectorQuedas = true;
}
void detectarQuedas() {
if (detectorQuedas) {
detectorQuedas = false;
}
}*/
/*
* Realiza a leitura do Acelerômetro, Giroscópio e Temperatura (ºC)
* e reorna a leitura do sensor
*/
void lerDadosMPU() {
aclNormalizado = mpu.readNormalizeAccel();
girNormalizado = mpu.readNormalizeGyro();
temperatura = mpu.readTemperature() + 0.5;
/*Serial.print(" Xnorm = ");
Serial.print(aclNormalizado.XAxis);
Serial.print(" Ynorm = ");
Serial.print(aclNormalizado.YAxis);
Serial.print(" Znorm = ");
Serial.println(aclNormalizado.ZAxis);
Serial.print(" Xnorm = ");
Serial.print(girNormalizado.XAxis);
Serial.print(" Ynorm = ");
Serial.print(girNormalizado.YAxis);
Serial.print(" Znorm = ");
Serial.println(girNormalizado.ZAxis);
Serial.print(" Temp = ");
Serial.print(temperatura);
Serial.println(" *C");*/
}
/*
* Monta mensagem e url para enviar os dados
*/
String montaURL() {
String msg;
msg.concat("GET /api/save/get?");
msg.concat("bpm=");
msg.concat(BPM);
msg.concat("&temperatura=");
msg.concat(temperatura);
msg.concat("&aclX=");
msg.concat(aclNormalizado.XAxis);
msg.concat("&aclY=");
msg.concat(aclNormalizado.YAxis);
msg.concat("&aclZ=");
msg.concat(aclNormalizado.ZAxis);
msg.concat("&girX=");
msg.concat(girNormalizado.XAxis);
msg.concat("&girY=");
msg.concat(girNormalizado.YAxis);
msg.concat("&girZ=");
msg.concat(girNormalizado.ZAxis);
//msg.concat("&detectorQuedas=");
//msg.concat(detectorQuedas);
msg.concat(" HTTP/1.1\r\nHost: ");
msg.concat(urlAPI);
msg.concat("\r\nConnection: close\r\n\r\n");
return msg;
}
/*
* Envia os dados para a API Online
*/
void enviarDadosAPI() {
if (!client.connect(urlAPI, apiPorta)) {
//Serial.println("connection failed");
ESP.restart();
}
String url = montaURL();
//Serial.print("requesting URL: ");
Serial.println(url);
client.print(url);
//Serial.println("request sent");
/*while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
Serial.println("headers received");
break;
}
}*/
}
| [
"[email protected]"
] | |
3752df0f0bbc717641e550115daaedc61eada5dc | 375fccaa7deeefaa392036e9c7e4c2be1b8cef44 | /contrib/Baikal/Baikal/SceneGraph/material.h | b0d6783dc6123ae3e8ac62133481339ab5d1a981 | [
"MIT"
] | permissive | naeioi/octoon | b98678df257e87da9fb27e56f0f209ff46cc126b | e32152fe4730fa609def41114613dbe067d31276 | refs/heads/master | 2020-07-09T05:33:15.019542 | 2019-08-22T11:34:54 | 2019-08-22T11:34:58 | 203,893,478 | 1 | 0 | MIT | 2019-08-23T00:22:11 | 2019-08-23T00:22:11 | null | UTF-8 | C++ | false | false | 5,776 | h | /**********************************************************************
Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
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.
********************************************************************/
/**
\file material.h
\author Dmitry Kozlov
\version 1.0
\brief Contains a class representing material
*/
#pragma once
#include <set>
#include <unordered_map>
#include <string>
#include <memory>
#include "math/float3.h"
#include "scene_object.h"
#include "texture.h"
#include "inputmap.h"
namespace Baikal
{
class Iterator;
class Texture;
/**
\brief High level material interface
\details Base class for all CPU side material supported by the renderer.
*/
class Material : public SceneObject
{
public:
using Ptr = std::shared_ptr<Material>;
friend class MaterialAccessor;
// Material input type
enum class InputType
{
kUint = 0,
kFloat4,
kTexture,
kMaterial,
kInputMap
};
// Input description
struct InputInfo
{
// Short name
std::string name;
// Desctiption
std::string desc;
// Set of supported types
std::set<InputType> supported_types;
};
// Input value description
struct InputValue {
// Current type
InputType type;
// Possible values (use based on type)
uint32_t uint_value;
RadeonRays::float4 float_value;
Texture::Ptr tex_value;
Material::Ptr mat_value;
InputMap::Ptr input_map_value;
InputValue()
: type(InputType::kMaterial)
, uint_value()
, float_value()
, tex_value(nullptr)
, mat_value(nullptr)
, input_map_value(nullptr)
{
}
};
// Full input state
struct Input
{
InputInfo info;
InputValue value;
};
using InputMap = std::unordered_map<std::string, Input>;
// Destructor
virtual ~Material() = 0;
// Iterator of dependent materials (plugged as inputs)
virtual std::unique_ptr<Iterator> CreateMaterialIterator() const;
// Iterator of textures (plugged as inputs)
virtual std::unique_ptr<Iterator> CreateTextureIterator() const;
// Iterator of InputMaps
virtual std::unique_ptr<Iterator> CreateInputMapsIterator() const;
// Iterator of InputMap leafs
virtual std::unique_ptr<Iterator> CreateInputMapLeafsIterator() const;
// Check if material has emissive components
virtual bool HasEmission() const;
// Set input value
// If specific data type is not supported throws std::runtime_error
void SetInputValue(std::string const& name, uint32_t value);
void SetInputValue(std::string const& name,
RadeonRays::float4 const& value);
void SetInputValue(std::string const& name, Texture::Ptr texture);
void SetInputValue(std::string const& name, Material::Ptr material);
void SetInputValue(std::string const& name, Baikal::InputMap::Ptr inputMap);
InputValue GetInputValue(std::string const& name) const;
// Check if material is thin (normal is always pointing in ray incidence
// direction)
bool IsThin() const;
// Set thin flag
void SetThin(bool thin);
virtual bool IsActive(const Input &input) const
{
return true;
}
size_t GetNumInputs() const;
Input GetInput(std::size_t idx) const;
Input& GetInput(const std::string& name, InputType type);
Material(Material const&) = delete;
Material& operator = (Material const&) = delete;
protected:
Material();
// Register specific input
void RegisterInput(std::string const& name, std::string const& desc,
std::set<InputType>&& supported_types);
// Wipe out all the inputs
void ClearInputs();
private:
// Input map
InputMap m_inputs;
// Thin material
bool m_thin;
};
inline Material::~Material()
{
}
inline bool Material::HasEmission() const
{
return false;
}
class VolumeMaterial : public Material
{
public:
using Ptr = std::shared_ptr<VolumeMaterial>;
static Ptr Create();
// Check if material has emissive components
bool HasEmission() const override;
protected:
VolumeMaterial();
};
}
| [
"[email protected]"
] | |
f8af74e41af77657bdeb16ce09f055b30a2213c4 | 21ebce8b95d42d8bbc4f6fd90220b49ccf3c103f | /coding_practice/manmohan_pattern.cpp | ac8b1c4e803dbf9c5a950b0c28764c35524e4744 | [] | no_license | Prerna13149/coding_practice_backup | 40c68331a3d7f11b5b002b8fa519ecedd3aa7a8f | 20f63906d2a66fd4e3a2d7a00a48d52d145b058f | refs/heads/master | 2020-10-01T18:45:28.810201 | 2019-12-12T12:32:01 | 2019-12-12T12:32:01 | 227,602,115 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 846 | cpp | /*
Given N, help Manmohan to print pattern upto N lines. For eg For N=6 , following pattern will be printed.
1
11
111
1001
11111
100001
Input Format:
Single number N.
Constraints:
N<=1000
Output Format:
Pattern corresponding to N.
Sample Input:
6
Sample Output:
1
11
111
1001
11111
100001
Explanation:
For every odd number row print 1, odd number of times and for every even number row , print first and last character as 1 and rest of middle characters as 0.
Time Limit: 1 sec
*/
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
int n;
cin>>n;
int line = 1;
while(line <= n){
int ele = 1;
while(ele <= line){
if(ele==1 || ele==line){
cout<<1;
}
else{
if(line%2==0){
cout<<0;
}
else{
cout<<1;
}
}
ele++;
}
cout<<"\n";
line++;
}
return 0;
} | [
"[email protected]"
] | |
d1a681f24776ccd0fbb2481fb88b603c8cae15ba | 67ed24f7e68014e3dbe8970ca759301f670dc885 | /win10.19042/System32/Chakrathunk.dll.cpp | f16a162dea72ee3f20ee4892f9da405ba0a36c47 | [] | no_license | nil-ref/dll-exports | d010bd77a00048e52875d2a739ea6a0576c82839 | 42ccc11589b2eb91b1aa82261455df8ee88fa40c | refs/heads/main | 2023-04-20T21:28:05.295797 | 2021-05-07T14:06:23 | 2021-05-07T14:06:23 | 401,055,938 | 1 | 0 | null | 2021-08-29T14:00:50 | 2021-08-29T14:00:49 | null | UTF-8 | C++ | false | false | 886 | cpp | #pragma comment(linker, "/export:JsThunk_AllocateData=\"C:\\Windows\\System32\\Chakrathunk.JsThunk_AllocateData\"")
#pragma comment(linker, "/export:JsThunk_Cleanup=\"C:\\Windows\\System32\\Chakrathunk.JsThunk_Cleanup\"")
#pragma comment(linker, "/export:JsThunk_CleanupDefer=\"C:\\Windows\\System32\\Chakrathunk.JsThunk_CleanupDefer\"")
#pragma comment(linker, "/export:JsThunk_CleanupFinish=\"C:\\Windows\\System32\\Chakrathunk.JsThunk_CleanupFinish\"")
#pragma comment(linker, "/export:JsThunk_DataToCode=\"C:\\Windows\\System32\\Chakrathunk.JsThunk_DataToCode\"")
#pragma comment(linker, "/export:JsThunk_GetSize=\"C:\\Windows\\System32\\Chakrathunk.JsThunk_GetSize\"")
#pragma comment(linker, "/export:JsThunk_InitData=\"C:\\Windows\\System32\\Chakrathunk.JsThunk_InitData\"")
#pragma comment(linker, "/export:JsThunk_Is=\"C:\\Windows\\System32\\Chakrathunk.JsThunk_Is\"")
| [
"[email protected]"
] | |
b5e35ef6f65ffc5b4e6b5d54cf1a06bef1008ba8 | 308c9d4167352cfc1b6db1d7a02db3f6894ca050 | /src/bencoder.cpp | 52f982df1d110f49b0e4b328154fdde55770c20d | [] | no_license | eNoise/uenclient | 224ddcabaff78b1a417f135698040bbacc2640d6 | 0aaabaafcb12efdfc778a2db45ef87e07e79251e | refs/heads/master | 2021-01-25T04:01:33.918968 | 2012-03-19T18:26:48 | 2012-03-19T18:26:48 | 1,613,676 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,140 | cpp | /*
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2011 <copyright holder> <email>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "bencoder.h"
Bencoder::Bencoder()
{
}
Bencoder::~Bencoder()
{
}
QByteArray Bencoder::encodeTorrent(const MetaInfo& torrent)
{
Dictionary reciver;
reciver["info"] = Dictionary();
if(torrent.metaInfoFileForm == MetaInfo::MultiFileForm)
{
(qVariantValue<Dictionary>(reciver["info"]))["files"] = List();
(qVariantValue<Dictionary>(reciver["info"]))["piece length"] = torrent.metaInfoPieceLength;
foreach(MetaInfoMultiFile file, torrent.metaInfoMultiFiles)
{
Dictionary fileadd;
fileadd["length"] = file.length;
if(file.md5sum.size() > 0)
fileadd["md5sum"] = file.md5sum;
QString path;
if(file.path.startsWith("/"))
path = file.path.mid(1);
else
path = file.path;
fileadd["path"] = path.split("/");
qVariantValue<List>((qVariantValue<Dictionary>(reciver["info"]))["files"]) << fileadd;
}
foreach(QByteArray hash, torrent.metaInfoSha1Sums)
qVariantValue<QByteArray>((qVariantValue<Dictionary>(reciver["info"]))["pieces"]) += hash;
}
else
{
(qVariantValue<Dictionary>(reciver["info"]))["piece length"] = torrent.metaInfoSingleFile.pieceLength;
(qVariantValue<Dictionary>(reciver["info"]))["length"] = torrent.metaInfoSingleFile.length;
if(torrent.metaInfoSingleFile.md5sum.size() > 0)
(qVariantValue<Dictionary>(reciver["info"]))["md5sum"] = torrent.metaInfoSingleFile.md5sum;
(qVariantValue<Dictionary>(reciver["info"]))["name"] = torrent.metaInfoSingleFile.name;
foreach(QByteArray hash, torrent.metaInfoSingleFile.sha1Sums)
qVariantValue<QByteArray>((qVariantValue<Dictionary>(reciver["info"]))["pieces"]) += hash;
}
reciver["announce"] = torrent.metaInfoAnnounce;
if(!torrent.metaInfoCreationDate.isNull())
reciver["creation date"] = torrent.metaInfoCreationDate.toTime_t();
if(torrent.metaInfoComment.size() > 0)
reciver["comment"] = torrent.metaInfoComment;
if(torrent.metaInfoCreatedBy.size() > 0)
reciver["created by"] = torrent.metaInfoCreatedBy;
reciver["encoding"] = QString("UTF-8");
return encode(reciver);
}
QByteArray Bencoder::encode(const QVariant& mixed)
{
if(mixed.type() == QVariant::Int || mixed.type() == QVariant::UInt)
return encodeInt(mixed.toInt());
else if(mixed.type() == QVariant::Double)
return encodeDouble(mixed.toDouble());
else if(mixed.type() == QVariant::String)
return encodeString(mixed.toString());
else if(mixed.type() == QVariant::List)
return encodeList(mixed.toList());
else if(mixed.type() == QVariant::Map)
return encodeDictionary(mixed.toMap());
return "";
}
QByteArray Bencoder::encodeDictionary(const Dictionary& array)
{
QMapIterator<QString,QVariant> it(array);
QByteArray ret = "d";
while(it.hasNext())
{
it.next();
ret += encodeString(it.key());
ret += encode(it.value());
}
ret += "e";
}
QByteArray Bencoder::encodeDouble(double value)
{
return (QString("i") + QString().sprintf("%.0f", value) + "e").toUtf8();
}
QByteArray Bencoder::encodeInt(int value)
{
return (QString("i") + value + "e").toUtf8();
}
QByteArray Bencoder::encodeList(const List& array)
{
QByteArray ret = "l";
foreach(QVariant val, array)
ret += encode(val);
ret += "e";
return ret;
}
QByteArray Bencoder::encodeString(const QString& str)
{
return (str.length() + ":" + str).toUtf8();
}
QByteArray Bencoder::encodeString(const QByteArray& str)
{
return str.length() + ":" + str;
}
| [
"[email protected]"
] | |
b785351565ddaaba22d9f922b685919ef77d02a1 | 99e9a110624c4dbb9ff7ac69479a94b6d6c9e637 | /ZAD5/primes_mpi.cpp | 1e1c20c6ee7409c19aff56ec252e266e96517602 | [] | no_license | kwanat/PRIR | ce7dba723659b4a132aaebdb9fafd7b80bdd29f0 | d087eebdbbce26ca9b662bbcc72489c576483495 | refs/heads/master | 2020-04-01T10:49:47.224631 | 2018-11-14T17:12:44 | 2018-11-14T17:12:44 | 153,133,307 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,267 | cpp | # include <iostream>
# include <fstream>
# include <cstdlib>
# include <cmath>
# include <vector>
# include "mpi.h"
using namespace std;
MPI_Comm comm;
struct number{ //struktura wykorzystywana w wektorze danych - zawiera informacje o wartosci liczby oraz o tym czy jest pierwsza
unsigned long int value;
bool prime;
};
vector<number> primeTesting (vector<number> tab, uint sqr, uint d) //Funkcja testująca pierwszoć liczb, przyjmuje jako argumenty zbior do tesowania, pierwiastek do ktorego testujemy oraz wielkosc zbioru testowanego
{ //Funkcja zwraca przetestowany zbior
uint i,j;
for (i=2;i<=sqr;i++) { //petla zrownoleglana - kolejne liczby od 2 do pierwiastka kwadratowego z najwiekszego elementu zbioru wczytywanego
for (j = 0; j <d; j++) { //petla wewnetrzna sprawdzajaca czy kolejne liczby wektora tab dziela sie przez aktualna wartosc zmiennej i
if((tab[j].value%i==0)&(tab[j].value!=i)) //jesli tak liczba uznawana jest za zlozona, dodatkowo sprawdzamy czy liczba nie jest rowna obecnemu dzielnikowi (zasada pierwszosci)
tab[j].prime=false;
}
}
return tab;
}
int main(int argc, char** argv) {
ifstream file; //plik wejsciowy
unsigned int maxval=0; //zmienna przechowująca wartosc maksymalna z testowanego pliku
number fromfile; // pojedyncza liczba z pliku wraz z informacja o pierwszosci
int rank, size; // numer procesu oraz liczba wszystkich procesow
double begin_time, end_time, total_time; //zmienne wykorzystywane do zliczania czasu dzialania programu
MPI_Init(&argc, &argv); //inicjalizacja MPI
comm = MPI_COMM_WORLD; //pobranie komunikatora
MPI_Comm_rank(comm, &rank); //pobranie numeru procesu
MPI_Comm_size(comm, &size); //pobranie liczby wszystkich procesow
//przygotowanie nowego typu danych dla MPI, aby mozliwe bylo przesylanie wektora typu number
int lengths[2] = {1,1}; // ilosc zmiennych w strukturze
MPI_Aint offsets[2] = {offsetof(number,value),offsetof(number,prime)}; // przesuniecie bitowe zmiennych struktury
MPI_Datatype types[2] = {MPI_LONG,MPI::BOOL}; // podstawowe typy skladajace sie na nasz typ
MPI_Datatype myType; // deklaracja nowego typu
MPI_Type_create_struct(2, lengths, offsets, types, &myType); // utworzenie nowego typu
MPI_Type_commit(&myType);
//PROCES ZEROWY
if(rank==0){
if (argc != 2) { //sprawdzenie ilosci argumentow podanych przy wywolaniu programu
cout << "The number of arguments is invalid"<<endl;
exit(1);
}
file.open(argv[1]);
if (file.fail()){ //Sprawdzenie poprawnosci otwartego pliku
cout<<"Could not open file to read."<<endl;
exit(1);
}
if (size <= 1) { //Zbyt mała liczba procesow
cout << "Za mala liczba procesow" << endl;
MPI_Finalize();
exit(-1);
}
vector<number> tab; //utworzenie wektora liczb
while (file >> fromfile.value) { //pobranie danych z pliku do wektora tab
fromfile.prime=true; //domniemanie pierwszosci liczby
tab.push_back(fromfile); //zapisanie liczby w wektorze tab
if(fromfile.value>maxval) //poszukiwanie liczby maksymalnej ze zbioru
maxval=fromfile.value;
}
uint sqr=sqrt(maxval); //pierwiastek z liczby maksymalnej
begin_time = MPI_Wtime(); //rozpoczecie liczenia czasu
uint d=tab.size(); //zmienna pomocnicza rozmiar wektora danych
int begin,end,step; // zmienne pomocnicze do manipulacji podzbiorami danych
begin=0; // początek
step=d/(size-1); // krok
end=step; // koniec
for (int i=1;i<size;i++){ // rozeslanie do procesow podzbiorow liczb pierwszych
if(i==(size-1)) // jesli ostatni podzbior to znacznik konca podzbioru rowny jest znacznikowi konca calego zbioru
end=tab.size();
vector<number> templateTable(tab.begin() + begin, tab.begin() + end); // przygotowanie podzbioru danych
begin=end; // zwiekszenie zmiennych pomocniczych
end+=step;
uint tableSize=templateTable.size(); // rozmiar podzbioru danych
MPI_Send(&tableSize, 1, MPI_INT, i, 0, comm); // wyslanie rozmiaru danych
MPI_Send(&sqr, 1, MPI_INT, i, 1, comm); // wyslanie pierwiastka kwadratowego
MPI_Send(templateTable.data(), tableSize,myType, i, 2, comm); // wyslanie podzbioru danych
}
vector<number> tab2; // wektor do odbierania danych
vector<number> concatTable; // wektor wynikowy
for (int i=1;i<size;i++){ // ODBIERANIE DANYCH Z PROCESOW
MPI_Recv(&d, 1, MPI_INT, i, 0, comm, MPI_STATUS_IGNORE); //odebranie rozmiaru danych
tab2.resize(d); //zmiana rozmiaru wektora abydopasować go do rozmiaru danych
MPI_Recv(tab2.data(),d , myType, i, 1, comm, MPI_STATUS_IGNORE); // odebranie danych
concatTable.insert(concatTable.end(), tab2.begin(), tab2.end()); // dolaczenie odebranych danych do wektora wynikowego
}
end_time = MPI_Wtime(); // zakonczenie liczenia czasu
total_time = ((end_time - begin_time) * 1000); // przeksztalcenie otrzymanego czasu do postaci ms
cout << "Czas: " << total_time << " ms" << endl; //wyświetlanie czasu
for (uint i=0;i<concatTable.size();i++) //wypisanie liczb z wektora tab wraz z informacją czy są pierwsze
if(concatTable[i].prime==true)
cout<<concatTable[i].value<<": prime"<<endl;
else
cout<<concatTable[i].value<<": composite"<<endl;
}else{// KONIEC PROCESU 0
vector<number> tab3,tab4; // wektory do odbierania oraz wysylania danych
uint d,sqr; // wielkosc wektora oraz pierwiastek
MPI_Recv(&d, 1, MPI_INT, 0, 0, comm, MPI_STATUS_IGNORE); // odebranie rozmiaru danych
MPI_Recv(&sqr, 1, MPI_INT, 0, 1, comm, MPI_STATUS_IGNORE); // odebranie pierwiastka
tab3.resize(d); // przygotowanie rozmiaru wektora
MPI_Recv(tab3.data(),d , myType, 0, 2, comm, MPI_STATUS_IGNORE); // odebranie danych do testowania
tab4=primeTesting(tab3,sqr,d); // testowanie pierwszosci liczb
MPI_Send(&d, 1, MPI_INT, 0, 0, comm); // wyslanie rozmiaru danych wynikowych
MPI_Send(tab4.data(), d,myType, 0, 1, comm); // wyslanie danych wynikowych
}
MPI_Type_free(&myType); // wyrejestrowanie typu
MPI_Finalize();
return 0;
}
| [
"[email protected]"
] | |
69ba9ac9208bd6a3395216794c15eac6064aa061 | 8469abaca657bdc96521d7f29b0bdd58634b0c3c | /Assignment_5/src/extra/main_supersample.cpp | 9d9827fbbd10058928935959d8e11fdc99317dac | [] | no_license | kk3039/cg | 7a6aa323f482c1b1f5b998d73820913756e6557c | 1befb77cf5c8fa1d31d70ebb4a3084363f9e7f1c | refs/heads/master | 2022-12-25T01:31:13.859934 | 2020-10-12T23:55:57 | 2020-10-12T23:55:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,231 | cpp | // C++ include
#include <iostream>
#include <string>
#include <vector>
// Utilities for the Assignment
#include "raster.h"
// Image writing library
#define STB_IMAGE_WRITE_IMPLEMENTATION // Do not include this line twice in your project!
#include "stb_image_write.h"
using namespace std;
FrameBuffer scale_down_4x(const FrameBuffer& fb)
{
// The size of the framebuffer must be a multiple of 4
assert(fb.rows() % 4 == 0);
assert(fb.cols() % 4 == 0);
// Allocate the reduced buffer
FrameBuffer out(fb.rows()/4,fb.cols()/4);
for (unsigned i=0;i<out.rows();i++)
{
for (unsigned j=0;j<out.cols();j++)
{
Eigen::Vector4f avg = Eigen::Vector4f::Zero();
for (unsigned ii=0;ii<4;ii++)
for (unsigned jj=0;jj<4;jj++)
avg += fb(i*4+ii,j*4+jj).color.cast<float>();
avg /= 16;
out(i,j).color = avg.cast<uint8_t>();
}
}
return out;
}
int main()
{
// The Framebuffer storing the image rendered by the rasterizer
Eigen::Matrix<FrameBufferAttributes,Eigen::Dynamic,Eigen::Dynamic> frameBuffer(40*4,40*4);
// Global Constants (empty in this example)
UniformAttributes uniform;
// Basic rasterization program
Program program;
// The vertex shader is the identity
program.VertexShader = [](const VertexAttributes& va, const UniformAttributes& uniform)
{
return va;
};
// The fragment shader uses a fixed color
program.FragmentShader = [](const VertexAttributes& va, const UniformAttributes& uniform)
{
return FragmentAttributes(1,0,0);
};
// The blending shader converts colors between 0 and 1 to uint8
program.BlendingShader = [](const FragmentAttributes& fa, const FrameBufferAttributes& previous)
{
return FrameBufferAttributes(fa.color[0]*255,fa.color[1]*255,fa.color[2]*255,fa.color[3]*255);
};
// One triangle in the center of the screen
vector<VertexAttributes> vertices;
vertices.push_back(VertexAttributes(-1,-1,0));
vertices.push_back(VertexAttributes(1,-1,0));
vertices.push_back(VertexAttributes(0,1,0));
rasterize_triangles(program,uniform,vertices,frameBuffer);
vector<uint8_t> image;
framebuffer_to_uint8(frameBuffer,image);
stbi_write_png("triangle.png", frameBuffer.rows(), frameBuffer.cols(), 4, image.data(), frameBuffer.rows()*4);
return 0;
}
| [
"[email protected]"
] | |
30ed71eb428df8c7a46689f2a851958f020f1980 | 0b72f4b4ab09ee4d8ac9ffc8e38facb6e75ba525 | /20210306/Leetcode347. Top K Frequent Elements.cpp | b6962acbe7f0871c1dccebb23cf12a004866f8f3 | [] | no_license | Zachary-Zuo/coding-every-day | 75a31d0cec9061e0b47b917135906a90b991c496 | b61c6fc11ed5264573f42f4d6d1adc9df7eb4f60 | refs/heads/main | 2023-04-03T06:16:29.432221 | 2021-04-09T13:45:44 | 2021-04-09T13:45:44 | 331,183,602 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 740 | cpp | class Solution
{
public:
vector<int> topKFrequent(vector<int> &nums, int k)
{
unordered_map<int, int> counts;
int max_count = 0;
for (const int &num : nums)
{
max_count = max(max_count, ++counts[num]);
}
vector<vector<int>> buckets(max_count + 1);
for (const auto &num : counts)
{
buckets[num.second].push_back(num.first);
}
vector<int> ans;
for (int i = max_count; i >= 0 && ans.size() < k; i--)
{
for (const auto &num : buckets[i])
{
ans.push_back(num);
if (ans.size() == k)
break;
}
}
return ans;
}
}; | [
"[email protected]"
] | |
36f51cb905a3fb5ccb735da505bb65024eccde16 | 01630a00b9aba26c292120419e74cac6cf5caeb0 | /108. Stone Game IV/code.cpp | 01cd818238bf3a01d7f9c03d61b8f3a73668b940 | [] | no_license | amarNetake/Dynamic-Programming-Practice-Work | 52348f131ef140f6bb2c9481dc6c79e8732d29a5 | 21c4da4e99eefbf5c7b0f08a833f85bfcce58261 | refs/heads/master | 2023-06-30T23:21:56.490305 | 2021-07-27T21:23:55 | 2021-07-27T21:23:55 | 389,616,015 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 867 | cpp | class Solution {
public:
int playGame(int n,vector<int>& dp)
{
if(n==0) return 0;
if(dp[n]!=-1) return dp[n];
int result=0;
for(int i=1;i*i<=n;i++)
{
//If the opponent won the game then surely current player will lose and vice versa
//So result of current player= NOT(playGame())=> In integer format we can negate it by subtracting the
//result from 1
result=result + (1-playGame(n-i*i,dp));
if(result==1) return dp[n]=result; //If player win in any of the scenario(for any i) then he can definately win
}
return dp[n]=result;
}
bool winnerSquareGame(int n) {
vector<int> dp(1e6,-1); //0->false; 1->true ; true->if player wins the game
int result=playGame(n,dp);
return result==1?true:false;
}
}; | [
"[email protected]"
] | |
464b5c0cc048166f6ce493fe768378e32cbf1676 | e76ea38dbe5774fccaf14e1a0090d9275cdaee08 | /src/sync/notifier/sync_invalidation_listener.h | 7b7b2fd640b5c45a02feb97fb44ece46b79edfa5 | [
"BSD-3-Clause"
] | permissive | eurogiciel-oss/Tizen_Crosswalk | efc424807a5434df1d5c9e8ed51364974643707d | a68aed6e29bd157c95564e7af2e3a26191813e51 | refs/heads/master | 2021-01-18T19:19:04.527505 | 2014-02-06T13:43:21 | 2014-02-06T13:43:21 | 16,070,101 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 6,927 | h | // Copyright 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.
//
// A simple wrapper around invalidation::InvalidationClient that
// handles all the startup/shutdown details and hookups.
#ifndef SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_H_
#define SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_H_
#include <string>
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "google/cacheinvalidation/include/invalidation-listener.h"
#include "jingle/notifier/listener/push_client_observer.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/util/weak_handle.h"
#include "sync/notifier/ack_tracker.h"
#include "sync/notifier/invalidation_state_tracker.h"
#include "sync/notifier/invalidator_state.h"
#include "sync/notifier/object_id_invalidation_map.h"
#include "sync/notifier/state_writer.h"
#include "sync/notifier/sync_system_resources.h"
namespace base {
class TickClock;
} // namespace base
namespace buzz {
class XmppTaskParentInterface;
} // namespace buzz
namespace notifier {
class PushClient;
} // namespace notifier
namespace syncer {
class RegistrationManager;
// SyncInvalidationListener is not thread-safe and lives on the sync
// thread.
class SYNC_EXPORT_PRIVATE SyncInvalidationListener
: public NON_EXPORTED_BASE(invalidation::InvalidationListener),
public StateWriter,
public NON_EXPORTED_BASE(notifier::PushClientObserver),
public base::NonThreadSafe,
public AckTracker::Delegate {
public:
typedef base::Callback<invalidation::InvalidationClient*(
invalidation::SystemResources*,
int,
const invalidation::string&,
const invalidation::string&,
invalidation::InvalidationListener*)> CreateInvalidationClientCallback;
class SYNC_EXPORT_PRIVATE Delegate {
public:
virtual ~Delegate();
virtual void OnInvalidate(
const ObjectIdInvalidationMap& invalidation_map) = 0;
virtual void OnInvalidatorStateChange(InvalidatorState state) = 0;
};
explicit SyncInvalidationListener(
base::TickClock* tick_clock,
scoped_ptr<notifier::PushClient> push_client);
// Calls Stop().
virtual ~SyncInvalidationListener();
// Does not take ownership of |delegate| or |state_writer|.
// |invalidation_state_tracker| must be initialized.
void Start(
const CreateInvalidationClientCallback&
create_invalidation_client_callback,
const std::string& client_id, const std::string& client_info,
const std::string& invalidation_bootstrap_data,
const InvalidationStateMap& initial_invalidation_state_map,
const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker,
Delegate* delegate);
void UpdateCredentials(const std::string& email, const std::string& token);
// Update the set of object IDs that we're interested in getting
// notifications for. May be called at any time.
void UpdateRegisteredIds(const ObjectIdSet& ids);
// Acknowledge that an invalidation for |id| was handled.
void Acknowledge(const invalidation::ObjectId& id,
const AckHandle& ack_handle);
// invalidation::InvalidationListener implementation.
virtual void Ready(
invalidation::InvalidationClient* client) OVERRIDE;
virtual void Invalidate(
invalidation::InvalidationClient* client,
const invalidation::Invalidation& invalidation,
const invalidation::AckHandle& ack_handle) OVERRIDE;
virtual void InvalidateUnknownVersion(
invalidation::InvalidationClient* client,
const invalidation::ObjectId& object_id,
const invalidation::AckHandle& ack_handle) OVERRIDE;
virtual void InvalidateAll(
invalidation::InvalidationClient* client,
const invalidation::AckHandle& ack_handle) OVERRIDE;
virtual void InformRegistrationStatus(
invalidation::InvalidationClient* client,
const invalidation::ObjectId& object_id,
invalidation::InvalidationListener::RegistrationState reg_state) OVERRIDE;
virtual void InformRegistrationFailure(
invalidation::InvalidationClient* client,
const invalidation::ObjectId& object_id,
bool is_transient,
const std::string& error_message) OVERRIDE;
virtual void ReissueRegistrations(
invalidation::InvalidationClient* client,
const std::string& prefix,
int prefix_length) OVERRIDE;
virtual void InformError(
invalidation::InvalidationClient* client,
const invalidation::ErrorInfo& error_info) OVERRIDE;
// StateWriter implementation.
virtual void WriteState(const std::string& state) OVERRIDE;
// notifier::PushClientObserver implementation.
virtual void OnNotificationsEnabled() OVERRIDE;
virtual void OnNotificationsDisabled(
notifier::NotificationsDisabledReason reason) OVERRIDE;
virtual void OnIncomingNotification(
const notifier::Notification& notification) OVERRIDE;
void DoRegistrationUpdate();
void StopForTest();
InvalidationStateMap GetStateMapForTest() const;
AckTracker* GetAckTrackerForTest();
private:
void Stop();
InvalidatorState GetState() const;
void EmitStateChange();
void PrepareInvalidation(const ObjectIdSet& ids,
int64 version,
const std::string& payload,
invalidation::InvalidationClient* client,
const invalidation::AckHandle& ack_handle);
void EmitInvalidation(const ObjectIdSet& ids,
int64 version,
const std::string& payload,
invalidation::InvalidationClient* client,
const invalidation::AckHandle& ack_handle,
const AckHandleMap& local_ack_handles);
// AckTracker::Delegate implementation.
virtual void OnTimeout(const ObjectIdSet& ids) OVERRIDE;
AckTracker ack_tracker_;
// Owned by |sync_system_resources_|.
notifier::PushClient* const push_client_;
SyncSystemResources sync_system_resources_;
InvalidationStateMap invalidation_state_map_;
WeakHandle<InvalidationStateTracker> invalidation_state_tracker_;
Delegate* delegate_;
scoped_ptr<invalidation::InvalidationClient> invalidation_client_;
scoped_ptr<RegistrationManager> registration_manager_;
// Stored to pass to |registration_manager_| on start.
ObjectIdSet registered_ids_;
// The states of the ticl and the push client.
InvalidatorState ticl_state_;
InvalidatorState push_client_state_;
base::WeakPtrFactory<SyncInvalidationListener> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SyncInvalidationListener);
};
} // namespace syncer
#endif // SYNC_NOTIFIER_SYNC_INVALIDATION_LISTENER_H_
| [
"[email protected]"
] | |
71d7b25ba0420efe5078bf1e01723d8fd6c1887a | 08b8cf38e1936e8cec27f84af0d3727321cec9c4 | /data/crawl/git/old_hunk_2883.cpp | ab83fc928bd24540d698a99250f75f53e838c423 | [] | no_license | ccdxc/logSurvey | eaf28e9c2d6307140b17986d5c05106d1fd8e943 | 6b80226e1667c1e0760ab39160893ee19b0e9fb1 | refs/heads/master | 2022-01-07T21:31:55.446839 | 2018-04-21T14:12:43 | 2018-04-21T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 639 | cpp | static void read_populate_todo(struct commit_list **todo_list,
struct replay_opts *opts)
{
const char *todo_file = git_path(SEQ_TODO_FILE);
struct strbuf buf = STRBUF_INIT;
int fd, res;
fd = open(todo_file, O_RDONLY);
if (fd < 0)
die_errno(_("Could not open %s"), todo_file);
if (strbuf_read(&buf, fd, 0) < 0) {
close(fd);
strbuf_release(&buf);
die(_("Could not read %s."), todo_file);
}
close(fd);
res = parse_insn_buffer(buf.buf, todo_list, opts);
strbuf_release(&buf);
if (res)
die(_("Unusable instruction sheet: %s"), todo_file);
}
static int populate_opts_cb(const char *key, const char *value, void *data)
| [
"[email protected]"
] | |
83e6c923f34d20bc1e410f663f0527758faf87c6 | c17ef4827869dbed4fd9e9af70ed77d620898b77 | /foobar/r3a.cpp | 234649ac3e3280720c1eefe6a56d6f0ad001dc28 | [] | no_license | Dsxv/competitveProgramming | c4fea2bac41ddc2b91c60507ddb39e8d9a3582e5 | 004bf0bb8783b29352035435283578a9db815cc5 | refs/heads/master | 2021-06-24T15:19:43.100584 | 2020-12-27T17:59:44 | 2020-12-27T17:59:44 | 193,387,301 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,162 | cpp | #include <bits/stdc++.h>
using namespace std ;
#define int long long
int xx[4] = {1,-1,0,0} ;
int yy[4] = {0,0,1,-1} ;
int solve(vector<vector<int>> &v){
int n = v.size() , m = v[0].size() ;
bool a[n][m] = {} ;
queue<vector<int>> q ;
vector<int> s = {0,0,1} ;
q.push(s) ;
a[0][0] = 1 ;
while(q.size()){
s = q.front() ;
if(s[0] == n - 1 && s[1] == m - 1) return s[2] ;
q.pop() ;
for(int i = 0 ; i < 4 ; i++){
int xi = xx[i] + s[0] , yi = yy[i] + s[1] ;
if(xi >= 0 && xi <= n - 1 && yi >= 0 && yi <= m - 1 && !a[xi][yi] && !v[xi][yi]){
a[xi][yi] = 1 ;
vector<int> temp = {xi , yi , s[2] + 1} ;
q.push(temp) ;
}
}
}
return INT_MAX ;
}
int solution(vector<vector<int>>& v){
int n = v.size() , m = v[0].size() ;
int ans = INT_MAX ;
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m ; j++){
int x = v[i][j] ;
v[i][j] = 0 ;
ans = min(ans, solve(v)) ;
v[i][j] = x ;
}
}
return ans ;
}
int32_t main(){
int n , m ;
cin >> n >> m ;
vector<vector<int>> v(n,vector<int>(m)) ;
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m ; j++){
cin >> v[i][j] ;
}
}
cout << solution(v) ;
return 0 ;
}
| [
"[email protected]"
] | |
53d3563d3d76fb18f7f0563af06122693ac4589f | 2ed39ca8368cabeaee3c5bae5b3e211c06e359ad | /acm.timus.ru/1907/a.cpp | 71f0f98c21d593f2897607580e8876bfa6588d03 | [] | no_license | herokiller/online-judges | 88f630d4d06aac5d71816f9236d0796b91c66690 | 653d76b677efa200b9488c23aabbede5afd24c92 | refs/heads/master | 2020-12-25T17:35:53.360111 | 2018-12-18T02:52:15 | 2018-12-18T02:52:15 | 39,811,568 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 966 | cpp | #include <iostream>
#include <cmath>
using namespace std;
long long a, b, c, d[20], nd = 0;
int main() {
cin >> a >> b;
c = a;
int x = (long long)(sqrt(c));
long long i = 1;
while (i <= x) {
i++;
if ( c%i == 0 ) {
nd++;
d[nd] = i;
while ( c%i == 0 )
c /= i;
}
}
if ( c > 1 ) {
nd++;
d[nd] = c;
}
long long ans = 0;
if ( a%2 == 0 ) {
for ( int i = 1; i <= (1 << nd)-1; i++ ) {
int k = 0;
long long x = 1;
for ( int j = 0; j < nd; j++ )
if ((i >> j) & 1) {
k++;
x *= d[j+1];
}
if (k%2 == 0 )
ans -= b/x;
else
ans += b/x;
}
} else {
ans = b/2;
if ( b%2 == 1 )
ans++;
for ( int i = 1; i <= (1 << nd)-1; i++ ) {
int k = 0;
long long x = 1;
for ( int j = 0; j < nd; j++ )
if ((i >> j) & 1) {
k++;
x *= d[j+1];
}
if (k%2 == 0 )
ans -= (b/x)/2;
else
ans += (b/x)/2;
}
}
cout << ans << endl;
return 0;
}
| [
"[email protected]"
] | |
2718c00349da57efab9888d050ed6a96f971010e | 8a1302c7f69db619ec871375635dc264fd3e3dbb | /src/components/store/hstore/src/persist_map.tcc | f75c25b7507ad2196977c9404b915727fc6444f2 | [
"Apache-2.0"
] | permissive | Bhaskers-Blu-Org1/mcas | 5a1f65178d2e71f8dd90a388ac7fc7f95f6cd0fe | 5abab4d9682f099e55e352ec3e0b78577ee5087f | refs/heads/master | 2022-04-15T21:03:44.594501 | 2020-04-03T22:26:43 | 2020-04-03T22:26:43 | 275,845,938 | 0 | 1 | NOASSERTION | 2020-06-29T14:53:57 | 2020-06-29T14:53:56 | null | UTF-8 | C++ | false | false | 6,053 | tcc | /*
Copyright [2019-2020] [IBM Corporation]
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 <type_traits> /* is_base_of */
#include "hstore_config.h"
#include "perishable.h"
#include "segment_layout.h"
#if 1
#include "logging.h"
#endif
template <typename Allocator>
class monitor_extend
{
Allocator _a;
public:
monitor_extend(const Allocator &a_)
: _a(a_)
{
#if HSTORE_TRACE_EXTEND
PLOG(PREFIX "ctor %d", LOCATION, USE_CC_HEAP);
#endif
_a.arm_extend();
}
~monitor_extend()
{
#if HSTORE_TRACE_EXTEND
PLOG(PREFIX "dtor", LOCATION);
#endif
_a.disarm_extend();
}
};
/*
* ===== persist_map =====
*/
template <typename Allocator>
impl::persist_map<Allocator>::persist_map(
std::size_t n, Allocator av_
, allocation_state_emplace *ase_
, allocation_state_pin *aspd_
, allocation_state_pin *aspk_
, allocation_state_extend *asx_
)
: _size_control()
, _segment_count(
/* The map tends to split when it is about 40% full.
* Triple the expected object count when computing a segment count.
*/
((n*3U)/base_segment_size == 0 ? 1U : segment_layout::log2((3U * n)/base_segment_size))
)
, _sc{}
, _ase{ase_}
, _aspd{aspd_}
, _aspk{aspk_}
, _asx{asx_}
{
/* do_initial_allocation now requires a persist_controller, to interpret the
* allocation_state_combined field. Construct a temporary one here.
* The permanent persist_controller will be constructted later.
* ERROR: See if we can use a single persist_controller, constructed at an
* appripriate time.
*/
persist_controller<Allocator> pc(av_, this, construction_mode::create);
do_initial_allocation(&pc);
}
template <typename Allocator>
void impl::persist_map<Allocator>::do_initial_allocation(persist_controller<Allocator> *pc_)
{
auto &av = static_cast<Allocator &>(*pc_);
if ( _segment_count.actual().is_stable() )
{
if ( _segment_count.actual().value() == 0 )
{
#if USE_CC_HEAP == 4
/*
* (1) save enough information to know when the allocated pointer is hardened. In this case, the address and new value of the length of the segment table
*
* inlcudes setting of doubt type to emplace
*/
/* ERROR: we can get at the pesistent state two ways: through the allocator (which
* knows about the allocation_state_extend member of persistent_state) and
* pc_, which is the persistent controller. This is one too many ways.
*/
monitor_extend<Allocator> m{bucket_allocator_t(av)};
#endif
pc_->record_segment_count_addr_and_target_value(&_segment_count, _segment_count.actual().value() + 1);
/* Run the allocation */
bucket_allocator_t(av).allocate(
_sc[0].bp
, base_segment_size
, segment_align
);
/* (2) Someone needs to persist the pointer at _sc[0].bp. We let the "tentative_allocator" (part of the "tentative_allocation_state") do that. */
new ( &*_sc[0].bp ) bucket_aligned_t[base_segment_size];
/* (3) atomic increment */
_segment_count.actual_incr();
/* (4) presist the change */
av.persist(&_segment_count, sizeof _segment_count);
/* (5) destructor of monitor_extend will set the allocation_state_extend
* state to idle, indicating that address at _sc[0].bp, which the
* allocator will remember for a while, is definitely allocated and
* not in doubt.
*/
}
/* while not enough allocated segments to hold n elements */
for ( auto ix = _segment_count.actual().value(); ix != _segment_count.specified(); ++ix )
{
auto segment_size = base_segment_size<<(ix-1U);
#if USE_CC_HEAP == 4
// tas_type tas(bucket_allocator_t(av), &_asc.extend);
monitor_extend<Allocator> m{bucket_allocator_t(av)};
pc_->record_segment_count_addr_and_target_value(&_segment_count, _segment_count.actual().value() + 1);
#endif
bucket_allocator_t(av).allocate(
_sc[ix].bp
, segment_size
, segment_align
);
new (&*_sc[ix].bp) bucket_aligned_t[base_segment_size << (ix-1U)];
_segment_count.actual_incr();
av.persist(&_segment_count, sizeof _segment_count);
}
av.persist(&_size_control, sizeof _size_control);
}
}
template <typename Allocator>
void impl::persist_map<Allocator>::reconstitute(Allocator av_)
{
#if USE_CC_HEAP == 3
auto av = bucket_allocator_t(av_);
if ( ! _segment_count.actual().is_stable() || _segment_count.actual().value() != 0 )
{
segment_layout::six_t ix = 0U;
av.reconstitute(base_segment_size, _sc[ix].bp);
++ix;
/* restore segments beyond the first */
for ( ; ix != _segment_count.actual().value_not_stable(); ++ix )
{
auto segment_size = base_segment_size<<(ix-1U);
av.reconstitute(segment_size, _sc[ix].bp);
}
if ( ! _segment_count.actual().is_stable() )
{
/* restore the last, "junior" segment */
auto segment_size = base_segment_size<<(ix-1U);
av.reconstitute(segment_size, _sc[ix].bp);
}
}
#elif USE_CC_HEAP == 4
/* */
/* manifest constant 4 is number of possible emplace/erase deallocations (though 2 is the maximum expected) */
for ( auto i = 0; i != 4; ++i )
{
if ( auto p = ase().er_disused_ptr(i) )
{
PLOG(PREFIX "possibly incomplete deallocation at %p", LOCATION, p);
av_.deallocate(&p);
}
}
/* emplace can be disarmed now. */
av_.emplace_disarm();
/* extend has only allocations (no deallocations), so it could ahve been
* disarmed when the allocator was reinstantiated. But it was not,
* so disarm it here.
*/
av_.extend_disarm();
#endif
}
| [
"[email protected]"
] | |
a2680245a5ed59b0c8c60e454aba283286dd5f3c | 8f97c5a125badba85f96a0a0c66432627a84bee8 | /src/qt/walletmodel.cpp | 1311efaa2503ab603443e833b3b5c1a4c9707ce3 | [
"MIT"
] | permissive | MonkeyD-Core/Rtid-Core | 171ef161576495437b76d753e60f12c1bc09d849 | 68fd6a49c38f661c02e93768bcbd891ce7d200d1 | refs/heads/master | 2021-05-22T19:28:47.257486 | 2020-04-04T17:03:15 | 2020-04-04T17:03:15 | 253,059,048 | 0 | 0 | MIT | 2020-04-04T17:30:08 | 2020-04-04T17:30:07 | null | UTF-8 | C++ | false | false | 19,322 | cpp | // Copyright (c) 2011-2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <qt/walletmodel.h>
#include <qt/addresstablemodel.h>
#include <qt/guiconstants.h>
#include <qt/optionsmodel.h>
#include <qt/paymentserver.h>
#include <qt/recentrequeststablemodel.h>
#include <qt/sendcoinsdialog.h>
#include <qt/transactiontablemodel.h>
#include <interfaces/handler.h>
#include <interfaces/node.h>
#include <key_io.h>
#include <ui_interface.h>
#include <util.h> // for GetBoolArg
#include <wallet/coincontrol.h>
#include <wallet/wallet.h>
#include <stdint.h>
#include <QDebug>
#include <QMessageBox>
#include <QSet>
#include <QTimer>
WalletModel::WalletModel(std::unique_ptr<interfaces::Wallet> wallet, interfaces::Node& node, const PlatformStyle *platformStyle, OptionsModel *_optionsModel, QObject *parent) :
QObject(parent), m_wallet(std::move(wallet)), m_node(node), optionsModel(_optionsModel), addressTableModel(0),
transactionTableModel(0),
recentRequestsTableModel(0),
cachedEncryptionStatus(Unencrypted),
cachedNumBlocks(0)
{
fHaveWatchOnly = m_wallet->haveWatchOnly();
fForceCheckBalanceChanged = false;
addressTableModel = new AddressTableModel(this);
transactionTableModel = new TransactionTableModel(platformStyle, this);
recentRequestsTableModel = new RecentRequestsTableModel(this);
// This timer will be fired repeatedly to update the balance
pollTimer = new QTimer(this);
connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollBalanceChanged()));
pollTimer->start(MODEL_UPDATE_DELAY);
subscribeToCoreSignals();
}
WalletModel::~WalletModel()
{
unsubscribeFromCoreSignals();
}
void WalletModel::updateStatus()
{
EncryptionStatus newEncryptionStatus = getEncryptionStatus();
if(cachedEncryptionStatus != newEncryptionStatus) {
Q_EMIT encryptionStatusChanged();
}
}
void WalletModel::pollBalanceChanged()
{
// Try to get balances and return early if locks can't be acquired. This
// avoids the GUI from getting stuck on periodical polls if the core is
// holding the locks for a longer time - for example, during a wallet
// rescan.
interfaces::WalletBalances new_balances;
int numBlocks = -1;
if (!m_wallet->tryGetBalances(new_balances, numBlocks)) {
return;
}
if(fForceCheckBalanceChanged || m_node.getNumBlocks() != cachedNumBlocks)
{
fForceCheckBalanceChanged = false;
// Balance and number of transactions might have changed
cachedNumBlocks = m_node.getNumBlocks();
checkBalanceChanged(new_balances);
if(transactionTableModel)
transactionTableModel->updateConfirmations();
}
}
void WalletModel::checkBalanceChanged(const interfaces::WalletBalances& new_balances)
{
if(new_balances.balanceChanged(m_cached_balances)) {
m_cached_balances = new_balances;
Q_EMIT balanceChanged(new_balances);
}
}
void WalletModel::updateTransaction()
{
// Balance and number of transactions might have changed
fForceCheckBalanceChanged = true;
}
void WalletModel::updateAddressBook(const QString &address, const QString &label,
bool isMine, const QString &purpose, int status)
{
if(addressTableModel)
addressTableModel->updateEntry(address, label, isMine, purpose, status);
}
void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
{
fHaveWatchOnly = fHaveWatchonly;
Q_EMIT notifyWatchonlyChanged(fHaveWatchonly);
}
bool WalletModel::validateAddress(const QString &address)
{
return IsValidDestinationString(address.toStdString());
}
WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction, const CCoinControl& coinControl)
{
CAmount total = 0;
bool fSubtractFeeFromAmount = false;
QList<SendCoinsRecipient> recipients = transaction.getRecipients();
std::vector<CRecipient> vecSend;
if(recipients.empty())
{
return OK;
}
QSet<QString> setAddress; // Used to detect duplicates
int nAddresses = 0;
// Pre-check input data for validity
for (const SendCoinsRecipient &rcp : recipients)
{
if (rcp.fSubtractFeeFromAmount)
fSubtractFeeFromAmount = true;
if (rcp.paymentRequest.IsInitialized())
{ // PaymentRequest...
CAmount subtotal = 0;
const payments::PaymentDetails& details = rcp.paymentRequest.getDetails();
for (int i = 0; i < details.outputs_size(); i++)
{
const payments::Output& out = details.outputs(i);
if (out.amount() <= 0) continue;
subtotal += out.amount();
const unsigned char* scriptStr = (const unsigned char*)out.script().data();
CScript scriptPubKey(scriptStr, scriptStr+out.script().size());
CAmount nAmount = out.amount();
CRecipient recipient = {scriptPubKey, nAmount, rcp.fSubtractFeeFromAmount};
vecSend.push_back(recipient);
}
if (subtotal <= 0)
{
return InvalidAmount;
}
total += subtotal;
}
else
{ // User-entered rtidcoin address / amount:
if(!validateAddress(rcp.address))
{
return InvalidAddress;
}
if(rcp.amount <= 0)
{
return InvalidAmount;
}
setAddress.insert(rcp.address);
++nAddresses;
CScript scriptPubKey = GetScriptForDestination(DecodeDestination(rcp.address.toStdString()));
CRecipient recipient = {scriptPubKey, rcp.amount, rcp.fSubtractFeeFromAmount};
vecSend.push_back(recipient);
total += rcp.amount;
}
}
if(setAddress.size() != nAddresses)
{
return DuplicateAddress;
}
CAmount nBalance = m_wallet->getAvailableBalance(coinControl);
if(total > nBalance)
{
return AmountExceedsBalance;
}
{
CAmount nFeeRequired = 0;
int nChangePosRet = -1;
std::string strFailReason;
auto& newTx = transaction.getWtx();
newTx = m_wallet->createTransaction(vecSend, coinControl, true /* sign */, nChangePosRet, nFeeRequired, strFailReason);
transaction.setTransactionFee(nFeeRequired);
if (fSubtractFeeFromAmount && newTx)
transaction.reassignAmounts(nChangePosRet);
if(!newTx)
{
if(!fSubtractFeeFromAmount && (total + nFeeRequired) > nBalance)
{
return SendCoinsReturn(AmountWithFeeExceedsBalance);
}
Q_EMIT message(tr("Send Coins"), QString::fromStdString(strFailReason),
CClientUIInterface::MSG_ERROR);
return TransactionCreationFailed;
}
// reject absurdly high fee. (This can never happen because the
// wallet caps the fee at maxTxFee. This merely serves as a
// belt-and-suspenders check)
if (nFeeRequired > m_node.getMaxTxFee())
return AbsurdFee;
}
return SendCoinsReturn(OK);
}
WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &transaction)
{
QByteArray transaction_array; /* store serialized transaction */
{
std::vector<std::pair<std::string, std::string>> vOrderForm;
for (const SendCoinsRecipient &rcp : transaction.getRecipients())
{
if (rcp.paymentRequest.IsInitialized())
{
// Make sure any payment requests involved are still valid.
if (PaymentServer::verifyExpired(rcp.paymentRequest.getDetails())) {
return PaymentRequestExpired;
}
// Store PaymentRequests in wtx.vOrderForm in wallet.
std::string value;
rcp.paymentRequest.SerializeToString(&value);
vOrderForm.emplace_back("PaymentRequest", std::move(value));
}
else if (!rcp.message.isEmpty()) // Message from normal rtidcoin:URI (rtidcoin:123...?message=example)
vOrderForm.emplace_back("Message", rcp.message.toStdString());
}
auto& newTx = transaction.getWtx();
std::string rejectReason;
if (!newTx->commit({} /* mapValue */, std::move(vOrderForm), {} /* fromAccount */, rejectReason))
return SendCoinsReturn(TransactionCommitFailed, QString::fromStdString(rejectReason));
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << newTx->get();
transaction_array.append(&(ssTx[0]), ssTx.size());
}
// Add addresses / update labels that we've sent to the address book,
// and emit coinsSent signal for each recipient
for (const SendCoinsRecipient &rcp : transaction.getRecipients())
{
// Don't touch the address book when we have a payment request
if (!rcp.paymentRequest.IsInitialized())
{
std::string strAddress = rcp.address.toStdString();
CTxDestination dest = DecodeDestination(strAddress);
std::string strLabel = rcp.label.toStdString();
{
// Check if we have a new address or an updated label
std::string name;
if (!m_wallet->getAddress(
dest, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr))
{
m_wallet->setAddressBook(dest, strLabel, "send");
}
else if (name != strLabel)
{
m_wallet->setAddressBook(dest, strLabel, ""); // "" means don't change purpose
}
}
}
Q_EMIT coinsSent(this, rcp, transaction_array);
}
checkBalanceChanged(m_wallet->getBalances()); // update balance immediately, otherwise there could be a short noticeable delay until pollBalanceChanged hits
return SendCoinsReturn(OK);
}
OptionsModel *WalletModel::getOptionsModel()
{
return optionsModel;
}
AddressTableModel *WalletModel::getAddressTableModel()
{
return addressTableModel;
}
TransactionTableModel *WalletModel::getTransactionTableModel()
{
return transactionTableModel;
}
RecentRequestsTableModel *WalletModel::getRecentRequestsTableModel()
{
return recentRequestsTableModel;
}
WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
{
if(!m_wallet->isCrypted())
{
return Unencrypted;
}
else if(m_wallet->isLocked())
{
return Locked;
}
else
{
return Unlocked;
}
}
bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase)
{
if(encrypted)
{
// Encrypt
return m_wallet->encryptWallet(passphrase);
}
else
{
// Decrypt -- TODO; not supported yet
return false;
}
}
bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase)
{
if(locked)
{
// Lock
return m_wallet->lock();
}
else
{
// Unlock
return m_wallet->unlock(passPhrase);
}
}
bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass)
{
m_wallet->lock(); // Make sure wallet is locked before attempting pass change
return m_wallet->changeWalletPassphrase(oldPass, newPass);
}
// Handlers for core signals
static void NotifyUnload(WalletModel* walletModel)
{
qDebug() << "NotifyUnload";
QMetaObject::invokeMethod(walletModel, "unload", Qt::QueuedConnection);
}
static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel)
{
qDebug() << "NotifyKeyStoreStatusChanged";
QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
}
static void NotifyAddressBookChanged(WalletModel *walletmodel,
const CTxDestination &address, const std::string &label, bool isMine,
const std::string &purpose, ChangeType status)
{
QString strAddress = QString::fromStdString(EncodeDestination(address));
QString strLabel = QString::fromStdString(label);
QString strPurpose = QString::fromStdString(purpose);
qDebug() << "NotifyAddressBookChanged: " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + strPurpose + " status=" + QString::number(status);
QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
Q_ARG(QString, strAddress),
Q_ARG(QString, strLabel),
Q_ARG(bool, isMine),
Q_ARG(QString, strPurpose),
Q_ARG(int, status));
}
static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)
{
Q_UNUSED(hash);
Q_UNUSED(status);
QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection);
}
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
{
// emits signal "showProgress"
QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(title)),
Q_ARG(int, nProgress));
}
static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
{
QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", Qt::QueuedConnection,
Q_ARG(bool, fHaveWatchonly));
}
void WalletModel::subscribeToCoreSignals()
{
// Connect signals to wallet
m_handler_unload = m_wallet->handleUnload(boost::bind(&NotifyUnload, this));
m_handler_status_changed = m_wallet->handleStatusChanged(boost::bind(&NotifyKeyStoreStatusChanged, this));
m_handler_address_book_changed = m_wallet->handleAddressBookChanged(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5));
m_handler_transaction_changed = m_wallet->handleTransactionChanged(boost::bind(NotifyTransactionChanged, this, _1, _2));
m_handler_show_progress = m_wallet->handleShowProgress(boost::bind(ShowProgress, this, _1, _2));
m_handler_watch_only_changed = m_wallet->handleWatchOnlyChanged(boost::bind(NotifyWatchonlyChanged, this, _1));
}
void WalletModel::unsubscribeFromCoreSignals()
{
// Disconnect signals from wallet
m_handler_unload->disconnect();
m_handler_status_changed->disconnect();
m_handler_address_book_changed->disconnect();
m_handler_transaction_changed->disconnect();
m_handler_show_progress->disconnect();
m_handler_watch_only_changed->disconnect();
}
// WalletModel::UnlockContext implementation
WalletModel::UnlockContext WalletModel::requestUnlock()
{
bool was_locked = getEncryptionStatus() == Locked;
if(was_locked)
{
// Request UI to unlock wallet
Q_EMIT requireUnlock();
}
// If wallet is still locked, unlock was failed or cancelled, mark context as invalid
bool valid = getEncryptionStatus() != Locked;
return UnlockContext(this, valid, was_locked);
}
WalletModel::UnlockContext::UnlockContext(WalletModel *_wallet, bool _valid, bool _relock):
wallet(_wallet),
valid(_valid),
relock(_relock)
{
}
WalletModel::UnlockContext::~UnlockContext()
{
if(valid && relock)
{
wallet->setWalletLocked(true);
}
}
void WalletModel::UnlockContext::CopyFrom(const UnlockContext& rhs)
{
// Transfer context; old object no longer relocks wallet
*this = rhs;
rhs.relock = false;
}
void WalletModel::loadReceiveRequests(std::vector<std::string>& vReceiveRequests)
{
vReceiveRequests = m_wallet->getDestValues("rr"); // receive request
}
bool WalletModel::saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
{
CTxDestination dest = DecodeDestination(sAddress);
std::stringstream ss;
ss << nId;
std::string key = "rr" + ss.str(); // "rr" prefix = "receive request" in destdata
if (sRequest.empty())
return m_wallet->eraseDestData(dest, key);
else
return m_wallet->addDestData(dest, key, sRequest);
}
bool WalletModel::bumpFee(uint256 hash)
{
CCoinControl coin_control;
coin_control.m_signal_bip125_rbf = true;
std::vector<std::string> errors;
CAmount old_fee;
CAmount new_fee;
CMutableTransaction mtx;
if (!m_wallet->createBumpTransaction(hash, coin_control, 0 /* totalFee */, errors, old_fee, new_fee, mtx)) {
QMessageBox::critical(0, tr("Fee bump error"), tr("Increasing transaction fee failed") + "<br />(" +
(errors.size() ? QString::fromStdString(errors[0]) : "") +")");
return false;
}
// allow a user based fee verification
QString questionString = tr("Do you want to increase the fee?");
questionString.append("<br />");
questionString.append("<table style=\"text-align: left;\">");
questionString.append("<tr><td>");
questionString.append(tr("Current fee:"));
questionString.append("</td><td>");
questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), old_fee));
questionString.append("</td></tr><tr><td>");
questionString.append(tr("Increase:"));
questionString.append("</td><td>");
questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee - old_fee));
questionString.append("</td></tr><tr><td>");
questionString.append(tr("New fee:"));
questionString.append("</td><td>");
questionString.append(BitcoinUnits::formatHtmlWithUnit(getOptionsModel()->getDisplayUnit(), new_fee));
questionString.append("</td></tr></table>");
SendConfirmationDialog confirmationDialog(tr("Confirm fee bump"), questionString);
confirmationDialog.exec();
QMessageBox::StandardButton retval = static_cast<QMessageBox::StandardButton>(confirmationDialog.result());
// cancel sign&broadcast if user doesn't want to bump the fee
if (retval != QMessageBox::Yes) {
return false;
}
WalletModel::UnlockContext ctx(requestUnlock());
if(!ctx.isValid())
{
return false;
}
// sign bumped transaction
if (!m_wallet->signBumpTransaction(mtx)) {
QMessageBox::critical(0, tr("Fee bump error"), tr("Can't sign transaction."));
return false;
}
// commit the bumped transaction
uint256 txid;
if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, txid)) {
QMessageBox::critical(0, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
QString::fromStdString(errors[0])+")");
return false;
}
return true;
}
bool WalletModel::isWalletEnabled()
{
return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
}
bool WalletModel::privateKeysDisabled() const
{
return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
}
QString WalletModel::getWalletName() const
{
return QString::fromStdString(m_wallet->getWalletName());
}
bool WalletModel::isMultiwallet()
{
return m_node.getWallets().size() > 1;
}
| [
"[email protected]"
] | |
cc24544a269cc01ac65d3f5b61be385ba49c2828 | 69ed1447b867b11b3ff841aeb10550fe138a2246 | /SDK/Interfaces/libamcf_interfaces.hpp | d593423813749294fec470a5119863c810eb428c | [
"BSD-3-Clause"
] | permissive | jakeread/AutodeskMachineControlFramework | 926d492390773b57b64aee910412ee29db13a055 | 288b07db3df7b72b67f98040ccf6da9889123469 | refs/heads/master | 2023-08-23T03:07:07.311759 | 2021-08-06T17:35:16 | 2021-08-06T17:35:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,008 | hpp | /*++
Copyright (C) 2021 Autodesk Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Autodesk Inc. nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop.
Abstract: This is an autogenerated C++ header file in order to allow easy
development of Autodesk Machine Control Framework SDK. The implementer of Autodesk Machine Control Framework SDK needs to
derive concrete classes from the abstract classes in this header.
Interface version: 1.0.0
*/
#ifndef __LIBAMCF_CPPINTERFACES
#define __LIBAMCF_CPPINTERFACES
#include <string>
#include <memory>
#include "libamcf_types.hpp"
namespace LibAMCF {
namespace Impl {
/**
Forward declarations of class interfaces
*/
class IBase;
class IOperationResult;
class IDataStream;
class IStreamUpload;
class IConnection;
/*************************************************************************************************************************
Parameter Cache definitions
**************************************************************************************************************************/
class ParameterCache {
public:
virtual ~ParameterCache() {}
};
template <class T1> class ParameterCache_1 : public ParameterCache {
private:
T1 m_param1;
public:
ParameterCache_1 (const T1 & param1)
: m_param1 (param1)
{
}
void retrieveData (T1 & param1)
{
param1 = m_param1;
}
};
template <class T1, class T2> class ParameterCache_2 : public ParameterCache {
private:
T1 m_param1;
T2 m_param2;
public:
ParameterCache_2 (const T1 & param1, const T2 & param2)
: m_param1 (param1), m_param2 (param2)
{
}
void retrieveData (T1 & param1, T2 & param2)
{
param1 = m_param1;
param2 = m_param2;
}
};
template <class T1, class T2, class T3> class ParameterCache_3 : public ParameterCache {
private:
T1 m_param1;
T2 m_param2;
T3 m_param3;
public:
ParameterCache_3 (const T1 & param1, const T2 & param2, const T3 & param3)
: m_param1 (param1), m_param2 (param2), m_param3 (param3)
{
}
void retrieveData (T1 & param1, T2 & param2, T3 & param3)
{
param1 = m_param1;
param2 = m_param2;
param3 = m_param3;
}
};
template <class T1, class T2, class T3, class T4> class ParameterCache_4 : public ParameterCache {
private:
T1 m_param1;
T2 m_param2;
T3 m_param3;
T4 m_param4;
public:
ParameterCache_4 (const T1 & param1, const T2 & param2, const T3 & param3, const T4 & param4)
: m_param1 (param1), m_param2 (param2), m_param3 (param3), m_param4 (param4)
{
}
void retrieveData (T1 & param1, T2 & param2, T3 & param3, T4 & param4)
{
param1 = m_param1;
param2 = m_param2;
param3 = m_param3;
param4 = m_param4;
}
};
/*************************************************************************************************************************
Class interface for Base
**************************************************************************************************************************/
class IBase {
private:
std::unique_ptr<ParameterCache> m_ParameterCache;
public:
/**
* IBase::~IBase - virtual destructor of IBase
*/
virtual ~IBase() {};
/**
* IBase::ReleaseBaseClassInterface - Releases ownership of a base class interface. Deletes the reference, if necessary.
* @param[in] pIBase - The base class instance to release
*/
static void ReleaseBaseClassInterface(IBase* pIBase)
{
if (pIBase) {
pIBase->DecRefCount();
}
};
/**
* IBase::AcquireBaseClassInterface - Acquires shared ownership of a base class interface.
* @param[in] pIBase - The base class instance to acquire
*/
static void AcquireBaseClassInterface(IBase* pIBase)
{
if (pIBase) {
pIBase->IncRefCount();
}
};
/**
* IBase::GetLastErrorMessage - Returns the last error registered of this class instance
* @param[out] sErrorMessage - Message of the last error registered
* @return Has an error been registered already
*/
virtual bool GetLastErrorMessage(std::string & sErrorMessage) = 0;
/**
* IBase::ClearErrorMessages - Clears all registered messages of this class instance
*/
virtual void ClearErrorMessages() = 0;
/**
* IBase::RegisterErrorMessage - Registers an error message with this class instance
* @param[in] sErrorMessage - Error message to register
*/
virtual void RegisterErrorMessage(const std::string & sErrorMessage) = 0;
/**
* IBase::IncRefCount - Increases the reference count of a class instance
*/
virtual void IncRefCount() = 0;
/**
* IBase::DecRefCount - Decreases the reference count of a class instance and free releases it, if the last reference has been removed
* @return Has the object been released
*/
virtual bool DecRefCount() = 0;
/**
* IBase::_setCache - set parameter cache of object
*/
void _setCache(ParameterCache * pCache)
{
m_ParameterCache.reset(pCache);
}
/**
* IBase::_getCache - returns parameter cache of object
*/
ParameterCache* _getCache()
{
return m_ParameterCache.get();
}
};
/**
Definition of a shared pointer class for IBase
*/
template<class T>
class IBaseSharedPtr : public std::shared_ptr<T>
{
public:
explicit IBaseSharedPtr(T* t = nullptr)
: std::shared_ptr<T>(t, IBase::ReleaseBaseClassInterface)
{
t->IncRefCount();
}
// Reset function, as it also needs to properly set the deleter.
void reset(T* t = nullptr)
{
std::shared_ptr<T>::reset(t, IBase::ReleaseBaseClassInterface);
}
// Get-function that increases the Base class's reference count
T* getCoOwningPtr()
{
T* t = this->get();
t->IncRefCount();
return t;
}
};
typedef IBaseSharedPtr<IBase> PIBase;
/*************************************************************************************************************************
Class interface for OperationResult
**************************************************************************************************************************/
class IOperationResult : public virtual IBase {
public:
/**
* IOperationResult::WaitFor - Waits for operation to be finished.
* @param[in] nTimeOut - Timeout value in Milliseconds. 0 means forever.
* @return Returns if operation has been finished.
*/
virtual bool WaitFor(const LibAMCF_uint32 nTimeOut) = 0;
/**
* IOperationResult::EnsureSuccess - Waits for operation to be successfully finished. Throws an error if not successful.
*/
virtual void EnsureSuccess() = 0;
/**
* IOperationResult::InProgress - Checks if operation is in progress.
* @return Flag if operation is in progress.
*/
virtual bool InProgress() = 0;
/**
* IOperationResult::Success - Checks if operation has been finished successfully. Waits for operation to finish.
* @return Flag if operation has been finished successful.
*/
virtual bool Success() = 0;
/**
* IOperationResult::GetErrorMessage - Returns the error message, if the operation has not been successful. Fails if operation is in progress.
* @return Returns error message of failed operation.
*/
virtual std::string GetErrorMessage() = 0;
};
typedef IBaseSharedPtr<IOperationResult> PIOperationResult;
/*************************************************************************************************************************
Class interface for DataStream
**************************************************************************************************************************/
class IDataStream : public virtual IBase {
public:
/**
* IDataStream::GetUUID - Returns the stream UUID.
* @return Stream UUID String.
*/
virtual std::string GetUUID() = 0;
/**
* IDataStream::GetContextUUID - Returns the stream's context UUID.
* @return Stream Context UUID String.
*/
virtual std::string GetContextUUID() = 0;
/**
* IDataStream::GetName - Returns the stream name.
* @return Stream Name.
*/
virtual std::string GetName() = 0;
/**
* IDataStream::GetMimeType - Returns the stream's mime type.
* @return Mime Type string.
*/
virtual std::string GetMimeType() = 0;
/**
* IDataStream::GetSHA256 - Returns the sha256 checksum of the stream.
* @return SHA256 string.
*/
virtual std::string GetSHA256() = 0;
/**
* IDataStream::GetSize - Returns the stream size.
* @return Stream size.
*/
virtual LibAMCF_uint64 GetSize() = 0;
/**
* IDataStream::GetTimestamp - Returns the timestamp of the stream.
* @return Timestamp string.
*/
virtual std::string GetTimestamp() = 0;
};
typedef IBaseSharedPtr<IDataStream> PIDataStream;
/*************************************************************************************************************************
Class interface for StreamUpload
**************************************************************************************************************************/
class IStreamUpload : public virtual IBase {
public:
/**
* IStreamUpload::GetName - returns the name of the stream upload
* @return Name String.
*/
virtual std::string GetName() = 0;
/**
* IStreamUpload::GetMimeType - returns the mimetype of the stream upload
* @return MimeType String.
*/
virtual std::string GetMimeType() = 0;
/**
* IStreamUpload::GetUsageContext - returns the usage context of the stream upload
* @return UsageContext String.
*/
virtual std::string GetUsageContext() = 0;
/**
* IStreamUpload::UploadData - uploads the passed data to the server. MUST only be called once.
* @param[in] nDataBufferSize - Number of elements in buffer
* @param[in] pDataBuffer - Data to be uploaded.
* @param[in] nChunkSize - Chunk size to use in bytes. MUST be a multiple of 64kB. MUST be at least 64kB and less than 64MB.
* @return Returns if upload was successful.
*/
virtual IOperationResult * UploadData(const LibAMCF_uint64 nDataBufferSize, const LibAMCF_uint8 * pDataBuffer, const LibAMCF_uint32 nChunkSize) = 0;
/**
* IStreamUpload::UploadFile - uploads a file to the server. MUST only be called once.
* @param[in] sFileName - File to be uploaded.
* @param[in] nChunkSize - Chunk size to use in bytes. MUST be a multiple of 64kB. MUST be at least 64kB and less than 64MB.
* @return Returns if upload was successful.
*/
virtual IOperationResult * UploadFile(const std::string & sFileName, const LibAMCF_uint32 nChunkSize) = 0;
/**
* IStreamUpload::BeginChunking - Starts a chunked upload. MUST not be used together with uploadData or uploadFile
* @param[in] nDataSize - Full data size to be uploaded.
* @return Returns if request was successful.
*/
virtual IOperationResult * BeginChunking(const LibAMCF_uint64 nDataSize) = 0;
/**
* IStreamUpload::UploadChunk - Uploads another chunk to the server. Chunks are added sequentially together.
* @param[in] nDataBufferSize - Number of elements in buffer
* @param[in] pDataBuffer - Data to be uploaded. Any chunk that is not the last chunk MUST have the size of a multiple of 64kB. A chunk MUST be less than 64MB.
* @return Returns if request was successful.
*/
virtual IOperationResult * UploadChunk(const LibAMCF_uint64 nDataBufferSize, const LibAMCF_uint8 * pDataBuffer) = 0;
/**
* IStreamUpload::FinishChunking - MUST only be called after all chunks have been uploaded.
* @return Returns if request was successful.
*/
virtual IOperationResult * FinishChunking() = 0;
/**
* IStreamUpload::GetStatus - Retrieves current upload status.
* @param[out] nUploadSize - Total target size of the upload. 0 if no upload has been started.
* @param[out] nFinishedSize - Current bytes that have been successfully uploaded.
* @param[out] nInProgressSize - Current bytes that have been uploaded or are currently in progress.
* @param[out] bFinished - Flag if upload has successfully finished.
*/
virtual void GetStatus(LibAMCF_uint64 & nUploadSize, LibAMCF_uint64 & nFinishedSize, LibAMCF_uint64 & nInProgressSize, bool & bFinished) = 0;
/**
* IStreamUpload::GetDataStream - Retrieves the uploaded data stream object. Upload must have finished successfully.
* @return Data stream instance.
*/
virtual IDataStream * GetDataStream() = 0;
};
typedef IBaseSharedPtr<IStreamUpload> PIStreamUpload;
/*************************************************************************************************************************
Class interface for Connection
**************************************************************************************************************************/
class IConnection : public virtual IBase {
public:
/**
* IConnection::GetBaseURL - returns the base url of the AMCF instance
* @return Base URL of the AMCF instance.
*/
virtual std::string GetBaseURL() = 0;
/**
* IConnection::SetTimeouts - sets the timeout behaviour of the connection.
* @param[in] nTimeout - Request timeout in milliseconds. Default is 1000.
* @param[in] nRetryCount - How many retries should be done in an error case. Default is 3.
*/
virtual void SetTimeouts(const LibAMCF_uint32 nTimeout, const LibAMCF_uint32 nRetryCount) = 0;
/**
* IConnection::GetTimeout - gets the timeout behaviour of the connection.
* @return Request timeout in milliseconds
*/
virtual LibAMCF_uint32 GetTimeout() = 0;
/**
* IConnection::GetRetryCount - gets the timeout behaviour of the connection.
* @return How many retries should be done in an error case.
*/
virtual LibAMCF_uint32 GetRetryCount() = 0;
/**
* IConnection::AuthenticateWithPassword - Authenticates with the remote instance with username and password.
* @param[in] sUserName - User name for authentication.
* @param[in] sPassword - Password for authentication.
* @return Returns if authentication was successful.
*/
virtual IOperationResult * AuthenticateWithPassword(const std::string & sUserName, const std::string & sPassword) = 0;
/**
* IConnection::IsAuthenticated - Authenticates with the remote instance with username and password
* @return Returns if connection is authenticated.
*/
virtual bool IsAuthenticated() = 0;
/**
* IConnection::RefreshAuthentication - Refreshes authentication with server.
* @return Returns if authentication refresh was successful.
*/
virtual IOperationResult * RefreshAuthentication() = 0;
/**
* IConnection::Ping - Detects if server is still reachable. Non-Blocking.
* @return Returns if server is still reachable.
*/
virtual IOperationResult * Ping() = 0;
/**
* IConnection::GetAuthToken - Returns the authentication token of the current connection.
* @return Token string.
*/
virtual std::string GetAuthToken() = 0;
/**
* IConnection::CreateUpload - Creates a file upload instance. Must be authenticated to make it work.
* @param[in] sName - Name of the file to be uploaded.
* @param[in] sMimeType - Mimetype of the file to be uploaded.
* @param[in] sUsageContext - Context string for the usage type of the file.
* @return File upload instance.
*/
virtual IStreamUpload * CreateUpload(const std::string & sName, const std::string & sMimeType, const std::string & sUsageContext) = 0;
};
typedef IBaseSharedPtr<IConnection> PIConnection;
/*************************************************************************************************************************
Global functions declarations
**************************************************************************************************************************/
class CWrapper {
public:
/**
* Ilibamcf::GetVersion - retrieves the binary version of this library.
* @param[out] nMajor - returns the major version of this library
* @param[out] nMinor - returns the minor version of this library
* @param[out] nMicro - returns the micro version of this library
*/
static void GetVersion(LibAMCF_uint32 & nMajor, LibAMCF_uint32 & nMinor, LibAMCF_uint32 & nMicro);
/**
* Ilibamcf::GetLastError - Returns the last error recorded on this object
* @param[in] pInstance - Instance Handle
* @param[out] sErrorMessage - Message of the last error
* @return Is there a last error to query
*/
static bool GetLastError(IBase* pInstance, std::string & sErrorMessage);
/**
* Ilibamcf::ReleaseInstance - Releases shared ownership of an Instance
* @param[in] pInstance - Instance Handle
*/
static void ReleaseInstance(IBase* pInstance);
/**
* Ilibamcf::AcquireInstance - Acquires shared ownership of an Instance
* @param[in] pInstance - Instance Handle
*/
static void AcquireInstance(IBase* pInstance);
/**
* Ilibamcf::CreateConnection - Creates a AMCF connection instance.
* @param[in] sBaseURL - Base URL of the AMCF Instance.
* @return New Connection instance
*/
static IConnection * CreateConnection(const std::string & sBaseURL);
};
LibAMCFResult LibAMCF_GetProcAddress (const char * pProcName, void ** ppProcAddress);
} // namespace Impl
} // namespace LibAMCF
#endif // __LIBAMCF_CPPINTERFACES
| [
"[email protected]"
] | |
acafb04a30d28fee1397fd69d3c8f1b56c9b499e | 961772147ce33900cfcda70fc9ab1bb5c7d284d8 | /test/test_bowling.cpp | 1d6b2ed3b706c51b75045cfdf9d40c5426ce53be | [] | no_license | zhourui33/tdd-kata-Bowling | cb96db8f9a47dc92eb1598e807ae5cb3e163a922 | f325c404dae49e4dc1641659e6fc18bb5d71d871 | refs/heads/master | 2022-11-18T22:08:51.430415 | 2020-07-19T14:40:38 | 2020-07-19T14:40:38 | 277,841,516 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,163 | cpp | #include <gtest/gtest.h>
#include "BowlingGame.h"
#define ROLLS(poured, times) do{ \
for(int i = 0; i < times; ++i) \
bowling.roll(poured); \
}while(0);
TEST(test_bowling_scoring, should_got_0_scores_when_every_round_roll_0)
{
BowlingGame bowling;
ROLLS(0, 20);
ASSERT_TRUE(0 == bowling.scoring());
}
TEST(test_bowling_scoring, should_got_60_scores_when_every_round_roll_3)
{
BowlingGame bowling;
ROLLS(3, 20);
ASSERT_TRUE(60 == bowling.scoring());
}
TEST(test_bowling_scoring, should_got_70_scores_when_roll_one_strike_and_others_3)
{
BowlingGame bowling;
bowling.roll(10);
ROLLS(3, 18);
ASSERT_TRUE(70 == bowling.scoring());
}
TEST(test_bowling_scoring, should_got_67_scores_when_roll_one_spare_and_others_3)
{
BowlingGame bowling;
ROLLS(5, 2);
ROLLS(3, 18);
ASSERT_TRUE(67 == bowling.scoring());
}
TEST(test_bowling_scoring, should_got_300_scores_when_every_roll_strike)
{
BowlingGame bowling;
ROLLS(10, 12);
ASSERT_TRUE(300 == bowling.scoring());
} | [
"[email protected]"
] | |
90979c9592e72c2055453e1b9cf13f3c29ffe9ba | 19fb04caaf0b29ba6168a26d491822f6bbed11ea | /5thweek2.cpp | d2f01ad56a49ab91dfb1e3aa14af69acbcb7b0f3 | [] | no_license | AAshisK/cs141 | f2be958061747904d63b48622f989adace16283a | c8af48c54346d796b71269a838f5391ff618cea5 | refs/heads/master | 2020-03-25T17:48:21.452926 | 2018-11-18T17:40:44 | 2018-11-18T17:40:44 | 143,996,946 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 663 | cpp | #include <iostream>
#include <cstring>
using namespace std;
int main()
{//first ask the users to enter all the 3 numbers
//then use a whole lot of if else if and else statements to ge the results
float a,b,c;
cout<<"enter the 1st number ="<<endl;
cin>>a;
cout<<"enter the 2nd number ="<<endl;
cin>>b;
cout<<"enter the 3rd number ="<<endl;
cin>>c;
if (a>b){
if (a>c){ cout<<"1st number is the greatest number"<<endl;}
else {}
}
else {}
if (b>a){
if (b>c){cout<<"2nd number is the greatest number"<<endl;}
else {}}
else {}
if (c>a){
if (c>b){ cout<<"3rd number is the greatest among three"<<endl;}
else{}
}
}
| [
"[email protected]"
] | |
64787679d9fd8ab4ba61d89add225ecae4057312 | 887d4b6cc0633304ad18571bda034b01cb7db479 | /x64/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/include/giomm-2.4/giomm/private/unixsocketaddress_p.h | 900fc55895cb459ab2f9ba79faa3079c450ad096 | [] | no_license | wqiangSSS/miyoo_toolchain | abb582c211332ad258c81437bca6fb031bc2d09f | 551938ab29e2551a25f6cc0dd84a4ffeb7c600a8 | refs/heads/master | 2020-05-17T18:14:19.623492 | 2019-03-14T02:22:18 | 2019-03-14T02:22:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,137 | h | // Generated by gmmproc 2.54.0 -- DO NOT MODIFY!
#ifndef _GIOMM_UNIXSOCKETADDRESS_P_H
#define _GIOMM_UNIXSOCKETADDRESS_P_H
#include <giomm/private/socketaddress_p.h>
#include <glibmm/class.h>
namespace Gio
{
class UnixSocketAddress_Class : public Glib::Class
{
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
using CppObjectType = UnixSocketAddress;
using BaseObjectType = GUnixSocketAddress;
using BaseClassType = GUnixSocketAddressClass;
using CppClassParent = SocketAddress_Class;
using BaseClassParent = GSocketAddressClass;
friend class UnixSocketAddress;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
const Glib::Class& init();
static void class_init_function(void* g_class, void* class_data);
static Glib::ObjectBase* wrap_new(GObject*);
protected:
//Callbacks (default signal handlers):
//These will call the *_impl member methods, which will then call the existing default signal callbacks, if any.
//You could prevent the original default signal handlers being called by overriding the *_impl method.
//Callbacks (virtual functions):
};
} // namespace Gio
#endif /* _GIOMM_UNIXSOCKETADDRESS_P_H */
| [
"[email protected]"
] | |
588e33e1bf367b309f06478ad080daa32ec7f022 | 1786f51414ac5919b4a80c7858e11f7eb12cb1a9 | /Luogu/Template/P3368_BIT2.cpp | af07f255403eb6a8372faa822fd23ee587f38cb1 | [] | no_license | SetsunaChyan/OI_source_code | 206c4d7a0d2587a4d09beeeb185765bca0948f27 | bb484131e02467cdccd6456ea1ecb17a72f6e3f6 | refs/heads/master | 2020-04-06T21:42:44.429553 | 2019-12-02T09:18:54 | 2019-12-02T09:18:54 | 157,811,588 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 739 | cpp | #include <cstdio>
const int MAXN = 500005;
int n, m, a[MAXN], BIT[MAXN];
inline int lowbit(int x)
{
return x & -x;
}
void add(int x, int y)
{
for(; x <= n; x += lowbit(x)) BIT[x] += y;
}
void add(int l, int r, int y)
{
for(; l <= n; l += lowbit(l)) BIT[l] += y;
for(r++; r <= n; r += lowbit(r)) BIT[r] -= y;
}
int sum(int x)
{
int ret = 0;
for(; x >= 1; x -= lowbit(x)) ret += BIT[x];
return ret;
}
int main()
{
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
add(i, a[i] - a[i - 1]);
}
while(m--)
{
int opt, x, y, k;
scanf("%d", &opt);
if(opt == 1)
{
scanf("%d%d%d", &x, &y, &k);
add(x, y, k);
}
else
{
scanf("%d", &x);
printf("%d\n", sum(x));
}
}
return 0;
} | [
"[email protected]"
] | |
aa9300d26928846d30f13716e066766dd114a65f | 4fd7cc39218c1d5fc69ff60dd163143a246da828 | /animation/Classes/VisibleRect.cpp | 2deda928a8219beffeb18e8005907a6242a4515c | [] | no_license | ghunreal/summary | 623ce4e82faf727c951b74bd10f157f9867e832f | db2c61a63d1c9fc72cd33a8eeb68ebc3819ecc17 | refs/heads/master | 2021-01-12T08:48:38.632071 | 2017-04-18T05:42:21 | 2017-04-18T05:42:21 | 76,701,594 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,608 | cpp | #include "VisibleRect.h"
namespace Tool{
Rect VisibleRect::s_visibleRect;
void VisibleRect::lazyInit()
{
s_visibleRect = Director::getInstance()->getOpenGLView()->getVisibleRect();
}
Rect VisibleRect::getVisibleRect()
{
lazyInit();
return s_visibleRect;
}
Vec2 VisibleRect::left()
{
lazyInit();
return Vec2(s_visibleRect.origin.x, s_visibleRect.origin.y + s_visibleRect.size.height / 2);
}
Vec2 VisibleRect::right()
{
lazyInit();
return Vec2(s_visibleRect.origin.x + s_visibleRect.size.width, s_visibleRect.origin.y + s_visibleRect.size.height / 2);
}
Vec2 VisibleRect::top()
{
lazyInit();
return Vec2(s_visibleRect.origin.x + s_visibleRect.size.width / 2,s_visibleRect.origin.y + s_visibleRect.size.height);
}
Vec2 VisibleRect::bottom()
{
lazyInit();
return Vec2(s_visibleRect.origin.x + s_visibleRect.size.width / 2, s_visibleRect.origin.y);
}
Vec2 VisibleRect::leftTop()
{
lazyInit();
return Vec2(s_visibleRect.origin.x, s_visibleRect.origin.y + s_visibleRect.size.height);
}
Vec2 VisibleRect::center()
{
lazyInit();
return Vec2(s_visibleRect.origin.x + s_visibleRect.size.width / 2, s_visibleRect.origin.y + s_visibleRect.size.height / 2);
}
Vec2 VisibleRect::leftBottom()
{
lazyInit();
return s_visibleRect.origin;
}
Vec2 VisibleRect::rightTop()
{
lazyInit();
return Vec2(s_visibleRect.origin.x + s_visibleRect.size.width, s_visibleRect.origin.y + s_visibleRect.size.height);
}
Vec2 VisibleRect::rightBottom()
{
lazyInit();
return Vec2(s_visibleRect.origin.x + s_visibleRect.size.width, s_visibleRect.origin.y);
}
} | [
"[email protected]"
] | |
022cb06a122a486244ae7c946224ac1cca533744 | fddf8f4d81e418e61875f56fdd026fdc7bc28810 | /packages/fltk.1.3.3.33/build/native/include/FL/Fl.H | 5411760fce8bc96e17c989cdd907c4636e87e6e8 | [
"MIT"
] | permissive | LemonyStudios/FenestraEngine | 3e7b6844e6f9b3572c943efc45b6c22c4f5e1b3b | d0e6b59315e4dfc32b08245cbb767219dec54daa | refs/heads/master | 2020-03-22T10:25:39.981440 | 2018-07-07T01:56:24 | 2018-07-07T01:56:24 | 139,901,852 | 0 | 1 | MIT | 2018-07-06T18:08:33 | 2018-07-05T21:21:14 | C++ | UTF-8 | C++ | false | false | 54,076 | h | //
// "$Id: Fl.H 10419 2014-10-30 16:05:22Z AlbrechtS $"
//
// Main header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2010 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
/** \file
Fl static class.
*/
#ifndef Fl_H
# define Fl_H
#if defined _WIN32
#ifndef WIN32
# define WIN32
#endif
#if defined(DEBUG) || defined(_DEBUG) || !defined(NDEBUG)
#if defined _DLL
#pragma comment(lib, "md/fltkd")
#pragma comment(lib, "md/fltk_formsd")
#pragma comment(lib, "md/fltk_gld")
#pragma comment(lib, "md/fltk_imagesd")
#pragma comment(lib, "md/fltk_jpegd")
#pragma comment(lib, "md/fltk_pngd")
#pragma comment(lib, "md/fltk_zd")
#elif defined _MT
#pragma comment(lib, "mt/fltkd")
#pragma comment(lib, "mt/fltk_formsd")
#pragma comment(lib, "mt/fltk_gld")
#pragma comment(lib, "mt/fltk_imagesd")
#pragma comment(lib, "mt/fltk_jpegd")
#pragma comment(lib, "mt/fltk_pngd")
#pragma comment(lib, "mt/fltk_zd")
#endif
#else
#if defined _DLL
#pragma comment(lib, "md/fltk")
#pragma comment(lib, "md/fltk_forms")
#pragma comment(lib, "md/fltk_gl")
#pragma comment(lib, "md/fltk_images")
#pragma comment(lib, "md/fltk_jpeg")
#pragma comment(lib, "md/fltk_png")
#pragma comment(lib, "md/fltk_z")
#elif defined _MT
#pragma comment(lib, "mt/fltk")
#pragma comment(lib, "mt/fltk_forms")
#pragma comment(lib, "mt/fltk_gl")
#pragma comment(lib, "mt/fltk_images")
#pragma comment(lib, "mt/fltk_jpeg")
#pragma comment(lib, "mt/fltk_png")
#pragma comment(lib, "mt/fltk_z")
#endif
#endif
#endif
#ifdef FLTK_HAVE_CAIRO
# include <FL/Fl_Cairo.H>
#endif
# include "fl_utf8.h"
# include "Enumerations.H"
# ifndef Fl_Object
# define Fl_Object Fl_Widget /**< for back compatibility - use Fl_Widget! */
# endif
# ifdef check
# undef check
# endif
class Fl_Widget;
class Fl_Window;
class Fl_Image;
struct Fl_Label;
// Keep avoiding having the socket deps at that level but mke sure it will work in both 32 & 64 bit builds
#if defined(WIN32) && !defined(__CYGWIN__)
# if defined(_WIN64)
# define FL_SOCKET unsigned __int64
# else
# define FL_SOCKET int
# endif
#else
# define FL_SOCKET int
#endif
/** \defgroup callback_functions Callback function typedefs
\brief Typedefs defined in <FL/Fl.H> for callback or handler functions passed as function parameters.
FLTK uses callback functions as parameters for some function calls, e.g. to
set up global event handlers (Fl::add_handler()), to add a timeout handler
(Fl::add_timeout()), and many more.
The typedefs defined in this group describe the function parameters used to set
up or clear the callback functions and should also be referenced to define the
callback function to handle such events in the user's code.
\see Fl::add_handler(), Fl::add_timeout(), Fl::repeat_timeout(),
Fl::remove_timeout() and others
@{ */
/** Signature of some label drawing functions passed as parameters */
typedef void (Fl_Label_Draw_F)(const Fl_Label *label, int x, int y, int w, int h, Fl_Align align);
/** Signature of some label measurement functions passed as parameters */
typedef void (Fl_Label_Measure_F)(const Fl_Label *label, int &width, int &height);
/** Signature of some box drawing functions passed as parameters */
typedef void (Fl_Box_Draw_F)(int x, int y, int w, int h, Fl_Color color);
/** Signature of some timeout callback functions passed as parameters */
typedef void (*Fl_Timeout_Handler)(void *data);
/** Signature of some wakeup callback functions passed as parameters */
typedef void (*Fl_Awake_Handler)(void *data);
/** Signature of add_idle callback functions passed as parameters */
typedef void (*Fl_Idle_Handler)(void *data);
/** Signature of set_idle callback functions passed as parameters */
typedef void (*Fl_Old_Idle_Handler)();
/** Signature of add_fd functions passed as parameters */
typedef void (*Fl_FD_Handler)(FL_SOCKET fd, void *data);
/** Signature of add_handler functions passed as parameters */
typedef int (*Fl_Event_Handler)(int event);
/** Signature of add_system_handler functions passed as parameters */
typedef int (*Fl_System_Handler)(void *event, void *data);
/** Signature of set_abort functions passed as parameters */
typedef void (*Fl_Abort_Handler)(const char *format,...);
/** Signature of set_atclose functions passed as parameters */
typedef void (*Fl_Atclose_Handler)(Fl_Window *window, void *data);
/** Signature of args functions passed as parameters */
typedef int (*Fl_Args_Handler)(int argc, char **argv, int &i);
/** Signature of event_dispatch functions passed as parameters.
\see Fl::event_dispatch(Fl_Event_Dispatch) */
typedef int (*Fl_Event_Dispatch)(int event, Fl_Window *w);
/** Signature of add_clipboard_notify functions passed as parameters */
typedef void (*Fl_Clipboard_Notify_Handler)(int source, void *data);
/** @} */ /* group callback_functions */
/**
The Fl is the FLTK global (static) class containing
state information and global methods for the current application.
*/
class FL_EXPORT Fl {
Fl() {}; // no constructor!
public: // should be private!
#ifndef FL_DOXYGEN
static int e_number;
static int e_x;
static int e_y;
static int e_x_root;
static int e_y_root;
static int e_dx;
static int e_dy;
static int e_state;
static int e_clicks;
static int e_is_click;
static int e_keysym;
static char* e_text;
static int e_length;
static void *e_clipboard_data;
static const char *e_clipboard_type;
static Fl_Event_Dispatch e_dispatch;
static Fl_Widget* belowmouse_;
static Fl_Widget* pushed_;
static Fl_Widget* focus_;
static int damage_;
static Fl_Widget* selection_owner_;
static Fl_Window* modal_;
static Fl_Window* grab_;
static int compose_state; // used for dead keys (WIN32) or marked text (MacOS)
static void call_screen_init(); // recompute screen number and dimensions
#ifdef __APPLE__
static void reset_marked_text(); // resets marked text
static void insertion_point_location(int x, int y, int height); // sets window coordinates & height of insertion point
#endif
#endif // FL_DOXYGEN
/**
If true then flush() will do something.
*/
static void damage(int d) {damage_ = d;}
public:
/** Enumerator for global FLTK options.
These options can be set system wide, per user, or for the running
application only.
\see Fl::option(Fl_Option, bool)
\see Fl::option(Fl_Option)
*/
typedef enum {
/// When switched on, moving the text cursor beyond the start or end of
/// a text in a text widget will change focus to the next text widget.
/// (This is considered 'old' behavior)
///
/// When switched off (default), the cursor will stop at the end of the text.
/// Pressing Tab or Ctrl-Tab will advance the keyboard focus.
///
/// See also: Fl_Input_::tab_nav()
///
OPTION_ARROW_FOCUS = 0,
// When switched on, FLTK will use the file chooser dialog that comes
// with your operating system whenever possible. When switched off, FLTK
// will present its own file chooser.
// \todo implement me
// OPTION_NATIVE_FILECHOOSER,
// When Filechooser Preview is enabled, the FLTK or native file chooser
// will show a preview of a selected file (if possible) before the user
// decides to choose the file.
// \todo implement me
//OPTION_FILECHOOSER_PREVIEW,
/// If visible focus is switched on (default), FLTK will draw a dotted rectangle
/// inside the widget that will receive the next keystroke. If switched
/// off, no such indicator will be drawn and keyboard navigation
/// is disabled.
OPTION_VISIBLE_FOCUS,
/// If text drag-and-drop is enabled (default), the user can select and drag text
/// from any text widget. If disabled, no dragging is possible, however
/// dropping text from other applications still works.
OPTION_DND_TEXT,
/// If tooltips are enabled (default), hovering the mouse over a widget with a
/// tooltip text will open a little tooltip window until the mouse leaves
/// the widget. If disabled, no tooltip is shown.
OPTION_SHOW_TOOLTIPS,
/// When switched on (default), Fl_Native_File_Chooser runs GTK file dialogs
/// if the GTK library is available on the platform (linux/unix only).
/// When switched off, GTK file dialogs aren't used even if the GTK library is available.
OPTION_FNFC_USES_GTK,
// don't change this, leave it always as the last element
/// For internal use only.
OPTION_LAST
} Fl_Option;
private:
static unsigned char options_[OPTION_LAST];
static unsigned char options_read_;
public:
/*
Return a global setting for all FLTK applications, possibly overridden
by a setting specifically for this application.
*/
static bool option(Fl_Option opt);
/*
Override an option while the application is running.
*/
static void option(Fl_Option opt, bool val);
/**
The currently executing idle callback function: DO NOT USE THIS DIRECTLY!
This is now used as part of a higher level system allowing multiple
idle callback functions to be called.
\see add_idle(), remove_idle()
*/
static void (*idle)();
#ifndef FL_DOXYGEN
static Fl_Awake_Handler *awake_ring_;
static void **awake_data_;
static int awake_ring_size_;
static int awake_ring_head_;
static int awake_ring_tail_;
static const char* scheme_;
static Fl_Image* scheme_bg_;
static int e_original_keysym; // late addition
static int scrollbar_size_;
#endif
static int add_awake_handler_(Fl_Awake_Handler, void*);
static int get_awake_handler_(Fl_Awake_Handler&, void*&);
public:
// API version number
static double version();
// argument parsers:
static int arg(int argc, char **argv, int& i);
static int args(int argc, char **argv, int& i, Fl_Args_Handler cb = 0);
static void args(int argc, char **argv);
/**
Usage string displayed if Fl::args() detects an invalid argument.
This may be changed to point to customized text at run-time.
*/
static const char* const help;
// things called by initialization:
static void display(const char*);
static int visual(int);
/**
This does the same thing as Fl::visual(int) but also requires OpenGL
drawing to work. This <I>must</I> be done if you want to draw in
normal windows with OpenGL with gl_start() and gl_end().
It may be useful to call this so your X windows use the same visual
as an Fl_Gl_Window, which on some servers will reduce colormap flashing.
See Fl_Gl_Window for a list of additional values for the argument.
*/
static int gl_visual(int, int *alist=0); // platform dependent
static void own_colormap();
static void get_system_colors();
static void foreground(uchar, uchar, uchar);
static void background(uchar, uchar, uchar);
static void background2(uchar, uchar, uchar);
// schemes:
static int scheme(const char *name);
/** See void scheme(const char *name) */
static const char* scheme() {return scheme_;}
/** Returns whether the current scheme is the given name.
This is a fast inline convenience function to support scheme-specific
code in widgets, e.g. in their draw() methods, if required.
Use a valid scheme name, not \p NULL (although \p NULL is allowed,
this is not a useful argument - see below).
If Fl::scheme() has not been set or has been set to the default
scheme ("none" or "base"), then this will always return 0 regardless
of the argument, because Fl::scheme() is \p NULL in this case.
\note The stored scheme name is always lowercase, and this method will
do a case-sensitive compare, so you \b must provide a lowercase string to
return the correct value. This is intentional for performance reasons.
Example:
\code
if (Fl::is_scheme("gtk+")) { your_code_here(); }
\endcode
\param[in] name \b lowercase string of requested scheme name.
\return 1 if the given scheme is active, 0 otherwise.
\see Fl::scheme(const char *name)
*/
static int is_scheme(const char *name) {
return (scheme_ && name && !strcmp(name,scheme_));
}
/**
Called by scheme according to scheme name.
Loads or reloads the current scheme selection.
See void scheme(const char *name)
*/
static int reload_scheme(); // platform dependent
static int scrollbar_size();
static void scrollbar_size(int W);
// execution:
static int wait();
static double wait(double time);
static int check();
static int ready();
static int run();
static Fl_Widget* readqueue();
/**
Adds a one-shot timeout callback. The function will be called by
Fl::wait() at <i>t</i> seconds after this function is called.
The optional void* argument is passed to the callback.
You can have multiple timeout callbacks. To remove a timeout
callback use Fl::remove_timeout().
If you need more accurate, repeated timeouts, use Fl::repeat_timeout() to
reschedule the subsequent timeouts.
The following code will print "TICK" each second on
stdout with a fair degree of accuracy:
\code
void callback(void*) {
puts("TICK");
Fl::repeat_timeout(1.0, callback);
}
int main() {
Fl::add_timeout(1.0, callback);
return Fl::run();
}
\endcode
*/
static void add_timeout(double t, Fl_Timeout_Handler,void* = 0); // platform dependent
/**
Repeats a timeout callback from the expiration of the
previous timeout, allowing for more accurate timing. You may only call
this method inside a timeout callback.
The following code will print "TICK" each second on
stdout with a fair degree of accuracy:
\code
void callback(void*) {
puts("TICK");
Fl::repeat_timeout(1.0, callback);
}
int main() {
Fl::add_timeout(1.0, callback);
return Fl::run();
}
\endcode
*/
static void repeat_timeout(double t, Fl_Timeout_Handler, void* = 0); // platform dependent
static int has_timeout(Fl_Timeout_Handler, void* = 0);
static void remove_timeout(Fl_Timeout_Handler, void* = 0);
static void add_check(Fl_Timeout_Handler, void* = 0);
static int has_check(Fl_Timeout_Handler, void* = 0);
static void remove_check(Fl_Timeout_Handler, void* = 0);
/**
Adds file descriptor fd to listen to.
When the fd becomes ready for reading Fl::wait() will call the
callback and then return. The callback is passed the fd and the
arbitrary void* argument.
The second version takes a when bitfield, with the bits
FL_READ, FL_WRITE, and FL_EXCEPT defined,
to indicate when the callback should be done.
There can only be one callback of each type for a file descriptor.
Fl::remove_fd() gets rid of <I>all</I> the callbacks for a given
file descriptor.
Under UNIX <I>any</I> file descriptor can be monitored (files,
devices, pipes, sockets, etc.). Due to limitations in Microsoft Windows,
WIN32 applications can only monitor sockets.
*/
static void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0); // platform dependent
/** See void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0) */
static void add_fd(int fd, Fl_FD_Handler cb, void* = 0); // platform dependent
/** Removes a file descriptor handler. */
static void remove_fd(int, int when); // platform dependent
/** Removes a file descriptor handler. */
static void remove_fd(int); // platform dependent
static void add_idle(Fl_Idle_Handler cb, void* data = 0);
static int has_idle(Fl_Idle_Handler cb, void* data = 0);
static void remove_idle(Fl_Idle_Handler cb, void* data = 0);
/** If true then flush() will do something. */
static int damage() {return damage_;}
static void redraw();
static void flush();
/** \addtogroup group_comdlg
@{ */
/**
FLTK calls Fl::warning() to output a warning message.
The default version on Windows returns \e without printing a warning
message, because Windows programs normally don't have stderr (a console
window) enabled.
The default version on all other platforms prints the warning message to stderr.
You can override the behavior by setting the function pointer to your
own routine.
Fl::warning() means that there was a recoverable problem, the display may
be messed up, but the user can probably keep working - all X protocol
errors call this, for example. The default implementation returns after
displaying the message.
\note \#include <FL/Fl.H>
*/
static void (*warning)(const char*, ...);
/**
FLTK calls Fl::error() to output a normal error message.
The default version on Windows displays the error message in a MessageBox window.
The default version on all other platforms prints the error message to stderr.
You can override the behavior by setting the function pointer to your
own routine.
Fl::error() means there is a recoverable error such as the inability to read
an image file. The default implementation returns after displaying the message.
\note \#include <FL/Fl.H>
*/
static void (*error)(const char*, ...);
/**
FLTK calls Fl::fatal() to output a fatal error message.
The default version on Windows displays the error message in a MessageBox window.
The default version on all other platforms prints the error message to stderr.
You can override the behavior by setting the function pointer to your
own routine.
Fl::fatal() must not return, as FLTK is in an unusable state, however your
version may be able to use longjmp or an exception to continue, as long as
it does not call FLTK again. The default implementation exits with status 1
after displaying the message.
\note \#include <FL/Fl.H>
*/
static void (*fatal)(const char*, ...);
/** @} */
/** \defgroup fl_windows Windows handling functions
\brief Windows and standard dialogs handling declared in <FL/Fl.H>
@{ */
static Fl_Window* first_window();
static void first_window(Fl_Window*);
static Fl_Window* next_window(const Fl_Window*);
/**
Returns the top-most modal() window currently shown.
This is the most recently shown() window with modal() true, or NULL
if there are no modal() windows shown().
The modal() window has its handle() method called
for all events, and no other windows will have handle()
called (grab() overrides this).
*/
static Fl_Window* modal() {return modal_;}
/** Returns the window that currently receives all events.
\return The window that currently receives all events,
or NULL if event grabbing is currently OFF.
*/
static Fl_Window* grab() {return grab_;}
/** Selects the window to grab.
This is used when pop-up menu systems are active.
Send all events to the passed window no matter where the pointer or
focus is (including in other programs). The window <I>does not have
to be shown()</I> , this lets the handle() method of a
"dummy" window override all event handling and allows you to
map and unmap a complex set of windows (under both X and WIN32
<I>some</I> window must be mapped because the system interface needs a
window id).
If grab() is on it will also affect show() of windows by doing
system-specific operations (on X it turns on override-redirect).
These are designed to make menus popup reliably
and faster on the system.
To turn off grabbing do Fl::grab(0).
<I>Be careful that your program does not enter an infinite loop
while grab() is on. On X this will lock up your screen!</I>
To avoid this potential lockup, all newer operating systems seem to
limit mouse pointer grabbing to the time during which a mouse button
is held down. Some OS's may not support grabbing at all.
*/
static void grab(Fl_Window*); // platform dependent
/** @} */
/** \defgroup fl_events Events handling functions
Fl class events handling API declared in <FL/Fl.H>
@{
*/
// event information:
/**
Returns the last event that was processed. This can be used
to determine if a callback is being done in response to a
keypress, mouse click, etc.
*/
static int event() {return e_number;}
/**
Returns the mouse position of the event relative to the Fl_Window
it was passed to.
*/
static int event_x() {return e_x;}
/**
Returns the mouse position of the event relative to the Fl_Window
it was passed to.
*/
static int event_y() {return e_y;}
/**
Returns the mouse position on the screen of the event. To find the
absolute position of an Fl_Window on the screen, use the
difference between event_x_root(),event_y_root() and
event_x(),event_y().
*/
static int event_x_root() {return e_x_root;}
/**
Returns the mouse position on the screen of the event. To find the
absolute position of an Fl_Window on the screen, use the
difference between event_x_root(),event_y_root() and
event_x(),event_y().
*/
static int event_y_root() {return e_y_root;}
/**
Returns the current horizontal mouse scrolling associated with the
FL_MOUSEWHEEL event. Right is positive.
*/
static int event_dx() {return e_dx;}
/**
Returns the current vertical mouse scrolling associated with the
FL_MOUSEWHEEL event. Down is positive.
*/
static int event_dy() {return e_dy;}
/**
Return where the mouse is on the screen by doing a round-trip query to
the server. You should use Fl::event_x_root() and
Fl::event_y_root() if possible, but this is necessary if you are
not sure if a mouse event has been processed recently (such as to
position your first window). If the display is not open, this will
open it.
*/
static void get_mouse(int &,int &); // platform dependent
/**
Returns non zero if we had a double click event.
\retval Non-zero if the most recent FL_PUSH or FL_KEYBOARD was a "double click".
\retval N-1 for N clicks.
A double click is counted if the same button is pressed
again while event_is_click() is true.
*/
static int event_clicks() {return e_clicks;}
/**
Manually sets the number returned by Fl::event_clicks().
This can be used to set it to zero so that
later code does not think an item was double-clicked.
\param[in] i corresponds to no double-click if 0, i+1 mouse clicks otherwise
\see int event_clicks()
*/
static void event_clicks(int i) {e_clicks = i;}
/**
Returns non-zero if the mouse has not moved far enough
and not enough time has passed since the last FL_PUSH or
FL_KEYBOARD event for it to be considered a "drag" rather than a
"click". You can test this on FL_DRAG, FL_RELEASE,
and FL_MOVE events.
*/
static int event_is_click() {return e_is_click;}
/**
Clears the value returned by Fl::event_is_click().
Useful to prevent the <I>next</I>
click from being counted as a double-click or to make a popup menu
pick an item with a single click. Don't pass non-zero to this.
*/
static void event_is_click(int i) {e_is_click = i;}
/**
Gets which particular mouse button caused the current event.
This returns garbage if the most recent event was not a FL_PUSH or FL_RELEASE event.
\retval FL_LEFT_MOUSE \retval FL_MIDDLE_MOUSE \retval FL_RIGHT_MOUSE.
\see Fl::event_buttons()
*/
static int event_button() {return e_keysym-FL_Button;}
/**
This is a bitfield of what shift states were on and what mouse buttons
were held down during the most recent event. The second version
returns non-zero if any of the passed bits are turned on.
The legal bits are:
\li FL_SHIFT
\li FL_CAPS_LOCK
\li FL_CTRL
\li FL_ALT
\li FL_NUM_LOCK
\li FL_META
\li FL_SCROLL_LOCK
\li FL_BUTTON1
\li FL_BUTTON2
\li FL_BUTTON3
X servers do not agree on shift states, and FL_NUM_LOCK, FL_META, and
FL_SCROLL_LOCK may not work. The values were selected to match the
XFree86 server on Linux. In addition there is a bug in the way X works
so that the shift state is not correctly reported until the first event
<I>after</I> the shift key is pressed or released.
*/
static int event_state() {return e_state;}
/** See int event_state() */
static int event_state(int i) {return e_state&i;}
/**
Gets which key on the keyboard was last pushed.
The returned integer 'key code' is not necessarily a text
equivalent for the keystroke. For instance: if someone presses '5' on the
numeric keypad with numlock on, Fl::event_key() may return the 'key code'
for this key, and NOT the character '5'. To always get the '5', use Fl::event_text() instead.
\returns an integer 'key code', or 0 if the last event was not a key press or release.
\see int event_key(int), event_text(), compose(int&).
*/
static int event_key() {return e_keysym;}
/**
Returns the keycode of the last key event, regardless of the NumLock state.
If NumLock is deactivated, FLTK translates events from the
numeric keypad into the corresponding arrow key events.
event_key() returns the translated key code, whereas
event_original_key() returns the keycode before NumLock translation.
*/
static int event_original_key(){return e_original_keysym;}
/**
Returns true if the given \p key was held
down (or pressed) <I>during</I> the last event. This is constant until
the next event is read from the server.
Fl::get_key(int) returns true if the given key is held down <I>now</I>.
Under X this requires a round-trip to the server and is <I>much</I>
slower than Fl::event_key(int).
Keys are identified by the <I>unshifted</I> values. FLTK defines a
set of symbols that should work on most modern machines for every key
on the keyboard:
\li All keys on the main keyboard producing a printable ASCII
character use the value of that ASCII character (as though shift,
ctrl, and caps lock were not on). The space bar is 32.
\li All keys on the numeric keypad producing a printable ASCII
character use the value of that ASCII character plus FL_KP.
The highest possible value is FL_KP_Last so you can
range-check to see if something is on the keypad.
\li All numbered function keys use the number on the function key plus
FL_F. The highest possible number is FL_F_Last, so you
can range-check a value.
\li Buttons on the mouse are considered keys, and use the button
number (where the left button is 1) plus FL_Button.
\li All other keys on the keypad have a symbol: FL_Escape,
FL_BackSpace, FL_Tab, FL_Enter, FL_Print, FL_Scroll_Lock, FL_Pause,
FL_Insert, FL_Home, FL_Page_Up, FL_Delete, FL_End, FL_Page_Down,
FL_Left, FL_Up, FL_Right, FL_Down, FL_Iso_Key, FL_Shift_L, FL_Shift_R,
FL_Control_L, FL_Control_R, FL_Caps_Lock, FL_Alt_L, FL_Alt_R,
FL_Meta_L, FL_Meta_R, FL_Menu, FL_Num_Lock, FL_KP_Enter. Be
careful not to confuse these with the very similar, but all-caps,
symbols used by Fl::event_state().
On X Fl::get_key(FL_Button+n) does not work.
On WIN32 Fl::get_key(FL_KP_Enter) and Fl::event_key(FL_KP_Enter) do not work.
*/
static int event_key(int key);
/**
Returns true if the given \p key is held down <I>now</I>.
Under X this requires a round-trip to the server and is <I>much</I>
slower than Fl::event_key(int). \see event_key(int)
*/
static int get_key(int key); // platform dependent
/**
Returns the text associated with the current event, including FL_PASTE or FL_DND_RELEASE events.
This can be used in response to FL_KEYUP, FL_KEYDOWN, FL_PASTE, and FL_DND_RELEASE.
When responding to FL_KEYUP/FL_KEYDOWN, use this function instead of Fl::event_key()
to get the text equivalent of keystrokes suitable for inserting into strings
and text widgets.
The returned string is guaranteed to be NULL terminated.
However, see Fl::event_length() for the actual length of the string,
in case the string itself contains NULLs that are part of the text data.
\returns A NULL terminated text string equivalent of the last keystroke.
*/
static const char* event_text() {return e_text;}
/**
Returns the length of the text in Fl::event_text(). There
will always be a nul at this position in the text. However there may
be a nul before that if the keystroke translates to a nul character or
you paste a nul character.
*/
static int event_length() {return e_length;}
/** During an FL_PASTE event of non-textual data, returns a pointer to the pasted data.
The returned data is an Fl_Image * when the result of Fl::event_clipboard_type() is Fl::clipboard_image.
*/
static void *event_clipboard() { return e_clipboard_data; }
/** Returns the type of the pasted data during an FL_PASTE event.
This type can be Fl::clipboard_plain_text or Fl::clipboard_image.
*/
static const char *event_clipboard_type() {return e_clipboard_type; }
static int compose(int &del);
static void compose_reset();
static int event_inside(int,int,int,int);
static int event_inside(const Fl_Widget*);
static int test_shortcut(Fl_Shortcut);
/**
Enables the system input methods facilities. This is the default.
\see disable_im()
*/
static void enable_im();
/**
Disables the system input methods facilities.
\see enable_im()
*/
static void disable_im();
// event destinations:
static int handle(int, Fl_Window*);
static int handle_(int, Fl_Window*);
/** Gets the widget that is below the mouse.
\see belowmouse(Fl_Widget*) */
static Fl_Widget* belowmouse() {return belowmouse_;}
static void belowmouse(Fl_Widget*);
/** Gets the widget that is being pushed.
\see void pushed(Fl_Widget*) */
static Fl_Widget* pushed() {return pushed_;}
static void pushed(Fl_Widget*);
/** Gets the current Fl::focus() widget. \sa Fl::focus(Fl_Widget*) */
static Fl_Widget* focus() {return focus_;}
static void focus(Fl_Widget*);
static void add_handler(Fl_Event_Handler h);
static void remove_handler(Fl_Event_Handler h);
static void add_system_handler(Fl_System_Handler h, void *data);
static void remove_system_handler(Fl_System_Handler h);
static void event_dispatch(Fl_Event_Dispatch d);
static Fl_Event_Dispatch event_dispatch();
/** @} */
/** \defgroup fl_clipboard Selection & Clipboard functions
FLTK global copy/cut/paste functions declared in <FL/Fl.H>
@{ */
// cut/paste:
/**
Copies the data pointed to by \p stuff to the selection buffer
(\p destination is 0) or
the clipboard (\p destination is 1).
\p len is the number of relevant bytes in \p stuff.
\p type is always Fl::clipboard_plain_text.
The selection buffer is used for
middle-mouse pastes and for drag-and-drop selections. The
clipboard is used for traditional copy/cut/paste operations.
\note This function is, at present, intended only to copy UTF-8 encoded textual data.
To copy graphical data, use the Fl_Copy_Surface class. The \p type argument may allow
in the future to copy other kinds of data.
*/
#if FLTK_ABI_VERSION >= 10303 || defined(FL_DOXYGEN)
static void copy(const char* stuff, int len, int destination = 0, const char *type = Fl::clipboard_plain_text); // platform dependent
#else
static void copy(const char* stuff, int len, int destination, const char *type);
static void copy(const char* stuff, int len, int destination = 0);
#endif
#if !(defined(__APPLE__) || defined(WIN32) || defined(FL_DOXYGEN))
static void copy_image(const unsigned char* data, int W, int H, int destination = 0); // platform dependent
#endif
/**
Pastes the data from the selection buffer (\p source is 0) or the clipboard
(\p source is 1) into \p receiver. If \p source is 1,
the optional \p type argument indicates what type of data is requested from the clipboard
(at present, Fl::clipboard_plain_text - requesting text data - and
Fl::clipboard_image - requesting image data - are possible).
Set things up so the handle function of the \p receiver widget will be called with an FL_PASTE event some
time in the future if the clipboard does contain data of the requested type. During processing of this event,
and if \p type is Fl::clipboard_plain_text, the text data from the specified \p source are in Fl::event_text()
with UTF-8 encoding, and the number of characters in Fl::event_length();
if \p type is Fl::clipboard_image, Fl::event_clipboard() returns a pointer to the
image data, as an Fl_Image *.
The receiver
should be prepared to be called \e directly by this, or for
it to happen \e later, or possibly <i>not at all</i>. This
allows the window system to take as long as necessary to retrieve
the paste buffer (or even to screw up completely) without complex
and error-prone synchronization code in FLTK.
The selection buffer is used for middle-mouse pastes and for
drag-and-drop selections. The clipboard is used for traditional
copy/cut/paste operations.
\par Platform details for image data:
\li Unix/Linux platform: Image data in PNG or BMP formats are recognized. Requires linking with the fltk_images library.
\li MSWindows platform: Both bitmap and vectorial (Enhanced metafile) data from clipboard
can be pasted as image data.
\li Mac OS X platform: Both bitmap (TIFF) and vectorial (PDF) data from clipboard
can be pasted as image data.
*/
#if FLTK_ABI_VERSION >= 10303 || defined(FL_DOXYGEN)
static void paste(Fl_Widget &receiver, int source, const char *type = Fl::clipboard_plain_text); // platform dependent
#else
static void paste(Fl_Widget &receiver, int source, const char *type);
static void paste(Fl_Widget &receiver, int source /*=0*/);
#endif
/**
FLTK will call the registered callback whenever there is a change to the
selection buffer or the clipboard. The source argument indicates which
of the two has changed. Only changes by other applications are reported.
Example:
\code
void clip_callback(int source, void *data) {
if ( source == 0 ) printf("CLIP CALLBACK: selection buffer changed\n");
if ( source == 1 ) printf("CLIP CALLBACK: clipboard changed\n");
}
[..]
int main() {
[..]
Fl::add_clipboard_notify(clip_callback);
[..]
}
\endcode
\note Some systems require polling to monitor the clipboard and may
therefore have some delay in detecting changes.
*/
static void add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data = 0);
/**
Stop calling the specified callback when there are changes to the selection
buffer or the clipboard.
*/
static void remove_clipboard_notify(Fl_Clipboard_Notify_Handler h);
/** Returns non 0 if the clipboard contains data matching \p type.
\p type can be Fl::clipboard_plain_text or Fl::clipboard_image.
*/
static int clipboard_contains(const char *type);
/** Denotes plain textual data
*/
static char const * const clipboard_plain_text;
/** Denotes image data
*/
static char const * const clipboard_image;
/**
Initiate a Drag And Drop operation. The selection buffer should be
filled with relevant data before calling this method. FLTK will
then initiate the system wide drag and drop handling. Dropped data
will be marked as <i>text</i>.
Create a selection first using:
Fl::copy(const char *stuff, int len, 0)
*/
static int dnd(); // platform dependent
// These are for back-compatibility only:
/** back-compatibility only: Gets the widget owning the current selection
\see Fl_Widget* selection_owner(Fl_Widget*) */
static Fl_Widget* selection_owner() {return selection_owner_;}
static void selection_owner(Fl_Widget*);
static void selection(Fl_Widget &owner, const char*, int len);
static void paste(Fl_Widget &receiver);
/** @} */
/** \defgroup fl_screen Screen functions
fl global screen functions declared in <FL/Fl.H>
@{ */
// screen size:
/** Returns the leftmost x coordinate of the main screen work area. */
static int x(); // platform dependent
/** Returns the topmost y coordinate of the main screen work area. */
static int y(); // platform dependent
/** Returns the width in pixels of the main screen work area. */
static int w(); // platform dependent
/** Returns the height in pixels of the main screen work area. */
static int h(); // platform dependent
// multi-head support:
static int screen_count();
/**
Gets the bounding box of a screen that contains the mouse pointer.
\param[out] X,Y,W,H the corresponding screen bounding box
\see void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my)
*/
static void screen_xywh(int &X, int &Y, int &W, int &H) {
int x, y;
Fl::get_mouse(x, y);
screen_xywh(X, Y, W, H, x, y);
}
static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
static void screen_xywh(int &X, int &Y, int &W, int &H, int n);
static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
static int screen_num(int x, int y);
static int screen_num(int x, int y, int w, int h);
static void screen_dpi(float &h, float &v, int n=0);
static void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my);
static void screen_work_area(int &X, int &Y, int &W, int &H, int n);
/**
Gets the bounding box of the work area of the screen that contains the mouse pointer.
\param[out] X,Y,W,H the work area bounding box
\see void screen_work_area(int &x, int &y, int &w, int &h, int mx, int my)
*/
static void screen_work_area(int &X, int &Y, int &W, int &H) {
int x, y;
Fl::get_mouse(x, y);
screen_work_area(X, Y, W, H, x, y);
}
/** @} */
/** \defgroup fl_attributes Color & Font functions
fl global color, font functions.
These functions are declared in <FL/Fl.H> or <FL/fl_draw.H>.
@{ */
// color map:
static void set_color(Fl_Color, uchar, uchar, uchar);
/**
Sets an entry in the fl_color index table. You can set it to any
8-bit RGB color. The color is not allocated until fl_color(i) is used.
*/
static void set_color(Fl_Color i, unsigned c); // platform dependent
static unsigned get_color(Fl_Color i);
static void get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue);
/**
Frees the specified color from the colormap, if applicable.
If overlay is non-zero then the color is freed from the
overlay colormap.
*/
static void free_color(Fl_Color i, int overlay = 0); // platform dependent
// fonts:
static const char* get_font(Fl_Font);
/**
Get a human-readable string describing the family of this face. This
is useful if you are presenting a choice to the user. There is no
guarantee that each face has a different name. The return value points
to a static buffer that is overwritten each call.
The integer pointed to by \p attributes (if the pointer is not
zero) is set to zero, FL_BOLD or FL_ITALIC or
FL_BOLD | FL_ITALIC. To locate a "family" of fonts, search
forward and back for a set with non-zero attributes, these faces along
with the face with a zero attribute before them constitute a family.
*/
static const char* get_font_name(Fl_Font, int* attributes = 0);
/**
Return an array of sizes in \p sizep. The return value is the
length of this array. The sizes are sorted from smallest to largest
and indicate what sizes can be given to fl_font() that will
be matched exactly (fl_font() will pick the closest size for
other sizes). A zero in the first location of the array indicates a
scalable font, where any size works, although the array may list sizes
that work "better" than others. Warning: the returned array
points at a static buffer that is overwritten each call. Under X this
will open the display.
*/
static int get_font_sizes(Fl_Font, int*& sizep);
static void set_font(Fl_Font, const char*);
static void set_font(Fl_Font, Fl_Font);
/**
FLTK will open the display, and add every fonts on the server to the
face table. It will attempt to put "families" of faces together, so
that the normal one is first, followed by bold, italic, and bold
italic.
The optional argument is a string to describe the set of fonts to
add. Passing NULL will select only fonts that have the
ISO8859-1 character set (and are thus usable by normal text). Passing
"-*" will select all fonts with any encoding as long as they have
normal X font names with dashes in them. Passing "*" will list every
font that exists (on X this may produce some strange output). Other
values may be useful but are system dependent. With WIN32 NULL
selects fonts with ISO8859-1 encoding and non-NULL selects
all fonts.
The return value is how many faces are in the table after this is done.
*/
static Fl_Font set_fonts(const char* = 0); // platform dependent
/** @} */
/** \defgroup fl_drawings Drawing functions
FLTK global graphics and GUI drawing functions.
These functions are declared in <FL/fl_draw.H>,
and in <FL/x.H> for offscreen buffer-related ones.
@{ */
// <Hack to re-order the 'Drawing functions' group>
/** @} */
// labeltypes:
static void set_labeltype(Fl_Labeltype,Fl_Label_Draw_F*,Fl_Label_Measure_F*);
/** Sets the functions to call to draw and measure a specific labeltype. */
static void set_labeltype(Fl_Labeltype, Fl_Labeltype from); // is it defined ?
// boxtypes:
static Fl_Box_Draw_F *get_boxtype(Fl_Boxtype);
static void set_boxtype(Fl_Boxtype, Fl_Box_Draw_F*,uchar,uchar,uchar,uchar);
static void set_boxtype(Fl_Boxtype, Fl_Boxtype from);
static int box_dx(Fl_Boxtype);
static int box_dy(Fl_Boxtype);
static int box_dw(Fl_Boxtype);
static int box_dh(Fl_Boxtype);
static int draw_box_active();
// back compatibility:
/** \addtogroup fl_windows
@{ */
/** For back compatibility, sets the void Fl::fatal handler callback */
static void set_abort(Fl_Abort_Handler f) {fatal = f;}
static void (*atclose)(Fl_Window*,void*);
static void default_atclose(Fl_Window*,void*);
/** For back compatibility, sets the Fl::atclose handler callback. You
can now simply change the callback for the window instead.
\see Fl_Window::callback(Fl_Callback*) */
static void set_atclose(Fl_Atclose_Handler f) {atclose = f;}
/** @} */
/** \addtogroup fl_events
@{ */
/** Returns non-zero if the Shift key is pressed. */
static int event_shift() {return e_state&FL_SHIFT;}
/** Returns non-zero if the Control key is pressed. */
static int event_ctrl() {return e_state&FL_CTRL;}
/** Returns non-zero if the FL_COMMAND key is pressed, either FL_CTRL or on OSX FL_META. */
static int event_command() {return e_state&FL_COMMAND;}
/** Returns non-zero if the Alt key is pressed. */
static int event_alt() {return e_state&FL_ALT;}
/**
Returns the mouse buttons state bits; if non-zero, then at least one
button is pressed now. This function returns the button state at the
time of the event. During an FL_RELEASE event, the state
of the released button will be 0. To find out, which button
caused an FL_RELEASE event, you can use Fl::event_button() instead.
\return a bit mask value like { [FL_BUTTON1] | [FL_BUTTON2] | [FL_BUTTON3] }
*/
static int event_buttons() {return e_state&0x7f000000;}
/**
Returns non-zero if mouse button 1 is currently held down.
For more details, see Fl::event_buttons().
*/
static int event_button1() {return e_state&FL_BUTTON1;}
/**
Returns non-zero if button 2 is currently held down.
For more details, see Fl::event_buttons().
*/
static int event_button2() {return e_state&FL_BUTTON2;}
/**
Returns non-zero if button 3 is currently held down.
For more details, see Fl::event_buttons().
*/
static int event_button3() {return e_state&FL_BUTTON3;}
/** @} */
/**
Sets an idle callback.
\deprecated This method is obsolete - use the add_idle() method instead.
*/
static void set_idle(Fl_Old_Idle_Handler cb) {idle = cb;}
/** See grab(Fl_Window*) */
static void grab(Fl_Window& win) {grab(&win);}
/** Releases the current grabbed window, equals grab(0).
\deprecated Use Fl::grab(0) instead.
\see grab(Fl_Window*) */
static void release() {grab(0);}
// Visible focus methods...
/**
Gets or sets the visible keyboard focus on buttons and other
non-text widgets. The default mode is to enable keyboard focus
for all widgets.
*/
static void visible_focus(int v) { option(OPTION_VISIBLE_FOCUS, (v!=0)); }
/**
Gets or sets the visible keyboard focus on buttons and other
non-text widgets. The default mode is to enable keyboard focus
for all widgets.
*/
static int visible_focus() { return option(OPTION_VISIBLE_FOCUS); }
// Drag-n-drop text operation methods...
/**
Gets or sets whether drag and drop text operations are supported.
This specifically affects whether selected text can
be dragged from text fields or dragged within a text field as a
cut/paste shortcut.
*/
static void dnd_text_ops(int v) { option(OPTION_DND_TEXT, (v!=0)); }
/**
Gets or sets whether drag and drop text operations are
supported. This specifically affects whether selected text can
be dragged from text fields or dragged within a text field as a
cut/paste shortcut.
*/
static int dnd_text_ops() { return option(OPTION_DND_TEXT); }
/** \defgroup fl_multithread Multithreading support functions
fl multithreading support functions declared in <FL/Fl.H>
@{ */
// Multithreading support:
static int lock();
static void unlock();
static void awake(void* message = 0);
/** See void awake(void* message=0). */
static int awake(Fl_Awake_Handler cb, void* message = 0);
/**
The thread_message() method returns the last message
that was sent from a child by the awake() method.
See also: \ref advanced_multithreading
*/
static void* thread_message(); // platform dependent
/** @} */
/** \defgroup fl_del_widget Safe widget deletion support functions
These functions, declared in <FL/Fl.H>, support deletion of widgets inside callbacks.
Fl::delete_widget() should be called when deleting widgets
or complete widget trees (Fl_Group, Fl_Window, ...) inside
callbacks.
The other functions are intended for internal use. The preferred
way to use them is by using the helper class Fl_Widget_Tracker.
The following is to show how it works ...
There are three groups of related methods:
-# scheduled widget deletion
- Fl::delete_widget() schedules widgets for deletion
- Fl::do_widget_deletion() deletes all scheduled widgets
-# widget watch list ("smart pointers")
- Fl::watch_widget_pointer() adds a widget pointer to the watch list
- Fl::release_widget_pointer() removes a widget pointer from the watch list
- Fl::clear_widget_pointer() clears a widget pointer \e in the watch list
-# the class Fl_Widget_Tracker:
- the constructor calls Fl::watch_widget_pointer()
- the destructor calls Fl::release_widget_pointer()
- the access methods can be used to test, if a widget has been deleted
\see Fl_Widget_Tracker.
@{ */
// Widget deletion:
static void delete_widget(Fl_Widget *w);
static void do_widget_deletion();
static void watch_widget_pointer(Fl_Widget *&w);
static void release_widget_pointer(Fl_Widget *&w);
static void clear_widget_pointer(Fl_Widget const *w);
/** @} */
#ifdef FLTK_HAVE_CAIRO
/** \defgroup group_cairo Cairo support functions and classes
@{
*/
public:
// Cairo support API
static cairo_t * cairo_make_current(Fl_Window* w);
/** when FLTK_HAVE_CAIRO is defined and cairo_autolink_context() is true,
any current window dc is linked to a current context.
This is not the default, because it may not be necessary
to add cairo support to all fltk supported windows.
When you wish to associate a cairo context in this mode,
you need to call explicitly in your draw() overridden method,
FL::cairo_make_current(Fl_Window*). This will create a cairo context
but only for this Window.
Still in custom cairo application it is possible to handle
completely this process automatically by setting \p alink to true.
In this last case, you don't need anymore to call Fl::cairo_make_current().
You can use Fl::cairo_cc() to get the current cairo context anytime.
\note Only available when configure has the --enable-cairo option
*/
static void cairo_autolink_context(bool alink) {cairo_state_.autolink(alink);}
/**
Gets the current autolink mode for cairo support.
\retval false if no cairo context autolink is made for each window.
\retval true if any fltk window is attached a cairo context when it
is current. \see void cairo_autolink_context(bool alink)
\note Only available when configure has the --enable-cairo option
*/
static bool cairo_autolink_context() {return cairo_state_.autolink();}
/** Gets the current cairo context linked with a fltk window. */
static cairo_t * cairo_cc() { return cairo_state_.cc(); }
/** Sets the current cairo context to \p c.
Set \p own to true if you want fltk to handle this cc deletion.
\note Only available when configure has the --enable-cairo option
*/
static void cairo_cc(cairo_t * c, bool own=false){ cairo_state_.cc(c, own); }
private:
static cairo_t * cairo_make_current(void* gc);
static cairo_t * cairo_make_current(void* gc, int W, int H);
static Fl_Cairo_State cairo_state_;
public:
/** @} */
#endif // FLTK_HAVE_CAIRO
};
/**
This class should be used to control safe widget deletion.
You can use an Fl_Widget_Tracker object to watch another widget, if you
need to know, if this widget has been deleted during a callback.
This simplifies the use of the "safe widget deletion" methods
Fl::watch_widget_pointer() and Fl::release_widget_pointer() and
makes their use more reliable, because the destructor autmatically
releases the widget pointer from the widget watch list.
It is intended to be used as an automatic (local/stack) variable,
such that the automatic destructor is called when the object's
scope is left. This ensures that no stale widget pointers are
left in the widget watch list (see example below).
You can also create Fl_Widget_Tracker objects with \c new, but then it
is your responsibility to delete the object (and thus remove the
widget pointer from the watch list) when it is not needed any more.
Example:
\code
int MyClass::handle (int event) {
if (...) {
Fl_Widget_Tracker wp(this); // watch myself
do_callback(); // call the callback
if (wp.deleted()) return 1; // exit, if deleted
// Now we are sure that the widget has not been deleted.
// It is safe to access the widget
clear_changed(); // access the widget
}
}
\endcode
*/
class FL_EXPORT Fl_Widget_Tracker {
Fl_Widget* wp_;
public:
Fl_Widget_Tracker(Fl_Widget *wi);
~Fl_Widget_Tracker();
/**
Returns a pointer to the watched widget.
This pointer is \c NULL, if the widget has been deleted.
*/
Fl_Widget *widget() {return wp_;}
/**
Returns 1, if the watched widget has been deleted.
This is a convenience method. You can also use something like
<tt> if (wp.widget() == 0) // ...</tt>
where \p wp is an Fl_Widget_Tracker object.
*/
int deleted() {return wp_ == 0;}
/**
Returns 1, if the watched widget exists (has not been deleted).
This is a convenience method. You can also use something like
<tt> if (wp.widget() != 0) // ...</tt>
where \p wp is an Fl_Widget_Tracker object.
*/
int exists() {return wp_ != 0;}
};
/** \defgroup fl_unicode Unicode and UTF-8 functions
fl global Unicode and UTF-8 handling functions declared in <FL/fl_utf8.h>
@{ */
/** @} */
#endif // !Fl_H
//
// End of "$Id: Fl.H 10419 2014-10-30 16:05:22Z AlbrechtS $".
//
| [
"[email protected]"
] | |
e5400d167cb1e4bfeeed09e735c07b47c55c7f92 | 17353cfd2c984f2b57ab09dce5b793f34b051f19 | /src/plugProjectNishimuraU/TankState.cpp | 6b2ddf84c83bf4cff93d9ba79b57e402d2409fb1 | [] | no_license | mxygon/pikmin2 | 573df84b127b27f1c5db6be22680b63fd34565d5 | fa16b706d562d3f276406d8a87e01ad541515737 | refs/heads/main | 2023-09-02T06:56:56.216154 | 2021-11-12T09:34:26 | 2021-11-12T09:34:26 | 427,367,127 | 1 | 0 | null | 2021-11-12T13:19:54 | 2021-11-12T13:19:53 | null | UTF-8 | C++ | false | false | 45,562 | cpp | #include "types.h"
namespace Game {
/*
* --INFO--
* Address: 80273DE4
* Size: 000280
*/
void Tank::FSM::init(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
li r4, 0x7
stw r0, 0x14(r1)
stw r31, 0xC(r1)
mr r31, r3
bl -0x143598
li r3, 0x10
bl -0x24FF60
mr. r4, r3
beq- .loc_0x64
lis r3, 0x804B
lis r5, 0x804C
subi r0, r3, 0x65C
lis r3, 0x804C
stw r0, 0x0(r4)
li r7, 0
addi r6, r5, 0x69F4
subi r5, r2, 0x30F8
stw r7, 0x4(r4)
addi r0, r3, 0x69D0
stw r7, 0x8(r4)
stw r6, 0x0(r4)
stw r5, 0xC(r4)
stw r0, 0x0(r4)
.loc_0x64:
mr r3, r31
bl -0x143544
li r3, 0x10
bl -0x24FFB0
mr. r4, r3
beq- .loc_0xB8
lis r3, 0x804B
lis r5, 0x804C
subi r0, r3, 0x65C
lis r3, 0x804C
stw r0, 0x0(r4)
li r0, 0x1
li r7, 0
addi r6, r5, 0x69F4
stw r0, 0x4(r4)
subi r5, r2, 0x30F0
addi r0, r3, 0x69AC
stw r7, 0x8(r4)
stw r6, 0x0(r4)
stw r5, 0xC(r4)
stw r0, 0x0(r4)
.loc_0xB8:
mr r3, r31
bl -0x143598
li r3, 0x10
bl -0x250004
mr. r4, r3
beq- .loc_0x10C
lis r3, 0x804B
lis r5, 0x804C
subi r0, r3, 0x65C
lis r3, 0x804C
stw r0, 0x0(r4)
li r0, 0x2
li r7, 0
addi r6, r5, 0x69F4
stw r0, 0x4(r4)
subi r5, r2, 0x30E8
addi r0, r3, 0x6988
stw r7, 0x8(r4)
stw r6, 0x0(r4)
stw r5, 0xC(r4)
stw r0, 0x0(r4)
.loc_0x10C:
mr r3, r31
bl -0x1435EC
li r3, 0x10
bl -0x250058
mr. r4, r3
beq- .loc_0x164
lis r3, 0x804B
lis r6, 0x804C
subi r0, r3, 0x65C
lis r5, 0x8048
stw r0, 0x0(r4)
li r0, 0x3
lis r3, 0x804C
li r7, 0
stw r0, 0x4(r4)
addi r6, r6, 0x69F4
addi r5, r5, 0x6C68
addi r0, r3, 0x6964
stw r7, 0x8(r4)
stw r6, 0x0(r4)
stw r5, 0xC(r4)
stw r0, 0x0(r4)
.loc_0x164:
mr r3, r31
bl -0x143644
li r3, 0x10
bl -0x2500B0
mr. r4, r3
beq- .loc_0x1BC
lis r3, 0x804B
lis r6, 0x804C
subi r0, r3, 0x65C
lis r5, 0x8048
stw r0, 0x0(r4)
li r0, 0x4
lis r3, 0x804C
li r7, 0
stw r0, 0x4(r4)
addi r6, r6, 0x69F4
addi r5, r5, 0x6C74
addi r0, r3, 0x6940
stw r7, 0x8(r4)
stw r6, 0x0(r4)
stw r5, 0xC(r4)
stw r0, 0x0(r4)
.loc_0x1BC:
mr r3, r31
bl -0x14369C
li r3, 0x10
bl -0x250108
mr. r4, r3
beq- .loc_0x210
lis r3, 0x804B
lis r5, 0x804C
subi r0, r3, 0x65C
lis r3, 0x804C
stw r0, 0x0(r4)
li r0, 0x5
li r7, 0
addi r6, r5, 0x69F4
stw r0, 0x4(r4)
subi r5, r2, 0x30E0
addi r0, r3, 0x691C
stw r7, 0x8(r4)
stw r6, 0x0(r4)
stw r5, 0xC(r4)
stw r0, 0x0(r4)
.loc_0x210:
mr r3, r31
bl -0x1436F0
li r3, 0x10
bl -0x25015C
mr. r4, r3
beq- .loc_0x264
lis r3, 0x804B
lis r5, 0x804C
subi r0, r3, 0x65C
lis r3, 0x804C
stw r0, 0x0(r4)
li r0, 0x6
li r7, 0
addi r6, r5, 0x69F4
stw r0, 0x4(r4)
subi r5, r2, 0x30D8
addi r0, r3, 0x68F8
stw r7, 0x8(r4)
stw r6, 0x0(r4)
stw r5, 0xC(r4)
stw r0, 0x0(r4)
.loc_0x264:
mr r3, r31
bl -0x143744
lwz r0, 0x14(r1)
lwz r31, 0xC(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 80274064
* Size: 000070
*/
void Tank::StateDead::init(Game::EnemyBase*, Game::StateArg*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xC(r1)
mr r31, r4
mr r3, r31
lwz r12, 0x0(r31)
lwz r12, 0x30C(r12)
mtctr r12
bctrl
lwz r0, 0x1E0(r31)
mr r3, r31
lfs f0, -0x30D0(r2)
rlwinm r0,r0,0,26,24
stw r0, 0x1E0(r31)
stfs f0, 0x1D4(r31)
stfs f0, 0x1D8(r31)
stfs f0, 0x1DC(r31)
bl -0x16E98C
mr r3, r31
li r4, 0
li r5, 0
bl -0x16F0B8
lwz r0, 0x14(r1)
lwz r31, 0xC(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 802740D4
* Size: 000004
*/
void Tank::Obj::finishEffect() { }
/*
* --INFO--
* Address: 802740D8
* Size: 000044
*/
void Tank::StateDead::exec(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r3, 0x188(r4)
lbz r0, 0x24(r3)
cmplwi r0, 0
beq- .loc_0x34
lwz r0, 0x1C(r3)
cmplwi r0, 0x3E8
bne- .loc_0x34
mr r3, r4
li r4, 0
bl -0x139018
.loc_0x34:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 8027411C
* Size: 000004
*/
void Tank::StateDead::cleanup(Game::EnemyBase*) { }
/*
* --INFO--
* Address: 80274120
* Size: 000044
*/
void Tank::StateWait::init(Game::EnemyBase*, Game::StateArg*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
lfs f0, -0x30D0(r2)
mr r3, r4
stw r0, 0x14(r1)
li r0, 0
li r5, 0
stfs f0, 0x1D4(r4)
li r4, 0x5
stfs f0, 0x1D8(r3)
stfs f0, 0x1DC(r3)
stw r0, 0x230(r3)
bl -0x16F14C
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 80274164
* Size: 000258
*/
void Tank::StateWait::exec(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x30(r1)
mflr r0
stw r0, 0x34(r1)
stfd f31, 0x20(r1)
psq_st f31,0x28(r1),0,0
stw r31, 0x1C(r1)
stw r30, 0x18(r1)
mr r31, r4
mr r30, r3
mr r3, r31
bl 0x2A5C
lfs f2, 0x200(r31)
fmr f31, f1
lfs f0, -0x30D0(r2)
fcmpo cr0, f2, f0
cror 2, 0, 0x2
bne- .loc_0x68
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x238
.loc_0x68:
mr r3, r31
li r4, 0
bl -0x15FB7C
rlwinm. r0,r3,0,24,31
bne- .loc_0x90
mr r3, r31
li r4, 0
bl 0x2318
rlwinm. r0,r3,0,24,31
beq- .loc_0x9C
.loc_0x90:
lfs f1, -0x30CC(r2)
mr r3, r31
bl -0x16CE6C
.loc_0x9C:
lwz r3, 0x188(r31)
lbz r0, 0x24(r3)
cmplwi r0, 0
beq- .loc_0x238
lwz r0, 0x1C(r3)
cmplwi r0, 0x3E8
bne- .loc_0x238
lfs f1, 0x200(r31)
lfs f0, -0x30D0(r2)
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0xF0
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x238
.loc_0xF0:
mr r3, r31
li r4, 0
bl -0x15FC04
rlwinm. r0,r3,0,24,31
beq- .loc_0x128
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x6
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x238
.loc_0x128:
mr r3, r31
li r4, 0
bl 0x226C
rlwinm. r0,r3,0,24,31
beq- .loc_0x160
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x5
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x238
.loc_0x160:
lwz r5, 0xC0(r31)
fmr f1, f31
mr r3, r31
li r4, 0
lfs f2, 0x3D4(r5)
li r5, 0
li r6, 0
bl -0x161290
cmplwi r3, 0
beq- .loc_0x1B8
stw r3, 0x230(r31)
mr r3, r30
lfs f0, -0x30D0(r2)
mr r4, r31
li r5, 0x4
li r6, 0
stfs f0, 0x2EC(r31)
lwz r12, 0x0(r30)
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x238
.loc_0x1B8:
bl -0x1AAD7C
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0xC(r1)
lfd f3, -0x30B8(r2)
stw r0, 0x8(r1)
lfs f2, -0x30C8(r2)
lfd f0, 0x8(r1)
lfs f1, -0x30C4(r2)
fsubs f3, f0, f3
lfs f0, -0x30C0(r2)
fmuls f2, f2, f3
fdivs f1, f2, f1
fcmpo cr0, f1, f0
bge- .loc_0x218
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x1
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x238
.loc_0x218:
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x3
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
.loc_0x238:
psq_l f31,0x28(r1),0,0
lwz r0, 0x34(r1)
lfd f31, 0x20(r1)
lwz r31, 0x1C(r1)
lwz r30, 0x18(r1)
mtlr r0
addi r1, r1, 0x30
blr
*/
}
/*
* --INFO--
* Address: 802743BC
* Size: 000028
*/
void Tank::StateWait::cleanup(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
lfs f1, -0x30B0(r2)
mr r3, r4
stw r0, 0x14(r1)
bl -0x16D040
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 802743E4
* Size: 000054
*/
void Tank::StateMove::init(Game::EnemyBase*, Game::StateArg*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
lfs f0, -0x30D0(r2)
li r5, 0
stw r0, 0x14(r1)
li r0, 0
stw r31, 0xC(r1)
mr r31, r4
mr r3, r31
stfs f0, 0x2F0(r4)
li r4, 0x1
stw r0, 0x230(r31)
bl -0x16F410
lfs f1, -0x30CC(r2)
mr r3, r31
bl -0x16D090
lwz r0, 0x14(r1)
lwz r31, 0xC(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 80274438
* Size: 00056C
*/
void Tank::StateMove::exec(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x130(r1)
mflr r0
stw r0, 0x134(r1)
stfd f31, 0x120(r1)
psq_st f31,0x128(r1),0,0
stfd f30, 0x110(r1)
psq_st f30,0x118(r1),0,0
stfd f29, 0x100(r1)
psq_st f29,0x108(r1),0,0
stfd f28, 0xF0(r1)
psq_st f28,0xF8(r1),0,0
stfd f27, 0xE0(r1)
psq_st f27,0xE8(r1),0,0
stfd f26, 0xD0(r1)
psq_st f26,0xD8(r1),0,0
stfd f25, 0xC0(r1)
psq_st f25,0xC8(r1),0,0
stfd f24, 0xB0(r1)
psq_st f24,0xB8(r1),0,0
stw r31, 0xAC(r1)
stw r30, 0xA8(r1)
stw r29, 0xA4(r1)
mr r31, r4
mr r30, r3
mr r3, r31
bl 0x274C
lwz r12, 0x0(r31)
fmr f28, f1
mr r4, r31
addi r3, r1, 0x80
lwz r12, 0x8(r12)
mtctr r12
bctrl
lfs f0, 0x88(r1)
lfs f5, 0x300(r31)
lfs f2, 0x2F8(r31)
fsubs f1, f0, f5
lfs f0, 0x80(r1)
lfs f4, 0x2FC(r31)
fsubs f3, f0, f2
lfs f0, -0x30AC(r2)
fmuls f1, f1, f1
stfs f2, 0x8C(r1)
fmadds f1, f3, f3, f1
stfs f4, 0x90(r1)
stfs f5, 0x94(r1)
fcmpo cr0, f1, f0
ble- .loc_0xF0
lfs f1, 0x2F0(r31)
lfs f0, -0x30A8(r2)
fcmpo cr0, f1, f0
bge- .loc_0xF0
lwz r5, 0xC0(r31)
mr r3, r31
addi r4, r1, 0x8C
lfs f1, 0x2E4(r5)
lfs f2, 0x30C(r5)
lfs f3, 0x334(r5)
bl -0x15EF44
b .loc_0x108
.loc_0xF0:
lfs f0, -0x30D0(r2)
mr r3, r31
stfs f0, 0x1D4(r31)
stfs f0, 0x1D8(r31)
stfs f0, 0x1DC(r31)
bl -0x16F29C
.loc_0x108:
lfs f1, 0x200(r31)
lfs f0, -0x30D0(r2)
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x140
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x510
.loc_0x140:
mr r3, r31
li r4, 0
bl -0x15FF28
rlwinm. r0,r3,0,24,31
bne- .loc_0x168
mr r3, r31
li r4, 0
bl 0x1F6C
rlwinm. r0,r3,0,24,31
beq- .loc_0x184
.loc_0x168:
lfs f0, -0x30D0(r2)
mr r3, r31
stfs f0, 0x1D4(r31)
stfs f0, 0x1D8(r31)
stfs f0, 0x1DC(r31)
bl -0x16F314
b .loc_0x1CC
.loc_0x184:
lwz r5, 0xC0(r31)
fmr f1, f28
mr r3, r31
li r4, 0
lfs f2, 0x3D4(r5)
li r5, 0
li r6, 0
bl -0x161588
cmplwi r3, 0
beq- .loc_0x1CC
stw r3, 0x230(r31)
mr r3, r31
lfs f0, -0x30D0(r2)
stfs f0, 0x2EC(r31)
stfs f0, 0x1D4(r31)
stfs f0, 0x1D8(r31)
stfs f0, 0x1DC(r31)
bl -0x16F360
.loc_0x1CC:
lwz r3, -0x6514(r13)
lfs f1, 0x2F0(r31)
lfs f0, 0x54(r3)
fadds f0, f1, f0
stfs f0, 0x2F0(r31)
lwz r3, 0x188(r31)
lbz r0, 0x24(r3)
cmplwi r0, 0
beq- .loc_0x510
lwz r0, 0x1C(r3)
cmplwi r0, 0x3E8
bne- .loc_0x510
lfs f1, 0x200(r31)
lfs f0, -0x30D0(r2)
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x234
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x510
.loc_0x234:
mr r3, r31
li r4, 0
bl -0x16001C
rlwinm. r0,r3,0,24,31
beq- .loc_0x26C
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x6
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x510
.loc_0x26C:
mr r3, r31
li r4, 0
bl 0x1E54
rlwinm. r0,r3,0,24,31
beq- .loc_0x2A4
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x5
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x510
.loc_0x2A4:
lwz r29, 0x230(r31)
cmplwi r29, 0
beq- .loc_0x4F0
mr r4, r29
lwz r5, 0xC0(r31)
lwz r12, 0x0(r29)
addi r3, r1, 0x20
lfs f29, 0x3FC(r5)
lwz r12, 0x8(r12)
lfs f30, 0x3D4(r5)
lfs f31, 0x3AC(r5)
mtctr r12
bctrl
mr r4, r31
lfs f2, 0x20(r1)
lwz r12, 0x0(r31)
addi r3, r1, 0x2C
lfs f1, 0x24(r1)
lfs f0, 0x28(r1)
lwz r12, 0x8(r12)
stfs f2, 0x8(r1)
stfs f1, 0xC(r1)
stfs f0, 0x10(r1)
mtctr r12
bctrl
lfs f5, 0x2C(r1)
lis r3, 0x8051
lfs f3, 0x34(r1)
subi r3, r3, 0x2E20
lfs f1, 0x8(r1)
lfs f0, 0x10(r1)
lfs f4, 0x30(r1)
fsubs f1, f1, f5
fsubs f2, f0, f3
stfs f5, 0x14(r1)
stfs f4, 0x18(r1)
stfs f3, 0x1C(r1)
bl -0x23F668
bl 0x19D45C
lwz r12, 0x0(r31)
fmr f24, f1
mr r3, r31
lwz r12, 0x64(r12)
mtctr r12
bctrl
fmr f2, f1
fmr f1, f24
bl 0x19D464
mr r4, r31
fmr f26, f1
lwz r12, 0x0(r31)
addi r3, r1, 0x44
lwz r12, 0x8(r12)
mtctr r12
bctrl
mr r4, r29
addi r3, r1, 0x38
lwz r12, 0x0(r29)
lfs f27, 0x44(r1)
lwz r12, 0x8(r12)
mtctr r12
bctrl
mr r4, r31
lfs f0, 0x38(r1)
lwz r12, 0x0(r31)
addi r3, r1, 0x5C
fsubs f24, f0, f27
lwz r12, 0x8(r12)
mtctr r12
bctrl
mr r4, r29
addi r3, r1, 0x50
lwz r12, 0x0(r29)
lfs f27, 0x60(r1)
lwz r12, 0x8(r12)
mtctr r12
bctrl
mr r4, r31
lfs f0, 0x54(r1)
lwz r12, 0x0(r31)
addi r3, r1, 0x74
fsubs f25, f0, f27
lwz r12, 0x8(r12)
mtctr r12
bctrl
mr r4, r29
addi r3, r1, 0x68
lwz r12, 0x0(r29)
lfs f27, 0x7C(r1)
lwz r12, 0x8(r12)
mtctr r12
bctrl
lfs f0, 0x70(r1)
fmuls f1, f31, f31
fmuls f2, f30, f30
li r3, 0x1
fsubs f0, f0, f27
li r4, 0
fmuls f0, f0, f0
fmadds f0, f24, f24, f0
fcmpo cr0, f0, f1
ble- .loc_0x468
fcmpo cr0, f0, f2
mr r0, r4
ble- .loc_0x45C
fabs f0, f25
frsp f0, f0
fcmpo cr0, f0, f29
bge- .loc_0x45C
mr r0, r3
.loc_0x45C:
rlwinm. r0,r0,0,24,31
beq- .loc_0x468
li r4, 0x1
.loc_0x468:
rlwinm. r0,r4,0,24,31
bne- .loc_0x4A0
lfs f0, -0x30A0(r2)
fabs f2, f26
lfs f1, -0x30A4(r2)
fmuls f0, f0, f28
frsp f2, f2
fmuls f0, f1, f0
fcmpo cr0, f2, f0
cror 2, 0, 0x2
mfcr r0
rlwinm. r0,r0,3,31,31
beq- .loc_0x4A0
li r3, 0
.loc_0x4A0:
rlwinm. r0,r3,0,24,31
beq- .loc_0x4CC
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x1
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x510
.loc_0x4CC:
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x4
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x510
.loc_0x4F0:
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x1
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
.loc_0x510:
psq_l f31,0x128(r1),0,0
lfd f31, 0x120(r1)
psq_l f30,0x118(r1),0,0
lfd f30, 0x110(r1)
psq_l f29,0x108(r1),0,0
lfd f29, 0x100(r1)
psq_l f28,0xF8(r1),0,0
lfd f28, 0xF0(r1)
psq_l f27,0xE8(r1),0,0
lfd f27, 0xE0(r1)
psq_l f26,0xD8(r1),0,0
lfd f26, 0xD0(r1)
psq_l f25,0xC8(r1),0,0
lfd f25, 0xC0(r1)
psq_l f24,0xB8(r1),0,0
lfd f24, 0xB0(r1)
lwz r31, 0xAC(r1)
lwz r30, 0xA8(r1)
lwz r0, 0x134(r1)
lwz r29, 0xA4(r1)
mtlr r0
addi r1, r1, 0x130
blr
*/
}
/*
* --INFO--
* Address: 802749A4
* Size: 000028
*/
void Tank::StateMove::cleanup(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
lfs f1, -0x30B0(r2)
mr r3, r4
stw r0, 0x14(r1)
bl -0x16D628
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 802749CC
* Size: 000104
*/
void Tank::StateMoveTurn::init(Game::EnemyBase*, Game::StateArg*)
{
/*
.loc_0x0:
stwu r1, -0x20(r1)
mflr r0
lfs f1, -0x309C(r2)
mr r3, r4
stw r0, 0x24(r1)
lfs f0, -0x30D0(r2)
lfs f2, 0x2F4(r4)
fadds f1, f2, f1
stfs f1, 0x2F4(r4)
lfs f5, 0x2F4(r4)
lfs f6, 0x198(r4)
fmr f1, f5
lfs f7, 0x19C(r4)
fcmpo cr0, f5, f0
lfs f4, 0x1A0(r4)
lwz r6, 0xC0(r4)
bge- .loc_0x48
fneg f1, f5
.loc_0x48:
lfs f2, -0x3098(r2)
lis r4, 0x8050
lfs f0, -0x30D0(r2)
addi r5, r4, 0x71A0
fmuls f1, f1, f2
lfs f3, 0x35C(r6)
fcmpo cr0, f5, f0
fctiwz f0, f1
stfd f0, 0x8(r1)
lwz r0, 0xC(r1)
rlwinm r0,r0,3,18,28
add r4, r5, r0
lfs f0, 0x4(r4)
fmadds f4, f3, f0, f4
bge- .loc_0xA8
lfs f0, -0x3094(r2)
fmuls f0, f5, f0
fctiwz f0, f0
stfd f0, 0x10(r1)
lwz r0, 0x14(r1)
rlwinm r0,r0,3,18,28
lfsx f0, r5, r0
fneg f0, f0
b .loc_0xC0
.loc_0xA8:
fmuls f0, f5, f2
fctiwz f0, f0
stfd f0, 0x18(r1)
lwz r0, 0x1C(r1)
rlwinm r0,r0,3,18,28
lfsx f0, r5, r0
.loc_0xC0:
fmadds f1, f3, f0, f6
li r0, 0
lfs f0, -0x30D0(r2)
li r4, 0x4
li r5, 0
stfs f1, 0x2F8(r3)
stfs f7, 0x2FC(r3)
stfs f4, 0x300(r3)
stw r0, 0x230(r3)
stfs f0, 0x1D4(r3)
stfs f0, 0x1D8(r3)
stfs f0, 0x1DC(r3)
bl -0x16FAB8
lwz r0, 0x24(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 80274AD0
* Size: 000364
*/
void Tank::StateMoveTurn::exec(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x70(r1)
mflr r0
stw r0, 0x74(r1)
stfd f31, 0x60(r1)
psq_st f31,0x68(r1),0,0
stfd f30, 0x50(r1)
psq_st f30,0x58(r1),0,0
stfd f29, 0x40(r1)
psq_st f29,0x48(r1),0,0
stfd f28, 0x30(r1)
psq_st f28,0x38(r1),0,0
stfd f27, 0x20(r1)
psq_st f27,0x28(r1),0,0
stw r31, 0x1C(r1)
stw r30, 0x18(r1)
mr r31, r4
mr r30, r3
mr r3, r31
bl 0x20D0
lwz r12, 0x0(r31)
fmr f31, f1
lwz r5, 0xC0(r31)
mr r4, r31
lwz r12, 0x8(r12)
addi r3, r1, 0x8
lfs f30, 0x2F8(r31)
lfs f27, 0x300(r31)
lfs f28, 0x334(r5)
lfs f29, 0x30C(r5)
mtctr r12
bctrl
lfs f1, 0x8(r1)
lis r3, 0x8051
lfs f0, 0x10(r1)
subi r3, r3, 0x2E20
fsubs f1, f30, f1
fsubs f2, f27, f0
bl -0x23FA5C
bl 0x19D068
lwz r12, 0x0(r31)
fmr f30, f1
mr r3, r31
lwz r12, 0x64(r12)
mtctr r12
bctrl
fmr f2, f1
fmr f1, f30
bl 0x19D070
fmr f30, f1
lfs f0, -0x30A0(r2)
lfs f1, -0x30A4(r2)
fmuls f0, f0, f28
fmuls f28, f30, f29
fmuls f1, f1, f0
fabs f0, f28
frsp f0, f0
fcmpo cr0, f0, f1
ble- .loc_0x100
lfs f0, -0x30D0(r2)
fcmpo cr0, f28, f0
ble- .loc_0xFC
fmr f28, f1
b .loc_0x100
.loc_0xFC:
fneg f28, f1
.loc_0x100:
mr r3, r31
lwz r12, 0x0(r31)
lwz r12, 0x64(r12)
mtctr r12
bctrl
fadds f1, f28, f1
bl 0x19CFE8
stfs f1, 0x1FC(r31)
lfs f0, -0x30D0(r2)
lfs f1, 0x1FC(r31)
stfs f1, 0x1A8(r31)
lfs f1, 0x200(r31)
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x160
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x324
.loc_0x160:
mr r3, r31
li r4, 0
bl -0x1605E0
rlwinm. r0,r3,0,24,31
bne- .loc_0x1A0
mr r3, r31
li r4, 0
bl 0x18B4
rlwinm. r0,r3,0,24,31
bne- .loc_0x1A0
fabs f1, f30
lfs f0, -0x3090(r2)
frsp f1, f1
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x1B8
.loc_0x1A0:
mr r3, r31
bl -0x16F9D4
lfs f1, -0x30CC(r2)
mr r3, r31
bl -0x16D8F0
b .loc_0x1E8
.loc_0x1B8:
lwz r5, 0xC0(r31)
fmr f1, f31
mr r3, r31
li r4, 0
lfs f2, 0x3D4(r5)
li r5, 0
li r6, 0
bl -0x161C54
cmplwi r3, 0
beq- .loc_0x1E8
mr r3, r31
bl -0x16FA14
.loc_0x1E8:
lwz r3, 0x188(r31)
lbz r0, 0x24(r3)
cmplwi r0, 0
beq- .loc_0x324
lwz r0, 0x1C(r3)
cmplwi r0, 0x3E8
bne- .loc_0x324
lfs f1, 0x200(r31)
lfs f0, -0x30D0(r2)
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x23C
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x324
.loc_0x23C:
mr r3, r31
li r4, 0
bl -0x1606BC
rlwinm. r0,r3,0,24,31
beq- .loc_0x274
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x6
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x324
.loc_0x274:
mr r3, r31
li r4, 0
bl 0x17B4
rlwinm. r0,r3,0,24,31
beq- .loc_0x2AC
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x5
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x324
.loc_0x2AC:
lwz r5, 0xC0(r31)
fmr f1, f31
mr r3, r31
li r4, 0
lfs f2, 0x3D4(r5)
li r5, 0
li r6, 0
bl -0x161D48
cmplwi r3, 0
beq- .loc_0x304
stw r3, 0x230(r31)
mr r3, r30
lfs f0, -0x30D0(r2)
mr r4, r31
li r5, 0x4
li r6, 0
stfs f0, 0x2EC(r31)
lwz r12, 0x0(r30)
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x324
.loc_0x304:
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x2
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
.loc_0x324:
psq_l f31,0x68(r1),0,0
lfd f31, 0x60(r1)
psq_l f30,0x58(r1),0,0
lfd f30, 0x50(r1)
psq_l f29,0x48(r1),0,0
lfd f29, 0x40(r1)
psq_l f28,0x38(r1),0,0
lfd f28, 0x30(r1)
psq_l f27,0x28(r1),0,0
lfd f27, 0x20(r1)
lwz r31, 0x1C(r1)
lwz r0, 0x74(r1)
lwz r30, 0x18(r1)
mtlr r0
addi r1, r1, 0x70
blr
*/
}
/*
* --INFO--
* Address: 80274E34
* Size: 000028
*/
void Tank::StateMoveTurn::cleanup(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
lfs f1, -0x30B0(r2)
mr r3, r4
stw r0, 0x14(r1)
bl -0x16DAB8
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 80274E5C
* Size: 000050
*/
void Tank::StateChaseTurn::init(Game::EnemyBase*, Game::StateArg*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
lfs f0, -0x30D0(r2)
stw r0, 0x14(r1)
stw r31, 0xC(r1)
mr r31, r4
mr r3, r31
stfs f0, 0x1D4(r4)
stfs f0, 0x1D8(r4)
stfs f0, 0x1DC(r4)
bl -0x1734B8
mr r3, r31
li r4, 0x4
li r5, 0
bl -0x16FE90
lwz r0, 0x14(r1)
lwz r31, 0xC(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 80274EAC
* Size: 0005F4
*/
void Tank::StateChaseTurn::exec(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x110(r1)
mflr r0
stw r0, 0x114(r1)
stfd f31, 0x100(r1)
psq_st f31,0x108(r1),0,0
stfd f30, 0xF0(r1)
psq_st f30,0xF8(r1),0,0
stfd f29, 0xE0(r1)
psq_st f29,0xE8(r1),0,0
stfd f28, 0xD0(r1)
psq_st f28,0xD8(r1),0,0
stfd f27, 0xC0(r1)
psq_st f27,0xC8(r1),0,0
stfd f26, 0xB0(r1)
psq_st f26,0xB8(r1),0,0
stfd f25, 0xA0(r1)
psq_st f25,0xA8(r1),0,0
stfd f24, 0x90(r1)
psq_st f24,0x98(r1),0,0
stw r31, 0x8C(r1)
stw r30, 0x88(r1)
stw r29, 0x84(r1)
mr r31, r4
mr r30, r3
mr r3, r31
bl 0x1CD8
lfs f2, 0x200(r31)
fmr f31, f1
lfs f0, -0x30D0(r2)
fcmpo cr0, f2, f0
cror 2, 0, 0x2
bne- .loc_0xA4
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x598
.loc_0xA4:
mr r3, r31
li r4, 0
bl -0x160900
rlwinm. r0,r3,0,24,31
bne- .loc_0xCC
mr r3, r31
li r4, 0
bl 0x1594
rlwinm. r0,r3,0,24,31
beq- .loc_0xE0
.loc_0xCC:
mr r3, r31
bl -0x16FCDC
lfs f1, -0x30CC(r2)
mr r3, r31
bl -0x16DBF8
.loc_0xE0:
lwz r29, 0x230(r31)
cmplwi r29, 0
beq- .loc_0x364
lfs f0, -0x30D0(r2)
mr r4, r29
addi r3, r1, 0x14
stfs f0, 0x2EC(r31)
lwz r12, 0x0(r29)
lwz r5, 0xC0(r31)
lwz r12, 0x8(r12)
lfs f28, 0x334(r5)
lfs f30, 0x30C(r5)
mtctr r12
bctrl
mr r4, r31
addi r3, r1, 0x20
lwz r12, 0x0(r31)
lfs f24, 0x14(r1)
lwz r12, 0x8(r12)
lfs f25, 0x1C(r1)
mtctr r12
bctrl
lfs f1, 0x20(r1)
lis r3, 0x8051
lfs f0, 0x28(r1)
subi r3, r3, 0x2E20
fsubs f1, f24, f1
fsubs f2, f25, f0
bl -0x23FEF4
bl 0x19CBD0
lwz r12, 0x0(r31)
fmr f24, f1
mr r3, r31
lwz r12, 0x64(r12)
mtctr r12
bctrl
fmr f2, f1
fmr f1, f24
bl 0x19CBD8
fmr f29, f1
lfs f0, -0x30A0(r2)
lfs f1, -0x30A4(r2)
fmuls f0, f0, f28
fmuls f24, f29, f30
fmuls f1, f1, f0
fabs f0, f24
frsp f0, f0
fcmpo cr0, f0, f1
ble- .loc_0x1BC
lfs f0, -0x30D0(r2)
fcmpo cr0, f24, f0
ble- .loc_0x1B8
fmr f24, f1
b .loc_0x1BC
.loc_0x1B8:
fneg f24, f1
.loc_0x1BC:
mr r3, r31
lwz r12, 0x0(r31)
lwz r12, 0x64(r12)
mtctr r12
bctrl
fadds f1, f24, f1
bl 0x19CB50
stfs f1, 0x1FC(r31)
mr r3, r29
lfs f0, 0x1FC(r31)
stfs f0, 0x1A8(r31)
lwz r12, 0x0(r29)
lwz r12, 0xA8(r12)
mtctr r12
bctrl
rlwinm. r0,r3,0,24,31
beq- .loc_0x350
mr r4, r31
lwz r5, 0xC0(r31)
lwz r12, 0x0(r31)
addi r3, r1, 0x38
lfs f24, 0x3FC(r5)
lwz r12, 0x8(r12)
lfs f25, 0x3D4(r5)
lfs f26, 0x3AC(r5)
mtctr r12
bctrl
mr r4, r29
addi r3, r1, 0x2C
lwz r12, 0x0(r29)
lfs f30, 0x38(r1)
lwz r12, 0x8(r12)
mtctr r12
bctrl
mr r4, r31
lfs f0, 0x2C(r1)
lwz r12, 0x0(r31)
addi r3, r1, 0x50
fsubs f27, f0, f30
lwz r12, 0x8(r12)
mtctr r12
bctrl
mr r4, r29
addi r3, r1, 0x44
lwz r12, 0x0(r29)
lfs f30, 0x54(r1)
lwz r12, 0x8(r12)
mtctr r12
bctrl
mr r4, r31
lfs f0, 0x48(r1)
lwz r12, 0x0(r31)
addi r3, r1, 0x68
fsubs f28, f0, f30
lwz r12, 0x8(r12)
mtctr r12
bctrl
mr r4, r29
addi r3, r1, 0x5C
lwz r12, 0x0(r29)
lfs f30, 0x70(r1)
lwz r12, 0x8(r12)
mtctr r12
bctrl
lfs f0, 0x64(r1)
fmuls f26, f26, f26
fmuls f25, f25, f25
li r3, 0x1
fsubs f0, f0, f30
li r4, 0
fmuls f0, f0, f0
fmadds f0, f27, f27, f0
fcmpo cr0, f0, f26
ble- .loc_0x310
fcmpo cr0, f0, f25
mr r0, r4
ble- .loc_0x304
fabs f0, f28
frsp f0, f0
fcmpo cr0, f0, f24
bge- .loc_0x304
mr r0, r3
.loc_0x304:
rlwinm. r0,r0,0,24,31
beq- .loc_0x310
li r4, 0x1
.loc_0x310:
rlwinm. r0,r4,0,24,31
bne- .loc_0x348
lfs f0, -0x30A0(r2)
fabs f2, f29
lfs f1, -0x30A4(r2)
fmuls f0, f0, f31
frsp f2, f2
fmuls f0, f1, f0
fcmpo cr0, f2, f0
cror 2, 0, 0x2
mfcr r0
rlwinm. r0,r0,3,31,31
beq- .loc_0x348
li r3, 0
.loc_0x348:
rlwinm. r0,r3,0,24,31
beq- .loc_0x45C
.loc_0x350:
li r0, 0
mr r3, r31
stw r0, 0x230(r31)
bl -0x16FF68
b .loc_0x45C
.loc_0x364:
mr r4, r31
lwz r5, 0xC0(r31)
lwz r12, 0x0(r31)
addi r3, r1, 0x8
lfs f26, 0x2F8(r31)
lwz r12, 0x8(r12)
lfs f27, 0x300(r31)
lfs f25, 0x334(r5)
lfs f24, 0x30C(r5)
mtctr r12
bctrl
lfs f1, 0x8(r1)
lis r3, 0x8051
lfs f0, 0x10(r1)
subi r3, r3, 0x2E20
fsubs f1, f26, f1
fsubs f2, f27, f0
bl -0x24014C
bl 0x19C978
lwz r12, 0x0(r31)
fmr f26, f1
mr r3, r31
lwz r12, 0x64(r12)
mtctr r12
bctrl
fmr f2, f1
fmr f1, f26
bl 0x19C980
fmr f30, f1
lfs f0, -0x30A0(r2)
lfs f1, -0x30A4(r2)
fmuls f0, f0, f25
fmuls f24, f30, f24
fmuls f1, f1, f0
fabs f0, f24
frsp f0, f0
fcmpo cr0, f0, f1
ble- .loc_0x414
lfs f0, -0x30D0(r2)
fcmpo cr0, f24, f0
ble- .loc_0x410
fmr f24, f1
b .loc_0x414
.loc_0x410:
fneg f24, f1
.loc_0x414:
mr r3, r31
lwz r12, 0x0(r31)
lwz r12, 0x64(r12)
mtctr r12
bctrl
fadds f1, f24, f1
bl 0x19C8F8
fabs f3, f30
stfs f1, 0x1FC(r31)
lfs f0, -0x3090(r2)
lfs f2, 0x1FC(r31)
frsp f1, f3
stfs f2, 0x1A8(r31)
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x45C
mr r3, r31
bl -0x170064
.loc_0x45C:
lwz r3, 0x188(r31)
lbz r0, 0x24(r3)
cmplwi r0, 0
beq- .loc_0x598
lwz r0, 0x1C(r3)
cmplwi r0, 0x3E8
bne- .loc_0x598
lfs f1, 0x200(r31)
lfs f0, -0x30D0(r2)
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x4B0
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x598
.loc_0x4B0:
mr r3, r31
li r4, 0
bl -0x160D0C
rlwinm. r0,r3,0,24,31
beq- .loc_0x4E8
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x6
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x598
.loc_0x4E8:
mr r3, r31
li r4, 0
bl 0x1164
rlwinm. r0,r3,0,24,31
beq- .loc_0x520
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x5
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x598
.loc_0x520:
lwz r5, 0xC0(r31)
fmr f1, f31
mr r3, r31
li r4, 0
lfs f2, 0x3D4(r5)
li r5, 0
li r6, 0
bl -0x162398
cmplwi r3, 0
beq- .loc_0x578
stw r3, 0x230(r31)
mr r3, r30
lfs f0, -0x30D0(r2)
mr r4, r31
li r5, 0x4
li r6, 0
stfs f0, 0x2EC(r31)
lwz r12, 0x0(r30)
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x598
.loc_0x578:
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x1
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
.loc_0x598:
psq_l f31,0x108(r1),0,0
lfd f31, 0x100(r1)
psq_l f30,0xF8(r1),0,0
lfd f30, 0xF0(r1)
psq_l f29,0xE8(r1),0,0
lfd f29, 0xE0(r1)
psq_l f28,0xD8(r1),0,0
lfd f28, 0xD0(r1)
psq_l f27,0xC8(r1),0,0
lfd f27, 0xC0(r1)
psq_l f26,0xB8(r1),0,0
lfd f26, 0xB0(r1)
psq_l f25,0xA8(r1),0,0
lfd f25, 0xA0(r1)
psq_l f24,0x98(r1),0,0
lfd f24, 0x90(r1)
lwz r31, 0x8C(r1)
lwz r30, 0x88(r1)
lwz r0, 0x114(r1)
lwz r29, 0x84(r1)
mtlr r0
addi r1, r1, 0x110
blr
*/
}
/*
* --INFO--
* Address: 802754A0
* Size: 00003C
*/
void Tank::StateChaseTurn::cleanup(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xC(r1)
mr r31, r4
mr r3, r31
bl -0x173B3C
lfs f1, -0x30B0(r2)
mr r3, r31
bl -0x16E134
lwz r0, 0x14(r1)
lwz r31, 0xC(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 802754DC
* Size: 000084
*/
void Tank::StateAttack::init(Game::EnemyBase*, Game::StateArg*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
li r5, 0
lfs f0, -0x30D0(r2)
stw r0, 0x14(r1)
stw r31, 0xC(r1)
mr r31, r4
mr r3, r31
stb r5, 0x304(r4)
stfs f0, 0x2E4(r4)
stfs f0, 0x2EC(r4)
lwz r0, 0x1E0(r4)
rlwinm r0,r0,0,26,24
stw r0, 0x1E0(r4)
stw r5, 0x230(r4)
stfs f0, 0x1D4(r4)
stfs f0, 0x1D8(r4)
stfs f0, 0x1DC(r4)
bl -0x173B58
mr r3, r31
li r4, 0x3
li r5, 0
bl -0x170530
mr r3, r31
lwz r12, 0x0(r31)
lwz r12, 0x320(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
lwz r31, 0xC(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 80275560
* Size: 000004
*/
void Tank::Obj::createChargeSE() { }
/*
* --INFO--
* Address: 80275564
* Size: 0001E0
*/
void Tank::StateAttack::exec(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
stfd f31, 0x10(r1)
psq_st f31,0x18(r1),0,0
stw r31, 0xC(r1)
stw r30, 0x8(r1)
mr r31, r4
mr r30, r3
mr r3, r31
bl 0x165C
lfs f2, 0x200(r31)
fmr f31, f1
lfs f0, -0x30D0(r2)
fcmpo cr0, f2, f0
cror 2, 0, 0x2
bne- .loc_0x68
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x1C0
.loc_0x68:
lbz r0, 0x304(r31)
cmplwi r0, 0
beq- .loc_0x94
mr r3, r31
li r4, 0x1
bl 0xF20
mr r3, r31
lwz r12, 0x0(r31)
lwz r12, 0x324(r12)
mtctr r12
bctrl
.loc_0x94:
lwz r3, 0x188(r31)
lbz r0, 0x24(r3)
cmplwi r0, 0
beq- .loc_0x1C0
lwz r0, 0x1C(r3)
cmplwi r0, 0x2
bne- .loc_0xD0
li r0, 0x1
mr r3, r31
stb r0, 0x304(r31)
lwz r12, 0x0(r31)
lwz r12, 0x304(r12)
mtctr r12
bctrl
b .loc_0x1C0
.loc_0xD0:
cmplwi r0, 0x3E8
bne- .loc_0x1C0
lfs f1, 0x200(r31)
lfs f0, -0x30D0(r2)
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x110
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x1C0
.loc_0x110:
mr r3, r31
li r4, 0
bl -0x161024
rlwinm. r0,r3,0,24,31
beq- .loc_0x148
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x6
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x1C0
.loc_0x148:
lwz r5, 0xC0(r31)
fmr f1, f31
mr r3, r31
li r4, 0
lfs f2, 0x3D4(r5)
li r5, 0
li r6, 0
bl -0x162678
cmplwi r3, 0
beq- .loc_0x1A0
stw r3, 0x230(r31)
mr r3, r30
lfs f0, -0x30D0(r2)
mr r4, r31
li r5, 0x4
li r6, 0
stfs f0, 0x2EC(r31)
lwz r12, 0x0(r30)
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x1C0
.loc_0x1A0:
mr r3, r30
mr r4, r31
lwz r12, 0x0(r30)
li r5, 0x1
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
.loc_0x1C0:
psq_l f31,0x18(r1),0,0
lwz r0, 0x24(r1)
lfd f31, 0x10(r1)
lwz r31, 0xC(r1)
lwz r30, 0x8(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 80275744
* Size: 000004
*/
void Tank::Obj::startEffect() { }
/*
* --INFO--
* Address: 80275748
* Size: 000004
*/
void Tank::Obj::createDisChargeSE() { }
/*
* --INFO--
* Address: 8027574C
* Size: 000058
*/
void Tank::StateAttack::cleanup(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
li r0, 0
stw r31, 0xC(r1)
mr r31, r4
mr r3, r31
lwz r4, 0x1E0(r4)
ori r4, r4, 0x40
stw r4, 0x1E0(r31)
stb r0, 0x304(r31)
lwz r12, 0x0(r31)
lwz r12, 0x308(r12)
mtctr r12
bctrl
mr r3, r31
bl -0x173E10
lwz r0, 0x14(r1)
lwz r31, 0xC(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 802757A4
* Size: 000004
*/
void Tank::Obj::startYodare() { }
/*
* --INFO--
* Address: 802757A8
* Size: 000058
*/
void Tank::StateFlick::init(Game::EnemyBase*, Game::StateArg*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
lfs f0, -0x30D0(r2)
stw r0, 0x14(r1)
li r0, 0
stw r31, 0xC(r1)
mr r31, r4
mr r3, r31
stw r0, 0x230(r4)
stfs f0, 0x1D4(r4)
stfs f0, 0x1D8(r4)
stfs f0, 0x1DC(r4)
bl -0x173E0C
mr r3, r31
li r4, 0x2
li r5, 0
bl -0x1707E4
lwz r0, 0x14(r1)
lwz r31, 0xC(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 80275800
* Size: 000180
*/
void Tank::StateFlick::exec(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x20(r1)
mflr r0
lfs f0, -0x30D0(r2)
stw r0, 0x24(r1)
stw r31, 0x1C(r1)
stw r30, 0x18(r1)
mr r30, r4
stw r29, 0x14(r1)
mr r29, r3
lfs f1, 0x200(r4)
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x50
lwz r12, 0x0(r3)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x164
.loc_0x50:
lwz r3, 0x188(r30)
lbz r0, 0x24(r3)
cmplwi r0, 0
beq- .loc_0x164
lwz r0, 0x1C(r3)
cmplwi r0, 0x2
bne- .loc_0xFC
lwz r5, 0xC0(r30)
mr r3, r30
lfs f4, -0x308C(r2)
li r4, 0
lfs f1, 0x514(r5)
lfs f2, 0x4C4(r5)
lfs f3, 0x4EC(r5)
bl -0x1620F8
mr r3, r30
lwz r31, 0xC0(r30)
lwz r12, 0x0(r30)
lwz r12, 0x64(r12)
mtctr r12
bctrl
fmr f4, f1
lfs f1, 0x514(r31)
lfs f2, 0x4C4(r31)
mr r3, r30
lfs f3, 0x4EC(r31)
li r4, 0
bl -0x1623E8
mr r3, r30
lwz r31, 0xC0(r30)
lwz r12, 0x0(r30)
lwz r12, 0x64(r12)
mtctr r12
bctrl
fmr f4, f1
lfs f1, 0x53C(r31)
lfs f2, 0x4C4(r31)
mr r3, r30
lfs f3, 0x4EC(r31)
li r4, 0
bl -0x1627D4
lfs f0, -0x30D0(r2)
stfs f0, 0x20C(r30)
.loc_0xFC:
lwz r3, 0x188(r30)
lwz r0, 0x1C(r3)
cmplwi r0, 0x3E8
bne- .loc_0x164
lfs f1, 0x200(r30)
lfs f0, -0x30D0(r2)
fcmpo cr0, f1, f0
cror 2, 0, 0x2
bne- .loc_0x144
mr r3, r29
mr r4, r30
lwz r12, 0x0(r29)
li r5, 0
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
b .loc_0x164
.loc_0x144:
mr r3, r29
mr r4, r30
lwz r12, 0x0(r29)
li r5, 0x5
li r6, 0
lwz r12, 0x1C(r12)
mtctr r12
bctrl
.loc_0x164:
lwz r0, 0x24(r1)
lwz r31, 0x1C(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 80275980
* Size: 000024
*/
void Tank::StateFlick::cleanup(Game::EnemyBase*)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
mr r3, r4
stw r0, 0x14(r1)
bl -0x174014
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
} // namespace Game
| [
"[email protected]"
] | |
5250554b59a9bd9d5e5fc3ef2456079007231b28 | 0591b3949543c7c59e093f66f5f24b26f27deaed | /cpp/protocl/cpp/object/gmap/MsgDelPoint.h | 1f2d64da0d21bb0255c900b2f3e91c9d92b0e7ba | [] | no_license | joydit/GMap | 72410e6f9452873679e2cc9fb4e27748ca39d7f0 | d17b4f484a456a38d3ffbadb77199daf4af7061c | refs/heads/master | 2020-03-28T15:26:18.718150 | 2017-09-28T10:06:42 | 2017-09-28T10:06:42 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 385 | h | #ifndef MSG_DEL_POINT_H
#define MSG_DEL_POINT_H
#include "../../Buffer.h"
namespace msg
{
//删除顶点
class MsgDelPoint : public msg::Buffer
{
public:
//传递数据
int64 m_pointId;//要删除的边id
//回应数据
public:
MsgDelPoint();
virtual ~MsgDelPoint();
bool Build( bool isResult = false );
bool Parse();
};
}
#endif //MSG_DEL_POINT_H | [
"[email protected]"
] | |
f9416dee7765c9ddba2a270f3c74e62c6c40c5e6 | b007b067677ad3f97949d8fe342af8603ed19aa8 | /EiQueen/EiQueen/main.cpp | 873b0c98ffd5bb6f15271aa3273ac215aec1a6a9 | [] | no_license | SouthStreet/AlgTrain | 9f3248ae95e5680526d8f0beb73fdd4efc656b70 | 4dc850cf7e5fe736aeb2ff8b4dc408a5a3ca0e8d | refs/heads/master | 2021-05-14T09:42:39.037464 | 2018-03-18T09:35:46 | 2018-03-18T09:35:46 | 116,333,027 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 739 | cpp | #include <cstdio>
#include <algorithm>
const int maxn = 1010;
int P[maxn];//第i列皇后的行号
bool ht[maxn] = {false};//第x行放了没
int cnt = 0;
int n = 8;
void gP(int index){
if(index == n + 1){
cnt ++;
return;
}
for(int x = 1; x <= n; x ++){
//x是还没放 准备放一发
if(ht[x] == false){
bool flag = true;//能不能放呢
for(int pre = 1; pre < index; pre ++){
if(abs(index - pre) == abs(x - P[pre])){
//index,pre都是列号 x,P[pre]都是行号
//GG 这个x放不了了
flag = false;
break;
}
}//检查完成
if(flag){
P[index] = x;
ht[x] = true;
gP(index + 1);
ht[x] = false;
}
}
}
}
int main(){
gP(1);
printf("%d", cnt);
return 0;
}
| [
"[email protected]"
] | |
2ac7808ac37cb116f6c1fdb17202d1ae24dc63ad | b9a3aa345b37e99a32cd6f003ec5f1f15cb79811 | /renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp | 1c74b81564f69f5acdf9d92c98533300ee7fe236 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | OzgurCerlet/renderdoc | a66ece6370d4cf0a7183bc58252989785434f23a | 92ce836ffe745e71cbc1d3db6c54fba35d3fd1b8 | refs/heads/master | 2021-01-09T05:20:22.191437 | 2017-02-02T18:41:16 | 2017-02-02T18:41:16 | 80,755,268 | 1 | 0 | null | 2017-02-02T18:26:25 | 2017-02-02T18:26:25 | null | UTF-8 | C++ | false | false | 170,810 | cpp | /******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2016-2017 Baldur Karlsson
*
* 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 "d3d12_command_list.h"
#include "d3d12_command_queue.h"
ID3D12GraphicsCommandList *WrappedID3D12GraphicsCommandList::GetList(ResourceId id)
{
return GetResourceManager()->GetLiveAs<WrappedID3D12GraphicsCommandList>(id)->GetReal();
}
ID3D12GraphicsCommandList *WrappedID3D12GraphicsCommandList::GetCrackedList(ResourceId id)
{
return Unwrap(m_Cmd->m_BakedCmdListInfo[id].crackedLists.back());
}
bool WrappedID3D12GraphicsCommandList::Serialise_Close()
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
ResourceId bakedCmdId;
if(m_State >= WRITING)
{
D3D12ResourceRecord *record = GetResourceManager()->GetResourceRecord(CommandList);
RDCASSERT(record->bakedCommands);
if(record->bakedCommands)
bakedCmdId = record->bakedCommands->GetResourceID();
}
SERIALISE_ELEMENT(ResourceId, bakeId, bakedCmdId);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
#if ENABLED(VERBOSE_PARTIAL_REPLAY)
RDCDEBUG("Ending partial command list for %llu baked to %llu", CommandList, bakeId);
#endif
list->Close();
// erase the non-baked reference to this command list so that we don't have
// duplicates when it comes time to clean up. See below in in Reset()
m_Cmd->m_RerecordCmds.erase(CommandList);
if(m_Cmd->m_Partial[D3D12CommandData::Primary].partialParent == CommandList)
m_Cmd->m_Partial[D3D12CommandData::Primary].partialParent = ResourceId();
}
m_Cmd->m_BakedCmdListInfo[CommandList].curEventID = 0;
}
else if(m_State == READING)
{
ID3D12GraphicsCommandList *list = GetList(CommandList);
GetResourceManager()->RemoveReplacement(CommandList);
list->Close();
if(!m_Cmd->m_BakedCmdListInfo[CommandList].crackedLists.empty())
{
GetCrackedList(CommandList)->Close();
}
if(!m_Cmd->m_BakedCmdListInfo[CommandList].curEvents.empty())
{
FetchDrawcall draw;
draw.name = "API Calls";
draw.flags |= eDraw_SetMarker | eDraw_APICalls;
m_Cmd->AddDrawcall(draw, true);
m_Cmd->m_BakedCmdListInfo[CommandList].curEventID++;
}
{
if(m_Cmd->GetDrawcallStack().size() > 1)
m_Cmd->GetDrawcallStack().pop_back();
}
m_Cmd->m_BakedCmdListInfo[bakeId].BakeFrom(CommandList, m_Cmd->m_BakedCmdListInfo[CommandList]);
}
return true;
}
HRESULT WrappedID3D12GraphicsCommandList::Close()
{
if(m_State >= WRITING)
{
{
SCOPED_SERIALISE_CONTEXT(CLOSE_LIST);
Serialise_Close();
m_ListRecord->AddChunk(scope.Get());
}
m_ListRecord->Bake();
}
return m_pReal->Close();
}
bool WrappedID3D12GraphicsCommandList::Serialise_Reset(ID3D12CommandAllocator *pAllocator,
ID3D12PipelineState *pInitialState)
{
// parameters to create the list with if needed
SERIALISE_ELEMENT(IID, riid, m_Init.riid);
SERIALISE_ELEMENT(UINT, nodeMask, m_Init.nodeMask);
SERIALISE_ELEMENT(D3D12_COMMAND_LIST_TYPE, type, m_Init.type);
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, Allocator, GetResID(pAllocator));
SERIALISE_ELEMENT(ResourceId, State, GetResID(pInitialState));
ResourceId bakedCmdId;
if(m_State >= WRITING)
{
D3D12ResourceRecord *record = GetResourceManager()->GetResourceRecord(CommandList);
RDCASSERT(record->bakedCommands);
if(record->bakedCommands)
bakedCmdId = record->bakedCommands->GetResourceID();
}
SERIALISE_ELEMENT(ResourceId, bakeId, bakedCmdId);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
const uint32_t length = m_Cmd->m_BakedCmdListInfo[bakeId].eventCount;
bool partial = false;
int partialType = D3D12CommandData::ePartialNum;
// check for partial execution of this command list
for(int p = 0; p < D3D12CommandData::ePartialNum; p++)
{
const vector<uint32_t> &baseEvents = m_Cmd->m_Partial[p].cmdListExecs[bakeId];
for(auto it = baseEvents.begin(); it != baseEvents.end(); ++it)
{
if(*it <= m_Cmd->m_LastEventID && m_Cmd->m_LastEventID < (*it + length))
{
#if ENABLED(VERBOSE_PARTIAL_REPLAY)
RDCDEBUG("Reset - partial detected %u < %u < %u, %llu -> %llu", *it, m_Cmd->m_LastEventID,
*it + length, CommandList, bakeId);
#endif
m_Cmd->m_Partial[p].partialParent = CommandList;
m_Cmd->m_Partial[p].baseEvent = *it;
partial = true;
partialType = p;
}
}
}
if(partial || (m_Cmd->m_DrawcallCallback && m_Cmd->m_DrawcallCallback->RecordAllCmds()))
{
pAllocator = GetResourceManager()->GetLiveAs<ID3D12CommandAllocator>(Allocator);
pInitialState =
State == ResourceId() ? NULL : GetResourceManager()->GetLiveAs<ID3D12PipelineState>(State);
ID3D12GraphicsCommandList *list = NULL;
HRESULT hr = m_pDevice->CreateCommandList(nodeMask, type, pAllocator, pInitialState, riid,
(void **)&list);
if(FAILED(hr))
RDCERR("Failed on resource serialise-creation, hr: 0x%08x", hr);
if(partial)
{
m_Cmd->m_Partial[partialType].resultPartialCmdList = list;
}
else
{
// we store under both baked and non baked ID.
// The baked ID is the 'real' entry, the non baked is simply so it
// can be found in the subsequent serialised commands that ref the
// non-baked ID. The baked ID is referenced by the submit itself.
//
// In Close() we erase the non-baked reference, and since
// we know you can only be recording a command list once at a time
// (even if it's baked to several command listsin the frame)
// there's no issue with clashes here.
m_Cmd->m_RerecordCmds[bakeId] = list;
m_Cmd->m_RerecordCmds[CommandList] = list;
}
m_Cmd->m_RenderState.pipe = GetResID(pInitialState);
}
m_Cmd->m_BakedCmdListInfo[CommandList].curEventID = 0;
m_Cmd->m_BakedCmdListInfo[CommandList].executeEvents =
m_Cmd->m_BakedCmdListInfo[bakeId].executeEvents;
}
else if(m_State == READING)
{
pAllocator = GetResourceManager()->GetLiveAs<ID3D12CommandAllocator>(Allocator);
pInitialState =
State == ResourceId() ? NULL : GetResourceManager()->GetLiveAs<ID3D12PipelineState>(State);
if(!GetResourceManager()->HasLiveResource(bakeId))
{
ID3D12GraphicsCommandList *list = NULL;
m_pDevice->CreateCommandList(nodeMask, type, pAllocator, pInitialState, riid, (void **)&list);
GetResourceManager()->AddLiveResource(bakeId, list);
// whenever a command-building chunk asks for the command list, it
// will get our baked version.
GetResourceManager()->ReplaceResource(CommandList, bakeId);
}
else
{
GetList(CommandList)->Reset(Unwrap(pAllocator), Unwrap(pInitialState));
}
{
D3D12DrawcallTreeNode *draw = new D3D12DrawcallTreeNode;
m_Cmd->m_BakedCmdListInfo[CommandList].draw = draw;
{
if(m_Cmd->m_CrackedAllocators[Allocator] == NULL)
{
HRESULT hr =
m_pDevice->CreateCommandAllocator(type, __uuidof(ID3D12CommandAllocator),
(void **)&m_Cmd->m_CrackedAllocators[Allocator]);
RDCASSERTEQUAL(hr, S_OK);
}
ID3D12GraphicsCommandList *list = NULL;
m_pDevice->CreateCommandList(nodeMask, type, m_Cmd->m_CrackedAllocators[Allocator],
pInitialState, riid, (void **)&list);
RDCASSERT(m_Cmd->m_BakedCmdListInfo[CommandList].crackedLists.empty());
m_Cmd->m_BakedCmdListInfo[CommandList].crackedLists.push_back(list);
}
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].type = type;
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].nodeMask = nodeMask;
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].allocator = Allocator;
// On list execute we increment all child events/drawcalls by
// m_RootEventID and insert them into the tree.
m_Cmd->m_BakedCmdListInfo[CommandList].curEventID = 0;
m_Cmd->m_BakedCmdListInfo[CommandList].eventCount = 0;
m_Cmd->m_BakedCmdListInfo[CommandList].drawCount = 0;
m_Cmd->m_BakedCmdListInfo[CommandList].drawStack.push_back(draw);
// reset state
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
state.m_ResourceManager = GetResourceManager();
state.pipe = GetResID(pInitialState);
}
}
return true;
}
HRESULT WrappedID3D12GraphicsCommandList::Reset(ID3D12CommandAllocator *pAllocator,
ID3D12PipelineState *pInitialState)
{
if(m_State >= WRITING)
{
bool firstTime = false;
// reset for new recording
m_ListRecord->DeleteChunks();
m_ListRecord->ContainsExecuteIndirect = false;
// free parents
m_ListRecord->FreeParents(GetResourceManager());
// free any baked commands. If we don't have any, this is the creation reset
// so we return before actually doing the 'real' reset.
if(m_ListRecord->bakedCommands)
m_ListRecord->bakedCommands->Delete(GetResourceManager());
else
firstTime = true;
m_ListRecord->bakedCommands =
GetResourceManager()->AddResourceRecord(ResourceIDGen::GetNewUniqueID());
m_ListRecord->bakedCommands->type = Resource_GraphicsCommandList;
m_ListRecord->bakedCommands->SpecialResource = true;
m_ListRecord->bakedCommands->cmdInfo = new CmdListRecordingInfo();
{
SCOPED_SERIALISE_CONTEXT(RESET_LIST);
Serialise_Reset(pAllocator, pInitialState);
m_ListRecord->AddChunk(scope.Get());
}
// add allocator and initial state (if there is one) as frame refs. We can't add
// them as parents of the list record because it won't get directly referenced
// (just the baked commands), and we can't parent them onto the baked commands
// because that would pull them into the capture section.
m_ListRecord->MarkResourceFrameReferenced(GetResID(pAllocator), eFrameRef_Read);
if(pInitialState)
m_ListRecord->MarkResourceFrameReferenced(GetResID(pInitialState), eFrameRef_Read);
if(firstTime)
return S_OK;
}
return m_pReal->Reset(Unwrap(pAllocator), Unwrap(pInitialState));
}
void WrappedID3D12GraphicsCommandList::ClearState(ID3D12PipelineState *pPipelineState)
{
m_pReal->ClearState(Unwrap(pPipelineState));
}
bool WrappedID3D12GraphicsCommandList::Serialise_ResourceBarrier(UINT NumBarriers,
const D3D12_RESOURCE_BARRIER *pBarriers)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, num, NumBarriers);
SERIALISE_ELEMENT_ARR(D3D12_RESOURCE_BARRIER, barriers, pBarriers, num);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
vector<D3D12_RESOURCE_BARRIER> filtered;
if(m_State <= EXECUTING)
{
filtered.reserve(num);
// non-transition barriers allow NULLs, but for transition barriers filter out any that
// reference the NULL resource - this means the resource wasn't used elsewhere so was discarded
// from the capture
for(UINT i = 0; i < num; i++)
if(barriers[i].Type != D3D12_RESOURCE_BARRIER_TYPE_TRANSITION ||
barriers[i].Transition.pResource)
filtered.push_back(barriers[i]);
}
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
if(!filtered.empty())
Unwrap(list)->ResourceBarrier((UINT)filtered.size(), &filtered[0]);
ResourceId cmd = GetResID(list);
// need to re-wrap the barriers
for(UINT i = 0; i < num; i++)
{
D3D12_RESOURCE_BARRIER b = barriers[i];
switch(b.Type)
{
case D3D12_RESOURCE_BARRIER_TYPE_TRANSITION:
{
b.Transition.pResource =
(ID3D12Resource *)GetResourceManager()->GetWrapper(b.Transition.pResource);
break;
}
case D3D12_RESOURCE_BARRIER_TYPE_ALIASING:
{
b.Aliasing.pResourceBefore =
(ID3D12Resource *)GetResourceManager()->GetWrapper(b.Aliasing.pResourceBefore);
b.Aliasing.pResourceAfter =
(ID3D12Resource *)GetResourceManager()->GetWrapper(b.Aliasing.pResourceAfter);
break;
}
case D3D12_RESOURCE_BARRIER_TYPE_UAV:
{
b.UAV.pResource = (ID3D12Resource *)GetResourceManager()->GetWrapper(b.UAV.pResource);
break;
}
}
m_Cmd->m_BakedCmdListInfo[cmd].barriers.push_back(b);
}
}
}
else if(m_State == READING)
{
ID3D12GraphicsCommandList *list = GetList(CommandList);
if(!filtered.empty())
{
list->ResourceBarrier((UINT)filtered.size(), &filtered[0]);
GetCrackedList(CommandList)->ResourceBarrier((UINT)filtered.size(), &filtered[0]);
}
ResourceId cmd = GetResID(GetResourceManager()->GetWrapper(list));
// need to re-wrap the barriers
for(UINT i = 0; i < num; i++)
{
D3D12_RESOURCE_BARRIER b = barriers[i];
switch(b.Type)
{
case D3D12_RESOURCE_BARRIER_TYPE_TRANSITION:
{
b.Transition.pResource =
(ID3D12Resource *)GetResourceManager()->GetWrapper(b.Transition.pResource);
break;
}
case D3D12_RESOURCE_BARRIER_TYPE_ALIASING:
{
b.Aliasing.pResourceBefore =
(ID3D12Resource *)GetResourceManager()->GetWrapper(b.Aliasing.pResourceBefore);
b.Aliasing.pResourceAfter =
(ID3D12Resource *)GetResourceManager()->GetWrapper(b.Aliasing.pResourceAfter);
break;
}
case D3D12_RESOURCE_BARRIER_TYPE_UAV:
{
b.UAV.pResource = (ID3D12Resource *)GetResourceManager()->GetWrapper(b.UAV.pResource);
break;
}
}
m_Cmd->m_BakedCmdListInfo[cmd].barriers.push_back(b);
}
}
SAFE_DELETE_ARRAY(barriers);
return true;
}
void WrappedID3D12GraphicsCommandList::ResourceBarrier(UINT NumBarriers,
const D3D12_RESOURCE_BARRIER *pBarriers)
{
D3D12_RESOURCE_BARRIER *barriers = m_pDevice->GetTempArray<D3D12_RESOURCE_BARRIER>(NumBarriers);
for(UINT i = 0; i < NumBarriers; i++)
{
barriers[i] = pBarriers[i];
if(barriers[i].Type == D3D12_RESOURCE_BARRIER_TYPE_TRANSITION)
{
barriers[i].Transition.pResource = Unwrap(barriers[i].Transition.pResource);
}
else if(barriers[i].Type == D3D12_RESOURCE_BARRIER_TYPE_ALIASING)
{
barriers[i].Aliasing.pResourceBefore = Unwrap(barriers[i].Aliasing.pResourceBefore);
barriers[i].Aliasing.pResourceAfter = Unwrap(barriers[i].Aliasing.pResourceAfter);
}
else if(barriers[i].Type == D3D12_RESOURCE_BARRIER_TYPE_UAV)
{
barriers[i].UAV.pResource = Unwrap(barriers[i].UAV.pResource);
}
}
m_pReal->ResourceBarrier(NumBarriers, barriers);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(RESOURCE_BARRIER);
Serialise_ResourceBarrier(NumBarriers, pBarriers);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->cmdInfo->barriers.insert(m_ListRecord->cmdInfo->barriers.end(), pBarriers,
pBarriers + NumBarriers);
}
}
#pragma region State Setting
bool WrappedID3D12GraphicsCommandList::Serialise_IASetPrimitiveTopology(
D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(D3D12_PRIMITIVE_TOPOLOGY, topo, PrimitiveTopology);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->IASetPrimitiveTopology(topo);
m_Cmd->m_RenderState.topo = topo;
}
}
else if(m_State == READING)
{
m_Cmd->m_BakedCmdListInfo[CommandList].state.topo = topo;
GetList(CommandList)->IASetPrimitiveTopology(topo);
GetCrackedList(CommandList)->IASetPrimitiveTopology(topo);
}
return true;
}
void WrappedID3D12GraphicsCommandList::IASetPrimitiveTopology(D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology)
{
m_pReal->IASetPrimitiveTopology(PrimitiveTopology);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_TOPOLOGY);
Serialise_IASetPrimitiveTopology(PrimitiveTopology);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_RSSetViewports(UINT NumViewports,
const D3D12_VIEWPORT *pViewports)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, num, NumViewports);
SERIALISE_ELEMENT_ARR(D3D12_VIEWPORT, views, pViewports, num);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->RSSetViewports(num, views);
if(m_Cmd->m_RenderState.views.size() < num)
m_Cmd->m_RenderState.views.resize(num);
for(UINT i = 0; i < num; i++)
m_Cmd->m_RenderState.views[i] = views[i];
}
}
else if(m_State == READING)
{
GetList(CommandList)->RSSetViewports(num, views);
GetCrackedList(CommandList)->RSSetViewports(num, views);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.views.size() < num)
state.views.resize(num);
for(UINT i = 0; i < num; i++)
state.views[i] = views[i];
}
SAFE_DELETE_ARRAY(views);
return true;
}
void WrappedID3D12GraphicsCommandList::RSSetViewports(UINT NumViewports,
const D3D12_VIEWPORT *pViewports)
{
m_pReal->RSSetViewports(NumViewports, pViewports);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_VIEWPORTS);
Serialise_RSSetViewports(NumViewports, pViewports);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_RSSetScissorRects(UINT NumRects,
const D3D12_RECT *pRects)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, num, NumRects);
SERIALISE_ELEMENT_ARR(D3D12_RECT, rects, pRects, num);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->RSSetScissorRects(num, rects);
if(m_Cmd->m_RenderState.scissors.size() < num)
m_Cmd->m_RenderState.scissors.resize(num);
for(UINT i = 0; i < num; i++)
m_Cmd->m_RenderState.scissors[i] = rects[i];
}
}
else if(m_State == READING)
{
GetList(CommandList)->RSSetScissorRects(num, rects);
GetCrackedList(CommandList)->RSSetScissorRects(num, rects);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.scissors.size() < num)
state.scissors.resize(num);
for(UINT i = 0; i < num; i++)
state.scissors[i] = rects[i];
}
SAFE_DELETE_ARRAY(rects);
return true;
}
void WrappedID3D12GraphicsCommandList::RSSetScissorRects(UINT NumRects, const D3D12_RECT *pRects)
{
m_pReal->RSSetScissorRects(NumRects, pRects);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_SCISSORS);
Serialise_RSSetScissorRects(NumRects, pRects);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_OMSetBlendFactor(const FLOAT BlendFactor[4])
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
float factor[4] = {1.0f, 1.0f, 1.0f, 1.0f};
if(m_State >= WRITING && BlendFactor)
memcpy(factor, BlendFactor, sizeof(float) * 4);
m_pSerialiser->SerialisePODArray<4>("BlendFactor", factor);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->OMSetBlendFactor(factor);
memcpy(m_Cmd->m_RenderState.blendFactor, factor, sizeof(factor));
}
}
else if(m_State == READING)
{
GetList(CommandList)->OMSetBlendFactor(factor);
GetCrackedList(CommandList)->OMSetBlendFactor(factor);
memcpy(m_Cmd->m_BakedCmdListInfo[CommandList].state.blendFactor, factor, sizeof(factor));
}
return true;
}
void WrappedID3D12GraphicsCommandList::OMSetBlendFactor(const FLOAT BlendFactor[4])
{
m_pReal->OMSetBlendFactor(BlendFactor);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_BLENDFACTOR);
Serialise_OMSetBlendFactor(BlendFactor);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_OMSetStencilRef(UINT StencilRef)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, ref, StencilRef);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->OMSetStencilRef(ref);
m_Cmd->m_RenderState.stencilRef = ref;
}
}
else if(m_State == READING)
{
GetList(CommandList)->OMSetStencilRef(ref);
GetCrackedList(CommandList)->OMSetStencilRef(ref);
m_Cmd->m_BakedCmdListInfo[CommandList].state.stencilRef = ref;
}
return true;
}
void WrappedID3D12GraphicsCommandList::OMSetStencilRef(UINT StencilRef)
{
m_pReal->OMSetStencilRef(StencilRef);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_STENCIL);
Serialise_OMSetStencilRef(StencilRef);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetDescriptorHeaps(
UINT NumDescriptorHeaps, ID3D12DescriptorHeap *const *ppDescriptorHeaps)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
std::vector<ResourceId> DescriptorHeaps;
if(m_State >= WRITING)
{
DescriptorHeaps.resize(NumDescriptorHeaps);
for(UINT i = 0; i < NumDescriptorHeaps; i++)
DescriptorHeaps[i] = GetResID(ppDescriptorHeaps[i]);
}
m_pSerialiser->Serialise("DescriptorHeaps", DescriptorHeaps);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
std::vector<ID3D12DescriptorHeap *> heaps;
heaps.resize(DescriptorHeaps.size());
for(size_t i = 0; i < heaps.size(); i++)
heaps[i] = Unwrap(GetResourceManager()->GetLiveAs<ID3D12DescriptorHeap>(DescriptorHeaps[i]));
Unwrap(m_Cmd->RerecordCmdList(CommandList))->SetDescriptorHeaps((UINT)heaps.size(), &heaps[0]);
m_Cmd->m_RenderState.heaps.resize(heaps.size());
for(size_t i = 0; i < heaps.size(); i++)
m_Cmd->m_RenderState.heaps[i] = GetResourceManager()->GetLiveID(DescriptorHeaps[i]);
}
}
else if(m_State == READING)
{
std::vector<ID3D12DescriptorHeap *> heaps;
heaps.resize(DescriptorHeaps.size());
for(size_t i = 0; i < heaps.size(); i++)
heaps[i] = Unwrap(GetResourceManager()->GetLiveAs<ID3D12DescriptorHeap>(DescriptorHeaps[i]));
GetList(CommandList)->SetDescriptorHeaps((UINT)heaps.size(), &heaps[0]);
GetCrackedList(CommandList)->SetDescriptorHeaps((UINT)heaps.size(), &heaps[0]);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
state.heaps.resize(heaps.size());
for(size_t i = 0; i < heaps.size(); i++)
state.heaps[i] = GetResourceManager()->GetLiveID(DescriptorHeaps[i]);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetDescriptorHeaps(UINT NumDescriptorHeaps,
ID3D12DescriptorHeap *const *ppDescriptorHeaps)
{
ID3D12DescriptorHeap **heaps = m_pDevice->GetTempArray<ID3D12DescriptorHeap *>(NumDescriptorHeaps);
for(UINT i = 0; i < NumDescriptorHeaps; i++)
heaps[i] = Unwrap(ppDescriptorHeaps[i]);
m_pReal->SetDescriptorHeaps(NumDescriptorHeaps, heaps);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_DESC_HEAPS);
Serialise_SetDescriptorHeaps(NumDescriptorHeaps, ppDescriptorHeaps);
m_ListRecord->AddChunk(scope.Get());
for(UINT i = 0; i < NumDescriptorHeaps; i++)
m_ListRecord->MarkResourceFrameReferenced(GetResID(ppDescriptorHeaps[i]), eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_IASetIndexBuffer(const D3D12_INDEX_BUFFER_VIEW *pView)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(bool, HasView, pView != NULL);
SERIALISE_ELEMENT_OPT(D3D12_INDEX_BUFFER_VIEW, view, *pView, HasView);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
if(HasView)
{
Unwrap(list)->IASetIndexBuffer(&view);
WrappedID3D12Resource::GetResIDFromAddr(
view.BufferLocation, m_Cmd->m_RenderState.ibuffer.buf, m_Cmd->m_RenderState.ibuffer.offs);
m_Cmd->m_RenderState.ibuffer.bytewidth = (view.Format == DXGI_FORMAT_R32_UINT ? 4 : 2);
m_Cmd->m_RenderState.ibuffer.size = view.SizeInBytes;
}
else
{
Unwrap(list)->IASetIndexBuffer(NULL);
m_Cmd->m_RenderState.ibuffer.buf = ResourceId();
m_Cmd->m_RenderState.ibuffer.offs = 0;
m_Cmd->m_RenderState.ibuffer.bytewidth = 2;
}
}
}
else if(m_State == READING)
{
ID3D12GraphicsCommandList *list = GetList(CommandList);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(HasView)
{
list->IASetIndexBuffer(&view);
GetCrackedList(CommandList)->IASetIndexBuffer(&view);
WrappedID3D12Resource::GetResIDFromAddr(view.BufferLocation, state.ibuffer.buf,
state.ibuffer.offs);
state.ibuffer.bytewidth = (view.Format == DXGI_FORMAT_R32_UINT ? 4 : 2);
state.ibuffer.size = view.SizeInBytes;
}
else
{
list->IASetIndexBuffer(NULL);
GetCrackedList(CommandList)->IASetIndexBuffer(NULL);
state.ibuffer.buf = ResourceId();
state.ibuffer.offs = 0;
state.ibuffer.bytewidth = 2;
}
}
return true;
}
void WrappedID3D12GraphicsCommandList::IASetIndexBuffer(const D3D12_INDEX_BUFFER_VIEW *pView)
{
m_pReal->IASetIndexBuffer(pView);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_IBUFFER);
Serialise_IASetIndexBuffer(pView);
m_ListRecord->AddChunk(scope.Get());
if(pView)
m_ListRecord->MarkResourceFrameReferenced(
WrappedID3D12Resource::GetResIDFromAddr(pView->BufferLocation), eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_IASetVertexBuffers(
UINT StartSlot, UINT NumViews, const D3D12_VERTEX_BUFFER_VIEW *pViews)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, start, StartSlot);
SERIALISE_ELEMENT(UINT, num, NumViews);
SERIALISE_ELEMENT_ARR(D3D12_VERTEX_BUFFER_VIEW, views, pViews, num);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->IASetVertexBuffers(start, num, views);
if(m_Cmd->m_RenderState.vbuffers.size() < start + num)
m_Cmd->m_RenderState.vbuffers.resize(start + num);
for(UINT i = 0; i < num; i++)
{
WrappedID3D12Resource::GetResIDFromAddr(views[i].BufferLocation,
m_Cmd->m_RenderState.vbuffers[start + i].buf,
m_Cmd->m_RenderState.vbuffers[start + i].offs);
m_Cmd->m_RenderState.vbuffers[start + i].stride = views[i].StrideInBytes;
m_Cmd->m_RenderState.vbuffers[start + i].size = views[i].SizeInBytes;
}
}
}
else if(m_State == READING)
{
GetList(CommandList)->IASetVertexBuffers(start, num, views);
GetCrackedList(CommandList)->IASetVertexBuffers(start, num, views);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.vbuffers.size() < start + num)
state.vbuffers.resize(start + num);
for(UINT i = 0; i < num; i++)
{
WrappedID3D12Resource::GetResIDFromAddr(
views[i].BufferLocation, state.vbuffers[start + i].buf, state.vbuffers[start + i].offs);
state.vbuffers[start + i].stride = views[i].StrideInBytes;
state.vbuffers[start + i].size = views[i].SizeInBytes;
}
}
SAFE_DELETE_ARRAY(views);
return true;
}
void WrappedID3D12GraphicsCommandList::IASetVertexBuffers(UINT StartSlot, UINT NumViews,
const D3D12_VERTEX_BUFFER_VIEW *pViews)
{
m_pReal->IASetVertexBuffers(StartSlot, NumViews, pViews);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_VBUFFERS);
Serialise_IASetVertexBuffers(StartSlot, NumViews, pViews);
m_ListRecord->AddChunk(scope.Get());
for(UINT i = 0; i < NumViews; i++)
m_ListRecord->MarkResourceFrameReferenced(
WrappedID3D12Resource::GetResIDFromAddr(pViews[i].BufferLocation), eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SOSetTargets(
UINT StartSlot, UINT NumViews, const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, start, StartSlot);
SERIALISE_ELEMENT(UINT, num, NumViews);
SERIALISE_ELEMENT_ARR(D3D12_STREAM_OUTPUT_BUFFER_VIEW, views, pViews, num);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->SOSetTargets(start, num, views);
if(m_Cmd->m_RenderState.streamouts.size() < start + num)
m_Cmd->m_RenderState.streamouts.resize(start + num);
for(UINT i = 0; i < num; i++)
{
D3D12RenderState::StreamOut &so = m_Cmd->m_RenderState.streamouts[start + i];
WrappedID3D12Resource::GetResIDFromAddr(views[i].BufferLocation, so.buf, so.offs);
WrappedID3D12Resource::GetResIDFromAddr(views[i].BufferFilledSizeLocation, so.countbuf,
so.countoffs);
so.size = views[i].SizeInBytes;
}
}
}
else if(m_State == READING)
{
GetList(CommandList)->SOSetTargets(start, num, views);
GetCrackedList(CommandList)->SOSetTargets(start, num, views);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.streamouts.size() < start + num)
state.streamouts.resize(start + num);
for(UINT i = 0; i < num; i++)
{
D3D12RenderState::StreamOut &so = state.streamouts[start + i];
WrappedID3D12Resource::GetResIDFromAddr(views[i].BufferLocation, so.buf, so.offs);
WrappedID3D12Resource::GetResIDFromAddr(views[i].BufferFilledSizeLocation, so.countbuf,
so.countoffs);
so.size = views[i].SizeInBytes;
}
}
SAFE_DELETE_ARRAY(views);
return true;
}
void WrappedID3D12GraphicsCommandList::SOSetTargets(UINT StartSlot, UINT NumViews,
const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews)
{
m_pReal->SOSetTargets(StartSlot, NumViews, pViews);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_SOTARGETS);
Serialise_SOSetTargets(StartSlot, NumViews, pViews);
m_ListRecord->AddChunk(scope.Get());
for(UINT i = 0; i < NumViews; i++)
m_ListRecord->MarkResourceFrameReferenced(
WrappedID3D12Resource::GetResIDFromAddr(pViews[i].BufferLocation), eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetPipelineState(ID3D12PipelineState *pPipelineState)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, pipe, GetResID(pPipelineState));
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
pPipelineState = GetResourceManager()->GetLiveAs<ID3D12PipelineState>(pipe);
Unwrap(m_Cmd->RerecordCmdList(CommandList))->SetPipelineState(Unwrap(pPipelineState));
m_Cmd->m_RenderState.pipe = GetResID(pPipelineState);
}
}
else if(m_State == READING)
{
pPipelineState = GetResourceManager()->GetLiveAs<ID3D12PipelineState>(pipe);
GetList(CommandList)->SetPipelineState(Unwrap(pPipelineState));
GetCrackedList(CommandList)->SetPipelineState(Unwrap(pPipelineState));
m_Cmd->m_BakedCmdListInfo[CommandList].state.pipe = GetResID(pPipelineState);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetPipelineState(ID3D12PipelineState *pPipelineState)
{
m_pReal->SetPipelineState(Unwrap(pPipelineState));
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_PIPE);
Serialise_SetPipelineState(pPipelineState);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pPipelineState), eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_OMSetRenderTargets(
UINT NumRenderTargetDescriptors, const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors,
BOOL RTsSingleHandleToDescriptorRange, const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, num, NumRenderTargetDescriptors);
SERIALISE_ELEMENT(bool, singlehandle, RTsSingleHandleToDescriptorRange != FALSE);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
UINT numHandles = singlehandle ? RDCMIN(1U, num) : num;
std::vector<PortableHandle> rts;
if(m_State >= WRITING)
{
rts.resize(numHandles);
// indexing pRenderTargetDescriptors with [i] is fine since if single handle is true,
// i will only ever be 0 (so we do equivalent of *pRenderTargetDescriptors)
for(UINT i = 0; i < numHandles; i++)
rts[i] = ToPortableHandle(pRenderTargetDescriptors[i]);
}
m_pSerialiser->Serialise("pRenderTargetDescriptors", rts);
SERIALISE_ELEMENT(PortableHandle, dsv, pDepthStencilDescriptor
? ToPortableHandle(*pDepthStencilDescriptor)
: PortableHandle(0));
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = CPUHandleFromPortableHandle(GetResourceManager(), dsv);
D3D12_CPU_DESCRIPTOR_HANDLE *rtHandles = new D3D12_CPU_DESCRIPTOR_HANDLE[numHandles];
for(UINT i = 0; i < numHandles; i++)
rtHandles[i] = CPUHandleFromPortableHandle(GetResourceManager(), rts[i]);
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->OMSetRenderTargets(num, rtHandles, singlehandle ? TRUE : FALSE,
dsv.heap != ResourceId() ? &dsvHandle : NULL);
m_Cmd->m_RenderState.rts.resize(numHandles);
for(UINT i = 0; i < numHandles; i++)
m_Cmd->m_RenderState.rts[i] = rts[i];
m_Cmd->m_RenderState.rtSingle = singlehandle;
m_Cmd->m_RenderState.dsv = dsv;
SAFE_DELETE_ARRAY(rtHandles);
}
}
else if(m_State == READING)
{
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = CPUHandleFromPortableHandle(GetResourceManager(), dsv);
D3D12_CPU_DESCRIPTOR_HANDLE *rtHandles = new D3D12_CPU_DESCRIPTOR_HANDLE[numHandles];
for(UINT i = 0; i < numHandles; i++)
rtHandles[i] = CPUHandleFromPortableHandle(GetResourceManager(), rts[i]);
GetList(CommandList)
->OMSetRenderTargets(num, rtHandles, singlehandle ? TRUE : FALSE,
dsv.heap != ResourceId() ? &dsvHandle : NULL);
GetCrackedList(CommandList)
->OMSetRenderTargets(num, rtHandles, singlehandle ? TRUE : FALSE,
dsv.heap != ResourceId() ? &dsvHandle : NULL);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
state.rts.resize(numHandles);
for(UINT i = 0; i < numHandles; i++)
state.rts[i] = rts[i];
state.rtSingle = singlehandle;
state.dsv = dsv;
SAFE_DELETE_ARRAY(rtHandles);
}
return true;
}
void WrappedID3D12GraphicsCommandList::OMSetRenderTargets(
UINT NumRenderTargetDescriptors, const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors,
BOOL RTsSingleHandleToDescriptorRange, const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor)
{
UINT num = NumRenderTargetDescriptors;
UINT numHandles = RTsSingleHandleToDescriptorRange ? RDCMIN(1U, num) : num;
D3D12_CPU_DESCRIPTOR_HANDLE *unwrapped =
m_pDevice->GetTempArray<D3D12_CPU_DESCRIPTOR_HANDLE>(numHandles);
for(UINT i = 0; i < numHandles; i++)
unwrapped[i] = Unwrap(pRenderTargetDescriptors[i]);
D3D12_CPU_DESCRIPTOR_HANDLE dsv =
pDepthStencilDescriptor ? Unwrap(*pDepthStencilDescriptor) : D3D12_CPU_DESCRIPTOR_HANDLE();
m_pReal->OMSetRenderTargets(num, unwrapped, RTsSingleHandleToDescriptorRange,
pDepthStencilDescriptor ? &dsv : NULL);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_RTVS);
Serialise_OMSetRenderTargets(num, pRenderTargetDescriptors, RTsSingleHandleToDescriptorRange,
pDepthStencilDescriptor);
m_ListRecord->AddChunk(scope.Get());
for(UINT i = 0; i < numHandles; i++)
{
D3D12Descriptor *desc = GetWrapped(pRenderTargetDescriptors[i]);
m_ListRecord->MarkResourceFrameReferenced(desc->nonsamp.heap->GetResourceID(), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(desc->nonsamp.resource), eFrameRef_Write);
}
if(pDepthStencilDescriptor)
{
D3D12Descriptor *desc = GetWrapped(*pDepthStencilDescriptor);
m_ListRecord->MarkResourceFrameReferenced(desc->nonsamp.heap->GetResourceID(), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(desc->nonsamp.resource), eFrameRef_Write);
}
}
}
#pragma endregion State Setting
#pragma region Compute Root Signatures
bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootSignature(
ID3D12RootSignature *pRootSignature)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, sig, GetResID(pRootSignature));
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
pRootSignature = GetResourceManager()->GetLiveAs<ID3D12RootSignature>(sig);
Unwrap(m_Cmd->RerecordCmdList(CommandList))->SetComputeRootSignature(Unwrap(pRootSignature));
// From the docs
// (https://msdn.microsoft.com/en-us/library/windows/desktop/dn903950(v=vs.85).aspx)
// "If a root signature is changed on a command list, all previous root signature bindings
// become stale and all newly expected bindings must be set before Draw/Dispatch; otherwise,
// the behavior is undefined. If the root signature is redundantly set to the same one
// currently set, existing root signature bindings do not become stale."
if(m_Cmd->m_RenderState.compute.rootsig != GetResID(pRootSignature))
m_Cmd->m_RenderState.compute.sigelems.clear();
m_Cmd->m_RenderState.compute.rootsig = GetResID(pRootSignature);
}
}
else if(m_State == READING)
{
pRootSignature = GetResourceManager()->GetLiveAs<ID3D12RootSignature>(sig);
GetList(CommandList)->SetComputeRootSignature(Unwrap(pRootSignature));
GetCrackedList(CommandList)->SetComputeRootSignature(Unwrap(pRootSignature));
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.compute.rootsig != GetResID(pRootSignature))
state.compute.sigelems.clear();
state.compute.rootsig = GetResID(pRootSignature);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetComputeRootSignature(ID3D12RootSignature *pRootSignature)
{
m_pReal->SetComputeRootSignature(Unwrap(pRootSignature));
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_COMP_ROOT_SIG);
Serialise_SetComputeRootSignature(pRootSignature);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pRootSignature), eFrameRef_Read);
// store this so we can look up how many descriptors a given slot references, etc
m_CurCompRootSig = GetWrapped(pRootSignature);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootDescriptorTable(
UINT RootParameterIndex, D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(PortableHandle, Descriptor, ToPortableHandle(BaseDescriptor));
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->SetComputeRootDescriptorTable(
idx, GPUHandleFromPortableHandle(GetResourceManager(), Descriptor));
WrappedID3D12DescriptorHeap *heap =
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(Descriptor.heap);
if(m_Cmd->m_RenderState.compute.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.compute.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.compute.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootTable, GetResID(heap), (UINT64)Descriptor.index);
}
}
else if(m_State == READING)
{
GetList(CommandList)
->SetComputeRootDescriptorTable(
idx, GPUHandleFromPortableHandle(GetResourceManager(), Descriptor));
GetCrackedList(CommandList)
->SetComputeRootDescriptorTable(
idx, GPUHandleFromPortableHandle(GetResourceManager(), Descriptor));
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.compute.sigelems.size() < idx + 1)
state.compute.sigelems.resize(idx + 1);
WrappedID3D12DescriptorHeap *heap =
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(Descriptor.heap);
state.compute.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootTable, GetResID(heap), (UINT64)Descriptor.index);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetComputeRootDescriptorTable(
UINT RootParameterIndex, D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor)
{
m_pReal->SetComputeRootDescriptorTable(RootParameterIndex, Unwrap(BaseDescriptor));
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_COMP_ROOT_TABLE);
Serialise_SetComputeRootDescriptorTable(RootParameterIndex, BaseDescriptor);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(GetWrapped(BaseDescriptor)->nonsamp.heap),
eFrameRef_Read);
vector<D3D12_DESCRIPTOR_RANGE1> &ranges =
GetWrapped(m_CurCompRootSig)->sig.params[RootParameterIndex].ranges;
D3D12Descriptor *base = GetWrapped(BaseDescriptor);
UINT prevTableOffset = 0;
for(size_t i = 0; i < ranges.size(); i++)
{
D3D12Descriptor *rangeStart = base;
UINT offset = ranges[i].OffsetInDescriptorsFromTableStart;
if(ranges[i].OffsetInDescriptorsFromTableStart == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
offset = prevTableOffset;
rangeStart += offset;
UINT num = ranges[i].NumDescriptors;
if(num == UINT_MAX)
{
// find out how many descriptors are left after rangeStart
num = base->samp.heap->GetNumDescriptors() - offset;
}
std::vector<D3D12Descriptor *> &descs = m_ListRecord->cmdInfo->boundDescs;
for(UINT d = 0; d < num; d++)
descs.push_back(rangeStart + d);
prevTableOffset = offset + num;
}
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRoot32BitConstant(
UINT RootParameterIndex, UINT SrcData, UINT DestOffsetIn32BitValues)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(UINT, val, SrcData);
SERIALISE_ELEMENT(UINT, offs, DestOffsetIn32BitValues);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->SetComputeRoot32BitConstant(idx, val, offs);
if(m_Cmd->m_RenderState.compute.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.compute.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.compute.sigelems[idx].SetConstant(offs, val);
}
}
else if(m_State == READING)
{
GetList(CommandList)->SetComputeRoot32BitConstant(idx, val, offs);
GetCrackedList(CommandList)->SetComputeRoot32BitConstant(idx, val, offs);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.compute.sigelems.size() < idx + 1)
state.compute.sigelems.resize(idx + 1);
state.compute.sigelems[idx].SetConstant(offs, val);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetComputeRoot32BitConstant(UINT RootParameterIndex,
UINT SrcData,
UINT DestOffsetIn32BitValues)
{
m_pReal->SetComputeRoot32BitConstant(RootParameterIndex, SrcData, DestOffsetIn32BitValues);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_COMP_ROOT_CONST);
Serialise_SetComputeRoot32BitConstant(RootParameterIndex, SrcData, DestOffsetIn32BitValues);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRoot32BitConstants(
UINT RootParameterIndex, UINT Num32BitValuesToSet, const void *pSrcData,
UINT DestOffsetIn32BitValues)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(UINT, num, Num32BitValuesToSet);
SERIALISE_ELEMENT(UINT, offs, DestOffsetIn32BitValues);
SERIALISE_ELEMENT_ARR(UINT, data, (UINT *)pSrcData, num);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->SetComputeRoot32BitConstants(idx, num, data, offs);
if(m_Cmd->m_RenderState.compute.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.compute.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.compute.sigelems[idx].SetConstants(num, data, offs);
}
}
else if(m_State == READING)
{
GetList(CommandList)->SetComputeRoot32BitConstants(idx, num, data, offs);
GetCrackedList(CommandList)->SetComputeRoot32BitConstants(idx, num, data, offs);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.compute.sigelems.size() < idx + 1)
state.compute.sigelems.resize(idx + 1);
state.compute.sigelems[idx].SetConstants(num, data, offs);
}
SAFE_DELETE_ARRAY(data);
return true;
}
void WrappedID3D12GraphicsCommandList::SetComputeRoot32BitConstants(UINT RootParameterIndex,
UINT Num32BitValuesToSet,
const void *pSrcData,
UINT DestOffsetIn32BitValues)
{
m_pReal->SetComputeRoot32BitConstants(RootParameterIndex, Num32BitValuesToSet, pSrcData,
DestOffsetIn32BitValues);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_COMP_ROOT_CONSTS);
Serialise_SetComputeRoot32BitConstants(RootParameterIndex, Num32BitValuesToSet, pSrcData,
DestOffsetIn32BitValues);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootConstantBufferView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
ResourceId id;
UINT64 offs = 0;
if(m_State >= WRITING)
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(ResourceId, buffer, id);
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
if(m_State < WRITING)
{
m_Cmd->m_LastCmdListID = CommandList;
if(ValidateRootGPUVA(buffer))
return true;
}
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->SetComputeRootConstantBufferView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
if(m_Cmd->m_RenderState.compute.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.compute.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.compute.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootCBV, GetResID(pRes), byteOffset);
}
}
else if(m_State == READING)
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
GetList(CommandList)->SetComputeRootConstantBufferView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
GetCrackedList(CommandList)
->SetComputeRootConstantBufferView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.compute.sigelems.size() < idx + 1)
state.compute.sigelems.resize(idx + 1);
state.compute.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootCBV, GetResID(pRes), byteOffset);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetComputeRootConstantBufferView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
m_pReal->SetComputeRootConstantBufferView(RootParameterIndex, BufferLocation);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_COMP_ROOT_CBV);
Serialise_SetComputeRootConstantBufferView(RootParameterIndex, BufferLocation);
ResourceId id;
UINT64 offs = 0;
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(id, eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootShaderResourceView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
ResourceId id;
UINT64 offs = 0;
if(m_State >= WRITING)
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(ResourceId, buffer, id);
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
if(m_State < WRITING)
{
m_Cmd->m_LastCmdListID = CommandList;
if(ValidateRootGPUVA(buffer))
return true;
}
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->SetComputeRootShaderResourceView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
if(m_Cmd->m_RenderState.compute.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.compute.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.compute.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootSRV, GetResID(pRes), byteOffset);
}
}
else if(m_State == READING)
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
GetList(CommandList)->SetComputeRootShaderResourceView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
GetCrackedList(CommandList)
->SetComputeRootShaderResourceView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.compute.sigelems.size() < idx + 1)
state.compute.sigelems.resize(idx + 1);
state.compute.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootSRV, GetResID(pRes), byteOffset);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetComputeRootShaderResourceView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
m_pReal->SetComputeRootShaderResourceView(RootParameterIndex, BufferLocation);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_COMP_ROOT_SRV);
Serialise_SetComputeRootShaderResourceView(RootParameterIndex, BufferLocation);
ResourceId id;
UINT64 offs = 0;
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(id, eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootUnorderedAccessView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
ResourceId id;
UINT64 offs = 0;
if(m_State >= WRITING)
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(ResourceId, buffer, id);
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
if(m_State < WRITING)
{
m_Cmd->m_LastCmdListID = CommandList;
if(ValidateRootGPUVA(buffer))
return true;
}
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->SetComputeRootUnorderedAccessView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
if(m_Cmd->m_RenderState.compute.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.compute.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.compute.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootUAV, GetResID(pRes), byteOffset);
}
}
else if(m_State == READING)
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
GetList(CommandList)
->SetComputeRootUnorderedAccessView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
GetCrackedList(CommandList)
->SetComputeRootUnorderedAccessView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.compute.sigelems.size() < idx + 1)
state.compute.sigelems.resize(idx + 1);
state.compute.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootUAV, GetResID(pRes), byteOffset);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetComputeRootUnorderedAccessView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
m_pReal->SetComputeRootUnorderedAccessView(RootParameterIndex, BufferLocation);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_COMP_ROOT_UAV);
Serialise_SetComputeRootUnorderedAccessView(RootParameterIndex, BufferLocation);
ResourceId id;
UINT64 offs = 0;
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(id, eFrameRef_Read);
}
}
#pragma endregion Compute Root Signatures
#pragma region Graphics Root Signatures
bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootSignature(
ID3D12RootSignature *pRootSignature)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, sig, GetResID(pRootSignature));
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
pRootSignature = GetResourceManager()->GetLiveAs<ID3D12RootSignature>(sig);
Unwrap(m_Cmd->RerecordCmdList(CommandList))->SetGraphicsRootSignature(Unwrap(pRootSignature));
// From the docs
// (https://msdn.microsoft.com/en-us/library/windows/desktop/dn903950(v=vs.85).aspx)
// "If a root signature is changed on a command list, all previous root signature bindings
// become stale and all newly expected bindings must be set before Draw/Dispatch; otherwise,
// the behavior is undefined. If the root signature is redundantly set to the same one
// currently set, existing root signature bindings do not become stale."
if(m_Cmd->m_RenderState.graphics.rootsig != GetResID(pRootSignature))
m_Cmd->m_RenderState.graphics.sigelems.clear();
m_Cmd->m_RenderState.graphics.rootsig = GetResID(pRootSignature);
}
}
else if(m_State == READING)
{
pRootSignature = GetResourceManager()->GetLiveAs<ID3D12RootSignature>(sig);
GetList(CommandList)->SetGraphicsRootSignature(Unwrap(pRootSignature));
GetCrackedList(CommandList)->SetGraphicsRootSignature(Unwrap(pRootSignature));
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.graphics.rootsig != GetResID(pRootSignature))
state.graphics.sigelems.clear();
state.graphics.rootsig = GetResID(pRootSignature);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRootSignature(ID3D12RootSignature *pRootSignature)
{
m_pReal->SetGraphicsRootSignature(Unwrap(pRootSignature));
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_GFX_ROOT_SIG);
Serialise_SetGraphicsRootSignature(pRootSignature);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pRootSignature), eFrameRef_Read);
// store this so we can look up how many descriptors a given slot references, etc
m_CurGfxRootSig = GetWrapped(pRootSignature);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootDescriptorTable(
UINT RootParameterIndex, D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(PortableHandle, Descriptor, ToPortableHandle(BaseDescriptor));
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->SetGraphicsRootDescriptorTable(
idx, GPUHandleFromPortableHandle(GetResourceManager(), Descriptor));
WrappedID3D12DescriptorHeap *heap =
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(Descriptor.heap);
if(m_Cmd->m_RenderState.graphics.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.graphics.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.graphics.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootTable, GetResID(heap), (UINT64)Descriptor.index);
}
}
else if(m_State == READING)
{
GetList(CommandList)
->SetGraphicsRootDescriptorTable(
idx, GPUHandleFromPortableHandle(GetResourceManager(), Descriptor));
GetCrackedList(CommandList)
->SetGraphicsRootDescriptorTable(
idx, GPUHandleFromPortableHandle(GetResourceManager(), Descriptor));
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.graphics.sigelems.size() < idx + 1)
state.graphics.sigelems.resize(idx + 1);
WrappedID3D12DescriptorHeap *heap =
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(Descriptor.heap);
state.graphics.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootTable, GetResID(heap), (UINT64)Descriptor.index);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable(
UINT RootParameterIndex, D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor)
{
m_pReal->SetGraphicsRootDescriptorTable(RootParameterIndex, Unwrap(BaseDescriptor));
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_GFX_ROOT_TABLE);
Serialise_SetGraphicsRootDescriptorTable(RootParameterIndex, BaseDescriptor);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(GetWrapped(BaseDescriptor)->nonsamp.heap),
eFrameRef_Read);
vector<D3D12_DESCRIPTOR_RANGE1> &ranges =
GetWrapped(m_CurGfxRootSig)->sig.params[RootParameterIndex].ranges;
D3D12Descriptor *base = GetWrapped(BaseDescriptor);
UINT prevTableOffset = 0;
for(size_t i = 0; i < ranges.size(); i++)
{
D3D12Descriptor *rangeStart = base;
UINT offset = ranges[i].OffsetInDescriptorsFromTableStart;
if(ranges[i].OffsetInDescriptorsFromTableStart == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
offset = prevTableOffset;
rangeStart += offset;
UINT num = ranges[i].NumDescriptors;
if(num == UINT_MAX)
{
// find out how many descriptors are left after rangeStart
num = base->samp.heap->GetNumDescriptors() - offset;
}
std::vector<D3D12Descriptor *> &descs = m_ListRecord->cmdInfo->boundDescs;
for(UINT d = 0; d < num; d++)
descs.push_back(rangeStart + d);
prevTableOffset = offset + num;
}
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRoot32BitConstant(
UINT RootParameterIndex, UINT SrcData, UINT DestOffsetIn32BitValues)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(UINT, val, SrcData);
SERIALISE_ELEMENT(UINT, offs, DestOffsetIn32BitValues);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->SetGraphicsRoot32BitConstant(idx, val, offs);
if(m_Cmd->m_RenderState.graphics.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.graphics.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.graphics.sigelems[idx].SetConstant(offs, val);
}
}
else if(m_State == READING)
{
GetList(CommandList)->SetGraphicsRoot32BitConstant(idx, val, offs);
GetCrackedList(CommandList)->SetGraphicsRoot32BitConstant(idx, val, offs);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.graphics.sigelems.size() < idx + 1)
state.graphics.sigelems.resize(idx + 1);
state.graphics.sigelems[idx].SetConstant(offs, val);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRoot32BitConstant(UINT RootParameterIndex,
UINT SrcData,
UINT DestOffsetIn32BitValues)
{
m_pReal->SetGraphicsRoot32BitConstant(RootParameterIndex, SrcData, DestOffsetIn32BitValues);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_GFX_ROOT_CONST);
Serialise_SetGraphicsRoot32BitConstant(RootParameterIndex, SrcData, DestOffsetIn32BitValues);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRoot32BitConstants(
UINT RootParameterIndex, UINT Num32BitValuesToSet, const void *pSrcData,
UINT DestOffsetIn32BitValues)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(UINT, num, Num32BitValuesToSet);
SERIALISE_ELEMENT(UINT, offs, DestOffsetIn32BitValues);
SERIALISE_ELEMENT_ARR(UINT, data, (UINT *)pSrcData, num);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))->SetGraphicsRoot32BitConstants(idx, num, data, offs);
if(m_Cmd->m_RenderState.graphics.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.graphics.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.graphics.sigelems[idx].SetConstants(num, data, offs);
}
}
else if(m_State == READING)
{
GetList(CommandList)->SetGraphicsRoot32BitConstants(idx, num, data, offs);
GetCrackedList(CommandList)->SetGraphicsRoot32BitConstants(idx, num, data, offs);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.graphics.sigelems.size() < idx + 1)
state.graphics.sigelems.resize(idx + 1);
state.graphics.sigelems[idx].SetConstants(num, data, offs);
}
SAFE_DELETE_ARRAY(data);
return true;
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRoot32BitConstants(UINT RootParameterIndex,
UINT Num32BitValuesToSet,
const void *pSrcData,
UINT DestOffsetIn32BitValues)
{
m_pReal->SetGraphicsRoot32BitConstants(RootParameterIndex, Num32BitValuesToSet, pSrcData,
DestOffsetIn32BitValues);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_GFX_ROOT_CONSTS);
Serialise_SetGraphicsRoot32BitConstants(RootParameterIndex, Num32BitValuesToSet, pSrcData,
DestOffsetIn32BitValues);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootConstantBufferView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
ResourceId id;
UINT64 offs = 0;
if(m_State >= WRITING)
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(ResourceId, buffer, id);
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
if(m_State < WRITING)
{
m_Cmd->m_LastCmdListID = CommandList;
if(ValidateRootGPUVA(buffer))
return true;
}
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->SetGraphicsRootConstantBufferView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
if(m_Cmd->m_RenderState.graphics.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.graphics.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.graphics.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootCBV, GetResID(pRes), byteOffset);
}
}
else if(m_State == READING)
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
GetList(CommandList)
->SetGraphicsRootConstantBufferView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
GetCrackedList(CommandList)
->SetGraphicsRootConstantBufferView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.graphics.sigelems.size() < idx + 1)
state.graphics.sigelems.resize(idx + 1);
state.graphics.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootCBV, GetResID(pRes), byteOffset);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRootConstantBufferView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
m_pReal->SetGraphicsRootConstantBufferView(RootParameterIndex, BufferLocation);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_GFX_ROOT_CBV);
Serialise_SetGraphicsRootConstantBufferView(RootParameterIndex, BufferLocation);
ResourceId id;
UINT64 offs = 0;
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(id, eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootShaderResourceView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
ResourceId id;
UINT64 offs = 0;
if(m_State >= WRITING)
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(ResourceId, buffer, id);
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
if(m_State < WRITING)
{
m_Cmd->m_LastCmdListID = CommandList;
if(ValidateRootGPUVA(buffer))
return true;
}
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->SetGraphicsRootShaderResourceView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
if(m_Cmd->m_RenderState.graphics.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.graphics.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.graphics.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootSRV, GetResID(pRes), byteOffset);
}
}
else if(m_State == READING)
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
GetList(CommandList)
->SetGraphicsRootShaderResourceView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
GetCrackedList(CommandList)
->SetGraphicsRootShaderResourceView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.graphics.sigelems.size() < idx + 1)
state.graphics.sigelems.resize(idx + 1);
state.graphics.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootSRV, GetResID(pRes), byteOffset);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRootShaderResourceView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
m_pReal->SetGraphicsRootShaderResourceView(RootParameterIndex, BufferLocation);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_GFX_ROOT_SRV);
Serialise_SetGraphicsRootShaderResourceView(RootParameterIndex, BufferLocation);
ResourceId id;
UINT64 offs = 0;
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(id, eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootUnorderedAccessView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
ResourceId id;
UINT64 offs = 0;
if(m_State >= WRITING)
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idx, RootParameterIndex);
SERIALISE_ELEMENT(ResourceId, buffer, id);
SERIALISE_ELEMENT(UINT64, byteOffset, offs);
if(m_State < WRITING)
{
m_Cmd->m_LastCmdListID = CommandList;
if(ValidateRootGPUVA(buffer))
return true;
}
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->SetGraphicsRootUnorderedAccessView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
if(m_Cmd->m_RenderState.graphics.sigelems.size() < idx + 1)
m_Cmd->m_RenderState.graphics.sigelems.resize(idx + 1);
m_Cmd->m_RenderState.graphics.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootUAV, GetResID(pRes), byteOffset);
}
}
else if(m_State == READING)
{
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
GetList(CommandList)
->SetGraphicsRootUnorderedAccessView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
GetCrackedList(CommandList)
->SetGraphicsRootUnorderedAccessView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[CommandList].state;
if(state.graphics.sigelems.size() < idx + 1)
state.graphics.sigelems.resize(idx + 1);
state.graphics.sigelems[idx] =
D3D12RenderState::SignatureElement(eRootUAV, GetResID(pRes), byteOffset);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRootUnorderedAccessView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
m_pReal->SetGraphicsRootUnorderedAccessView(RootParameterIndex, BufferLocation);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_GFX_ROOT_UAV);
Serialise_SetGraphicsRootUnorderedAccessView(RootParameterIndex, BufferLocation);
ResourceId id;
UINT64 offs = 0;
WrappedID3D12Resource::GetResIDFromAddr(BufferLocation, id, offs);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(id, eFrameRef_Read);
}
}
#pragma endregion Graphics Root Signatures
#pragma region Queries / Events
bool WrappedID3D12GraphicsCommandList::Serialise_BeginQuery(ID3D12QueryHeap *pQueryHeap,
D3D12_QUERY_TYPE Type, UINT Index)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, heap, GetResID(pQueryHeap));
SERIALISE_ELEMENT(D3D12_QUERY_TYPE, type, Type);
SERIALISE_ELEMENT(UINT, idx, Index);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
pQueryHeap = GetResourceManager()->GetLiveAs<ID3D12QueryHeap>(heap);
// Unwrap(m_Cmd->RerecordCmdList(CommandList))->BeginQuery(Unwrap(pQueryHeap), type, idx);
}
}
else if(m_State == READING)
{
pQueryHeap = GetResourceManager()->GetLiveAs<ID3D12QueryHeap>(heap);
// GetList(CommandList)->BeginQuery(Unwrap(pQueryHeap), type, idx);
// GetCrackedList(CommandList)->BeginQuery(Unwrap(pQueryHeap), type, idx);
}
return true;
}
void WrappedID3D12GraphicsCommandList::BeginQuery(ID3D12QueryHeap *pQueryHeap,
D3D12_QUERY_TYPE Type, UINT Index)
{
m_pReal->BeginQuery(Unwrap(pQueryHeap), Type, Index);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(BEGIN_QUERY);
Serialise_BeginQuery(pQueryHeap, Type, Index);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pQueryHeap), eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_EndQuery(ID3D12QueryHeap *pQueryHeap,
D3D12_QUERY_TYPE Type, UINT Index)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, heap, GetResID(pQueryHeap));
SERIALISE_ELEMENT(D3D12_QUERY_TYPE, type, Type);
SERIALISE_ELEMENT(UINT, idx, Index);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
pQueryHeap = GetResourceManager()->GetLiveAs<ID3D12QueryHeap>(heap);
// Unwrap(m_Cmd->RerecordCmdList(CommandList))->EndQuery(Unwrap(pQueryHeap), type, idx);
}
}
else if(m_State == READING)
{
pQueryHeap = GetResourceManager()->GetLiveAs<ID3D12QueryHeap>(heap);
// GetList(CommandList)->EndQuery(Unwrap(pQueryHeap), type, idx);
// GetCrackedList(CommandList)->EndQuery(Unwrap(pQueryHeap), type, idx);
}
return true;
}
void WrappedID3D12GraphicsCommandList::EndQuery(ID3D12QueryHeap *pQueryHeap, D3D12_QUERY_TYPE Type,
UINT Index)
{
m_pReal->EndQuery(Unwrap(pQueryHeap), Type, Index);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(END_QUERY);
Serialise_EndQuery(pQueryHeap, Type, Index);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pQueryHeap), eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_ResolveQueryData(
ID3D12QueryHeap *pQueryHeap, D3D12_QUERY_TYPE Type, UINT StartIndex, UINT NumQueries,
ID3D12Resource *pDestinationBuffer, UINT64 AlignedDestinationBufferOffset)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, heap, GetResID(pQueryHeap));
SERIALISE_ELEMENT(D3D12_QUERY_TYPE, type, Type);
SERIALISE_ELEMENT(UINT, start, StartIndex);
SERIALISE_ELEMENT(UINT, num, NumQueries);
SERIALISE_ELEMENT(ResourceId, buf, GetResID(pDestinationBuffer));
SERIALISE_ELEMENT(UINT64, offs, AlignedDestinationBufferOffset);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
pQueryHeap = GetResourceManager()->GetLiveAs<ID3D12QueryHeap>(heap);
pDestinationBuffer = GetResourceManager()->GetLiveAs<ID3D12Resource>(buf);
/*
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->ResolveQueryData(Unwrap(pQueryHeap), type, start, num, Unwrap(pDestinationBuffer),
offs);*/
}
}
else if(m_State == READING)
{
pQueryHeap = GetResourceManager()->GetLiveAs<ID3D12QueryHeap>(heap);
pDestinationBuffer = GetResourceManager()->GetLiveAs<ID3D12Resource>(buf);
// GetList(CommandList)->ResolveQueryData(Unwrap(pQueryHeap), type, start, num,
// Unwrap(pDestinationBuffer), offs);
// GetCrackedList(CommandList)->ResolveQueryData(Unwrap(pQueryHeap), type, start, num,
// Unwrap(pDestinationBuffer), offs);
}
return true;
}
void WrappedID3D12GraphicsCommandList::ResolveQueryData(ID3D12QueryHeap *pQueryHeap,
D3D12_QUERY_TYPE Type, UINT StartIndex,
UINT NumQueries,
ID3D12Resource *pDestinationBuffer,
UINT64 AlignedDestinationBufferOffset)
{
m_pReal->ResolveQueryData(Unwrap(pQueryHeap), Type, StartIndex, NumQueries,
Unwrap(pDestinationBuffer), AlignedDestinationBufferOffset);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(RESOLVE_QUERY);
Serialise_ResolveQueryData(pQueryHeap, Type, StartIndex, NumQueries, pDestinationBuffer,
AlignedDestinationBufferOffset);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pQueryHeap), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pDestinationBuffer), eFrameRef_Write);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetPredication(ID3D12Resource *pBuffer,
UINT64 AlignedBufferOffset,
D3D12_PREDICATION_OP Operation)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, buffer, GetResID(pBuffer));
SERIALISE_ELEMENT(UINT64, offs, AlignedBufferOffset);
SERIALISE_ELEMENT(D3D12_PREDICATION_OP, op, Operation);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
// don't replay predication at all
return true;
}
void WrappedID3D12GraphicsCommandList::SetPredication(ID3D12Resource *pBuffer,
UINT64 AlignedBufferOffset,
D3D12_PREDICATION_OP Operation)
{
m_pReal->SetPredication(Unwrap(pBuffer), AlignedBufferOffset, Operation);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_PREDICATION);
Serialise_SetPredication(pBuffer, AlignedBufferOffset, Operation);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pBuffer), eFrameRef_Read);
}
}
// from PIXEventsCommon.h of winpixeventruntime
enum PIXEventType
{
ePIXEvent_EndEvent = 0x000,
ePIXEvent_BeginEvent_VarArgs = 0x001,
ePIXEvent_BeginEvent_NoArgs = 0x002,
ePIXEvent_SetMarker_VarArgs = 0x007,
ePIXEvent_SetMarker_NoArgs = 0x008,
ePIXEvent_EndEvent_OnContext = 0x010,
ePIXEvent_BeginEvent_OnContext_VarArgs = 0x011,
ePIXEvent_BeginEvent_OnContext_NoArgs = 0x012,
ePIXEvent_SetMarker_OnContext_VarArgs = 0x017,
ePIXEvent_SetMarker_OnContext_NoArgs = 0x018,
};
static const UINT PIX_EVENT_UNICODE_VERSION = 0;
static const UINT PIX_EVENT_ANSI_VERSION = 1;
static const UINT PIX_EVENT_PIX3BLOB_VERSION = 2;
inline void PIX3DecodeEventInfo(const UINT64 BlobData, UINT64 &Timestamp, PIXEventType &EventType)
{
static const UINT64 PIXEventsBlockEndMarker = 0x00000000000FFF80;
static const UINT64 PIXEventsTypeReadMask = 0x00000000000FFC00;
static const UINT64 PIXEventsTypeWriteMask = 0x00000000000003FF;
static const UINT64 PIXEventsTypeBitShift = 10;
static const UINT64 PIXEventsTimestampReadMask = 0xFFFFFFFFFFF00000;
static const UINT64 PIXEventsTimestampWriteMask = 0x00000FFFFFFFFFFF;
static const UINT64 PIXEventsTimestampBitShift = 20;
Timestamp = (BlobData >> PIXEventsTimestampBitShift) & PIXEventsTimestampWriteMask;
EventType = PIXEventType((BlobData >> PIXEventsTypeBitShift) & PIXEventsTypeWriteMask);
}
inline void PIX3DecodeStringInfo(const UINT64 BlobData, UINT64 &Alignment, UINT64 &CopyChunkSize,
bool &IsANSI, bool &IsShortcut)
{
static const UINT64 PIXEventsStringAlignmentWriteMask = 0x000000000000000F;
static const UINT64 PIXEventsStringAlignmentReadMask = 0xF000000000000000;
static const UINT64 PIXEventsStringAlignmentBitShift = 60;
static const UINT64 PIXEventsStringCopyChunkSizeWriteMask = 0x000000000000001F;
static const UINT64 PIXEventsStringCopyChunkSizeReadMask = 0x0F80000000000000;
static const UINT64 PIXEventsStringCopyChunkSizeBitShift = 55;
static const UINT64 PIXEventsStringIsANSIWriteMask = 0x0000000000000001;
static const UINT64 PIXEventsStringIsANSIReadMask = 0x0040000000000000;
static const UINT64 PIXEventsStringIsANSIBitShift = 54;
static const UINT64 PIXEventsStringIsShortcutWriteMask = 0x0000000000000001;
static const UINT64 PIXEventsStringIsShortcutReadMask = 0x0020000000000000;
static const UINT64 PIXEventsStringIsShortcutBitShift = 53;
Alignment = (BlobData >> PIXEventsStringAlignmentBitShift) & PIXEventsStringAlignmentWriteMask;
CopyChunkSize =
(BlobData >> PIXEventsStringCopyChunkSizeBitShift) & PIXEventsStringCopyChunkSizeWriteMask;
IsANSI = (BlobData >> PIXEventsStringIsANSIBitShift) & PIXEventsStringIsANSIWriteMask;
IsShortcut = (BlobData >> PIXEventsStringIsShortcutBitShift) & PIXEventsStringIsShortcutWriteMask;
}
const UINT64 *PIX3DecodeStringParam(const UINT64 *pData, string &DecodedString)
{
UINT64 alignment;
UINT64 copyChunkSize;
bool isANSI;
bool isShortcut;
PIX3DecodeStringInfo(*pData, alignment, copyChunkSize, isANSI, isShortcut);
++pData;
UINT totalStringBytes = 0;
if(isANSI)
{
const char *c = (const char *)pData;
UINT formatStringByteCount = UINT(strlen((const char *)pData));
DecodedString = string(c, c + formatStringByteCount);
totalStringBytes = formatStringByteCount + 1;
}
else
{
const wchar_t *w = (const wchar_t *)pData;
UINT formatStringByteCount = UINT(wcslen((const wchar_t *)pData));
DecodedString = StringFormat::Wide2UTF8(std::wstring(w, w + formatStringByteCount));
totalStringBytes = (formatStringByteCount + 1) * sizeof(wchar_t);
}
UINT64 byteChunks = ((totalStringBytes + copyChunkSize - 1) / copyChunkSize) * copyChunkSize;
UINT64 stringQWordCount = (byteChunks + 7) / 8;
pData += stringQWordCount;
return pData;
}
string PIX3SprintfParams(const string &Format, const UINT64 *pData)
{
string finalString;
string formatPart;
size_t lastFind = 0;
for(size_t found = Format.find_first_of("%"); found != string::npos;)
{
finalString += Format.substr(lastFind, found - lastFind);
size_t endOfFormat = Format.find_first_of("%diufFeEgGxXoscpaAn", found + 1);
if(endOfFormat == string::npos)
{
finalString += "<FORMAT_ERROR>";
break;
}
formatPart = Format.substr(found, (endOfFormat - found) + 1);
// strings
if(formatPart.back() == 's')
{
string stringParam;
pData = PIX3DecodeStringParam(pData, stringParam);
finalString += stringParam;
}
// numerical values
else
{
static const UINT MAX_CHARACTERS_FOR_VALUE = 32;
char formattedValue[MAX_CHARACTERS_FOR_VALUE];
StringFormat::snprintf(formattedValue, MAX_CHARACTERS_FOR_VALUE, formatPart.c_str(), *pData);
finalString += formattedValue;
++pData;
}
lastFind = endOfFormat + 1;
found = Format.find_first_of("%", lastFind);
}
finalString += Format.substr(lastFind);
return finalString;
}
inline string PIX3DecodeEventString(const UINT64 *pData)
{
// event header
UINT64 timestamp;
PIXEventType eventType;
PIX3DecodeEventInfo(*pData, timestamp, eventType);
++pData;
if(eventType != ePIXEvent_BeginEvent_NoArgs && eventType != ePIXEvent_BeginEvent_VarArgs)
{
RDCERR("Unexpected/unsupported PIX3Event %u type in PIXDecodeMarkerEventString", eventType);
return "";
}
// color
// UINT64 color = *pData;
++pData;
// format string
string formatString;
pData = PIX3DecodeStringParam(pData, formatString);
if(eventType == ePIXEvent_BeginEvent_NoArgs)
return formatString;
// sprintf remaining args
formatString = PIX3SprintfParams(formatString, pData);
return formatString;
}
bool WrappedID3D12GraphicsCommandList::Serialise_SetMarker(UINT Metadata, const void *pData, UINT Size)
{
string markerText = "";
if(m_State >= WRITING && pData && Size)
{
if(Metadata == PIX_EVENT_UNICODE_VERSION)
{
const wchar_t *w = (const wchar_t *)pData;
markerText = StringFormat::Wide2UTF8(std::wstring(w, w + Size));
}
else if(Metadata == PIX_EVENT_ANSI_VERSION)
{
const char *c = (const char *)pData;
markerText = string(c, c + Size);
}
else if(Metadata == PIX_EVENT_PIX3BLOB_VERSION)
{
markerText = PIX3DecodeEventString((UINT64 *)pData);
}
else
{
RDCERR("Unexpected/unsupported Metadata value %u in SetMarker", Metadata);
}
}
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
m_pSerialiser->Serialise("MarkerText", markerText);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == READING)
{
FetchDrawcall draw;
draw.name = markerText;
draw.flags |= eDraw_SetMarker;
m_Cmd->AddDrawcall(draw, false);
}
return true;
}
void WrappedID3D12GraphicsCommandList::SetMarker(UINT Metadata, const void *pData, UINT Size)
{
m_pReal->SetMarker(Metadata, pData, Size);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(SET_MARKER);
Serialise_SetMarker(Metadata, pData, Size);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_BeginEvent(UINT Metadata, const void *pData,
UINT Size)
{
string markerText = "";
if(m_State >= WRITING && pData && Size)
{
if(Metadata == PIX_EVENT_UNICODE_VERSION)
{
const wchar_t *w = (const wchar_t *)pData;
markerText = StringFormat::Wide2UTF8(std::wstring(w, w + Size));
}
else if(Metadata == PIX_EVENT_ANSI_VERSION)
{
const char *c = (const char *)pData;
markerText = string(c, c + Size);
}
else if(Metadata == PIX_EVENT_PIX3BLOB_VERSION)
{
markerText = PIX3DecodeEventString((UINT64 *)pData);
}
else
{
RDCERR("Unexpected/unsupported Metadata value %u in BeginEvent", Metadata);
}
}
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
m_pSerialiser->Serialise("MarkerText", markerText);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == READING)
{
FetchDrawcall draw;
draw.name = markerText;
draw.flags |= eDraw_PushMarker;
m_Cmd->AddDrawcall(draw, false);
}
return true;
}
void WrappedID3D12GraphicsCommandList::BeginEvent(UINT Metadata, const void *pData, UINT Size)
{
m_pReal->BeginEvent(Metadata, pData, Size);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(BEGIN_EVENT);
Serialise_BeginEvent(Metadata, pData, Size);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_EndEvent()
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == READING && !m_Cmd->m_BakedCmdListInfo[CommandList].curEvents.empty())
{
FetchDrawcall draw;
draw.name = "API Calls";
draw.flags = eDraw_SetMarker | eDraw_APICalls;
m_Cmd->AddDrawcall(draw, true);
}
if(m_State == READING)
{
// dummy draw that is consumed when this command buffer
// is being in-lined into the call stream
FetchDrawcall draw;
draw.name = "Pop()";
draw.flags = eDraw_PopMarker;
m_Cmd->AddDrawcall(draw, false);
}
return true;
}
void WrappedID3D12GraphicsCommandList::EndEvent()
{
m_pReal->EndEvent();
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(END_EVENT);
Serialise_EndEvent();
m_ListRecord->AddChunk(scope.Get());
}
}
#pragma endregion Queries / Events
#pragma region Draws
bool WrappedID3D12GraphicsCommandList::Serialise_DrawInstanced(UINT VertexCountPerInstance,
UINT InstanceCount,
UINT StartVertexLocation,
UINT StartInstanceLocation)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, vtxCount, VertexCountPerInstance);
SERIALISE_ELEMENT(UINT, instCount, InstanceCount);
SERIALISE_ELEMENT(UINT, startVtx, StartVertexLocation);
SERIALISE_ELEMENT(UINT, startInst, StartInstanceLocation);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
uint32_t eventID = m_Cmd->HandlePreCallback(list);
Unwrap(list)->DrawInstanced(vtxCount, instCount, startVtx, startInst);
if(eventID && m_Cmd->m_DrawcallCallback->PostDraw(eventID, list))
{
Unwrap(list)->DrawInstanced(vtxCount, instCount, startVtx, startInst);
m_Cmd->m_DrawcallCallback->PostRedraw(eventID, list);
}
}
}
else if(m_State == READING)
{
GetList(CommandList)->DrawInstanced(vtxCount, instCount, startVtx, startInst);
GetCrackedList(CommandList)->DrawInstanced(vtxCount, instCount, startVtx, startInst);
const string desc = m_pSerialiser->GetDebugStr();
m_Cmd->AddEvent(desc);
string name = "DrawInstanced(" + ToStr::Get(vtxCount) + ", " + ToStr::Get(instCount) + ")";
FetchDrawcall draw;
draw.name = name;
draw.numIndices = vtxCount;
draw.numInstances = instCount;
draw.indexOffset = 0;
draw.baseVertex = startVtx;
draw.instanceOffset = startInst;
draw.flags |= eDraw_Drawcall | eDraw_Instanced;
m_Cmd->AddDrawcall(draw, true);
}
return true;
}
void WrappedID3D12GraphicsCommandList::DrawInstanced(UINT VertexCountPerInstance,
UINT InstanceCount, UINT StartVertexLocation,
UINT StartInstanceLocation)
{
m_pReal->DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation,
StartInstanceLocation);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(DRAW_INST);
Serialise_DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation,
StartInstanceLocation);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_DrawIndexedInstanced(UINT IndexCountPerInstance,
UINT InstanceCount,
UINT StartIndexLocation,
INT BaseVertexLocation,
UINT StartInstanceLocation)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, idxCount, IndexCountPerInstance);
SERIALISE_ELEMENT(UINT, instCount, InstanceCount);
SERIALISE_ELEMENT(UINT, startIdx, StartIndexLocation);
SERIALISE_ELEMENT(INT, startVtx, BaseVertexLocation);
SERIALISE_ELEMENT(UINT, startInst, StartInstanceLocation);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
uint32_t eventID = m_Cmd->HandlePreCallback(list);
Unwrap(list)->DrawIndexedInstanced(idxCount, instCount, startIdx, startVtx, startInst);
if(eventID && m_Cmd->m_DrawcallCallback->PostDraw(eventID, list))
{
Unwrap(list)->DrawIndexedInstanced(idxCount, instCount, startIdx, startVtx, startInst);
m_Cmd->m_DrawcallCallback->PostRedraw(eventID, list);
}
}
}
else if(m_State == READING)
{
GetList(CommandList)->DrawIndexedInstanced(idxCount, instCount, startIdx, startVtx, startInst);
GetCrackedList(CommandList)->DrawIndexedInstanced(idxCount, instCount, startIdx, startVtx, startInst);
const string desc = m_pSerialiser->GetDebugStr();
m_Cmd->AddEvent(desc);
string name =
"DrawIndexedInstanced(" + ToStr::Get(idxCount) + ", " + ToStr::Get(instCount) + ")";
FetchDrawcall draw;
draw.name = name;
draw.numIndices = idxCount;
draw.numInstances = instCount;
draw.indexOffset = startIdx;
draw.baseVertex = startVtx;
draw.instanceOffset = startInst;
draw.flags |= eDraw_Drawcall | eDraw_Instanced | eDraw_UseIBuffer;
m_Cmd->AddDrawcall(draw, true);
}
return true;
}
void WrappedID3D12GraphicsCommandList::DrawIndexedInstanced(UINT IndexCountPerInstance,
UINT InstanceCount,
UINT StartIndexLocation,
INT BaseVertexLocation,
UINT StartInstanceLocation)
{
m_pReal->DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation,
BaseVertexLocation, StartInstanceLocation);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(DRAW_INDEXED_INST);
Serialise_DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation,
BaseVertexLocation, StartInstanceLocation);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_Dispatch(UINT ThreadGroupCountX,
UINT ThreadGroupCountY,
UINT ThreadGroupCountZ)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, x, ThreadGroupCountX);
SERIALISE_ELEMENT(UINT, y, ThreadGroupCountY);
SERIALISE_ELEMENT(UINT, z, ThreadGroupCountZ);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
uint32_t eventID = m_Cmd->HandlePreCallback(list, true);
Unwrap(list)->Dispatch(x, y, z);
if(eventID && m_Cmd->m_DrawcallCallback->PostDraw(eventID, list))
{
Unwrap(list)->Dispatch(x, y, z);
m_Cmd->m_DrawcallCallback->PostRedraw(eventID, list);
}
}
}
else if(m_State == READING)
{
GetList(CommandList)->Dispatch(x, y, z);
GetCrackedList(CommandList)->Dispatch(x, y, z);
const string desc = m_pSerialiser->GetDebugStr();
m_Cmd->AddEvent(desc);
string name = "Dispatch(" + ToStr::Get(x) + ", " + ToStr::Get(y) + ", " + ToStr::Get(z) + ")";
FetchDrawcall draw;
draw.name = name;
draw.dispatchDimension[0] = x;
draw.dispatchDimension[1] = y;
draw.dispatchDimension[2] = z;
draw.flags |= eDraw_Dispatch;
m_Cmd->AddDrawcall(draw, true);
}
return true;
}
void WrappedID3D12GraphicsCommandList::Dispatch(UINT ThreadGroupCountX, UINT ThreadGroupCountY,
UINT ThreadGroupCountZ)
{
m_pReal->Dispatch(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(DISPATCH);
Serialise_Dispatch(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ);
m_ListRecord->AddChunk(scope.Get());
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_ExecuteBundle(ID3D12GraphicsCommandList *pCommandList)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
ResourceId Bundle;
if(m_State >= WRITING)
{
D3D12ResourceRecord *record = GetRecord(pCommandList);
RDCASSERT(record->bakedCommands);
if(record->bakedCommands)
Bundle = record->bakedCommands->GetResourceID();
}
m_pSerialiser->Serialise("Bundle", Bundle);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
uint32_t eventID = m_Cmd->HandlePreCallback(list, true);
ID3D12GraphicsCommandList *bundle =
GetResourceManager()->GetLiveAs<ID3D12GraphicsCommandList>(Bundle);
Unwrap(list)->ExecuteBundle(Unwrap(bundle));
if(eventID && m_Cmd->m_DrawcallCallback->PostDraw(eventID, list))
{
Unwrap(list)->ExecuteBundle(Unwrap(bundle));
m_Cmd->m_DrawcallCallback->PostRedraw(eventID, list);
}
}
}
else if(m_State == READING)
{
ID3D12GraphicsCommandList *bundle =
GetResourceManager()->GetLiveAs<ID3D12GraphicsCommandList>(Bundle);
GetList(CommandList)->ExecuteBundle(Unwrap(bundle));
GetCrackedList(CommandList)->ExecuteBundle(Unwrap(bundle));
const string desc = m_pSerialiser->GetDebugStr();
m_Cmd->AddEvent(desc);
string name = "ExecuteBundle(" + ToStr::Get(Bundle) + ")";
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_CmdList;
m_Cmd->AddDrawcall(draw, true);
}
return true;
}
void WrappedID3D12GraphicsCommandList::ExecuteBundle(ID3D12GraphicsCommandList *pCommandList)
{
m_pReal->ExecuteBundle(Unwrap(pCommandList));
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(EXEC_BUNDLE);
Serialise_ExecuteBundle(pCommandList);
m_ListRecord->AddChunk(scope.Get());
D3D12ResourceRecord *record = GetRecord(pCommandList);
CmdListRecordingInfo *dst = m_ListRecord->cmdInfo;
CmdListRecordingInfo *src = record->bakedCommands->cmdInfo;
dst->boundDescs.insert(dst->boundDescs.end(), src->boundDescs.begin(), src->boundDescs.end());
dst->dirtied.insert(src->dirtied.begin(), src->dirtied.end());
dst->bundles.push_back(record);
}
}
/*
* ExecuteIndirect needs special handling - whenever we encounter an ExecuteIndirect during READING
* time we crack the list into two, and copy off the argument buffer in the first part and execute
* with the copy destination in the second part.
*
* Then when we come to ExecuteCommandLists this list, we go step by step through the cracked lists,
* executing the first, then syncing to the GPU and patching the argument buffer before continuing.
*
* At READING time we reserve a maxCount number of drawcalls and events, and later on when patching
* the argument buffer we fill in the parameters/names and remove any excess draws that weren't
* actually executed.
*
* During EXECUTING we read the patched argument buffer and execute any commands needed by hand on
* the CPU.
*/
void WrappedID3D12GraphicsCommandList::ReserveExecuteIndirect(ID3D12GraphicsCommandList *list,
ResourceId sig, UINT maxCount)
{
WrappedID3D12CommandSignature *comSig =
GetResourceManager()->GetLiveAs<WrappedID3D12CommandSignature>(sig);
const bool multidraw = (maxCount > 1 || comSig->sig.numDraws > 1);
const uint32_t sigSize = (uint32_t)comSig->sig.arguments.size();
RDCASSERT(m_State == READING);
BakedCmdListInfo &cmdInfo = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID];
for(uint32_t i = 0; i < maxCount; i++)
{
for(uint32_t a = 0; a < sigSize; a++)
{
const D3D12_INDIRECT_ARGUMENT_DESC &arg = comSig->sig.arguments[a];
switch(arg.Type)
{
case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH:
case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED:
case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW:
// add dummy event and drawcall
m_Cmd->AddEvent("");
m_Cmd->AddDrawcall(FetchDrawcall(), true);
cmdInfo.curEventID++;
break;
case D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW:
case D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW:
case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT:
case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW:
case D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW:
case D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW:
// add dummy event
m_Cmd->AddEvent("");
cmdInfo.curEventID++;
break;
default: RDCERR("Unexpected argument type! %d", arg.Type); break;
}
}
}
if(multidraw)
{
FetchDrawcall draw;
draw.name = "ExecuteIndirect()";
draw.flags = eDraw_PopMarker;
m_Cmd->AddDrawcall(draw, false);
}
else
{
cmdInfo.curEventID--;
}
}
void WrappedID3D12GraphicsCommandList::PatchExecuteIndirect(BakedCmdListInfo &info,
uint32_t executeIndex)
{
BakedCmdListInfo::ExecuteData &exec = info.executeEvents[executeIndex];
exec.patched = true;
WrappedID3D12CommandSignature *comSig =
GetResourceManager()->GetLiveAs<WrappedID3D12CommandSignature>(exec.sig);
uint32_t count = exec.maxCount;
if(exec.countBuf)
{
vector<byte> data;
m_pDevice->GetDebugManager()->GetBufferData(exec.countBuf, exec.countOffs, 4, data);
count = RDCMIN(count, *(uint32_t *)&data[0]);
}
exec.realCount = count;
const bool multidraw = (count > 1 || comSig->sig.numDraws > 1);
const uint32_t sigSize = (uint32_t)comSig->sig.arguments.size();
const bool gfx = comSig->sig.graphics;
const char *sigTypeString = gfx ? "Graphics" : "Compute";
// + 1 is because baseEvent refers to the marker before the commands
exec.lastEvent = exec.baseEvent + 1 + sigSize * count;
D3D12_RANGE range = {0, D3D12CommandData::m_IndirectSize};
byte *mapPtr = NULL;
exec.argBuf->Map(0, &range, (void **)&mapPtr);
std::vector<D3D12DrawcallTreeNode> &draws = info.draw->children;
size_t idx = 0;
uint32_t eid = exec.baseEvent;
// find the draw where our execute begins
for(; idx < draws.size(); idx++)
if(draws[idx].draw.eventID == eid)
break;
RDCASSERTMSG("Couldn't find base event draw!", idx < draws.size(), idx, draws.size());
// patch the name for the base drawcall
draws[idx].draw.name =
StringFormat::Fmt("ExecuteIndirect(maxCount %u, count <%u>)", exec.maxCount, count);
// if there's only one command running, remove its pushmarker flag
if(!multidraw)
draws[idx].draw.flags = (draws[idx].draw.flags & ~eDraw_PushMarker) | eDraw_SetMarker;
// move to the first actual draw of the commands
idx++;
eid++;
for(uint32_t i = 0; i < count; i++)
{
byte *data = mapPtr + exec.argOffs;
mapPtr += comSig->sig.ByteStride;
for(uint32_t a = 0; a < sigSize; a++)
{
const D3D12_INDIRECT_ARGUMENT_DESC &arg = comSig->sig.arguments[a];
switch(arg.Type)
{
case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW:
{
D3D12_DRAW_ARGUMENTS *args = (D3D12_DRAW_ARGUMENTS *)data;
data += sizeof(D3D12_DRAW_ARGUMENTS);
FetchDrawcall &draw = draws[idx].draw;
draw.numIndices = args->VertexCountPerInstance;
draw.numInstances = args->InstanceCount;
draw.vertexOffset = args->StartVertexLocation;
draw.instanceOffset = args->StartInstanceLocation;
draw.flags |= eDraw_Drawcall | eDraw_Instanced | eDraw_Indirect;
draw.name = StringFormat::Fmt("[%u] arg%u: IndirectDraw(<%u, %u>)", i, a, draw.numIndices,
draw.numInstances);
// if this is the first draw of the indirect, we could have picked up previous
// non-indirect events in this drawcall, so the EID will be higher than we expect. Just
// assign the draw's EID
eid = draw.eventID;
string eventStr = draw.name;
// a bit of a hack, but manually construct serialised event data for this command
eventStr += "\n{\n";
eventStr +=
StringFormat::Fmt("\tVertexCountPerInstance: %u\n", args->VertexCountPerInstance);
eventStr += StringFormat::Fmt("\tInstanceCount: %u\n", args->InstanceCount);
eventStr += StringFormat::Fmt("\tStartVertexLocation: %u\n", args->StartVertexLocation);
eventStr += StringFormat::Fmt("\tStartInstanceLocation: %u\n", args->StartInstanceLocation);
eventStr += "}\n";
FetchAPIEvent &ev = draw.events[draw.events.count - 1];
ev.eventDesc = eventStr;
RDCASSERT(ev.eventID == eid);
m_Cmd->AddUsage(draws[idx]);
// advance
idx++;
eid++;
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED:
{
D3D12_DRAW_INDEXED_ARGUMENTS *args = (D3D12_DRAW_INDEXED_ARGUMENTS *)data;
data += sizeof(D3D12_DRAW_INDEXED_ARGUMENTS);
FetchDrawcall &draw = draws[idx].draw;
draw.numIndices = args->IndexCountPerInstance;
draw.numInstances = args->InstanceCount;
draw.baseVertex = args->BaseVertexLocation;
draw.vertexOffset = args->StartIndexLocation;
draw.instanceOffset = args->StartInstanceLocation;
draw.flags |= eDraw_Drawcall | eDraw_Instanced | eDraw_UseIBuffer | eDraw_Indirect;
draw.name = StringFormat::Fmt("[%u] arg%u: IndirectDrawIndexed(<%u, %u>)", i, a,
draw.numIndices, draw.numInstances);
// if this is the first draw of the indirect, we could have picked up previous
// non-indirect events in this drawcall, so the EID will be higher than we expect. Just
// assign the draw's EID
eid = draw.eventID;
string eventStr = draw.name;
// a bit of a hack, but manually construct serialised event data for this command
eventStr += "\n{\n";
eventStr += StringFormat::Fmt("\tIndexCountPerInstance: %u\n", args->IndexCountPerInstance);
eventStr += StringFormat::Fmt("\tInstanceCount: %u\n", args->InstanceCount);
eventStr += StringFormat::Fmt("\tBaseVertexLocation: %u\n", args->BaseVertexLocation);
eventStr += StringFormat::Fmt("\tStartIndexLocation: %u\n", args->StartIndexLocation);
eventStr += StringFormat::Fmt("\tStartInstanceLocation: %u\n", args->StartInstanceLocation);
eventStr += "}\n";
FetchAPIEvent &ev = draw.events[draw.events.count - 1];
ev.eventDesc = eventStr;
RDCASSERT(ev.eventID == eid);
m_Cmd->AddUsage(draws[idx]);
// advance
idx++;
eid++;
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH:
{
D3D12_DISPATCH_ARGUMENTS *args = (D3D12_DISPATCH_ARGUMENTS *)data;
data += sizeof(D3D12_DISPATCH_ARGUMENTS);
FetchDrawcall &draw = draws[idx].draw;
draw.dispatchDimension[0] = args->ThreadGroupCountX;
draw.dispatchDimension[1] = args->ThreadGroupCountY;
draw.dispatchDimension[2] = args->ThreadGroupCountZ;
draw.flags |= eDraw_Dispatch | eDraw_Indirect;
draw.name = StringFormat::Fmt("[%u] arg%u: IndirectDispatch(<%u, %u, %u>)", i, a,
draw.dispatchDimension[0], draw.dispatchDimension[1],
draw.dispatchDimension[2]);
// if this is the first draw of the indirect, we could have picked up previous
// non-indirect events in this drawcall, so the EID will be higher than we expect. Just
// assign the draw's EID
eid = draw.eventID;
string eventStr = draw.name;
// a bit of a hack, but manually construct serialised event data for this command
eventStr += "\n{\n";
eventStr += StringFormat::Fmt("\tThreadGroupCountX: %u\n", args->ThreadGroupCountX);
eventStr += StringFormat::Fmt("\tThreadGroupCountY: %u\n", args->ThreadGroupCountY);
eventStr += StringFormat::Fmt("\tThreadGroupCountZ: %u\n", args->ThreadGroupCountZ);
eventStr += "}\n";
FetchAPIEvent &ev = draw.events[draw.events.count - 1];
ev.eventDesc = eventStr;
RDCASSERT(ev.eventID == eid);
m_Cmd->AddUsage(draws[idx]);
// advance
idx++;
eid++;
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT:
{
size_t argSize = sizeof(uint32_t) * arg.Constant.Num32BitValuesToSet;
uint32_t *values = (uint32_t *)data;
data += argSize;
string name = StringFormat::Fmt("[%u] arg%u: IndirectSet%sRoot32bitConstants()\n", i, a,
sigTypeString);
// a bit of a hack, but manually construct serialised event data for this command
name += "{\n";
name += StringFormat::Fmt("\tConstant.RootParameterIndex: %u\n",
arg.Constant.RootParameterIndex);
name += StringFormat::Fmt("\tConstant.DestOffsetIn32BitValues: %u\n",
arg.Constant.DestOffsetIn32BitValues);
name += StringFormat::Fmt("\tConstant.Num32BitValuesToSet: %u\n",
arg.Constant.Num32BitValuesToSet);
for(uint32_t val = 0; val < arg.Constant.Num32BitValuesToSet; val++)
name += StringFormat::Fmt("\tvalues[%u]: %u\n", val, values[val]);
name += "}\n";
FetchDrawcall &draw = draws[idx].draw;
FetchAPIEvent *ev = NULL;
for(int32_t e = 0; e < draw.events.count; e++)
{
if(draw.events[e].eventID == eid)
{
ev = &draw.events[e];
break;
}
}
if(ev)
ev->eventDesc = name;
// advance only the EID, since we're still in the same draw
eid++;
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW:
{
D3D12_VERTEX_BUFFER_VIEW *vb = (D3D12_VERTEX_BUFFER_VIEW *)data;
data += sizeof(D3D12_VERTEX_BUFFER_VIEW);
ResourceId id;
uint64_t offs = 0;
m_pDevice->GetResIDFromAddr(vb->BufferLocation, id, offs);
ID3D12Resource *res = GetResourceManager()->GetLiveAs<ID3D12Resource>(id);
RDCASSERT(res);
if(res)
vb->BufferLocation = res->GetGPUVirtualAddress() + offs;
string name = StringFormat::Fmt("[%u] arg%u: IndirectIASetVertexBuffers()\n", i, a);
// a bit of a hack, but manually construct serialised event data for this command
name += "{\n";
name += StringFormat::Fmt("\tVertexBuffer.Slot: %u\n", arg.VertexBuffer.Slot);
name += StringFormat::Fmt("\tView.BufferLocation: %llu\n", id);
name += StringFormat::Fmt("\tView.BufferLocation: %llu\n", offs);
name += StringFormat::Fmt("\tView.SizeInBytes: %u\n", vb->SizeInBytes);
name += StringFormat::Fmt("\tView.StrideInBytes: %u\n", vb->StrideInBytes);
name += "}\n";
FetchDrawcall &draw = draws[idx].draw;
FetchAPIEvent *ev = NULL;
for(int32_t e = 0; e < draw.events.count; e++)
{
if(draw.events[e].eventID == eid)
{
ev = &draw.events[e];
break;
}
}
if(ev)
ev->eventDesc = name;
// advance only the EID, since we're still in the same draw
eid++;
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW:
{
D3D12_INDEX_BUFFER_VIEW *ib = (D3D12_INDEX_BUFFER_VIEW *)data;
data += sizeof(D3D12_INDEX_BUFFER_VIEW);
ResourceId id;
uint64_t offs = 0;
m_pDevice->GetResIDFromAddr(ib->BufferLocation, id, offs);
ID3D12Resource *res = GetResourceManager()->GetLiveAs<ID3D12Resource>(id);
RDCASSERT(res);
if(res)
ib->BufferLocation = res->GetGPUVirtualAddress() + offs;
string name = StringFormat::Fmt("[%u] arg%u: IndirectIASetIndexBuffer()\n", i, a);
// a bit of a hack, but manually construct serialised event data for this command
name += "{\n";
name += StringFormat::Fmt("\tView.BufferLocation: %llu\n", id);
name += StringFormat::Fmt("\tView.BufferLocation: %llu\n", offs);
name += StringFormat::Fmt("\tView.SizeInBytes: %u\n", ib->SizeInBytes);
name += StringFormat::Fmt("\tView.Format: %s\n", ToStr::Get(ib->Format).c_str());
name += "}\n";
FetchDrawcall &draw = draws[idx].draw;
FetchAPIEvent *ev = NULL;
for(int32_t e = 0; e < draw.events.count; e++)
{
if(draw.events[e].eventID == eid)
{
ev = &draw.events[e];
break;
}
}
if(ev)
ev->eventDesc = name;
// advance only the EID, since we're still in the same draw
eid++;
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW:
case D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW:
case D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW:
{
D3D12_GPU_VIRTUAL_ADDRESS *addr = (D3D12_GPU_VIRTUAL_ADDRESS *)data;
data += sizeof(D3D12_GPU_VIRTUAL_ADDRESS);
ResourceId id;
uint64_t offs = 0;
m_pDevice->GetResIDFromAddr(*addr, id, offs);
ID3D12Resource *res = GetResourceManager()->GetLiveAs<ID3D12Resource>(id);
RDCASSERT(res);
if(res)
*addr = res->GetGPUVirtualAddress() + offs;
const uint32_t rootIdx = arg.Constant.RootParameterIndex;
const char *argTypeString = "Unknown";
if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW)
argTypeString = "ConstantBuffer";
else if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW)
argTypeString = "ShaderResource";
else if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW)
argTypeString = "UnorderedAccess";
else
RDCERR("Unexpected argument type! %d", arg.Type);
string name = StringFormat::Fmt("[%u] arg%u: IndirectSet%sRoot%sView()\n", i, a,
sigTypeString, argTypeString);
// a bit of a hack, but manually construct serialised event data for this command
name += "{\n";
name += StringFormat::Fmt("\tView.RootParameterIndex: %u\n", rootIdx);
name += StringFormat::Fmt("\tBufferLocation: %llu\n", id);
name += StringFormat::Fmt("\tBufferLocation_Offset: %llu\n", offs);
name += "}\n";
FetchDrawcall &draw = draws[idx].draw;
FetchAPIEvent *ev = NULL;
for(int32_t e = 0; e < draw.events.count; e++)
{
if(draw.events[e].eventID == eid)
{
ev = &draw.events[e];
break;
}
}
if(ev)
ev->eventDesc = name;
// advance only the EID, since we're still in the same draw
eid++;
break;
}
default: RDCERR("Unexpected argument type! %d", arg.Type); break;
}
}
}
exec.argBuf->Unmap(0, &range);
// remove excesss draws if count < maxCount
if(count < exec.maxCount)
{
uint32_t shiftEID = (exec.maxCount - count) * sigSize;
uint32_t lastEID = exec.baseEvent + 1 + sigSize * exec.maxCount;
uint32_t shiftDrawID = 0;
while(idx < draws.size() && draws[idx].draw.eventID < lastEID)
{
draws.erase(draws.begin() + idx);
shiftDrawID++;
}
// shift all subsequent EIDs and drawcall IDs so they're contiguous
info.ShiftForRemoved(shiftDrawID, shiftEID, idx);
}
if(!multidraw && exec.maxCount > 1)
{
// remove pop event
draws.erase(draws.begin() + idx);
info.ShiftForRemoved(1, 1, idx);
}
}
void WrappedID3D12GraphicsCommandList::ReplayExecuteIndirect(ID3D12GraphicsCommandList *list,
BakedCmdListInfo &info)
{
BakedCmdListInfo &cmdInfo = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID];
size_t executeIndex = info.executeEvents.size();
for(size_t i = 0; i < info.executeEvents.size(); i++)
{
if(info.executeEvents[i].baseEvent <= cmdInfo.curEventID &&
cmdInfo.curEventID < info.executeEvents[i].lastEvent)
{
executeIndex = i;
break;
}
}
if(executeIndex >= info.executeEvents.size())
{
RDCERR("Couldn't find ExecuteIndirect to replay!");
return;
}
BakedCmdListInfo::ExecuteData &exec = info.executeEvents[executeIndex];
WrappedID3D12CommandSignature *comSig =
GetResourceManager()->GetLiveAs<WrappedID3D12CommandSignature>(exec.sig);
uint32_t count = exec.realCount;
uint32_t origCount = exec.realCount;
const bool multidraw = (count > 1 || comSig->sig.numDraws > 1);
vector<byte> data;
m_pDevice->GetDebugManager()->GetBufferData(exec.argBuf, exec.argOffs,
count * comSig->sig.ByteStride, data);
byte *dataPtr = &data[0];
const bool gfx = comSig->sig.graphics;
const uint32_t sigSize = (uint32_t)comSig->sig.arguments.size();
vector<D3D12RenderState::SignatureElement> &sigelems =
gfx ? m_Cmd->m_RenderState.graphics.sigelems : m_Cmd->m_RenderState.compute.sigelems;
// while executing, decide where to start and stop. We do this by modifying the max count and
// noting which arg we should start working, and which arg in the last execute we should get up
// to. Since we don't actually replay as indirect executes to save on having to allocate and
// manage indirect buffers across the command list, we can just skip commands we don't want to
// execute.
uint32_t firstCommand = 0;
uint32_t firstArg = 0;
uint32_t lastArg = ~0U;
{
uint32_t curEID = m_Cmd->m_RootEventID;
if(m_Cmd->m_FirstEventID <= 1)
{
curEID = cmdInfo.curEventID;
if(m_Cmd->m_Partial[D3D12CommandData::Primary].partialParent == m_Cmd->m_LastCmdListID)
curEID += m_Cmd->m_Partial[D3D12CommandData::Primary].baseEvent;
else if(m_Cmd->m_Partial[D3D12CommandData::Secondary].partialParent == m_Cmd->m_LastCmdListID)
curEID += m_Cmd->m_Partial[D3D12CommandData::Secondary].baseEvent;
}
D3D12CommandData::DrawcallUse use(m_Cmd->m_CurChunkOffset, 0);
auto it = std::lower_bound(m_Cmd->m_DrawcallUses.begin(), m_Cmd->m_DrawcallUses.end(), use);
RDCASSERT(it != m_Cmd->m_DrawcallUses.end());
uint32_t baseEventID = it->eventID;
// TODO when re-recording all, we should submit every drawcall individually
if(m_Cmd->m_DrawcallCallback && m_Cmd->m_DrawcallCallback->RecordAllCmds())
{
firstCommand = 0;
firstArg = 0;
lastArg = ~0U;
}
// To add the execute, we made an event N that is the 'parent' marker, then
// N+1, N+2, N+3, ... for each of the arguments. If the first sub-argument is selected
// then we'll replay up to N but not N+1, so just do nothing - we DON'T want to draw
// the first sub-draw in that range.
else if(m_Cmd->m_LastEventID > baseEventID)
{
if(m_Cmd->m_FirstEventID <= 1)
{
// one event per arg, and N args per command
uint32_t numArgs = m_Cmd->m_LastEventID - baseEventID;
// play all commands up to the one we want
firstCommand = 0;
// how many commands?
uint32_t numCmds = numArgs / sigSize + 1;
count = RDCMIN(count, numCmds);
// play all args in the fnial commmad up to the one we want
firstArg = 0;
// how many args in the final command
if(numCmds > count)
lastArg = ~0U;
else
lastArg = numArgs % sigSize;
}
else
{
// note we'll never be asked to do e.g. 3rd-7th commands of an execute. Only ever 0th-nth or
// a single argument.
uint32_t argIdx = (curEID - baseEventID - 1);
firstCommand = argIdx / sigSize;
count = RDCMIN(count, firstCommand + 1);
firstArg = argIdx % sigSize;
lastArg = firstArg + 1;
}
}
else
{
// don't do anything, we've selected the base event
count = 0;
}
}
bool executing = true;
for(uint32_t i = 0; i < count; i++)
{
byte *src = dataPtr;
dataPtr += comSig->sig.ByteStride;
// don't have to do an upper bound on commands, count was modified
if(i < firstCommand)
continue;
for(uint32_t a = 0; a < sigSize; a++)
{
const D3D12_INDIRECT_ARGUMENT_DESC &arg = comSig->sig.arguments[a];
// only execute things while we're in the range we want
// on the last command count, stop executing once we're past the last arg.
if(i == count - 1)
executing = (a >= firstArg && a < lastArg);
switch(arg.Type)
{
case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW:
{
D3D12_DRAW_ARGUMENTS *args = (D3D12_DRAW_ARGUMENTS *)src;
src += sizeof(D3D12_DRAW_ARGUMENTS);
if(executing)
list->DrawInstanced(args->VertexCountPerInstance, args->InstanceCount,
args->StartVertexLocation, args->StartInstanceLocation);
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED:
{
D3D12_DRAW_INDEXED_ARGUMENTS *args = (D3D12_DRAW_INDEXED_ARGUMENTS *)src;
src += sizeof(D3D12_DRAW_INDEXED_ARGUMENTS);
if(executing)
list->DrawIndexedInstanced(args->IndexCountPerInstance, args->InstanceCount,
args->StartIndexLocation, args->BaseVertexLocation,
args->StartInstanceLocation);
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH:
{
D3D12_DISPATCH_ARGUMENTS *args = (D3D12_DISPATCH_ARGUMENTS *)src;
src += sizeof(D3D12_DISPATCH_ARGUMENTS);
if(executing)
list->Dispatch(args->ThreadGroupCountX, args->ThreadGroupCountY, args->ThreadGroupCountZ);
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT:
{
size_t argSize = sizeof(uint32_t) * arg.Constant.Num32BitValuesToSet;
uint32_t *values = (uint32_t *)src;
src += argSize;
if(executing)
{
if(sigelems.size() < arg.Constant.RootParameterIndex + 1)
sigelems.resize(arg.Constant.RootParameterIndex + 1);
sigelems[arg.Constant.RootParameterIndex].SetConstants(
arg.Constant.Num32BitValuesToSet, values, arg.Constant.DestOffsetIn32BitValues);
if(gfx)
list->SetGraphicsRoot32BitConstants(arg.Constant.RootParameterIndex,
arg.Constant.Num32BitValuesToSet, values,
arg.Constant.DestOffsetIn32BitValues);
else
list->SetComputeRoot32BitConstants(arg.Constant.RootParameterIndex,
arg.Constant.Num32BitValuesToSet, values,
arg.Constant.DestOffsetIn32BitValues);
}
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW:
{
D3D12_VERTEX_BUFFER_VIEW *srcVB = (D3D12_VERTEX_BUFFER_VIEW *)src;
src += sizeof(D3D12_VERTEX_BUFFER_VIEW);
ResourceId id;
uint64_t offs = 0;
WrappedID3D12Resource::GetResIDFromAddr(srcVB->BufferLocation, id, offs);
RDCASSERT(id != ResourceId());
if(executing)
{
if(m_Cmd->m_RenderState.vbuffers.size() < arg.VertexBuffer.Slot + 1)
m_Cmd->m_RenderState.vbuffers.resize(arg.VertexBuffer.Slot + 1);
m_Cmd->m_RenderState.vbuffers[arg.VertexBuffer.Slot].buf = id;
m_Cmd->m_RenderState.vbuffers[arg.VertexBuffer.Slot].offs = offs;
m_Cmd->m_RenderState.vbuffers[arg.VertexBuffer.Slot].size = srcVB->SizeInBytes;
m_Cmd->m_RenderState.vbuffers[arg.VertexBuffer.Slot].stride = srcVB->StrideInBytes;
}
if(executing && id != ResourceId())
list->IASetVertexBuffers(arg.VertexBuffer.Slot, 1, srcVB);
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW:
{
D3D12_INDEX_BUFFER_VIEW *srcIB = (D3D12_INDEX_BUFFER_VIEW *)src;
src += sizeof(D3D12_INDEX_BUFFER_VIEW);
ResourceId id;
uint64_t offs = 0;
WrappedID3D12Resource::GetResIDFromAddr(srcIB->BufferLocation, id, offs);
RDCASSERT(id != ResourceId());
if(executing)
{
m_Cmd->m_RenderState.ibuffer.buf = id;
m_Cmd->m_RenderState.ibuffer.offs = offs;
m_Cmd->m_RenderState.ibuffer.size = srcIB->SizeInBytes;
m_Cmd->m_RenderState.ibuffer.bytewidth = (srcIB->Format == DXGI_FORMAT_R32_UINT ? 4 : 2);
}
if(executing && id != ResourceId())
list->IASetIndexBuffer(srcIB);
break;
}
case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW:
case D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW:
case D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW:
{
D3D12_GPU_VIRTUAL_ADDRESS *srcAddr = (D3D12_GPU_VIRTUAL_ADDRESS *)src;
src += sizeof(D3D12_GPU_VIRTUAL_ADDRESS);
ResourceId id;
uint64_t offs = 0;
WrappedID3D12Resource::GetResIDFromAddr(*srcAddr, id, offs);
RDCASSERT(id != ResourceId());
const uint32_t rootIdx = arg.Constant.RootParameterIndex;
SignatureElementType elemType = eRootUnknown;
if(gfx)
{
if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW)
{
elemType = eRootCBV;
if(executing && id != ResourceId())
list->SetGraphicsRootConstantBufferView(rootIdx, *srcAddr);
}
else if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW)
{
elemType = eRootSRV;
if(executing && id != ResourceId())
list->SetGraphicsRootShaderResourceView(rootIdx, *srcAddr);
}
else if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW)
{
elemType = eRootUAV;
if(executing && id != ResourceId())
list->SetGraphicsRootUnorderedAccessView(rootIdx, *srcAddr);
}
else
{
RDCERR("Unexpected argument type! %d", arg.Type);
}
}
else
{
if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW)
{
elemType = eRootCBV;
if(executing && id != ResourceId())
list->SetComputeRootConstantBufferView(rootIdx, *srcAddr);
}
else if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW)
{
elemType = eRootSRV;
if(executing && id != ResourceId())
list->SetComputeRootShaderResourceView(rootIdx, *srcAddr);
}
else if(arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW)
{
elemType = eRootUAV;
if(executing && id != ResourceId())
list->SetComputeRootUnorderedAccessView(rootIdx, *srcAddr);
}
else
{
RDCERR("Unexpected argument type! %d", arg.Type);
}
}
if(executing)
{
if(sigelems.size() < rootIdx + 1)
sigelems.resize(rootIdx + 1);
sigelems[rootIdx] = D3D12RenderState::SignatureElement(elemType, id, offs);
}
break;
}
default: RDCERR("Unexpected argument type! %d", arg.Type); break;
}
}
}
// skip past all the events
cmdInfo.curEventID += origCount * sigSize;
// skip past the pop event
if(multidraw)
cmdInfo.curEventID++;
}
bool WrappedID3D12GraphicsCommandList::Serialise_ExecuteIndirect(
ID3D12CommandSignature *pCommandSignature, UINT MaxCommandCount, ID3D12Resource *pArgumentBuffer,
UINT64 ArgumentBufferOffset, ID3D12Resource *pCountBuffer, UINT64 CountBufferOffset)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, sig, GetResID(pCommandSignature));
SERIALISE_ELEMENT(UINT, maxCount, MaxCommandCount);
SERIALISE_ELEMENT(ResourceId, arg, GetResID(pArgumentBuffer));
SERIALISE_ELEMENT(UINT64, argOffs, ArgumentBufferOffset);
SERIALISE_ELEMENT(ResourceId, countbuf, GetResID(pCountBuffer));
SERIALISE_ELEMENT(UINT64, countOffs, CountBufferOffset);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
BakedCmdListInfo &bakeInfo = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID];
ReplayExecuteIndirect(Unwrap(list), bakeInfo);
}
}
else if(m_State == READING)
{
const string desc = m_pSerialiser->GetDebugStr();
WrappedID3D12CommandSignature *comSig =
GetResourceManager()->GetLiveAs<WrappedID3D12CommandSignature>(sig);
ID3D12Resource *argBuf = GetResourceManager()->GetLiveAs<ID3D12Resource>(arg);
ID3D12Resource *countBuf = GetResourceManager()->GetLiveAs<ID3D12Resource>(countbuf);
m_Cmd->AddEvent(desc);
FetchDrawcall draw;
draw.name = "ExecuteIndirect";
draw.flags |= eDraw_MultiDraw;
if(maxCount > 1 || comSig->sig.numDraws > 1)
draw.flags |= eDraw_PushMarker;
else
draw.flags |= eDraw_SetMarker;
// this drawcall needs an event to anchor its file offset. This is a bit of a hack,
// but a proper solution for handling 'fake' events that don't correspond to actual
// events in the file, or duplicates, is overkill.
create_array(draw.events, 1);
draw.events[0] = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].curEvents.back();
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].curEvents.pop_back();
m_Cmd->AddDrawcall(draw, false);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
drawNode.resourceUsage.push_back(std::make_pair(
GetResourceManager()->GetLiveID(arg), EventUsage(drawNode.draw.eventID, eUsage_Indirect)));
drawNode.resourceUsage.push_back(
std::make_pair(GetResourceManager()->GetLiveID(countbuf),
EventUsage(drawNode.draw.eventID, eUsage_Indirect)));
ID3D12GraphicsCommandList *cracked = GetCrackedList(CommandList);
BakedCmdListInfo::ExecuteData exec;
exec.baseEvent = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].curEventID;
exec.sig = sig;
exec.maxCount = maxCount;
exec.countBuf = countBuf;
exec.countOffs = countOffs;
// allocate space for patched indirect buffer
m_Cmd->GetIndirectBuffer(comSig->sig.ByteStride * maxCount, &exec.argBuf, &exec.argOffs);
// transition buffer to COPY_SOURCE/COPY_DEST, copy, and back to INDIRECT_ARG
D3D12_RESOURCE_BARRIER barriers[2] = {};
barriers[0].Transition.pResource = Unwrap(argBuf);
barriers[0].Transition.StateBefore = D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT;
barriers[0].Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE;
barriers[1].Transition.pResource = Unwrap(exec.argBuf);
barriers[1].Transition.StateBefore = D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT;
barriers[1].Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST;
cracked->ResourceBarrier(2, barriers);
cracked->CopyBufferRegion(Unwrap(exec.argBuf), exec.argOffs, Unwrap(argBuf), argOffs,
comSig->sig.ByteStride * maxCount);
std::swap(barriers[0].Transition.StateBefore, barriers[0].Transition.StateAfter);
std::swap(barriers[1].Transition.StateBefore, barriers[1].Transition.StateAfter);
cracked->ResourceBarrier(2, barriers);
cracked->Close();
// open new cracked list and re-apply the current state
{
D3D12_COMMAND_LIST_TYPE type = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].type;
UINT nodeMask = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].nodeMask;
ResourceId allocid = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].allocator;
ID3D12CommandAllocator *allocator = m_Cmd->m_CrackedAllocators[allocid];
ID3D12GraphicsCommandList *list = NULL;
m_pDevice->CreateCommandList(nodeMask, type, allocator, NULL,
__uuidof(ID3D12GraphicsCommandList), (void **)&list);
m_Cmd->m_BakedCmdListInfo[CommandList].crackedLists.push_back(list);
m_Cmd->m_BakedCmdListInfo[CommandList].state.ApplyState(list);
}
// perform indirect draw, but from patched buffer. It will be patched between the above list and
// this list during the first execution of the command list
GetList(CommandList)
->ExecuteIndirect(comSig->GetReal(), maxCount, Unwrap(exec.argBuf), exec.argOffs,
Unwrap(countBuf), countOffs);
GetCrackedList(CommandList)
->ExecuteIndirect(comSig->GetReal(), maxCount, Unwrap(exec.argBuf), exec.argOffs,
Unwrap(countBuf), countOffs);
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].executeEvents.push_back(exec);
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].curEventID++;
// reserve the right number of drawcalls and events, to later be patched up with the actual
// details
ReserveExecuteIndirect(GetList(CommandList), sig, maxCount);
}
return true;
}
void WrappedID3D12GraphicsCommandList::ExecuteIndirect(ID3D12CommandSignature *pCommandSignature,
UINT MaxCommandCount,
ID3D12Resource *pArgumentBuffer,
UINT64 ArgumentBufferOffset,
ID3D12Resource *pCountBuffer,
UINT64 CountBufferOffset)
{
m_pReal->ExecuteIndirect(Unwrap(pCommandSignature), MaxCommandCount, Unwrap(pArgumentBuffer),
ArgumentBufferOffset, Unwrap(pCountBuffer), CountBufferOffset);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(EXEC_INDIRECT);
Serialise_ExecuteIndirect(pCommandSignature, MaxCommandCount, pArgumentBuffer,
ArgumentBufferOffset, pCountBuffer, CountBufferOffset);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->ContainsExecuteIndirect = true;
m_ListRecord->MarkResourceFrameReferenced(GetResID(pCommandSignature), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pArgumentBuffer), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pCountBuffer), eFrameRef_Read);
}
}
#pragma endregion Draws
#pragma region Clears
bool WrappedID3D12GraphicsCommandList::Serialise_ClearDepthStencilView(
D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, D3D12_CLEAR_FLAGS ClearFlags, FLOAT Depth,
UINT8 Stencil, UINT NumRects, const D3D12_RECT *pRects)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(PortableHandle, dsv, ToPortableHandle(DepthStencilView));
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
SERIALISE_ELEMENT(D3D12_CLEAR_FLAGS, f, ClearFlags);
SERIALISE_ELEMENT(FLOAT, d, Depth);
SERIALISE_ELEMENT(UINT8, s, Stencil);
SERIALISE_ELEMENT(UINT, num, NumRects);
SERIALISE_ELEMENT_ARR(D3D12_RECT, rects, pRects, num);
if(m_State == EXECUTING)
{
DepthStencilView = CPUHandleFromPortableHandle(GetResourceManager(), dsv);
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->ClearDepthStencilView(DepthStencilView, f, d, s, num, rects);
}
}
else if(m_State == READING)
{
DepthStencilView = CPUHandleFromPortableHandle(GetResourceManager(), dsv);
GetList(CommandList)->ClearDepthStencilView(DepthStencilView, f, d, s, num, rects);
GetCrackedList(CommandList)->ClearDepthStencilView(DepthStencilView, f, d, s, num, rects);
const string desc = m_pSerialiser->GetDebugStr();
{
m_Cmd->AddEvent(desc);
string name = "ClearDepthStencilView(" + ToStr::Get(d) + "," + ToStr::Get(s) + ")";
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_Clear | eDraw_ClearDepthStencil;
m_Cmd->AddDrawcall(draw, true);
D3D12Descriptor *descriptor = DescriptorFromPortableHandle(GetResourceManager(), dsv);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
drawNode.resourceUsage.push_back(std::make_pair(
GetResID(descriptor->nonsamp.resource), EventUsage(drawNode.draw.eventID, eUsage_Clear)));
}
}
SAFE_DELETE_ARRAY(rects);
return true;
}
void WrappedID3D12GraphicsCommandList::ClearDepthStencilView(
D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, D3D12_CLEAR_FLAGS ClearFlags, FLOAT Depth,
UINT8 Stencil, UINT NumRects, const D3D12_RECT *pRects)
{
m_pReal->ClearDepthStencilView(Unwrap(DepthStencilView), ClearFlags, Depth, Stencil, NumRects,
pRects);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(CLEAR_DSV);
Serialise_ClearDepthStencilView(DepthStencilView, ClearFlags, Depth, Stencil, NumRects, pRects);
m_ListRecord->AddChunk(scope.Get());
{
D3D12Descriptor *desc = GetWrapped(DepthStencilView);
m_ListRecord->MarkResourceFrameReferenced(desc->nonsamp.heap->GetResourceID(), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(desc->nonsamp.resource), eFrameRef_Read);
}
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_ClearRenderTargetView(
D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, const FLOAT ColorRGBA[4], UINT NumRects,
const D3D12_RECT *pRects)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(PortableHandle, rtv, ToPortableHandle(RenderTargetView));
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
float Color[4] = {0};
if(m_State >= WRITING)
memcpy(Color, ColorRGBA, sizeof(float) * 4);
m_pSerialiser->SerialisePODArray<4>("ColorRGBA", Color);
SERIALISE_ELEMENT(UINT, num, NumRects);
SERIALISE_ELEMENT_ARR(D3D12_RECT, rects, pRects, num);
if(m_State == EXECUTING)
{
RenderTargetView = CPUHandleFromPortableHandle(GetResourceManager(), rtv);
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->ClearRenderTargetView(RenderTargetView, Color, num, rects);
}
}
else if(m_State == READING)
{
RenderTargetView = CPUHandleFromPortableHandle(GetResourceManager(), rtv);
GetList(CommandList)->ClearRenderTargetView(RenderTargetView, Color, num, rects);
GetCrackedList(CommandList)->ClearRenderTargetView(RenderTargetView, Color, num, rects);
const string desc = m_pSerialiser->GetDebugStr();
{
m_Cmd->AddEvent(desc);
string name = "ClearRenderTargetView(" + ToStr::Get(Color[0]) + "," + ToStr::Get(Color[1]) +
"," + ToStr::Get(Color[2]) + "," + ToStr::Get(Color[3]) + ")";
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_Clear | eDraw_ClearColour;
m_Cmd->AddDrawcall(draw, true);
D3D12Descriptor *descriptor = DescriptorFromPortableHandle(GetResourceManager(), rtv);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
drawNode.resourceUsage.push_back(std::make_pair(
GetResID(descriptor->nonsamp.resource), EventUsage(drawNode.draw.eventID, eUsage_Clear)));
}
}
SAFE_DELETE_ARRAY(rects);
return true;
}
void WrappedID3D12GraphicsCommandList::ClearRenderTargetView(
D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, const FLOAT ColorRGBA[4], UINT NumRects,
const D3D12_RECT *pRects)
{
m_pReal->ClearRenderTargetView(Unwrap(RenderTargetView), ColorRGBA, NumRects, pRects);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(CLEAR_RTV);
Serialise_ClearRenderTargetView(RenderTargetView, ColorRGBA, NumRects, pRects);
m_ListRecord->AddChunk(scope.Get());
{
D3D12Descriptor *desc = GetWrapped(RenderTargetView);
m_ListRecord->MarkResourceFrameReferenced(desc->nonsamp.heap->GetResourceID(), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(desc->nonsamp.resource), eFrameRef_Read);
}
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_ClearUnorderedAccessViewUint(
D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle,
ID3D12Resource *pResource, const UINT Values[4], UINT NumRects, const D3D12_RECT *pRects)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(PortableHandle, gpuhandle, ToPortableHandle(ViewGPUHandleInCurrentHeap));
SERIALISE_ELEMENT(PortableHandle, cpuhandle, ToPortableHandle(ViewCPUHandle));
SERIALISE_ELEMENT(ResourceId, res, GetResID(pResource));
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
UINT vals[4] = {0};
if(m_State >= WRITING)
memcpy(vals, Values, sizeof(UINT) * 4);
m_pSerialiser->SerialisePODArray<4>("Values", vals);
SERIALISE_ELEMENT(UINT, num, NumRects);
SERIALISE_ELEMENT_ARR(D3D12_RECT, rects, pRects, num);
if(m_State == EXECUTING)
{
ViewGPUHandleInCurrentHeap = GPUHandleFromPortableHandle(GetResourceManager(), gpuhandle);
ViewCPUHandle = CPUHandleFromPortableHandle(GetResourceManager(), cpuhandle);
pResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(res);
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap, ViewCPUHandle,
Unwrap(pResource), vals, num, rects);
}
}
else if(m_State == READING)
{
ViewGPUHandleInCurrentHeap = GPUHandleFromPortableHandle(GetResourceManager(), gpuhandle);
ViewCPUHandle = CPUHandleFromPortableHandle(GetResourceManager(), cpuhandle);
pResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(res);
GetList(CommandList)
->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap, ViewCPUHandle, Unwrap(pResource),
vals, num, rects);
GetCrackedList(CommandList)
->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap, ViewCPUHandle, Unwrap(pResource),
vals, num, rects);
const string desc = m_pSerialiser->GetDebugStr();
{
m_Cmd->AddEvent(desc);
string name = "ClearUnorderedAccessViewUint(" + ToStr::Get(vals[0]) + "," +
ToStr::Get(vals[1]) + "," + ToStr::Get(vals[2]) + "," + ToStr::Get(vals[3]) +
")";
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_Clear;
m_Cmd->AddDrawcall(draw, true);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
drawNode.resourceUsage.push_back(
std::make_pair(GetResID(pResource), EventUsage(drawNode.draw.eventID, eUsage_Clear)));
}
}
SAFE_DELETE_ARRAY(rects);
return true;
}
void WrappedID3D12GraphicsCommandList::ClearUnorderedAccessViewUint(
D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle,
ID3D12Resource *pResource, const UINT Values[4], UINT NumRects, const D3D12_RECT *pRects)
{
m_pReal->ClearUnorderedAccessViewUint(Unwrap(ViewGPUHandleInCurrentHeap), Unwrap(ViewCPUHandle),
Unwrap(pResource), Values, NumRects, pRects);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(CLEAR_UAV_INT);
Serialise_ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap, ViewCPUHandle, pResource,
Values, NumRects, pRects);
m_ListRecord->AddChunk(scope.Get());
{
D3D12Descriptor *desc = GetWrapped(ViewGPUHandleInCurrentHeap);
m_ListRecord->MarkResourceFrameReferenced(desc->nonsamp.heap->GetResourceID(), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(desc->nonsamp.resource), eFrameRef_Write);
desc = GetWrapped(ViewCPUHandle);
m_ListRecord->MarkResourceFrameReferenced(desc->nonsamp.heap->GetResourceID(), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(desc->nonsamp.resource), eFrameRef_Write);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pResource), eFrameRef_Write);
}
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_ClearUnorderedAccessViewFloat(
D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle,
ID3D12Resource *pResource, const FLOAT Values[4], UINT NumRects, const D3D12_RECT *pRects)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(PortableHandle, gpuhandle, ToPortableHandle(ViewGPUHandleInCurrentHeap));
SERIALISE_ELEMENT(PortableHandle, cpuhandle, ToPortableHandle(ViewCPUHandle));
SERIALISE_ELEMENT(ResourceId, res, GetResID(pResource));
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
FLOAT vals[4] = {0};
if(m_State >= WRITING)
memcpy(vals, Values, sizeof(FLOAT) * 4);
m_pSerialiser->SerialisePODArray<4>("Values", vals);
SERIALISE_ELEMENT(UINT, num, NumRects);
SERIALISE_ELEMENT_ARR(D3D12_RECT, rects, pRects, num);
if(m_State == EXECUTING)
{
ViewGPUHandleInCurrentHeap = GPUHandleFromPortableHandle(GetResourceManager(), gpuhandle);
ViewCPUHandle = CPUHandleFromPortableHandle(GetResourceManager(), cpuhandle);
pResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(res);
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap, ViewCPUHandle,
Unwrap(pResource), vals, num, rects);
}
}
else if(m_State == READING)
{
ViewGPUHandleInCurrentHeap = GPUHandleFromPortableHandle(GetResourceManager(), gpuhandle);
ViewCPUHandle = CPUHandleFromPortableHandle(GetResourceManager(), cpuhandle);
pResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(res);
GetList(CommandList)
->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap, ViewCPUHandle,
Unwrap(pResource), vals, num, rects);
GetCrackedList(CommandList)
->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap, ViewCPUHandle,
Unwrap(pResource), vals, num, rects);
const string desc = m_pSerialiser->GetDebugStr();
{
m_Cmd->AddEvent(desc);
string name = "ClearUnorderedAccessViewFloat(" + ToStr::Get(vals[0]) + "," +
ToStr::Get(vals[1]) + "," + ToStr::Get(vals[2]) + "," + ToStr::Get(vals[3]) +
")";
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_Clear;
m_Cmd->AddDrawcall(draw, true);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
drawNode.resourceUsage.push_back(
std::make_pair(GetResID(pResource), EventUsage(drawNode.draw.eventID, eUsage_Clear)));
}
}
SAFE_DELETE_ARRAY(rects);
return true;
}
void WrappedID3D12GraphicsCommandList::ClearUnorderedAccessViewFloat(
D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle,
ID3D12Resource *pResource, const FLOAT Values[4], UINT NumRects, const D3D12_RECT *pRects)
{
m_pReal->ClearUnorderedAccessViewFloat(Unwrap(ViewGPUHandleInCurrentHeap), Unwrap(ViewCPUHandle),
Unwrap(pResource), Values, NumRects, pRects);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(CLEAR_UAV_FLOAT);
Serialise_ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap, ViewCPUHandle, pResource,
Values, NumRects, pRects);
m_ListRecord->AddChunk(scope.Get());
{
D3D12Descriptor *desc = GetWrapped(ViewGPUHandleInCurrentHeap);
m_ListRecord->MarkResourceFrameReferenced(desc->nonsamp.heap->GetResourceID(), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(desc->nonsamp.resource), eFrameRef_Write);
desc = GetWrapped(ViewCPUHandle);
m_ListRecord->MarkResourceFrameReferenced(desc->nonsamp.heap->GetResourceID(), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(desc->nonsamp.resource), eFrameRef_Write);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pResource), eFrameRef_Write);
}
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_DiscardResource(ID3D12Resource *pResource,
const D3D12_DISCARD_REGION *pRegion)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, res, GetResID(pResource));
SERIALISE_ELEMENT(BOOL, HasRegion, pRegion != NULL);
SERIALISE_ELEMENT_OPT(D3D12_DISCARD_REGION, region, *pRegion, HasRegion);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
pResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(res);
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
Unwrap(m_Cmd->RerecordCmdList(CommandList))
->DiscardResource(Unwrap(pResource), HasRegion ? ®ion : NULL);
}
}
else if(m_State == READING)
{
pResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(res);
GetList(CommandList)->DiscardResource(Unwrap(pResource), HasRegion ? ®ion : NULL);
GetCrackedList(CommandList)->DiscardResource(Unwrap(pResource), HasRegion ? ®ion : NULL);
}
return true;
}
void WrappedID3D12GraphicsCommandList::DiscardResource(ID3D12Resource *pResource,
const D3D12_DISCARD_REGION *pRegion)
{
m_pReal->DiscardResource(Unwrap(pResource), pRegion);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(DISCARD_RESOURCE);
Serialise_DiscardResource(pResource, pRegion);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pResource), eFrameRef_Write);
}
}
#pragma endregion Clears
#pragma region Copies
bool WrappedID3D12GraphicsCommandList::Serialise_CopyBufferRegion(ID3D12Resource *pDstBuffer,
UINT64 DstOffset,
ID3D12Resource *pSrcBuffer,
UINT64 SrcOffset, UINT64 NumBytes)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, dst, GetResID(pDstBuffer));
SERIALISE_ELEMENT(UINT64, dstoffs, DstOffset);
SERIALISE_ELEMENT(ResourceId, src, GetResID(pSrcBuffer));
SERIALISE_ELEMENT(UINT64, srcoffs, SrcOffset);
SERIALISE_ELEMENT(UINT64, num, NumBytes);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
pDstBuffer = GetResourceManager()->GetLiveAs<ID3D12Resource>(dst);
pSrcBuffer = GetResourceManager()->GetLiveAs<ID3D12Resource>(src);
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
Unwrap(list)->CopyBufferRegion(Unwrap(pDstBuffer), dstoffs, Unwrap(pSrcBuffer), srcoffs, num);
}
}
else if(m_State == READING)
{
pDstBuffer = GetResourceManager()->GetLiveAs<ID3D12Resource>(dst);
pSrcBuffer = GetResourceManager()->GetLiveAs<ID3D12Resource>(src);
GetList(CommandList)->CopyBufferRegion(Unwrap(pDstBuffer), dstoffs, Unwrap(pSrcBuffer), srcoffs, num);
GetCrackedList(CommandList)
->CopyBufferRegion(Unwrap(pDstBuffer), dstoffs, Unwrap(pSrcBuffer), srcoffs, num);
const string desc = m_pSerialiser->GetDebugStr();
{
m_Cmd->AddEvent(desc);
string name = "CopyBufferRegion(" + ToStr::Get(src) + "," + ToStr::Get(dst) + ")";
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_Copy;
draw.copySource = src;
draw.copyDestination = dst;
m_Cmd->AddDrawcall(draw, true);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
if(src == dst)
{
drawNode.resourceUsage.push_back(
std::make_pair(GetResID(pSrcBuffer), EventUsage(drawNode.draw.eventID, eUsage_Copy)));
}
else
{
drawNode.resourceUsage.push_back(std::make_pair(
GetResID(pSrcBuffer), EventUsage(drawNode.draw.eventID, eUsage_CopySrc)));
drawNode.resourceUsage.push_back(std::make_pair(
GetResID(pDstBuffer), EventUsage(drawNode.draw.eventID, eUsage_CopyDst)));
}
}
}
return true;
}
void WrappedID3D12GraphicsCommandList::CopyBufferRegion(ID3D12Resource *pDstBuffer,
UINT64 DstOffset, ID3D12Resource *pSrcBuffer,
UINT64 SrcOffset, UINT64 NumBytes)
{
m_pReal->CopyBufferRegion(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer), SrcOffset, NumBytes);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(COPY_BUFFER);
Serialise_CopyBufferRegion(pDstBuffer, DstOffset, pSrcBuffer, SrcOffset, NumBytes);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pDstBuffer), eFrameRef_Write);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pSrcBuffer), eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_CopyTextureRegion(
const D3D12_TEXTURE_COPY_LOCATION *pDst, UINT DstX, UINT DstY, UINT DstZ,
const D3D12_TEXTURE_COPY_LOCATION *pSrc, const D3D12_BOX *pSrcBox)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(D3D12_TEXTURE_COPY_LOCATION, dst, *pDst);
SERIALISE_ELEMENT(UINT, dstX, DstX);
SERIALISE_ELEMENT(UINT, dstY, DstY);
SERIALISE_ELEMENT(UINT, dstZ, DstZ);
SERIALISE_ELEMENT(D3D12_TEXTURE_COPY_LOCATION, src, *pSrc);
SERIALISE_ELEMENT(bool, HasSrcBox, pSrcBox != NULL);
SERIALISE_ELEMENT_OPT(D3D12_BOX, box, *pSrcBox, HasSrcBox);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
Unwrap(list)->CopyTextureRegion(&dst, dstX, dstY, dstZ, &src, HasSrcBox ? &box : NULL);
}
}
else if(m_State == READING)
{
GetList(CommandList)->CopyTextureRegion(&dst, dstX, dstY, dstZ, &src, HasSrcBox ? &box : NULL);
GetCrackedList(CommandList)->CopyTextureRegion(&dst, dstX, dstY, dstZ, &src, HasSrcBox ? &box : NULL);
const string desc = m_pSerialiser->GetDebugStr();
{
m_Cmd->AddEvent(desc);
ResourceId liveSrc = GetResID(GetResourceManager()->GetWrapper(src.pResource));
ResourceId liveDst = GetResID(GetResourceManager()->GetWrapper(dst.pResource));
ResourceId origSrc = GetResourceManager()->GetOriginalID(liveSrc);
ResourceId origDst = GetResourceManager()->GetOriginalID(liveDst);
string name = "CopyTextureRegion(" + ToStr::Get(origSrc) + "," + ToStr::Get(origDst) + ")";
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_Copy;
draw.copySource = origSrc;
draw.copyDestination = origDst;
m_Cmd->AddDrawcall(draw, true);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
if(origSrc == origDst)
{
drawNode.resourceUsage.push_back(
std::make_pair(liveSrc, EventUsage(drawNode.draw.eventID, eUsage_Copy)));
}
else
{
drawNode.resourceUsage.push_back(
std::make_pair(liveSrc, EventUsage(drawNode.draw.eventID, eUsage_CopySrc)));
drawNode.resourceUsage.push_back(
std::make_pair(liveDst, EventUsage(drawNode.draw.eventID, eUsage_CopyDst)));
}
}
}
return true;
}
void WrappedID3D12GraphicsCommandList::CopyTextureRegion(const D3D12_TEXTURE_COPY_LOCATION *pDst,
UINT DstX, UINT DstY, UINT DstZ,
const D3D12_TEXTURE_COPY_LOCATION *pSrc,
const D3D12_BOX *pSrcBox)
{
D3D12_TEXTURE_COPY_LOCATION dst = *pDst;
dst.pResource = Unwrap(dst.pResource);
D3D12_TEXTURE_COPY_LOCATION src = *pSrc;
src.pResource = Unwrap(src.pResource);
m_pReal->CopyTextureRegion(&dst, DstX, DstY, DstZ, &src, pSrcBox);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(COPY_TEXTURE);
Serialise_CopyTextureRegion(pDst, DstX, DstY, DstZ, pSrc, pSrcBox);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pDst->pResource), eFrameRef_Write);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pSrc->pResource), eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_CopyResource(ID3D12Resource *pDstResource,
ID3D12Resource *pSrcResource)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, dst, GetResID(pDstResource));
SERIALISE_ELEMENT(ResourceId, src, GetResID(pSrcResource));
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
pDstResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(dst);
pSrcResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(src);
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
Unwrap(list)->CopyResource(Unwrap(pDstResource), Unwrap(pSrcResource));
}
}
else if(m_State == READING)
{
pDstResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(dst);
pSrcResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(src);
GetList(CommandList)->CopyResource(Unwrap(pDstResource), Unwrap(pSrcResource));
GetCrackedList(CommandList)->CopyResource(Unwrap(pDstResource), Unwrap(pSrcResource));
const string desc = m_pSerialiser->GetDebugStr();
{
m_Cmd->AddEvent(desc);
string name = "CopyResource(" + ToStr::Get(src) + "," + ToStr::Get(dst) + ")";
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_Copy;
draw.copySource = src;
draw.copyDestination = dst;
m_Cmd->AddDrawcall(draw, true);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
if(pSrcResource == pDstResource)
{
drawNode.resourceUsage.push_back(
std::make_pair(GetResID(pSrcResource), EventUsage(drawNode.draw.eventID, eUsage_Copy)));
}
else
{
drawNode.resourceUsage.push_back(std::make_pair(
GetResID(pSrcResource), EventUsage(drawNode.draw.eventID, eUsage_CopySrc)));
drawNode.resourceUsage.push_back(std::make_pair(
GetResID(pDstResource), EventUsage(drawNode.draw.eventID, eUsage_CopyDst)));
}
}
}
return true;
}
void WrappedID3D12GraphicsCommandList::CopyResource(ID3D12Resource *pDstResource,
ID3D12Resource *pSrcResource)
{
m_pReal->CopyResource(Unwrap(pDstResource), Unwrap(pSrcResource));
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(COPY_RESOURCE);
Serialise_CopyResource(pDstResource, pSrcResource);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pDstResource), eFrameRef_Write);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pSrcResource), eFrameRef_Read);
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_ResolveSubresource(ID3D12Resource *pDstResource,
UINT DstSubresource,
ID3D12Resource *pSrcResource,
UINT SrcSubresource,
DXGI_FORMAT Format)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, dst, GetResID(pDstResource));
SERIALISE_ELEMENT(UINT, dstSub, DstSubresource);
SERIALISE_ELEMENT(ResourceId, src, GetResID(pSrcResource));
SERIALISE_ELEMENT(UINT, srcSub, SrcSubresource);
SERIALISE_ELEMENT(DXGI_FORMAT, fmt, Format);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
if(m_State == EXECUTING)
{
pDstResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(dst);
pSrcResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(src);
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
Unwrap(list)->ResolveSubresource(Unwrap(pDstResource), dstSub, Unwrap(pSrcResource), srcSub,
fmt);
}
}
else if(m_State == READING)
{
pDstResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(dst);
pSrcResource = GetResourceManager()->GetLiveAs<ID3D12Resource>(src);
GetList(CommandList)
->ResolveSubresource(Unwrap(pDstResource), dstSub, Unwrap(pSrcResource), srcSub, fmt);
GetCrackedList(CommandList)
->ResolveSubresource(Unwrap(pDstResource), dstSub, Unwrap(pSrcResource), srcSub, fmt);
const string desc = m_pSerialiser->GetDebugStr();
{
m_Cmd->AddEvent(desc);
string name = "ResolveSubresource(" + ToStr::Get(src) + "," + ToStr::Get(dst) + ")";
FetchDrawcall draw;
draw.name = name;
draw.flags |= eUsage_Resolve;
draw.copySource = src;
draw.copyDestination = dst;
m_Cmd->AddDrawcall(draw, true);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
if(pSrcResource == pDstResource)
{
drawNode.resourceUsage.push_back(std::make_pair(
GetResID(pSrcResource), EventUsage(drawNode.draw.eventID, eUsage_Resolve)));
}
else
{
drawNode.resourceUsage.push_back(std::make_pair(
GetResID(pSrcResource), EventUsage(drawNode.draw.eventID, eUsage_ResolveSrc)));
drawNode.resourceUsage.push_back(std::make_pair(
GetResID(pDstResource), EventUsage(drawNode.draw.eventID, eUsage_ResolveDst)));
}
}
}
return true;
}
void WrappedID3D12GraphicsCommandList::ResolveSubresource(ID3D12Resource *pDstResource,
UINT DstSubresource,
ID3D12Resource *pSrcResource,
UINT SrcSubresource, DXGI_FORMAT Format)
{
m_pReal->ResolveSubresource(Unwrap(pDstResource), DstSubresource, Unwrap(pSrcResource),
SrcSubresource, Format);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(RESOLVE_SUBRESOURCE);
Serialise_ResolveSubresource(pDstResource, DstSubresource, pSrcResource, SrcSubresource, Format);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pDstResource), eFrameRef_Write);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pSrcResource), eFrameRef_Read);
}
}
void WrappedID3D12GraphicsCommandList::CopyTiles(
ID3D12Resource *pTiledResource, const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate,
const D3D12_TILE_REGION_SIZE *pTileRegionSize, ID3D12Resource *pBuffer,
UINT64 BufferStartOffsetInBytes, D3D12_TILE_COPY_FLAGS Flags)
{
D3D12NOTIMP("Tiled Resources");
m_pReal->CopyTiles(Unwrap(pTiledResource), pTileRegionStartCoordinate, pTileRegionSize,
Unwrap(pBuffer), BufferStartOffsetInBytes, Flags);
}
#pragma endregion Copies
| [
"[email protected]"
] | |
c5873e6101ec142c219566f51037cb499fe1122e | 984f870fd8fc3ecdbb4153eff18ff29dd43f3808 | /Trees/destructor.cpp | 2de201b416259ed2cdc6067bb84697b8ea646926 | [] | no_license | sakshamsomani2345/c-plus-plus-practice | 7c777fbb4444cd717bdcc6e77501b74f78c06964 | aa36723642c5f740564bcf95469ebfe0893c5121 | refs/heads/main | 2023-08-06T22:38:52.811277 | 2021-09-03T04:54:31 | 2021-09-03T04:54:31 | 402,649,494 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,722 | cpp | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
template <typename T>
class Treenode
{
public:
T data;
vector<Treenode<T> *> children;
Treenode(T data)
{
this->data = data;
}
~Treenode(){
for (int i = 0; i < children.size(); i++)
{
delete children[i];
}
}
};
Treenode<int> *takeinputlevelwise()
{
int rootdata;
cout << "Enter root data" << endl;
cin >> rootdata;
Treenode<int> *root = new Treenode<int>(rootdata);
queue<Treenode<int> *> pendingnodes;
pendingnodes.push(root);
while (pendingnodes.size() != 0)
{
Treenode<int> *front = pendingnodes.front();
pendingnodes.pop();
cout << "enter no of children " << front->data;
int numchild;
cin >> numchild;
int i;
for (i = 0; i < numchild; i++)
{
int childdata;
cout << "enter " << i << "the child of " << front->data << endl;
cin >> childdata;
Treenode<int> *child = new Treenode<int>(childdata);
front->children.push_back(child);
pendingnodes.push(child);
}
}
return root;
}
void postordertraversal(Treenode<int> *root)
{
for (int i = 0; i < root->children.size(); i++)
{
postordertraversal(root->children[i]);
}
cout << root->data;
}
// void deletes(Treenode<int> *root)
// {
// for (int i = 0; i < root->children.size(); i++)
// {
// delete(root->children[i]);
// }
// delete root;
// }
int main()
{
Treenode<int> *root = takeinputlevelwise();
postordertraversal(root);
// deletes(root);
} | [
"[email protected]"
] | |
890d92dba45eb82fa7fbe368f325384e4959eb9b | ff24f636caea06227a97c6ad018ebeaaedc75f8f | /SFMLTutorial/Config.h | a4ade5b65f959949b1353dcd4375d65c0353534d | [] | no_license | nhathuy13598/Demo-Source-Game | c4ced0a4a41ebe9141ccc5c5369d7874a0926fab | c70e8399b79864524d544c61cc4cd77f03bc2727 | refs/heads/master | 2020-06-23T01:49:40.415641 | 2019-07-23T16:12:32 | 2019-07-23T16:12:32 | 198,465,597 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 200 | h | #pragma once
#include <iostream>
#include "../include/SFML/Graphics.hpp"
using namespace sf;
using namespace std;
#define WINDOWS_W 900
#define WINDOWS_H 600
#define WINDOWS_NAME "Spaceship Game!"
| [
"[email protected]"
] | |
f46f5c81f5b06e95aa7d97d92393dfee9f336a6d | 9f57130720fe9d671c916cbe38afb96ba65f0ba7 | /examples/post_processing.cc | 64fe0284fa2e068ae82923cc0042758a50cd9d44 | [] | no_license | gsibley/quarkGL | ded8c2ba5def64d4394343da471efa702fe53fbe | 52e9270ebc02752c46e5a47bee372d396c51b1d3 | refs/heads/master | 2020-03-27T17:17:59.584199 | 2018-01-18T06:40:43 | 2018-01-18T06:40:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,493 | cc | #include <iostream>
// Must precede glfw/glad, to include OpenGL functions.
#include <qrk/core.h>
#include <GLFW/glfw3.h>
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <qrk/camera.h>
#include <qrk/framebuffer.h>
#include <qrk/shader.h>
#include <qrk/texture.h>
#include <qrk/vertex_array.h>
#include <qrk/window.h>
const char* textureVertexSource = R"SHADER(
#version 330 core
layout(location = 0) in vec3 vertexPos;
layout(location = 1) in vec2 vertexTexCoords;
out vec2 texCoords;
out vec3 fragPos;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main() {
gl_Position = projection * view * model * vec4(vertexPos, 1.0);
texCoords = vertexTexCoords;
fragPos = vec3(view * model * vec4(vertexPos, 1.0));
}
)SHADER";
const char* textureFragmentSource = R"SHADER(
#version 330 core
in vec2 texCoords;
out vec4 fragColor;
uniform sampler2D texture0;
void main() { fragColor = texture(texture0, texCoords); }
)SHADER";
const char* screenVertexSource = R"SHADER(
#version 330 core
layout(location = 0) in vec2 vertexPos;
layout(location = 1) in vec2 vertexTexCoords;
out vec2 texCoords;
void main() {
gl_Position = vec4(vertexPos, 0.0, 1.0);
texCoords = vertexTexCoords;
}
)SHADER";
const char* screenFragmentSource = R"SHADER(
#version 330 core
#pragma qrk_include < gamma.frag >
#pragma qrk_include < post_processing.frag >
#pragma qrk_include < window.frag >
in vec2 texCoords;
out vec4 fragColor;
uniform sampler2D screenTexture;
// TODO: Allow other post_processing methods from command line.
void main() {
if (qrk_isWindowLeftHalf()) {
if (qrk_isWindowTopHalf()) {
fragColor = texture(screenTexture, texCoords);
} else {
fragColor = qrk_blurKernel(screenTexture, texCoords);
}
} else {
if (qrk_isWindowTopHalf()) {
fragColor = qrk_grayscale(texture(screenTexture, texCoords));
} else {
fragColor = qrk_edgeKernel(screenTexture, texCoords);
}
}
fragColor.rgb = qrk_gammaCorrect(fragColor.rgb);
}
)SHADER";
// clang-format off
const float cubeVertices[] = {
// positions // texture coords
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f
};
const float planeVertices[] = {
// positions // texture coords
5.0f, -0.5f, 5.0f, 2.0f, 0.0f,
-5.0f, -0.5f, 5.0f, 0.0f, 0.0f,
-5.0f, -0.5f, -5.0f, 0.0f, 2.0f,
5.0f, -0.5f, 5.0f, 2.0f, 0.0f,
-5.0f, -0.5f, -5.0f, 0.0f, 2.0f,
5.0f, -0.5f, -5.0f, 2.0f, 2.0f
};
const float quadVertices[] = {
// positions // texture coords
-1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 0.0f,
1.0f, -1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f,
1.0f, -1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 1.0f, 1.0f
};
// clang-format on
int main() {
auto win = std::make_shared<qrk::Window>(800, 600, "Post processing");
win->setClearColor(glm::vec4(0.1f, 0.1f, 0.1f, 1.0f));
win->enableMouseCapture();
win->setEscBehavior(qrk::EscBehavior::CLOSE);
auto camera =
std::make_shared<qrk::Camera>(/* position */ glm::vec3(0.0f, 0.0f, 3.0f));
auto cameraControls = std::make_shared<qrk::FpsCameraControls>();
win->bindCamera(camera);
win->bindCameraControls(cameraControls);
qrk::Shader mainShader((qrk::ShaderInline(textureVertexSource)),
qrk::ShaderInline(textureFragmentSource));
qrk::Shader screenShader((qrk::ShaderInline(screenVertexSource)),
qrk::ShaderInline(screenFragmentSource));
// Create a VAO for the boxes.
qrk::VertexArray cubeVarray;
cubeVarray.loadVertexData(cubeVertices, sizeof(cubeVertices));
cubeVarray.addVertexAttrib(3, GL_FLOAT);
cubeVarray.addVertexAttrib(2, GL_FLOAT);
cubeVarray.finalizeVertexAttribs();
// Create a VAO for the plane.
qrk::VertexArray planeVarray;
planeVarray.loadVertexData(planeVertices, sizeof(planeVertices));
planeVarray.addVertexAttrib(3, GL_FLOAT);
planeVarray.addVertexAttrib(2, GL_FLOAT);
planeVarray.finalizeVertexAttribs();
// Create a VAO for the screen quad.
qrk::VertexArray quadVarray;
quadVarray.loadVertexData(quadVertices, sizeof(quadVertices));
quadVarray.addVertexAttrib(2, GL_FLOAT);
quadVarray.addVertexAttrib(2, GL_FLOAT);
quadVarray.finalizeVertexAttribs();
// Load textures.
unsigned int cubeTexture = qrk::loadTexture("examples/container.jpg");
unsigned int floorTexture = qrk::loadTexture("examples/metal.png");
// Framebuffer.
qrk::Framebuffer fb(win->getSize());
auto colorAttachment = fb.attachTexture(qrk::BufferType::COLOR);
fb.attachRenderbuffer(qrk::BufferType::DEPTH_AND_STENCIL);
screenShader.addUniformSource(win);
win->loop([&](float deltaTime) {
fb.activate();
fb.clear();
glm::mat4 view = camera->getViewTransform();
glm::mat4 projection = camera->getPerspectiveTransform();
// Setup shader and textures for the framebuffer.
mainShader.activate();
mainShader.setMat4("view", view);
mainShader.setMat4("projection", projection);
mainShader.setInt("texture0", 0);
glm::mat4 model;
// Draw cubes.
cubeVarray.activate();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, cubeTexture);
model = glm::translate(glm::mat4(), glm::vec3(-1.0f, 0.0f, -1.0f));
mainShader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::translate(glm::mat4(), glm::vec3(2.0f, 0.0f, 0.0f));
mainShader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// Draw floor.
planeVarray.activate();
glBindTexture(GL_TEXTURE_2D, floorTexture);
mainShader.setMat4("model", glm::mat4());
glDrawArrays(GL_TRIANGLES, 0, 6);
planeVarray.deactivate();
fb.deactivate();
// Finally, draw to the screen based on the framebuffer contents.
screenShader.updateUniforms();
screenShader.activate();
screenShader.setInt("screenTexture", 0);
quadVarray.activate();
glBindTexture(GL_TEXTURE_2D, colorAttachment.id);
win->disableDepthTest();
glDrawArrays(GL_TRIANGLES, 0, 6);
win->enableDepthTest();
});
return 0;
}
| [
"[email protected]"
] | |
40a93feb760412b25ac2bc2d9f20033a43697732 | 46a7ff3fd79a56085593b69c0ab344c34ed12c08 | /src/Tools/Code/Polar/Patterns/Pattern_polar_r0_left.hpp | 2934b32375fc9c20dcc681b1d028c279a5b3ac65 | [
"MIT"
] | permissive | cs0x7f/aff3ct | ec6a2f486ef92f5308b0eae19aa8de3687bcbb59 | 0c23f39d39989fddb83e5c1e5dca9bc2d760f670 | refs/heads/master | 2020-03-31T17:08:33.977314 | 2018-10-10T11:21:40 | 2018-10-10T11:21:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,475 | hpp | #ifndef PATTERN_POLAR_RATE_0_LEFT_HPP_
#define PATTERN_POLAR_RATE_0_LEFT_HPP_
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <typeinfo>
#include "Tools/Exception/exception.hpp"
#include "Pattern_polar_i.hpp"
#include "Pattern_polar_r0.hpp"
namespace aff3ct
{
namespace tools
{
class Pattern_polar_r0_left : public Pattern_polar_i
{
protected:
Pattern_polar_r0_left(const int &N, const Binary_node<Pattern_polar_i>* node,
const int min_level = 1, const int max_level = -1)
: Pattern_polar_i(N, node, min_level, max_level)
{
if (min_level < 1)
{
std::stringstream message;
message << "'min_level' has to be equal or greater than 1 ('min_level' = " << min_level << ").";
throw invalid_argument(__FILE__, __LINE__, __func__, message.str());
}
}
public:
Pattern_polar_r0_left(const int min_level = 1, const int max_level = -1)
: Pattern_polar_i(min_level, max_level)
{
if (min_level < 1)
{
std::stringstream message;
message << "'min_level' has to be equal or greater than 1 ('min_level' = " << min_level << ").";
throw invalid_argument(__FILE__, __LINE__, __func__, message.str());
}
}
virtual Pattern_polar_i* alloc(const int &N, const Binary_node<Pattern_polar_i>* node) const
{
return new Pattern_polar_r0_left(N, node, min_level, max_level);
}
virtual ~Pattern_polar_r0_left() {}
virtual polar_node_t type() const { return polar_node_t::RATE_0_LEFT; }
virtual std::string name() const { return "Rate 0 left"; }
virtual std::string short_name() const { return "r0l"; }
virtual std::string fill_color() const { return "#dadada"; }
virtual std::string font_color() const { return "#000000"; }
virtual std::string f() const { return "f"; }
virtual std::string g() const { return "g0"; }
virtual std::string h() const { return "xo0"; }
virtual int _match(const int &reverse_graph_depth, const Binary_node<Pattern_polar_i>* node_curr) const
{
const Pattern_polar_i *pattern_left = node_curr->get_left()->get_contents();
if (pattern_left == nullptr)
throw runtime_error(__FILE__, __LINE__, __func__, "'pattern_left' can't be null.");
int match_val = 0;
if (pattern_left->type() == polar_node_t::RATE_0)
{
match_val = 20;
}
return match_val;
}
virtual bool is_terminal() const { return false; }
};
}
}
#endif /* PATTERN_POLAR_RATE_0_LEFT_HPP_ */
| [
"[email protected]"
] | |
3d77dba565a9382e3cb7b442bb814e2e047ead8e | 052b567e55fc5d9e1415351008ae7a0b1b4317db | /04/test01_output_container.cpp | 4ed00963458505ac1a9aa98a0771e35a685a30f4 | [
"Unlicense"
] | permissive | caijw/geek_time_cpp | 75fbee65412b6176f16ce48ad8f6c9b4e7b92894 | 746cd3bd15a511dc41130632563f66a475a756f5 | refs/heads/master | 2022-12-07T00:09:52.727994 | 2020-09-02T17:46:58 | 2020-09-02T17:46:58 | 280,107,476 | 0 | 0 | Unlicense | 2020-07-16T09:09:22 | 2020-07-16T09:09:21 | null | UTF-8 | C++ | false | false | 382 | cpp | #include <iostream> // std::cout/endl
#include <map> // std::map
#include <vector> // std::vector
#include "output_container.h" // operator<< for containers
using namespace std;
int main()
{
map<int, int> mp{{1, 1}, {2, 4}, {3, 9}};
cout << mp << endl;
vector<vector<int>> vv{{1, 1}, {2, 4}, {3, 9}};
cout << vv << endl;
}
| [
"[email protected]"
] | |
b9aff7201dbc3c570101699c80d90a5ffff5946c | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/httpd/gumtree/httpd_old_log_4978.cpp | 34d7444b37dcb4ca5213a5fe21370909005b0a24 | [] | 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 | 119 | cpp | ap_log_perror(APLOG_MARK, APLOG_WARNING, rv, p,
"Failed to enable APR_TCP_DEFER_ACCEPT"); | [
"[email protected]"
] | |
1c1741efc0e3defe882f4ac860260213e8e4abed | eef01cebbf69c1d5132793432578d931a40ce77c | /IF/Classes/scene/world/ResourceTile.cpp | b5ce051f9310bc52dd347d23ccbe9df83aa81698 | [] | no_license | atom-chen/zltx | 0b2e78dd97fc94fa0448ba9832da148217f1a77d | 8ead8fdddecd64b7737776c03417d73a82a6ff32 | refs/heads/master | 2022-12-03T05:02:45.624200 | 2017-03-29T02:58:10 | 2017-03-29T02:58:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 23,296 | cpp | //
// ResourceTile.cpp
// IF
//
// Created by 邹 程 on 14-2-26.
//
//
#include "ResourceTile.h"
#include "ScoutInfo.h"
#include "WorldCommand.h"
#include "WorldMapView.h"
#include "YesNoDialog.h"
#include "AddFavorite.h"
#include "RoleInfoView.h"
#include "ResourceTileInfoPopUpView.h"
#include "TipsView.h"
#include "SceneController.h"
#include "SoundController.h"
#include "EnemyInfoController.h"
#include "TipsWithPicView.h"
#include "YuanJunTipView.h"
bool ResourceTile::init() {
NewBaseTileInfo::init();
std::string resName = "";
if (m_cityInfo.resource.type<ResourceStr.size()) {//防止越界崩了
resName = ResourceStr[m_cityInfo.resource.type];
}
//m_title->setString(CCString::createWithFormat("%d %s ",m_cityInfo.resource.lv,_lang(resName.c_str()).c_str())->getCString());
requestDetail();
onDetailCallback(NULL);
bool flag = false;
for(auto it = WorldController::getInstance()->m_marchInfo.begin(); it != WorldController::getInstance()->m_marchInfo.end(); it++){
if(it->second.ownerType == PlayerSelf && it->second.endPointIndex == m_cityInfo.cityIndex){
m_cityInfo.resource.troopMax = it->second.troopMax;
m_cityInfo.resource.digSpeed = it->second.digSpeed;
m_cityInfo.resource.digStartTime = it->second.digStartTime;
m_cityInfo.resource.digStartNum = it->second.digStartNum;
m_cityInfo.resource.changeCollectSpdTime = it->second.changeCollectSpdTime;
flag = true;
break;
}
}
if(!flag){
// no owner
m_cityInfo.resource.troopMax = 0;
m_cityInfo.resource.digSpeed = 0.0;
m_cityInfo.resource.digStartTime = 0.0;
// m_cityInfo.playerName = "";
}
m_cityInfo.resource.sum = 0;
if(m_cityInfo.playerName != "" && m_cityInfo.playerName != GlobalData::shared()->playerInfo.name){
addNameNode();
}
//
m_isInUpdate = false;
addToParent();
this->setVisible(false);
updateView();
return true;
}
void ResourceTile::onEnter(){
NewBaseTileInfo::onEnter();
CCDirector::sharedDirector()->getScheduler()->scheduleUpdateForTarget(this, 0, false);
}
void ResourceTile::onExit(){
CCDirector::sharedDirector()->getScheduler()->unscheduleAllForTarget(this);
NewBaseTileInfo::onExit();
}
void ResourceTile::requestDetail() {
m_isInUpdate = true;
unsigned int index = m_cityInfo.cityIndex;
if(m_cityInfo.parentCityIndex != -1){
index = m_cityInfo.parentCityIndex;
}
auto cmd = new WorldDetailCommand(index,m_cityInfo.tileServerId);
cmd->setCallback(CCCallFuncO::create(this, callfuncO_selector(ResourceTile::onDetailCallback), nullptr));
cmd->sendAndRelease();
}
void ResourceTile::onDetailCallback(cocos2d::CCObject *obj) {
m_isInUpdate = false;
this->setVisible(true);
if(SceneController::getInstance()->currentSceneId != SCENE_ID_WORLD){
return;
}
if(!WorldController::getInstance()->isInWorld){
return;
}
auto ret = dynamic_cast<NetResult*>(obj);
if (!ret || ret->getErrorCode() != Error_OK) {
// todo : parse error
return;
}
auto info = dynamic_cast<CCDictionary*>(ret->getData());
if (!info) {
return;
}
if(!this->getParent()){
return;
}
if (!info->objectForKey("uid")) {
// no owner
map<string, MarchInfo>::iterator it;
for(it = WorldController::getInstance()->m_marchInfo.begin(); it != WorldController::getInstance()->m_marchInfo.end(); it++){
if(it->second.endPointIndex == m_cityInfo.cityIndex){
auto pointer = WorldMapView::instance()->m_occupyPointerNode->getChildByTag(it->second.marchTag);
if (pointer) {
pointer->removeFromParentAndCleanup(true);
//删除显示
auto now = WorldController::getInstance()->getTime();
it->second.endStamp = now;
it->second.action = MarchActionNone;
it->second.stateType = StateReturn;
if (WorldController::getInstance()->initWorld && WorldMapView::instance()){
WorldMapView::instance()->updateMarchTarget(it->second, now, 1000);
}
//删除数据
WorldController::getInstance()->m_marchInfo.erase(it);
//刷新数据
if (WorldController::getInstance()->initWorld && WorldMapView::instance()){
WorldMapView::instance()->m_map->updateDynamicMap();
}
break;
}
}
}
m_cityInfo.playerName = "";
}else{
m_playerUid = info->valueForKey("uid")->getCString();
if (info->objectForKey("q")) {
m_cityInfo.resource.troopMax = info->valueForKey("q")->intValue();
m_cityInfo.resource.digSpeed = info->valueForKey("spd")->floatValue();
m_cityInfo.resource.digStartTime = info->valueForKey("sdt")->doubleValue();
m_cityInfo.resource.digStartNum = info->valueForKey("collected")->intValue();
m_cityInfo.resource.changeCollectSpdTime = info->valueForKey("changeCollectSpdTime")->doubleValue();
}
}
if(info->objectForKey("tq")){
m_cityInfo.resource.sum = info->valueForKey("tq")->intValue();
if(m_cityInfo.resource.sum == 0){
WorldMapView::instance()->m_map->updateDynamicMap();
this->closeThis();
return;
}
// else if(WorldMapView::instance()->getNeedOpenInfoView())
// {
// WorldMapView::instance()->setNeedOpenInfoView(false);
// PopupViewController::getInstance()->addPopupView(ResourceTileInfoPopUpView::create(m_cityInfo));
// }
}
if (info->objectForKey("hm"))
{
m_isHaveMacrh=info->valueForKey("hm")->boolValue();
}
if (info->objectForKey("max"))
{
m_iMaxGarrison=info->valueForKey("max")->intValue();
m_iCurrentGarrison=info->valueForKey("cu")->intValue();
}
if (info->objectForKey("if"))
{
m_isFull=info->valueForKey("if")->boolValue();
}
if (info->objectForKey("territory_positive_effect")) {
GlobalData::shared()->alliance_territory_positive_effect_gather = 1;
}
else
GlobalData::shared()->alliance_territory_positive_effect_gather = 0;
auto now = WorldController::getInstance()->getTime();
auto duration = now - m_cityInfo.resource.digStartTime;
unsigned int currentLoad = (m_cityInfo.resource.digSpeed * duration)/1000;
if(m_cityInfo.resource.changeCollectSpdTime != 0){
duration = now - m_cityInfo.resource.changeCollectSpdTime;
currentLoad = m_cityInfo.resource.digStartNum + (m_cityInfo.resource.digSpeed * duration)/1000;
}
//big
if (info->objectForKey("bid")) {
m_cityInfo.kingBuildInfo.tid = info->valueForKey("bid")->getCString();
}
// unsigned int sumFix = m_currentState == ResourceBlank ? 0 : currentLoad;
// m_title->setString(CCCommonUtils::getResourceStr(m_cityInfo.resource.sum - sumFix).c_str());
updateView();
}
void ResourceTile::updateView() {
this->m_iconNode->removeAllChildren();
// auto sprite = CCLoadSprite::createSprite(CCCommonUtils::getResourceIconByType(m_cityInfo.resource.type).c_str());
// CCCommonUtils::setSpriteMaxSize(sprite, 30);
// this->m_iconNode->addChild(sprite);
m_currentState = getState();
// string owner = m_currentState == ResourceBlank ? _lang("108550") : m_cityInfo.playerName;
// m_title->setString(owner);
auto now = WorldController::getInstance()->getTime();
auto duration = now - m_cityInfo.resource.digStartTime;
unsigned int currentLoad = (m_cityInfo.resource.digSpeed * duration)/1000;
if(m_cityInfo.resource.changeCollectSpdTime != 0){
duration = now - m_cityInfo.resource.changeCollectSpdTime;
currentLoad = m_cityInfo.resource.digStartNum + (m_cityInfo.resource.digSpeed * duration)/1000;
}
unsigned int sumFix = m_currentState == ResourceBlank ? 0 : currentLoad;
// if(m_cityInfo.resource.sum == 0){
// m_title->setString("");
// }else{
// m_title->setString(/*_lang("108543") + */CCCommonUtils::getResourceStr(m_cityInfo.resource.sum - sumFix).c_str());
// }
unsigned int buttonCount = 0;
if(!WorldController::isInSelfServer(m_cityInfo.tileServerId)){
buttonCount = 1;
setButtonCount(buttonCount);
if(m_currentState == ResourceBlank){
setButtonName(1, _lang("108730"));//说明
setButtonState(1, ButtonInformation);
}else{
setButtonName(1, _lang("108742"));//我的详情
setButtonState(1, ButtonProfile);
}
}else{
switch (m_currentState) {
case ResourceSelf: {
if (m_isHaveMacrh&&!m_isFull)//有部队,未满员
{
buttonCount = 4;
setButtonCount(buttonCount);
setButtonName(2, _lang("108730"));//说明
setButtonState(2, ButtonInformation);
setButtonName(5, _lang("108742"));//我的详情
setButtonState(5, ButtonProfile);
setButtonName(4, _lang("108725"));//返回
setButtonState(4, ButtonGoHome);
setButtonName(3, _lang("115333"));//驻守
setButtonState(3, ButtonDispatch);
}else if(m_isHaveMacrh&&m_isFull)//有部队,满员
{
buttonCount = 3;
setButtonCount(buttonCount);
setButtonName(3, _lang("108725"));//返回
setButtonName(2, _lang("108730"));//说明
setButtonName(1, _lang("108742"));//我的详情
setButtonState(1, ButtonProfile);
setButtonState(2, ButtonInformation);
setButtonState(3, ButtonGoHome);
}else if(!m_isHaveMacrh&&!m_isFull)//没部队,没满员
{
buttonCount = 3;
setButtonCount(buttonCount);
setButtonName(3, _lang("115333"));//驻守
setButtonName(2, _lang("108730"));//说明
setButtonName(1, _lang("108742"));//我的详情
setButtonState(1, ButtonProfile);
setButtonState(2, ButtonInformation);
setButtonState(3, ButtonDispatch);
}else if(!m_isHaveMacrh&&m_isFull)//没部队,满员
{
buttonCount = 2;
setButtonCount(buttonCount);
setButtonName(2, _lang("108730"));//说明
setButtonName(3, _lang("108742"));//我的详情
setButtonState(2, ButtonInformation);
setButtonState(3, ButtonProfile);
}
}
break;
case ResourceAlliance: {
buttonCount = 2;
setButtonCount(buttonCount);
setButtonName(2, _lang("108721"));//主公详情
setButtonName(3, _lang("108730"));//说明
setButtonState(2, ButtonProfile);
setButtonState(3, ButtonInformation);
}
break;
case ResourceOther: {
buttonCount = 4;
setButtonCount(buttonCount);
setButtonName(3, _lang("108723"));//攻击
setButtonName(2, _lang("108721"));//主公详情
setButtonName(5, _lang("108722"));//侦查
setButtonName(4, _lang("108730"));//说明
setButtonState(3, ButtonMarch);
setButtonState(2, ButtonProfile);
setButtonState(5, ButtonScout);
setButtonState(4, ButtonInformation);
}
break;
default: {
buttonCount = 3;
setButtonCount(buttonCount);
setButtonName(3, _lang("108720"));//占领
setButtonName(2, _lang("108730"));//说明
setButtonName(1, _lang("108722"));//侦查
setButtonState(3, ButtonOccupy);
setButtonState(2, ButtonInformation);
setButtonState(1, ButtonScout);
}
break;
}
}
for (int i=1; i<=TOTAL_BUTTON_NUM; ++i) {
setButtonCallback(i, cccontrol_selector(ResourceTile::onClickButton));
}
}
void ResourceTile::update(float sec) {
if (m_isInUpdate) {
return;
}
if(SceneController::getInstance()->currentSceneId != SCENE_ID_WORLD){
return;
}
if(!WorldController::getInstance()->isInWorld){
return;
}
if(!this->getParent()){
return;
}
bool flag = false;
if (m_currentState != getState()) {
if(ResourceSelf == m_currentState && getState() == ResourceBlank){
this->closeThis();
return;
}
flag = true;
}
auto now = WorldController::getInstance()->getTime();
// if (m_currentState != ResourceBlank) {
//
// auto duration = now - m_cityInfo.resource.digStartTime + 500;
// unsigned int currentLoad = (m_cityInfo.resource.digSpeed * duration)/1000;
// if(m_cityInfo.resource.changeCollectSpdTime != 0){
// duration = now - m_cityInfo.resource.changeCollectSpdTime;
// currentLoad = m_cityInfo.resource.digStartNum + (m_cityInfo.resource.digSpeed * duration)/1000;
// }
//
// unsigned load = MIN(m_cityInfo.resource.troopMax, m_cityInfo.resource.sum);
//
// if (currentLoad >= load && m_cityInfo.resource.sum != 0) {
// flag = true;
// currentLoad = load;
// }
// m_title->setString(CCString::createWithFormat("%s", CCCommonUtils::getResourceStr(m_cityInfo.resource.sum - currentLoad).c_str())->getCString());
// }
if(flag){
requestDetail();
}
}
bool ResourceTile::onAssignCCBMemberVariable(CCObject* pTarget, const char* pMemberVariableName, CCNode* pNode) {
return NewBaseTileInfo::onAssignCCBMemberVariable(pTarget, pMemberVariableName, pNode);
}
CCNode *ResourceTile::getNodeByType(std::string type){
return getButton(3);
}
ResourceTileState ResourceTile::getState() {
//std::string nameStr = m_cityInfo.playerName;
unsigned int index = m_cityInfo.cityIndex;
if(m_cityInfo.parentCityIndex != -1){
index = m_cityInfo.parentCityIndex;
}
std::string nameStr =WorldController::getInstance()->m_cityInfo[index].playerName;
bool isOccupied = (nameStr != "");
if (isOccupied) {
auto ownerInfo = WorldController::getInstance()->m_playerInfo.find(nameStr);
if(ownerInfo == WorldController::getInstance()->m_playerInfo.end()){
return ResourceBlank;
}
switch (ownerInfo->second.type) {
case PlayerSelf:
return ResourceSelf;
case PlayerAlliance:
return ResourceAlliance;
case PlayerOther:
return ResourceOther;
default:
break;
}
}
return ResourceBlank;
}
SEL_CCControlHandler ResourceTile::onResolveCCBCCControlSelector(cocos2d::CCObject *pTarget, const char *pSelectorName) {
return NewBaseTileInfo::onResolveCCBCCControlSelector(pTarget, pSelectorName);
}
BaseTileInfo* ResourceTile::getFavoriteView() {
// return AddFavorite::create(m_cityInfo.cityIndex,m_title->getString());
int restype = m_cityInfo.resource.type;
string resourceName;
if (restype == 0) {
resourceName = _lang("102011");
}else if(restype == 1){
resourceName = _lang("108580");
}else if(restype == 2){
resourceName = _lang("102012");
}else if(restype == 3){
resourceName = _lang("102013");
}else{
resourceName = CCCommonUtils::getResourceNameByType(m_cityInfo.resource.type);
}
string Lv = CC_ITOA((int)m_cityInfo.resource.lv);
resourceName = resourceName + " Lv." + Lv;
return AddFavorite::create(m_cityInfo.cityIndex,resourceName);
}
void ResourceTile::onClickButton(CCObject * pSender, Control::EventType pCCControlEvent) {
// todo
if (!this->isInitEnd) {
return;
}
auto button = dynamic_cast<CCControlButton*>(pSender);
auto buttonState = getButtonState(button);
WorldController::getInstance()->alertProectFlag = false;
WorldController::getInstance()->m_alertStateFlag = -1;
switch (buttonState) {
case ButtonDispatch:{
SoundController::sharedSound()->playEffects(Music_Sfx_click_button);
auto selfProtect = GlobalData::shared()->playerInfo.protectTimeStamp;
auto now = WorldController::getInstance()->getTime();
unsigned int index = m_cityInfo.cityIndex;
if(m_cityInfo.parentCityIndex != -1){
index = m_cityInfo.parentCityIndex;
}
auto func = [&,index](){
YuanJunTipView::openYuanYunView(index, WorldCityType::ResourceTile, 1,m_iMaxGarrison,m_iCurrentGarrison);
};
if (now < selfProtect){
YesNoDialog::show(_lang("150319").c_str(),func);
}
else{
func();
}
}
break;
case ButtonOccupy:
case ButtonMarch: {
if (!m_cityInfo.playerName.empty()) {
// have owner
WorldController::getInstance()->m_alertStateFlag = 2;
// judge self protect state
auto selfProtect = GlobalData::shared()->playerInfo.protectTimeStamp;
auto now = WorldController::getInstance()->getTime();
unsigned int index = m_cityInfo.cityIndex;
if(m_cityInfo.parentCityIndex != -1){
index = m_cityInfo.parentCityIndex;
}
auto func = [&,index](){
WorldController::getInstance()->openMarchDeploy(index,1,0,MethodSALLCity);
};
if (now < selfProtect) {
YesNoDialog::show(_lang("101438").c_str(),func);//E100050
} else {
func();
}
} else {
// no owner
WorldController::getInstance()->m_alertStateFlag = 0;
for(auto it :WorldController::getInstance()->m_marchInfo)
{
if(it.second.stateType == StateMarch && it.second.endPointIndex == this->m_cityInfo.cityIndex)
{
WorldController::getInstance()->m_alertStateFlag = 1;
WorldController::getInstance()->marchingAlertFlag = true;
break;
}
}
WorldController::getInstance()->alertProectFlag = true;
unsigned int index = m_cityInfo.cityIndex;
if(m_cityInfo.parentCityIndex != -1){
index = m_cityInfo.parentCityIndex;
}
WorldController::getInstance()->openMarchDeploy(index,0,0,MethodSALLCity);
}
CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(GUIDE_INDEX_CHANGE, CCString::createWithFormat("WR_attack"));
}
break;
case ButtonProfile: {
RoleInfoView::createInfoByUid(m_playerUid);
}
break;
case ButtonScout: {
// judge self protect state
auto selfProtect = GlobalData::shared()->playerInfo.protectTimeStamp;
auto now = WorldController::getInstance()->getTime();
unsigned int index = m_cityInfo.cityIndex;
auto func = [&,index](){
auto world = WorldMapView::instance();
if (world) {
world->addPopupView(ScoutInfo::create(WorldController::getInstance()->m_cityInfo[index]));
}
};
if (now < selfProtect) {
YesNoDialog::show(_lang("101438").c_str(),func);//E100050
} else {
func();
}
}
break;
case ButtonInformation: {
SoundController::sharedSound()->playEffects(Music_Sfx_click_button);
string content = m_cityInfo.resource.type != Gold ? "108629" : "108631";
if(m_currentState == ResourceSelf){
PopupViewController::getInstance()->addPopupView(ResourceTileInfoPopUpView::create(m_cityInfo));
}else{
//PopupViewController::getInstance()->addPopupView(TipsView::create(_lang(content)));
PopupViewController::getInstance()->addPopupView(TipsWithPicView::create(m_cityInfo));
}
}
break;
case ButtonGoHome: {
auto &selfMarch = WorldController::getInstance()->m_selfMarchUuid;
unsigned int index = m_cityInfo.cityIndex;
if(m_cityInfo.parentCityIndex != -1){
index = m_cityInfo.parentCityIndex;
}
auto it = selfMarch.find(index);
if (it == selfMarch.end()) {
// todo : show error
return;
}
string uuid = it->second;
if (uuid.empty()) {
// todo : show error
return;
}
auto dict = CCDictionary::create();
dict->setObject(CCString::create(uuid), "marchId");
WorldMapView::instance()->afterMarchCancel(dict);
vector<EnemyInfo>::iterator enemyIt = EnemyInfoController::getInstance()->m_enemyInfos.begin();
for(auto &enemyInfo : EnemyInfoController::getInstance()->m_enemyInfos)
{
for(auto &marchInfo : WorldController::getInstance()->m_marchInfo)
{
if((enemyInfo.type == ENEMY_TYPE_BATTLE || enemyInfo.type == ENEMY_TYPE_TEAM) && enemyInfo.uuid == marchInfo.second.uuid)
{
if(marchInfo.second.endPointIndex == index)
{
// 停止闪红
// enemyInfo.type = ENEMY_TYPE_TARGET_RETREAT;
EnemyInfoController::getInstance()->m_enemyInfos.erase(enemyIt);
break;
}
}
}
enemyIt++;
}
}
break;
default:
break;
}
closeThis();
}
| [
"[email protected]"
] | |
e07096a5e07e3388cd574e52864786c6a5a0587c | f05076f3ae6f5144cd9c48fa26a697d31652cd03 | /Servidor/Proyecto1/ui_terminado.h | 37476147a338ff4183d1de2e42d2a8750b6cf63e | [] | no_license | SergioFerrer9/EDD_Proyecto1_2018 | 5ae0a748fec8e206c64e0e44b3ab90f89265db81 | 9544be6c19cb32dd4de3c58e255859497ef9bcc3 | refs/heads/master | 2020-03-18T13:15:16.352042 | 2018-05-24T21:43:15 | 2018-05-24T21:43:15 | 134,771,741 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,427 | h | /********************************************************************************
** Form generated from reading UI file 'terminado.ui'
**
** Created by: Qt User Interface Compiler version 5.10.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_TERMINADO_H
#define UI_TERMINADO_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_Terminado
{
public:
QWidget *centralwidget;
QPushButton *pushButton;
QPushButton *pushButton_2;
QLabel *label;
QLabel *label_2;
QLabel *label_3;
QMenuBar *menubar;
QStatusBar *statusbar;
void setupUi(QMainWindow *Terminado)
{
if (Terminado->objectName().isEmpty())
Terminado->setObjectName(QStringLiteral("Terminado"));
Terminado->resize(377, 186);
centralwidget = new QWidget(Terminado);
centralwidget->setObjectName(QStringLiteral("centralwidget"));
pushButton = new QPushButton(centralwidget);
pushButton->setObjectName(QStringLiteral("pushButton"));
pushButton->setGeometry(QRect(100, 90, 80, 23));
pushButton_2 = new QPushButton(centralwidget);
pushButton_2->setObjectName(QStringLiteral("pushButton_2"));
pushButton_2->setGeometry(QRect(200, 90, 80, 23));
label = new QLabel(centralwidget);
label->setObjectName(QStringLiteral("label"));
label->setGeometry(QRect(130, 0, 121, 31));
label_2 = new QLabel(centralwidget);
label_2->setObjectName(QStringLiteral("label_2"));
label_2->setGeometry(QRect(110, 20, 161, 31));
label_3 = new QLabel(centralwidget);
label_3->setObjectName(QStringLiteral("label_3"));
label_3->setGeometry(QRect(60, 40, 271, 31));
Terminado->setCentralWidget(centralwidget);
menubar = new QMenuBar(Terminado);
menubar->setObjectName(QStringLiteral("menubar"));
menubar->setGeometry(QRect(0, 0, 377, 20));
Terminado->setMenuBar(menubar);
statusbar = new QStatusBar(Terminado);
statusbar->setObjectName(QStringLiteral("statusbar"));
Terminado->setStatusBar(statusbar);
retranslateUi(Terminado);
QMetaObject::connectSlotsByName(Terminado);
} // setupUi
void retranslateUi(QMainWindow *Terminado)
{
Terminado->setWindowTitle(QApplication::translate("Terminado", "MainWindow", nullptr));
pushButton->setText(QApplication::translate("Terminado", "No", nullptr));
pushButton_2->setText(QApplication::translate("Terminado", "SI", nullptr));
label->setText(QApplication::translate("Terminado", "!!! FELICIDADES !!!", nullptr));
label_2->setText(QApplication::translate("Terminado", "Has completado el nivel", nullptr));
label_3->setText(QApplication::translate("Terminado", "Deseas ver los enemigos que has eliminado", nullptr));
} // retranslateUi
};
namespace Ui {
class Terminado: public Ui_Terminado {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_TERMINADO_H
| [
"[email protected]"
] | |
a84cac036d05135697aa9475659c8dbea97c6dbe | 44295298cdb2c452f5915764979a9cf1e08c12c6 | /CSIRO-face-tracker-mfc_notWorkingInFindingHeadPos/CSIRO-face-tracker-mfc/CSIRO-face-tracker/IO.cpp | eb61ea9ad538637f9b40db673f1129d3c1e229d7 | [] | no_license | davidxue1989/MASc | e797a41246e36c0770a6944a2c216bc760d23d3d | 58a8d725447e0852e285f923733d658f4d7a15c8 | refs/heads/master | 2021-06-03T10:14:51.409328 | 2016-07-10T20:56:25 | 2016-07-10T20:56:25 | 24,718,221 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,419 | cpp |
#include "stdafx.h"
// CSIRO has filed various patents which cover the Software.
// CSIRO grants to you a license to any patents granted for inventions
// implemented by the Software for academic, research and non-commercial
// use only.
// CSIRO hereby reserves all rights to its inventions implemented by the
// Software and any patents subsequently granted for those inventions
// that are not expressly granted to you. Should you wish to license the
// patents relating to the Software for commercial use please contact
// CSIRO IP & Licensing, Gautam Tendulkar ([email protected]) or
// Nick Marsh ([email protected])
// This software is provided under the CSIRO OPEN SOURCE LICENSE
// (GPL2) which can be found in the LICENSE file located in the top
// most directory of the source code.
// Copyright CSIRO 2013
#include "IO.hpp"
#include <stdio.h>
using namespace FACETRACKER;
using namespace std;
//===========================================================================
vector<string> IO::GetList(const char* fname)
{
vector<string> names(0); string str;
fstream file(fname,fstream::in);
if(!file.is_open()){
printf("ERROR(%s,%d) : Failed opening file %s for reading\n",
__FILE__,__LINE__,fname); abort();
}
while(!file.eof()){
getline(file,str); if(str.length() < 2)continue; names.push_back(str);
}
file.close(); return names;
}
//===========================================================================
void IO::ReadMat(ifstream& s,cv::Mat &M)
{
int r,c,t; s >> r >> c >> t;
M = cv::Mat(r,c,t);
switch(M.type()){
case CV_64FC1:
{
cv::MatIterator_<double> i1 = M.begin<double>(),i2 = M.end<double>();
while(i1 != i2)s >> *i1++;
}break;
case CV_32FC1:
{
cv::MatIterator_<float> i1 = M.begin<float>(),i2 = M.end<float>();
while(i1 != i2)s >> *i1++;
}break;
case CV_32SC1:
{
cv::MatIterator_<int> i1 = M.begin<int>(),i2 = M.end<int>();
while(i1 != i2)s >> *i1++;
}break;
case CV_8UC1:
{
cv::MatIterator_<uchar> i1 = M.begin<uchar>(),i2 = M.end<uchar>();
while(i1 != i2)s >> *i1++;
}break;
default:
printf("ERROR(%s,%d) : Unsupported Matrix type %d!\n",
__FILE__,__LINE__,M.type()); abort();
}return;
}
//===========================================================================
void IO::WriteMat(ofstream& s,cv::Mat &M)
{
s << M.rows << " " << M.cols << " " << M.type() << " ";
switch(M.type()){
case CV_64FC1:
{
s.precision(10); s << std::scientific;
cv::MatIterator_<double> i1 = M.begin<double>(),i2 = M.end<double>();
while(i1 != i2)s << *i1++ << " ";
}break;
case CV_32FC1:
{
cv::MatIterator_<float> i1 = M.begin<float>(),i2 = M.end<float>();
while(i1 != i2)s << *i1++ << " ";
}break;
case CV_32SC1:
{
cv::MatIterator_<int> i1 = M.begin<int>(),i2 = M.end<int>();
while(i1 != i2)s << *i1++ << " ";
}break;
case CV_8UC1:
{
cv::MatIterator_<uchar> i1 = M.begin<uchar>(),i2 = M.end<uchar>();
while(i1 != i2)s << *i1++ << " ";
}break;
default:
printf("ERROR(%s,%d) : Unsupported Matrix type %d!\n",
__FILE__,__LINE__,M.type()); abort();
}return;
}
//===========================================================================
cv::Mat IO::LoadCon(const char* fname)
{
int i,n; char str[256]; char c; fstream file(fname,fstream::in);
if(!file.is_open()){
printf("ERROR(%s,%d) : Failed opening file %s for reading\n",
__FILE__,__LINE__,fname); abort();
}
while(1){file >> str; if(strncmp(str,"n_connections:",14) == 0)break;}
file >> n; cv::Mat con(2,n,CV_32S);
while(1){file >> c; if(c == '{')break;}
for(i = 0; i < n; i++)file >> con.at<int>(0,i) >> con.at<int>(1,i);
file.close(); return con;
}
//=============================================================================
cv::Mat IO::LoadTri(const char* fname)
{
int i,n; char str[256]; char c; fstream file(fname,fstream::in);
if(!file.is_open()){
printf("ERROR(%s,%d) : Failed opening file %s for reading\n",
__FILE__,__LINE__,fname); abort();
}
while(1){file >> str; if(strncmp(str,"n_tri:",6) == 0)break;}
file >> n; cv::Mat tri(n,3,CV_32S);
while(1){file >> c; if(c == '{')break;}
for(i = 0; i < n; i++)
file >> tri.at<int>(i,0) >> tri.at<int>(i,1) >> tri.at<int>(i,2);
file.close(); return tri;
}
//=============================================================================
cv::Mat IO::LoadVis(const char* fname)
{
int i,n; char str[256]; char c;
fstream file(fname,fstream::in);
if(!file.is_open()){
printf("ERROR(%s,%d) : Failed opening shape file %s for reading!\n",
__FILE__,__LINE__,fname); abort();
}
while(!file.eof()){file >> str; if(strncmp(str,"n_points:",9) == 0)break;}
file >> n; cv::Mat shape(n,1,CV_32S);
while(!file.eof()){file >> c; if(c == '{')break;}
for(i = 0; i<n; i++)file >> shape.at<int>(i,0);
file.close(); return shape;
}
//=============================================================================
cv::Mat IO::LoadPts(const char* fname)
{
int i,n; char str[256]; char c;
fstream file(fname,fstream::in);
if(!file.is_open()){
printf("ERROR(%s,%d) : Failed opening shape file %s for reading!\n",
__FILE__,__LINE__,fname); abort();
}
while(!file.eof()){file >> str; if(strncmp(str,"n_points:",9) == 0)break;}
file >> n; cv::Mat shape(2*n,1,CV_64F);
while(!file.eof()){file >> c; if(c == '{')break;}
for(i = 0; i<n; i++)file >> shape.at<double>(i,0) >> shape.at<double>(i+n,0);
file.close(); return shape;
}
//=============================================================================
cv::Mat IO::LoadPts3D(const char* fname)
{
int i,n; char str[256]; char c;
fstream file(fname,fstream::in);
if(!file.is_open()){
printf("ERROR(%s,%d) : Failed opening shape file %s for reading!\n",
__FILE__,__LINE__,fname); abort();
}
while(!file.eof()){file >> str; if(strncmp(str,"n_points:",9) == 0)break;}
file >> n; cv::Mat shape(3*n,1,CV_64F);
while(!file.eof()){file >> c; if(c == '{')break;}
for(i = 0; i<n; i++)
file >> shape.at<double>(i,0)
>> shape.at<double>(i+n,0)
>> shape.at<double>(i+n*2,0);
file.close(); return shape;
}
//=============================================================================
void IO::SavePts(const char* fname,cv::Mat &pts)
{
int i,n = pts.rows/2; fstream file(fname,fstream::out);
if(!file.is_open()){
printf("ERROR(%s,%d) : Failed opening pts file %s for writing!\n",
__FILE__,__LINE__,fname); abort();
}
file << "n_points: " << n << "\n{\n";
for(i = 0; i < n; i++){
file << pts.at<double>(i,0) << "\t" << pts.at<double>(i+n,0) << "\n";
}
file << "}\n"; file.close(); return;
}
//=============================================================================
void
IO::SavePts(const char* fname, std::vector<cv::Point_<double> > &pts)
{
cv::Mat_<double> mat(pts.size()*2, 1);
const size_t n = pts.size();
for (size_t i = 0; i < n; i++) {
mat(i + 0, 0) = pts[i].x;
mat(i + n, 0) = pts[i].y;
}
SavePts(fname, mat);
}
//=============================================================================
void IO::SavePts3D(const char* fname,cv::Mat &pts)
{
int i,n = pts.rows/3; fstream file(fname,fstream::out);
if(!file.is_open()){
printf("ERROR(%s,%d) : Failed opening pts file %s for writing!\n",
__FILE__,__LINE__,fname); abort();
}
file << "n_points: " << n << "\n{\n";
for(i = 0; i < n; i++){
file << pts.at<double>(i,0) << "\t"
<< pts.at<double>(i+n,0) << "\t"
<< pts.at<double>(i+n*2,0) << "\n";
}
file << "}\n"; file.close(); return;
}
//===========================================================================
std::vector<cv::Mat> IO::LoadMatList(const char* fname)
{
int n; ifstream file(fname); assert(file.is_open());
file >> n; std::vector<cv::Mat> L(n);
for(int i = 0; i < n; i++)IO::ReadMat(file,L[i]);
file.close(); return L;
}
//===========================================================================
//===========================================================================
//===========================================================================
//===========================================================================
void IOBinary::ReadMat(std::ifstream &s, cv::Mat &M)
{
int r,c,t;
//s >> r >> c >> t;
s.read((char*)&r, sizeof(int));
s.read((char*)&c, sizeof(int));
s.read((char*)&t, sizeof(int));
M = cv::Mat(r,c,t);
s.read(reinterpret_cast<char*>(M.datastart), M.total()*M.elemSize());
if(!s.good()){
std::cout << "Error reading matrix" << std::endl;
}
// std::cout << "Mat read: "<< r << "x"<<c << ", type " << t << std::endl;
}
//===========================================================================
void IOBinary::WriteMat(std::ofstream &s, cv::Mat &M)
{
assert(M.isContinuous() && !M.isSubmatrix());
int t = M.type();
s.write(reinterpret_cast<char*>(&M.rows), sizeof(int));
s.write(reinterpret_cast<char*>(&M.cols), sizeof(int));
s.write(reinterpret_cast<char*>(&t), sizeof(int));
// s << M.rows << " " << M.cols << " " << M.type();
s.write(reinterpret_cast<char*>(M.datastart), M.total()*M.elemSize());
// std::cout << "Mat written: "<< M.rows << "x"<< M.cols << ", type " << M.type() << std::endl;
}
////===========================================================================
//cv::Mat IOBinary::LoadCon(const char *fname)
//{
// int n; char str[256]; char c;
// fstream file(fname,fstream::in);
// if(!file.is_open()){
// printf("ERROR(%s,%d) : Failed opening file %s for reading\n",
// __FILE__,__LINE__,fname);
// abort();
// }
// while(1){
// file >> str;
// if(strncmp(str,"n_connections:",14) == 0)
// break;
// }
// file >> n;
// cv::Mat con(2,n,CV_32S);
// while(1){
// file >> c;
// if(c == '{')break;
// }
// file.read((char*)con.datastart, con.total());
//
// // for(i = 0; i < n; i++)
//// file >> con.at<int>(0,i) >> con.at<int>(1,i);
// file.close();
// return con;
//}
//===========================================================================
std::vector<cv::Mat> IOBinary::LoadMatList(const char *fname)
{
int n; ifstream file(fname); assert(file.is_open());
file >> n; std::vector<cv::Mat> L(n);
for(int i = 0; i < n; i++)
IOBinary::ReadMat(file,L[i]);
file.close();
return L;
}
//===========================================================================
| [
"[email protected]"
] | |
fa0b5e870b2c703e89ba7869d35b9738cad28e7b | c60a810d25bb8e5d614daeb37212568f614a4401 | /simulacros/Regionals 2014 - Asia - Tehran/7020.cpp | 970f5537111e6bbdf1f93e522ab736cb98f763bd | [] | no_license | jonasla/icpc | f5d0af087a54b7bb57bc92e4191ddc09e2669d5b | 4f464de0b374f4c5b756b1a87322f87b08d9551a | refs/heads/master | 2021-01-24T03:42:37.957660 | 2018-03-17T15:30:05 | 2018-03-17T15:30:05 | 122,900,491 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 637 | cpp | #include <iostream>
#include <cmath>
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define mp make_pair
typedef pair<int,int> pt;
int main(){
int n;
while(cin>>n && n!=0){
if(n<=2){
cout << "Fair";
int x,y;
forn(i,n)
cin >> x >> y;
}
else{
int x1,y1,x2,y2,x3,y3;
bool fair = true;
cin >> x1 >> y1 >> x2 >> y2;
pt p1, p2, p3;
p1 = mp(x1,y1);
p2 = mp(x2,y2);
forn(i,n-2){
cin >> x3 >> y3;
p3 = mp(x3,y3);
pt b = p2-p1;
pt c = p3-p2;
if(acos(b*c/(n(b)*n(c)))<)
p1=p2;
p2=p3;
}
if(fair) cout << "Fair";
else cout << "Unfair";
}
}
return 0;
}
| [
"[email protected]"
] | |
b3d67c0271c80fba198b5beb5cf3da391462de14 | 1fcdb2bc2c7f75f6aed466119a4b1c53777f0b7a | /holly_inletwfine_kappaepsilon_noturbulence5/13/p | 577123cd9a87d35fa1c11d073631b7cfb0d18262 | [] | no_license | bshambaugh/openfoam-experiments3 | b32549e80836eee9fc6062873fc737155168f919 | 4bd90a951845a4bc5dda7063e91f6cc0ba730e48 | refs/heads/master | 2020-04-15T08:17:15.156512 | 2019-01-15T04:31:23 | 2019-01-15T04:31:23 | 164,518,405 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 61,404 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "13";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
6785
(
594.448
519.097
471.49
419.504
373.179
328.916
287.499
248.288
211.157
175.916
141.762
108.778
80.213
49.4647
9.43377
6.12558
-11.5916
-2.59854
-8.87616
-8.80365
-11.0311
-11.8676
-12.4282
-12.1055
-10.8262
-8.49625
-5.20093
-0.0884224
5.87026
8.03796
10.6074
5.03973
13.8309
9.07707
12.1092
10.9282
11.2535
10.6606
10.1528
9.37927
8.68266
8.57548
8.53024
7.82806
7.00755
12.0989
7.7344
9.69729
3.54617
3.40249
-0.922496
-3.14348
-6.4626
-9.30026
-12.2211
-14.6703
-16.1047
-16.8862
-17.6085
-16.8543
-10.1186
-13.0375
-10.5739
-14.044
-11.7496
-13.7147
-12.9554
-13.4468
-13.2826
-13.2193
-12.8578
-12.1493
-10.6427
-9.47668
-7.23224
6.72505
6.33229
9.66759
8.39949
11.7496
11.6485
13.7881
14.9162
16.5067
18.0036
19.6179
21.1311
22.9152
24.1743
26.3615
28.7545
29.4385
32.2231
31.4838
34.2263
34.3144
35.998
36.9194
38.088
39.1801
40.3092
41.3737
42.6147
43.547
44.8651
45.452
46.3357
48.3371
47.725
49.7553
49.6385
50.8297
51.2545
51.951
52.6334
53.4091
54.2384
55.1929
55.8919
56.892
57.4669
58.3828
59.7165
59.532
61.2269
61.3811
62.5655
62.934
63.4215
63.3779
63.0385
62.6667
62.5067
62.7745
62.9477
66.8742
66.1159
66.8971
65.6659
66.2164
65.0085
64.6667
63.2421
61.8492
59.9902
58.2007
56.6534
55.6819
55.5481
54.1756
52.1577
48.4858
47.8238
45.0597
44.2805
42.104
41.0831
39.4742
38.3161
36.7782
35.2147
33.8104
33.1832
32.3167
29.1325
16.1182
11.5541
9.83896
6.50741
4.28802
1.0194
-1.61399
-4.65009
-7.29593
-9.83194
-11.6959
-12.6279
-13.2647
-14.0745
-14.1981
0.473519
-1.96141
-3.85107
-6.62184
-8.3273
-10.762
-12.4898
-14.0174
-14.7209
-14.7723
-14.0198
-12.6648
-10.8682
-9.48405
-7.4918
5.42645
7.49773
8.6221
8.82303
9.44681
10.0076
11.082
12.1508
13.3095
14.4378
15.5721
16.5419
17.5714
18.1964
19.5816
53.0714
53.0559
52.151
47.6981
42.6669
39.0774
35.7782
32.8022
30.5099
28.8028
27.2133
26.1131
25.4111
24.9845
24.1532
42.5658
42.9629
43.2047
43.2051
43.3135
43.6292
44.2032
44.0433
43.9517
43.8445
44.1634
43.7408
43.5266
43.7296
43.1466
42.9757
42.9775
43.1209
42.2302
42.3707
42.6275
41.8067
41.6261
42.0656
42.2457
41.4151
41.2808
41.821
42.1511
41.224
41.7618
42.0823
41.4698
41.3687
41.9092
42.1429
41.5443
41.9133
42.1277
41.798
41.6963
42.0005
41.95
41.6878
41.5774
41.7484
41.5406
41.2247
41.3499
41.1925
41.0218
40.9191
41.0163
41.0461
40.9573
40.8683
40.9102
41.2206
41.1504
41.1449
41.455
41.4453
41.4144
41.3393
41.6639
41.8341
42.4679
41.6215
40.4834
41.619
42.5354
36.6816
33.8364
36.7967
38.7341
19.4987
27.7955
32.4187
-6.20524
4.10796
9.25607
7.44845
11.0597
4.66656
6.62812
11.7116
12.0672
13.0642
13.6513
14.6246
16.4441
19.6762
20.5583
15.5729
17.37
20.2012
23.0831
23.6013
24.9696
25.7038
27.3847
31.6339
28.2718
30.495
30.994
32.7031
35.3286
36.9363
37.6922
38.6937
37.9999
43.5104
42.3485
43.9578
44.5823
45.0535
46.5992
49.0307
49.8383
46.8357
51.7874
53.0168
55.0661
55.6356
54.9799
54.2575
53.6013
55.0739
51.5015
58.5988
60.2401
56.812
56.887
56.3531
53.741
51.7437
49.2756
42.4745
52.4254
54.6386
48.2036
44.9175
40.3347
35.8014
31.5611
28.5397
24.7031
19.4561
19.1769
21.6469
16.4212
15.3998
13.7283
11.156
4.64578
2.51101
5.03246
-3.36698
7.76823
5.80943
5.54531
11.1785
6.22378
8.83912
8.00292
9.87837
12.4914
8.67062
10.9295
12.5548
10.0234
10.9675
10.327
11.1356
12.6536
10.3562
11.0922
10.4063
11.1401
12.3121
9.88382
11.0676
11.918
10.0988
10.6073
9.9696
10.4848
11.4294
9.63756
10.108
9.44874
9.97108
10.7542
8.80075
9.65624
10.2232
8.74331
9.0846
8.51946
8.86105
9.50753
8.08322
8.38924
7.83992
8.16821
8.67785
7.18672
7.74895
8.07192
6.95381
7.14219
6.69601
6.86579
7.19604
6.17177
6.31524
5.89701
6.03156
6.20842
5.21506
5.46632
5.48326
4.73171
4.74759
4.40805
4.39717
4.35493
3.68784
3.63835
3.31408
3.26366
3.07051
2.3691
2.42728
2.25249
1.38232
1.18393
1.06821
0.499509
0.269807
0.00117555
0.00192243
0.00309857
0.00390839
0.00483282
0.00563978
0.00645706
0.00721613
0.00794659
0.0086254
0.00925656
0.00983218
0.0103539
0.0108235
0.0112488
0.0116412
0.0120161
0.0123913
0.0127849
0.0132115
0.0136797
0.0141904
0.014739
0.0153212
0.0159434
0.0166326
0.0174429
0.0184526
0.0197425
0.0213523
0.023233
0.0252519
0.0272596
0.0291054
0.030619
0.0316639
0.0321369
0.0319948
0.0312957
0.0302003
0.0289535
0.0278052
0.0268943
0.0261446
0.0252911
0.0240141
0.0219164
0.0184242
0.012786
0.00406153
-0.00856197
-0.0246279
-0.0428529
-0.0714533
-0.123249
-0.0709733
-0.681696
-0.640326
-0.794025
-0.969463
-1.03819
-1.0638
-1.04281
-0.930699
-0.783375
-0.583762
-0.355182
-0.141694
0.0726758
0.247262
0.396928
0.494951
0.57316
0.588874
0.620082
0.612129
0.568028
0.677937
0.39035
0.00332314
0.00535154
0.00861811
0.0109058
0.0134401
0.0156594
0.0178675
0.0199055
0.0218383
0.0236131
0.0252357
0.0266885
0.0279754
0.0291045
0.0300987
0.0309923
0.0318308
0.0326664
0.0335511
0.0345272
0.0356187
0.036827
0.0381371
0.0395363
0.0410415
0.0427295
0.0447549
0.0473413
0.0507193
0.0549998
0.0600367
0.0654457
0.0708064
0.0757051
0.0796743
0.0823474
0.0834482
0.0828649
0.0807634
0.0775862
0.0739844
0.0705602
0.0674774
0.0641047
0.0591114
0.0510558
0.0387287
0.0213583
-0.00116067
-0.0286208
-0.0606511
-0.0959181
-0.133518
-0.175586
-0.2173
-0.160821
-0.975213
-1.00801
-1.30956
-1.65488
-1.85406
-1.9696
-1.97506
-1.78639
-1.51425
-1.13156
-0.691202
-0.270355
0.141634
0.482073
0.751111
0.948462
1.06879
1.14167
1.17214
1.21267
1.18169
1.2979
1.10695
0.00519019
0.00869068
0.014266
0.0181675
0.0224991
0.0262924
0.0300738
0.0335689
0.0368919
0.0399512
0.0427581
0.0452821
0.0475297
0.0495141
0.0512734
0.0528648
0.0543646
0.0558605
0.0574399
0.0591745
0.0611046
0.0632328
0.0655337
0.0679847
0.0706136
0.0735486
0.0770503
0.081497
0.0872813
0.0945945
0.103191
0.112424
0.121583
0.129967
0.136785
0.141411
0.143372
0.142471
0.138988
0.13368
0.127683
0.122089
0.117299
0.11242
0.105406
0.0939842
0.0760997
0.0501267
0.0151927
-0.0292686
-0.0835283
-0.146511
-0.217411
-0.294533
-0.392267
-0.471428
-1.00987
-1.16296
-1.52575
-1.95451
-2.22252
-2.38541
-2.40592
-2.17815
-1.84682
-1.37449
-0.834009
-0.315993
0.188423
0.604958
0.928325
1.16925
1.30705
1.39837
1.4367
1.46996
1.48983
1.52576
1.56113
0.00694692
0.0118848
0.0196554
0.0251384
0.0311912
0.036503
0.0417852
0.0466687
0.051306
0.0555736
0.0594851
0.0629994
0.0661251
0.0688808
0.0713202
0.0735233
0.0755971
0.0776648
0.0798492
0.0822508
0.0849262
0.0878781
0.0910695
0.0944663
0.098105
0.102163
0.107005
0.113163
0.121197
0.131379
0.143364
0.156238
0.169011
0.180705
0.190214
0.196667
0.199398
0.198128
0.193239
0.185794
0.177392
0.169581
0.162932
0.15617
0.146395
0.130415
0.105387
0.0691333
0.0205842
-0.0408419
-0.115408
-0.202477
-0.301957
-0.405478
-0.550013
-0.854416
-1.05728
-1.41856
-1.83591
-2.3722
-2.71627
-2.92568
-2.95787
-2.67664
-2.26973
-1.6859
-1.02027
-0.382459
0.238035
0.749917
1.14592
1.44116
1.60794
1.71533
1.76828
1.78521
1.84857
1.82559
2.15554
0.0085363
0.0149829
0.0249544
0.0320587
0.0398626
0.0467282
0.0535442
0.0598506
0.0658362
0.0713462
0.0763964
0.0809345
0.0849711
0.0885303
0.0916806
0.0945255
0.0972029
0.099872
0.102692
0.105793
0.109248
0.11306
0.117178
0.121556
0.126235
0.13144
0.137641
0.145532
0.155847
0.168954
0.184404
0.201006
0.217489
0.23259
0.244885
0.25325
0.256811
0.255198
0.248886
0.239241
0.228342
0.218217
0.209638
0.200968
0.188499
0.168226
0.13665
0.091092
0.0301522
-0.0471287
-0.141538
-0.253479
-0.383792
-0.521971
-0.731954
-1.2071
-1.00642
-1.71947
-2.18634
-2.84204
-3.27504
-3.53837
-3.58553
-3.24337
-2.7513
-2.04108
-1.23396
-0.460446
0.290926
0.910479
1.38741
1.74473
1.94279
2.07215
2.13721
2.14574
2.24544
2.17348
2.60353
0.0100085
0.0179909
0.030105
0.038838
0.0483729
0.0567878
0.0651238
0.072843
0.080163
0.0869021
0.0930754
0.098621
0.103551
0.107894
0.111734
0.115199
0.118457
0.121704
0.125136
0.128914
0.133128
0.13778
0.142803
0.148135
0.153819
0.160125
0.16763
0.177194
0.189739
0.205738
0.224635
0.24495
0.265133
0.283635
0.298711
0.308986
0.313371
0.311392
0.303605
0.291674
0.278162
0.265594
0.254938
0.24417
0.228752
0.203911
0.165585
0.110701
0.0375817
-0.055104
-0.168736
-0.304917
-0.465367
-0.640085
-0.905876
-1.41142
-0.915957
-2.05191
-2.53528
-3.29756
-3.81994
-4.13573
-4.19679
-3.79045
-3.21432
-2.37835
-1.43387
-0.529169
0.347865
1.06983
1.62298
2.03908
2.26507
2.4154
2.49059
2.48951
2.624
2.50154
2.96596
0.0113618
0.0209301
0.0351456
0.045528
0.0567916
0.0667681
0.0766292
0.0857699
0.0944308
0.102406
0.109708
0.116266
0.122091
0.12722
0.131751
0.135833
0.139669
0.143491
0.147533
0.151988
0.156964
0.16246
0.168392
0.174676
0.181355
0.188742
0.197517
0.208719
0.223473
0.242373
0.264751
0.288822
0.312755
0.334711
0.352621
0.364854
0.370087
0.367727
0.358393
0.344039
0.327723
0.312491
0.299533
0.286426
0.267813
0.238254
0.193263
0.129436
0.0447455
-0.0627175
-0.195214
-0.355742
-0.547035
-0.762198
-1.07581
-1.52759
-0.921543
-2.41585
-2.90982
-3.76258
-4.37619
-4.74347
-4.81666
-4.34011
-3.67781
-2.71261
-1.63017
-0.594374
0.407671
1.23068
1.85904
2.33284
2.58577
2.7559
2.8404
2.82737
2.99396
2.82321
3.36138
0.0126147
0.0238101
0.040072
0.0521177
0.0650972
0.0766395
0.0880216
0.0985842
0.108583
0.117792
0.126219
0.133784
0.140499
0.146405
0.151615
0.156303
0.160703
0.165085
0.169725
0.174847
0.180577
0.186911
0.193745
0.200969
0.208619
0.217047
0.227041
0.239824
0.256748
0.278545
0.304429
0.332287
0.360009
0.385462
0.406246
0.420469
0.426558
0.423776
0.412779
0.395799
0.376409
0.358215
0.34265
0.32688
0.304749
0.27027
0.218654
0.146187
0.0503853
-0.0714153
-0.222553
-0.407512
-0.630225
-0.888234
-1.24496
-1.64976
-1.15683
-2.78423
-3.33044
-4.24884
-4.95817
-5.37799
-5.46199
-4.90736
-4.15457
-3.05353
-1.82921
-0.659124
0.470263
1.39548
2.09974
2.63176
2.91108
3.10134
3.19354
3.16866
3.36341
3.14696
3.72071
0.0137747
0.0266435
0.0448984
0.0586233
0.0733074
0.0864226
0.0993246
0.111313
0.122651
0.133096
0.142648
0.151219
0.158819
0.165497
0.171379
0.176663
0.181614
0.186546
0.191773
0.197555
0.204035
0.211207
0.218941
0.227096
0.235698
0.245129
0.256288
0.270594
0.28965
0.314351
0.343782
0.375476
0.407047
0.436056
0.459773
0.47603
0.482981
0.479709
0.466874
0.446982
0.424148
0.402593
0.384027
0.365197
0.339202
0.299658
0.24158
0.160893
0.0544998
-0.0812282
-0.250922
-0.460667
-0.715888
-1.0189
-1.41928
-1.82763
-1.65912
-3.13233
-3.80432
-4.75444
-5.56499
-6.03845
-6.131
-5.48905
-4.64108
-3.3973
-2.02789
-0.721131
0.536816
1.56426
2.34406
2.93405
3.2384
3.44914
3.54679
3.51069
3.72944
3.47119
4.04823
0.0148523
0.0294387
0.0496299
0.0650479
0.0814226
0.0961157
0.110534
0.123951
0.136628
0.148308
0.158982
0.168556
0.177037
0.184478
0.191021
0.196887
0.202377
0.207843
0.213644
0.220076
0.227301
0.235308
0.243938
0.253015
0.262543
0.272934
0.285194
0.300954
0.322097
0.349709
0.382732
0.418318
0.453803
0.486435
0.513143
0.531474
0.539266
0.535385
0.520455
0.497258
0.470509
0.445109
0.423075
0.400747
0.370572
0.325928
0.26167
0.173243
0.0567618
-0.0925556
-0.280817
-0.515838
-0.804817
-1.15431
-1.60197
-2.07122
-2.33083
-3.38528
-4.3299
-5.28156
-6.20003
-6.729
-6.82664
-6.08636
-5.13763
-3.74321
-2.22537
-0.779585
0.607882
1.7372
2.5919
3.23933
3.56709
3.79866
3.89919
3.8526
4.09134
3.79293
4.41213
0.015855
0.0322041
0.0542753
0.0714
0.0894505
0.105727
0.121659
0.136506
0.150521
0.163438
0.175233
0.185807
0.195163
0.20336
0.210552
0.216987
0.222999
0.228983
0.235344
0.242416
0.250381
0.259222
0.268748
0.278737
0.289166
0.300469
0.313761
0.330897
0.354077
0.384611
0.421284
0.460827
0.500304
0.536634
0.566396
0.586827
0.595402
0.590715
0.573323
0.546317
0.515092
0.485298
0.459287
0.433038
0.398474
0.348857
0.278838
0.18322
0.0571553
-0.105462
-0.312385
-0.573313
-0.897478
-1.29482
-1.79507
-2.35879
-2.96999
-3.48479
-4.90525
-5.83475
-6.8686
-7.45709
-7.55515
-6.70342
-5.64711
-4.09269
-2.42237
-0.834541
0.683725
1.91476
2.84384
3.54816
3.89766
4.15061
4.25115
4.19525
4.44974
4.11176
4.75293
0.01679
0.034946
0.0588407
0.0776847
0.0973951
0.115259
0.132701
0.14898
0.164333
0.178487
0.191402
0.202972
0.213196
0.222139
0.229969
0.236957
0.243473
0.249958
0.256862
0.264562
0.273264
0.282939
0.293359
0.304252
0.315555
0.327717
0.34196
0.360382
0.385543
0.419015
0.459405
0.50298
0.546534
0.586639
0.61951
0.642036
0.651263
0.645459
0.625111
0.593692
0.55738
0.522626
0.49214
0.461642
0.422656
0.368378
0.293138
0.190922
0.0557658
-0.119908
-0.345645
-0.63319
-0.994009
-1.44066
-1.99873
-2.66
-3.42351
-3.53229
-5.55159
-6.41984
-7.57444
-8.23008
-8.32238
-7.34355
-6.17152
-4.44627
-2.61884
-0.88559
0.764864
2.09736
3.10012
3.86076
4.23005
4.50514
4.60244
4.53898
4.80437
4.43232
5.06029
0.0176632
0.0376705
0.0633329
0.0839082
0.105262
0.124717
0.143665
0.161378
0.178068
0.193459
0.207492
0.220056
0.231142
0.240821
0.249274
0.256798
0.263799
0.270764
0.278194
0.286512
0.295944
0.306454
0.31777
0.329558
0.341708
0.354671
0.369778
0.389385
0.416462
0.45289
0.497075
0.544765
0.592491
0.636445
0.672455
0.697005
0.706639
0.699263
0.67534
0.638852
0.596859
0.556619
0.52125
0.486346
0.443116
0.384658
0.30483
0.19663
0.052855
-0.135674
-0.380425
-0.695342
-1.09429
-1.59198
-2.21282
-2.9641
-3.74898
-3.68766
-6.25845
-7.04647
-8.32012
-9.05616
-9.13496
-8.01017
-6.71274
-4.80428
-2.81475
-0.932304
0.852153
2.28569
3.36112
4.17706
4.56417
4.86221
4.95271
4.88385
5.15532
4.74889
5.40995
0.01848
0.0403824
0.0677577
0.0900753
0.113055
0.134105
0.154554
0.173704
0.191731
0.208359
0.223507
0.23706
0.249001
0.259406
0.268467
0.276509
0.283973
0.291396
0.299333
0.308255
0.318413
0.32976
0.341975
0.354651
0.367619
0.381322
0.397194
0.41787
0.44679
0.4862
0.534268
0.586163
0.638156
0.686015
0.725138
0.751529
0.761161
0.751597
0.723397
0.681215
0.633051
0.586923
0.546421
0.507168
0.460074
0.398052
0.314326
0.200763
0.0488153
-0.152403
-0.416398
-0.759447
-1.19794
-1.74871
-2.43726
-3.27417
-4.06702
-4.092
-6.96403
-7.73066
-9.10738
-9.94448
-10.0009
-8.7076
-7.27317
-5.16744
-3.01032
-0.974332
0.946402
2.4806
3.62822
4.49748
4.89979
5.22181
5.30174
5.23003
5.50245
5.06547
5.71629
0.0192449
0.043086
0.0721204
0.0961909
0.120779
0.143427
0.165372
0.18596
0.205323
0.223189
0.239451
0.253989
0.266777
0.277895
0.287549
0.296089
0.303993
0.311849
0.320273
0.329784
0.340664
0.352851
0.365969
0.379528
0.393285
0.407663
0.42419
0.445805
0.476484
0.518906
0.570956
0.627152
0.683498
0.735272
0.777379
0.805253
0.814276
0.801766
0.768589
0.72024
0.66562
0.61339
0.567704
0.524372
0.473957
0.409078
0.322173
0.203855
0.0441517
-0.169621
-0.453103
-0.825017
-1.30439
-1.91039
-2.67101
-3.5916
-4.42529
-4.80328
-7.64542
-8.48858
-9.93741
-10.9045
-10.9296
-9.44088
-7.85554
-5.53672
-3.20551
-1.01111
1.04819
2.68259
3.9025
4.82261
5.23714
5.58403
5.64923
5.57776
5.84561
5.38004
6.0245
0.0199616
0.0457852
0.0764261
0.102259
0.128438
0.152685
0.176122
0.19815
0.218848
0.237952
0.255327
0.270846
0.284472
0.296292
0.306521
0.315536
0.323855
0.332119
0.341005
0.351091
0.362688
0.375721
0.389749
0.404188
0.418706
0.433687
0.450749
0.473153
0.505497
0.550967
0.607107
0.667696
0.728452
0.784059
0.828849
0.857615
0.865208
0.848929
0.810224
0.755529
0.694458
0.636119
0.585383
0.538418
0.485341
0.418365
0.329006
0.206522
0.0394484
-0.186766
-0.489968
-0.891423
-1.41287
-2.07615
-2.91202
-3.91587
-4.84356
-5.78958
-8.25879
-9.32311
-10.8114
-11.9458
-11.9313
-10.2158
-8.46287
-5.91293
-3.40017
-1.04203
1.15812
2.89216
4.18425
5.15253
5.57807
5.94859
5.99502
5.92722
6.18487
5.69155
6.33695
0.0206336
0.0484831
0.0806791
0.108284
0.136035
0.161884
0.186808
0.210277
0.23231
0.252653
0.271137
0.287632
0.302089
0.314597
0.325384
0.33485
0.343555
0.352199
0.361522
0.372166
0.384476
0.398362
0.41331
0.428629
0.443879
0.459389
0.476852
0.499877
0.533777
0.582336
0.642682
0.70774
0.772891
0.832089
0.879008
0.907801
0.912983
0.892191
0.847741
0.786945
0.719727
0.65544
0.599926
0.549903
0.494897
0.426612
0.335512
0.209423
0.0353383
-0.203212
-0.526345
-0.95792
-1.52247
-2.2447
-3.15768
-4.24588
-5.31771
-6.89451
-8.6868
-10.2114
-11.7323
-13.0788
-13.0176
-11.0391
-9.09878
-6.29671
-3.5941
-1.0665
1.27683
3.10989
4.47383
5.48734
5.92411
6.31525
6.33899
6.27844
6.52008
6.00536
6.62383
0.0212633
0.0511827
0.0848835
0.114269
0.143574
0.171027
0.197432
0.222343
0.245711
0.267292
0.286885
0.304352
0.31963
0.332813
0.344136
0.354029
0.363092
0.372083
0.381816
0.393
0.40602
0.420767
0.436649
0.452849
0.468806
0.484766
0.502484
0.525936
0.561268
0.612962
0.677628
0.747182
0.816583
0.878879
0.927056
0.954745
0.956496
0.93075
0.880872
0.814672
0.741837
0.671849
0.611915
0.559496
0.503338
0.43454
0.342394
0.213235
0.0324756
-0.218305
-0.561531
-1.02369
-1.63211
-2.41449
-3.40518
-4.57998
-5.81665
-7.83774
-8.88563
-11.1463
-12.7036
-14.3148
-14.2016
-11.9184
-9.76754
-6.68888
-3.78713
-1.08389
1.40498
3.33633
4.77161
5.82717
6.27528
6.68412
6.68016
6.63183
6.85111
6.31569
6.91913
0.0218531
0.0538865
0.089043
0.120217
0.151057
0.180115
0.207996
0.234351
0.259053
0.281875
0.302574
0.321008
0.337098
0.35094
0.36278
0.373072
0.38246
0.391764
0.401877
0.413583
0.427309
0.442929
0.459761
0.47685
0.493488
0.509817
0.527628
0.551288
0.587907
0.642784
0.711859
0.785838
0.859121
0.923683
0.9719
0.997178
0.994671
0.964106
0.909742
0.839197
0.761364
0.68592
0.621966
0.567879
0.511374
0.442859
0.350343
0.218623
0.0315111
-0.231384
-0.594815
-1.08788
-1.74065
-2.58375
-3.65185
-4.91555
-6.30511
-8.44704
-9.04297
-12.1315
-13.728
-15.6667
-15.497
-12.8622
-10.4741
-7.09059
-3.97907
-1.09354
1.54324
3.57206
5.07795
6.17215
6.63137
7.05439
7.02002
6.9874
7.17809
6.62135
7.22693
0.0224046
0.0565968
0.0931606
0.126131
0.158488
0.18915
0.218502
0.246303
0.272339
0.296401
0.318205
0.337602
0.354494
0.368981
0.381315
0.391978
0.401656
0.411237
0.421697
0.433903
0.448332
0.464839
0.482642
0.500631
0.517929
0.534542
0.55227
0.575887
0.613622
0.67172
0.745234
0.823386
0.899854
0.965455
1.01218
1.03377
1.02671
0.992236
0.934874
0.861203
0.778942
0.698228
0.630673
0.575697
0.519675
0.452242
0.360012
0.226223
0.0330669
-0.241821
-0.625527
-1.14968
-1.84698
-2.75073
-3.89543
-5.25039
-6.77318
-8.86906
-9.39589
-13.0987
-14.8242
-17.1468
-16.9183
-13.8798
-11.224
-7.50337
-4.16972
-1.09476
1.69226
3.81765
5.39313
6.52238
6.9923
7.42498
7.36293
7.34355
7.50097
6.93134
7.51188
0.022919
0.0593157
0.0972392
0.132013
0.165868
0.198136
0.228953
0.258201
0.285571
0.310875
0.333782
0.354137
0.371821
0.386936
0.399742
0.410745
0.420676
0.430494
0.441265
0.453948
0.469077
0.486488
0.505289
0.524195
0.542135
0.558945
0.576396
0.59968
0.638327
0.699649
0.777504
0.859293
0.937846
1.00285
1.04639
1.06339
1.05235
1.01564
0.957057
0.881436
0.795177
0.709283
0.638557
0.58353
0.528845
0.463302
0.372004
0.23662
0.0377017
-0.249083
-0.653122
-1.20845
-1.95015
-2.91398
-4.13427
-5.58287
-7.22646
-9.28896
-10.2058
-13.9944
-16.0329
-18.7677
-18.4799
-14.9809
-12.0231
-7.92908
-4.35891
-1.08685
1.85274
4.07368
5.71741
6.87796
7.35789
7.79551
7.71084
7.69917
7.81954
7.23409
7.80837
0.0233973
0.0620451
0.101281
0.137865
0.1732
0.207073
0.23935
0.270045
0.298751
0.325298
0.349308
0.370615
0.389082
0.404808
0.418061
0.429371
0.439515
0.449527
0.46057
0.473706
0.489533
0.507867
0.527697
0.547542
0.566113
0.583034
0.599993
0.622608
0.661908
0.726377
0.808253
0.892764
0.971852
1.03427
1.0731
1.08547
1.07201
1.03521
0.977182
0.900597
0.81058
0.719484
0.646032
0.591863
0.539413
0.476587
0.386858
0.25032
0.0458553
-0.252811
-0.677302
-1.26384
-2.04962
-3.07262
-4.36759
-5.91171
-7.67259
-9.79116
-11.462
-14.7118
-17.3602
-20.5491
-20.1972
-16.1758
-12.8779
-8.36993
-4.54654
-1.06907
2.02535
4.34071
6.05103
7.23897
7.72782
8.16565
8.06337
8.05458
8.13393
7.53701
8.10205
0.02384
0.0647865
0.105288
0.143689
0.180485
0.215962
0.249694
0.281839
0.31188
0.339672
0.364783
0.387038
0.406277
0.422597
0.436272
0.447855
0.45817
0.468328
0.4796
0.493161
0.509684
0.528967
0.549863
0.570677
0.589873
0.606817
0.62305
0.644598
0.684201
0.751588
0.836843
0.922727
1.00034
1.05806
1.09137
1.10028
1.08666
1.05199
0.996086
0.919272
0.825532
0.729092
0.653391
0.60108
0.551824
0.492572
0.405026
0.267698
0.0577607
-0.252956
-0.698174
-1.316
-2.14548
-3.2267
-4.59569
-6.23696
-8.11995
-10.3756
-12.7759
-15.0802
-18.7771
-22.5151
-22.0878
-17.4749
-13.7948
-8.82824
-4.73265
-1.0407
2.21076
4.61929
6.39417
7.60547
8.10166
8.53501
8.42011
8.41006
8.44405
7.8366
8.38116
0.0242472
0.0675416
0.109262
0.149485
0.187725
0.224804
0.259986
0.293581
0.324959
0.353999
0.38021
0.403409
0.423409
0.440306
0.454375
0.466195
0.476635
0.486888
0.498343
0.512301
0.529518
0.549775
0.571781
0.593603
0.613427
0.630308
0.645551
0.665547
0.704959
0.774784
0.862397
0.94783
1.02154
1.0729
1.1012
1.10881
1.09753
1.067
1.01448
0.937908
0.84027
0.738221
0.660794
0.611463
0.56644
0.511641
0.42683
0.288918
0.0733142
-0.249935
-0.716425
-1.36579
-2.23867
-3.37727
-4.82004
-6.56032
-8.57357
-10.9921
-13.7064
-15.3161
-20.2865
-24.6866
-24.1715
-18.8892
-14.7804
-9.30625
-4.91744
-1.00102
2.40966
4.90996
6.74697
7.97748
8.47886
8.90322
8.78059
8.76576
8.74999
8.13537
8.68453
0.0246188
0.0703118
0.113205
0.155255
0.194919
0.233599
0.270227
0.305273
0.33799
0.36828
0.395591
0.419729
0.44048
0.457935
0.472371
0.484389
0.494906
0.5052
0.516786
0.531107
0.549017
0.57028
0.593446
0.616323
0.636788
0.65352
0.667471
0.685301
0.723796
0.795275
0.883834
0.96641
1.03378
1.07835
1.10353
1.11249
1.10586
1.08111
1.0329
0.956812
0.85489
0.746833
0.668279
0.6232
0.583536
0.534063
0.452391
0.3138
0.0919075
-0.244813
-0.733499
-1.41489
-2.33101
-3.52639
-5.04319
-6.88502
-9.0374
-11.6215
-14.3975
-15.8195
-21.7916
-27.1224
-26.4683
-20.4291
-15.8411
-9.80587
-5.10128
-0.949316
2.6227
5.21323
7.10952
8.35496
8.85874
9.26993
9.14408
9.12195
9.05165
8.44616
8.96248
0.0249542
0.0730983
0.117116
0.161
0.202068
0.242348
0.280415
0.316916
0.350974
0.382516
0.410928
0.436001
0.457491
0.475485
0.49026
0.502436
0.512977
0.523253
0.534914
0.549562
0.568164
0.59047
0.614854
0.638843
0.659969
0.676463
0.688757
0.703607
0.740161
0.812248
0.899811
0.976577
1.03608
1.0752
1.10002
1.11283
1.1127
1.09499
1.05177
0.976177
0.869362
0.754753
0.675768
0.636385
0.603288
0.559931
0.481512
0.341655
0.112241
-0.239467
-0.75168
-1.46578
-2.42509
-3.67685
-5.26831
-7.21509
-9.51581
-12.2742
-15.1461
-17.0635
-23.2245
-29.9176
-28.9927
-22.1032
-16.9827
-10.3287
-5.28469
-0.884948
2.85055
5.52957
7.48188
8.73784
9.24055
9.63476
9.50966
9.47854
9.34883
8.75963
9.22972
0.0252527
0.0759024
0.120998
0.16672
0.209173
0.25105
0.290552
0.328508
0.363909
0.396707
0.426221
0.452225
0.474444
0.492958
0.508042
0.520334
0.530844
0.541037
0.552712
0.567647
0.58694
0.610328
0.635996
0.661164
0.682981
0.699132
0.709293
0.720065
0.753419
0.824803
0.908564
0.976742
1.02879
1.0652
1.09242
1.1111
1.11889
1.10915
1.07137
0.996112
0.883552
0.761678
0.68308
0.651026
0.625736
0.589065
0.513514
0.371091
0.132157
-0.236655
-0.774036
-1.52155
-2.52387
-3.83165
-5.49872
-7.55438
-10.0116
-12.9632
-16.0915
-19.0596
-24.4227
-33.1317
-31.7679
-23.9185
-18.2104
-10.8763
-5.46812
-0.807297
3.09382
5.85944
7.86403
9.12596
9.62338
9.99736
9.87622
9.8348
9.6419
9.07224
9.52432
0.0255133
0.0787251
0.124849
0.172413
0.216233
0.259703
0.300635
0.340048
0.376797
0.410855
0.441472
0.468403
0.49134
0.510354
0.525717
0.538081
0.548502
0.558542
0.570164
0.585342
0.605324
0.62984
0.656865
0.683287
0.705823
0.721478
0.728833
0.734152
0.763035
0.831693
0.908065
0.966508
1.01362
1.05041
1.08229
1.1083
1.12503
1.12397
1.09195
1.01668
0.897243
0.767188
0.689945
0.667031
0.650724
0.620877
0.547042
0.399831
0.148564
-0.239928
-0.804105
-1.58538
-2.63021
-3.99351
-5.73727
-7.90598
-10.5269
-13.6999
-17.2318
-21.2152
-25.2606
-36.8625
-34.8293
-25.8817
-19.5292
-11.4499
-5.65169
-0.715738
3.35314
6.20324
8.25592
9.51912
10.0062
10.3573
10.2425
10.1895
9.93156
9.39981
9.79087
0.0257345
0.0815674
0.12867
0.178081
0.223246
0.268307
0.310664
0.351537
0.389637
0.42496
0.456682
0.484537
0.508181
0.527675
0.543285
0.555676
0.565945
0.575758
0.587252
0.602624
0.623293
0.648986
0.677448
0.705201
0.728465
0.743349
0.746928
0.745445
0.76857
0.831034
0.896909
0.947168
0.992928
1.03271
1.07082
1.10516
1.13158
1.13977
1.11373
1.03794
0.910149
0.770755
0.696013
0.684188
0.6778
0.65418
0.579867
0.424611
0.157526
-0.253272
-0.845358
-1.66003
-2.74629
-4.1644
-5.9859
-8.27172
-11.0632
-14.4887
-18.4871
-22.9656
-26.0841
-41.3261
-38.1896
-28.0017
-20.9435
-12.0506
-5.83488
-0.609561
3.6291
6.56133
8.65744
9.91703
10.388
10.7142
10.6073
10.5412
10.2193
9.72135
10.0596
0.0259149
0.0844303
0.13246
0.183721
0.230212
0.27686
0.320637
0.362972
0.402427
0.439021
0.471851
0.500627
0.524967
0.544922
0.560748
0.573117
0.583168
0.592673
0.603958
0.619469
0.640821
0.667744
0.697727
0.726877
0.750807
0.764374
0.762996
0.753814
0.768926
0.820632
0.875407
0.921224
0.968948
1.01351
1.05886
1.1022
1.13891
1.15684
1.13696
1.05995
0.921931
0.771754
0.700859
0.702117
0.706073
0.686992
0.608747
0.441237
0.154631
-0.28049
-0.900536
-1.74726
-2.87329
-4.3452
-6.2453
-8.652
-11.6214
-15.3315
-19.8283
-24.5736
-27.4024
-46.3672
-41.8815
-30.2829
-22.4565
-12.678
-6.01622
-0.487857
3.92236
6.93403
9.06841
10.3193
10.7675
11.0675
10.9692
10.8885
10.5083
10.0482
10.3322
0.0260525
0.0873145
0.13622
0.189334
0.237129
0.28536
0.330552
0.374351
0.415167
0.453038
0.486979
0.516673
0.5417
0.562095
0.578104
0.590403
0.600166
0.609274
0.620261
0.635849
0.657881
0.686089
0.717667
0.748241
0.772582
0.783875
0.776668
0.759131
0.761695
0.799146
0.845871
0.891482
0.943356
0.993765
1.04699
1.09979
1.14734
1.17553
1.16196
1.08283
0.932205
0.769471
0.703992
0.720196
0.734032
0.716344
0.629402
0.444916
0.135671
-0.324429
-0.971081
-1.84753
-3.0111
-4.53542
-6.51457
-9.04551
-12.2008
-16.2297
-21.2546
-26.2809
-29.8002
-51.8417
-45.9777
-32.7258
-24.0684
-13.3302
-6.19336
-0.349424
4.23361
7.32163
9.48857
10.7256
11.1434
11.4165
11.327
11.23
10.8006
10.3708
10.5871
0.0261452
0.0902209
0.139947
0.194916
0.243995
0.293803
0.340406
0.385672
0.427854
0.467009
0.502066
0.532677
0.55838
0.579195
0.595354
0.607531
0.616933
0.62555
0.63614
0.651735
0.674438
0.703983
0.737212
0.769118
0.793207
0.800977
0.788043
0.761064
0.745847
0.767496
0.811056
0.859826
0.91726
0.974148
1.0356
1.09828
1.15721
1.19625
1.18914
1.10678
0.940547
0.76312
0.704855
0.73745
0.75934
0.738155
0.636747
0.430964
0.0975433
-0.386332
-1.05684
-1.95984
-3.15815
-4.73297
-6.79095
-9.44883
-12.7986
-17.1798
-22.7615
-28.1987
-33.3622
-57.653
-50.4808
-35.3221
-25.7723
-14.0039
-6.36324
-0.192641
4.56373
7.72442
9.91761
11.1353
11.5142
11.7604
11.6793
11.5643
11.0973
10.6873
10.8745
0.0261908
0.0931502
0.14364
0.200467
0.250807
0.302186
0.350195
0.396931
0.440487
0.480934
0.517112
0.548638
0.575007
0.596222
0.612498
0.624502
0.633465
0.641488
0.651571
0.667094
0.690452
0.721375
0.756247
0.789116
0.811713
0.814982
0.79634
0.754942
0.713945
0.729235
0.773132
0.827901
0.891181
0.955026
1.02501
1.09799
1.16895
1.21948
1.21904
1.13206
0.946502
0.751872
0.702821
0.752414
0.778616
0.747263
0.625539
0.39584
0.0390414
-0.465533
-1.156
-2.08165
-3.31124
-4.93386
-7.06942
-9.85591
-13.4085
-18.173
-24.3406
-30.3817
-38.0378
-63.5786
-55.3445
-38.0545
-27.5542
-14.6949
-6.52233
-0.0153495
4.91386
8.14274
10.3552
11.5479
11.8784
12.0982
12.0248
11.8902
11.3994
11.0153
11.1329
0.0261866
0.0961031
0.147298
0.205983
0.257562
0.310505
0.359915
0.408125
0.453061
0.494811
0.532115
0.564556
0.59158
0.613176
0.629536
0.641314
0.649756
0.657075
0.666529
0.681886
0.705873
0.738181
0.774535
0.807481
0.827021
0.825283
0.798909
0.735314
0.670747
0.688855
0.731995
0.796224
0.865579
0.936705
1.01552
1.09929
1.18302
1.24586
1.25234
1.15907
0.94959
0.734894
0.697218
0.762941
0.787182
0.737833
0.591521
0.338154
-0.03879
-0.559506
-1.2652
-2.20885
-3.46535
-5.13187
-7.3423
-10.2576
-14.02
-19.1942
-25.978
-32.8403
-43.7509
-69.4486
-60.5513
-40.9097
-29.3981
-15.3989
-6.66666
0.18526
5.28558
8.57707
10.8008
11.9628
12.2341
12.4286
12.3623
12.2065
11.7075
11.333
11.3912
0.0261297
0.0990801
0.15092
0.211463
0.264255
0.318756
0.369561
0.419248
0.465575
0.508636
0.547075
0.580429
0.608101
0.630057
0.646469
0.657965
0.665801
0.672295
0.680985
0.696066
0.720629
0.754258
0.791595
0.823127
0.838596
0.831999
0.794029
0.699331
0.625982
0.648845
0.690636
0.765542
0.840674
0.919531
1.00749
1.10263
1.2
1.27614
1.28992
1.18834
0.949291
0.711452
0.687411
0.765812
0.778953
0.704478
0.532767
0.259168
-0.132796
-0.664107
-1.37954
-2.33564
-3.6134
-5.31838
-7.59907
-10.6413
-14.6186
-20.2223
-27.6529
-35.5493
-50.4168
-75.19
-66.0716
-43.8718
-31.2881
-16.111
-6.7915
0.412693
5.68094
9.02813
11.2541
12.3793
12.5795
12.7501
12.6904
12.5124
12.0222
11.6406
11.6868
0.0260171
0.102082
0.154502
0.216903
0.270884
0.326934
0.379129
0.430297
0.478023
0.522408
0.561989
0.596257
0.624566
0.646864
0.663295
0.674456
0.681594
0.687133
0.694903
0.709573
0.734621
0.769331
0.806613
0.835193
0.847332
0.837498
0.77504
0.656508
0.580258
0.607185
0.649412
0.735973
0.816858
0.903895
1.00132
1.10852
1.22055
1.31121
1.33284
1.22053
0.944994
0.681179
0.672823
0.755927
0.747066
0.644032
0.450512
0.162594
-0.238132
-0.773798
-1.49267
-2.45445
-3.74627
-5.48246
-7.82686
-10.9921
-15.1864
-21.2319
-29.3372
-38.4554
-57.8429
-80.797
-71.8072
-46.9121
-33.2048
-16.8238
-6.89084
0.671059
6.10263
9.49703
11.7149
12.7965
12.9123
13.0611
13.008
12.8075
12.3442
11.966
11.9483
0.0258454
0.105109
0.158042
0.222299
0.277443
0.335032
0.388613
0.441264
0.490401
0.536122
0.576855
0.612038
0.640975
0.663596
0.680014
0.690783
0.697129
0.701568
0.708241
0.72233
0.747682
0.782897
0.818667
0.843872
0.854666
0.837323
0.744633
0.613739
0.53244
0.564677
0.609488
0.707763
0.794509
0.890193
0.997466
1.1175
1.24544
1.35214
1.38242
1.25636
0.935918
0.644764
0.652268
0.725481
0.685917
0.557082
0.34898
0.0539421
-0.348685
-0.881831
-1.59686
-2.55621
-3.85338
-5.61199
-8.01196
-11.2942
-15.7048
-22.196
-30.9975
-41.4868
-65.7727
-86.3782
-77.6177
-49.9777
-35.1208
-17.5258
-6.95722
0.964866
6.55397
9.98542
12.1828
13.2137
13.2302
13.3599
13.3137
13.0917
12.6728
12.2752
12.2253
0.025611
0.108161
0.161537
0.227648
0.283927
0.343045
0.398004
0.452144
0.502703
0.549774
0.591669
0.627768
0.657325
0.680251
0.696625
0.706947
0.712399
0.715576
0.720943
0.734225
0.759523
0.794232
0.827521
0.851358
0.862825
0.823101
0.713471
0.569526
0.483153
0.520927
0.571496
0.68126
0.774044
0.878833
0.996388
1.13018
1.2755
1.40018
1.4402
1.29626
0.921262
0.604935
0.621727
0.66482
0.594048
0.448139
0.234444
-0.0601405
-0.457416
-0.980496
-1.68344
-2.6312
-3.92407
-5.69559
-8.14228
-11.5341
-16.1577
-23.0904
-32.5988
-44.5706
-73.9225
-91.6654
-83.1726
-53.0029
-36.9998
-18.2013
-6.98209
1.29878
7.03889
10.4957
12.6582
13.63
13.5306
13.6444
13.6066
13.3652
13.0083
12.5912
12.5104
0.0253099
0.11124
0.164985
0.232945
0.29033
0.350964
0.407296
0.462929
0.514922
0.563359
0.606428
0.643444
0.673612
0.696824
0.713125
0.722941
0.72739
0.729123
0.732934
0.74509
0.769688
0.802784
0.834175
0.860123
0.865012
0.802462
0.683409
0.523023
0.433598
0.474624
0.535935
0.656698
0.755899
0.870256
0.9986
1.14723
1.31171
1.45677
1.50781
1.3397
0.901227
0.565855
0.571112
0.566322
0.475806
0.324306
0.114226
-0.172385
-0.556721
-1.06166
-1.74373
-2.67055
-3.94972
-5.72521
-8.21021
-11.7034
-16.5341
-23.8972
-34.1105
-47.6373
-81.8647
-96.5426
-88.3869
-55.9342
-38.7977
-18.8338
-6.95639
1.67747
7.56174
11.031
13.1417
14.0443
13.8104
13.9127
13.8857
13.6287
13.3498
12.9
12.7925
0.0249381
0.114345
0.168382
0.238184
0.296646
0.358783
0.41648
0.47361
0.527052
0.576871
0.621126
0.659062
0.689831
0.713313
0.72951
0.73876
0.742083
0.74216
0.744108
0.754657
0.777654
0.808863
0.840822
0.870253
0.855993
0.784196
0.652083
0.475668
0.385178
0.425613
0.503597
0.634365
0.740567
0.864905
1.00464
1.16935
1.35511
1.52353
1.58649
1.38415
0.87966
0.528677
0.484732
0.429492
0.340082
0.193608
-0.00402049
-0.275352
-0.639028
-1.11775
-1.77058
-2.66812
-3.92579
-5.69801
-8.21407
-11.8
-16.8295
-24.6061
-35.5113
-50.6208
-89.2946
-100.987
-93.206
-58.698
-40.4698
-19.4068
-6.87092
2.1056
8.12718
11.5956
13.6346
14.4558
14.0666
14.1631
14.1503
13.883
13.697
13.2021
13.1205
0.024491
0.117477
0.171724
0.243362
0.302868
0.366492
0.425547
0.484178
0.539083
0.590303
0.635758
0.674616
0.705977
0.729708
0.745769
0.754387
0.756445
0.754618
0.75431
0.762577
0.783297
0.814098
0.850389
0.874291
0.844647
0.767652
0.619373
0.428906
0.339411
0.37493
0.475031
0.614564
0.728545
0.863254
1.01508
1.19729
1.40686
1.60212
1.67571
1.4251
0.866471
0.48671
0.350368
0.262772
0.196762
0.0641939
-0.112833
-0.362028
-0.697686
-1.143
-1.75976
-2.62186
-3.85262
-5.61642
-8.15749
-11.8272
-17.0454
-25.2141
-36.7902
-53.4648
-95.8427
-104.384
-97.3911
-61.2181
-41.968
-19.9072
-6.71644
2.58796
8.73981
12.1946
14.1393
14.8634
14.2961
14.3936
14.3999
14.1292
14.0489
13.5275
13.4213
0.023964
0.120636
0.175007
0.248471
0.308987
0.374082
0.434486
0.494621
0.551006
0.603646
0.650317
0.690099
0.72204
0.746
0.761888
0.769795
0.770424
0.766392
0.763321
0.768577
0.78728
0.820241
0.861947
0.870259
0.836816
0.750681
0.586448
0.383713
0.298089
0.324417
0.450904
0.597686
0.720363
0.865768
1.03049
1.23181
1.46817
1.69375
1.77072
1.45763
0.868712
0.407267
0.155718
0.0799356
0.0560453
-0.0569866
-0.205368
-0.426624
-0.728018
-1.13457
-1.71073
-2.53374
-3.73445
-5.48626
-8.04699
-11.7911
-17.1869
-25.7235
-37.9449
-56.1105
-100.987
-106.517
-100.634
-63.4229
-43.2543
-20.3141
-6.48289
3.12955
9.40394
12.8342
14.6597
15.2661
14.4955
14.6028
14.6345
14.3681
14.4041
13.8434
13.7456
0.023352
0.123821
0.178227
0.253506
0.314996
0.381541
0.443284
0.504928
0.562809
0.616893
0.664795
0.705501
0.738008
0.762169
0.77784
0.784939
0.783937
0.777335
0.770926
0.772879
0.791309
0.829591
0.868507
0.86615
0.830763
0.733447
0.55409
0.340963
0.262807
0.276664
0.431806
0.584181
0.716531
0.872919
1.05144
1.27367
1.54022
1.79803
1.86044
1.48031
0.878903
0.231733
-0.0642025
-0.117115
-0.0744732
-0.163737
-0.276751
-0.46542
-0.728172
-1.09287
-1.6262
-2.40841
-3.57728
-5.31431
-7.88956
-11.6987
-17.2608
-26.1399
-38.9784
-58.5046
-104.558
-107.901
-102.845
-65.269
-44.283
-20.6058
-6.16207
3.73548
10.1234
13.5212
15.2011
15.6631
14.6622
14.7891
14.8543
14.6006
14.7627
14.1507
14.1292
0.0226497
0.127034
0.181379
0.258459
0.320885
0.388859
0.451931
0.515086
0.574482
0.630031
0.679181
0.72081
0.753862
0.778189
0.793577
0.79974
0.796857
0.787264
0.777081
0.776381
0.797012
0.841703
0.868948
0.865548
0.824843
0.716904
0.522656
0.301579
0.234249
0.234902
0.418129
0.574614
0.717535
0.885141
1.07845
1.32358
1.62391
1.91047
1.92963
1.50464
0.877705
-0.0578136
-0.265876
-0.313546
-0.18847
-0.251897
-0.324314
-0.477624
-0.699267
-1.02101
-1.51074
-2.25133
-3.38692
-5.10649
-7.69134
-11.557
-17.2749
-26.4698
-39.8942
-60.6212
-106.952
-108.759
-104.291
-66.7344
-45.019
-20.7702
-5.7466
4.41063
10.9012
14.263
15.7714
16.0537
14.7934
14.9514
15.0602
14.8273
15.1235
14.4992
14.4688
0.0218515
0.130273
0.184458
0.263323
0.326644
0.396023
0.46041
0.52508
0.58601
0.643049
0.693463
0.73601
0.769577
0.794012
0.809023
0.814077
0.809014
0.796052
0.782207
0.780569
0.80578
0.851302
0.869872
0.866752
0.819325
0.701547
0.492565
0.266377
0.21127
0.202214
0.41013
0.569587
0.723801
0.902816
1.11193
1.38215
1.7191
2.02
1.97013
1.54847
0.775293
-0.37619
-0.456046
-0.491277
-0.282772
-0.319785
-0.348163
-0.465048
-0.644693
-0.923408
-1.36913
-2.06717
-3.16785
-4.86741
-7.45763
-11.3728
-17.2363
-26.7194
-40.6926
-62.4513
-108.473
-108.996
-104.901
-67.773
-45.4487
-20.796
-5.23019
5.15934
11.7399
15.0671
16.3809
16.4371
14.8876
15.0885
15.2531
15.0492
15.4853
14.8311
14.87
0.0209517
0.133538
0.187458
0.268089
0.332263
0.403018
0.468707
0.534893
0.597376
0.655931
0.707625
0.751076
0.785109
0.809568
0.82406
0.827773
0.820212
0.803766
0.787263
0.787068
0.818318
0.85653
0.874002
0.868442
0.81491
0.687573
0.464495
0.236158
0.190421
0.181293
0.407789
0.569755
0.735657
0.926242
1.15218
1.44973
1.82298
2.10983
1.99561
1.62882
0.504481
-0.660947
-0.656978
-0.637139
-0.359535
-0.367487
-0.350786
-0.431271
-0.568698
-0.804344
-1.20515
-1.85915
-2.92325
-4.60087
-7.19362
-11.153
-17.1514
-26.8925
-41.3694
-63.9923
-109.272
-108.519
-104.624
-68.3566
-45.5637
-20.6727
-4.60912
5.98522
12.6412
15.9408
17.0435
16.8129
14.9437
15.1995
15.4348
15.2663
15.8469
15.1966
15.2526
0.0199442
0.136829
0.190375
0.272749
0.33773
0.409831
0.476804
0.544506
0.608564
0.66866
0.721644
0.765973
0.800396
0.824744
0.838512
0.840599
0.830314
0.810783
0.793264
0.796262
0.831616
0.861865
0.880049
0.87074
0.811922
0.675232
0.43943
0.212079
0.165755
0.173968
0.410837
0.575723
0.753311
0.955592
1.19932
1.5261
1.92766
2.1641
2.02402
1.67082
0.156571
-0.909961
-0.882008
-0.744818
-0.422469
-0.397165
-0.336059
-0.380288
-0.475091
-0.666884
-1.02103
-1.62923
-2.65572
-4.31086
-6.90532
-10.9047
-17.0244
-26.9901
-41.9168
-65.247
-109.422
-107.308
-103.516
-68.4872
-45.3648
-20.3944
-3.88275
6.89104
13.6063
16.8908
17.7764
17.1804
14.9617
15.2831
15.6068
15.4792
16.208
15.5701
15.6424
0.0188226
0.140144
0.193203
0.277293
0.343034
0.416446
0.484684
0.5539
0.619551
0.681213
0.73549
0.780649
0.81534
0.839376
0.852139
0.852308
0.839341
0.817777
0.801252
0.80872
0.842473
0.869611
0.886857
0.874108
0.810481
0.664913
0.418879
0.196883
0.133185
0.179955
0.419068
0.587924
0.776847
0.990892
1.25326
1.6097
2.01955
2.18689
2.09807
1.55281
-0.164735
-1.12519
-1.13259
-0.821109
-0.476021
-0.411749
-0.307869
-0.315351
-0.366393
-0.51257
-0.817746
-1.37895
-2.36833
-4.00243
-6.59983
-10.6341
-16.8569
-27.0102
-42.3264
-66.2213
-108.958
-105.409
-101.669
-68.1885
-44.8667
-19.9588
-3.05325
7.87854
14.6356
17.9226
18.6012
17.5382
14.9423
15.3373
15.7717
15.6873
16.5669
15.9408
16.0853
0.0175807
0.143482
0.195934
0.281711
0.34816
0.422844
0.492326
0.563052
0.630314
0.69356
0.749118
0.795021
0.829796
0.853235
0.86465
0.862697
0.847481
0.8253
0.811243
0.823491
0.852434
0.879189
0.894323
0.878758
0.810733
0.657084
0.404912
0.195137
0.0967912
0.197606
0.432243
0.606647
0.806187
1.032
1.31359
1.69596
2.08144
2.19254
2.20372
1.29107
-0.447738
-1.29486
-1.38911
-0.87588
-0.523339
-0.41394
-0.269007
-0.238344
-0.243675
-0.341735
-0.595846
-1.11051
-2.06534
-3.6823
-6.28493
-10.3455
-16.6476
-26.9492
-42.5922
-66.9224
-107.893
-102.908
-99.2103
-67.496
-44.0928
-19.3657
-2.12509
8.94804
15.7285
19.0407
19.544
17.8829
14.8868
15.3592
15.9316
15.8929
16.9242
16.3978
16.4473
0.0162119
0.146841
0.198563
0.285992
0.353096
0.429009
0.499707
0.571934
0.640822
0.70566
0.762461
0.808969
0.84356
0.86603
0.875747
0.871672
0.855022
0.833658
0.822829
0.838027
0.863398
0.889619
0.902656
0.884758
0.812848
0.652149
0.399299
0.208774
0.0671222
0.224898
0.450442
0.631892
0.841139
1.0786
1.37925
1.77608
2.1044
2.20877
2.23339
1.01546
-0.716512
-1.41182
-1.61988
-0.916523
-0.565438
-0.405357
-0.220856
-0.149795
-0.106917
-0.154208
-0.356448
-0.82748
-1.75262
-3.35881
-5.96776
-10.0407
-16.3934
-26.8035
-42.7133
-67.357
-106.232
-99.8966
-96.2767
-66.4435
-43.0688
-18.6169
-1.10478
10.0978
16.8836
20.2477
20.6365
18.2089
14.7944
15.3439
16.0901
16.0933
17.2651
16.8259
16.6685
0.0147097
0.150221
0.201082
0.290125
0.357828
0.43492
0.506803
0.580518
0.651035
0.717457
0.77542
0.822319
0.856364
0.877433
0.885173
0.879242
0.862188
0.842846
0.835662
0.851372
0.875416
0.900537
0.911936
0.892159
0.816941
0.650396
0.402732
0.232926
0.0572152
0.258998
0.474102
0.663404
0.881375
1.13015
1.44787
1.83749
2.10107
2.27617
2.10245
0.78093
-0.986332
-1.48901
-1.80429
-0.946212
-0.601691
-0.386499
-0.163549
-0.0493126
0.0444193
0.0499261
-0.102066
-0.535043
-1.43766
-3.04116
-5.65328
-9.71844
-16.0905
-26.5715
-42.6948
-67.5313
-104.019
-96.5283
-92.9902
-65.064
-41.8229
-17.719
-0.00069724
11.3235
18.0977
21.5441
21.9154
18.5029
14.6648
15.2811
16.2471
16.2948
17.61
17.2996
16.9745
0.0130678
0.153616
0.203486
0.294098
0.36234
0.440555
0.513586
0.588765
0.660903
0.728867
0.78785
0.834836
0.867889
0.887127
0.892763
0.885474
0.869036
0.852518
0.84908
0.864207
0.887905
0.911911
0.922153
0.901019
0.823068
0.65216
0.414729
0.252982
0.0765585
0.297757
0.503679
0.70074
0.92643
1.18582
1.51453
1.86719
2.08784
2.36191
1.88872
0.571048
-1.25779
-1.55388
-1.93968
-0.966048
-0.630146
-0.357065
-0.096428
0.0639491
0.210888
0.269631
0.162977
-0.23962
-1.12941
-2.73784
-5.34326
-9.37651
-15.737
-26.2548
-42.5465
-67.453
-101.343
-93.0292
-89.4643
-63.4024
-40.3892
-16.6854
1.17759
12.6182
19.366
22.9283
23.4316
18.7495
14.4663
15.1623
16.4113
16.4993
17.8741
17.9778
15.481
0.01128
0.157026
0.205767
0.297899
0.366615
0.445893
0.520026
0.596632
0.670356
0.739773
0.799551
0.846227
0.877802
0.894852
0.898454
0.890454
0.875498
0.862214
0.862078
0.876908
0.900447
0.923705
0.933278
0.911382
0.831297
0.658354
0.435825
0.253846
0.122929
0.339973
0.539401
0.743277
0.975717
1.24423
1.57137
1.86413
2.09395
2.36408
1.70175
0.36243
-1.52516
-1.63425
-2.02967
-0.97694
-0.648407
-0.316276
-0.0184502
0.190942
0.392651
0.502306
0.432788
0.0515845
-0.837764
-2.45462
-5.03652
-9.01287
-15.3336
-25.8583
-42.2812
-67.1324
-98.2884
-89.5372
-85.8087
-61.5165
-38.806
-15.5338
2.42038
13.9723
20.6817
24.3926
25.2451
18.8995
14.1944
14.9518
16.5739
16.7072
18.0671
18.0348
14.1005
0.00934079
0.160445
0.207918
0.301513
0.370639
0.450908
0.526087
0.604062
0.679301
0.75001
0.810263
0.856164
0.885795
0.90043
0.902267
0.894311
0.881546
0.871652
0.874164
0.889373
0.912873
0.935839
0.945279
0.923256
0.841802
0.671111
0.469508
0.241061
0.185025
0.384965
0.580984
0.790302
1.02848
1.30286
1.60902
1.84543
2.14557
2.23936
1.56416
0.152104
-1.78148
-1.75426
-2.08102
-0.979275
-0.654081
-0.263209
0.071562
0.332502
0.589029
0.743337
0.700804
0.330579
-0.572091
-2.19318
-4.7304
-8.62748
-14.8844
-25.3897
-41.9117
-66.5829
-94.9283
-86.0681
-82.1174
-59.4647
-37.109
-14.2822
3.7181
15.3739
22.0361
25.9164
27.4419
18.9608
13.6572
14.6355
16.7456
16.8748
18.3387
17.7291
14.5812
0.00724518
0.163868
0.209932
0.304927
0.374393
0.455572
0.531725
0.610984
0.687609
0.759361
0.819684
0.864337
0.891679
0.903905
0.904449
0.897232
0.88712
0.880647
0.885358
0.901377
0.925087
0.948228
0.958113
0.936544
0.854573
0.691617
0.510461
0.23994
0.252287
0.432941
0.627631
0.841015
1.0837
1.35727
1.62099
1.82903
2.20535
2.07988
1.45162
-0.0488677
-2.01713
-1.93439
-2.10028
-0.973693
-0.644837
-0.197009
0.174761
0.489123
0.797836
0.986199
0.960839
0.588245
-0.339
-1.95119
-4.42264
-8.22307
-14.3963
-24.8574
-41.4488
-65.8222
-91.3608
-82.6561
-78.4586
-57.296
-35.3279
-12.948
5.06071
16.8093
23.4154
27.4323
30.2785
18.883
11.9673
14.1062
16.919
17.0193
18.4879
18.1447
16.8702
0.00498927
0.16729
0.211801
0.308127
0.377858
0.459856
0.536892
0.617306
0.695114
0.767565
0.827496
0.87045
0.895228
0.905214
0.905188
0.89949
0.89231
0.889105
0.895755
0.912767
0.937004
0.960795
0.971694
0.950999
0.869461
0.718508
0.536714
0.271652
0.318565
0.484351
0.678254
0.894544
1.13987
1.40153
1.61343
1.8402
2.19665
1.96281
1.3444
-0.226934
-2.2099
-2.16959
-2.08994
-0.960304
-0.618647
-0.11694
0.292141
0.660608
1.01459
1.22366
1.20716
0.814768
-0.140127
-1.72406
-4.11291
-7.80493
-13.8776
-24.2691
-40.901
-64.8724
-87.6915
-79.3694
-74.8786
-55.0519
-33.4889
-11.5479
6.43728
18.2625
24.8015
28.778
32.8667
18.3728
8.18092
13.273
17.0285
17.1824
18.5469
19.1367
20.0367
0.00257062
0.170701
0.21352
0.311096
0.381016
0.463726
0.541526
0.622913
0.701611
0.774328
0.833378
0.87432
0.896722
0.905126
0.90512
0.901264
0.897042
0.896864
0.905359
0.923469
0.948553
0.973469
0.985911
0.966401
0.887368
0.751759
0.538849
0.332786
0.382772
0.539084
0.731653
0.94991
1.1945
1.43018
1.60377
1.89131
2.10995
1.88929
1.24074
-0.372315
-2.32986
-2.43209
-2.04838
-0.938094
-0.573767
-0.0224592
0.424427
0.845423
1.2321
1.44992
1.43301
1.00197
0.0283973
-1.50728
-3.80326
-7.38007
-13.3366
-23.6308
-40.2742
-63.761
-84.0002
-76.2174
-71.4126
-52.7693
-31.6172
-10.0985
7.83676
19.7175
26.2089
29.9229
34.2341
17.0193
3.09947
12.1692
17.271
17.3846
18.7499
20.2282
23.6893
-1.13003e-05
0.17409
0.21508
0.313818
0.383846
0.467145
0.545557
0.627665
0.706876
0.779389
0.837167
0.875956
0.895967
0.903332
0.904469
0.902907
0.901471
0.903905
0.914135
0.933426
0.95967
0.986176
1.00055
0.982481
0.909571
0.784304
0.539843
0.403213
0.446443
0.596191
0.786717
1.00589
1.24379
1.44252
1.6057
1.94575
2.02231
1.83573
1.1465
-0.480528
-2.34978
-2.68609
-1.97184
-0.905224
-0.508791
0.0868122
0.571845
1.0397
1.44159
1.6618
1.62913
1.14686
0.174077
-1.29831
-3.49768
-6.95584
-12.7806
-22.9464
-39.5718
-62.5182
-80.3609
-73.1967
-68.0853
-50.4804
-29.7353
-8.61456
9.24931
21.1586
27.6918
31.5233
34.8522
14.9501
-2.25185
10.665
17.8923
17.6693
19.1509
21.086
28.6456
-0.00275433
0.177444
0.216474
0.316276
0.386328
0.470071
0.548906
0.631418
0.710702
0.782507
0.838552
0.874962
0.893515
0.90111
0.903619
0.904279
0.905455
0.910218
0.922091
0.942635
0.970318
0.998799
1.01523
0.999121
0.935381
0.798913
0.567777
0.470426
0.510594
0.654367
0.842403
1.06077
1.28386
1.44853
1.63577
1.95252
1.9768
1.7889
1.06583
-0.552439
-2.25355
-2.89233
-1.85816
-0.858724
-0.422831
0.211072
0.733657
1.23616
1.63592
1.85682
1.78514
1.25384
0.304754
-1.09708
-3.20111
-6.53882
-12.2149
-22.2181
-38.795
-61.1722
-76.8383
-70.3296
-64.9112
-48.2108
-27.8612
-7.10913
10.6664
22.5621
29.2814
34.5839
35.4202
12.037
-6.6085
9.07575
18.6604
18.1807
19.9034
22.7884
34.6663
-0.00565273
0.180744
0.217696
0.318453
0.388441
0.472466
0.551491
0.634042
0.712918
0.783525
0.837679
0.872202
0.890508
0.898898
0.902871
0.905623
0.909099
0.91586
0.929214
0.951063
0.980436
1.01113
1.02952
1.01717
0.959858
0.800248
0.617461
0.534068
0.574829
0.71239
0.897577
1.11196
1.31295
1.46154
1.69436
1.92239
1.96383
1.74909
0.999433
-0.593077
-2.04424
-3.0127
-1.70807
-0.795185
-0.315541
0.35025
0.907139
1.42435
1.81313
2.0288
1.89457
1.33314
0.425839
-0.905435
-2.91835
-6.13409
-11.6435
-21.4476
-37.9428
-59.7471
-73.4679
-67.6163
-61.8983
-45.9793
-26.0091
-5.59327
12.0797
23.9021
30.8299
38.1842
36.3618
8.62204
-8.87241
7.57795
19.1139
19.0211
21.317
25.963
39.7498
-0.00869566
0.183965
0.218739
0.320331
0.390167
0.474294
0.553253
0.635474
0.713558
0.78294
0.835136
0.868866
0.887602
0.896839
0.902187
0.90678
0.912253
0.920763
0.935478
0.958681
0.98992
1.02281
1.04332
1.03689
0.9713
0.813366
0.669935
0.59644
0.637863
0.769255
0.950801
1.15642
1.33419
1.4885
1.75018
1.9071
1.96427
1.7209
0.946488
-0.61062
-1.75115
-3.02247
-1.52522
-0.711196
-0.187245
0.503733
1.08599
1.5941
1.97583
2.16636
1.95993
1.39639
0.539409
-0.726113
-2.65326
-5.74518
-11.0698
-20.6371
-37.0122
-58.2612
-70.2715
-65.0517
-59.0489
-43.7989
-24.1897
-4.07661
13.4813
25.1706
32.135
40.6598
37.4939
6.14348
-9.36836
5.9826
18.863
20.2195
23.4957
30.0626
40.0381
-0.0118649
0.187074
0.219599
0.321898
0.391497
0.475538
0.554192
0.635808
0.713168
0.781146
0.831744
0.865592
0.884842
0.894998
0.90164
0.907828
0.914974
0.924932
0.940844
0.965403
0.998538
1.03342
1.05712
1.05277
0.973547
0.843383
0.719827
0.658179
0.698677
0.823983
1.00012
1.1924
1.35698
1.53658
1.77588
1.92202
1.97025
1.70691
0.906778
-0.614111
-1.43072
-2.9116
-1.31742
-0.603775
-0.0389008
0.669586
1.25923
1.74184
2.12423
2.25826
1.99289
1.45206
0.644983
-0.561761
-2.40834
-5.37442
-10.4973
-19.7894
-35.9981
-56.7247
-67.2568
-62.6353
-56.3599
-41.6781
-22.4109
-2.56796
14.8603
26.36
33.1634
41.8121
38.4522
5.90456
-8.82636
4.30137
17.754
21.4583
26.1881
34.4918
38.7724
-0.0151315
0.190026
0.220272
0.323142
0.392434
0.476227
0.554408
0.635344
0.71231
0.778272
0.828375
0.862524
0.882361
0.893437
0.90118
0.908667
0.917147
0.928269
0.945222
0.971076
1.00599
1.04332
1.07069
1.05804
0.983839
0.877443
0.769159
0.717938
0.756521
0.875352
1.04322
1.22089
1.3867
1.59587
1.79146
1.95413
1.98266
1.70706
0.881805
-0.607732
-1.15318
-2.68018
-1.09505
-0.471048
0.127869
0.842887
1.41367
1.87346
2.24953
2.30221
2.00876
1.5038
0.740907
-0.414246
-2.18471
-5.02364
-9.93034
-18.9091
-34.895
-55.1399
-64.4151
-60.3568
-53.8251
-39.6212
-20.6786
-1.07645
16.2036
27.4605
33.9743
42.1451
39.0759
8.9257
-6.86744
2.69606
16.2487
22.5794
29.259
38.12
39.2906
-0.0184506
0.192766
0.22076
0.324067
0.393008
0.476457
0.554159
0.634736
0.710701
0.775131
0.825309
0.85971
0.88023
0.892171
0.900835
0.90932
0.918763
0.930712
0.948482
0.97547
1.01234
1.05346
1.07939
1.06117
1.0035
0.911411
0.818561
0.774792
0.81073
0.921844
1.07862
1.24653
1.4257
1.64323
1.82289
1.99128
2.0036
1.72029
0.875372
-0.585883
-0.99848
-2.35099
-0.864462
-0.312944
0.310461
1.01359
1.54167
1.99719
2.33691
2.30859
2.01953
1.55158
0.825491
-0.284284
-1.98245
-4.6946
-9.3745
-18.0022
-33.6981
-53.5029
-61.7323
-58.2041
-51.4364
-37.6292
-18.9965
0.38916
17.4982
28.4634
34.6031
42.0519
39.2006
14.6634
-2.29885
2.89219
16.353
24.5602
32.4884
40.1509
42.3902
-0.0217551
0.195224
0.221069
0.324686
0.393278
0.476363
0.553681
0.634276
0.708436
0.77235
0.822536
0.857258
0.878495
0.891201
0.900575
0.909719
0.919721
0.932133
0.950465
0.978559
1.01849
1.06196
1.08278
1.07195
1.02573
0.946557
0.866824
0.828257
0.860342
0.96186
1.10706
1.27496
1.47328
1.67497
1.86879
2.03058
2.0333
1.74555
0.894207
-0.517034
-1.00142
-1.96281
-0.632964
-0.130471
0.5039
1.16706
1.64879
2.1111
2.37739
2.29525
2.03059
1.59383
0.897715
-0.171448
-1.80108
-4.38924
-8.83615
-17.0769
-32.4047
-51.8064
-59.1958
-56.1656
-49.1846
-35.7019
-17.3693
1.81442
18.7231
29.3557
35.0554
41.6974
38.8675
20.9739
4.29821
6.10706
18.7691
27.5091
35.3788
40.2635
43.5033
-0.0249492
0.197317
0.221214
0.325033
0.393336
0.476122
0.553285
0.633552
0.706229
0.769984
0.820105
0.855236
0.877162
0.890532
0.900401
0.909856
0.91999
0.932485
0.951264
0.981359
1.02502
1.06605
1.08935
1.08739
1.04942
0.982602
0.913121
0.877785
0.904257
0.994513
1.13131
1.30736
1.51845
1.70987
1.91921
2.07328
2.07071
1.78173
0.946712
-0.341831
-1.1112
-1.55169
-0.403471
0.0734344
0.698628
1.29147
1.74957
2.20058
2.37669
2.27794
2.04202
1.629
0.957551
-0.0744789
-1.63988
-4.1096
-8.3225
-16.1437
-31.0158
-50.0403
-56.796
-54.226
-47.0637
-33.8411
-15.8033
3.18564
19.8686
30.145
35.3609
41.1421
38.4525
26.0529
11.1506
11.049
22.2852
30.702
37.6782
39.9258
42.1338
-0.0279039
0.198955
0.221219
0.325156
0.393274
0.475888
0.553181
0.632455
0.70446
0.767984
0.818091
0.853663
0.876229
0.890149
0.900289
0.909706
0.919565
0.931914
0.951779
0.985743
1.02984
1.07076
1.10126
1.10472
1.07508
1.01856
0.956968
0.922569
0.941542
1.0206
1.15549
1.34487
1.55218
1.75419
1.96954
2.12008
2.11465
1.82678
1.03492
-0.0263001
-1.21418
-1.14337
-0.172963
0.293631
0.879307
1.38907
1.85106
2.25069
2.35239
2.26441
2.05188
1.65627
1.00594
0.00823945
-1.49814
-3.85771
-7.84152
-15.2164
-29.5373
-48.1904
-54.5099
-52.3622
-45.0685
-32.0511
-14.3085
4.47884
20.896
30.7861
35.531
40.5118
38.2965
29.7774
17.2277
16.2386
26.0018
33.6032
39.2634
40.1229
41.3483
-0.0304575
0.200043
0.221115
0.325111
0.39318
0.475761
0.553222
0.631403
0.703134
0.766367
0.816532
0.852538
0.87569
0.890038
0.900237
0.909304
0.918599
0.931059
0.95372
0.991078
1.03387
1.08084
1.1156
1.12402
1.10198
1.05374
0.997693
0.9618
0.971976
1.04238
1.18128
1.38347
1.58276
1.8023
2.01989
2.17051
2.16412
1.8773
1.14813
0.391745
-1.18142
-0.747627
0.0632183
0.520872
1.03055
1.47672
1.943
2.26016
2.32294
2.25517
2.05841
1.67579
1.04442
0.0782342
-1.3753
-3.63542
-7.40177
-14.3132
-27.9806
-46.2455
-52.2866
-50.5629
-43.1947
-30.338
-12.9041
5.65921
21.7818
31.3058
35.6738
40.0627
38.3779
32.6046
22.3931
21.1429
29.5441
35.9971
40.1657
40.4393
41.1136
-0.0324249
0.200498
0.220937
0.324948
0.393111
0.475825
0.553144
0.630678
0.70217
0.765154
0.815426
0.851849
0.87552
0.890173
0.900239
0.908722
0.917448
0.931136
0.958151
0.995082
1.04211
1.09419
1.13168
1.14507
1.1293
1.08748
1.03448
0.994993
0.996558
1.06278
1.2094
1.41569
1.61831
1.84979
2.07105
2.22385
2.21812
1.92986
1.26697
0.79633
-0.949244
-0.365067
0.308745
0.739515
1.14928
1.56894
2.00758
2.24279
2.29873
2.2478
2.06082
1.68855
1.07465
0.136662
-1.27095
-3.44411
-7.01165
-13.4571
-26.3664
-44.2212
-50.0917
-48.843
-41.4217
-28.688
-11.5779
6.73585
22.5357
31.6838
35.7197
39.7684
38.5035
34.8294
26.6645
25.6804
32.7188
37.8001
40.616
40.4455
40.7557
-0.0336167
0.200258
0.220725
0.324716
0.393105
0.476098
0.553023
0.630312
0.701538
0.764351
0.814757
0.851578
0.875698
0.890537
0.900317
0.90811
0.916716
0.9333
0.963334
1.00028
1.05479
1.1091
1.14951
1.1671
1.15635
1.11892
1.06661
1.02232
1.0173
1.08406
1.23992
1.44201
1.65702
1.89603
2.12307
2.27967
2.27573
1.98364
1.3786
1.04264
-0.553491
0.00339785
0.560313
0.931198
1.2495
1.66186
2.03684
2.21706
2.28133
2.24023
2.05927
1.696
1.09796
0.184246
-1.1848
-3.28452
-6.67774
-12.6742
-24.7273
-42.1615
-48.0395
-47.2157
-39.7397
-27.1146
-10.3946
7.54148
22.9009
31.6961
35.6021
39.5327
38.6616
36.5572
30.3544
29.8551
35.3931
39.0438
40.79
39.9688
40.1566
-0.0338687
0.199296
0.220501
0.324426
0.393143
0.476387
0.553029
0.630212
0.701212
0.763928
0.814495
0.851692
0.876186
0.891097
0.900473
0.907648
0.917107
0.937815
0.967272
1.01013
1.0695
1.12544
1.1685
1.18939
1.18227
1.14718
1.09374
1.04471
1.03625
1.10659
1.27011
1.46862
1.69554
1.9415
2.17568
2.33771
2.33621
2.04398
1.50867
1.09446
-0.0863737
0.354328
0.80525
1.08646
1.34783
1.73862
2.03859
2.19517
2.26824
2.23152
2.05459
1.69953
1.11522
0.221394
-1.1166
-3.15661
-6.40328
-11.9884
-23.108
-40.0473
-46.3868
-45.595
-38.261
-25.7575
-9.49109
8.0551
23.0937
31.7517
35.6302
39.3268
39.2753
38.6367
34.1261
33.6612
37.4846
39.8198
40.7963
39.6496
39.5332
-0.0330723
0.197637
0.220305
0.324126
0.39328
0.47663
0.553244
0.630337
0.701181
0.763863
0.814613
0.852162
0.87696
0.891843
0.900746
0.907577
0.919064
0.943236
0.972083
1.02366
1.08526
1.14288
1.18792
1.21113
1.2061
1.17154
1.11603
1.06361
1.05485
1.12988
1.29669
1.49705
1.73269
1.98634
2.2287
2.39774
2.3987
2.11947
1.7089
1.05319
0.371602
0.682989
1.02442
1.21226
1.44525
1.78744
2.02841
2.18019
2.25702
2.22166
2.04793
1.70017
1.12696
0.24844
-1.06594
-3.05975
-6.18826
-11.4162
-21.5676
-37.7185
-45.0952
-43.9036
-37.0993
-24.6651
-8.8206
8.38731
23.1143
31.8863
36.2795
40.3685
41.6096
41.9003
38.1029
36.936
38.9912
40.2662
40.7428
39.4851
39.0074
-0.0312084
0.19535
0.220134
0.3238
0.393459
0.476861
0.553593
0.630628
0.701397
0.764107
0.815067
0.852941
0.877963
0.892705
0.901091
0.908022
0.922359
0.947315
0.980663
1.03878
1.10184
1.16078
1.20697
1.23136
1.2269
1.19162
1.13413
1.08037
1.07382
1.15371
1.31997
1.52561
1.7684
2.03038
2.28202
2.45912
2.46062
2.20803
1.96709
1.07767
0.792668
0.981788
1.20405
1.32154
1.52884
1.81075
2.0184
2.17013
2.24651
2.21115
2.04029
1.69854
1.13357
0.265887
-1.03205
-2.99269
-6.0305
-10.9652
-20.1892
-35.1013
-43.4862
-42.2622
-36.1637
-23.7384
-8.24164
8.62486
23.1609
32.3386
37.661
42.5923
45.0994
45.6999
41.7885
39.4956
39.9853
40.4915
40.7137
39.3641
38.6484
-0.0283608
0.192572
0.220024
0.323512
0.393672
0.477192
0.554075
0.631093
0.701852
0.764637
0.815824
0.854002
0.879186
0.893695
0.901582
0.909154
0.926349
0.950449
0.992646
1.0545
1.1188
1.17828
1.22469
1.24906
1.24398
1.20745
1.14884
1.0956
1.09243
1.1769
1.34168
1.55307
1.80272
2.07343
2.33549
2.52106
2.5187
2.29515
2.18641
1.25981
1.17769
1.23955
1.34532
1.41752
1.58826
1.81994
2.01273
2.16255
2.23645
2.20075
2.0324
1.69504
1.1355
0.274514
-1.01368
-2.95338
-5.92617
-10.6334
-19.0531
-32.472
-41.1466
-40.5016
-34.9998
-22.8572
-7.59933
8.98736
23.4045
33.0035
39.2855
45.1235
48.6921
49.2249
44.8013
41.3197
40.5928
40.5916
40.7155
39.2581
38.4688
-0.0247219
0.189475
0.219952
0.323241
0.39386
0.47756
0.554601
0.63166
0.702477
0.765395
0.816831
0.855279
0.880521
0.894642
0.902044
0.910636
0.929528
0.955291
1.00618
1.07038
1.13537
1.19448
1.2401
1.26339
1.25701
1.21948
1.16109
1.10998
1.11066
1.19878
1.36254
1.57882
1.83536
2.11524
2.38884
2.58251
2.5713
2.37325
2.28475
1.57041
1.52368
1.44815
1.45727
1.49398
1.62473
1.82511
2.0104
2.15615
2.22704
2.19109
2.02461
1.68998
1.13339
0.27544
-1.00895
-2.93858
-5.86938
-10.4106
-18.1912
-30.1936
-38.5218
-38.4401
-33.3545
-21.7627
-6.76753
9.55984
23.8604
33.8313
40.9521
47.5728
51.9039
52.1276
47.0553
42.5275
40.9434
40.6404
40.7259
39.1986
38.4026
-0.0205823
0.186267
0.219949
0.323034
0.394123
0.478017
0.555225
0.632365
0.703281
0.766361
0.818051
0.856749
0.881992
0.895647
0.90267
0.912261
0.931164
0.96299
1.01995
1.08584
1.15059
1.20835
1.25232
1.27392
1.26613
1.22817
1.17095
1.12244
1.12655
1.21758
1.38193
1.60283
1.86613
2.15547
2.44169
2.64303
2.6227
2.46013
2.29347
1.91717
1.81851
1.60876
1.54427
1.54706
1.64684
1.83052
2.00955
2.1506
2.21878
2.1827
2.01735
1.684
1.12832
0.270362
-1.01512
-2.94364
-5.85196
-10.2807
-17.5877
-28.4342
-36.202
-36.4267
-31.5829
-20.4546
-5.72746
10.3315
24.5019
34.766
42.5396
49.7371
54.5277
54.3273
48.636
43.2877
41.1405
40.6695
40.7326
39.2127
38.4677
-0.0162738
0.183186
0.219989
0.322838
0.394377
0.478438
0.555826
0.63309
0.704162
0.767455
0.819416
0.858304
0.883364
0.896324
0.903006
0.913301
0.932585
0.9723
1.03325
1.09995
1.16336
1.21891
1.26064
1.28035
1.2715
1.23409
1.17937
1.13452
1.14192
1.23461
1.39956
1.62435
1.89433
2.19354
2.49303
2.69971
2.67084
2.54954
2.31244
2.23162
2.05261
1.72772
1.60615
1.58047
1.66202
1.836
2.00904
2.14586
2.21195
2.17567
2.01063
1.67735
1.12091
0.260606
-1.02951
-2.96324
-5.86356
-10.2223
-17.2
-27.1905
-34.4404
-34.8048
-30.0783
-19.2317
-4.6844
11.1621
25.216
35.6899
43.9169
51.4736
56.4847
55.8651
49.6848
43.7537
41.253
40.6855
40.7326
39.2766
38.7186
-0.0122358
0.18042
0.220104
0.32275
0.394713
0.47893
0.556502
0.633907
0.705145
0.768642
0.820843
0.859882
0.884736
0.897074
0.903467
0.913696
0.935471
0.981477
1.0451
1.11166
1.17305
1.22611
1.26562
1.28375
1.27431
1.23775
1.18528
1.14311
1.15279
1.24745
1.41469
1.6435
1.9195
2.22815
2.54057
2.74959
2.71031
2.60016
2.40813
2.48662
2.22275
1.80918
1.64525
1.60085
1.67349
1.84064
2.00863
2.14228
2.20695
2.17042
2.00527
1.67152
1.11364
0.250126
-1.04587
-2.98775
-5.8898
-10.2123
-16.9835
-26.4013
-33.2753
-33.7056
-29.009
-18.2957
-3.84881
11.8628
25.8371
36.448
44.9503
52.6923
57.7842
56.8506
50.3569
44.04
41.3265
40.695
40.7292
39.3812
38.7993
-0.00880046
0.178332
0.220187
0.322696
0.394957
0.479298
0.557037
0.634599
0.706038
0.769777
0.822216
0.861273
0.885585
0.89696
0.902906
0.913556
0.939634
0.989656
1.0543
1.11949
1.17854
1.22932
1.26704
1.28396
1.27418
1.23874
1.18929
1.15139
1.1643
1.25912
1.42656
1.65826
1.9399
2.25771
2.58108
2.78558
2.73093
2.60396
2.54641
2.67499
2.32951
1.85494
1.66734
1.61348
1.6814
1.84371
2.00826
2.1399
2.2036
2.16664
2.001
1.66627
1.1064
0.239206
-1.06304
-3.01394
-5.92259
-10.2302
-16.884
-25.9533
-32.5821
-33.0432
-28.351
-17.6871
-3.28465
12.3538
26.2793
36.959
45.5874
53.3945
58.5113
57.4065
50.7513
44.2168
41.38
40.7147
40.7031
39.5816
38.7811
-0.00612565
0.176611
0.220354
0.322766
0.395241
0.479688
0.557567
0.635262
0.706842
0.770704
0.823191
0.862105
0.886057
0.897169
0.903185
0.914443
0.942589
0.994183
1.05946
1.12401
1.18166
1.23093
1.26753
1.28393
1.27426
1.23937
1.1906
1.15332
1.16732
1.26424
1.43445
1.66872
1.9542
2.27768
2.60586
2.80507
2.74305
2.60342
2.64336
2.78836
2.39746
1.88004
1.6769
1.6195
1.68547
1.84525
2.00806
2.13874
2.20199
2.16485
1.99901
1.66388
1.10319
0.234474
-1.07031
-3.02493
-5.93648
-10.24
-16.8531
-25.7911
-32.3383
-32.8137
-28.0858
-17.4141
-3.02775
12.5787
26.4753
37.1671
45.8245
53.6543
58.7998
57.6612
50.9835
44.3388
41.4507
40.7483
40.7207
39.924
41.6242
)
;
boundaryField
{
inletFace
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
inletWalls
{
type zeroGradient;
}
outletInlet
{
type cyclicAMI;
value nonuniform List<scalar>
15
(
15.5766
18.4412
21.7474
25.6964
29.4585
34.0969
38.6705
42.3863
46.6089
48.5092
46.9794
46.3358
37.4172
30.6922
26.7238
)
;
}
fineSymmetryWall
{
type symmetryPlane;
}
fineWalls
{
type zeroGradient;
}
fineCyclicBoundary
{
type fixedValue;
value uniform 0;
}
fineplug
{
type cyclicAMI;
value nonuniform List<scalar>
80
(
15.6406
14.6077
16.6712
16.1233
14.1389
17.2813
17.6034
18.1731
18.5085
19.0647
20.1653
22.134
23.4113
19.7892
20.8162
22.434
24.3817
24.6778
25.4597
25.8792
26.8397
28.8193
27.8182
29.0885
29.3736
30.3503
32.0776
33.4506
33.8825
34.4548
34.0584
34.8635
37.2748
38.1944
38.5513
38.8205
39.7038
41.748
42.5369
40.8212
40.6253
44.3532
45.9495
47.1254
46.7508
46.3379
45.963
46.8045
46.1769
47.122
51.1703
49.2114
49.2543
49.9747
48.9948
47.8535
46.4432
42.5569
47.6742
51.6642
47.9869
46.1091
43.4904
40.8999
40.3854
38.6589
36.4665
33.4683
38.5632
34.9789
32.1222
31.5386
30.5835
29.1136
25.3955
24.1794
25.6202
29.8133
27.1836
26.0642
)
;
}
faceFine
{
type zeroGradient;
}
}
// ************************************************************************* //
| [
"[email protected]"
] | ||
7dfb0a45902dc05fd1043bee9aab9da5921b7323 | fd0535d648b47310240603f980ada2decc71d79a | /Aplikacja_deksktop/mainwindow.h | eea2213fc6e56274dc84d60fddbc7ca7499168a0 | [] | no_license | Fariusz/CRUD_Library | 85811a3ac42f686756fba4a1b43308726f7d8793 | 37ea03075975f9d7575dd5edd56e09a62029552e | refs/heads/master | 2022-11-08T05:38:26.083328 | 2020-06-27T13:53:24 | 2020-06-27T13:53:24 | 275,373,590 | 0 | 0 | null | 2020-06-27T13:04:52 | 2020-06-27T13:04:51 | null | UTF-8 | C++ | false | false | 372 | h | #ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void on_btn_Dodaj_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
| [
"[email protected]"
] | |
3c9d188370709ecfbb83b41cf4ecf683f03ab86c | 6f874ccb136d411c8ec7f4faf806a108ffc76837 | /code/Windows-classic-samples/Samples/Win7Samples/security/cryptoapi/CertSelect/CPP/CertSelect.cpp | 88cb058717425e8bcc2a7d6b94cf44b9d123dc30 | [
"MIT"
] | permissive | JetAr/ZDoc | c0f97a8ad8fd1f6a40e687b886f6c25bb89b6435 | e81a3adc354ec33345e9a3303f381dcb1b02c19d | refs/heads/master | 2022-07-26T23:06:12.021611 | 2021-07-11T13:45:57 | 2021-07-11T13:45:57 | 33,112,803 | 8 | 8 | null | null | null | null | UTF-8 | C++ | false | false | 7,374 | cpp | //
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// --------------------------------------------------------------------------
// This sample shows how to use the new certificate selection API in Windows 7
// CertSelectCertificateChains to select certificates. It also shows how to
// display the selected certificates to the user for selection using
// CredUIPromptForWindowsCredentials API.
//
// Requirements:
//
// Scenario: Selecting a certificate for signing email
// Select a certificate that meets the following criteria
// a. Is from the user MY store
// b. Has the SMIME EKU
// c. Has the Digital Signature KU
// d. Is not expired
//
// NOTE: THIS SAMPLE WILL NOT COMPILE ON WINDOWS VISTA AS THIS USES NEW APIS AVAILABLE IN WINDOWS 7.
#include <windows.h>
#include <winerror.h>
#include <strsafe.h>
#include <wincrypt.h>
#include <stdio.h>
#include <cryptuiapi.h>
#include <wincred.h>
/*****************************************************************************
ReportError
Prints error information to the console
*****************************************************************************/
void
ReportError(
LPCWSTR wszMessage,
DWORD dwErrCode
)
{
LPWSTR pwszMsgBuf = NULL;
if( NULL!=wszMessage && 0!=*wszMessage )
{
wprintf( L"%s\n", wszMessage );
}
FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, // Location of message
// definition ignored
dwErrCode, // Message identifier for
// the requested message
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Language identifier for
// the requested message
(LPWSTR) &pwszMsgBuf, // Buffer that receives
// the formatted message
0, // Size of output buffer
// not needed as allocate
// buffer flag is set
NULL // Array of insert values
);
if( NULL != pwszMsgBuf )
{
wprintf( L"Error: 0x%08x (%d) %s\n", dwErrCode, dwErrCode, pwszMsgBuf );
LocalFree(pwszMsgBuf);
}
else
{
wprintf( L"Error: 0x%08x (%d)\n", dwErrCode, dwErrCode );
}
}
/*****************************************************************************
wmain
*****************************************************************************/
DWORD
__cdecl
wmain(
int argc,
LPWSTR argv[]
)
{
HRESULT hr = S_OK;
HCERTSTORE hStore = NULL;
PCCERT_CHAIN_CONTEXT *prgpSelection = 0;
DWORD cSelection = 0;
BYTE bDigSig = CERT_DIGITAL_SIGNATURE_KEY_USAGE; // in byte 0
ULONG ulAuthPackage;
BOOL bSave = FALSE;
DWORD cbAuthBuffer = 0;
DWORD dwError = ERROR_SUCCESS;
DWORD dwAuthError = 0;
void * pBuffer = NULL;
ULONG ulSize = 0;
LPVOID pbAuthBuffer;
PCCERT_CONTEXT pCertContext = NULL;
CREDUI_INFO CredUiInfo;
CredUiInfo.pszCaptionText = L"Select your credentials";
CredUiInfo.pszMessageText = L"Please select a certificate";
CredUiInfo.cbSize = sizeof(CredUiInfo);
CredUiInfo.hbmBanner = NULL;
CredUiInfo.hwndParent = NULL;
ulAuthPackage = (ULONG) CERT_CREDENTIAL_PROVIDER_ID;
CERT_SELECTUI_INPUT certInput = {0};
void* rgParaEKU[] =
{
szOID_PKIX_KP_EMAIL_PROTECTION
};
CERT_SELECT_CRITERIA EKUCriteria =
{
CERT_SELECT_BY_ENHKEY_USAGE,
ARRAYSIZE(rgParaEKU),
rgParaEKU
};
CERT_EXTENSION extDigSig =
{
NULL, // pszObjId
FALSE, // fCritical
{1, &bDigSig} // Value
};
void* rgParaKU[] =
{
&extDigSig // digital signature key usage
};
CERT_SELECT_CRITERIA KUCriteria =
{
CERT_SELECT_BY_KEY_USAGE,
ARRAYSIZE(rgParaKU),
rgParaKU
};
CERT_SELECT_CRITERIA rgCriteriaFilter[] =
{
EKUCriteria,
KUCriteria
};
hStore = CertOpenStore(
CERT_STORE_PROV_SYSTEM_W,
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
NULL,
CERT_SYSTEM_STORE_CURRENT_USER,
L"MY"
);
if( NULL == hStore )
{
hr = HRESULT_FROM_WIN32( GetLastError() );
goto CleanUp;
}
wprintf( L"Looking for certificates in MY store ...\n" );
if( !CertSelectCertificateChains(
NULL,
CERT_SELECT_TRUSTED_ROOT | CERT_SELECT_HAS_PRIVATE_KEY,
NULL,
ARRAYSIZE(rgCriteriaFilter),
rgCriteriaFilter,
hStore,
&cSelection,
&prgpSelection))
{
hr = HRESULT_FROM_WIN32( GetLastError() );
goto CleanUp;
}
if( cSelection < 1 )
{
wprintf( L"No certificates found matching the selection criteria.\n" );
goto CleanUp;
}
wprintf( L"%u certificates found matching the selection criteria.\n", cSelection );
//
// show the selected cert in UI
//
certInput.prgpChain = prgpSelection;
certInput.cChain = cSelection;
hr = CertSelectionGetSerializedBlob(
&certInput,
&pBuffer,
&ulSize);
if(S_OK != hr)
goto CleanUp;
dwError = CredUIPromptForWindowsCredentials(
&CredUiInfo,
dwAuthError,
(PULONG)&ulAuthPackage,
pBuffer,
ulSize,
&pbAuthBuffer,
&cbAuthBuffer,
&bSave,
CREDUIWIN_AUTHPACKAGE_ONLY);
if(ERROR_SUCCESS != dwError)
{
hr = HRESULT_FROM_WIN32(GetLastError());
}
else
{
//get the selected cert context
if( !CertAddSerializedElementToStore( NULL,
(BYTE *)pbAuthBuffer,
cbAuthBuffer,
CERT_STORE_ADD_ALWAYS,
0, // flags
CERT_STORE_CERTIFICATE_CONTEXT_FLAG,
NULL,
reinterpret_cast<const void **>(&pCertContext)
))
{
goto CleanUp;
}
//
// pCertContext now is ready to use
//
}
CleanUp:
if( FAILED( hr ))
{
ReportError( NULL, hr );
}
if( NULL != pBuffer )
{
LocalFree(pBuffer);
}
if( NULL != pCertContext )
{
CertFreeCertificateContext(pCertContext);
}
return (DWORD)hr;
UNREFERENCED_PARAMETER( argc );
UNREFERENCED_PARAMETER( argv );
}
| [
"[email protected]"
] | |
612c00d2575e6608c20d961eb4b451604e409666 | f0749232d54f17e3c321b0b90daaeb23b9faec82 | /Online Judge Code/[Other] Online-Judge-Solutions-master_from github/TJU/2526 - Root of the Problem.cpp | f11639f6039231b0d565ebf29a2bee6e22bd7d4a | [] | no_license | tmuttaqueen/MyCodes | c9024a5b901e68e7c7466885eddbfcd31a5c9780 | 80ec40b26649029ad546ce8ce5bfec0b314b1f61 | refs/heads/master | 2020-04-18T22:20:51.845309 | 2019-05-16T18:11:02 | 2019-05-16T18:11:02 | 167,791,029 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 683 | cpp | #include<iostream>
#include<cmath>
using namespace std;
int main(){
int B,N,A;
double x,ans;
while(1){
cin>>B>>N;
if(B==0 && N==0) break;
ans=-1000000.0;
for(int i=floor(pow(B*1.0,1.0/N))-1;;i++){
x=pow(i*1.0,N*1.0);
if(x>B){
if(fabs(x-B)<fabs(ans-B)){
A=i;
ans=x;
}
break;
}else{
if(fabs(x-B)<fabs(ans-B)){
A=i;
ans=x;
}
}
}
cout<<A<<endl;
}
return 0;
}
| [
"[email protected]"
] | |
4cf3e8703825db933cfcfa03eff6b18ab38afed3 | 6b40e9dccf2edc767c44df3acd9b626fcd586b4d | /NT/com/ole32/com/dde/server/srvr.cxx | 07419aadc21e9c83c802e71f78f151c1bc54e692 | [] | no_license | jjzhang166/WinNT5_src_20201004 | 712894fcf94fb82c49e5cd09d719da00740e0436 | b2db264153b80fbb91ef5fc9f57b387e223dbfc2 | refs/heads/Win2K3 | 2023-08-12T01:31:59.670176 | 2021-10-14T15:14:37 | 2021-10-14T15:14:37 | 586,134,273 | 1 | 0 | null | 2023-01-07T03:47:45 | 2023-01-07T03:47:44 | null | UTF-8 | C++ | false | false | 72,841 | cxx |
/****************************** Module Header ******************************\
* Module Name: Srvr.c Server Main module
*
* Purpose: Includes All the server communication related routines.
*
* Created: Oct 1990.
*
* Copyright (c) 1985, 1986, 1987, 1988, 1989 Microsoft Corporation
*
* History:
* Raor: Wrote the original version.
*
*
\***************************************************************************/
#include "ole2int.h"
//#include <shellapi.h>
// #include "cmacs.h"
#include <dde.h>
// for RemDdeRevokeClassFactory and HDDESRVR
#include <olerem.h>
#include "srvr.h"
#include "ddedebug.h"
#include "ddesrvr.h"
ASSERTDATA
#define WM_DONOTDESTROY WM_USER+1
#ifdef FIREWALLS
BOOL bShowed = FALSE;
void ShowVersion (void);
#endif
#define DdeCHAR WCHAR
#define Ddelstrcmp lstrcmpW
#define DdeGetClassName GetClassName
#define szCDDEServer OLESTR("CDDEServer")
//+---------------------------------------------------------------------------
//
// Method: CDDEServer::Create
//
// Synopsis: Create a server window to service a particular class
//
// Effects: Using lpclass, and the information in lpDdeInfo, create
// a server window that is ready to respond to initiate
// messages from this class.
//
// Arguments: [lpclass] -- Class name
// [rclsid] -- Class ID
// [lpDdeInfo] -- Class Object information
// [phwnd] -- Out pointer for new window
// [aOriginalClass] -- For TreatAs/Convert to case
// [cnvtyp] -- Conversion type
//
// Requires:
//
// Returns:
//
// Signals:
//
// Modifies:
//
// Derivation:
//
// Algorithm:
//
// History: 5-28-94 kevinro Commented/cleaned
//
// Notes:
//
//----------------------------------------------------------------------------
INTERNAL CDDEServer::Create
(LPOLESTR lpclass,
REFCLSID rclsid,
LPDDECLASSINFO lpDdeInfo,
HWND FAR * phwnd,
ATOM aOriginalClass,
CNVTYP cnvtyp)
{
// REVIEW what happens if we have two MDI servers register the
// same class factory?.
LPSRVR lpDDEsrvr = NULL;
ATOM aExe = NULL;
intrDebugOut((DEB_DDE_INIT,
"0 _IN CDDEServer::Create(lpclass=%ws)\n",
lpclass));
// add the app atom to global list
if (!ValidateSrvrClass (lpclass, &aExe))
{
intrDebugOut((DEB_IWARN,
"CDDEServer::Create(%ws) Invalid Class\n",
lpclass));
return OLE_E_CLSID;
}
lpDDEsrvr = new CDDEServer;
RetZS (lpDDEsrvr, E_OUTOFMEMORY);
// set the signature handle and the app atom.
lpDDEsrvr->m_chk = chkDdeSrvr;
lpDDEsrvr->m_aClass = wGlobalAddAtom (lpclass);
lpDDEsrvr->m_clsid = rclsid; // Class ID (already TreatAs'd)
lpDDEsrvr->m_aOriginalClass = wDupAtom (aOriginalClass);
lpDDEsrvr->m_pClassFactory = NULL;
lpDDEsrvr->m_dwClassFactoryKey = lpDdeInfo->dwRegistrationKey;
lpDDEsrvr->m_aExe = aExe;
lpDDEsrvr->m_cnvtyp = cnvtyp;
lpDDEsrvr->m_fcfFlags = lpDdeInfo->dwFlags;
lpDDEsrvr->m_bTerminate = FALSE; // Set if we are terminating.
lpDDEsrvr->m_hcli = NULL; // handle to the first block of clients list
lpDDEsrvr->m_termNo = 0; // termination count
lpDDEsrvr->m_cSrvrClients= 0; // no of clients;
lpDDEsrvr->m_fDoNotDestroyWindow= 0;
#ifdef FIREWALLS
AssertSz(lpDdeInfo.dwFlags <= REGCLS_MULTI_SEPARATE, "invalid server options");
#endif
// Create the server window and do not show it.
//
// We are explicitly calling CreateWindowA here.
// The DDE tracking layer will attempt to convert hCommands to UNICODE
// if the two windows in the conversation are both UNICODE.
// This window is created as a child of the common server window for this
// thread. When this thread dies, the common server window is destroyed if
// it exists, which will cause all of the child windows to be destroyed also.
//
//
if (!(lpDDEsrvr->m_hwnd = DdeCreateWindowEx (0, gOleDdeWindowClass,
szCDDEServer,
WS_OVERLAPPED | WS_CHILD,
0,0,0,0,
(HWND)TLSGetDdeServer(),
NULL,
g_hinst, NULL)))
{
goto errReturn;
}
// fix up the WindowProc entry point.
SetWindowLongPtr(lpDDEsrvr->m_hwnd, GWLP_WNDPROC, (LONG_PTR)SrvrWndProc);
//
// The following will inform the class object in the class registration table
// that this window should be notified when the class object is revoked. This
// enables the window to shutdown properly.
//
// If there isn't a class factory, which happens for single instance servers
// which were launched with a filename, then m_dwClassFactory will be 0,
// in which case we don't make the set call.
//
if(lpDDEsrvr->m_dwClassFactoryKey != 0)
{
if(!CCSetDdeServerWindow(lpDDEsrvr->m_dwClassFactoryKey,lpDDEsrvr->m_hwnd))
{
intrDebugOut((DEB_IERROR,
"0 CDDEServer::Create unable to SetDdeServerWindow\n"));
goto errReturn;
}
}
intrDebugOut((DEB_DDE_INIT,
"DDE Server window for %ws created in task %x\n",
lpclass,GetCurrentThreadId()));
// save the ptr to the server struct in the window.
SetWindowLongPtr (lpDDEsrvr->m_hwnd, 0, (LONG_PTR)lpDDEsrvr);
// Set the signature.
SetWindowWord (lpDDEsrvr->m_hwnd, WW_LE, WC_LE);
*phwnd = lpDDEsrvr->m_hwnd;
intrDebugOut((DEB_DDE_INIT,
"0 _OUT CDDEServer::Create returns %x\n",
NOERROR));
return NOERROR;
errReturn:
AssertSz (0, "CDDEServer::Create errReturn");
if (lpDDEsrvr)
{
if (lpDDEsrvr->m_hwnd)
SSDestroyWindow (lpDDEsrvr->m_hwnd);
if (lpDDEsrvr->m_aClass)
GlobalDeleteAtom (lpDDEsrvr->m_aClass);
if (lpDDEsrvr->m_aExe)
GlobalDeleteAtom (lpDDEsrvr->m_aExe);
delete lpDDEsrvr;
}
intrDebugOut((DEB_IERROR,
"0 _OUT CDDEServer::Create returns %x\n",
E_OUTOFMEMORY));
return E_OUTOFMEMORY;
}
// ValidateSrvrClass checks whether the given server class is valid by
// looking in the registration database.
INTERNAL_(BOOL) ValidateSrvrClass (
LPOLESTR lpclass,
ATOM FAR * lpAtom
)
{
WCHAR buf[MAX_STR];
LONG cb = MAX_STR;
WCHAR key[MAX_STR];
LPOLESTR lptmp;
LPOLESTR lpbuf;
WCHAR ch;
CLSID clsid;
if (CLSIDFromProgID (lpclass, &clsid) != NOERROR)
{
// ProgId is not correctly registered in reg db
return FALSE;
}
lstrcpyW (key, lpclass);
lstrcatW (key, OLESTR("\\protocol\\StdFileEditing\\server"));
if (QueryClassesRootValue (key, buf, &cb))
return TRUE;
if (!buf[0])
{
AssertSz (0, "ValidateSrvrClass failed.");
return FALSE;
}
// Get exe name without path and then get an atom for that
lptmp = lpbuf = buf;
while (ch = *lptmp)
{
lptmp++;
if (ch == '\\' || ch == ':')
lpbuf = lptmp;
}
*lpAtom = wGlobalAddAtom (lpbuf);
return TRUE;
}
INTERNAL RemDdeRevokeClassFactory
(LPSRVR lpsrvr)
{
HRESULT hr;
intrDebugOut((DEB_ITRACE,
"0 _IN RemDdeRevokeClassFactory(%x)\n",
lpsrvr));
ChkS(lpsrvr);
hr = lpsrvr->Revoke();
intrDebugOut((DEB_ITRACE,
"0 OUT RemDdeRevokeClassFactory(%x) %x\n",
lpsrvr,hr));
return(hr);
}
INTERNAL CDDEServer::Revoke ()
{
intrDebugOut((DEB_ITRACE,
"%x _IN CDDEServer::Revoke() m_cSrvrClients=%x\n",
this,
m_cSrvrClients));
HRESULT hr;
ChkS(this);
//
// Can't revoke if there are still clients. QueryRevokeCLassFactory
// determines if there are still clients attached.
//
if (!QueryRevokeClassFactory ())
{
intrDebugOut((DEB_IERROR,
"QueryRevokeClassFactory failed!"));
hr = RPC_E_DDE_REVOKE;
goto exitRtn;
}
if (m_cSrvrClients)
{
m_bTerminate = TRUE;
// if there are any clients connected to this classfactory,
// send terminates.
SendServerTerminateMsg ();
m_bTerminate = FALSE;
}
hr = FreeSrvrMem ();
exitRtn:
intrDebugOut((DEB_ITRACE,
"%x OUT CDDEServer::Revoke(%x) hr = %x\n",
this, hr));
return hr;
}
INTERNAL_(void) CDDEServer::SendServerTerminateMsg ()
{
HANDLE hcliPrev = NULL;
PCLILIST pcli;
HANDLE *phandle;
HANDLE hcli;
intrDebugOut((DEB_ITRACE,
"%x _IN CDDEServer::SendServerTerminateMsg\n",
this));
hcli = m_hcli;
while (hcli) {
if ((pcli = (PCLILIST) LocalLock (hcli)) == NULL)
{
Assert(0);
goto exitRtn;
}
phandle = (HANDLE *) (pcli->info);
while (phandle < (HANDLE *)(pcli + 1)) {
if (*phandle)
{
PostMessageToClientWithReply ((HWND)(*phandle), WM_DDE_TERMINATE,
(WPARAM) m_hwnd, NULL, WM_DDE_TERMINATE);
Assert (m_cSrvrClients);
m_cSrvrClients--;
}
phandle++;
phandle++;
}
hcliPrev = hcli;
hcli = pcli->hcliNext;
LocalUnlock (hcliPrev);
}
exitRtn:
intrDebugOut((DEB_ITRACE,
"%x OUT CDDEServer::SendServerTerminateMsg\n",
this));
}
//+---------------------------------------------------------------------------
//
// Method: CDDEServer::FreeSrvrMem
//
// Synopsis: Free's up a CDDEServer.
//
// Effects:
//
// Arguments: [void] --
//
// Requires:
//
// Returns:
//
// Signals:
//
// Modifies:
//
// Derivation:
//
// Algorithm:
//
// History: 6-26-94 kevinro Commented
//
// Notes:
//
//----------------------------------------------------------------------------
INTERNAL CDDEServer::FreeSrvrMem
(void)
{
HRESULT hr;
// REVIEW: Not clear how this works in the synchronous mode
// Release for class factory is called only when everything is
// cleaned and srvr app can post WM_QUIT at this stage
intrDebugOut((DEB_ITRACE,
"%x _IN CDDEServer::FreeSrvrMem\n",
this));
PCLILIST pcliPrev;
HANDLE hcli, hcliPrev;
if (m_bTerminate)
{
AssertSz (0, "terminate flag is not FALSE");
}
if (m_aExe)
{
GlobalDeleteAtom (m_aExe);
}
// We deliberately do not call this->Lock (FALSE)
// If the server has revoked his class object without
// waiting for his Lock count to go to zero, then
// presumably he doesn't need us to unlock him. In fact,
// doing such an unlock might confuse a server who then
// tries to call CoRevokeClassObject recursively.
if (m_pClassFactory)
{
m_pClassFactory->Release();
m_pClassFactory = NULL;
}
hcli = m_hcli;
while (hcli)
{
hcliPrev = hcli;
if (pcliPrev = (PCLILIST) LocalLock (hcliPrev))
{
hcli = pcliPrev->hcliNext;
}
else
{
AssertSz (0, "Corrupt internal data structure or out-of-memory");
hcli = NULL;
}
Verify (0==LocalUnlock (hcliPrev));
Verify (NULL==LocalFree (hcliPrev));
}
hr = DestroyDdeSrvrWindow(m_hwnd,m_aClass);
if (hr != NOERROR)
{
//
// Well now, if DestroyWindow fails, there isn't a whole heck of
// alot we can do about it. It could mean that the window was
// destroyed previously, or the parent window was destroyed during
// thread shutdown. We should still continue to cleanup
//
intrDebugOut((DEB_IERROR,
"%x CDDEServer::FreeSrvrMem DestroyDdeSrvrWindow failed %x\n",
this,
hr));
}
if (m_aClass)
{
GlobalDeleteAtom (m_aClass);
}
delete this;
intrDebugOut((DEB_ITRACE,
"%x _OUT CDDEServer::FreeSrvrMem\n",
this));
return NOERROR;
}
//+---------------------------------------------------------------------------
//
// Function: SrvrHandleIncomingCall
//
// Synopsis: Setup and call the CallControl to dispatch a call to the server
//
// Effects: A call has been made from the client that requires us to call
// into our server. This must be routed through the call control.
// This routine sets up the appropriate data structures, and
// calls into the CallControl. The CallControl will in turn
// call SrvrDispatchIncomingCall to actuall process the call.
//
// This routine should only be called by the SrvrWndProc
//
//
// Arguments: [lpsrvr] -- Points to the server
// [hwnd] -- hwnd of server
// [hdata] -- Handle to data
// [wParam] -- hwnd of client
//
// Requires:
//
// Returns:
//
// Signals:
//
// Modifies:
//
// Algorithm:
//
// History: 6-05-94 kevinro Commented/cleaned
//
// Notes:
//
//----------------------------------------------------------------------------
INTERNAL SrvrHandleIncomingCall(LPSRVR lpsrvr,
HWND hwnd,
HANDLE hdata,
HWND wParam)
{
VDATEHEAP();
HRESULT hresult = NOERROR;
SRVRDISPATCHDATA srvrdispdata;
DISPATCHDATA dispatchdata;
intrDebugOut((DEB_ITRACE,
"0 _IN SrvrHandleIncomingCall lpsrvr=%x hwnd=%x hdata=%x wParam=%x\n",
lpsrvr,
hwnd,
hdata,
wParam));
srvrdispdata.wDispFunc = DDE_DISP_SRVRWNDPROC;
srvrdispdata.hwnd = hwnd;
srvrdispdata.hData = hdata;
srvrdispdata.wParam = wParam;
srvrdispdata.lpsrvr = lpsrvr;
dispatchdata.pData = &srvrdispdata;
RPCOLEMESSAGE rpcMsg = {0};
RPC_SERVER_INTERFACE RpcInterfaceInfo;
DWORD dwFault;
rpcMsg.iMethod = 0;
rpcMsg.Buffer = &dispatchdata;
rpcMsg.cbBuffer = sizeof(dispatchdata);
rpcMsg.reserved2[1] = &RpcInterfaceInfo;
*MSG_TO_IIDPTR(&rpcMsg) = GUID_NULL;
IRpcStubBuffer * pStub = &(lpsrvr->m_pCallMgr);
IInternalChannelBuffer * pChannel = &(lpsrvr->m_pCallMgr);
hresult = STAInvoke(&rpcMsg, CALLCAT_SYNCHRONOUS, pStub, pChannel,
NULL, NULL, &dwFault);
intrDebugOut((DEB_ITRACE,
"0 _OUT SrvrHandleIncomingCall hresult=%x\n",
hresult));
return(hresult);
}
//+---------------------------------------------------------------------------
//
// Function: SrvrDispatchIncomingCall
//
// Synopsis: Dispatch a call into the server.
//
// Effects: At the moment, the only incoming call that requires handling
// by the server window is Execute. This routine dispatchs to it,
// and returns.
//
// Arguments: [psdd] --
//
// Requires:
//
// Returns:
//
// Signals:
//
// Modifies:
//
// Algorithm:
//
// History: 6-05-94 kevinro Commented/cleaned
//
// Notes:
//
//----------------------------------------------------------------------------
INTERNAL SrvrDispatchIncomingCall(PSRVRDISPATCHDATA psdd)
{
VDATEHEAP();
HRESULT hr;
intrDebugOut((DEB_ITRACE,
"0 _IN SrvrDispatchIncomingCall psdd(%x)\n",psdd));
hr = psdd->lpsrvr->SrvrExecute (psdd->hwnd,
psdd->hData,
(HWND)(psdd->wParam));
intrDebugOut((DEB_ITRACE,
"0 _OUT SrvrDispatchIncomingCall psdd(%x) hr =%x\n",
psdd,
hr));
return(hr);
}
// REVIEW: Revoking Class Factory will not be successful if
// any clients are either connected to the classfactory
// or to the object instances.
//+---------------------------------------------------------------------------
//
// Function: SrvrWndProc
//
// Synopsis: This is the server window procedure.
//
// Effects:
//
// Arguments: [hwndIn] -- Window handle (may not be full. See note)
// [msg] --
// [wParam] --
// [lParam] --
//
// Requires:
//
// Returns:
//
// Signals:
//
// Modifies:
//
// Algorithm:
//
// History: 8-03-94 kevinro Created
//
// Notes:
//
// When running in a VDM, it is possible that this window was dispatched
// without having a full window handle. This happens when the getmessage
// was dispatched from 16-bit. Therefore, we need to convert the hwnd to
// a full hwnd before doing any comparision functions.
//
//----------------------------------------------------------------------------
STDAPI_(LRESULT) SrvrWndProc (
HWND hwndIn,
UINT msg,
WPARAM wParam,
LPARAM lParam
)
{
BOOL fRevoke=FALSE;
LPSRVR lpsrvr;
WORD status = NULL;
HANDLE hdata;
ATOM aItem;
HRESULT retval;
//
// The following hwnd variable is used to determine the full HWND, in the
// event we were dispatched in a 16 bit process.
//
HWND hwnd;
#ifdef FIREWALLS
HWND hwndClient;
#endif
switch (msg){
case WM_DDE_INITIATE:
VDATEHEAP();
#ifdef FIREWALLS
AssertSz (lpsrvr, "No server window handle in server window");
#endif
hwnd = ConvertToFullHWND(hwndIn);
lpsrvr = (LPSRVR)GetWindowLongPtr (hwnd, 0);
if (lpsrvr->m_bTerminate){
// we are terminating, no more connections
break;
}
// class is not matching, so it is not definitely for us.
// for apps sending the EXE for initiate, do not allow if the app
// is mutiple instance (Bug fix for winworks).
if (!(lpsrvr->m_aClass == (ATOM)(LOWORD(lParam)) ||
(NOERROR==wCompatibleClasses (LOWORD(lParam), lpsrvr->m_aClass)) ||
(lpsrvr->m_aExe == (ATOM)(LOWORD(lParam)) && IsSingleServerInstance() )))
{
break;
}
intrDebugOut((DEB_DDE_INIT,"::SrvrWndProc INITIATE\n"));
if (!lpsrvr->HandleInitMsg (lParam))
{
if (!(aSysTopic == (ATOM)(HIWORD(lParam))))
{
//
// If this isn't a sys topic, then it must be a request for
// a specific document. Send a message to the
// children windows, asking for the document. If one of them
// may send an ACK to the client.
//
// if the server window is not the right window for
// DDE conversation, then try with the doc windows.
BOOL fAckSent = SendInitMsgToChildren (hwnd, msg, wParam, lParam);
#ifdef KEVINRO_OLDCODE
The following code was removed, because I don't belive it is required
any longer. I am not 100% sure yet, so I have left it in. If you find it,
you can probably remove it.
It appears to be trying to claim the SINGLE_USE class factory from the class
factory table. It does this when a child document window sends an ACK to the
client, claiming to support the document being asked for. It really doesn't
make too much sense here, since a single use server would have already removed
its class factory if there was an open document.
Anyway, the 16-bit version had a direct hack into the class factory table. We
don't have that anymore, so this code wouldn't work anyway.
if (lpsrvr->m_fcfFlags==REGCLS_SINGLEUSE)
{
if (lpsrvr->m_pfAvail)
{
// Hide the entry in the class factory table so that no 2.0
// client can connect to the same server.
Assert (IsValidPtrOut (lpsrvr->m_pfAvail, sizeof(BOOL)));
*(lpsrvr->m_pfAvail) = FALSE;
}
}
#endif // KEVINRO_OLDCODE
intrDebugOut((DEB_DDE_INIT,"SrvrWndProc Child Init\n"));
return fAckSent;
}
break;
}
// We can enterain this client. Put him in our client list
// and acknowledge the initiate.
if (!AddClient ((LPHANDLE)&lpsrvr->m_hcli, (HWND)wParam,(HWND)/*fLocked*/FALSE))
{
break;
}
//
// Now its time to grab up the class factory from the class
// factory table. When this window was created, the class factory
// was available. However, it is possible that it has already
// been claimed by someone else. So, we try grabbing it (which
// normally should succeed). If it fails, then delete the client
// and don't acknowledge.
//
if (lpsrvr->m_pClassFactory == NULL)
{
DdeClassInfo ddeInfo;
ddeInfo.dwContextMask = CLSCTX_LOCAL_SERVER |
CLSCTX_INPROC_SERVER;
intrDebugOut((DEB_DDE_INIT,"SrvrWndProc getting class factory\n"));
//
// The following asks for control of the class
// factory in the case of a single use class
//
ddeInfo.fClaimFactory = TRUE;
ddeInfo.dwRegistrationKey = lpsrvr->m_dwClassFactoryKey;
if (CCGetClassInformationFromKey(&ddeInfo) == FALSE)
{
intrDebugOut((DEB_IERROR,"SrvrWndProc failed to get class factory\n"));
//
// Whoops, we were not able to grab the class factory
// Cleanup and hop out
if (!FindClient ((LPHANDLE)lpsrvr->m_hcli,(HWND)wParam, TRUE))
{
intrAssert(!"FindClient failed\n");
}
return(0);
}
lpsrvr->m_pClassFactory = (IClassFactory *)ddeInfo.punk;
lpsrvr->m_fcfFlags = ddeInfo.dwFlags;
}
intrAssert(lpsrvr->m_pClassFactory != NULL);
lpsrvr->m_cSrvrClients++;
lpsrvr->Lock (TRUE, (HWND)wParam);
// Post acknowledge
DuplicateAtom (LOWORD(lParam));
DuplicateAtom (HIWORD(lParam));
SSSendMessage ((HWND)wParam, WM_DDE_ACK, (WPARAM)hwnd, lParam);
return 1L; // fAckSent==TRUE
VDATEHEAP();
break;
case WM_DDE_EXECUTE:
VDATEHEAP();
hwnd = ConvertToFullHWND(hwndIn);
lpsrvr = (LPSRVR)GetWindowLongPtr (hwnd, 0);
hdata = GET_WM_DDE_EXECUTE_HDATA(wParam,lParam);
#ifdef FIREWALLS
AssertSz (lpsrvr, "No server handle in server window");
#endif
intrDebugOut((DEB_ITRACE,"SrvrWndProc WM_DDE_EXECUTE\n"));
#ifdef FIREWALLS
// find the client in the client list.
hwndClient = FindClient (lpsrvr->m_hcli, (HWND)wParam, FALSE);
AssertSz (hwndClient, "Client is missing from the server")
#endif
// Are we terminating
if (lpsrvr->m_bTerminate) {
intrDebugOut((DEB_ITRACE,
"SrvrWndProc WM_DDE_EXECUTE ignored for TERMINATE\n"));
// !!! are we supposed to free the data
GlobalFree (hdata);
break;
}
retval = SrvrHandleIncomingCall(lpsrvr,hwnd,hdata,(HWND)wParam);
if (NOERROR!=retval)
{
intrDebugOut((DEB_IERROR,
"SrvrWndProc SrvrHandleIncomingCall fail %x\n",
retval));
}
SET_MSG_STATUS (retval, status)
if (!lpsrvr->m_bTerminate)
{
// REVIEW: We are making an assumption that, we will not be posting
// any DDE messages because of calling the SrvrExecute.
// If we post any messages, before we post the acknowledge
// we will be in trouble.
lParam = MAKE_DDE_LPARAM(WM_DDE_ACK,status, hdata);
intrDebugOut((DEB_ITRACE,
"SrvrWndProc WM_DDE_EXECUTE sending %x for ack\n",status));
// Post the acknowledge to the client
if (!PostMessageToClient ((HWND) wParam,
WM_DDE_ACK, (WPARAM) hwnd, lParam)) {
// if the window died or post failed, delete the atom.
GlobalFree (hdata);
DDEFREE(WM_DDE_ACK,lParam);
}
}
VDATEHEAP();
break;
case WM_DDE_TERMINATE:
intrDebugOut((DEB_ITRACE,
"SrvrWndProc WM_DDE_TERMINATE\n"));
hwnd = ConvertToFullHWND(hwndIn);
lpsrvr = (LPSRVR)GetWindowLongPtr (hwnd, 0);
#ifdef FIREWALLS
// find the client in the client list.
hwndClient = FindClient (lpsrvr->m_hcli, (HWND)wParam, FALSE);
AssertSz (hwndClient, "Client is missing from the server")
#endif
Putsi (lpsrvr->m_bTerminate);
if (lpsrvr->m_bTerminate)
{
AssertSz (0, "Unexpected code path");
}
else
{
// If client initiated the terminate. post matching terminate
PostMessageToClient ((HWND)wParam,
WM_DDE_TERMINATE,
(WPARAM) hwnd,
NULL);
--lpsrvr->m_cSrvrClients;
if (0==lpsrvr->m_cSrvrClients
&& lpsrvr->QueryRevokeClassFactory())
{
#ifdef KEVINRO_OLD_CODE
if (lpsrvr->m_phwndDde)
{
// Remove from class factory table
*(lpsrvr->m_phwndDde) = (HWND)0;
}
#endif // KEVINRO_OLD_CODE
fRevoke = TRUE;
}
lpsrvr->Lock (FALSE, (HWND)wParam); // Unlock server
FindClient (lpsrvr->m_hcli, (HWND)wParam, /*fDelete*/TRUE);
if (fRevoke)
{
lpsrvr->Revoke();
}
}
break;
case WM_DDE_REQUEST:
aItem = GET_WM_DDE_REQUEST_ITEM(wParam,lParam);
hwnd = ConvertToFullHWND(hwndIn);
lpsrvr = (LPSRVR)GetWindowLongPtr (hwnd, 0);
intrDebugOut((DEB_ITRACE,
"SrvrWndProc WM_DDE_REQUEST(aItem=%x)\n",aItem));
if (lpsrvr->m_bTerminate || !IsWindowValid ((HWND) wParam))
{
goto RequestErr;
}
if(RequestDataStd (aItem, (HANDLE FAR *)&hdata) != NOERROR)
{
lParam = MAKE_DDE_LPARAM(WM_DDE_ACK,0x8000,aItem);
// if request failed, then acknowledge with error.
if (!PostMessageToClient ((HWND)wParam, WM_DDE_ACK,
(WPARAM) hwnd, lParam))
{
DDEFREE(WM_DDE_ACK,lParam);
RequestErr:
if (aItem)
{
GlobalDeleteAtom (aItem);
}
}
}
else
{
lParam = MAKE_DDE_LPARAM(WM_DDE_REQUEST, hdata, aItem);
// post the data message and we are not asking for any
// acknowledge.
if (!PostMessageToClient ((HWND)wParam, WM_DDE_DATA,
(WPARAM) hwnd, lParam))
{
GlobalFree (hdata);
DDEFREE(WM_DDE_REQUEST,lParam);
goto RequestErr;
}
}
break;
case WM_DONOTDESTROY:
intrDebugOut((DEB_ITRACE,
"SrvrWndProc WM_DONOTDESTROY %x\n",
wParam));
//
// This message is only sent by 32-bit code that has been
// given our full handle
//
lpsrvr = (LPSRVR)GetWindowLongPtr (hwndIn, 0);
//
// The WM_DONOTDESTROY message tells the server how to
// handle the following WM_USER message. If wParam is set,
// then the m_fDoNotDestroyWindow flag will be set, which
// keeps us from destroying the server window. If cleared,
// it will enable the destruction. This message is sent
// from the MaybeCreateDocWindow routine
//
lpsrvr->m_fDoNotDestroyWindow = (BOOL) wParam;
return 0;
break;
case WM_USER:
intrDebugOut((DEB_ITRACE,
"SrvrWndProc WM_USER\n"));
//
// This message is only sent by 32-bit code that has been
// given our full handle
//
lpsrvr = (LPSRVR)GetWindowLongPtr (hwndIn, 0);
// cftable.cpp sends a WM_USER message to destory the DDE
// server window when a 2.0 client has connected to a
// SDI 2.0 server (and no 1.0 client should be allowed to also
// connect.
// cftable.cpp cannot call RemDdeRevokeClassFactory directly
// becuase they may be in different processes.
//
// The m_fDoNotDestroyWindow flag is used by
// MaybeCreateDocWindow in the case that the server is a
// single use server, and revokes its class factory when
// an object is created. MaybeCreateDocWindow will set this
// flag, telling us to ignore the message.
//
// returning 0 means we did destroy, 1 means we did not.
if (!lpsrvr->m_fDoNotDestroyWindow)
{
RemDdeRevokeClassFactory(lpsrvr);
return(0);
}
return 1;
break;
default:
return SSDefWindowProc (hwndIn, msg, wParam, lParam);
}
return 0L;
}
//+---------------------------------------------------------------------------
//
// Method: CDDEServer::HandleInitMsg
//
// Synopsis: Determine if we are going to handle the INITIATE message.
//
// Effects:
//
// Arguments: [lParam] --
//
// Requires:
//
// Returns:
//
// Signals:
//
// Modifies:
//
// Derivation:
//
// Algorithm:
//
// History: 5-28-94 kevinro Commented/cleaned
//
// Notes:
//
//----------------------------------------------------------------------------
INTERNAL_(BOOL) CDDEServer::HandleInitMsg(LPARAM lParam)
{
// If it is not system or Ole, this is not the server.
if (!((aSysTopic == (ATOM)(HIWORD(lParam))) || (aOLE == (ATOM)(HIWORD(lParam)))))
{
return FALSE;
}
Assert (m_fcfFlags<=REGCLS_MULTI_SEPARATE);
// single instance MDI accept
if (m_fcfFlags != REGCLS_SINGLEUSE)
{
return TRUE;
}
// this server is multiple instance. So, check for any clients or docs.
if (!GetWindow (m_hwnd, GW_CHILD) && 0==m_cSrvrClients)
return TRUE;
return FALSE;
}
// AddClient: Adds a client entry to the list.
// Each client entry is a pair of handles; key handle
// and data handle. Ecah list entry contains space for
// MAX_LIST of pairs of handles.
INTERNAL_(BOOL) AddClient
(
LPHANDLE lphead, // ptr to loc which contains the head handle
HANDLE hkey, // key
HANDLE hdata // hdata
)
{
HANDLE hcli = NULL;
HANDLE hcliPrev = NULL;
PCLILIST pcli;
HANDLE *phandle;
hcli = *lphead;
// if the entry is already present, return error.
if (hcli && FindClient (hcli, hkey, FALSE))
return FALSE;
while (hcli) {
if (hcliPrev)
LocalUnlock (hcliPrev);
if ((pcli = (PCLILIST) LocalLock (hcli)) == NULL)
return FALSE;
phandle = (HANDLE *) pcli->info;
while (phandle < (HANDLE *)(pcli + 1)) {
if (*phandle == NULL) {
*phandle++ = hkey;
*phandle++ = hdata;
LocalUnlock (hcli);
return TRUE;
}
phandle++;
phandle++;
}
hcliPrev = hcli;
hcli = pcli->hcliNext;
lphead = (LPHANDLE)&pcli->hcliNext;
}
// not in the list.
hcli = LocalAlloc (LMEM_MOVEABLE | LMEM_ZEROINIT, sizeof (CLILIST));
if (hcli == NULL)
goto errRtn;
if ((pcli = (PCLILIST) LocalLock (hcli)) == NULL)
goto errRtn;
// set the link to this handle in the previous entry
*lphead = hcli;
if (hcliPrev)
LocalUnlock (hcliPrev);
phandle = (HANDLE *) pcli->info;
*phandle++ = hkey;
*phandle++ = hdata;
LocalUnlock (hcli);
return TRUE;
errRtn:
if (hcliPrev)
LocalUnlock (hcliPrev);
if (hcli)
LocalFree (hcli);
return FALSE;
}
// FindClient: finds a client and deletes the client if necessary.
INTERNAL_(HANDLE) FindClient
(
HANDLE hcli,
HANDLE hkey,
BOOL bDelete
)
{
HANDLE hcliPrev = NULL;
PCLILIST pcli;
HANDLE *phandle;
HANDLE hdata;
while (hcli) {
if ((pcli = (PCLILIST) LocalLock (hcli)) == NULL)
return FALSE;
phandle = (HANDLE *) pcli->info;
while (phandle < (HANDLE *)(pcli + 1)) {
if (*phandle == hkey) {
if (bDelete)
*phandle = NULL;
hdata = *++phandle;
LocalUnlock (hcli);
return hdata;
}
phandle++;
phandle++;
}
hcliPrev = hcli;
hcli = pcli->hcliNext;
LocalUnlock (hcliPrev);
}
return NULL;
}
//+---------------------------------------------------------------------------
//
// Method: CDDEServer::SrvrExecute
//
// Synopsis: takes care of the WM_DDE_EXECUTE for the server.
//
// Effects: Parses the EXECUTE string, and determines what it should be
// done.
//
// Arguments: [hwnd] -- Server window
// [hdata] -- Handle to EXECUTE string
// [hwndClient] -- Client window
//
// Requires:
// hdata is an ANSI string. It was passed to us by a DDE client.
//
// Returns:
//
// Signals:
//
// Modifies:
//
// Derivation:
//
// Algorithm:
//
// History: 6-05-94 kevinro Commented/cleaned
//
// Notes:
//
//----------------------------------------------------------------------------
INTERNAL CDDEServer::SrvrExecute
(
HWND hwnd,
HANDLE hdata,
HWND hwndClient
)
{
intrDebugOut((DEB_ITRACE,
"%x _IN CDDESrvr::SrvrExecute(hwnd=%x,hdata=%x,hwndClient=%x)\n",
this,
hwnd,
hdata,
hwndClient));
ATOM aCmd;
BOOL fActivate;
LPSTR lpdata = NULL;
HANDLE hdup = NULL;
HRESULT hresult = E_UNEXPECTED;
LPSTR lpdocname;
LPSTR lptemplate;
LPCLIENT lpdocClient = NULL;
LPSTR lpnextarg;
LPSTR lpclassname;
LPSTR lpitemname;
LPSTR lpopt;
CLSID clsid;
WORD wCmdType;
BOOL bCreateInst = FALSE;
LPUNKNOWN pUnk = NULL;
LPPERSISTSTORAGE pPersistStg=NULL;
// REVIEW: if any methods called on the objects genarate DDE messages
// before we return from Execute, we will be in trouble.
// REVIEW: this code can be lot simplified if we do the argument scanning
// seperately and return the ptrs to the args. Rewrite later on.
ErrZS (hdup = UtDupGlobal (hdata,GMEM_MOVEABLE), E_OUTOFMEMORY);
ErrZS (lpdata = (LPSTR)GlobalLock (hdup), E_OUTOFMEMORY);
intrDebugOut((DEB_ITRACE,
"CDDESrvr::SrvrExecute(lpdata = %s)\n",lpdata));
if (*lpdata++ != '[') // commands start with the left sqaure bracket
{
hresult = ResultFromScode (RPC_E_DDE_SYNTAX_EXECUTE);
goto errRtn;
}
hresult = ReportResult(0, RPC_E_DDE_SYNTAX_EXECUTE, 0, 0);
// scan upto the first arg
if (!(wCmdType = ScanCommand (lpdata, WT_SRVR, &lpdocname, &aCmd)))
goto errRtn;
if (wCmdType == NON_OLE_COMMAND)
{
if (!UtilQueryProtocol (m_aClass, PROTOCOL_EXECUTE))
hresult = ReportResult(0, RPC_E_DDE_PROTOCOL, 0, 0);
else {
// REVIEW: StdExecute has to be mapped on to the StdCommandProtocol
// What command do we map on to?
AssertSz (0, "StdExecute is being called for server");
}
goto errRtn1;
}
if (aCmd == aStdExit)
{
if (*lpdocname)
goto errRtn1;
hresult = NOERROR;
// REVIEW: Do we have to initiate any terminations from the
// the servr side? Check how this works with excel.
goto end2;
}
// scan the next argument.
if (!(lpnextarg = ScanArg(lpdocname)))
goto errRtn;
//////////////////////////////////////////////////////////////////////////
//
// [StdShowItem("docname", "itemname"[, "true"])]
//
//////////////////////////////////////////////////////////////////////////
if (aCmd == aStdShowItem) {
// first find the documnet. If the doc does not exist, then
// blow it off.
if (!(lpdocClient = FindDocObj (lpdocname)))
goto errRtn1;
lpitemname = lpnextarg;
if( !(lpopt = ScanArg(lpitemname)))
goto errRtn1;
// scan for the optional parameter
// Optional can be only TRUE or FALSE.
fActivate = FALSE;
if (*lpopt) {
if( !(lpnextarg = ScanBoolArg (lpopt, (BOOL FAR *)&fActivate)))
goto errRtn1;
if (*lpnextarg)
goto errRtn1;
}
// scan it. But, igonre the arg.
hresult = lpdocClient->DocShowItem (lpitemname, !fActivate);
goto end2;
}
//////////////////////////////////////////////////////////////////////////
//
// [StdCloseDocument ("docname")]
//
//////////////////////////////////////////////////////////////////////////
if (aCmd == aStdClose) {
if (!(lpdocClient = FindDocObj (lpdocname)))
goto errRtn1;
if (*lpnextarg)
goto errRtn1;
// REVIEW: Do we have to do anything for shutting down the
// the app? Is the client going to initiate the terminate?.
// if we need to initiate the terminates, make sure we post
// the ACK first.
lpdocClient->Revoke();
goto end2;
}
if (aCmd == aStdOpen)
{
// find if any doc level object is already registerd.
// if the object is registerd, then no need to call srvr app.
if (FindDocObj (lpdocname))
{
// A client has already opened the document or user opened the
// doc. We should do an addref to the docobj
#ifdef TRY
if (m_cSrvrClients == 0)
// Why are we doing this?
hresult = lpdocClient->m_lpoleObj->AddRef();
else
#endif
hresult = NOERROR;
goto end1;
}
}
if (aCmd == aStdCreate || aCmd == aStdCreateFromTemplate) {
lpclassname = lpdocname;
lpdocname = lpnextarg;
if( !(lpnextarg = ScanArg(lpdocname)))
goto errRtn1;
}
// check whether we can create/open more than one doc.
if ((m_fcfFlags == REGCLS_SINGLEUSE) &&
GetWindow (m_hwnd, GW_CHILD))
goto errRtn;
ErrZ (CLSIDFromAtom(m_aClass, &clsid));
//
// Generate a wide version of the name
//
WCHAR awcWideDocName[MAX_STR];
if (MultiByteToWideChar(CP_ACP,0,lpdocname,-1,awcWideDocName,MAX_STR) == FALSE)
{
Assert(!"Unable to convert characters");
hresult = E_UNEXPECTED;
goto errRtn;
}
//////////////////////////////////////////////////////////////////////////
//
// [StdOpenDocument ("docname")]
//
//////////////////////////////////////////////////////////////////////////
// Document does not exist.
if (aCmd == aStdOpen)
{
ErrRtnH (wClassesMatch (clsid, awcWideDocName));
ErrRtnH (wFileBind (awcWideDocName, &pUnk));
}
ErrRtnH (CreateInstance (clsid, awcWideDocName, lpdocname, pUnk, &lpdocClient, hwndClient));
bCreateInst = TRUE;
if (aCmd == aStdOpen)
{
// Temporary flag to indicate someone will INITIATE on this doc.
// The flag is reset after the INITITATE.
// This is Yet-Another-Excel-Hack. See ::QueryRevokeClassFactory
lpdocClient->m_fCreatedNotConnected = TRUE;
}
else
{
lpdocClient->m_fEmbed = TRUE;
}
//////////////////////////////////////////////////////////////////////////
//
// [StdNewDocument ("classname", "docname")]
//
//////////////////////////////////////////////////////////////////////////
if (aCmd == aStdCreate)
{
hresult = lpdocClient->DoInitNew();
lpdocClient->m_fCreatedNotConnected = TRUE;
goto end;
}
//////////////////////////////////////////////////////////////////////////
//
// [StdNewFormTemplate ("classname", "docname". "templatename)]
//
//////////////////////////////////////////////////////////////////////////
if (aCmd == aStdCreateFromTemplate)
{
ErrRtnH (lpdocClient->DoInitNew());
lpdocClient->m_fCreatedNotConnected = TRUE;
IPersistFile FAR * lpPF;
lptemplate = lpnextarg;
if(!(lpnextarg = ScanArg(lpnextarg)))
{
goto errRtn;
}
hresult = lpdocClient->m_lpoleObj->QueryInterface(IID_IPersistFile,(LPLPVOID)&lpPF);
if (hresult == NOERROR)
{
WCHAR awcWideTemplate[MAX_STR];
if (MultiByteToWideChar(CP_ACP,0,lpdocname,-1,awcWideTemplate,MAX_STR) != FALSE)
{
hresult = lpPF->Load(awcWideTemplate, 0);
}
else
{
Assert(!"Unable to convert characters");
lpPF->Release();
hresult = E_UNEXPECTED;
goto end;
}
lpPF->Release();
lpdocClient->m_fEmbed = TRUE;
}
else
{
goto end;
}
}
//////////////////////////////////////////////////////////////////////////
//
// [StdEditDocument ("docname")]
//
//////////////////////////////////////////////////////////////////////////
// REVIEW: Do we have to call InitNew for editing an embedded object
if (aCmd == aStdEdit)
{
lpdocClient->m_fEmbed = TRUE;
lpdocClient->m_fGotEditNoPokeNativeYet = TRUE;
lpdocClient->m_fCreatedNotConnected = TRUE;
goto end;
}
intrDebugOut((DEB_IERROR,
"%x CDDESrvr::SrvrExecute Unknown command\n",
this));
end:
if (hresult != NOERROR)
goto errRtn;
end1:
// make sure that the srg string is indeed terminated by
// NULL.
if (*lpnextarg)
{
hresult = RPC_E_DDE_SYNTAX_EXECUTE;
}
errRtn:
if ( hresult != NOERROR)
{
if (bCreateInst && lpdocClient)
{
lpdocClient->DestroyInstance ();
lpdocClient = NULL; //DestroyInstance invalidates the pointer
}
}
end2:
errRtn1:
if (lpdata)
GlobalUnlock (hdup);
if (hdup)
GlobalFree (hdup);
if (pUnk)
pUnk->Release();
if (pPersistStg)
pPersistStg->Release();
Assert (GetScode(hresult) != E_UNEXPECTED);
intrDebugOut((DEB_ITRACE,
"%x _OUT CDDESrvr::SrvrExecute hresult=%x\n",
this,
hresult));
return hresult;
}
// Maybe CreateDocWindow
//
// Return NOERROR only if a doc window was created and it sent an ACK.
//
//+---------------------------------------------------------------------------
//
// Function: MaybeCreateDocWindow
//
// Synopsis: Determine if a DocWindow should be created
//
// Effects: Given a class, and a filename atom, determine if this thread
// should be the server for this request.
//
// Arguments: [aClass] -- Class of object (PROGID)
// [aFile] -- Filename (ATOM)
// [hwndDdeServer] -- HWND of CDDEServer
// [hwndSender] -- HWND of new requesting client
//
// Requires:
//
// Returns:
//
// Signals:
//
// Modifies:
//
// Algorithm:
//
// History: 6-29-94 kevinro Created
//
// Notes:
//
//----------------------------------------------------------------------------
INTERNAL MaybeCreateDocWindow
(ATOM aClass,
ATOM aFile,
HWND hwndDdeServer,
HWND hwndSender)
{
CLSID clsid = CLSID_NULL;
LPUNKNOWN pUnk = NULL;
HWND hwndClient = NULL;
ULONG fAckSent = FALSE;
LPSRVR pDdeSrvr = NULL;
WCHAR szFile [MAX_STR];
BOOL fTrue = TRUE;
BOOL fRunningInSDI = FALSE;
HRESULT hresult = NOERROR;
IClassFactory *pcf = NULL;
IPersistFile *ppf = NULL;
DdeClassInfo ddeClassInfo;
intrDebugOut((DEB_DDE_INIT,
"MaybeCreateDocWindow(aClass=%x(%ws),aFile=%x,"
"hwndDdeServer=%x,hwndSender=%x\n",
aClass,wAtomName(aClass),aFile,hwndDdeServer,hwndSender));
//
// If the window isn't valid, it would be very bad.
//
if (!IsWindowValid(hwndDdeServer))
{
intrDebugOut((DEB_DDE_INIT,
"MaybeCreateDocWindow: hwndDdeServer is invalid\n"));
hresult = E_UNEXPECTED;
goto exitRtn;
}
//
// We need the filename, which is passed in an Atom
//
Assert (IsFile (aFile));
if (GlobalGetAtomName(aFile,szFile,MAX_STR) == 0)
{
//
// The filename was not valid
//
hresult = S_FALSE;
intrDebugOut((DEB_IERROR,
"MaybeCreateDocWindow Invalid file atom\n"));
goto exitRtn;
}
intrDebugOut((DEB_DDE_INIT,
"MaybeCreateDocWindow File=(%ws)\n",
WIDECHECK(szFile)));
//
// Get the class of the object. The class was passed as an atom
// in the INITIATE message.
//
if (CLSIDFromAtomWithTreatAs (&aClass, &clsid, NULL))
{
intrDebugOut((DEB_IERROR,
"MaybeCreateDocWindow CLSIDFromAtom failed\n"));
hresult = S_FALSE;
goto exitRtn;
}
if (CoIsOle1Class(clsid))
{
// we shouldn't even be looking at this INIT message
hresult = S_FALSE;
intrDebugOut((DEB_DDE_INIT,
"MaybeCreateDocWindow Its an OLE 1.0 class\n"));
goto exitRtn;
}
//
// First of three cases is to see if the object is running in our
// local apartment. If it is, then this is the object we need to create
// a DDEServer for.
//
// Otherwise, We are going to try and load this file.
// Therefore, we need the class factory from the CFT.
//
// GetClassInformationForDde won't find a match if the class factory was
// single use, and is now hidden or invalid.
//
// If there was no class information available, then we are going to
// check to see if the object is in the local ROT. If it is in the
// local ROT, then we will use it, since it is registered and
// available for use by others
//
ddeClassInfo.dwContextMask = CLSCTX_LOCAL_SERVER | CLSCTX_INPROC_SERVER;
ddeClassInfo.fClaimFactory = TRUE;
if ( GetLocalRunningObjectForDde(szFile, &pUnk) == NOERROR)
{
intrDebugOut((DEB_DDE_INIT,
"Found %ws in ROT\n",WIDECHECK(szFile)));
//
// Elsewhere in the code, we need to know if this is an SDI server.
// The old code determined this by detecting that there is a running
// object, and there was no class factory registered.
// This is sick, and obscene. Compatibilities says we need to get the
// class info anyway. However, we don't want to claim it.
//
ddeClassInfo.fClaimFactory = FALSE;
fRunningInSDI = !CCGetClassInformationForDde(clsid,&ddeClassInfo);
}
else if (!CCGetClassInformationForDde(clsid,&ddeClassInfo))
{
intrDebugOut((DEB_IERROR,
"No class registered for %ws\n",WIDECHECK(szFile)));
hresult = S_FALSE;
goto exitRtn;
}
else
{
//
// Otherwise, we are registered as the server for this class. This
// means we can create this object.
//
// A 1.0 client will have launched the server with a command line
// like server.exe -Embedding filename The server ignored the filename
// so now we must make it load the file by binding the moniker.
//
// KevinRo: The old code did a bind moniker here, on the filename,
// which went through the ROT, didn't find the object, so went for
// a server. This isn't terribly safe, since we could end up binding
// out of process when we really didn't mean to. So, I have made this
// routine just use the ClassFactory we retrieve from the
// local class factory table.
//
intrDebugOut((DEB_DDE_INIT,
"Found classinfo: Loading %ws\n",WIDECHECK(szFile)));
//
// Need to insure that the server doesn't go away on us. The following
// tells the server not to destroy itself.
//
SSSendMessage(hwndDdeServer,WM_DONOTDESTROY,TRUE,0);
intrAssert(ddeClassInfo.punk != NULL);
pcf = (IClassFactory *) ddeClassInfo.punk;
hresult = pcf->CreateInstance(NULL,IID_IUnknown,(void **)&pUnk);
if (hresult != NOERROR)
{
intrDebugOut((DEB_IERROR,
"MaybeCreateDocWindow CreateInstancefailed File=(%ws)\n",
WIDECHECK(szFile)));
goto sndMsg;
}
//
// Get the IPersistFile interface, and ask the object to load
// itself.
//
hresult = pUnk->QueryInterface(IID_IPersistFile,(void **)&ppf);
if (hresult != NOERROR)
{
intrDebugOut((DEB_IERROR,
"MaybeCreateDocWindow QI IPF failed File=(%ws)\n",
WIDECHECK(szFile)));
goto sndMsg;
}
//
// Attempt to load the object. The flags STGM_READWRITE are the
// same default values used by a standard bind context.
//
hresult = ppf->Load(szFile,STGM_READWRITE);
if (hresult != NOERROR)
{
intrDebugOut((DEB_IERROR,
"MaybeCreateDocWindow ppf->Load(%ws) failed %x\n",
WIDECHECK(szFile),
hresult));
goto sndMsg;
}
sndMsg:
SSSendMessage(hwndDdeServer,WM_DONOTDESTROY,FALSE,0);
if (hresult != NOERROR)
{
goto exitRtn;
}
intrDebugOut((DEB_DDE_INIT,
"Loading %ws complete\n",WIDECHECK(szFile)));
}
intrAssert(IsWindowValid(hwndDdeServer));
intrAssert (pUnk);
pDdeSrvr = (LPSRVR) GetWindowLongPtr (hwndDdeServer, 0);
if (pDdeSrvr == NULL)
{
intrAssert(pDdeSrvr != NULL);
hresult = E_UNEXPECTED;
goto exitRtn;
}
// This actually creates the doc window as a child of the server window
// Do not set the client site becuase this is a link.
hresult = CDefClient::Create (pDdeSrvr,
pUnk,
szFile,
/*fSetClientSite*/FALSE,
/*fDoAdvise*/TRUE,
fRunningInSDI,
&hwndClient);
if (hresult != NOERROR)
{
intrDebugOut((DEB_IERROR,
"MaybeCreateDocWindow CDefClient::Create failed %x\n",
hresult));
goto exitRtn;
}
Assert (IsWindowValid (hwndClient));
//
// Pass along the original DDE_INIT to the newly created window.
// That window should respond by sending an ACK to the 1.0 client.
//
fAckSent = (ULONG) SSSendMessage (hwndClient,
WM_DDE_INITIATE,
(WPARAM) hwndSender,
MAKELONG(aClass, aFile));
if (!fAckSent)
{
intrDebugOut((DEB_IERROR,
"MaybeCreateDocWindow !fAckSent\n"));
hresult = CO_E_APPDIDNTREG;
}
exitRtn:
if (ppf)
{
ppf->Release();
}
if (pUnk)
{
pUnk->Release();
}
if (pcf)
{
pcf->Release();
}
intrDebugOut((DEB_DDE_INIT,
"MaybeCreateDocWindow returns %x\n",
hresult));
return hresult;
}
//+---------------------------------------------------------------------------
//
// Function: SendMsgToChildren
//
// Synopsis: This routine sends the msg to all child windows.
//
// Arguments: [hwnd] -- Hwnd of parent window
// [msg] -- Message and parameters to send
// [wParam] --
// [lParam] --
//
// Notes: This routine will stop on the first non-zero return code.
//
//----------------------------------------------------------------------------
BOOL SendMsgToChildren (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
intrDebugOut((DEB_ITRACE,
"0 _IN SendMsgToChildren(hwnd=%x,msg=%x,wParam=%x,lParam=%x)\n",
hwnd,msg,wParam,lParam));
BOOL fAckSent = FALSE;
hwnd = GetWindow(hwnd, GW_CHILD);
//
// This routine is to be called only from one place, which is
// in the handling of WM_DDE_INITIATE. Because of that, we will terminate
// the loop on the first non-zero return code.
//
Assert (msg == WM_DDE_INITIATE);
while (hwnd)
{
intrDebugOut((DEB_ITRACE," SendMsgToChildren send to hwnd=%x\n",hwnd));
if (fAckSent = (1L==SSSendMessage (hwnd, msg, wParam, lParam)))
{
break;
}
hwnd = GetWindow (hwnd, GW_HWNDNEXT);
}
intrDebugOut((DEB_ITRACE,"0 OUT SendMsgToChildren returns %x\n",fAckSent));
return(fAckSent);
}
//+---------------------------------------------------------------------------
//
// Function: SendInitMsgToChildren
//
// Synopsis: Sends an init message to all child windows of the hwnd
//
// Effects: This routine will send an init message to all children
// of the given window. It is assuming that the lParam is
// the atom that contains the topic (ie filename) of the
// object being looked for.
//
// Arguments: [hwnd] -- hwnd of server window
// [msg] -- MSG to send
// [wParam] -- hwnd of client window
// [lParam] -- HIWORD(lParam) is atom of filename
//
// Requires:
//
// Returns:
//
// Signals:
//
// Modifies:
//
// Algorithm:
//
// History: 6-28-94 kevinro Commented
//
// Notes:
//
//----------------------------------------------------------------------------
BOOL SendInitMsgToChildren (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
intrDebugOut((DEB_DDE_INIT,
"0 _IN SendInitMsgToChildren(hwnd=%x,msg=%x,wParam=%x,lParam=%x)\n",
hwnd,msg,wParam,lParam));
BOOL fAckSent = FALSE;
fAckSent = SendMsgToChildren(hwnd,msg,wParam,lParam);
//
// If no windows acknowledged, then we might need to create a doc window
//
if (!fAckSent)
{
ATOM aTopic = HIWORD(lParam);
Assert (IsAtom(aTopic));
// if someone's trying to initiate on a filename, i.e., for a link
// then create the doc window on demand because 2.0 servers do not
// register doc windows. They don't even accept "-Embedding filename"
// on the command line
if (aTopic != aOLE && aTopic != aSysTopic && IsFile (aTopic))
{
intrDebugOut((DEB_DDE_INIT," Initiate for link %ws\n",wAtomName(aTopic)));
HRESULT hresult = MaybeCreateDocWindow (LOWORD(lParam), aTopic,
hwnd, (HWND)wParam);
fAckSent = (NOERROR==hresult);
}
}
intrDebugOut((DEB_DDE_INIT,
"0 _OUT SendInitMsgToChildren fAckSent=%x\n",fAckSent));
return fAckSent;
}
INTERNAL_(HRESULT) RequestDataStd
(
ATOM aItem,
LPHANDLE lphdde
)
{
HANDLE hnew = NULL;
if (!aItem)
goto errRtn;
if (aItem == aEditItems){
hnew = MakeGlobal ("StdHostNames\tStdDocDimensions\tStdTargetDevice");
goto PostData;
}
if (aItem == aProtocols) {
hnew = MakeGlobal ("Embedding\tStdFileEditing");
goto PostData;
}
if (aItem == aTopics) {
hnew = MakeGlobal ("Doc");
goto PostData;
}
if (aItem == aFormats) {
hnew = MakeGlobal ("Picture\tBitmap");
goto PostData;
}
if (aItem == aStatus) {
hnew = MakeGlobal ("Ready");
goto PostData;
}
// format we do not understand.
goto errRtn;
PostData:
// Duplicate the DDE data
if (MakeDDEData (hnew, CF_TEXT, lphdde, TRUE)){
// !!! why are we duplicating the atom.
DuplicateAtom (aItem);
return NOERROR;
}
errRtn:
return ReportResult(0, S_FALSE, 0, 0);
}
//IsSingleServerInstance: returns true if the app is single server app else
//false.
INTERNAL_(BOOL) IsSingleServerInstance ()
{
HWND hwnd;
WORD cnt = 0;
HTASK hTask;
DdeCHAR buf[MAX_STR];
hwnd = GetWindow (GetDesktopWindow(), GW_CHILD);
hTask = GetCurrentThreadId();
while (hwnd) {
if (hTask == ((HTASK) GetWindowThreadProcessId (hwnd,NULL))) {
DdeGetClassName (hwnd, buf, MAX_STR);
if (Ddelstrcmp (buf, SRVR_CLASS) == 0)
cnt++;
}
hwnd = GetWindow (hwnd, GW_HWNDNEXT);
}
#ifdef FIREWALLS
AssertSz (cnt > 0, "srvr window instance count is zero");
#endif
if (cnt == 1)
return TRUE;
else
return FALSE;
}
// QueryRevokeClassFactory: returns FALSE if there are clients
// connected tothis class factory;
INTERNAL_(BOOL) CDDEServer::QueryRevokeClassFactory ()
{
HWND hwnd;
LPCLIENT lpclient;
Assert (IsWindow (m_hwnd));
hwnd = GetWindow (m_hwnd, GW_CHILD);
while (hwnd)
{
Assert (IsWindow (hwnd));
lpclient = (LPCLIENT)GetWindowLongPtr (hwnd, 0);
if (lpclient->m_cClients != 0 || lpclient->m_fCreatedNotConnected)
return FALSE;
hwnd = GetWindow (hwnd, GW_HWNDNEXT);
}
return TRUE;
}
//+---------------------------------------------------------------------------
//
// Method: CDDEServer::CreateInstance
//
// Synopsis: Create an instance of a document
//
// Effects:
//
// Arguments: [lpclassName] --
// [lpWidedocName] --
// [lpdocName] --
// [pUnk] --
// [lplpdocClient] --
// [hwndClient] --
//
// Requires:
//
// Returns:
//
// Signals:
//
// Modifies:
//
// Derivation:
//
// Algorithm:
//
// History: 5-30-94 kevinro Commented/cleaned
//
// Notes:
//
//----------------------------------------------------------------------------
INTERNAL CDDEServer::CreateInstance
(
REFCLSID lpclassName,
LPOLESTR lpWidedocName,
LPSTR lpdocName,
LPUNKNOWN pUnk,
LPCLIENT FAR* lplpdocClient,
HWND hwndClient)
{
intrDebugOut((DEB_ITRACE,
"%p _IN CDDEServer::CreateInstance(lpWidedocName=%ws,hwndClient=%x)\n",
this,
WIDECHECK(lpWidedocName),
hwndClient));
LPUNKNOWN pUnk2=NULL;
LPOLEOBJECT lpoleObj= NULL; // unknown object
HRESULT hresult;
ChkS(this);
if (NULL==pUnk)
{
Assert (m_pClassFactory);
hresult = m_pClassFactory->CreateInstance (NULL, IID_IUnknown, (LPLPVOID)&pUnk2);
if (hresult != NOERROR)
{
return hresult;
}
// Now that we have *used* the DDE server window, we can unlock
// the server.
// The OLE1 OleLockServer API opens a dummy DDE system channel
// and just leaves it open until OleunlockServer is called.
// Since we have now used this channel, we know it was not created
// for the purpose of locking the server.
this->Lock (FALSE, hwndClient);
// if it is an SDI app, we must revoke the ClassFactory after using it
// it is only good for "one-shot" createinstance call.
if (m_fcfFlags == REGCLS_SINGLEUSE)
{
m_pClassFactory->Release(); // done with the ClassFactory
Puts ("NULLing m_pCF\r\n");
m_pClassFactory = NULL;
}
}
else
{
pUnk2 = pUnk;
pUnk->AddRef();
}
hresult = CDefClient::Create ((LPSRVR)this,
pUnk2,
lpWidedocName,
/*fSetClientSite*/FALSE,
/*fDoAdvise*/pUnk!=NULL);
intrAssert (pUnk2 != NULL);
if (pUnk2 != NULL)
{
pUnk2->Release();
}
pUnk2 = NULL;
// REVIEW: error recovery
if (!(*lplpdocClient = FindDocObj (lpdocName)))
{
intrAssert(!"Document created but not found");
}
else
{
// set the server instance flag so that WM_DDE_INITIATE will not icrement
// the ref count. (EXCEL BUG)
(*lplpdocClient)->m_bCreateInst = TRUE;
}
intrDebugOut((DEB_ITRACE,
"%p _OUT CDDEServer::CreateInstance hresult=%x\n",
this,hresult));
return hresult;
}
INTERNAL_(void) CDDEServer::Lock
(BOOL fLock, // lock or unlock?
HWND hwndClient) // on behalf of which window?
{
intrDebugOut((DEB_ITRACE,
"%p _IN CDDEServer::Lock(fLock=%x,hwndCient=%x)\n",
this,
fLock,
hwndClient));
VDATEHEAP();
BOOL fIsLocked = FindClient (m_hcli, hwndClient, /*fDelete*/FALSE) != NULL;
if (fLock && !fIsLocked)
{
if (m_pClassFactory)
{
intrDebugOut((DEB_ITRACE,
"%p ::Locking %x\n",
this,
m_pClassFactory));
m_pClassFactory->LockServer (TRUE);
// Only way to change the data associated with a client window
// is to delete it and re-add it with the new data.
FindClient (m_hcli, hwndClient, /*fDelete*/ TRUE);
AddClient (&m_hcli, hwndClient, (HANDLE) TRUE); // mark as locked
}
}
else if (!fLock && fIsLocked)
{
if (m_pClassFactory)
{
intrDebugOut((DEB_ITRACE,
"%p ::UnLocking %x\n",
this,
m_pClassFactory));
m_pClassFactory->LockServer (FALSE);
FindClient (m_hcli, hwndClient, /*fDelete*/ TRUE);
AddClient (&m_hcli, hwndClient, (HANDLE) FALSE); //mark as unlocked
}
}
VDATEHEAP();
intrDebugOut((DEB_ITRACE,
"%p _OUT CDDEServer::Lock(fLock=%x,hwndCient=%x)\n",
this,
fLock,
hwndClient));
}
INTERNAL CDefClient::DestroyInstance
(void)
{
Puts ("DestroyInstance\r\n");
// We just created the instance. we ran into error.
// just call Release.
m_pUnkOuter->AddRef();
ReleaseObjPtrs();
Verify (0==m_pUnkOuter->Release());
// "this" should be deleted now
return NOERROR;
}
INTERNAL CDefClient::SetClientSite
(void)
{
HRESULT hresult = m_lpoleObj->SetClientSite (&m_OleClientSite);
if (hresult==NOERROR)
{
m_fDidSetClientSite = TRUE;
}
else
{
Warn ("SetClientSite failed");
}
return hresult;
}
// implementations of IRpcStubBuffer methods
STDMETHODIMP CDdeServerCallMgr::QueryInterface
( REFIID iid, LPVOID * ppvObj )
{
return S_OK;
}
STDMETHODIMP_(ULONG)CDdeServerCallMgr::AddRef ()
{
return 1;
}
STDMETHODIMP_(ULONG)CDdeServerCallMgr::Release ()
{
return 1;
}
STDMETHODIMP CDdeServerCallMgr::Connect
(IUnknown * pUnkServer )
{
// do nothing
return S_OK;
}
STDMETHODIMP_(void) CDdeServerCallMgr::Disconnect
()
{
// do nothing
}
STDMETHODIMP_(IRpcStubBuffer*) CDdeServerCallMgr::IsIIDSupported
(REFIID riid)
{
// do nothing
return NULL;
}
STDMETHODIMP_(ULONG) CDdeServerCallMgr::CountRefs
()
{
// do nothing
return 1;
}
STDMETHODIMP CDdeServerCallMgr::DebugServerQueryInterface
(void ** ppv )
{
// do nothing
*ppv = NULL;
return S_OK;
}
STDMETHODIMP_(void) CDdeServerCallMgr::DebugServerRelease
(void * pv)
{
// do nothing
}
STDMETHODIMP CDdeServerCallMgr::Invoke
(RPCOLEMESSAGE *_prpcmsg, IRpcChannelBuffer *_pRpcChannelBuffer)
{
DISPATCHDATA *pdispdata = (PDISPATCHDATA) _prpcmsg->Buffer;
return DispatchCall( pdispdata );
}
// Provided IRpcChannelBuffer methods (for callback methods side)
STDMETHODIMP CDdeServerCallMgr::GetBuffer(
/* [in] */ RPCOLEMESSAGE __RPC_FAR *pMessage,
/* [in] */ REFIID riid)
{
return S_OK;
}
STDMETHODIMP CDdeServerCallMgr::SendReceive(
/* [out][in] */ RPCOLEMESSAGE __RPC_FAR *pMessage,
/* [out] */ ULONG __RPC_FAR *pStatus)
{
return S_OK;
}
STDMETHODIMP CDdeServerCallMgr::FreeBuffer(
/* [in] */ RPCOLEMESSAGE __RPC_FAR *pMessage)
{
return S_OK;
}
STDMETHODIMP CDdeServerCallMgr::GetDestCtx(
/* [out] */ DWORD __RPC_FAR *pdwDestContext,
/* [out] */ void __RPC_FAR *__RPC_FAR *ppvDestContext)
{
return S_OK;
}
STDMETHODIMP CDdeServerCallMgr::IsConnected( void)
{
return S_OK;
}
STDMETHODIMP CDdeServerCallMgr::GetProtocolVersion(
/* [out] */ DWORD __RPC_FAR *pdwVersion)
{
return S_OK;
}
STDMETHODIMP CDdeServerCallMgr::SendReceive2(
/* [out][in] */ RPCOLEMESSAGE __RPC_FAR *pMessage,
/* [out] */ ULONG __RPC_FAR *pStatus)
{
intrDebugOut((DEB_ITRACE,
"%p _IN CDdeServerCallMgr::SendReceive2(pMessage=%x,pStatus=%x)\n",
this,
pMessage,
pStatus));
DDECALLDATA *pCD = ((DDECALLDATA *) pMessage->Buffer);
if(!PostMessageToClient(pCD->hwndSvr,
pCD->wMsg,
pCD->wParam,
pCD->lParam))
{
intrDebugOut((DEB_ITRACE, "SendRecieve2(%x)PostMessageToClient failed", this));
return RPC_E_SERVER_DIED;
}
CAptCallCtrl *pCallCtrl = GetAptCallCtrl();
CCliModalLoop *pCML = pCallCtrl->GetTopCML();
HRESULT hres = S_OK;
BOOL fWait = !(m_pDefClient->m_CallState == SERVERCALLEX_ISHANDLED);
while (fWait)
{
HRESULT hr = OleModalLoopBlockFn(NULL, pCML, NULL);
if (m_pDefClient->m_CallState == SERVERCALLEX_ISHANDLED)
{
fWait = FALSE;
}
else if (hr != RPC_S_CALLPENDING)
{
fWait = FALSE;
hres = hr; // return result from OleModalLoopBlockFn()
}
}
if (FAILED(hres))
{
intrDebugOut((DEB_ITRACE, "**** CDdeServerCallMgr::SendReceive2 OleModalLoopBlockFn returned %x ***\n", hres));
}
intrDebugOut((DEB_ITRACE,
"%p _OUT CDdeServerCallMgr::SendReceive2(pMessage=%x,pStatus=%x)\n",
this,
pMessage,
pStatus));
return hres;
}
STDMETHODIMP CDdeServerCallMgr::ContextInvoke(
/* [out][in] */ RPCOLEMESSAGE *pMessage,
/* [in] */ IRpcStubBuffer *pStub,
/* [in] */ IPIDEntry *pIPIDEntry,
/* [out] */ DWORD *pdwFault)
{
intrDebugOut((DEB_ITRACE,
"%p _IN CDdeServerCallMgr::ContextInvoke(pMessage=%x,pStub=%x,pdwFault=%x)\n",
this,
pMessage,
pStub,
pdwFault));
HRESULT hr = StubInvoke(pMessage, NULL, pStub, (IRpcChannelBuffer3 *)this, pIPIDEntry, pdwFault);
intrDebugOut((DEB_ITRACE,
"%p _OUT CDdeServerCallMgr::ContextInvoke returning hr=0x%x\n",
this,
hr));
return(hr);
}
STDMETHODIMP CDdeServerCallMgr::GetBuffer2(
/* [in] */ RPCOLEMESSAGE __RPC_FAR *pMessage,
/* [in] */ REFIID riid)
{
return GetBuffer(pMessage, riid);
}
| [
"[email protected]"
] | |
37474b6010b22c37294285249f37d1574052e989 | 81b370d8b975b36834800390254f92fb67fb9328 | /AP325/P-6-3.cpp | 3c2c1880a7778848799aef57dce0664fac7ed854 | [
"MIT"
] | permissive | Superdanby/YEE | b58c198486ffb45d5c162958d232441d9ac56ed4 | 3dfb71033455772dac9a6c09a025fdfd0307182e | refs/heads/master | 2022-08-29T05:11:24.816963 | 2022-07-10T08:50:02 | 2022-07-10T08:50:02 | 53,384,232 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 717 | cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr const ll INF = 1L << 60;
ll solve(vector<ll> &nums) {
for (int i = 3; i < nums.size(); ++i) {
ll accum = nums[i - 2] < nums[i - 3] ? nums[i - 2] : nums[i - 3];
nums[i] += accum < nums[i - 1] ? accum : nums[i - 1];
}
return nums[nums.size() - 2] < nums.back() ? nums[nums.size() - 2]
: nums.back();
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int num_cnt;
cin >> num_cnt;
vector<ll> nums(num_cnt + 1);
fill(nums.begin(), nums.begin() + 1, INF);
for (int i = 1; i < nums.size(); ++i) cin >> nums[i];
cout << solve(nums) << "\n";
return 0;
} | [
"[email protected]"
] | |
1b6603dda7928ec96babf22c9b6c175c80ec8a99 | 7ceacce50613174e4722de74fc9de38e08ac92c6 | /Dependencies/libpxcclr/src/pxcmmetadata.cpp | f449e0a0722727715d019f1d0b32351b5943c420 | [] | no_license | ajnovice/Intel-Perceptual-Computing---JARVIS | f6e54abccb6993059675a749e700216b2c126d99 | 9c061274f55e96da2864b7a0db8d05ecb0332091 | refs/heads/master | 2021-05-26T22:47:48.126305 | 2013-09-29T13:44:47 | 2013-09-29T13:44:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,138 | cpp | /*******************************************************************************
INTEL CORPORATION PROPRIETARY INFORMATION
This software is supplied under the terms of a license agreement or nondisclosure
agreement with Intel Corporation and may not be copied or disclosed except in
accordance with the terms of that agreement
Copyright(c) 2012 Intel Corporation. All Rights Reserved.
*******************************************************************************/
#include "pxcmmetadata.h"
pxcmStatus PXCMMetadata::AttachBuffer(pxcmUID id, array<pxcmBYTE> ^buffer) {
pin_ptr<pxcmBYTE> pp(&buffer[0]);
return (pxcmStatus)QueryInstance()->AttachBuffer((pxcUID)id,(pxcBYTE*)pp,buffer->Length);
}
pxcmStatus PXCMMetadata::QueryBuffer(pxcmUID id, [Out] array<pxcmBYTE> ^%buffer) {
buffer=nullptr;
pxcU32 bufferSize=0;
pxcStatus sts=QueryInstance()->QueryBuffer((pxcUID)id,0,&bufferSize);
if (sts>=PXC_STATUS_NO_ERROR) {
buffer=gcnew array<pxcmBYTE>(bufferSize);
pin_ptr<pxcmBYTE> pp(&buffer[0]);
sts=QueryInstance()->QueryBuffer((pxcUID)id,(pxcBYTE*)pp,&bufferSize);
}
return (pxcmStatus)sts;
}
pxcmStatus PXCMMetadata::QueryMetadata(pxcmU32 idx, [Out] pxcmUID %id) {
pxcUID id2;
pxcStatus sts=QueryInstance()->QueryMetadata((pxcU32)idx,&id2);
id=id2;
return (pxcmStatus)sts;
}
pxcmStatus PXCMMetadata::AttachSerializable(pxcmUID id, PXCMBase ^instance) {
return (pxcmStatus)QueryInstance()->AttachSerializable((pxcUID)id,instance->m_instance);
}
pxcmStatus PXCMMetadata::CreateSerializable(pxcmUID id, pxcmUID cuid, [Out] PXCMBase ^%instance) {
void *instance2=0;
pxcStatus sts=QueryInstance()->CreateSerializable((pxcUID)id,(pxcUID)cuid,&instance2);
instance=(sts>=PXC_STATUS_NO_ERROR)?PXCMBase::DynamicCastEx(cuid,(PXCBase*)instance2):nullptr;
return (pxcmStatus)sts;
}
pxcmStatus PXCMMetadata::DetachMetadata(pxcmUID id) {
return (pxcmStatus)QueryInstance()->DetachMetadata((pxcUID)id);
}
pxcmUID PXCMMetadata::QueryUID(void) {
return (pxcmUID)QueryInstance()->QueryUID();
}
| [
"[email protected]"
] | |
5e83440c8d118a8ca54eb9a98df8402e4e04ab48 | a2edddc09740e8c2ff3a483f26c786eba6f14806 | /impgears/graphics/RenderTarget.cpp | 31c7b67f66ceb525dde1b2bec1b6b74e396619ea | [
"MIT"
] | permissive | BtPht/ImpGears | 233c97947a452ac6f17b68a3a3263014564b4e74 | 199f2648982a0aa555f15d3d4f9414d7033243a0 | refs/heads/master | 2021-01-18T09:02:20.468306 | 2015-02-22T22:37:48 | 2015-02-22T22:37:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,631 | cpp | #include "RenderTarget.h"
#include "EvnContextInterface.h"
#include <cstdio>
#include "camera/Camera.h"
IMPGEARS_BEGIN
//--------------------------------------------------------------
RenderTarget::RenderTarget():
m_type(TargetType_Unkown),
m_width(0),
m_height(0),
m_bpp(0),
m_textureCount(0),
m_hasDepthBuffer(false),
m_depthTexture(IMP_NULL)
{
for(Uint32 i=0; i<5; ++i)
m_colorTextures[i] = IMP_NULL;
}
//--------------------------------------------------------------
RenderTarget::~RenderTarget()
{
destroy();
}
//--------------------------------------------------------------
void RenderTarget::createScreenTarget(Uint32 windowID)
{
destroy();
m_type = TargetType_Screen;
EvnContextInterface* evn = EvnContextInterface::getInstance();
m_width = evn->getWidth(windowID);
m_height = evn->getHeight(windowID);
m_bpp = 32;
m_hasDepthBuffer = false;
}
//--------------------------------------------------------------
void RenderTarget::createBufferTarget(Uint32 width, Uint32 height, Uint32 textureCount, bool depthBuffer)
{
destroy();
m_type = TargetType_Buffer;
m_hasDepthBuffer = depthBuffer;
m_width = width;
m_height = height;
m_textureCount = textureCount;
glGenFramebuffers(1, &m_frameBufferID);
glBindFramebuffer(GL_FRAMEBUFFER, m_frameBufferID);
GL_CHECKERROR("bind FBO");
GLenum DrawBuffers[5] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3, GL_COLOR_ATTACHMENT4};
for(Uint32 i=0; i<textureCount; ++i)
{
m_colorTextures[i] = new Texture();
m_colorTextures[i]->create(width, height, PixelFormat_RGBA8);
m_colorTextures[i]->setSmooth(false);
m_colorTextures[i]->setRepeated(false);
m_colorTextures[i]->synchronize();
m_colorTextures[i]->bind();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+i, GL_TEXTURE_2D, m_colorTextures[i]->getVideoID(), 0);
GL_CHECKERROR("set color buffer");
}
if(m_hasDepthBuffer)
{
m_depthTexture = new Texture();
m_depthTexture->create(width, height, PixelFormat_R16);
m_depthTexture->setSmooth(false);
m_depthTexture->setRepeated(false);
m_depthTexture->synchronize();
m_depthTexture->bind();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture->getVideoID(), 0);
GL_CHECKERROR("set depth buffer");
}
glDrawBuffers(textureCount, DrawBuffers);
GL_CHECKERROR("set draw buffers");
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
fprintf(stderr, "[impError] FrameBuffer creation failed.\n");
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
//--------------------------------------------------------------
void RenderTarget::destroy()
{
if(m_type == TargetType_Buffer)
{
glDeleteFramebuffers(1, &m_frameBufferID);
for(Uint32 i=0; i<m_textureCount; ++i)
{
delete m_colorTextures[i];
m_colorTextures[i] = IMP_NULL;
}
if(m_hasDepthBuffer)
{
delete m_depthTexture;
m_depthTexture = IMP_NULL;
}
}
m_textureCount = 0;
m_hasDepthBuffer = false;
m_type = TargetType_Unkown;
}
//--------------------------------------------------------------
Texture* RenderTarget::getTexture(Uint32 n)
{
if(m_type != TargetType_Buffer)
{
fprintf(stderr, "[impError] Render target has not texture buffer.\n");
return IMP_NULL;
}
return m_colorTextures[n];
}
//--------------------------------------------------------------
Texture* RenderTarget::getDepthTexture()
{
if(m_type != TargetType_Buffer || m_hasDepthBuffer == false)
{
fprintf(stderr, "[impError] Render target has not depth texture.\n");
return IMP_NULL;
}
return m_depthTexture;
}
//--------------------------------------------------------------
void RenderTarget::bind()
{
if(m_type == TargetType_Buffer)
glBindFramebuffer(GL_FRAMEBUFFER, m_frameBufferID);
else
unbind();
glViewport(0, 0, m_width, m_height);
}
//--------------------------------------------------------------
void RenderTarget::unbind()
{
if(m_type == TargetType_Buffer)
{
for(Uint32 i=0; i<m_textureCount; ++i)
{
m_colorTextures[i]->notifyTextureRendering();
m_colorTextures[i]->synchronize();
}
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
IMPGEARS_END
| [
"[email protected]"
] | |
2caa3822708d2cbff55993689dd9fa6d9c3f89ee | ebd73ddfc5d041d3a4315449d54d3a01b786ea8b | /compress.hpp | 601e11c1e5eb6723fb9b5a071d78c5eaa9ed5518 | [
"MIT"
] | permissive | Anil-Turgeman/itertools-cfar-a | caee352452b45884cef6a7ea9d6ed9f43db538f1 | e482d5bde6d34e77f5b3b6694fa5bf65b6583eaa | refs/heads/master | 2022-11-11T01:38:41.093010 | 2020-06-25T10:48:01 | 2020-06-25T10:48:01 | 271,559,523 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,187 | hpp | #include <iostream>
#include <vector>
#include <typeinfo>
#include <cassert>
#include <iterator>
using namespace std;
namespace itertools{
template<typename T> struct is_bool {
static const bool value = false;
};
template<> struct is_bool<bool> {
static const bool value = true;
};
template <typename Container,typename ContainerBool>
class compress{
private:
const ContainerBool& cbool;
const Container& container;
public:
compress(const Container& cont,const ContainerBool& cb ):container(cont),cbool(cb){}
class iterator {
private:
decltype(container.begin()) pos;
decltype(container.end()) end;
decltype(cbool.begin()) pos_bool;
decltype(cbool.end()) end_bool;
public:
iterator(decltype(container.begin()) p,decltype(container.end()) end,
decltype(cbool.begin()) p_bool,decltype(cbool.end()) end_bool):
pos(p),end(end),pos_bool(p_bool),end_bool(end_bool) {
while(!*pos_bool && pos_bool!=end_bool){
++pos;
++pos_bool;
}
}
iterator& operator++() {
do{
++pos;
++pos_bool;
}while(!*pos_bool && pos_bool!=end_bool);
return *this;
}
iterator operator++(int) {
iterator tmp= *this;
pos++;
pos_bool++;
while(!*pos_bool && pos_bool!=end_bool){
++pos;
++pos_bool;
}
return tmp;
}
auto operator*() {
if(!*pos_bool && pos!=end){
(*this)++;
}
return *pos;
}
bool operator==(const iterator& rhs) const {
return pos == rhs.pos;
}
bool operator!=(const iterator& rhs) const{
return pos != rhs.pos;
}
};
iterator begin() const{
return iterator(container.begin(),container.end(),cbool.begin(),cbool.end());
}
iterator end() const{
return iterator(container.end(),container.end(),cbool.end(),cbool.end());
}
};
}
| [
"[email protected]"
] | |
c391dccda599d6d42ccea6eac0aea6ff4568ec15 | 16d5cd8328ff8b31334afac4030754e59151c376 | /source/pubsub/stress_adapter.h | 5121ecd56a105ee28b59916e947f8497c10a9678 | [
"MIT"
] | permissive | TorstenRobitzki/Sioux | c443083677b10a8796dedc3adc3f950e273758e5 | 709eef5ebab5fed896b0b36f0c89f0499954657d | refs/heads/master | 2023-03-31T18:44:55.391134 | 2023-03-16T06:51:56 | 2023-03-16T06:51:56 | 5,154,565 | 19 | 9 | MIT | 2023-03-16T06:51:57 | 2012-07-23T16:51:12 | C++ | UTF-8 | C++ | false | false | 4,174 | h | // Copyright (c) Torrox GmbH & Co KG. All rights reserved.
// Please note that the content of this file is confidential or protected by law.
// Any unauthorised copying or unauthorised distribution of the information contained herein is prohibited.
#ifndef SIOUX_PUBSUB_STRESS_ADAPTER_H
#define SIOUX_PUBSUB_STRESS_ADAPTER_H
#include "pubsub/pubsub.h"
#include "pubsub/node.h"
#include <boost/asio/io_service.hpp>
#include <boost/thread/mutex.hpp>
#include <map>
#include <set>
namespace pubsub
{
namespace test
{
/*!
* \brief adapter that decides whether a requested action succeeds or not, solely by the node name and a per subscriber
* authorization
*
* For validation and initialization and authorization, there is are distinct key domains in the node name that
* describes if the requested action should succeed or not:
*
* "valid" : "\"valid\"" ; The node is valid. The callback will be called immediately.
* "\"async_valid\"" ; The node is valid. The call to the callback will be postponed via the used io_service.
* "\"async_invalid\"" ; The node is invalid. The call to the callback will be postponed via the used io_service.
*
* "init" : "x" ; if the node_name contains a domain name "init" the node will not cause errors while
* initializing and return a value equal to json::parse("x").
*
* "async_init" : "x" ; if the node_name contains a domain name "async_init" the node will not cause errors while
* initializing and will post a call to the initialization call back with x.
*
* "async_init_fail" : ; If the node_name contains a domain "async_init_fail", the initialization failure will be postponed
* via the stored io_service.
*
* "async_auth" : ; Answer to an authorization request will be posted to the given io_service.
*/
class stress_adapter : public ::pubsub::adapter
{
public:
/*!
* \brief constructs a stress_adapter for testing and stores the passed io_service to be used to simulate
* asynchronous behavior
* \param queue queue that is used to simulate deferred (asynchronous) answers to requests. The responding call
* to a call back is posted to the queue if asynchronous response is used.
*/
explicit stress_adapter( boost::asio::io_service& queue );
/*!
* \brief adds a new node to the subscribers list of authorized nodes.
*
* If the subscriber requests access to the given node, by subscribing to the node, the adapter will grand
* access, if the node name was previously added to the subscribers list of authorized nodes by calling this function.
* If the node name contains a key "auth"="\"async\"", the call to the given call back will be postponed.
*
* The subscribers address will be stored, to identify the subscriber later.
*/
void add_authorization(const subscriber& subcriber, const node_name& authorized_node);
/*!
* \brief removes a node from the subscribers list of authorized nodes.
* \post the authorized_node must have been added to the subscribers list before.
*/
void remove_authorization(const subscriber& subcriber, const node_name& authorized_node);
private:
// no copy, no assigment
stress_adapter(const stress_adapter&);
stress_adapter& operator=(const stress_adapter&);
// adapter implementation
virtual void validate_node(const pubsub::node_name& node_name, const boost::shared_ptr<pubsub::validation_call_back>&);
virtual void authorize(const boost::shared_ptr<pubsub::subscriber>&, const pubsub::node_name& node_name,
const boost::shared_ptr<pubsub::authorization_call_back>&);
virtual void node_init(const pubsub::node_name& node_name, const boost::shared_ptr<pubsub::initialization_call_back>&);
typedef std::map< const void*, std::set<node_name> > authorized_nodes_by_subscriber_list_t;
boost::mutex mutex_;
authorized_nodes_by_subscriber_list_t authorized_nodes_by_subscriber_;
boost::asio::io_service& io_queue_;
};
}
}
#endif /* SIOUX_PUBSUB_STRESS_ADAPTER_H */
| [
"[email protected]"
] | |
e9062007510e85ba7ad127f1bd3a7668bf918749 | da336c579916f2e098ec8b27d53eb20813aec718 | /Prova2/esercizio1int.cpp | bf5be05d85c654349773cd071501a028916b29fc | [] | no_license | aladimpa/esercitazioni_uni | 319b4bf21c56798f052959fe2749dfbb8a56de82 | 0a979a721e73fdcbcf1a8249f41fb6d72c2e75a7 | refs/heads/master | 2021-01-19T16:34:20.861031 | 2017-05-24T13:00:29 | 2017-05-24T13:00:29 | 88,271,115 | 0 | 1 | null | 2017-05-19T16:39:06 | 2017-04-14T13:46:28 | C++ | UTF-8 | C++ | false | false | 723 | cpp | #include <iostream>
using namespace std;
int main()
{
int num1, num2, add, sott, molt, divis, resto;
cout << "Inserisci il primo numero: "<<endl;
cin >> num1;
cout << "Inserisci il secondo numero: "<<endl;
cin >> num2;
add=num1+num2;
sott=num1-num2;
molt=num1*num2;
divis=num1/num2;
resto=num1%num2;
cout << "I risultati delle operazioni sono:" << endl
<< "Addizione = " << add << ";" << endl
<< "Sottrazione = " << sott << ";" << endl
<< "Moltiplicazione = " << molt << ";" << endl
<< "Divisione = " << divis << ";" << endl;
if (resto!=0)
{
cout << "La divisione ha resto " << resto << endl;
}
return 0;
} | [
"[email protected]"
] | |
e6c98dd126bda46dfdb60917107f45cc6c482150 | 51121984f98e7a79f9b9cd844ebe0314fd0845f2 | /Voxilian/Src/Engine/Core/Core0/Tier3/NeuralNet/NeuralNet.cpp | 3e0efbad64fe5b7ae9ad0f3fd2cef0683b2bbc56 | [] | no_license | Skareeg/voxilian | 584b7463ceeb1cd78cd39371b008a889126ddcb0 | bc24fa80c914855dbef96cc9cd82e5fc9edb0ac9 | refs/heads/master | 2020-04-14T16:53:32.521942 | 2014-04-02T02:05:06 | 2014-04-02T02:05:06 | 32,126,141 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,770 | cpp | #include "NeuralNet.h"
#include "..\..\Core0.h"
CNNNode::CNNNode()
{
value=0.0f;
}
void CNETINIT(CNeuralNet* net)
{
}
void CNeuralNet::Init(int iiinputs,int iiwidth,int iiheight,int iioutputs)
{
iinputs=iiinputs;
iwidth=iiwidth;
iheight=iiheight;
ioutputs=iioutputs;
inputs.resize(iinputs);
nodes.resize(iwidth);
outputs.resize(ioutputs);
targets.resize(ioutputs);
target.resize(ioutputs);
for(int i = 0;i<iinputs;i++)
{
CNNNode* cn = new CNNNode();
cn->weights.resize(iheight);
for(int j = 0;j<iheight;j++)
{
cn->weights[j]=rnd();
}
inputs[i]=cn;
}
for(int i = 0;i<iwidth;i++)
{
nodes[i].resize(iheight);
for(int j = 0;j<iheight;j++)
{
CNNNode* cn = new CNNNode();
cn->weights.resize(iheight);
for(int k = 0;k<iheight;k++)
{
cn->weights[k]=rnd();
}
nodes[i][j]=cn;
}
}
for(int i = 0;i<ioutputs;i++)
{
CNNNode* cn = new CNNNode();
outputs[i]=cn;
target[i]=false;
targets[i]=0.0f;
}
}
void CNETRUN(CNeuralNet* net)
{
net->Calculate();
net->BackPropagate();
}
void CNeuralNet::Run()
{
if(glfwWaitThread(thread,GLFW_NOWAIT)==1)
{
thread = glfwCreateThread((GLFWthreadfun)CNETRUN,this);
}
}
float sigmoid(float num)
{
return (1.0f/(powf(EXP,num)));
}
void CNeuralNet::Calculate()
{
for(int i = 0;i<iwidth;i++)
{
for(int j = 0;j<iheight;j++)
{
float value = 0.0f;
if(i==0)
{
for(int k = 0;k<iinputs;k++)
{
value+=inputs[k]->value*inputs[k]->weights[j];
}
}
else
{
for(int k = 0;k<iheight;k++)
{
value+=nodes[i-1][k]->value*nodes[i-1][k]->weights[j];
}
}
nodes[i][j]->value=sigmoid(value);
}
}
}
void CNeuralNet::BackPropagate()
{
} | [
"[email protected]@825dd620-273b-aec8-ac3f-b42787872301"
] | [email protected]@825dd620-273b-aec8-ac3f-b42787872301 |
3299d0fea450d7ddedba682aa7be18c3bf38511d | 94c980dff20873bf6d0c4c21413697f8e07ded10 | /16-AUG-19/SJF.cpp | 30ac42f5bfda7e722722660862bddbca0db5c09f | [] | no_license | pg8469/OS_LAB | 04cec307a9a501a7a9040d09e7132269793f30c9 | 862f8a42372bf823db8093ce690dd21db10e5be4 | refs/heads/master | 2020-08-27T19:30:37.860605 | 2019-10-25T06:59:28 | 2019-10-25T06:59:28 | 217,471,072 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,233 | cpp | #include <iostream>
#include <bits/stdc++.h>
#include <utility>
class PAIR {
public:
int first;
int second;
};
struct CompareExec {
bool operator()(PAIR p1, PAIR p2)
{
return p1.second > p2.second;
}
};
using namespace std;
int main()
{
long long N;
cin >> N;
PAIR pro[N];
vector<vector<long long> > res(4);
for( int i =0 ; i< N ; i++ )
{
cin >> pro[i].first >> pro[i].second;
}
priority_queue <PAIR , vector < PAIR > , CompareExec > execuSpace;
long long arrival = pro[0].first;
res[0].push_back(pro[0].first);
res[1].push_back(pro[0].second);
res[2].push_back(pro[0].first);
res[3].push_back(pro[0].first);
int j = 0 ;
for( int i = 1 ; i < N ; )
{
execuSpace.push(pro[i]);
i++;
// cout << "First "<< execuSpace.top().first << " Second " << execuSpace.top( ).second << endl;
// cout << pro[i].first << " check " << res[2][j] << endl;
while( pro[i].first < res[2][j] && i < N )
{
execuSpace.push(pro[i]);
// cout << " Line : First "<< pro[i].first << " Second " << pro[i].second << endl;
i++;
}
res[0].push_back(execuSpace.top().first );
res[1].push_back(execuSpace.top().second );
res[2].push_back( res[2][j] + res[1][j]);
res[3].push_back( res[2][j+1] - execuSpace.top().first );
j++;
execuSpace.pop();
// cout << "First "<< execuSpace.top().first << " Second " << execuSpace.top( ).second << endl;
}
while( !execuSpace.empty() )
{
res[0].push_back(execuSpace.top().first );
res[1].push_back(execuSpace.top().second );
res[2].push_back( res[2][j] + res[1][j]);
res[3].push_back( res[2][j+1] - execuSpace.top().first );
j++;
execuSpace.pop();
// cout << "First "<< execuSpace.top().first << " Second " << execuSpace.top( ).second << endl;
}
cout << "Arrival " << "Execution " << "Service " << "Waiting "<< endl;
for( int i = 0 ; i < N ; i++ )
{
cout << res[0][i] << " " << res[1][i] << " " << res[2][i] << " " << res[3][i] << endl;
}
} | [
"[email protected]"
] | |
05a39534310c405d1f1f6147bd6234b4607ac66c | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/git/gumtree/git_repos_function_851_git-2.14.0.cpp | d9424324b5d9cecf99ccea155cee41ad54d0b335 | [] | 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 | 284 | cpp | int parse_opt_passthru(const struct option *opt, const char *arg, int unset)
{
static struct strbuf sb = STRBUF_INIT;
char **opt_value = opt->value;
if (recreate_opt(&sb, opt, arg, unset) < 0)
return -1;
free(*opt_value);
*opt_value = strbuf_detach(&sb, NULL);
return 0;
} | [
"[email protected]"
] | |
6a5fa39398b44673d6e2ad253bc3f26867155715 | a0415faaaf2bcdf4d2fbae0006aa6a5f7a031aae | /app_httpd.cpp | 37ab3017eddbc5c607f87bb9faf66d232494f752 | [] | no_license | HLGhpz/ESP32-CAM | 5fc1ec0db10796c974d37744da0a566edc1def69 | 92fb9cff201320a00ef3ca8324a74501a9618ba4 | refs/heads/master | 2022-03-02T10:19:34.369781 | 2019-10-03T11:57:31 | 2019-10-03T11:57:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 22,753 | cpp | #include "esp_http_server.h"
#include "esp_timer.h"
#include "esp_camera.h"
#include "img_converters.h"
#include "camera_index.h"
#include "Arduino.h"
#include "fb_gfx.h"
#include "fd_forward.h"
#include "fr_forward.h"
#define ENROLL_CONFIRM_TIMES 5
#define FACE_ID_SAVE_NUMBER 7
#define FACE_COLOR_WHITE 0x00FFFFFF
#define FACE_COLOR_BLACK 0x00000000
#define FACE_COLOR_RED 0x000000FF
#define FACE_COLOR_GREEN 0x0000FF00
#define FACE_COLOR_BLUE 0x00FF0000
#define FACE_COLOR_YELLOW (FACE_COLOR_RED | FACE_COLOR_GREEN)
#define FACE_COLOR_CYAN (FACE_COLOR_BLUE | FACE_COLOR_GREEN)
#define FACE_COLOR_PURPLE (FACE_COLOR_BLUE | FACE_COLOR_RED)
typedef struct {
size_t size; //number of values used for filtering
size_t index; //current value index
size_t count; //value count
int sum;
int * values; //array to be filled with values
} ra_filter_t;
typedef struct {
httpd_req_t *req;
size_t len;
} jpg_chunking_t;
#define PART_BOUNDARY "123456789000000000000987654321"
static const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;
static const char* _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
static ra_filter_t ra_filter;
httpd_handle_t stream_httpd = NULL;
httpd_handle_t camera_httpd = NULL;
static mtmn_config_t mtmn_config = {0};
static int8_t detection_enabled = 0;
static int8_t recognition_enabled = 0;
static int8_t is_enrolling = 0;
static face_id_list id_list = {0};
static ra_filter_t * ra_filter_init(ra_filter_t * filter, size_t sample_size){
memset(filter, 0, sizeof(ra_filter_t));
filter->values = (int *)malloc(sample_size * sizeof(int));
if(!filter->values){
return NULL;
}
memset(filter->values, 0, sample_size * sizeof(int));
filter->size = sample_size;
return filter;
}
static int ra_filter_run(ra_filter_t * filter, int value){
if(!filter->values){
return value;
}
filter->sum -= filter->values[filter->index];
filter->values[filter->index] = value;
filter->sum += filter->values[filter->index];
filter->index++;
filter->index = filter->index % filter->size;
if (filter->count < filter->size) {
filter->count++;
}
return filter->sum / filter->count;
}
static void rgb_print(dl_matrix3du_t *image_matrix, uint32_t color, const char * str){
fb_data_t fb;
fb.width = image_matrix->w;
fb.height = image_matrix->h;
fb.data = image_matrix->item;
fb.bytes_per_pixel = 3;
fb.format = FB_BGR888;
fb_gfx_print(&fb, (fb.width - (strlen(str) * 14)) / 2, 10, color, str);
}
static int rgb_printf(dl_matrix3du_t *image_matrix, uint32_t color, const char *format, ...){
char loc_buf[64];
char * temp = loc_buf;
int len;
va_list arg;
va_list copy;
va_start(arg, format);
va_copy(copy, arg);
len = vsnprintf(loc_buf, sizeof(loc_buf), format, arg);
va_end(copy);
if(len >= sizeof(loc_buf)){
temp = (char*)malloc(len+1);
if(temp == NULL) {
return 0;
}
}
vsnprintf(temp, len+1, format, arg);
va_end(arg);
rgb_print(image_matrix, color, temp);
if(len > 64){
free(temp);
}
return len;
}
static void draw_face_boxes(dl_matrix3du_t *image_matrix, box_array_t *boxes, int face_id){
int x, y, w, h, i;
uint32_t color = FACE_COLOR_YELLOW;
if(face_id < 0){
color = FACE_COLOR_RED;
} else if(face_id > 0){
color = FACE_COLOR_GREEN;
}
fb_data_t fb;
fb.width = image_matrix->w;
fb.height = image_matrix->h;
fb.data = image_matrix->item;
fb.bytes_per_pixel = 3;
fb.format = FB_BGR888;
for (i = 0; i < boxes->len; i++){
// rectangle box
x = (int)boxes->box[i].box_p[0];
y = (int)boxes->box[i].box_p[1];
w = (int)boxes->box[i].box_p[2] - x + 1;
h = (int)boxes->box[i].box_p[3] - y + 1;
fb_gfx_drawFastHLine(&fb, x, y, w, color);
fb_gfx_drawFastHLine(&fb, x, y+h-1, w, color);
fb_gfx_drawFastVLine(&fb, x, y, h, color);
fb_gfx_drawFastVLine(&fb, x+w-1, y, h, color);
#if 0
// landmark
int x0, y0, j;
for (j = 0; j < 10; j+=2) {
x0 = (int)boxes->landmark[i].landmark_p[j];
y0 = (int)boxes->landmark[i].landmark_p[j+1];
fb_gfx_fillRect(&fb, x0, y0, 3, 3, color);
}
#endif
}
}
static int run_face_recognition(dl_matrix3du_t *image_matrix, box_array_t *net_boxes){
dl_matrix3du_t *aligned_face = NULL;
int matched_id = 0;
aligned_face = dl_matrix3du_alloc(1, FACE_WIDTH, FACE_HEIGHT, 3);
if(!aligned_face){
Serial.println("Could not allocate face recognition buffer");
return matched_id;
}
if (align_face(net_boxes, image_matrix, aligned_face) == ESP_OK){
if (is_enrolling == 1){
int8_t left_sample_face = enroll_face(&id_list, aligned_face);
if(left_sample_face == (ENROLL_CONFIRM_TIMES - 1)){
Serial.printf("Enrolling Face ID: %d\n", id_list.tail);
}
Serial.printf("Enrolling Face ID: %d sample %d\n", id_list.tail, ENROLL_CONFIRM_TIMES - left_sample_face);
rgb_printf(image_matrix, FACE_COLOR_CYAN, "ID[%u] Sample[%u]", id_list.tail, ENROLL_CONFIRM_TIMES - left_sample_face);
if (left_sample_face == 0){
is_enrolling = 0;
Serial.printf("Enrolled Face ID: %d\n", id_list.tail);
}
} else {
matched_id = recognize_face(&id_list, aligned_face);
if (matched_id >= 0) {
Serial.printf("Match Face ID: %u\n", matched_id);
rgb_printf(image_matrix, FACE_COLOR_GREEN, "Hello Subject %u", matched_id);
} else {
Serial.println("No Match Found");
rgb_print(image_matrix, FACE_COLOR_RED, "Intruder Alert!");
matched_id = -1;
}
}
} else {
Serial.println("Face Not Aligned");
//rgb_print(image_matrix, FACE_COLOR_YELLOW, "Human Detected");
}
dl_matrix3du_free(aligned_face);
return matched_id;
}
static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size_t len){
jpg_chunking_t *j = (jpg_chunking_t *)arg;
if(!index){
j->len = 0;
}
if(httpd_resp_send_chunk(j->req, (const char *)data, len) != ESP_OK){
return 0;
}
j->len += len;
return len;
}
static esp_err_t capture_handler(httpd_req_t *req){
camera_fb_t * fb = NULL;
esp_err_t res = ESP_OK;
int64_t fr_start = esp_timer_get_time();
fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Camera capture failed");
httpd_resp_send_500(req);
return ESP_FAIL;
}
httpd_resp_set_type(req, "image/jpeg");
httpd_resp_set_hdr(req, "Content-Disposition", "inline; filename=capture.jpg");
size_t out_len, out_width, out_height;
uint8_t * out_buf;
bool s;
bool detected = false;
int face_id = 0;
if(!detection_enabled || fb->width > 400){
size_t fb_len = 0;
if(fb->format == PIXFORMAT_JPEG){
fb_len = fb->len;
res = httpd_resp_send(req, (const char *)fb->buf, fb->len);
} else {
jpg_chunking_t jchunk = {req, 0};
res = frame2jpg_cb(fb, 80, jpg_encode_stream, &jchunk)?ESP_OK:ESP_FAIL;
httpd_resp_send_chunk(req, NULL, 0);
fb_len = jchunk.len;
}
esp_camera_fb_return(fb);
int64_t fr_end = esp_timer_get_time();
Serial.printf("JPG: %uB %ums\n", (uint32_t)(fb_len), (uint32_t)((fr_end - fr_start)/1000));
return res;
}
dl_matrix3du_t *image_matrix = dl_matrix3du_alloc(1, fb->width, fb->height, 3);
if (!image_matrix) {
esp_camera_fb_return(fb);
Serial.println("dl_matrix3du_alloc failed");
httpd_resp_send_500(req);
return ESP_FAIL;
}
out_buf = image_matrix->item;
out_len = fb->width * fb->height * 3;
out_width = fb->width;
out_height = fb->height;
s = fmt2rgb888(fb->buf, fb->len, fb->format, out_buf);
esp_camera_fb_return(fb);
if(!s){
dl_matrix3du_free(image_matrix);
Serial.println("to rgb888 failed");
httpd_resp_send_500(req);
return ESP_FAIL;
}
box_array_t *net_boxes = face_detect(image_matrix, &mtmn_config);
if (net_boxes){
detected = true;
if(recognition_enabled){
face_id = run_face_recognition(image_matrix, net_boxes);
}
draw_face_boxes(image_matrix, net_boxes, face_id);
free(net_boxes->box);
free(net_boxes->landmark);
free(net_boxes);
}
jpg_chunking_t jchunk = {req, 0};
s = fmt2jpg_cb(out_buf, out_len, out_width, out_height, PIXFORMAT_RGB888, 90, jpg_encode_stream, &jchunk);
dl_matrix3du_free(image_matrix);
if(!s){
Serial.println("JPEG compression failed");
return ESP_FAIL;
}
int64_t fr_end = esp_timer_get_time();
Serial.printf("FACE: %uB %ums %s%d\n", (uint32_t)(jchunk.len), (uint32_t)((fr_end - fr_start)/1000), detected?"DETECTED ":"", face_id);
return res;
}
static esp_err_t stream_handler(httpd_req_t *req){
camera_fb_t * fb = NULL;
esp_err_t res = ESP_OK;
size_t _jpg_buf_len = 0;
uint8_t * _jpg_buf = NULL;
char * part_buf[64];
dl_matrix3du_t *image_matrix = NULL;
bool detected = false;
int face_id = 0;
int64_t fr_start = 0;
int64_t fr_ready = 0;
int64_t fr_face = 0;
int64_t fr_recognize = 0;
int64_t fr_encode = 0;
static int64_t last_frame = 0;
if(!last_frame) {
last_frame = esp_timer_get_time();
}
res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);
if(res != ESP_OK){
return res;
}
while(true){
detected = false;
face_id = 0;
fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Camera capture failed");
res = ESP_FAIL;
} else {
fr_start = esp_timer_get_time();
fr_ready = fr_start;
fr_face = fr_start;
fr_encode = fr_start;
fr_recognize = fr_start;
if(!detection_enabled || fb->width > 400){
if(fb->format != PIXFORMAT_JPEG){
bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);
esp_camera_fb_return(fb);
fb = NULL;
if(!jpeg_converted){
Serial.println("JPEG compression failed");
res = ESP_FAIL;
}
} else {
_jpg_buf_len = fb->len;
_jpg_buf = fb->buf;
}
} else {
image_matrix = dl_matrix3du_alloc(1, fb->width, fb->height, 3);
if (!image_matrix) {
Serial.println("dl_matrix3du_alloc failed");
res = ESP_FAIL;
} else {
if(!fmt2rgb888(fb->buf, fb->len, fb->format, image_matrix->item)){
Serial.println("fmt2rgb888 failed");
res = ESP_FAIL;
} else {
fr_ready = esp_timer_get_time();
box_array_t *net_boxes = NULL;
if(detection_enabled){
net_boxes = face_detect(image_matrix, &mtmn_config);
}
fr_face = esp_timer_get_time();
fr_recognize = fr_face;
if (net_boxes || fb->format != PIXFORMAT_JPEG){
if(net_boxes){
detected = true;
if(recognition_enabled){
face_id = run_face_recognition(image_matrix, net_boxes);
}
fr_recognize = esp_timer_get_time();
draw_face_boxes(image_matrix, net_boxes, face_id);
free(net_boxes->box);
free(net_boxes->landmark);
free(net_boxes);
}
if(!fmt2jpg(image_matrix->item, fb->width*fb->height*3, fb->width, fb->height, PIXFORMAT_RGB888, 90, &_jpg_buf, &_jpg_buf_len)){
Serial.println("fmt2jpg failed");
res = ESP_FAIL;
}
esp_camera_fb_return(fb);
fb = NULL;
} else {
_jpg_buf = fb->buf;
_jpg_buf_len = fb->len;
}
fr_encode = esp_timer_get_time();
}
dl_matrix3du_free(image_matrix);
}
}
}
if(res == ESP_OK){
size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len);
res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);
}
if(res == ESP_OK){
res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);
}
if(res == ESP_OK){
res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));
}
if(fb){
esp_camera_fb_return(fb);
fb = NULL;
_jpg_buf = NULL;
} else if(_jpg_buf){
free(_jpg_buf);
_jpg_buf = NULL;
}
if(res != ESP_OK){
break;
}
int64_t fr_end = esp_timer_get_time();
int64_t ready_time = (fr_ready - fr_start)/1000;
int64_t face_time = (fr_face - fr_ready)/1000;
int64_t recognize_time = (fr_recognize - fr_face)/1000;
int64_t encode_time = (fr_encode - fr_recognize)/1000;
int64_t process_time = (fr_encode - fr_start)/1000;
int64_t frame_time = fr_end - last_frame;
last_frame = fr_end;
frame_time /= 1000;
uint32_t avg_frame_time = ra_filter_run(&ra_filter, frame_time);
Serial.printf("MJPG: %uB %ums (%.1ffps), AVG: %ums (%.1ffps), %u+%u+%u+%u=%u %s%d\n",
(uint32_t)(_jpg_buf_len),
(uint32_t)frame_time, 1000.0 / (uint32_t)frame_time,
avg_frame_time, 1000.0 / avg_frame_time,
(uint32_t)ready_time, (uint32_t)face_time, (uint32_t)recognize_time, (uint32_t)encode_time, (uint32_t)process_time,
(detected)?"DETECTED ":"", face_id
);
}
last_frame = 0;
return res;
}
static esp_err_t cmd_handler(httpd_req_t *req){
char* buf;
size_t buf_len;
char variable[32] = {0,};
char value[32] = {0,};
buf_len = httpd_req_get_url_query_len(req) + 1;
if (buf_len > 1) {
buf = (char*)malloc(buf_len);
if(!buf){
httpd_resp_send_500(req);
return ESP_FAIL;
}
if (httpd_req_get_url_query_str(req, buf, buf_len) == ESP_OK) {
if (httpd_query_key_value(buf, "var", variable, sizeof(variable)) == ESP_OK &&
httpd_query_key_value(buf, "val", value, sizeof(value)) == ESP_OK) {
} else {
free(buf);
httpd_resp_send_404(req);
return ESP_FAIL;
}
} else {
free(buf);
httpd_resp_send_404(req);
return ESP_FAIL;
}
free(buf);
} else {
httpd_resp_send_404(req);
return ESP_FAIL;
}
int val = atoi(value);
sensor_t * s = esp_camera_sensor_get();
int res = 0;
if(!strcmp(variable, "framesize")) {
if(s->pixformat == PIXFORMAT_JPEG) res = s->set_framesize(s, (framesize_t)val);
}
else if(!strcmp(variable, "quality")) res = s->set_quality(s, val);
else if(!strcmp(variable, "contrast")) res = s->set_contrast(s, val);
else if(!strcmp(variable, "brightness")) res = s->set_brightness(s, val);
else if(!strcmp(variable, "saturation")) res = s->set_saturation(s, val);
else if(!strcmp(variable, "gainceiling")) res = s->set_gainceiling(s, (gainceiling_t)val);
else if(!strcmp(variable, "colorbar")) res = s->set_colorbar(s, val);
else if(!strcmp(variable, "awb")) res = s->set_whitebal(s, val);
else if(!strcmp(variable, "agc")) res = s->set_gain_ctrl(s, val);
else if(!strcmp(variable, "aec")) res = s->set_exposure_ctrl(s, val);
else if(!strcmp(variable, "hmirror")) res = s->set_hmirror(s, val);
else if(!strcmp(variable, "vflip")) res = s->set_vflip(s, val);
else if(!strcmp(variable, "awb_gain")) res = s->set_awb_gain(s, val);
else if(!strcmp(variable, "agc_gain")) res = s->set_agc_gain(s, val);
else if(!strcmp(variable, "aec_value")) res = s->set_aec_value(s, val);
else if(!strcmp(variable, "aec2")) res = s->set_aec2(s, val);
else if(!strcmp(variable, "dcw")) res = s->set_dcw(s, val);
else if(!strcmp(variable, "bpc")) res = s->set_bpc(s, val);
else if(!strcmp(variable, "wpc")) res = s->set_wpc(s, val);
else if(!strcmp(variable, "raw_gma")) res = s->set_raw_gma(s, val);
else if(!strcmp(variable, "lenc")) res = s->set_lenc(s, val);
else if(!strcmp(variable, "special_effect")) res = s->set_special_effect(s, val);
else if(!strcmp(variable, "wb_mode")) res = s->set_wb_mode(s, val);
else if(!strcmp(variable, "ae_level")) res = s->set_ae_level(s, val);
else if(!strcmp(variable, "face_detect")) {
detection_enabled = val;
if(!detection_enabled) {
recognition_enabled = 0;
}
}
else if(!strcmp(variable, "face_enroll")) is_enrolling = val;
else if(!strcmp(variable, "face_recognize")) {
recognition_enabled = val;
if(recognition_enabled){
detection_enabled = val;
}
}
else {
res = -1;
}
if(res){
return httpd_resp_send_500(req);
}
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
return httpd_resp_send(req, NULL, 0);
}
static esp_err_t status_handler(httpd_req_t *req){
static char json_response[1024];
sensor_t * s = esp_camera_sensor_get();
char * p = json_response;
*p++ = '{';
p+=sprintf(p, "\"framesize\":%u,", s->status.framesize);
p+=sprintf(p, "\"quality\":%u,", s->status.quality);
p+=sprintf(p, "\"brightness\":%d,", s->status.brightness);
p+=sprintf(p, "\"contrast\":%d,", s->status.contrast);
p+=sprintf(p, "\"saturation\":%d,", s->status.saturation);
p+=sprintf(p, "\"sharpness\":%d,", s->status.sharpness);
p+=sprintf(p, "\"special_effect\":%u,", s->status.special_effect);
p+=sprintf(p, "\"wb_mode\":%u,", s->status.wb_mode);
p+=sprintf(p, "\"awb\":%u,", s->status.awb);
p+=sprintf(p, "\"awb_gain\":%u,", s->status.awb_gain);
p+=sprintf(p, "\"aec\":%u,", s->status.aec);
p+=sprintf(p, "\"aec2\":%u,", s->status.aec2);
p+=sprintf(p, "\"ae_level\":%d,", s->status.ae_level);
p+=sprintf(p, "\"aec_value\":%u,", s->status.aec_value);
p+=sprintf(p, "\"agc\":%u,", s->status.agc);
p+=sprintf(p, "\"agc_gain\":%u,", s->status.agc_gain);
p+=sprintf(p, "\"gainceiling\":%u,", s->status.gainceiling);
p+=sprintf(p, "\"bpc\":%u,", s->status.bpc);
p+=sprintf(p, "\"wpc\":%u,", s->status.wpc);
p+=sprintf(p, "\"raw_gma\":%u,", s->status.raw_gma);
p+=sprintf(p, "\"lenc\":%u,", s->status.lenc);
p+=sprintf(p, "\"vflip\":%u,", s->status.vflip);
p+=sprintf(p, "\"hmirror\":%u,", s->status.hmirror);
p+=sprintf(p, "\"dcw\":%u,", s->status.dcw);
p+=sprintf(p, "\"colorbar\":%u,", s->status.colorbar);
p+=sprintf(p, "\"face_detect\":%u,", detection_enabled);
p+=sprintf(p, "\"face_enroll\":%u,", is_enrolling);
p+=sprintf(p, "\"face_recognize\":%u", recognition_enabled);
*p++ = '}';
*p++ = 0;
httpd_resp_set_type(req, "application/json");
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
return httpd_resp_send(req, json_response, strlen(json_response));
}
static esp_err_t index_handler(httpd_req_t *req){
httpd_resp_set_type(req, "text/html");
httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
sensor_t * s = esp_camera_sensor_get();
return httpd_resp_send(req, (const char *)index_ov2640_html_gz, index_ov2640_html_gz_len);
}
void startCameraServer(){
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
httpd_uri_t index_uri = {
.uri = "/",
.method = HTTP_GET,
.handler = index_handler,
.user_ctx = NULL
};
httpd_uri_t status_uri = {
.uri = "/status",
.method = HTTP_GET,
.handler = status_handler,
.user_ctx = NULL
};
httpd_uri_t cmd_uri = {
.uri = "/control",
.method = HTTP_GET,
.handler = cmd_handler,
.user_ctx = NULL
};
httpd_uri_t capture_uri = {
.uri = "/capture",
.method = HTTP_GET,
.handler = capture_handler,
.user_ctx = NULL
};
httpd_uri_t stream_uri = {
.uri = "/stream",
.method = HTTP_GET,
.handler = stream_handler,
.user_ctx = NULL
};
ra_filter_init(&ra_filter, 20);
mtmn_config.min_face = 80;
mtmn_config.pyramid = 0.7;
mtmn_config.p_threshold.score = 0.6;
mtmn_config.p_threshold.nms = 0.7;
mtmn_config.r_threshold.score = 0.7;
mtmn_config.r_threshold.nms = 0.7;
mtmn_config.r_threshold.candidate_number = 4;
mtmn_config.o_threshold.score = 0.7;
mtmn_config.o_threshold.nms = 0.4;
mtmn_config.o_threshold.candidate_number = 1;
face_id_init(&id_list, FACE_ID_SAVE_NUMBER, ENROLL_CONFIRM_TIMES);
Serial.printf("Starting web server on port: '%d'\n", config.server_port);
if (httpd_start(&camera_httpd, &config) == ESP_OK) {
httpd_register_uri_handler(camera_httpd, &index_uri);
httpd_register_uri_handler(camera_httpd, &cmd_uri);
httpd_register_uri_handler(camera_httpd, &status_uri);
httpd_register_uri_handler(camera_httpd, &capture_uri);
}
config.server_port += 1;
config.ctrl_port += 1;
Serial.printf("Starting stream server on port: '%d'\n", config.server_port);
if (httpd_start(&stream_httpd, &config) == ESP_OK) {
httpd_register_uri_handler(stream_httpd, &stream_uri);
}
}
| [
"[email protected]"
] | |
d83ffc64be9c300e0d9386094c307c20a8f450fb | e0159e48fcbee78ae545f61a9b6d1f81805af5df | /Bitmasking/3uique number.cpp | 83baa6f61d109da05836d65edd440a3b82d7b8bb | [
"MIT"
] | permissive | sans712/SDE-Interview-Questions | 944f583d63b4a30020d6ecc0de09eb50948a5f7f | 44f5bda60b9ed301b93a944e1c333d833c9b054b | refs/heads/master | 2022-12-24T14:28:46.896108 | 2020-10-01T05:39:16 | 2020-10-01T05:39:16 | 300,159,282 | 0 | 0 | MIT | 2020-10-01T05:41:08 | 2020-10-01T05:41:08 | null | UTF-8 | C++ | false | false | 361 | cpp | #include<iostream>
using namespace std;
#include<bits/stdc++.h>
int main(){
int num,no;
int cnt[64]={0};
cin>>num;
for(int i=0;i<num;i++){
cin>>no;
int j=0;
while(no>0){
int last_bit=no&1;
cnt[j]+=last_bit;
j++;
no=no>>1;
}
}
int ans=0,p=1;
for(int i=0;i<64;i++){
cnt[i]=cnt[i]%3;
ans+=cnt[i]*p;
p=p<<1;
}
cout<<ans<<endl;
} | [
"[email protected]"
] | |
d5ed0c20344524572d798048ea24b08711523002 | 73ee941896043f9b3e2ab40028d24ddd202f695f | /external/chromium_org/net/quic/quic_stream_factory_test.cc | 2f46772d0fc24358219654fe9216e5b2082e4d69 | [
"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 | 13,530 | cc | // 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.
#include "net/quic/quic_stream_factory.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "net/cert/cert_verifier.h"
#include "net/dns/mock_host_resolver.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
#include "net/http/http_util.h"
#include "net/quic/crypto/quic_decrypter.h"
#include "net/quic/crypto/quic_encrypter.h"
#include "net/quic/quic_http_stream.h"
#include "net/quic/test_tools/mock_clock.h"
#include "net/quic/test_tools/mock_crypto_client_stream_factory.h"
#include "net/quic/test_tools/mock_random.h"
#include "net/quic/test_tools/quic_test_utils.h"
#include "net/socket/socket_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
namespace test {
class QuicStreamFactoryTest : public ::testing::Test {
protected:
QuicStreamFactoryTest()
: clock_(new MockClock()),
factory_(&host_resolver_, &socket_factory_,
&crypto_client_stream_factory_,
&random_generator_, clock_),
host_port_proxy_pair_(HostPortPair("www.google.com", 443),
ProxyServer::Direct()),
is_https_(false),
cert_verifier_(CertVerifier::CreateDefault()) {
}
scoped_ptr<QuicEncryptedPacket> ConstructRstPacket(
QuicPacketSequenceNumber num,
QuicStreamId stream_id) {
QuicPacketHeader header;
header.public_header.guid = 0xDEADBEEF;
header.public_header.reset_flag = false;
header.public_header.version_flag = true;
header.packet_sequence_number = num;
header.entropy_flag = false;
header.fec_flag = false;
header.fec_group = 0;
QuicRstStreamFrame rst(stream_id, QUIC_STREAM_NO_ERROR);
return scoped_ptr<QuicEncryptedPacket>(
ConstructPacket(header, QuicFrame(&rst)));
}
scoped_ptr<QuicEncryptedPacket> ConstructAckPacket(
QuicPacketSequenceNumber largest_received,
QuicPacketSequenceNumber least_unacked) {
QuicPacketHeader header;
header.public_header.guid = 0xDEADBEEF;
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.packet_sequence_number = 2;
header.entropy_flag = false;
header.fec_flag = false;
header.fec_group = 0;
QuicAckFrame ack(largest_received, QuicTime::Zero(), least_unacked);
QuicCongestionFeedbackFrame feedback;
feedback.type = kTCP;
feedback.tcp.accumulated_number_of_lost_packets = 0;
feedback.tcp.receive_window = 16000;
QuicFramer framer(QuicVersionMax(), QuicTime::Zero(), false);
QuicFrames frames;
frames.push_back(QuicFrame(&ack));
frames.push_back(QuicFrame(&feedback));
scoped_ptr<QuicPacket> packet(
framer.BuildUnsizedDataPacket(header, frames).packet);
return scoped_ptr<QuicEncryptedPacket>(framer.EncryptPacket(
ENCRYPTION_NONE, header.packet_sequence_number, *packet));
}
// Returns a newly created packet to send congestion feedback data.
scoped_ptr<QuicEncryptedPacket> ConstructFeedbackPacket(
QuicPacketSequenceNumber sequence_number) {
QuicPacketHeader header;
header.public_header.guid = 0xDEADBEEF;
header.public_header.reset_flag = false;
header.public_header.version_flag = false;
header.packet_sequence_number = sequence_number;
header.entropy_flag = false;
header.fec_flag = false;
header.fec_group = 0;
QuicCongestionFeedbackFrame frame;
frame.type = kTCP;
frame.tcp.accumulated_number_of_lost_packets = 0;
frame.tcp.receive_window = 16000;
return scoped_ptr<QuicEncryptedPacket>(
ConstructPacket(header, QuicFrame(&frame)));
}
scoped_ptr<QuicEncryptedPacket> ConstructPacket(
const QuicPacketHeader& header,
const QuicFrame& frame) {
QuicFramer framer(QuicVersionMax(), QuicTime::Zero(), false);
QuicFrames frames;
frames.push_back(frame);
scoped_ptr<QuicPacket> packet(
framer.BuildUnsizedDataPacket(header, frames).packet);
return scoped_ptr<QuicEncryptedPacket>(framer.EncryptPacket(
ENCRYPTION_NONE, header.packet_sequence_number, *packet));
}
MockHostResolver host_resolver_;
DeterministicMockClientSocketFactory socket_factory_;
MockCryptoClientStreamFactory crypto_client_stream_factory_;
MockRandom random_generator_;
MockClock* clock_; // Owned by factory_.
QuicStreamFactory factory_;
HostPortProxyPair host_port_proxy_pair_;
bool is_https_;
scoped_ptr<CertVerifier> cert_verifier_;
BoundNetLog net_log_;
TestCompletionCallback callback_;
};
TEST_F(QuicStreamFactoryTest, CreateIfSessionExists) {
EXPECT_EQ(NULL, factory_.CreateIfSessionExists(host_port_proxy_pair_,
net_log_).get());
}
TEST_F(QuicStreamFactoryTest, Create) {
MockRead reads[] = {
MockRead(ASYNC, OK, 0) // EOF
};
DeterministicSocketData socket_data(reads, arraysize(reads), NULL, 0);
socket_factory_.AddSocketDataProvider(&socket_data);
socket_data.StopAfter(1);
QuicStreamRequest request(&factory_);
EXPECT_EQ(ERR_IO_PENDING, request.Request(host_port_proxy_pair_, is_https_,
cert_verifier_.get(), net_log_,
callback_.callback()));
EXPECT_EQ(OK, callback_.WaitForResult());
scoped_ptr<QuicHttpStream> stream = request.ReleaseStream();
EXPECT_TRUE(stream.get());
// Will reset stream 3.
stream = factory_.CreateIfSessionExists(host_port_proxy_pair_, net_log_);
EXPECT_TRUE(stream.get());
// TODO(rtenneti): We should probably have a tests that HTTP and HTTPS result
// in streams on different sessions.
QuicStreamRequest request2(&factory_);
EXPECT_EQ(OK, request2.Request(host_port_proxy_pair_, is_https_,
cert_verifier_.get(), net_log_,
callback_.callback()));
stream = request2.ReleaseStream(); // Will reset stream 5.
stream.reset(); // Will reset stream 7.
EXPECT_TRUE(socket_data.at_read_eof());
EXPECT_TRUE(socket_data.at_write_eof());
}
TEST_F(QuicStreamFactoryTest, MaxOpenStream) {
MockRead reads[] = {
MockRead(ASYNC, OK, 0) // EOF
};
DeterministicSocketData socket_data(reads, arraysize(reads), NULL, 0);
socket_factory_.AddSocketDataProvider(&socket_data);
socket_data.StopAfter(1);
HttpRequestInfo request_info;
std::vector<QuicHttpStream*> streams;
// The MockCryptoClientStream sets max_open_streams to be
// 2 * kDefaultMaxStreamsPerConnection.
for (size_t i = 0; i < 2 * kDefaultMaxStreamsPerConnection; i++) {
QuicStreamRequest request(&factory_);
int rv = request.Request(host_port_proxy_pair_, is_https_,
cert_verifier_.get(), net_log_,
callback_.callback());
if (i == 0) {
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback_.WaitForResult());
} else {
EXPECT_EQ(OK, rv);
}
scoped_ptr<QuicHttpStream> stream = request.ReleaseStream();
EXPECT_TRUE(stream);
EXPECT_EQ(OK, stream->InitializeStream(
&request_info, DEFAULT_PRIORITY, net_log_, CompletionCallback()));
streams.push_back(stream.release());
}
QuicStreamRequest request(&factory_);
EXPECT_EQ(OK, request.Request(host_port_proxy_pair_, is_https_,
cert_verifier_.get(), net_log_,
CompletionCallback()));
scoped_ptr<QuicHttpStream> stream = request.ReleaseStream();
EXPECT_TRUE(stream);
EXPECT_EQ(ERR_IO_PENDING, stream->InitializeStream(
&request_info, DEFAULT_PRIORITY, net_log_, callback_.callback()));
// Close the first stream.
streams.front()->Close(false);
ASSERT_TRUE(callback_.have_result());
EXPECT_EQ(OK, callback_.WaitForResult());
EXPECT_TRUE(socket_data.at_read_eof());
EXPECT_TRUE(socket_data.at_write_eof());
STLDeleteElements(&streams);
}
TEST_F(QuicStreamFactoryTest, CreateError) {
DeterministicSocketData socket_data(NULL, 0, NULL, 0);
socket_factory_.AddSocketDataProvider(&socket_data);
host_resolver_.rules()->AddSimulatedFailure("www.google.com");
QuicStreamRequest request(&factory_);
EXPECT_EQ(ERR_IO_PENDING, request.Request(host_port_proxy_pair_, is_https_,
cert_verifier_.get(), net_log_,
callback_.callback()));
EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult());
EXPECT_TRUE(socket_data.at_read_eof());
EXPECT_TRUE(socket_data.at_write_eof());
}
TEST_F(QuicStreamFactoryTest, CancelCreate) {
MockRead reads[] = {
MockRead(ASYNC, OK, 0) // EOF
};
DeterministicSocketData socket_data(reads, arraysize(reads), NULL, 0);
socket_factory_.AddSocketDataProvider(&socket_data);
{
QuicStreamRequest request(&factory_);
EXPECT_EQ(ERR_IO_PENDING, request.Request(host_port_proxy_pair_, is_https_,
cert_verifier_.get(), net_log_,
callback_.callback()));
}
socket_data.StopAfter(1);
base::RunLoop run_loop;
run_loop.RunUntilIdle();
scoped_ptr<QuicHttpStream> stream(
factory_.CreateIfSessionExists(host_port_proxy_pair_, net_log_));
EXPECT_TRUE(stream.get());
stream.reset();
EXPECT_TRUE(socket_data.at_read_eof());
EXPECT_TRUE(socket_data.at_write_eof());
}
TEST_F(QuicStreamFactoryTest, CloseAllSessions) {
MockRead reads[] = {
MockRead(ASYNC, 0, 0) // EOF
};
DeterministicSocketData socket_data(reads, arraysize(reads), NULL, 0);
socket_factory_.AddSocketDataProvider(&socket_data);
socket_data.StopAfter(1);
MockRead reads2[] = {
MockRead(ASYNC, 0, 0) // EOF
};
DeterministicSocketData socket_data2(reads2, arraysize(reads2), NULL, 0);
socket_factory_.AddSocketDataProvider(&socket_data2);
socket_data2.StopAfter(1);
QuicStreamRequest request(&factory_);
EXPECT_EQ(ERR_IO_PENDING, request.Request(host_port_proxy_pair_, is_https_,
cert_verifier_.get(), net_log_,
callback_.callback()));
EXPECT_EQ(OK, callback_.WaitForResult());
scoped_ptr<QuicHttpStream> stream = request.ReleaseStream();
HttpRequestInfo request_info;
EXPECT_EQ(OK, stream->InitializeStream(&request_info,
DEFAULT_PRIORITY,
net_log_, CompletionCallback()));
// Close the session and verify that stream saw the error.
factory_.CloseAllSessions(ERR_INTERNET_DISCONNECTED);
EXPECT_EQ(ERR_INTERNET_DISCONNECTED,
stream->ReadResponseHeaders(callback_.callback()));
// Now attempting to request a stream to the same origin should create
// a new session.
QuicStreamRequest request2(&factory_);
EXPECT_EQ(ERR_IO_PENDING, request2.Request(host_port_proxy_pair_, is_https_,
cert_verifier_.get(), net_log_,
callback_.callback()));
EXPECT_EQ(OK, callback_.WaitForResult());
stream = request2.ReleaseStream();
stream.reset(); // Will reset stream 3.
EXPECT_TRUE(socket_data.at_read_eof());
EXPECT_TRUE(socket_data.at_write_eof());
EXPECT_TRUE(socket_data2.at_read_eof());
EXPECT_TRUE(socket_data2.at_write_eof());
}
TEST_F(QuicStreamFactoryTest, OnIPAddressChanged) {
MockRead reads[] = {
MockRead(ASYNC, 0, 0) // EOF
};
DeterministicSocketData socket_data(reads, arraysize(reads), NULL, 0);
socket_factory_.AddSocketDataProvider(&socket_data);
socket_data.StopAfter(1);
MockRead reads2[] = {
MockRead(ASYNC, 0, 0) // EOF
};
DeterministicSocketData socket_data2(reads2, arraysize(reads2), NULL, 0);
socket_factory_.AddSocketDataProvider(&socket_data2);
socket_data2.StopAfter(1);
QuicStreamRequest request(&factory_);
EXPECT_EQ(ERR_IO_PENDING, request.Request(host_port_proxy_pair_, is_https_,
cert_verifier_.get(), net_log_,
callback_.callback()));
EXPECT_EQ(OK, callback_.WaitForResult());
scoped_ptr<QuicHttpStream> stream = request.ReleaseStream();
HttpRequestInfo request_info;
EXPECT_EQ(OK, stream->InitializeStream(&request_info,
DEFAULT_PRIORITY,
net_log_, CompletionCallback()));
// Change the IP address and verify that stream saw the error.
factory_.OnIPAddressChanged();
EXPECT_EQ(ERR_NETWORK_CHANGED,
stream->ReadResponseHeaders(callback_.callback()));
// Now attempting to request a stream to the same origin should create
// a new session.
QuicStreamRequest request2(&factory_);
EXPECT_EQ(ERR_IO_PENDING, request2.Request(host_port_proxy_pair_, is_https_,
cert_verifier_.get(), net_log_,
callback_.callback()));
EXPECT_EQ(OK, callback_.WaitForResult());
stream = request2.ReleaseStream();
stream.reset(); // Will reset stream 3.
EXPECT_TRUE(socket_data.at_read_eof());
EXPECT_TRUE(socket_data.at_write_eof());
EXPECT_TRUE(socket_data2.at_read_eof());
EXPECT_TRUE(socket_data2.at_write_eof());
}
} // namespace test
} // namespace net
| [
"[email protected]"
] | |
e0e804990f5b99f7207f4c7eb5e15adc540bbce2 | 1c888fbe74d0b8842ac68ffd75499493aa092138 | /TaskSchedular.h | c08fe78f57e8f4c27ba5f09187b72cd0539f6429 | [] | no_license | fastbird/FBTaskSchedular | 1275e1ecc4ff0f7b66b285cb5127c17ff718ccde | bdaba8414536b177630fbb9a6fc9300076a72483 | refs/heads/master | 2020-06-19T09:38:56.901832 | 2019-08-08T21:59:16 | 2019-08-08T21:59:16 | 196,665,643 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,325 | h | #pragma once
#include <condition_variable>
#include <list>
#include <vector>
namespace fb
{
class FTaskSchedular;
enum class ETaskPriority
{
VeryHigh,
High,
Normal,
Low,
VeryLow,
Count
};
class FTask;
class ITaskListener {
public:
virtual void OnTaskFinish(FTask* task) {}
};
class FTask : public ITaskListener
{
public:
std::vector<ITaskListener*> TaskListeners;
bool AutoDelete = false;
virtual void Run() = 0;
virtual bool CanRun() const = 0;
void NotifyFinish()
{
for (auto listener : TaskListeners) {
listener->OnTaskFinish(this);
}
}
};
class FTaskThread
{
public:
FTaskSchedular& TaskSchedular;
std::thread Thread;
volatile bool Quit = false;
FTask* Task = nullptr;
std::condition_variable CV;
std::mutex Mutex;
FTaskThread(FTaskSchedular& taskSchedular);
void EnterLoop();
};
class FTaskSchedular
{
std::mutex Mutex;
std::list<FTask*> Tasks[(int)ETaskPriority::Count];
std::vector<FTaskThread*> TaskThreads;
bool Finish = true;
bool Quit = false;
std::condition_variable CVFinish;
public:
void CreateTaskThreads(int numTaskThreads);
void FinishTaskThreads();
void AddTask(FTask* task, ETaskPriority priority);
void Wait();
private:
friend void TaskThread(FTaskThread* taskThread);
FTask* PopTask();
};
} | [
"[email protected]"
] | |
b4975d310ca39bd84177be4716e6426b3782a588 | 8cf32b4cbca07bd39341e1d0a29428e420b492a6 | /externals/binaryen/src/support/colors.h | d797ef2f3d75cfd99c857a96c83a2c101cb57dfd | [
"MIT",
"Apache-2.0"
] | permissive | cubetrain/CubeTrain | e1cd516d5dbca77082258948d3c7fc70ebd50fdc | b930a3e88e941225c2c54219267f743c790e388f | refs/heads/master | 2020-04-11T23:00:50.245442 | 2018-12-17T16:07:16 | 2018-12-17T16:07:16 | 156,970,178 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,620 | h | /*
* Copyright 2015 WebAssembly Community Group participants
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef wasm_support_color_h
#define wasm_support_color_h
#include <iosfwd>
namespace Colors {
void disable();
#if defined(__linux__) || defined(__APPLE__)
void outputColorCode(std::ostream& stream, const char *colorCode);
inline void normal(std::ostream& stream) { outputColorCode(stream,"\033[0m"); }
inline void red(std::ostream& stream) { outputColorCode(stream,"\033[31m"); }
inline void magenta(std::ostream& stream) { outputColorCode(stream,"\033[35m"); }
inline void orange(std::ostream& stream) { outputColorCode(stream,"\033[33m"); }
inline void grey(std::ostream& stream) { outputColorCode(stream,"\033[37m"); }
inline void green(std::ostream& stream) { outputColorCode(stream,"\033[32m"); }
inline void blue(std::ostream& stream) { outputColorCode(stream,"\033[34m"); }
inline void bold(std::ostream& stream) { outputColorCode(stream,"\033[1m"); }
#elif defined(_WIN32)
void outputColorCode(std::ostream& stream, const unsigned short &colorCode);
inline void normal(std::ostream& stream) { outputColorCode(stream, 0x07); }
inline void red(std::ostream& stream) { outputColorCode(stream, 0x0c); }
inline void magenta(std::ostream& stream) { outputColorCode(stream, 0x05); }
inline void orange(std::ostream& stream) { outputColorCode(stream, 0x06); }
inline void grey(std::ostream& stream) { outputColorCode(stream, 0x08); }
inline void green(std::ostream& stream) { outputColorCode(stream, 0x02); }
inline void blue(std::ostream& stream) { outputColorCode(stream, 0x09); }
inline void bold(std::ostream& stream) { /* Do nothing */ }
#else
inline void normal(std::ostream& stream) {}
inline void red(std::ostream& stream) {}
inline void magenta(std::ostream& stream) {}
inline void orange(std::ostream& stream) {}
inline void grey(std::ostream& stream) {}
inline void green(std::ostream& stream) {}
inline void blue(std::ostream& stream) {}
inline void bold(std::ostream& stream) {}
#endif
};
#endif // wasm_support_color_h
| [
"[email protected]"
] | |
3fcd62386daee66f3daec5a4c76799361eb48316 | b55a1da5314b01f9ef617ecb5d56b78d90340e6f | /sorting/radix_sort.cpp | 2a6948a2744568047ae72995636f69d51e0a53ae | [] | no_license | dakshverma2411/data-structures | 1da52acb5017b9fd2e45227b342ab2c1a1bb1f84 | 73540fedbe6e3f31e77d7fbeb38e7605977d5414 | refs/heads/master | 2022-08-20T22:59:28.453459 | 2020-05-25T12:23:12 | 2020-05-25T12:23:12 | 266,767,523 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,054 | cpp | #include<iostream>
#include<cmath>
#include<queue>
using namespace std;
void radix_sort(int * arr,int n)
{
int max=INT_MIN;
for(int i=0;i<n;i++)
{
if(max<arr[i])
{
max=arr[i];
}
}
cout<<"max:"<<max<<endl;
int largest_length=log10(max)+1;
queue <int> s[10];
for(int i=1;i<=largest_length;i++)
{
int divisor=pow(10,i-1);
for(int j=0;j<n;j++)
{
int x=arr[j]/divisor;
s[(x%10)].push(arr[j]);
}
int k=0;
for(int l=0;l<10;l++)
{
while(!s[l].empty())
{
arr[k++]=s[l].front();
s[l].pop();
}
}
for(int o=0;o<n;o++)
{
cout<<arr[o]<<" ";
}
cout<<endl;
}
}
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
radix_sort(arr,n);
cout<<endl;
for(int i=0;i<n;i++)
{
cout<<arr[i]<<" ";
}
} | [
"[email protected]"
] | |
40a66fddd10314e462b53ccc14476d3d25d7475f | c496edec2fc0ccb52290975c9d62e87b9289ab15 | /test.cc | cbe5f4ce7f7f707a38a70bfe1bb8f1ab41af85ac | [] | no_license | poseidonv/test_SLAM | cac25da95402186010a9e416f410ca1aa267b0cb | c0652d01c75366d80d50168af63802971c7a7bf9 | refs/heads/main | 2023-04-01T21:26:07.361989 | 2021-04-13T09:08:48 | 2021-04-13T09:08:48 | 357,489,786 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,642 | cc | #include <iostream>
#include <unordered_map>
#include <ctime>
#include <iomanip>
#include <typeinfo>
#include <cstdlib>
#include <sstream>
#include "SLAM_base.h"
#include "Reprojection.h"
using namespace std;
#define N_PICTURES 800
int main(int argc, char **argv)
{
vector<string> filenames;
string filedir = "/home/poseidon/Documents/00/image_0/";
for (int i = 0; i < N_PICTURES; i++)
{
stringstream ss;
ss << std::setw(6) << std::setfill('0') << i;
filenames.push_back(filedir + ss.str() + ".png");
}
vector<pair<cv::Mat, cv::Mat>> poses;
poses.push_back(make_pair(cv::Mat::eye(3, 3, CV_32FC1), cv::Mat::zeros(3, 1, CV_32FC1)));
cv::Mat totalR, totalt;
totalR = cv::Mat::eye(3, 3, CV_32FC1);
totalt = cv::Mat::zeros(3, 1, CV_32FC1);
for (int i = 1; i < N_PICTURES; i++)
{
cv::Mat Rcw, tcw;
cv::Mat Rwc, twc;
cv::Mat resultR, resultt;
// /home/poseidon/Documents/00/image_0/000201.png /home/poseidon/Documents/00/image_0/000202.png
EstimatePose(filenames[i - 1], filenames[i], Rcw, tcw);
// cout<<filenames[i - 1]<<" "<<filenames[i]<<endl;
Rwc = Rcw.t();
twc = -Rwc * tcw;
totalt = totalt + totalR*twc;
totalR = totalR*Rwc;
// totalR = totalR*Rcw;
// Rwc = Rcw.t();
resultR = totalR.clone();
resultt = totalt.clone();
poses.push_back(make_pair(resultR, resultt));
// cout << "R: \n"<< Rwc << endl<< "t:\n"<< twc << endl;
}
string filename = "TEST_KITTI.txt";
SaveKeyFrameTrajectoryTUM(filename, poses);
return 0;
} | [
"[email protected]"
] | |
f614a1158823c8da8f60280217c9db1e84a8fb60 | 0e8d57f10639b0bdcab2c89b307029697c909863 | /atcoder/abc058/D/main.cpp | 65d07eaf01b9abad9acc582a6a5ebf31b2385d20 | [
"Apache-2.0"
] | permissive | xirc/cp-algorithm | 07a6faf5228e07037920f5011326c16091a9157d | e83ea891e9f8994fdd6f704819c0c69f5edd699a | refs/heads/main | 2021-12-25T16:19:57.617683 | 2021-12-22T12:06:49 | 2021-12-22T12:06:49 | 226,591,291 | 15 | 1 | Apache-2.0 | 2021-12-22T12:06:50 | 2019-12-07T23:53:18 | C++ | UTF-8 | C++ | false | false | 738 | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll const MOD = 1e9 + 7;
int N, M;
vector<int> xs, ys;
ll solve() {
ll xx = 0;
for (int i = 0; i < N; ++i) {
xx += (ll(i) * xs[i]) - (ll(N - 1 - i) * xs[i]);
xx %= MOD;
}
ll yy = 0;
for (int i = 0; i < M; ++i) {
yy += (ll(i) * ys[i]) - (ll(M - 1 - i) * ys[i]);
yy %= MOD;
}
return xx * yy % MOD;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> N >> M;
xs.assign(N, 0);
ys.assign(M, 0);
for (int i = 0; i < N; ++i) {
cin >> xs[i];
}
for (int i = 0; i < M; ++i) {
cin >> ys[i];
}
cout << solve() << endl;
return 0;
} | [
"[email protected]"
] | |
49b61665c7b2a22ac0aefae50a03043ae1e7bd1d | 7712e63123fdcaf0396f6c2d6ad6cd6b198f9aa3 | /Learn28-Font/main.cpp | 92233bd5930ed60082a223a307599124b3639977 | [] | no_license | YzlCoder/LearnOpengl | c151aeed63b0b949c87a32d490f8979ebe025a86 | f128f71728952668cb1a14de1d6b3bcc4536c1c9 | refs/heads/master | 2021-08-23T05:05:44.698503 | 2017-12-03T14:13:07 | 2017-12-03T14:13:07 | 107,639,295 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,667 | cpp | // Std. Includes
#include <string>
// GLEW
#define GLEW_STATIC
#include <GL/glew.h>
// GLFW
#include <GLFW/glfw3.h>
// GL includes
#include "ShaderTool.h"
#include "Camera.h"
// GLM Mathemtics
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <map>
// FreeType
#include <ft2build.h>
#include FT_FREETYPE_H
// Properties
const GLuint WIDTH = 800, HEIGHT = 600;
/// Holds all state information relevant to a character as loaded using FreeType
struct Character {
GLuint TextureID; // ID handle of the glyph texture
glm::ivec2 Size; // Size of glyph
glm::ivec2 Bearing; // Offset from baseline to left/top of glyph
GLuint Advance; // Horizontal offset to advance to next glyph
};
std::map<GLchar, Character> Characters;
GLuint VAO, VBO;
void RenderText(Shader &shader, std::string text, GLfloat x, GLfloat y, GLfloat scale, glm::vec3 color);
// timing
float deltaTime = 0.0f;
float lastFrame = 0.0f;
float fps = 0.0f;
// The MAIN function, from here we start our application and run the Game loop
int main()
{
// Init GLFW
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr); // Windowed
glfwMakeContextCurrent(window);
// Initialize GLEW to setup the OpenGL Function pointers
glewExperimental = GL_TRUE;
glewInit();
// Define the viewport dimensions
glViewport(0, 0, WIDTH, HEIGHT);
// Set OpenGL options
glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Compile and setup the shader
Shader shader("shaders/text.vs", "shaders/text.frag");
glm::mat4 projection = glm::ortho(0.0f, static_cast<GLfloat>(WIDTH), 0.0f, static_cast<GLfloat>(HEIGHT));
shader.Use();
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
// FreeType
FT_Library ft;
// All functions return a value different than 0 whenever an error occurred
if (FT_Init_FreeType(&ft))
std::cout << "ERROR::FREETYPE: Could not init FreeType Library" << std::endl;
// Load font as face
FT_Face face;
if (FT_New_Face(ft, "fonts/arial.ttf", 0, &face))
std::cout << "ERROR::FREETYPE: Failed to load font" << std::endl;
// Set size to load glyphs as
FT_Set_Pixel_Sizes(face, 0, 48);
// Disable byte-alignment restriction
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// Load first 128 characters of ASCII set
for (GLubyte c = 0; c < 128; c++)
{
// Load character glyph
if (FT_Load_Char(face, c, FT_LOAD_RENDER))
{
std::cout << "ERROR::FREETYTPE: Failed to load Glyph" << std::endl;
continue;
}
// Generate texture
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_RED,
face->glyph->bitmap.width,
face->glyph->bitmap.rows,
0,
GL_RED,
GL_UNSIGNED_BYTE,
face->glyph->bitmap.buffer
);
// Set texture options
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Now store character for later use
Character character = {
texture,
glm::ivec2(face->glyph->bitmap.width, face->glyph->bitmap.rows),
glm::ivec2(face->glyph->bitmap_left, face->glyph->bitmap_top),
face->glyph->advance.x
};
Characters.insert(std::pair<GLchar, Character>(c, character));
}
glBindTexture(GL_TEXTURE_2D, 0);
// Destroy FreeType once we're finished
FT_Done_Face(face);
FT_Done_FreeType(ft);
// Configure VAO/VBO for texture quads
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 4, NULL, GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
// Game loop
while (!glfwWindowShouldClose(window))
{
float currentFrame = glfwGetTime();
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
// Check and call events
glfwPollEvents();
// Clear the colorbuffer
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
if (fps == 0)
fps = 1.0f / deltaTime;
fps = glm::mix(fps, 1.0f / deltaTime, 0.001f);
char fpsstr[20];
sprintf_s(fpsstr, "FPS : %.0f", fps);
RenderText(shader, fpsstr, 25.0f, 570.0f, 0.4f, glm::vec3(0.5, 0.8f, 0.2f));
RenderText(shader, "This is sample text", 25.0f, 25.0f, 1.0f, glm::vec3(0.5, 0.8f, 0.2f));
RenderText(shader, "(C) LearnOpenGL.com", 540.0f, 570.0f, 0.5f, glm::vec3(0.3, 0.7f, 0.9f));
// Swap the buffers
glfwSwapBuffers(window);
}
glfwTerminate();
return 0;
}
void RenderText(Shader &shader, std::string text, GLfloat x, GLfloat y, GLfloat scale, glm::vec3 color)
{
// Activate corresponding render state
shader.Use();
glUniform3f(glGetUniformLocation(shader.Program, "textColor"), color.x, color.y, color.z);
glActiveTexture(GL_TEXTURE0);
glBindVertexArray(VAO);
// Iterate through all characters
std::string::const_iterator c;
for (c = text.begin(); c != text.end(); c++)
{
Character ch = Characters[*c];
GLfloat xpos = x + ch.Bearing.x * scale;
GLfloat ypos = y - (ch.Size.y - ch.Bearing.y) * scale;
GLfloat w = ch.Size.x * scale;
GLfloat h = ch.Size.y * scale;
// Update VBO for each character
GLfloat vertices[6][4] = {
{ xpos, ypos + h, 0.0, 0.0 },
{ xpos, ypos, 0.0, 1.0 },
{ xpos + w, ypos, 1.0, 1.0 },
{ xpos, ypos + h, 0.0, 0.0 },
{ xpos + w, ypos, 1.0, 1.0 },
{ xpos + w, ypos + h, 1.0, 0.0 }
};
// Render glyph texture over quad
glBindTexture(GL_TEXTURE_2D, ch.TextureID);
// Update content of VBO memory
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); // Be sure to use glBufferSubData and not glBufferData
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Render quad
glDrawArrays(GL_TRIANGLES, 0, 6);
// Now advance cursors for next glyph (note that advance is number of 1/64 pixels)
x += (ch.Advance >> 6) * scale; // Bitshift by 6 to get value in pixels (2^6 = 64 (divide amount of 1/64th pixels by 64 to get amount of pixels))
}
glBindVertexArray(0);
glBindTexture(GL_TEXTURE_2D, 0);
} | [
"[email protected]"
] | |
ac5af0386bab4162dbfbc3c098145b4855665d71 | 1c2d23368a2189677094c8ec56ec3a438fa57c4a | /spoj/1837. Pie.cpp | 3e129d7c0d1463de109370c6341533058868f6eb | [] | no_license | mabuelkhair/problemSolving | 27b1c6c9dfb81b8cdb06936c6da6da30d1ac39ba | ef0629003b948443a18d341ffde3f289a3f7f414 | refs/heads/master | 2021-05-27T17:32:44.578871 | 2015-06-02T17:51:45 | 2015-06-02T17:51:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 695 | cpp | #include<bits/stdc++.h>
using namespace std;
double const EPS=1e-6;
int const OO=1e9;
int n,f;
vector<double>v;
bool valid(double sz)
{
int c=0;
for(int i=0;i<v.size();i++)
c+=v[i]/sz;
if(c>=f)
return 1;
return 0;
}
double res=0;
void binarySearch()
{
double start=0,end=100000009*M_PI;
while(end-start>=EPS)
{
double mid = (start+end)/2.0;
if(valid(mid))
{
start=mid;
res=max(res,mid);
}
else
{
end=mid;
}
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
res=0;
scanf("%d%d",&n,&f);
v.clear();
v.resize(n);
f++;
for(int i=0;i<n;i++)
{
int a; scanf("%d",&a);
v[i]=(a*a*M_PI);
}
binarySearch();
printf("%.4lf\n",res);
}
return 0;
}
| [
"[email protected]"
] | |
c0b4dc409099af9c569abffb3cc95eaa0e6cb8f2 | be0282afa8dd436619c71d6118c9db455eaf1a29 | /Intermediate/Build/Win64/Design3D/Inc/Engine/SingleAnimationPlayData.gen.cpp | 69df2a5554d336e061f69c084871c77eb465abb9 | [] | no_license | Quant2017/Design3D | 0f915580b222af40ab911021cceef5c26375d7f9 | 94a22386be4aa37aa0f546354cc62958820a4bf6 | refs/heads/master | 2022-04-23T10:44:12.398772 | 2020-04-22T01:02:39 | 2020-04-22T01:02:39 | 262,966,755 | 1 | 0 | null | 2020-05-11T07:12:37 | 2020-05-11T07:12:36 | null | UTF-8 | C++ | false | false | 11,715 | cpp | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
Generated code exported from UnrealHeaderTool.
DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/
#include "UObject/GeneratedCppIncludes.h"
#include "Engine/Public/SingleAnimationPlayData.h"
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable : 4883)
#endif
PRAGMA_DISABLE_DEPRECATION_WARNINGS
void EmptyLinkFunctionForGeneratedCodeSingleAnimationPlayData() {}
// Cross Module References
ENGINE_API UScriptStruct* Z_Construct_UScriptStruct_FSingleAnimationPlayData();
UPackage* Z_Construct_UPackage__Script_Engine();
ENGINE_API UClass* Z_Construct_UClass_UAnimationAsset_NoRegister();
// End Cross Module References
class UScriptStruct* FSingleAnimationPlayData::StaticStruct()
{
static class UScriptStruct* Singleton = NULL;
if (!Singleton)
{
extern ENGINE_API uint32 Get_Z_Construct_UScriptStruct_FSingleAnimationPlayData_Hash();
Singleton = GetStaticStruct(Z_Construct_UScriptStruct_FSingleAnimationPlayData, Z_Construct_UPackage__Script_Engine(), TEXT("SingleAnimationPlayData"), sizeof(FSingleAnimationPlayData), Get_Z_Construct_UScriptStruct_FSingleAnimationPlayData_Hash());
}
return Singleton;
}
template<> ENGINE_API UScriptStruct* StaticStruct<FSingleAnimationPlayData>()
{
return FSingleAnimationPlayData::StaticStruct();
}
static FCompiledInDeferStruct Z_CompiledInDeferStruct_UScriptStruct_FSingleAnimationPlayData(FSingleAnimationPlayData::StaticStruct, TEXT("/Script/Engine"), TEXT("SingleAnimationPlayData"), false, nullptr, nullptr);
static struct FScriptStruct_Engine_StaticRegisterNativesFSingleAnimationPlayData
{
FScriptStruct_Engine_StaticRegisterNativesFSingleAnimationPlayData()
{
UScriptStruct::DeferCppStructOps(FName(TEXT("SingleAnimationPlayData")),new UScriptStruct::TCppStructOps<FSingleAnimationPlayData>);
}
} ScriptStruct_Engine_StaticRegisterNativesFSingleAnimationPlayData;
struct Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics
{
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam Struct_MetaDataParams[];
#endif
static void* NewStructOps();
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam NewProp_SavedPlayRate_MetaData[];
#endif
static const UE4CodeGen_Private::FFloatPropertyParams NewProp_SavedPlayRate;
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam NewProp_SavedPosition_MetaData[];
#endif
static const UE4CodeGen_Private::FFloatPropertyParams NewProp_SavedPosition;
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam NewProp_bSavedPlaying_MetaData[];
#endif
static void NewProp_bSavedPlaying_SetBit(void* Obj);
static const UE4CodeGen_Private::FBoolPropertyParams NewProp_bSavedPlaying;
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam NewProp_bSavedLooping_MetaData[];
#endif
static void NewProp_bSavedLooping_SetBit(void* Obj);
static const UE4CodeGen_Private::FBoolPropertyParams NewProp_bSavedLooping;
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam NewProp_AnimToPlay_MetaData[];
#endif
static const UE4CodeGen_Private::FObjectPropertyParams NewProp_AnimToPlay;
static const UE4CodeGen_Private::FPropertyParamsBase* const PropPointers[];
static const UE4CodeGen_Private::FStructParams ReturnStructParams;
};
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::Struct_MetaDataParams[] = {
{ "BlueprintType", "true" },
{ "ModuleRelativePath", "Public/SingleAnimationPlayData.h" },
};
#endif
void* Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewStructOps()
{
return (UScriptStruct::ICppStructOps*)new UScriptStruct::TCppStructOps<FSingleAnimationPlayData>();
}
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_SavedPlayRate_MetaData[] = {
{ "Category", "Animation" },
{ "DisplayName", "PlayRate" },
{ "ModuleRelativePath", "Public/SingleAnimationPlayData.h" },
{ "ToolTip", "Default setting for play rate of SequenceToPlay to play." },
};
#endif
const UE4CodeGen_Private::FFloatPropertyParams Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_SavedPlayRate = { "SavedPlayRate", nullptr, (EPropertyFlags)0x0010040000000005, UE4CodeGen_Private::EPropertyGenFlags::Float, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(FSingleAnimationPlayData, SavedPlayRate), METADATA_PARAMS(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_SavedPlayRate_MetaData, ARRAY_COUNT(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_SavedPlayRate_MetaData)) };
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_SavedPosition_MetaData[] = {
{ "Category", "Animation" },
{ "DisplayName", "Initial Position" },
{ "ModuleRelativePath", "Public/SingleAnimationPlayData.h" },
{ "ToolTip", "Default setting for position of SequenceToPlay to play." },
};
#endif
const UE4CodeGen_Private::FFloatPropertyParams Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_SavedPosition = { "SavedPosition", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Float, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(FSingleAnimationPlayData, SavedPosition), METADATA_PARAMS(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_SavedPosition_MetaData, ARRAY_COUNT(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_SavedPosition_MetaData)) };
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedPlaying_MetaData[] = {
{ "Category", "Animation" },
{ "DisplayName", "Playing" },
{ "ModuleRelativePath", "Public/SingleAnimationPlayData.h" },
{ "ToolTip", "Default setting for playing for SequenceToPlay. This is not current state of playing." },
};
#endif
void Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedPlaying_SetBit(void* Obj)
{
((FSingleAnimationPlayData*)Obj)->bSavedPlaying = 1;
}
const UE4CodeGen_Private::FBoolPropertyParams Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedPlaying = { "bSavedPlaying", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Bool , RF_Public|RF_Transient|RF_MarkAsNative, 1, sizeof(uint8), sizeof(FSingleAnimationPlayData), &Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedPlaying_SetBit, METADATA_PARAMS(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedPlaying_MetaData, ARRAY_COUNT(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedPlaying_MetaData)) };
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedLooping_MetaData[] = {
{ "Category", "Animation" },
{ "DisplayName", "Looping" },
{ "ModuleRelativePath", "Public/SingleAnimationPlayData.h" },
{ "ToolTip", "Default setting for looping for SequenceToPlay. This is not current state of looping." },
};
#endif
void Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedLooping_SetBit(void* Obj)
{
((FSingleAnimationPlayData*)Obj)->bSavedLooping = 1;
}
const UE4CodeGen_Private::FBoolPropertyParams Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedLooping = { "bSavedLooping", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Bool , RF_Public|RF_Transient|RF_MarkAsNative, 1, sizeof(uint8), sizeof(FSingleAnimationPlayData), &Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedLooping_SetBit, METADATA_PARAMS(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedLooping_MetaData, ARRAY_COUNT(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedLooping_MetaData)) };
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_AnimToPlay_MetaData[] = {
{ "Category", "Animation" },
{ "ModuleRelativePath", "Public/SingleAnimationPlayData.h" },
{ "ToolTip", "@todo in the future, we should make this one UObject\nand have detail customization to display different things\nThe default sequence to play on this skeletal mesh" },
};
#endif
const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_AnimToPlay = { "AnimToPlay", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(FSingleAnimationPlayData, AnimToPlay), Z_Construct_UClass_UAnimationAsset_NoRegister, METADATA_PARAMS(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_AnimToPlay_MetaData, ARRAY_COUNT(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_AnimToPlay_MetaData)) };
const UE4CodeGen_Private::FPropertyParamsBase* const Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::PropPointers[] = {
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_SavedPlayRate,
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_SavedPosition,
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedPlaying,
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_bSavedLooping,
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::NewProp_AnimToPlay,
};
const UE4CodeGen_Private::FStructParams Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::ReturnStructParams = {
(UObject* (*)())Z_Construct_UPackage__Script_Engine,
nullptr,
&NewStructOps,
"SingleAnimationPlayData",
sizeof(FSingleAnimationPlayData),
alignof(FSingleAnimationPlayData),
Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::PropPointers,
ARRAY_COUNT(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::PropPointers),
RF_Public|RF_Transient|RF_MarkAsNative,
EStructFlags(0x00000001),
METADATA_PARAMS(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::Struct_MetaDataParams, ARRAY_COUNT(Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::Struct_MetaDataParams))
};
UScriptStruct* Z_Construct_UScriptStruct_FSingleAnimationPlayData()
{
#if WITH_HOT_RELOAD
extern uint32 Get_Z_Construct_UScriptStruct_FSingleAnimationPlayData_Hash();
UPackage* Outer = Z_Construct_UPackage__Script_Engine();
static UScriptStruct* ReturnStruct = FindExistingStructIfHotReloadOrDynamic(Outer, TEXT("SingleAnimationPlayData"), sizeof(FSingleAnimationPlayData), Get_Z_Construct_UScriptStruct_FSingleAnimationPlayData_Hash(), false);
#else
static UScriptStruct* ReturnStruct = nullptr;
#endif
if (!ReturnStruct)
{
UE4CodeGen_Private::ConstructUScriptStruct(ReturnStruct, Z_Construct_UScriptStruct_FSingleAnimationPlayData_Statics::ReturnStructParams);
}
return ReturnStruct;
}
uint32 Get_Z_Construct_UScriptStruct_FSingleAnimationPlayData_Hash() { return 448781412U; }
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#ifdef _MSC_VER
#pragma warning (pop)
#endif
| [
"[email protected]"
] | |
eb0603c37111a4422860a55ad33e921d69e43c10 | a1fbf16243026331187b6df903ed4f69e5e8c110 | /cs/sdk/include/boost/lambda/detail/control_structures_impl.hpp | 5a974296162d5d035981555bfe3cdb4ca9d99140 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
] | permissive | OpenXRay/xray-15 | ca0031cf1893616e0c9795c670d5d9f57ca9beff | 1390dfb08ed20997d7e8c95147ea8e8cb71f5e86 | refs/heads/xd_dev | 2023-07-17T23:42:14.693841 | 2021-09-01T23:25:34 | 2021-09-01T23:25:34 | 23,224,089 | 64 | 23 | NOASSERTION | 2019-04-03T17:50:18 | 2014-08-22T12:09:41 | C++ | ISO-8859-1 | C++ | false | false | 16,216 | hpp | // Boost Lambda Library -- control_structures_impl.hpp ---------------------
// Copyright (C) 1999, 2000 Jaakko Järvi ([email protected])
// Copyright (C) 2000 Gary Powell ([email protected])
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// For more information, see www.boost.org
// --------------------------------------------------------------------------
#if !defined(BOOST_LAMBDA_CONTROL_CONSTRUCTS_HPP)
#define BOOST_LAMBDA_CONTROL_CONSTRUCTS_HPP
namespace boost {
namespace lambda {
// -- void return control actions ----------------------
class forloop_action {};
class forloop_no_body_action {};
class ifthen_action {};
class ifthenelse_action {};
class whileloop_action {};
class whileloop_no_body_action {};
class dowhileloop_action {};
class dowhileloop_no_body_action {};
// -- nonvoid return control actions ----------------------
class ifthenelsereturn_action {};
// For loop
template <class Arg1, class Arg2, class Arg3, class Arg4>
inline const
lambda_functor<
lambda_functor_base<
forloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>,
lambda_functor<Arg3>, lambda_functor<Arg4> >
>
>
for_loop(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2,
const lambda_functor<Arg3>& a3, const lambda_functor<Arg4>& a4) {
return
lambda_functor_base<
forloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>,
lambda_functor<Arg3>, lambda_functor<Arg4> >
>
( tuple<lambda_functor<Arg1>, lambda_functor<Arg2>,
lambda_functor<Arg3>, lambda_functor<Arg4> >(a1, a2, a3, a4)
);
}
// No body case.
template <class Arg1, class Arg2, class Arg3>
inline const
lambda_functor<
lambda_functor_base<
forloop_no_body_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>, lambda_functor<Arg3> >
>
>
for_loop(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2,
const lambda_functor<Arg3>& a3) {
return
lambda_functor_base<
forloop_no_body_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>,
lambda_functor<Arg3> >
>
( tuple<lambda_functor<Arg1>, lambda_functor<Arg2>,
lambda_functor<Arg3> >(a1, a2, a3) );
}
// While loop
template <class Arg1, class Arg2>
inline const
lambda_functor<
lambda_functor_base<
whileloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
>
while_loop(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2) {
return
lambda_functor_base<
whileloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
( tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >(a1, a2));
}
// No body case.
template <class Arg1>
inline const
lambda_functor<
lambda_functor_base<
whileloop_no_body_action,
tuple<lambda_functor<Arg1> >
>
>
while_loop(const lambda_functor<Arg1>& a1) {
return
lambda_functor_base<
whileloop_no_body_action,
tuple<lambda_functor<Arg1> >
>
( tuple<lambda_functor<Arg1> >(a1) );
}
// Do While loop
template <class Arg1, class Arg2>
inline const
lambda_functor<
lambda_functor_base<
dowhileloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
>
do_while_loop(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2) {
return
lambda_functor_base<
dowhileloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
( tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >(a1, a2));
}
// No body case.
template <class Arg1>
inline const
lambda_functor<
lambda_functor_base<
dowhileloop_no_body_action,
tuple<lambda_functor<Arg1> >
>
>
do_while_loop(const lambda_functor<Arg1>& a1) {
return
lambda_functor_base<
dowhileloop_no_body_action,
tuple<lambda_functor<Arg1> >
>
( tuple<lambda_functor<Arg1> >(a1));
}
// If Then
template <class Arg1, class Arg2>
inline const
lambda_functor<
lambda_functor_base<
ifthen_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
>
if_then(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2) {
return
lambda_functor_base<
ifthen_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
( tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >(a1, a2) );
}
// If then else
template <class Arg1, class Arg2, class Arg3>
inline const
lambda_functor<
lambda_functor_base<
ifthenelse_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>, lambda_functor<Arg3> >
>
>
if_then_else(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2,
const lambda_functor<Arg3>& a3) {
return
lambda_functor_base<
ifthenelse_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>, lambda_functor<Arg3> >
>
(tuple<lambda_functor<Arg1>, lambda_functor<Arg2>, lambda_functor<Arg3> >
(a1, a2, a3) );
}
// Our version of operator?:()
template <class Arg1, class Arg2, class Arg3>
inline const
lambda_functor<
lambda_functor_base<
other_action<ifthenelsereturn_action>,
tuple<lambda_functor<Arg1>,
typename const_copy_argument<Arg2>::type,
typename const_copy_argument<Arg3>::type>
>
>
if_then_else_return(const lambda_functor<Arg1>& a1,
const Arg2 & a2,
const Arg3 & a3) {
return
lambda_functor_base<
other_action<ifthenelsereturn_action>,
tuple<lambda_functor<Arg1>,
typename const_copy_argument<Arg2>::type,
typename const_copy_argument<Arg3>::type>
> ( tuple<lambda_functor<Arg1>,
typename const_copy_argument<Arg2>::type,
typename const_copy_argument<Arg3>::type> (a1, a2, a3) );
}
namespace detail {
// return type specialization for conditional expression begins -----------
// start reading below and move upwards
// PHASE 6:1
// check if A is conbertible to B and B to A
template<int Phase, bool AtoB, bool BtoA, bool SameType, class A, class B>
struct return_type_2_ifthenelsereturn;
// if A can be converted to B and vice versa -> ambiguous
template<int Phase, class A, class B>
struct return_type_2_ifthenelsereturn<Phase, true, true, false, A, B> {
typedef
detail::return_type_deduction_failure<return_type_2_ifthenelsereturn> type;
// ambiguous type in conditional expression
};
// if A can be converted to B and vice versa and are of same type
template<int Phase, class A, class B>
struct return_type_2_ifthenelsereturn<Phase, true, true, true, A, B> {
typedef A type;
};
// A can be converted to B
template<int Phase, class A, class B>
struct return_type_2_ifthenelsereturn<Phase, true, false, false, A, B> {
typedef B type;
};
// B can be converted to A
template<int Phase, class A, class B>
struct return_type_2_ifthenelsereturn<Phase, false, true, false, A, B> {
typedef A type;
};
// neither can be converted. Then we drop the potential references, and
// try again
template<class A, class B>
struct return_type_2_ifthenelsereturn<1, false, false, false, A, B> {
// it is safe to add const, since the result will be an rvalue and thus
// const anyway. The const are needed eg. if the types
// are 'const int*' and 'void *'. The remaining type should be 'const void*'
typedef const typename boost::remove_reference<A>::type plainA;
typedef const typename boost::remove_reference<B>::type plainB;
// TODO: Add support for volatile ?
typedef typename
return_type_2_ifthenelsereturn<
2,
boost::is_convertible<plainA,plainB>::value,
boost::is_convertible<plainB,plainA>::value,
boost::is_same<plainA,plainB>::value,
plainA,
plainB>::type type;
};
// PHASE 6:2
template<class A, class B>
struct return_type_2_ifthenelsereturn<2, false, false, false, A, B> {
typedef
detail::return_type_deduction_failure<return_type_2_ifthenelsereturn> type;
// types_do_not_match_in_conditional_expression
};
// PHASE 5: now we know that types are not arithmetic.
template<class A, class B>
struct non_numeric_types {
typedef typename
return_type_2_ifthenelsereturn<
1, // phase 1
is_convertible<A,B>::value,
is_convertible<B,A>::value,
is_same<A,B>::value,
A,
B>::type type;
};
// PHASE 4 :
// the base case covers arithmetic types with differing promote codes
// use the type deduction of arithmetic_actions
template<int CodeA, int CodeB, class A, class B>
struct arithmetic_or_not {
typedef typename
return_type_2<arithmetic_action<plus_action>, A, B>::type type;
// plus_action is just a random pick, has to be a concrete instance
};
// this case covers the case of artihmetic types with the same promote codes.
// non numeric deduction is used since e.g. integral promotion is not
// performed with operator ?:
template<int CodeA, class A, class B>
struct arithmetic_or_not<CodeA, CodeA, A, B> {
typedef typename non_numeric_types<A, B>::type type;
};
// if either A or B has promote code -1 it is not an arithmetic type
template<class A, class B>
struct arithmetic_or_not <-1, -1, A, B> {
typedef typename non_numeric_types<A, B>::type type;
};
template<int CodeB, class A, class B>
struct arithmetic_or_not <-1, CodeB, A, B> {
typedef typename non_numeric_types<A, B>::type type;
};
template<int CodeA, class A, class B>
struct arithmetic_or_not <CodeA, -1, A, B> {
typedef typename non_numeric_types<A, B>::type type;
};
// PHASE 3 : Are the types same?
// No, check if they are arithmetic or not
template <class A, class B>
struct same_or_not {
typedef typename detail::remove_reference_and_cv<A>::type plainA;
typedef typename detail::remove_reference_and_cv<B>::type plainB;
typedef typename
arithmetic_or_not<
detail::promote_code<plainA>::value,
detail::promote_code<plainB>::value,
A,
B>::type type;
};
// Yes, clear.
template <class A> struct same_or_not<A, A> {
typedef A type;
};
} // detail
// PHASE 2 : Perform first the potential array_to_pointer conversion
template<class A, class B>
struct return_type_2<other_action<ifthenelsereturn_action>, A, B> {
typedef typename detail::array_to_pointer<A>::type A1;
typedef typename detail::array_to_pointer<B>::type B1;
typedef typename
boost::add_const<typename detail::same_or_not<A1, B1>::type>::type type;
};
// PHASE 1 : Deduction is based on the second and third operand
// return type specialization for conditional expression ends -----------
// Control loop lambda_functor_base specializations.
// Specialization for for_loop.
template<class Args>
class
lambda_functor_base<forloop_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
for(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS))
detail::select(boost::tuples::get<3>(args), CALL_ACTUAL_ARGS);
}
};
// No body case
template<class Args>
class
lambda_functor_base<forloop_no_body_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
for(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS)) {}
}
};
// Specialization for while_loop.
template<class Args>
class
lambda_functor_base<whileloop_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
while(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS))
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
}
};
// No body case
template<class Args>
class
lambda_functor_base<whileloop_no_body_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
while(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) {}
}
};
// Specialization for do_while_loop.
// Note that the first argument is the condition.
template<class Args>
class
lambda_functor_base<dowhileloop_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
do {
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
} while (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS) );
}
};
// No body case
template<class Args>
class
lambda_functor_base<dowhileloop_no_body_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
do {} while (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS) );
}
};
// Specialization for if_then.
template<class Args>
class
lambda_functor_base<ifthen_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
if (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
}
};
// Specialization for if_then_else.
template<class Args>
class
lambda_functor_base<ifthenelse_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
if (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS))
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
else
detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS);
}
};
// Specialization of lambda_functor_base for if_then_else_return.
template<class Args>
class
lambda_functor_base<other_action<ifthenelsereturn_action>, Args> {
public:
Args args;
template <class SigArgs> struct sig {
private:
typedef typename detail::nth_return_type_sig<1, Args, SigArgs>::type ret1;
typedef typename detail::nth_return_type_sig<2, Args, SigArgs>::type ret2;
public:
typedef typename return_type_2<
other_action<ifthenelsereturn_action>, ret1, ret2
>::type type;
};
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
return (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) ?
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS)
:
detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS);
}
};
} // lambda
} // boost
#endif // BOOST_LAMBDA_CONTROL_CONSTRUCTS_HPP
| [
"[email protected]"
] | |
28caa594da77562cd3afa6fc108b13cd3b679e5c | b262108a7d7f4294b29ffb4b3327c03ee4715e21 | /NachenBlaster/Actor.cpp | da5352939cc9422a7295d01200f87d48377c51a1 | [] | no_license | jackvanb/NachenBlaster | f34c9a05116074a6d9e8ed5327ca445aef4a3bd8 | b8cf318bb9d67965c7dccc1a120409daac1b9f67 | refs/heads/master | 2021-04-15T17:07:40.464066 | 2018-08-24T02:29:24 | 2018-08-24T02:29:24 | 126,879,258 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,981 | cpp | #include "Actor.h"
#include "StudentWorld.h"
#include <cmath>
// Students: Add code to this file, Actor.h, StudentWorld.h, and StudentWorld.cpp
// STAR CONSTANTS
const double STAR_MIN_SIZE = 5;
const double STAR_MAX_SIZE = 50;
const int STAR_DEPTH = 3;
// NACHENBLASTER CONSTANS
const double NACHENBLASTER_SIZE = 1.0;
const int NACHENBLASTER_DEPTH = 0;
const int CABBAGE_ENERGY_MAX = 30;
const int PLAYER_HP_MAX = 50;
// FLIGHT PLANS
const int DUE_LEFT = 1;
const int UP_AND_LEFT = 2;
const int DOWN_AND_LEFT = 3;
//////////// Helper Functions ////////////////////
bool hasCollidedWithActor(Actor* a1, Actor* a2)
{
double x = a1->getX() - a2->getX();
double y = a1->getY() - a2->getY();
double dist;
dist = pow(x, 2) + pow(y, 2);
dist = sqrt(dist);
// Eucledian Distance Between Two Actors
if (dist < (.75 * (a1->getRadius() + a2->getRadius())))
return true;
else
return false;
}
/////////////////// ACTOR /////////////////////
Actor::Actor(int ID, double x, double y, int dir, double size, int depth, StudentWorld* world)
: GraphObject(ID, x, y, dir, size, depth)
{
m_ID = ID;
m_x = x;
m_y = y;
m_dir = dir;
m_size = size;
m_depth = depth;
m_dead = false;
m_world = world;
}
void Actor::moveToIfAble(double x, double y)
{
if (x < 0 || x >= VIEW_WIDTH || y < 0 || y >= VIEW_HEIGHT) // Out of View
return;
else
moveTo(x, y);
}
/////////////////// DAMAGEABLE OBJECT /////////////////////
DamageableObject::DamageableObject(int ID, double x, double y, int dir, double size, int depth, StudentWorld* world, double hitPoints)
: Actor(ID, x, y, dir, size, depth, world)
{
m_hitPoints = hitPoints;
}
/////////////////// NACHENBLASTER /////////////////////
NachenBlaster::NachenBlaster(StudentWorld* world)
: DamageableObject(IID_NACHENBLASTER, 0, 128, 0, NACHENBLASTER_SIZE, NACHENBLASTER_DEPTH, world, PLAYER_HP_MAX)
{
m_cabbageEnergy = CABBAGE_ENERGY_MAX;
m_torpedos = 0;
}
void NachenBlaster::increaseHitPoints(double amt)
{
if (( hitPoints() + amt ) > PLAYER_HP_MAX)
setHitPoints(PLAYER_HP_MAX);
else
DamageableObject::increaseHitPoints(amt);
}
void NachenBlaster::sufferDamage(double amt, int cause)
{
if (cause == HIT_BY_SHIP)
{
decreaseHitPoints(amt);
}
if (cause == HIT_BY_PROJECTILE)
{
decreaseHitPoints(amt);
getWorld()->playSound(SOUND_BLAST);
}
if (hitPoints() <= 0)
die();
}
void NachenBlaster::doSomething()
{
if (isDead())
return;
int ch;
if (getWorld()->getKey(ch))
{
switch (ch) {
case KEY_PRESS_LEFT:
{
moveToIfAble(getX() - 6, getY());
break;
}
case KEY_PRESS_RIGHT:
{
moveToIfAble(getX() + 6, getY());
break;
}
case KEY_PRESS_UP:
{
moveToIfAble(getX(), getY() + 6);
break;
}
case KEY_PRESS_DOWN:
{
moveToIfAble(getX(), getY() - 6);
break;
}
case KEY_PRESS_SPACE:
{
if (m_cabbageEnergy > 5)
{
getWorld()->addActor(new Cabbage(getX() + 12, getY(), getWorld()));
getWorld()->playSound(SOUND_PLAYER_SHOOT);
m_cabbageEnergy -= 5;
}
break;
}
case KEY_PRESS_TAB:
{
if (m_torpedos > 0)
{
getWorld()->addActor(new PlayerFiredTorpedo(getX() + 12, getY(), getWorld()));
m_torpedos--;
getWorld()->playSound(SOUND_TORPEDO);
}
break;
}
default:
break;
}
}
if (m_cabbageEnergy < 30)
m_cabbageEnergy++;
}
/////////////////// ALIEN /////////////////////
Alien::Alien(int ID, double x, double y, StudentWorld* world,
double hitPoints, double damageAmt, double deltaX,
double deltaY, double speed, unsigned int scoreValue)
: DamageableObject(ID, x, y, 0, 1.5, 1, world, hitPoints)
{
m_damageAmt = damageAmt;
m_deltaX = deltaX;
m_deltaY = deltaY;
m_speed = speed;
m_scoreValue = scoreValue;
}
void Alien::die()
{
Actor::die();
getWorld()->shipOffScreen();
}
void Alien::doSomething()
{
// CHECK TO SEE IF DEAD OR OUT OF VIEW
if (isDead())
return;
if (outOfView())
{
die();
return;
}
}
void Alien::sufferDamage(double amt, int cause)
{
decreaseHitPoints(amt);
if (hitPoints() <= 0 || cause == HIT_BY_SHIP)
{
getWorld()->increaseScore(getScoreValue());
die();
getWorld()->shipDestroyed();
getWorld()->playSound(SOUND_DEATH);
getWorld()->addActor(new Explosion(getX(), getY(), getWorld()));
possiblyDropGoodie();
}
else
getWorld()->playSound(SOUND_BLAST);
}
void Alien::collidesWithPlayer()
{
getWorld()->getPlayer()->sufferDamage(getDamageAmt(), HIT_BY_SHIP);
sufferDamage(hitPoints(), HIT_BY_SHIP);
}
bool Alien::playerNear()
{
double playerX;
double playerY;
getWorld()->getPlayerLocation(playerX, playerY);
if (playerX < getX()) {
if (playerY - getY() <= 4 && playerY - getY() >= -4) {
return true;
}
}
return false;
}
void Alien::newFlightPlan()
{
if (getY() >= VIEW_HEIGHT - 1)
{
// Up and Left
setDeltaX(getSpeed() * -1);
setDeltaY(getSpeed() * -1);
}
else if (getY() <= 0)
{
// Down and Left
setDeltaX(getSpeed() * -1);
setDeltaY(getSpeed());
}
else
{
int x = randInt(1, 3);
switch(x)
{
case DUE_LEFT:
{
setDeltaX(getSpeed() * -1);
setDeltaY(0);
break;
}
case DOWN_AND_LEFT:
{
setDeltaX(getSpeed() * -1);
setDeltaY(getSpeed());
break;
}
case UP_AND_LEFT:
{
setDeltaX(getSpeed() * -1);
setDeltaY(getSpeed() * -1);
break;
}
}
}
}
/////////////////// SMALLGON /////////////////////
Smallgon::Smallgon(double x, double y, StudentWorld* world)
: Alien(IID_SMALLGON, x, y, world, 5, 5, 0, 0, 2.0, 250)
{
m_flightPlanLength = 0;
setHitPoints(5 * (1 + (getWorld()->getLevel() - 1) * 0.1));
}
void Smallgon::possiblyDropGoodie()
{
// Smallgon's can't drop goodies
return;
}
void Smallgon::doSomething()
{
Alien::doSomething();
// CHECK TO SEE IF COLLIDED WITH NACHENBLASTER
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
collidesWithPlayer();
// FLIGHT PLAN
if (m_flightPlanLength == 0 || getY() >= VIEW_HEIGHT - 1 || getY() <= 0)
{
newFlightPlan();
m_flightPlanLength = randInt(1, 32);
}
// Check to see NachenBlaster Location
if (playerNear())
{
int rand = randInt(1, 20/(getWorld()->getLevel())+5);
if (rand == 1)
{
getWorld()->addActor(new Turnip(getX() + 14, getY(), getWorld()));
getWorld()->playSound(SOUND_ALIEN_SHOOT);
return;
}
}
// CHOOSE NEW FLIGTH PLAN
move();
m_flightPlanLength--;
// CHECK AGAIN
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
collidesWithPlayer();
}
/////////////////// SMOREGON /////////////////////
Smoregon::Smoregon(double x, double y, StudentWorld* world)
: Alien(IID_SMOREGON, x, y, world, 5, 5, 0, 0, 2.0, 250)
{
m_flightPlanLength = 0;
setHitPoints(5 * (1 + (getWorld()->getLevel() - 1) * 0.1));
}
void Smoregon::possiblyDropGoodie()
{
int rand = randInt(1, 3);
if (rand == 1)
{
int rand1 = randInt(1, 2);
if (rand1 == 1)
getWorld()->addActor(new RepairGoodie(getX(), getY(), getWorld()));
else
getWorld()->addActor(new TorpedoGoodie(getX(), getY(), getWorld()));
}
}
void Smoregon::doSomething()
{
Alien::doSomething();
// CHECK TO SEE IF COLLIDED WITH NACHENBLASTER
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
collidesWithPlayer();
//FLIGHT PLAN
if (m_flightPlanLength == 0 || getY() >= VIEW_HEIGHT - 1 || getY() <= 0)
{
newFlightPlan();
m_flightPlanLength = randInt(1, 32);
}
// Check to see NachenBlaster Location
if (playerNear())
{
int rand = randInt(1, 20/(getWorld()->getLevel())+5);
int rand1 = randInt(1, 20/(getWorld()->getLevel())+5);
if (rand == 1)
{
getWorld()->addActor(new Turnip(getX() + 14, getY(), getWorld()));
getWorld()->playSound(SOUND_ALIEN_SHOOT);
return;
}
if (rand1 == 1)
{
// Set location to due left
setDeltaX(getSpeed() * -1);
setDeltaY(0);
m_flightPlanLength = VIEW_WIDTH;
setSpeed(5.0);
}
}
//CHOSE NEW FLIGHT PLAN
move();
m_flightPlanLength--;
// CHECK AGAIN
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
collidesWithPlayer();
}
/////////////////// SNAGGLEGON /////////////////////
Snagglegon::Snagglegon(double x, double y, StudentWorld* world)
: Alien(IID_SNAGGLEGON, x, y, world, 10, 15, -1.75, 1.75, 1.75, 1000)
{
setHitPoints(10 * (1 + (getWorld()->getLevel() - 1) * 0.1));
}
void Snagglegon::possiblyDropGoodie()
{
int rand = randInt(1, 6);
if (rand == 1)
{
getWorld()->addActor(new ExtraLifeGoodie(getX(), getY(), getWorld()));
}
}
void Snagglegon::doSomething()
{
Alien::doSomething();
if (getY() >= VIEW_HEIGHT - 1 || getY() <= 0)
{
newFlightPlan();
}
// CHECK TO SEE IF COLLIDED WITH NACHENBLASTER
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
collidesWithPlayer();
// Check to see NachenBlaster Location
if (playerNear())
{
int rand = randInt(1, 15 /(getWorld()->getLevel())+10);
if (rand == 1)
{
getWorld()->addActor(new AlienFiredTorpedo(getX() + 14, getY(), getWorld()));
getWorld()->playSound(SOUND_TORPEDO);
return;
}
}
move();
// CHECK AGAIN
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
collidesWithPlayer();
}
/////////////////// STAR /////////////////////
Star::Star(StudentWorld* world)
: Actor(IID_STAR, randInt(0, VIEW_WIDTH-1), randInt(0, VIEW_HEIGHT-1), 0, randInt(STAR_MIN_SIZE, STAR_MAX_SIZE) / 100.0, STAR_DEPTH, world)
{
}
void Star::doSomething()
{
moveTo(getX() - 1, getY());
if (getX() <= -1)
die();
}
/////////////////// EXPLOSION /////////////////////
Explosion::Explosion(double x_cord, double y_cord, StudentWorld* world)
: Actor(IID_EXPLOSION, x_cord, y_cord, 0, 1, 0, world)
{
m_tickCount = 0;
}
void Explosion::doSomething()
{
setSize(getSize() * 1.5);
m_tickCount++;
if (m_tickCount >= 4)
{
m_tickCount = 0;
die();
}
}
/////////////////// PROJECTILE /////////////////////
Projectile::Projectile(int ID, double x_cord, double y_cord, StudentWorld* world)
: Actor(ID, x_cord, y_cord, 0, 0.5, 1, world)
{
}
/////////////////// CABBAGE /////////////////////
Cabbage::Cabbage(double x_cord, double y_cord, StudentWorld* world)
: Projectile(IID_CABBAGE, x_cord, y_cord, world)
{
}
void Cabbage::doSomething()
{
if (isDead())
return;
if (getX() >= VIEW_WIDTH)
{
die();
return;
}
// Check Collison
Actor* alien = getWorld()->hitAlien(this);
if (alien != nullptr)
{
alien->sufferDamage(2, HIT_BY_PROJECTILE);
die();
return;
}
moveTo(getX() + 8 , getY());
setDirection(getDirection() + 20);
// Check Collison
Actor* alien1 = getWorld()->hitAlien(this);
if (alien1 != nullptr)
{
alien1->sufferDamage(2, HIT_BY_PROJECTILE);
die();
return;
}
}
/////////////////// TURNIP /////////////////////
Turnip::Turnip(double x_cord, double y_cord, StudentWorld* world)
: Projectile(IID_TURNIP, x_cord, y_cord, world)
{
}
void Turnip::doSomething()
{
if (isDead())
return;
if (getX() < 0)
{
die();
return;
}
// CHECK TO SEE IF COLLIDED WITH NACHENBLASTER
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
{
getWorld()->getPlayer()->sufferDamage(2, HIT_BY_PROJECTILE);
die();
return;
}
moveTo(getX() - 6 , getY());
setDirection(getDirection() + 20);
// Check Again
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
{
getWorld()->getPlayer()->sufferDamage(2, HIT_BY_PROJECTILE);
die();
return;
}
}
/////////////////// TORPEDO /////////////////////
Torpedo::Torpedo(double x_cord, double y_cord, StudentWorld* world)
: Projectile(IID_TORPEDO, x_cord, y_cord, world)
{
}
void Torpedo::doSomething()
{
if (isDead())
return;
if (getX() < 0 || getX() >= VIEW_WIDTH)
{
die();
return;
}
// Rest implemented in specifc torpedos
}
/////////////////// PLAYER FIRED TORPEDO /////////////////////
PlayerFiredTorpedo::PlayerFiredTorpedo(double x_cord, double y_cord, StudentWorld* world)
: Torpedo(x_cord, y_cord, world)
{
}
void PlayerFiredTorpedo::doSomething()
{
Torpedo::doSomething();
// Check Collison
Actor* alien = getWorld()->hitAlien(this);
if (alien != nullptr)
{
alien->sufferDamage(8, HIT_BY_PROJECTILE);
die();
return;
}
moveTo(getX() + 8 , getY());
// Check Collison AGAIN
Actor* alien1 = getWorld()->hitAlien(this);
if (alien1 != nullptr)
{
alien1->sufferDamage(8, HIT_BY_PROJECTILE);
die();
return;
}
}
/////////////////// ALIEN FIRED TORPEDO /////////////////////
AlienFiredTorpedo::AlienFiredTorpedo(double x_cord, double y_cord, StudentWorld* world)
: Torpedo(x_cord, y_cord, world)
{
}
void AlienFiredTorpedo::doSomething()
{
Torpedo::doSomething();
//CHECK IF HIT PLAYER
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
{
getWorld()->getPlayer()->sufferDamage(8, HIT_BY_PROJECTILE);
die();
return;
}
moveTo(getX() - 8 , getY());
//AGAIN
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
{
getWorld()->getPlayer()->sufferDamage(8, HIT_BY_PROJECTILE);
die();
return;
}
}
/////////////////// GOODIE /////////////////////
Goodie::Goodie(int ID, double x_cord, double y_cord, StudentWorld* world)
: Actor(ID, x_cord, y_cord, 0, 0.5, 1, world)
{
}
void Goodie::collidedWithPlayer()
{
getWorld()->increaseScore(100);
die();
getWorld()->playSound(SOUND_GOODIE);
specificGoodieAction();
}
void Goodie::doSomething()
{
if (isDead())
return;
if (getX() < 0 || getX() >= VIEW_WIDTH)
{
die();
return;
}
// CHECK
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
{
collidedWithPlayer();
return;
}
goodieMove();
// CHECK AGAIN
if (hasCollidedWithActor(this, getWorld()->getPlayer()))
{
collidedWithPlayer();
return;
}
}
/////////////////// EXTRA LIFE GOODIE /////////////////////
ExtraLifeGoodie::ExtraLifeGoodie(double x_cord, double y_cord, StudentWorld* world)
: Goodie(IID_LIFE_GOODIE, x_cord, y_cord, world)
{
}
void ExtraLifeGoodie::specificGoodieAction()
{
getWorld()->incLives();
}
/////////////////// REPAIR GOODIE /////////////////////
RepairGoodie::RepairGoodie(double x_cord, double y_cord, StudentWorld* world)
: Goodie(IID_REPAIR_GOODIE, x_cord, y_cord, world)
{
}
void RepairGoodie::specificGoodieAction()
{
getWorld()->getPlayer()->increaseHitPoints(10);
}
/////////////////// TORPEDO GOODIE /////////////////////
TorpedoGoodie::TorpedoGoodie(double x_cord, double y_cord, StudentWorld* world)
: Goodie(IID_TORPEDO_GOODIE, x_cord, y_cord, world)
{
}
void TorpedoGoodie::specificGoodieAction()
{
getWorld()->getPlayer()->addTorpedos();
}
| [
"[email protected]"
] | |
c893901a1888cd02a4787d754f0c96fd292fe919 | f7ace99e3f15df3a58aae465361033497dd85ea4 | /lab2/StatusDisplay.ino/StatusDisplay.ino.ino | b674d8fc41aecebce03e8ff66c7a774743bceeaa | [] | no_license | matt5200/ee_474 | 05615b475a0d5431bf8e4b1f8a6526ff1e3c1977 | d7e826600c799c53e243f8ef990118554cdc3082 | refs/heads/master | 2020-03-30T04:41:27.597832 | 2018-12-09T02:29:32 | 2018-12-09T02:29:32 | 150,756,807 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 717 | ino | #include <TFT.h>
typedef struct consoleDisplayData{
unsigned short *nothing;
unsigned short *batteryLevel;
float fuelLevel;
// unsigned short *batteryLevel;
unsigned short *powerConsumption;
unsigned short *powerGeneration;
bool *fuelLow;
bool *batteryLow;
bool *solarPanelState;
} consoleDisplayData;
typedef struct warningAlarmData{
unsigned short *nothing;
float *fuelLevel;
unsigned short *batteryLevel;
bool *fuelLow;
bool *batteryLow;
} warningAlarmData;
typedef struct powerSubsystemData {
unsigned short *nothing;
bool* solarPanelState;
unsigned short* batteryLevel;
unsigned short* powerConsumption;
unsigned short* powerGeneration;
} powerSubsystemData;
| [
"[email protected]"
] | |
177be23b5419d869be93a42e7ea573130f563bb1 | be44d239aa01c3fc3582a0c9aa3babc3c94eac34 | /AdimSample.cpp | d4591ddebbdad63881d0353b1268e9b156c066be | [] | no_license | nishio-dens/Adim-mfc | ca4cca1310b18aea6335734b0839e092f4361edf | a33159015075f8e669be9a59cc87603933a12674 | refs/heads/master | 2016-09-02T04:21:02.505421 | 2012-10-29T14:54:17 | 2012-10-29T14:54:17 | 6,442,207 | 0 | 1 | null | null | null | null | SHIFT_JIS | C++ | false | false | 4,405 | cpp | // AdimSample.cpp : アプリケーションのクラス動作を定義します。
//
#include "stdafx.h"
#include "AdimSample.h"
#include "MainFrm.h"
#include "AdimSampleDoc.h"
#include "AdimSampleView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CAdimSampleApp
BEGIN_MESSAGE_MAP(CAdimSampleApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// 標準のファイル基本ドキュメント コマンド
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
// CAdimSampleApp コンストラクション
CAdimSampleApp::CAdimSampleApp()
{
// TODO: この位置に構築用コードを追加してください。
// ここに InitInstance 中の重要な初期化処理をすべて記述してください。
}
// 唯一の CAdimSampleApp オブジェクトです。
CAdimSampleApp theApp;
// CAdimSampleApp 初期化
BOOL CAdimSampleApp::InitInstance()
{
// アプリケーション マニフェストが visual スタイルを有効にするために、
// ComCtl32.dll バージョン 6 以降の使用を指定する場合は、
// Windows XP に InitCommonControls() が必要です。さもなければ、ウィンドウ作成はすべて失敗します。
InitCommonControls();
CWinApp::InitInstance();
// OLE ライブラリを初期化します。
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 標準初期化
// これらの機能を使わずに、最終的な実行可能ファイルのサイズを縮小したい場合は、
// 以下から、不要な初期化ルーチンを
// 削除してください。
// 設定が格納されているレジストリ キーを変更します。
// TODO: この文字列を、会社名または組織名などの、
// 適切な文字列に変更してください。
SetRegistryKey(_T("アプリケーション ウィザードで生成されたローカル アプリケーション"));
LoadStdProfileSettings(0); // 標準の INI ファイルのオプションをロードします (MRU を含む)
// アプリケーション用のドキュメント テンプレートを登録します。ドキュメント テンプレート
// はドキュメント、フレーム ウィンドウとビューを結合するために機能します。
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CAdimSampleDoc),
RUNTIME_CLASS(CMainFrame), // メイン SDI フレーム ウィンドウ
RUNTIME_CLASS(CAdimSampleView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// DDE、file open など標準のシェル コマンドのコマンドラインを解析します。
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// コマンド ラインで指定されたディスパッチ コマンドです。アプリケーションが
// /RegServer、/Register、/Unregserver または /Unregister で起動された場合、 False を返します。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// メイン ウィンドウが初期化されたので、表示と更新を行います。
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
// 接尾辞が存在する場合にのみ DragAcceptFiles を呼び出してください。
// SDI アプリケーションでは、ProcessShellCommand の直後にこの呼び出しが発生しなければなりません。
return TRUE;
}
// アプリケーションのバージョン情報に使われる CAboutDlg ダイアログ
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// ダイアログ データ
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV サポート
// 実装
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// ダイアログを実行するためのアプリケーション コマンド
void CAdimSampleApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// CAdimSampleApp メッセージ ハンドラ
| [
"[email protected]"
] | |
ef00588e1e5afa37f904b1880191d5fd377c2faf | c92c222f13674f0c7284849ed3393b124127f14b | /Practice1/Sources/Filters/SharpFilter.cpp | 758d10630baae8b9081ec9ab1286b5eb3de83b43 | [] | no_license | BFDestroyeer/cg-practice | 033826c49166b580acd9f9874dff89b8e29b426b | e930a7f562a20f3785de2b270a5b80b15679dfb0 | refs/heads/master | 2022-08-20T04:39:33.759286 | 2020-05-25T06:55:49 | 2020-05-25T06:55:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 152 | cpp | #include "SharpFilter.h"
SharpFilter::SharpFilter(int radius_) : MatrixFilter(radius_)
{
vector = new float[9]{ 0, -1, 0, -1, 5, -1, 0, -1, 0 };
} | [
"[email protected]"
] | |
1d1c9158f2d903c335c6dc0750311685604adf7b | c51febc209233a9160f41913d895415704d2391f | /library/ATF/_LINKKEYDetail.hpp | 02499b6a38c63a8065feb4d402a31fb90d3da092 | [
"MIT"
] | permissive | roussukke/Yorozuya | 81f81e5e759ecae02c793e65d6c3acc504091bc3 | d9a44592b0714da1aebf492b64fdcb3fa072afe5 | refs/heads/master | 2023-07-08T03:23:00.584855 | 2023-06-29T08:20:25 | 2023-06-29T08:20:25 | 463,330,454 | 0 | 0 | MIT | 2022-02-24T23:15:01 | 2022-02-24T23:15:00 | null | UTF-8 | C++ | false | false | 340 | hpp | // This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
#include <_LINKKEYInfo.hpp>
START_ATF_NAMESPACE
namespace Detail
{
extern ::std::array<hook_record, 7> _LINKKEY_functions;
}; // end namespace Detail
END_ATF_NAMESPACE
| [
"[email protected]"
] | |
617d91757c4044108aea71c48580726768ed6b81 | 1520e1acf91ad3b61ff1c7c72df3091ec59183ce | /src/kernels/add_test.cpp | ae8158b782e234f18d660414aa9e3ae4d66446b9 | [] | no_license | rayglover-ibm/cuda-bindings | 39cbc51385f4d3a7d1de9b9f85f1806eb09b11c3 | 7d9f2f1f2f15cec7ec7b1d5882dc2a2cbfb646cd | refs/heads/master | 2020-05-24T16:11:56.052154 | 2017-03-28T19:57:46 | 2017-03-28T19:57:46 | 84,856,586 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,476 | cpp | /* Copyright 2017 International Business Machines Corporation
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 "gtest/gtest.h"
#include "mwe.h"
#include "mwe_config.h"
#include <array>
#include <vector>
#include <thread>
using std::array;
TEST(mwe, add)
{
auto c = mwe::add(5, 4);
EXPECT_EQ(c, 9);
}
TEST(mwe, add_span)
{
array<int, 6> a{ 1, 2, 3, 4, 5, 6 };
array<int, 6> b{ 7, 8, 9, 10, 11, 12 };
array<int, 6> c;
mwe::add(a, b, c);
array<int, 6> d{ 8, 10, 12, 14, 16, 18 };
EXPECT_EQ(c, d);
}
TEST(mwe, add_span_multithreaded)
{
const uint32_t M = 1024000;
std::vector<int> a(M, 7);
std::vector<int> b(M, 21);
auto fn = [&](int)
{
std::vector<int> c(M, 0);
mwe::add(a, b, c);
for (int x : c) EXPECT_EQ(x, 7 + 21);
};
const uint32_t N = 4;
std::thread t[N];
for (int i = 0; i < N; ++i)
t[i] = std::thread(fn, i);
for (int i = 0; i < N; ++i)
t[i].join();
}
| [
"[email protected]"
] | |
10f2525ea4a6a49aee78f0f61293ba687ccddc16 | 23d76b4de78ccc4fdd664733ea818f0c95a6e897 | /wpilibNewCommands/src/main/native/cpp/frc2/command/Commands.cpp | f3c47765322f632a7e72b76f50d1a33f6825a1e3 | [
"BSD-3-Clause"
] | permissive | calcmogul/allwpilib | da43cbf8a4caabc363e8fa7689d92938b003f333 | a750bee54df236e21bca45a2c4a4c8f80b279b98 | refs/heads/main | 2023-09-01T15:55:17.288910 | 2023-09-01T05:52:18 | 2023-09-01T05:52:18 | 58,856,085 | 2 | 9 | NOASSERTION | 2022-10-04T06:27:33 | 2016-05-15T10:31:54 | C++ | UTF-8 | C++ | false | false | 4,464 | cpp | // Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc2/command/Commands.h"
#include "frc2/command/ConditionalCommand.h"
#include "frc2/command/FunctionalCommand.h"
#include "frc2/command/InstantCommand.h"
#include "frc2/command/ParallelCommandGroup.h"
#include "frc2/command/ParallelDeadlineGroup.h"
#include "frc2/command/ParallelRaceGroup.h"
#include "frc2/command/PrintCommand.h"
#include "frc2/command/RunCommand.h"
#include "frc2/command/SequentialCommandGroup.h"
#include "frc2/command/WaitCommand.h"
#include "frc2/command/WaitUntilCommand.h"
using namespace frc2;
// Factories
CommandPtr cmd::None() {
return InstantCommand().ToPtr();
}
CommandPtr cmd::Idle() {
return Run([] {});
}
CommandPtr cmd::RunOnce(std::function<void()> action,
std::initializer_list<Subsystem*> requirements) {
return InstantCommand(std::move(action), requirements).ToPtr();
}
CommandPtr cmd::RunOnce(std::function<void()> action,
std::span<Subsystem* const> requirements) {
return InstantCommand(std::move(action), requirements).ToPtr();
}
CommandPtr cmd::Run(std::function<void()> action,
std::initializer_list<Subsystem*> requirements) {
return RunCommand(std::move(action), requirements).ToPtr();
}
CommandPtr cmd::Run(std::function<void()> action,
std::span<Subsystem* const> requirements) {
return RunCommand(std::move(action), requirements).ToPtr();
}
CommandPtr cmd::StartEnd(std::function<void()> start, std::function<void()> end,
std::initializer_list<Subsystem*> requirements) {
return FunctionalCommand(
std::move(start), [] {},
[end = std::move(end)](bool interrupted) { end(); },
[] { return false; }, requirements)
.ToPtr();
}
CommandPtr cmd::StartEnd(std::function<void()> start, std::function<void()> end,
std::span<Subsystem* const> requirements) {
return FunctionalCommand(
std::move(start), [] {},
[end = std::move(end)](bool interrupted) { end(); },
[] { return false; }, requirements)
.ToPtr();
}
CommandPtr cmd::RunEnd(std::function<void()> run, std::function<void()> end,
std::initializer_list<Subsystem*> requirements) {
return FunctionalCommand([] {}, std::move(run),
[end = std::move(end)](bool interrupted) { end(); },
[] { return false; }, requirements)
.ToPtr();
}
CommandPtr cmd::RunEnd(std::function<void()> run, std::function<void()> end,
std::span<Subsystem* const> requirements) {
return FunctionalCommand([] {}, std::move(run),
[end = std::move(end)](bool interrupted) { end(); },
[] { return false; }, requirements)
.ToPtr();
}
CommandPtr cmd::Print(std::string_view msg) {
return PrintCommand(msg).ToPtr();
}
CommandPtr cmd::Wait(units::second_t duration) {
return WaitCommand(duration).ToPtr();
}
CommandPtr cmd::WaitUntil(std::function<bool()> condition) {
return WaitUntilCommand(condition).ToPtr();
}
CommandPtr cmd::Either(CommandPtr&& onTrue, CommandPtr&& onFalse,
std::function<bool()> selector) {
return ConditionalCommand(std::move(onTrue).Unwrap(),
std::move(onFalse).Unwrap(), std::move(selector))
.ToPtr();
}
CommandPtr cmd::Sequence(std::vector<CommandPtr>&& commands) {
return SequentialCommandGroup(CommandPtr::UnwrapVector(std::move(commands)))
.ToPtr();
}
CommandPtr cmd::RepeatingSequence(std::vector<CommandPtr>&& commands) {
return Sequence(std::move(commands)).Repeatedly();
}
CommandPtr cmd::Parallel(std::vector<CommandPtr>&& commands) {
return ParallelCommandGroup(CommandPtr::UnwrapVector(std::move(commands)))
.ToPtr();
}
CommandPtr cmd::Race(std::vector<CommandPtr>&& commands) {
return ParallelRaceGroup(CommandPtr::UnwrapVector(std::move(commands)))
.ToPtr();
}
CommandPtr cmd::Deadline(CommandPtr&& deadline,
std::vector<CommandPtr>&& others) {
return ParallelDeadlineGroup(std::move(deadline).Unwrap(),
CommandPtr::UnwrapVector(std::move(others)))
.ToPtr();
}
| [
"[email protected]"
] | |
163f749dd9e7cb152d887b2ecb36c5800f797db2 | b892cb9d586b77489c98cec4600cb3ff9c4f0071 | /MsgInstanceMgr.h | 6505e7dd21843c516c2608456d8707230b735ae2 | [] | no_license | zhuzkh/Server | 7ae72b55dc2f2f241e93edbc4490786656d48766 | 537b043b034f77d9df91f9bc33ed163417f339f1 | refs/heads/master | 2022-11-11T09:59:22.529629 | 2020-06-30T02:37:49 | 2020-06-30T02:37:49 | 200,565,262 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 643 | h | #pragma once
#include <map>
#include <string>
#include "google/protobuf/message.h"
#include "Singleton.h"
class MsgInstMgr : public Singleton<MsgInstMgr>
{
private:
MsgInstMgr();
~MsgInstMgr();
friend Singleton<MsgInstMgr>;
public:
void ClearData();
template<typename T>
T* GetMessage(std::string name)
{
if (m_pbMap.find(name) == m_pbMap.end())
{
T* pObj = new T();
if (!pObj)
{
return NULL;
}
m_pbMap[name] = pObj;
}
return dynamic_cast<T*>(m_pbMap[name]);
}
private:
std::map<std::string, google::protobuf::MessageLite*> m_pbMap;
};
#define GetProtoBuf(T) PbManager::GetInstance()->GetMessage<T>(#T);
| [
"[email protected]"
] | |
4c57c22767944d1f0a55d5f9ea8ddec3a72f5900 | 5f4213507ea473067af2943ff8136e229157f0cb | /ABC042/D.cpp | 3793badaf9c6fa187bda1e214a28585d011df06a | [] | no_license | KeiShimon/AtCoder | 682b698cf1098edc25e4d0d823c90da0090e9d62 | 709879babf13a7456c63a0c0df606b9185dd22d8 | refs/heads/master | 2020-04-27T05:26:37.949956 | 2019-11-03T17:04:35 | 2019-11-03T17:04:35 | 174,081,003 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,630 | cpp | #include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>
#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
vector<int64_t> factMemo{ 1,1 }, factInvMemo{ 1, 1 }, invMemo{ 0, 1 };
int curMax{ 1 };
void initTable(int n) {
factMemo.resize(n + 1);
factInvMemo.resize(n + 1);
invMemo.resize(n + 1);
for (; curMax < n;)
{
curMax++;
factMemo[curMax] = factMemo[curMax - 1] * curMax % MOD;
invMemo[curMax] = MOD - invMemo[MOD % curMax] * (MOD / curMax) % MOD;
factInvMemo[curMax] = factInvMemo[curMax - 1] * invMemo[curMax] % MOD;
}
}
// calculate mod of combination
int64_t comb(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
if (curMax < n)
initTable(n);
return factMemo[n] * (factInvMemo[k] * factInvMemo[n - k] % MOD) % MOD;
}
int64_t comb(int64_t n, int64_t k)
{
return comb((int)n, (int)k);
}
int main()
{
ll h, w, a, b; cin >> h >> w >> a >> b;
if (w - b == 1)
{
if (h - a == 1)
{ cout << 1 << endl; return 0; }
ll ans = comb((h - a - 1) + (w - 1), w - 1);
cout << ans << endl;
return 0;
}
else if (h - a == 1)
{
ll ans = comb((w - b - 1) + a, a) % MOD;
cout << ans << endl;
return 0;
}
ll ans = comb(b + (h - a - 1), b);
ans = ans * comb((w - b - 1) + a, a) % MOD;
REP1O(i, h - a)
{
ll tmp = comb(b + (i - 1), b);
tmp = tmp * comb((w - b - 2) + (h - i), h - i) % MOD;
ans = (tmp + ans) % MOD;
}
cout << ans << endl;
} | [
"[email protected]"
] | |
a1798e9db65f3ca1b144a252bd2b3e4e86f5ac4b | 4575e791af09cea766d41c3044d9f1f4bcaf14ad | /phonebook.cpp | adefc268b7cc78f7d752ebdbd83c9331d3d8a843 | [
"MIT"
] | permissive | ruedigergad/SkippingStones | 9f0146ecfdaee0ac81a57cba72adb9f7247c34b0 | 8018c4d44de83b9d382ed78283cde69166706d1a | refs/heads/master | 2021-01-19T07:41:57.543506 | 2014-09-17T06:04:58 | 2014-09-17T06:04:58 | 15,951,525 | 7 | 1 | null | 2014-09-17T05:59:27 | 2014-01-15T23:00:52 | C++ | UTF-8 | C++ | false | false | 2,443 | cpp | /*
* Copyright 2014 Uladzislau Vasilyeu
*
* This file is part of SkippingStones.
*
* SkippingStones is largely based on libpebble by Liam McLoughlin
* https://github.com/Hexxeh/libpebble
*
* SkippingStones is published under the same license as libpebble (as of 10-02-2014):
*
* 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 "phonebook.h"
PhoneBook::PhoneBook(QObject *parent) :
QObject(parent){
}
QString PhoneBook::NameByPhoneNumber(QString PhoneNumber) {
QContactManager *manager = new QContactManager(this);
QList<QContact> contactslist = manager->contacts();
QVariantList contacts;
QStringList phones;
QString label = "";
for (int i = 0; i < contactslist.size(); ++i) {
foreach (QContactPhoneNumber number, contactslist.at(i).details<QContactPhoneNumber>()) {
if (!number.isEmpty()) {
QString phone = QContactPhoneNumber(number).number();
if (!phone.isEmpty() && phone == PhoneNumber) {
QList<QContactDisplayLabel> labels = contactslist.at(i).details<QContactDisplayLabel>();
if (labels.size() > 0 && !labels.first().isEmpty()){
label = labels.first().label();
break;
}
}
}
}
if (label != "")
break;
}
delete manager;
return label;
}
| [
"[email protected]"
] | |
096bd4dde16e998407eea4d0d2f8b0d4010404c0 | 875d08888809ada04d9b22e514aab104179484e4 | /largest_sum_stream.cpp | 23521c1900bef652fe0c1699a951da310048ec0a | [] | no_license | Mritunjay19/Advanced-Algorithms | c9822b360acabba71e244883efd13ea7a0401e0e | ecd8e46fd2cc4b8abc5f12e0731b28db4e3cd73b | refs/heads/master | 2021-11-04T04:57:56.957383 | 2021-10-26T12:08:22 | 2021-10-26T12:08:22 | 215,718,519 | 0 | 4 | null | 2020-10-20T11:13:32 | 2019-10-17T06:25:11 | C++ | UTF-8 | C++ | false | false | 1,841 | cpp | #include<iostream>
#include<climits>
using namespace std;
void swap(int *x, int *y);
class MinHeap
{
int *harr;
int capacity;
int heap_size;
public:
MinHeap(int a[], int size);
void buildHeap();
void MinHeapify(int i);
int parent(int i) { return (i-1)/2; }
int left(int i) { return (2*i + 1); }
int right(int i) { return (2*i + 2); }
int extractMin();
int getMin() { return harr[0]; }
void replaceMin(int x) { harr[0] = x; MinHeapify(0); }
};
MinHeap::MinHeap(int a[], int size)
{
heap_size = size;
harr = a;
}
void MinHeap::buildHeap()
{
int i = (heap_size - 1)/2;
while (i >= 0)
{
MinHeapify(i);
i--;
}
}
int MinHeap::extractMin()
{
if (heap_size == 0)
return INT_MAX;
int root = harr[0];
if (heap_size > 1)
{
harr[0] = harr[heap_size-1];
MinHeapify(0);
}
heap_size--;
return root;
}
void MinHeap::MinHeapify(int i)
{
int l = left(i);
int r = right(i);
int smallest = i;
if (l < heap_size && harr[l] < harr[i])
smallest = l;
if (r < heap_size && harr[r] < harr[smallest])
smallest = r;
if (smallest != i)
{
swap(&harr[i], &harr[smallest]);
MinHeapify(smallest);
}
}
void swap(int *x, int *y)
{
int temp = *x;
*x = *y;
*y = temp;
}
void kthLargest(int k)
{
int count = 0, x;
int *arr = new int[k];
MinHeap mh(arr, k);
while (1)
{
cout << "Enter next element of stream ";
cin >> x;
if (count < k-1)
{
arr[count] = x;
count++;
}
else
{
if (count == k-1)
{
arr[count] = x;
mh.buildHeap();
}
else
{
if (x > mh.getMin())
mh.replaceMin(x);
}
cout << "K'th largest element is "
<< mh.getMin() << endl;
count++;
}
}
}
int main()
{
int k = 3;
cout << "K is " << k << endl;
kthLargest(k);
return 0;
}
| [
"[email protected]"
] | |
1be59cf8c450b1ef7a034ba93611caa1a8c4ab31 | 5d4b70ac5e555e3c8b68534ef1790ce041a0f65e | /include/luxrays/core/color/spds/rgbillum.h | 407a5527ac19ce03276b132ece7caa13b573e621 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | LuxCoreRender/LuxCore | eddb0e3710cbc8fa28cb80f16d908f1ec3cc72db | 2f35684a04d9e1bd48d6ffa88b19a88871e90942 | refs/heads/master | 2023-08-17T01:28:23.931381 | 2023-05-28T22:25:00 | 2023-05-28T22:25:00 | 111,695,279 | 1,055 | 154 | Apache-2.0 | 2023-08-03T20:21:05 | 2017-11-22T14:36:32 | C++ | UTF-8 | C++ | false | false | 1,940 | h | /***************************************************************************
* Copyright 1998-2020 by authors (see AUTHORS.txt) *
* *
* This file is part of LuxCoreRender. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
#ifndef _LUXRAYS_RGBILLUMSPD_H
#define _LUXRAYS_RGBILLUMSPD_H
#include "luxrays/core/color/color.h"
#include "luxrays/core/color/spd.h"
namespace luxrays {
// illuminant SPD, from RGB color, using smits conversion, reconstructed using linear interpolation
class RGBIllumSPD : public SPD {
public:
RGBIllumSPD() : SPD() { init(RGBColor(1.f)); }
RGBIllumSPD(const RGBColor &s) : SPD() { init(s); }
virtual ~RGBIllumSPD() {}
protected:
void AddWeighted(float w, const float *c) {
for(u_int i = 0; i < nSamples; ++i)
samples[i] += c[i] * w;
}
void init(const RGBColor &s);
};
}
#endif // _LUXRAYS_RGBILLUMSPD_H
| [
"[email protected]"
] | |
365305e9248087a77afdacfdb7889e7a7c1ed4c0 | dd25bddb7ff7af363dd4c5a42f06f9a5327281c1 | /CinchGrid/ReferenceEditableDelegate.cpp | 808e017bbdccda7b6180b4bcb9e16a96fb99af39 | [] | no_license | jennmat/CinchGrid | 99892e9f8875a48e885d5a9a4b0af22bafefb432 | 526187a76f0f19b14b6162e6eb78a89a796f8b67 | refs/heads/master | 2021-01-19T05:22:11.139753 | 2013-11-04T17:36:23 | 2013-11-04T17:36:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,043 | cpp |
#include "stdafx.h"
#include <string.h>
#include <stdio.h>
ReferenceEditableDelegate::ReferenceEditableDelegate(){
rowCount = 3;
}
ReferenceEditableDelegate::~ReferenceEditableDelegate(){
}
int ReferenceEditableDelegate::totalColumns(){
return 4;
}
int ReferenceEditableDelegate::totalRows(){
return rowCount;
}
int ReferenceEditableDelegate::columnWidth(int column){
return 85;
}
int ReferenceEditableDelegate::rowHeight(){
return 22;
}
void ReferenceEditableDelegate::headerContent(int col, wstring& content) {
content = L"";
}
bool ReferenceEditableDelegate::stickyHeaders(){
return false;
}
void ReferenceEditableDelegate::LoadSegment(int start_row, int len, wchar_t*** data, int* rows_loaded, int* cols_loaded){
int row = start_row;
for(int i=0; i<len; i++){
for(int col=0; col<totalColumns(); col++){
if ( data[i][col] == nullptr ){
data[i][col] = new wchar_t[200];
memset(data[i][col], 0, sizeof(wchar_t)*200);
wcscpy_s(data[i][col], 200, L"abc");
}
}
row++;
}
*rows_loaded = len;
*cols_loaded = totalColumns();
}
void ReferenceEditableDelegate::CleanupSegment(int rowCount, int columnCount, wchar_t*** data){
for(int i=0; i<rowCount; i++){
for(int col=0; col<columnCount; col++){
delete data[i][col];
}
}
}
HFONT ReferenceEditableDelegate::getFont(){
HFONT hFont=CreateFont(17,0,0,0,0,0,0,0,0,0,0,0,0,TEXT("MS Shell Dlg"));
return hFont;
}
HFONT ReferenceEditableDelegate::getEditFont(){
HFONT hFont=CreateFont(18,0,0,0,0,0,0,0,0,0,0,0,0,TEXT("MS Shell Dlg"));
return hFont;
}
bool ReferenceEditableDelegate::drawHorizontalGridlines(){
return true;
}
bool ReferenceEditableDelegate::drawVerticalGridlines(){
return true;
}
bool ReferenceEditableDelegate::rowSelection() {
return false;
}
bool ReferenceEditableDelegate::allowEditing(int col){
return true;
}
void ReferenceEditableDelegate::editingFinished(int row, int col, wchar_t*** data)
{
}
void ReferenceEditableDelegate::willLoseFocus(){
}
bool ReferenceEditableDelegate::allowNewRows() {
return true;
}
void ReferenceEditableDelegate::prepareNewRow(int row){
rowCount++;
}
bool ReferenceEditableDelegate::allowHeaderTitleEditing(int col) {
return true;
}
bool ReferenceEditableDelegate::allowNewColumns() {
return false;
}
void ReferenceEditableDelegate::headerContextClick(HWND hwnd, int x, int y){
}
void ReferenceEditableDelegate::willReloadData(){
}
void ReferenceEditableDelegate::didReloadData(){
}
void ReferenceEditableDelegate::didSelectRow(int row){
}
void ReferenceEditableDelegate::setGrid(CinchGrid* grid){
}
void ReferenceEditableDelegate::didChangeColumnWidth(int col, int newWidth){
}
bool ReferenceEditableDelegate::allowSorting(int col){
return false;
}
void ReferenceEditableDelegate::sortAscending(int col){
}
void ReferenceEditableDelegate::sortDescending(int col){
}
void ReferenceEditableDelegate::sortOff(int col){
} | [
"[email protected]"
] | |
38de226f2dde09aec05e706137097fffb6b1fb2d | 2de8f5ba729a846f8ad5630272dd5b1f3b7b6e44 | /src/server/gameserver/skill/CastleSkillSlot.cpp | 99fcca14d6a0ef2834704a2bd39d354922fd0edd | [] | no_license | najosky/darkeden-v2-serverfiles | dc0f90381404953e3716bf71320a619eb10c3825 | 6e0015f5b8b658697228128543ea145a1fc4c559 | refs/heads/master | 2021-10-09T13:01:42.843224 | 2018-12-24T15:01:52 | 2018-12-24T15:01:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 261 | cpp | #include "CastleSkillSlot.h"
CastleSkillSlot::~CastleSkillSlot() throw() { }
void CastleSkillSlot::save(const string& ownerID) throw(Error) { }
void CastleSkillSlot::save() throw(Error) { }
void CastleSkillSlot::create(const string& ownerID) throw(Error) { }
| [
"[email protected]"
] | |
2e6f054c0b206d67612fda060d011811d323a663 | 028823a52e2ef93fd3a53d74ae6c5e459a2f954e | /ros_voice_system/src/voice_move/src/voice_move.cpp | 3f929cf8cf5ed126d6a5c62efd8aac582c0b312a | [] | no_license | wzh1998/Care_Robot | fe6ac33f4762dfa996b70326ff8adb30965c5320 | f416514348825b1a405718c93834906d7263f980 | refs/heads/master | 2022-11-07T19:40:19.235642 | 2021-09-05T15:11:44 | 2021-09-05T15:11:44 | 214,085,698 | 2 | 0 | null | 2022-10-18T19:25:13 | 2019-10-10T04:22:25 | Makefile | UTF-8 | C++ | false | false | 2,981 | cpp |
#include <ros/ros.h>
#include <std_msgs/Int32.h>
#include <geometry_msgs/Twist.h>
#define MOVE_FORWARD_CMD 1
#define MOVE_BACK_CMD 2
#define MOVE_LEFT_CMD 3
#define MOVE_RIGHT_CMD 4
#define TURN_LEFT_CMD 5
#define TURN_RIGHT_CMD 6
#define STOP_MOVE_CMD 7
ros::Publisher pub;
float speed_x = 0.2;
float speed_y = 0.2;
float turn_speed = 0.5;
int pub_flag = 0;
geometry_msgs::Twist cmd_msg;
void subCallBack(const std_msgs::Int32::ConstPtr& msg)
{
ROS_WARN("Get Move CMD:%d",msg->data);
switch(msg->data)
{
case MOVE_FORWARD_CMD: //move forward
cmd_msg.linear.x = speed_x;
cmd_msg.linear.y = 0;
cmd_msg.angular.z = 0;
break;
case MOVE_BACK_CMD: //move back
cmd_msg.linear.x = -speed_x;
cmd_msg.linear.y = 0;
cmd_msg.angular.z = 0;
break;
case MOVE_LEFT_CMD: //move left
cmd_msg.linear.x = 0;
cmd_msg.linear.y = speed_y;
cmd_msg.angular.z = 0;
break;
case MOVE_RIGHT_CMD: //move right
cmd_msg.linear.x = 0;
cmd_msg.linear.y = -speed_y;
cmd_msg.angular.z = 0;
break;
case TURN_LEFT_CMD: //turn left
cmd_msg.linear.x = 0;
cmd_msg.linear.y = 0;
cmd_msg.angular.z = turn_speed;
break;
case TURN_RIGHT_CMD: //turn right
cmd_msg.linear.x = 0;
cmd_msg.linear.y = 0;
cmd_msg.angular.z = -turn_speed;
break;
case STOP_MOVE_CMD: //stop move
cmd_msg.linear.x = 0;
cmd_msg.linear.y = 0;
cmd_msg.angular.z = 0;
ROS_WARN("Get stop move cmd:%d",msg->data);
break;
default:
ROS_WARN("Get Unknown Move CMD:%d",msg->data);
break;
}
if((msg->data >= MOVE_FORWARD_CMD)&&(msg->data <= TURN_RIGHT_CMD))
{
pub_flag = 1;
}
else
{
ROS_WARN("set pub_flag = 0");
pub_flag = 0;
}
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "voice_move_node");
ros::NodeHandle ndHandle;
std::string sub_move_topic = "/voice_system/voice_cmd_vel";
std::string pub_move_topic = "/cmd_vel";
ros::param::get("~sub_move_topic", sub_move_topic);
ros::param::get("~pub_move_topic", pub_move_topic);
ros::param::get("~default_speed_x", speed_x);
ros::param::get("~default_speed_y", speed_y);
ros::param::get("~default_turn_speed", turn_speed);
ros::Subscriber sub = ndHandle.subscribe(sub_move_topic, 1, subCallBack);
pub = ndHandle.advertise<geometry_msgs::Twist>(pub_move_topic, 1);
ros::Rate loop_rate(5);
while(ros::ok())
{
if(pub_flag)
{
pub.publish(cmd_msg);
}
loop_rate.sleep();
ros::spinOnce();
}
return 0;
}
| [
"[email protected]"
] | |
ccf998b176f03217647cc1bfcfa1a6a7b2bdd3dd | a751d5f3c2d16a9824090c702dfedd6eb50bf674 | /Core/Level.cpp | 36a2c70973e1705a4635ab54980f6058dfa0deec | [
"MIT"
] | permissive | felipeprov/Monocle-Engine | a67af8652dd9a33cd6836c254cc1c8566bea7b03 | 534ce4e683944842b30531bfbbdf628aea576723 | refs/heads/master | 2020-12-25T05:28:14.214501 | 2011-06-29T00:05:36 | 2011-06-29T00:05:36 | 2,456,034 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,186 | cpp | #include "Level.h"
#include "Assets.h"
#include <TinyXML/tinyxml.h>
#include "XML/XMLFileNode.h"
#include <iostream>
#include <fstream>
#include "Entity.h"
#include "LevelEditor/Node.h"
#include "LevelEditor/PathMesh.h"
namespace Monocle
{
EntityType::EntityType()
{
}
void EntityType::Save(FileNode *fileNode)
{
fileNode->Write("name", name);
fileNode->Write("image", image);
}
void EntityType::Load(FileNode *fileNode)
{
fileNode->Read("name", name);
fileNode->Read("image", image);
}
Level *Level::instance = NULL;
Level::Level()
: scene(NULL), fringeTileset(NULL)
{
instance = this;
width = height = 0;
}
void Level::Init()
{
}
void Level::SetScene(Scene *scene)
{
instance->scene = scene;
}
void Level::LoadProject(const std::string &filename)
{
Debug::Log("Loading Level...");
// load the project data from an xml file
instance->tilesets.clear();
///TODO: clear fringeTileset
TiXmlDocument xml(Assets::GetContentPath() + filename);
bool isLoaded = xml.LoadFile();
if (isLoaded)
{
TiXmlElement* eProject = xml.FirstChildElement("Project");
if (eProject)
{
TiXmlElement* eEntityTypes = eProject->FirstChildElement("EntityTypes");
if (eEntityTypes)
{
TiXmlElement* eEntityType = eEntityTypes->FirstChildElement("EntityType");
while (eEntityType)
{
XMLFileNode xmlFileNode(eEntityType);
EntityType entityType;
entityType.Load(&xmlFileNode);
instance->entityTypes.push_back(entityType);
eEntityType = eEntityType->NextSiblingElement("EntityType");
}
}
// Load Tileset data (for tiles on a grid)
TiXmlElement* eTilesets = eProject->FirstChildElement("Tilesets");
if (eTilesets)
{
TiXmlElement* eTileset = eTilesets->FirstChildElement("Tileset");
while (eTileset)
{
instance->tilesets.push_back(Tileset(XMLReadString(eTileset, "name"), XMLReadString(eTileset, "image"), XMLReadInt(eTileset, "tileWidth"), XMLReadInt(eTileset, "tileHeight")));
eTileset = eTilesets->NextSiblingElement("Tileset");
}
}
// Load FringeTileset data (for arbitrarily sized 'n placed tiles)
TiXmlElement* eFringeTilesets = eProject->FirstChildElement("FringeTilesets");
if (eFringeTilesets)
{
TiXmlElement* eFringeTileset = eFringeTilesets->FirstChildElement("FringeTileset");
while (eFringeTileset)
{
FringeTileset fringeTileset = FringeTileset(XMLReadString(eFringeTileset, "name"));
TiXmlElement* eFringeTile = eFringeTileset->FirstChildElement("FringeTile");
while (eFringeTile)
{
if (eFringeTile->Attribute("id") && eFringeTile->Attribute("image"))
{
int tileID = XMLReadInt(eFringeTile, "id");
std::string image = XMLReadString(eFringeTile, "image");
int width = -1;
int height = -1;
if (eFringeTile->Attribute("width") && eFringeTile->Attribute("height"))
{
width = XMLReadInt(eFringeTile, "width");
height = XMLReadInt(eFringeTile, "height");
}
FilterType filter = FILTER_LINEAR;
bool repeatX = XMLReadBool(eFringeTile, "repeatX");
bool repeatY = XMLReadBool(eFringeTile, "repeatY");
bool autoTile = XMLReadBool(eFringeTile, "autoTile");
int atlasX=0, atlasY=0, atlasW=0, atlasH=0;
std::string atlas = XMLReadString(eFringeTile, "atlas");
if (atlas != "")
{
std::istringstream is(atlas);
is >> atlasX >> atlasY >> atlasW >> atlasH;
}
if (image != "")
{
fringeTileset.SetFringeTileData(tileID, new FringeTileData(image, width, height, filter, repeatX, repeatY, atlasX, atlasY, atlasW, atlasH, autoTile));
}
}
eFringeTile = eFringeTile->NextSiblingElement("FringeTile");
}
instance->fringeTilesets.push_back(fringeTileset);
eFringeTileset = eFringeTileset->NextSiblingElement("FringeTileset");
}
}
}
}
Debug::Log("...done");
}
void Level::Load(const std::string &filename, Scene* scene)
{
// load from an xml file, into the scene
if (scene != NULL)
{
instance->scene = scene;
}
if (instance->scene)
{
// unload tilemaps... (need to destroy them?)
instance->tilemaps.clear();
//clearfringeTileset
TiXmlDocument xml(Assets::GetContentPath() + filename);
instance->filename = filename;
bool isLoaded = xml.LoadFile();
if (isLoaded)
{
TiXmlElement* eLevel = xml.FirstChildElement("Level");
if (eLevel)
{
instance->width = XMLReadInt(eLevel, "width");
instance->height = XMLReadInt(eLevel, "height");
std::string fringeTilesetName = XMLReadString(eLevel, "fringeTileset");
if (fringeTilesetName != "")
{
instance->fringeTileset = instance->GetFringeTilesetByName(fringeTilesetName);
}
Color backgroundColor = Color::black;
XMLReadColor(eLevel, "backgroundColor", &backgroundColor);
Graphics::SetBackgroundColor(backgroundColor);
XMLFileNode xmlFileNode(eLevel);
instance->scene->LoadLevel(&xmlFileNode);
TiXmlElement *eTilemap = eLevel->FirstChildElement("Tilemap");
while (eTilemap)
{
Tilemap *tilemap = new Tilemap(instance->GetTilesetByName(XMLReadString(eTilemap, "set")), instance->width, instance->height, XMLReadInt(eTilemap, "tileWidth"), XMLReadInt(eTilemap, "tileHeight"));
instance->tilemaps.push_back(tilemap);
Entity *entity = new Entity();
entity->SetGraphic(tilemap);
instance->scene->Add(entity);
TiXmlElement *eTile = eTilemap->FirstChildElement("Tile");
while (eTile)
{
tilemap->SetTile(XMLReadInt(eTile, "x"), XMLReadInt(eTile, "y"), XMLReadInt(eTile, "tileID"));
eTile = eTile->NextSiblingElement("Tile");
}
eTilemap = eTilemap->NextSiblingElement("Tilemap");
}
TiXmlElement *eEntities = eLevel->FirstChildElement("Entities");
if (eEntities)
{
instance->LoadEntities(eEntities);
instance->scene->LoadEntities(eEntities);
}
instance->scene->ResolveEntityChanges();
}
}
}
}
/*
template <class T>
void Level::SaveEntitiesOfType(const std::string &name, TiXmlElement *element, Entity *fromEntity)
{
XMLFileNode xmlFileNode;
const std::list<Entity*> *entities;
if (fromEntity)
entities = fromEntity->GetChildren();
else
entities = instance->scene->GetEntities();
for (std::list<Entity*>::const_iterator i = entities->begin(); i != entities->end(); ++i)
{
Entity *entity = *i;
T *t = dynamic_cast<T*>(entity);
if (t)
{
TiXmlElement saveElement(name);
xmlFileNode.element = &saveElement;
instance->SaveEntities(&saveElement, entity);
entity->Save(&xmlFileNode);
element->InsertEndChild(saveElement);
}
}
}
*/
/*
template <class T>
void Level::LoadEntitiesOfType(const std::string &name, TiXmlElement *element, Entity *intoEntity)
{
XMLFileNode xmlFileNode;
TiXmlElement *eEntity = element->FirstChildElement(name);
while (eEntity)
{
T *t = new T();
Entity *entity = dynamic_cast<Entity*>(t);
if (intoEntity == NULL)
instance->scene->Add(entity);
else
intoEntity->Add(entity);
instance->LoadEntities(eEntity, entity);
xmlFileNode.element = eEntity;
entity->Load(&xmlFileNode);
eEntity = eEntity->NextSiblingElement(name);
}
}
*/
void Level::SaveEntities(TiXmlElement *element, Entity *fromEntity)
{
SaveEntitiesOfType<PathMesh>("PathMesh", element, fromEntity);
SaveEntitiesOfType<FringeTile>("FringeTile", element, fromEntity);
//SaveEntitiesOfType<Node>("Node", element, fromEntity);
}
void Level::LoadEntities(TiXmlElement *element, Entity *intoEntity)
{
if (element)
{
LoadEntitiesOfType<PathMesh>("PathMesh", element, intoEntity);
LoadEntitiesOfType<FringeTile>("FringeTile", element, intoEntity);
//LoadEntitiesOfType<Node>("Node", element, intoEntity);
}
}
Tileset *Level::GetTilesetByName(const std::string &name)
{
for (std::list<Tileset>::iterator i = tilesets.begin(); i != tilesets.end(); ++i)
{
if ((*i).name == name)
return &(*i);
}
Debug::Log("Error: Could not find tileset with name: " + name);
return NULL;
}
void Level::Save()
{
if (instance->filename == "")
{
// open save as dialog or something
Debug::Log("Warning: Won't save level, no filename set");
}
else
{
// save our data out to xml file
if (instance->scene)
{
Debug::Log("Saving scene...");
TiXmlDocument xml;
TiXmlElement eLevel("Level");
eLevel.SetAttribute("width", instance->width);
eLevel.SetAttribute("height", instance->height);
if (instance->fringeTileset)
{
eLevel.SetAttribute("fringeTileset", instance->fringeTileset->GetName());
}
Color backgroundColor = Graphics::GetBackgroundColor();
if (backgroundColor != Color::black)
{
XMLWriteColor(&eLevel, "backgroundColor", backgroundColor);
}
XMLFileNode xmlFileNode(&eLevel);
instance->scene->SaveLevel(&xmlFileNode);
if (!instance->tilemaps.empty())
{
//TiXmlElement eTilemaps("Tilemaps");
// save tilemaps
for (std::list<Tilemap*>::iterator i = instance->tilemaps.begin(); i != instance->tilemaps.end(); ++i)
{
TiXmlElement eTilemap("Tilemap");
if ((*i)->tileset)
eTilemap.SetAttribute("set", (*i)->tileset->name);
eTilemap.SetAttribute("tileWidth", (*i)->tileWidth);
eTilemap.SetAttribute("tileHeight", (*i)->tileHeight);
for (int ty = 0; ty < (*i)->height / (*i)->tileHeight; ty++)
{
for (int tx = 0; tx < (*i)->width / (*i)->tileWidth; tx++)
{
TiXmlElement eTile("Tile");
eTile.SetAttribute("x", tx);
eTile.SetAttribute("y", ty);
eTile.SetAttribute("tileID", (*i)->GetTile(tx, ty));
eTilemap.InsertEndChild(eTile);
}
}
eLevel.InsertEndChild(eTilemap);
}
}
TiXmlElement eEntities("Entities");
instance->SaveEntities(&eEntities);
instance->scene->SaveEntities(&eEntities);
eLevel.InsertEndChild(eEntities);
/*
// save fringe tiles
// go through the sets
for (std::list<FringeTileset>::iterator i = instance->fringeTilesets.begin(); i != instance->fringeTilesets.end(); ++i)
{
bool savedAny = false;
TiXmlElement eFringeTiles("FringeTiles");
eFringeTiles.SetAttribute("set", (*i).GetName());
// save fringeTiles that belong to the set
for (std::list<FringeTile*>::iterator j = instance->fringeTiles.begin(); j != instance->fringeTiles.end(); ++j)
{
if ((*j)->GetFringeTileset() == &(*i))
{
savedAny = true;
TiXmlElement eFringeTile("FringeTile");
// TODO: use tags instead
eFringeTile.SetAttribute("id", (*j)->GetTileID());
eFringeTile.SetAttribute("layer", (*j)->GetLayer());
eFringeTile.SetAttribute("x", (*j)->position.x);
eFringeTile.SetAttribute("y", (*j)->position.y);
eFringeTile.SetAttribute("rotation", (*j)->rotation);
eFringeTile.SetDoubleAttribute("scaleX", (*j)->scale.x);
eFringeTile.SetDoubleAttribute("scaleY", (*j)->scale.y);
if ((*j)->color.a != 1.0f)
{
eFringeTile.SetDoubleAttribute("ca", (*j)->color.a);
}
eFringeTiles.InsertEndChild(eFringeTile);
}
}
if (savedAny)
{
eLevel.InsertEndChild(eFringeTiles);
}
}
*/
xml.InsertEndChild(eLevel);
xml.SaveFile(Assets::GetContentPath() + instance->filename);
Debug::Log("...done");
}
}
}
void Level::SaveAs(const std::string &filename)
{
// save under a new filename
}
void Level::End()
{
// do any cleanup required
instance->scene = NULL;
}
FringeTileset *Level::GetFringeTilesetByName(const std::string &name)
{
for (std::list<FringeTileset>::iterator i = fringeTilesets.begin(); i != fringeTilesets.end(); ++i)
{
if ((*i).IsName(name))
{
return &(*i);
}
}
return NULL;
}
FringeTileset* Level::GetCurrentFringeTileset()
{
return instance->fringeTileset;
}
}
| [
"[email protected]"
] | |
b98d2c86ded070f2a532b32fd08c70080c2274e9 | 95397145944f76fe788c0aeeea128baa9c92fa93 | /Arduino Code/readPotentiometer/readPotentiometer.ino | eea4b65c93482c7abc6a35434d30bc67f489f33d | [] | no_license | Carl-L/Arduino_Processing_Movie | a52294cdc8dd1303c1bfe5a8356f0ace19480796 | 6c32d638a5ff5fdba2606f17f8947019c6140aad | refs/heads/master | 2021-01-11T20:50:13.442783 | 2017-01-20T13:27:22 | 2017-01-20T13:27:22 | 79,194,546 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,539 | ino | /*
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on
the value obtained by analogRead().
The circuit:
* Potentiometer attached to analog input 0
* center pin of the potentiometer to the analog pin
* one side pin (either one) to ground
* the other side pin to +5V
* LED anode (long leg) attached to digital output 13
* LED cathode (short leg) attached to ground
* Note: because most Arduinos have a built-in LED attached
to pin 13 on the board, the LED is optional.
Created by David Cuartielles
modified 30 Aug 2011
By Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/AnalogInput
*/
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}
| [
"[email protected]"
] | |
57f542cc0be7d10bfc5234d0b400b5f3c2a6d866 | aabfe137db175f0e070bd9342e6346ae65e2be32 | /DQM/EcalBarrelMonitorTasks/interface/EBTrendTask.h | 58cb404a7b2d0f891cfa00869ed75124a67bbddc | [] | no_license | matteosan1/cmssw | e67b77be5d03e826afd36a9ec5a6dc1b3ee57deb | 74f7c9a4cf24913e2a9f4e6805bb2e8e25ab7d52 | refs/heads/CMSSW_7_0_X | 2021-01-15T18:35:33.405650 | 2013-07-30T14:59:30 | 2013-07-30T14:59:30 | 11,789,054 | 1 | 1 | null | 2016-04-03T13:48:46 | 2013-07-31T11:06:26 | C++ | UTF-8 | C++ | false | false | 2,969 | h | #ifndef EBTrendTask_H
#define EBTrendTask_H
/*
* \file EBTrendTask.h
*
* $Date: 2010/02/08 21:35:03 $
* $Revision: 1.3 $
* \author Dongwook Jang, Soon Yung Jun
*
*/
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
class MonitorElement;
class DQMStore;
class EBTrendTask: public edm::EDAnalyzer{
public:
// Constructor
EBTrendTask(const edm::ParameterSet& ps);
// Destructor
virtual ~EBTrendTask();
protected:
// Analyze
void analyze(const edm::Event& e, const edm::EventSetup& c);
// BeginJob
void beginJob(void);
// EndJob
void endJob(void);
// BeginRun
void beginRun(const edm::Run & r, const edm::EventSetup & c);
// EndRun
void endRun(const edm::Run & r, const edm::EventSetup & c);
// Reset
void reset(void);
// Setup
void setup(void);
// Cleanup
void cleanup(void);
// Update time check
void updateTime(void);
private:
int ievt_;
DQMStore* dqmStore_;
std::string prefixME_;
bool enableCleanup_;
bool mergeRuns_;
bool verbose_;
edm::InputTag EBDigiCollection_;
edm::InputTag EcalPnDiodeDigiCollection_;
edm::InputTag EcalRecHitCollection_;
edm::InputTag EcalTrigPrimDigiCollection_;
edm::InputTag BasicClusterCollection_;
edm::InputTag SuperClusterCollection_;
edm::InputTag EBDetIdCollection0_;
edm::InputTag EBDetIdCollection1_;
edm::InputTag EBDetIdCollection2_;
edm::InputTag EBDetIdCollection3_;
edm::InputTag EBDetIdCollection4_;
edm::InputTag EcalElectronicsIdCollection1_;
edm::InputTag EcalElectronicsIdCollection2_;
edm::InputTag EcalElectronicsIdCollection3_;
edm::InputTag EcalElectronicsIdCollection4_;
edm::InputTag EcalElectronicsIdCollection5_;
edm::InputTag EcalElectronicsIdCollection6_;
edm::InputTag FEDRawDataCollection_;
edm::InputTag EBSRFlagCollection_;
MonitorElement* nEBDigiMinutely_;
MonitorElement* nEcalPnDiodeDigiMinutely_;
MonitorElement* nEcalRecHitMinutely_;
MonitorElement* nEcalTrigPrimDigiMinutely_;
MonitorElement* nBasicClusterMinutely_;
MonitorElement* nBasicClusterSizeMinutely_;
MonitorElement* nSuperClusterMinutely_;
MonitorElement* nSuperClusterSizeMinutely_;
MonitorElement* nIntegrityErrorMinutely_;
MonitorElement* nFEDEBRawDataMinutely_;
MonitorElement* nEBSRFlagMinutely_;
MonitorElement* nEBDigiHourly_;
MonitorElement* nEcalPnDiodeDigiHourly_;
MonitorElement* nEcalRecHitHourly_;
MonitorElement* nEcalTrigPrimDigiHourly_;
MonitorElement* nBasicClusterHourly_;
MonitorElement* nBasicClusterSizeHourly_;
MonitorElement* nSuperClusterHourly_;
MonitorElement* nSuperClusterSizeHourly_;
MonitorElement* nIntegrityErrorHourly_;
MonitorElement* nFEDEBRawDataHourly_;
MonitorElement* nEBSRFlagHourly_;
bool init_;
int start_time_;
int current_time_;
int last_time_;
};
#endif
| [
"[email protected]"
] | |
f8a9be31e67e7bbcb204995495379799cca770c5 | afdb4de6d6db332b410dcacb23daf54f86cec7d6 | /COmeter_proyect/COmeter_proyect.ino | 1a67b58e022a8fb4f45636b746d18996ebad241e | [] | no_license | andereyes99/ArduinoStuff | 9bafae696d8a7074e2eddf63bd52a99de34e8918 | d0507415e823831fcccf768f643bf00efa8ef3ee | refs/heads/master | 2021-05-12T16:06:20.972459 | 2017-12-26T19:09:16 | 2017-12-26T19:09:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 376 | ino | int mq3_analogPin = 1; // connected to the output pin of MQ3
void setup(){
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
}
void loop()
{
// give ample warmup time for readings to stabilize
int mq3_value = analogRead(mq3_analogPin);
if(mq3_value>500){
digitalWrite(0,HIGH);
}else{
digitalWrite(0,LOW);
}
delay(100); //Just here to slow down the output.
}
| [
"[email protected]"
] | |
5751c3899c5d7715d8e4a2b98d65fc551825ee33 | 86368e5fc2ca6ab93267675689c85c06540cd1dd | /CODE/LL/classic/5palindrome.cpp | 3493e80ae4b658360ad676384c624a262129ac4f | [] | no_license | alenthankz/Master_DSA | 471e091720fff6e3b8c1e38965af73e566728ddf | 131fc45211e1fe08c958f8d34674faa90c16fc8c | refs/heads/main | 2023-07-28T00:01:46.291091 | 2021-09-08T05:39:43 | 2021-09-08T05:39:43 | 404,223,486 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,148 | cpp | #include<bits/stdc++.h>
using namespace std;
class Node {
public:
Node* next;
int data;
Node(int dat){
next=NULL;
data=dat;
}
};
void printL(Node *tNode){
while(tNode!=NULL){
cout<<tNode->data<<" ";
tNode=tNode->next;
}
}
bool method1(Node * head){
Node * slow=head,*fast=head;
int count=0;
while(fast && fast->next){
count++;
fast=fast->next->next;
slow=slow->next;
}
Node *prev =NULL,*curr=head,*next;
while(curr!=slow){
next=curr->next;
curr->next=prev;
prev=curr;
curr=next;
}
Node * ptr1=prev;
Node *ptr2=(count%2==0)?slow:slow->next;
cout<<slow->data<<endl;
while(ptr1 && ptr2){
if(ptr1->data!=ptr2->data)return false;
ptr1=ptr1->next;
ptr2=ptr2->next;
}
return true;
}
int main(){
Node *head1=new Node(1);head1->next=new Node(2);head1->next->next=new Node(3);head1->next->next->next=new Node(2);;head1->next->next->next->next=new Node(1);
printL(head1);cout<<endl;
cout<<method1(head1);
// method2(head1,2);
return 0;
} | [
"[email protected]"
] | |
f4c916a2bfc7255dba31d93ef7931087faeca911 | e29b39448d111df4326c7a23370549be779e9dbb | /nsDM/src/NotifyEdit.cpp | 2247828a85f49531b79ae833e60763a3eeeb0e05 | [] | no_license | lineCode/nsDM | e2874028fcda2346f94c8278a11689f0c3e9200e | e45cfbeb2969d4b89fdb81c27f73f6be2b07a67d | refs/heads/master | 2022-10-10T08:44:43.156863 | 2020-06-12T02:40:57 | 2020-06-12T02:40:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 313 | cpp | #include "StdAfx.h"
#include "NotifyEdit.h"
using DM::DM_ECODE_FAIL;
using DM::DM_ECODE_OK;
CNotifyEdit::CNotifyEdit(void)
{
}
CNotifyEdit::~CNotifyEdit(void)
{
}
void CNotifyEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
DM_SendMessage(EM_SETEVENTMASK, 0, ENM_CHANGE);
SetMsgHandled(FALSE);
}
| [
"[email protected]"
] | |
5453d58fd23b7a16f970e96bd071527341d5c9fa | eee92bb4dc8d24aa874c9253295301c86330b23a | /source/Renderer/GlRenderer/Src/Command/Commands/GlResetQueryPoolCommand.cpp | 6dd03e6cf61a8f494bc6d07d31a0f2e8567ddda2 | [
"MIT"
] | permissive | fcccode/RendererLib | d7c127a4b22428220098bfee4575e5401c7c3769 | f8e692ae1f1cddae0185fc0c1fe7107efcc8d959 | refs/heads/master | 2020-03-27T08:29:56.020776 | 2018-08-07T14:58:58 | 2018-08-07T14:58:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 482 | cpp | /*
This file belongs to GlRenderer.
See LICENSE file in root folder.
*/
#include "GlResetQueryPoolCommand.hpp"
namespace gl_renderer
{
ResetQueryPoolCommand::ResetQueryPoolCommand( renderer::QueryPool const & pool
, uint32_t firstQuery
, uint32_t queryCount )
{
}
void ResetQueryPoolCommand::apply()const
{
glLogCommand( "ResetQueryPoolCommand" );
}
CommandPtr ResetQueryPoolCommand::clone()const
{
return std::make_unique< ResetQueryPoolCommand >( *this );
}
}
| [
"[email protected]"
] | |
9f48d560dbcaa42f17844aa354f15fc15d945d1f | 11c1724973017e9f4503c738eb1a98a081a02f4f | /MinimalExample/MyLibWorkingTest.cpp | 6005376ed6d30f5a9c6aef937c34c6422726fa76 | [] | no_license | chetgnegy/bazel_issue_9_4_2020 | 6d0787c04c028c4faf5dfa735fe23c3426d237cc | be9720fe959e27b7628be0046176d610e36ba24d | refs/heads/master | 2022-12-19T07:47:33.430916 | 2020-09-17T02:09:17 | 2020-09-17T02:09:17 | 292,972,305 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 134 | cpp | #include "MinimalExample/ComplicatedLib.h"
#include <cstdio>
int main() {
ComplicatedLib lib;
printf("%d\n", lib.GetAnswer());
} | [
"[email protected]"
] | |
3be18d8314602644c85e6f321441cd52bb0325d5 | 26b47adc22a1538b8045ae13e55055c8f0631a2b | /rntl/rtcus_compositions/src/tests/state_composer.cpp | e082b734f9900e6f15e321ef4e94d42c499cb75e | [] | no_license | congleetea/rtc-us-ros-pkg-code | 6912dce6f497afbff157bd6f382b9deb650813a0 | 527c3ae15ad0227dde059afa0a4fb82974500a73 | refs/heads/master | 2020-07-16T16:27:39.194532 | 2019-05-28T09:27:46 | 2019-05-28T09:27:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,066 | cpp | /*
* state_composer.cpp
*
* Created on: Jun 13, 2012
* Author: Pablo Iñigo Blasco - Robotics and Computer Architecture (ATC) - University of Seville - 2012
* License: GPLv3
*/
#include <mrpt_bridge/mrpt_bridge.h>
#include <gtest/gtest.h>
#include <ros/ros.h>
#include <geometry_msgs/Pose.h>
#include <rtcus_compositions/state_composer.h>
#include <rtcus_nav_msgs/DynamicState2D.h>
using namespace rtcus_nav_msgs;
// Run all the tests that were declared with TEST()
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
TEST(Compositions, dynamicCompositions)
{
DynamicState2D state, result;
DynamicState2D transform;
state.pose.x = 1.0;
state.pose.y = 0;
state.pose.phi = 0;
state.twist.angular = 1.0;
state.twist.linear = 1.0;
state.twist.lateral = 0.0;
transform.pose.x = 10;
transform.pose.y = 10;
transform.pose.phi = 1.0;
transform.twist.angular = -1.0;
transform.twist.linear = 5.0;
//rtcus_compositions::StateComposer::compose(state, transform, result);
}
| [
"[email protected]"
] | |
3ebc97b6434b18dcd64df66044b35d14ac5907dd | 2afd36dffef6ead6a94ff0ee08ff1b1cfa090814 | /from_me/code11-5-close-unlive.cpp | 36dcc32a828cd110d0b515bee01f985e872ce530 | [] | no_license | zhyss/linux-server-examples | c8db4ea365de45d991305006163ee7bda2d6eeb7 | b16f257f58348d5e4299999e49a085dd46521a07 | refs/heads/main | 2023-07-18T07:07:00.036128 | 2021-09-05T09:25:53 | 2021-09-05T09:25:53 | 334,066,400 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,655 | cpp | #include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys/epoll.h>
#include <fcntl.h>
#include "time_wheel_timer.h"
#define FD_LIMIT 65535
#define MAX_EVENT_NUMBER 1024
#define TIMESLOT 1
static int pipefd[2];
/* timer */
static time_wheel timer_lst;
static int epollfd = 0;
int setnonblocking(int fd)
{
int old_option = fcntl(fd, F_GETFL);
int new_option = old_option | O_NONBLOCK;
fcntl(fd, F_SETFL, new_option);
return old_option;
}
void addfd(int epollfd, int fd)
{
epoll_event event;
event.data.fd = fd;
event.events = EPOLLIN | EPOLLET;
epoll_ctl( epollfd, EPOLL_CTL_ADD, fd, &event);
setnonblocking( fd );
}
/* signal chuli */
void sig_handler( int sig )
{
int save_errno = errno;
int msg = sig;
send(pipefd[1], ( char* )&msg, 1, 0);
errno = save_errno;
}
/* set signal's chuli function */
void addsig( int sig )
{
struct sigaction sa;
memset( &sa, '\0', sizeof( sa ));
sa.sa_handler = sig_handler;
sa.sa_flags |= SA_RESTART;
sigfillset( &sa.sa_mask);
assert( sigaction( sig, &sa, NULL ) != -1 );
}
void timer_handler()
{
timer_lst.tick();
alarm( TIMESLOT );
}
void cb_func( client_data* user_data )
{
epoll_ctl(epollfd, EPOLL_CTL_DEL, user_data->sockfd, 0 );
assert( user_data );
close( user_data->sockfd );
printf( "close fd %d\n", user_data->sockfd );
}
int main(int argc, char* argv[])
{
const char* ip = "192.168.31.59";
int port = 54321;
int ret = 0;
/* create a ipv4 socket address */
struct sockaddr_in address;
bzero(&address, sizeof(address));
address.sin_family = AF_INET;
inet_pton(AF_INET, ip, &address.sin_addr);
address.sin_port = htons(port);
/* create a TCP socket */
int listenfd = socket(PF_INET, SOCK_STREAM, 0);
assert(listenfd >= 0);
ret = bind(listenfd, (struct sockaddr*)&address, sizeof(address));
assert(ret != -1);
ret = listen(listenfd, 5);
assert(ret != -1);
epoll_event events[ MAX_EVENT_NUMBER ];
int epollfd = epoll_create( 5 );
assert( epollfd != -1 );
addfd(epollfd, listenfd);
/* use socketpair create pipe*/
ret = socketpair( PF_UNIX, SOCK_STREAM, 0, pipefd);
assert( ret != -1 );
setnonblocking( pipefd[1] );
addfd( epollfd, pipefd[0] );
addsig( SIGALRM );
addsig( SIGTERM );
bool stop_server = false;
client_data* users = new client_data[FD_LIMIT];
bool timeout = false;
alarm( TIMESLOT );
while(!stop_server)
{
int number = epoll_wait( epollfd, events, MAX_EVENT_NUMBER, -1 );
if( ( number < 0 ) && ( errno != EINTR ))
{
printf( "epoll failure\n" );
break;
}
for( int i = 0; i < number; i++)
{
int sockfd = events[i].data.fd;
if( sockfd == listenfd )
{
struct sockaddr_in client_address;
socklen_t client_addrlength = sizeof(client_address);
int connfd = accept(listenfd, ( struct sockaddr* )&client_address, &client_addrlength );
addfd(epollfd, connfd);
users[connfd].address = client_address;
users[connfd].sockfd = connfd;
/* timer */
//tw_timer* timer = new tw_timer;
tw_timer* timer = timer_lst.add_timer(10);
timer->user_data = &users[connfd];
timer->cb_func = cb_func;
//time_t cur = time(NULL);
//timer->expire = 5 * TIMESLOT;
users[connfd].timer = timer;
//timer_lst.add_timer( timer );
}
else if( ( sockfd == pipefd[0] ) && ( events[i].events & EPOLLIN ) )
{
int sig;
char signals[1024];
ret = recv( pipefd[0], signals, sizeof( signals ), 0 );
if( ret == -1 )
{
continue;
}
else if( ret == 0 )
{
continue;
}
else
{
for(int i=0; i<ret; ++i)
{
switch( signals[i])
{
case SIGALRM:
{
timeout = true;
break;
}
case SIGTERM:
{
stop_server = true;
}
}
}
}
}
else if ( events[i].events & EPOLLIN )
{
memset( users[sockfd].buf, '\0', BUFFER_SIZE );
ret = recv(sockfd, users[sockfd].buf, BUFFER_SIZE-1, 0);
printf("get %d bytes of client data %s from %d\n", ret, users[sockfd].buf, sockfd);
tw_timer* timer = users[sockfd].timer;
if( ret < 0 )
{
if(errno != EAGAIN )
{
cb_func( &users[sockfd]);
if( timer )
{
timer_lst.del_timer( timer );
}
}
}
else if( ret == 0)
{
cb_func(&users[sockfd]);
if( timer )
{
timer_lst.del_timer( timer );
}
}
else
{
if(timer)
{
printf("adjust timer once\n");
//timer_lst.adjust_timer( timer );
timer_lst.del_timer(timer);
tw_timer* timer = timer_lst.add_timer(10);
timer->user_data = &users[sockfd];
timer->cb_func = cb_func;
users[sockfd].timer = timer;
}
}
}
else
{
/* code */
}
}
if( timeout )
{
timer_handler();
timeout = false;
}
}
close( listenfd );
close( pipefd[1] );
close( pipefd[0] );
delete [] users;
return 0;
}
| [
"[email protected]"
] | |
b9b77ec3283afe7f17a5dfa08c69ee8429e58d61 | 4a7494ac83a0359ae22a15ad6a989f943b299400 | /BaseDataTypes/OperatChar/Main.cpp | caea485045e15caf3a8c95f1230f49217b23ef75 | [] | no_license | ZyxEforce/Routine | 1cc001d7419be7707ca1f3e82ec6f0694739b710 | 5f132caea998364f645f6ccd8586928cb4be7c74 | refs/heads/master | 2020-04-27T15:36:15.788294 | 2019-03-19T06:54:59 | 2019-03-19T06:54:59 | 174,452,671 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 384 | cpp | #include<stdio.h>
void GetChar2Put();
void GetChar2PutB();
int main()
{
GetChar2PutB();
GetChar2Put();
return 0;
}
/*copy input to output; 1st version*/
void GetChar2Put()
{
int c_var;
while((c_var = getchar()) != EOF)
{
putchar(c_var);
}
}
void GetChar2PutB()
{
bool b_var = (getchar() != EOF);
printf("getchar() != EOF:%d\n", b_var);
} | [
"[email protected]"
] | |
4a6e12bca6b5aee8318c6ad5f4e51b97807cd3ae | 0009080def481681386ae0ceac317c0a83b66653 | /cpp_d13/ex06/Toy.cpp | e5d86b97b7a85784c54379aa3c052447325680ed | [] | no_license | BruhJerem/EPITECH_TEK2_POOL | aaeaac1e276b82e745dcb1d7b28788cf65972649 | 54be4997ba9793266cb5360c577fd94cfd043451 | refs/heads/master | 2021-09-08T00:59:04.560652 | 2018-03-04T22:17:06 | 2018-03-04T22:17:06 | 122,841,365 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,359 | cpp | //
// EPITECH PROJECT, 2018
// cpp_d13
// File description:
//
//
#include "Toy.hpp"
Toy::Toy(const ToyType &type, const std::string &name, const std::string &file)
{
this->_type = type;
this->_name = name;
this->_picture = Picture(file);
this->_error = Error();
}
Toy::Toy()
{
this->_type = BASIC_TOY;
this->_name = "toy";
this->_picture = Picture();
}
Toy::ToyType Toy::getType()
{
return _type;
}
std::string Toy::getName() const
{
return _name;
}
void Toy::setName(const char *name)
{
_name = name;
}
bool Toy::setAscii(const std::string &data)
{
this->_picture = Picture(data);
if (this->_picture.data == "ERROR") {
this->_error.setType(Error::PICTURE);
return false;
}
return true;
}
std::string Toy::getAscii() const
{
return _picture.data;
}
Toy &Toy::operator=(const Toy &toy)
{
this->_name = toy._name;
this->_type = toy._type;
this->_picture = toy._picture;
return *this;
}
bool Toy::speak(const std::string statement)
{
std::cout << this->_name << " \"" << statement << "\"\n";
return true;
}
bool Toy::speak_es(const std::string statement)
{
(void)statement;
this->_error.setType(Error::SPEAK);
return false;
}
Toy &Toy::operator<<(const std::string &data)
{
this->setAsciiFromString(data);
return *this;
}
void Toy::setAsciiFromString(const std::string &data)
{
this->_picture.data = data;
}
/* Error Handling */
/* Constructor Error */
Toy::Error::Error()
{
this->type = Toy::Error::UNKNOWN;
this->_where = "";
this->_what = "";
}
std::string Toy::Error::what()
{
if (this->type == Toy::Error::PICTURE)
this->_what = "bad new illustration";
else if (this->type == Toy::Error::SPEAK)
this->_what = "wrong mode";
else
this->_what = "";
return this->_what;
}
std::string Toy::Error::where()
{
if (this->type == Toy::Error::PICTURE)
this->_where = "setAscii";
else if (this->type == Toy::Error::SPEAK)
this->_where = "speak_es";
else
this->_where = "";
return this->_where;
}
void Toy::Error::setType(ErrorType type)
{
this->type = type;
}
Toy::Error Toy::getLastError()
{
return this->_error;
}
/* Print Ofstream */
std::ostream &operator<<(std::ostream &s, const Toy &toy)
{
s << toy.getName();
s << std::endl;
s << toy.getAscii();
s << std::endl;
return s;
}
| [
"[email protected]"
] | |
732d4da32896fbfcb7efd1b98ca5b90ee879b0d5 | a800e658a6fe251f625a5365390f18b3e448b736 | /Construct Binary Tree from Inorder and Postorder Traversal/Accepted-144ms-11071928.cpp | 2221bbd927effeee44763eda2cdc321eaf3d7eec | [] | no_license | gitzhou/leetcode-oj-submissions | 2a695ce3307f1a16a9a8c578d0775c57fec4cf79 | 0f7a3c4ef25504d8ad6e75e79613a4cafa99412f | refs/heads/master | 2021-07-09T18:19:12.822239 | 2020-09-01T08:00:56 | 2020-09-01T08:00:56 | 24,507,197 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,666 | cpp | //
// Generated by fetch-leetcode-submission project on GitHub.
// https://github.com/gitzhou/fetch-leetcode-submission
// Contact Me: aaron67[AT]aaron67.cc
//
// Construct Binary Tree from Inorder and Postorder Traversal
// https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/
//
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode *buildTree(vector<int> &inorder, vector<int> &postorder) {
return build(inorder, 0, inorder.size(), postorder, 0, postorder.size());
}
private:
// inorder[inorderi, inorderj)
// postorder[postorderi, postorderj)
TreeNode *build(const vector<int> &inorder, size_t inorderi, size_t inorderj,
const vector<int> &postorder, size_t postorderi, size_t postorderj) {
if (inorderi == inorderj || postorderi == postorderj) {
return NULL;
}
int val = postorder[postorderj - 1];
TreeNode *node = new TreeNode(val);
size_t inorderMid = inorderi, postOrderMid = postorderi;
while (inorderMid < inorderj) {
if (inorder[inorderMid] == val) {
break;
}
++inorderMid;
++postOrderMid;
}
node->left = build(inorder, inorderi, inorderMid, postorder, postorderi, postOrderMid);
node->right = build(inorder, inorderMid + 1, inorderj, postorder, postOrderMid, postorderj - 1);
return node;
}
};
| [
"[email protected]"
] | |
29d866f0ef87de31d4fcae015f4486840ebcec5b | 05fd3ac0e61f5eee408578a264d5e05a2f43aa83 | /tools/ASMTester.cpp | dd37d66a1d6826c0cf59b1a17f367bcc21ce50b4 | [] | no_license | 3x1l3/cpsc4600-project | 087a3155e5e7381790b3bfe8a1191c22ca61eda0 | 09d4047a2d2dc4a9e23cf5a009ce9c84b41c9824 | refs/heads/master | 2020-05-05T06:23:49.779743 | 2012-04-21T05:11:58 | 2012-04-21T05:11:58 | 32,120,000 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,641 | cpp | /**
* @brief A file for testing completed ASM files with the Assembler.
*
* Takes an input .asm file and assembles it,
* sending the completed file to a test.itp file.
*/
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include "assembler.h"
using std::stringstream;
using std::cout;
using std::cin;
using std::string;
int main(int argc, char* argv[])
{
string ASMSourceFile;
//Deal with our arguments
if(argc == 1)
{
cout << "\nYou did not specify an input file. Using \"test.asm\"." << endl;
ASMSourceFile = "test.asm";
}
else
{
//set out interp file string.
ASMSourceFile = "";
ASMSourceFile.append(argv[1]);
}
std::ifstream asmStringFile;
asmStringFile.open(ASMSourceFile.c_str());
string inputString;
string temp;
while(asmStringFile.good())
{/*
asmStringFile >> temp;
inputString.append(temp.append("\n"));
cout << "ASM OUTPUT \t" << temp << endl;*/
getline(asmStringFile, temp);
temp += '\n';
inputString += temp;
}
asmStringFile.close();
cout << "Main input string:\n\n" << inputString << endl;
std::ifstream asmFile, asmFile2;
asmFile.open(ASMSourceFile.c_str());
//This will be the file read by our Interpreter.
std::ofstream interpCode("interpInput.itp");
Assembler* myASM = new Assembler( asmFile, interpCode);
//Our actual Assembler passes.
myASM->firstPass();
cerr << "\n\n\nOutputting asdasdasd\n" << inputString << endl;
//Hossain's Assembler does not reset his stream. So we cheat.
myASM->secondPass(inputString);
cout << "Assembly Complete.\n";
return 0;
} | [
"[email protected]@b6dedcac-f8b6-b7c9-e359-98e7ae5e6d10"
] | [email protected]@b6dedcac-f8b6-b7c9-e359-98e7ae5e6d10 |
bc903d3d3485dc4dddab5b57b5d921c1012c9854 | 55cfa1eed966766aeb72e54a1ed6f2591255e5c0 | /LC_1100.cpp | 1b00601bcec5dd77a9f17f158e72905c7badcfe9 | [] | no_license | iCodeIN/leetcode-4 | 1bf2751c861ccf1652b0e5b096595e6874e568e3 | 9081802f99da6cfded421fe10052839bad449fd2 | refs/heads/master | 2023-01-13T07:22:53.362907 | 2020-11-13T03:56:20 | 2020-11-13T03:56:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 525 | cpp | class Solution {
public:
int numKLenSubstrNoRepeats(string S, int K) {
int i,len=S.length(),j,con=0;
if(len<K)
return con;
unordered_map<char,int>mp;
for(i=0;i<K;i++)
mp[S[i]]++;
if(mp.size()==K)
con++;
for(i=K;i<len;i++)
{
mp[S[i-K]]--;
if(mp[S[i-K]]==0)
mp.erase(S[i-K]);
mp[S[i]]++;
if(mp.size()==K)
con++;
}
return con;
}
};
| [
"[email protected]"
] | |
dfac12dd088db774a2942efe392034759e780429 | 6dc1b2d11e9b1612bea869870fb0c113f70c761c | /include/glt.hpp | 38fc8d7298f8eb56ed856320cc5166491f947486 | [
"MIT"
] | permissive | nolanderc/glt | 5fc18e90eb46912524bf4948cff47319cd4cb637 | ab39829c8d9a3d24cfa852f63e97e16e0f106b23 | refs/heads/master | 2021-09-02T04:39:26.692348 | 2017-12-30T11:36:33 | 2017-12-30T11:36:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 115 | hpp | //
// Created by Christofer Nolander on 2017-12-27.
//
#pragma once
#include "vec/vec.hpp"
#include "mat/mat.hpp" | [
"[email protected]"
] | |
7a49743ae671f954818214f7fafc98e7adea4f5a | 482d6d40ac23badf20e7a694d0de4fada04cc0c7 | /SWEA/SWEA_1251/SWEA_1251/소스.cpp | cba9fa202bf8c6f41735ead935c04b777b148f34 | [] | no_license | heechan3006/CS | b0f4662d785033d3542cd8e0cc5e696a5e34f1b4 | 45eef91d3915f445029f2f06bb1e3494c4f775e4 | refs/heads/master | 2020-08-11T14:27:32.032048 | 2020-01-07T08:39:11 | 2020-01-07T08:39:11 | 214,579,503 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,487 | cpp | #include <iostream>
#include <tuple>
#include <memory.h>
#include <vector>
#include <algorithm>
using namespace std;
int N;
long long coord[2][1000];
int connect[1001];
long long find_connect(long long a) {
if (a == connect[a]) return a;
return connect[a] = find_connect(connect[a]);
}
void Union(long long a, long long b) {
a = find_connect(a);
b = find_connect(b);
if (a == b) return;
connect[b] = a;
}
long long dist(long long x1, long long y1, long long x2, long long y2) {
long long d;
d = ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
return d;
}
int main() {
int t;
scanf("%d", &t);
for (int test_case = 1; test_case <= t; test_case++){
memset(connect, 0, sizeof(connect));
memset(coord, 0, sizeof(coord));
scanf("%d", &N);
for (int i = 0; i < 2; i++){
for (int j = 0 ; j < N; j++){
scanf("%llu", &coord[i][j]);
connect[j] = j;
}
}
double e;
scanf("%lf", &e);
vector< tuple<long long, long long, long long>> v;
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
v.push_back(make_tuple(dist(coord[0][i], coord[1][i], coord[0][j], coord[1][j]), (long long) i, (long long) j));
}
}
sort(v.begin(), v.end());
long long ans = 0;
for (auto it = v.begin(); it != v.end(); it++) {
long long x = get<1>((*it));
long long y = get<2>((*it));
if (find_connect(x) == find_connect(y)) {
continue;
}
ans += get<0>((*it));
Union(x, y);
}
e = ans * e;
printf("#%d %.0f\n",test_case, e);
}
} | [
"[email protected]"
] |
Subsets and Splits