blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
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
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 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
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
da53251837e8e58ab415062d369c2ede51d097f2
8e7ef8f67ba8bc3cd5ad37376c3570559d8ccbbb
/Client/Client.cpp
e652242835d8dec2d376dc6cd1a7bfd5bc7dc79e
[]
no_license
CongGroup/IWQoS-18
648b8a6dc91f0e386b82748108bf47e3fdbc7d82
3d05844e1738d73ef5b9eece70e2872e1fd49666
refs/heads/master
2020-03-11T07:28:57.628549
2018-04-17T07:37:33
2018-04-17T07:37:33
129,857,927
1
0
null
null
null
null
UTF-8
C++
false
false
4,616
cpp
#include <string> #include <cstring> #include <cstdint> #include <iostream> #include "config.h" #include "TMiddleBoxService.h" #include "../Caravel/ThriftAdapt.h" #include "../Caravel/TimeDiff.h" #include "../FastORE/OREHelper.h" #include "ClientCpp.h" #include "Header.h" using namespace std; using namespace caravel; using namespace MiddleBoxServer; int main(int argc, char ** argv) { if (argc == 6) { ClientCpp clientcpp; char* headerFileName = "\0"; int type = 0; int slices = 1; char* ruleFileName = "\0"; char* baseOutputName = "\0"; char* serverIP = "\0"; int ruleCount = 0; //which middle to connect int middleBoxID; headerFileName = argv[1]; sscanf(argv[2], "%d", &clientcpp.usedPackageCount); //sscanf(argv[3], "%d", &usePackageLoc); sscanf(argv[3], "%d", &type); //sscanf(argv[4], "%d", &slices); baseOutputName = argv[4]; sscanf(argv[5], "%d", &middleBoxID); //ruleFileName = argv[5]; //sscanf(argv[6], "%d", &ruleCount); if (clientcpp.usedPackageCount == 0) { clientcpp.usedPackageCount = INT32_MAX; } if (ruleCount == 0) { ruleCount = INT32_MAX; } if (strlen(ruleFileName) > 2) { clientcpp.setRuleFile(ruleFileName, ruleCount); } if (slices < 1) slices = 1; type = 1; bool setNormal = type & 0x1; bool setBit = type & 0x2; bool setState = type & 0x4; bool setHitTest = type & 0x8; //test package hit at loacl if (setHitTest&&clientcpp.getTester()->available()) { clientcpp.loadHeader(headerFileName); clientcpp.hitTest(); string filename = baseOutputName; filename.append("-hit.csv"); clientcpp.getTableReport(filename); return 0; } switch (middleBoxID) { case 1: { serverIP = MIDDLEBOX1; break; } case 2: { serverIP = MIDDLEBOX2; break; } case 3: { serverIP = MIDDLEBOX3; break; } case 4: { serverIP = MIDDLEBOX4; break; } case 5: { serverIP = MIDDLEBOX5; break; } default: { cout << "Wrong middle box id" << endl; return 0; } } //connect to thrift ThriftAdapt<TMiddleBoxServiceClient> thriftAdapt; int middleBoxPort = 9090; thriftAdapt.Init(serverIP, middleBoxPort); thriftAdapt.Open(); TMiddleBoxServiceClient* client = thriftAdapt.GetClient(); cout << "Finish connect to server." << endl; clientcpp.loadHeader(headerFileName); uint32_t useTime = 0; uint32_t hitNum = 0; cout << endl; //clientcpp.computeSize(slices); if (setNormal) { cout << "In normal package"<< endl; hitNum = clientcpp.sendHeader(client, false, false); cout << "Total " << clientcpp.getpHeaders()->size() << " packages, and hit " << hitNum << " packages" << endl; //clientcpp.computeLatency(slices); string filename = baseOutputName; filename.append(".csv"); clientcpp.getTableReport(filename); } if (setBit) { cout << endl << "In Set Bit" << endl; hitNum = clientcpp.sendHeader(client, true, false); cout <<"Total " << clientcpp.getpHeaders()->size() << " packages, and hit " << hitNum << " packages" << endl; //clientcpp.computeLatency(slices); string filename = baseOutputName; filename.append("-bit.csv"); clientcpp.getTableReport(filename); } if (setState) { cout << endl << "In Set State" << endl; hitNum = clientcpp.sendHeader(client, false, true); cout << "Total " << clientcpp.getpHeaders()->size() << " packages, and hit " << hitNum << " packages" << endl; //clientcpp.computeLatency(slices); string filename = baseOutputName; filename.append("-state.csv"); clientcpp.getTableReport(filename); } if (!setNormal && !setBit && !setState) { string filename = baseOutputName; filename.append("-package.csv"); clientcpp.getTableReport(filename); } thriftAdapt.Close(); return 0; } else { cout << "Usage: Latency HeaderFIle PackageNum Type OutputFile MiddleBox " << endl; cout << endl; cout << "[HeaderFile] = > The file name of header. " << endl; cout << "[PackageNum] = > The count of package to use. " << endl; cout << "[Type] = > 1: normal 2:setBit 4:setState. " << endl; cout << "[OutputFile] = > The file name of OutputFile. " << endl; cout << "[MiddleBox] = > The ID of MiddleBox. " << endl; //cout << "[RuleFile] = > The file of rules. " << endl; //cout << "[RuleCount] = > The use count of rules. " << endl; //cout << "[Slice] = > The latency sliced sheet count." << endl; //cout << "[PackageOffset] = > Use package begin of this. " << endl; cout << endl; return -1; } }
[ "mengycs@gmai..com" ]
mengycs@gmai..com
5214f778cc0c6242430bdcefd958d63e588a92f6
0a443bd0a525fc81c55639a797a601ef5482d7b3
/SuperMarket.cpp
9c05fa08d9039bf736f891118bc11dd650f5e283
[]
no_license
JPValiente/supermarketmanager
b85793b549ca22bf2def380afe552c47b7402b46
d2dec0669b58738939303b3c100e29c34b1dd826
refs/heads/master
2020-06-05T01:06:13.189362
2019-06-19T05:36:54
2019-06-19T05:36:54
192,260,006
0
0
null
null
null
null
UTF-8
C++
false
false
4,101
cpp
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ #include <iostream> #include <stdio.h> #include <stdlib.h> #include <ctime> #include <unistd.h> #include <thread> //#include <pthread.h> #include "SuperMarket.h" #include "Pila.h" #include "Cola.h" #include "ListaDoble.h" #include "ListaCircular.h" using namespace std; void SuperMarket::agregarClienteAEspera(Nodo* cliente){ this->clientes->encolar(cliente); } SuperMarket::SuperMarket() { } bool SuperMarket::hayCarretas(){ Nodo *carretaSaliendo; if(!pilaCarreta1->estaVacia()) { } else if(!pilaCarreta2->estaVacia()){ } else { cout<<"No hay carretas disponibles en este momento, cliente en espera"<<endl; return false; } return true; } Nodo* SuperMarket::sacarCarreta(){ Nodo *carretaSaliendo; if(!pilaCarreta1->estaVacia()) { carretaSaliendo = pilaCarreta1->desapilar(); } else if(!pilaCarreta2->estaVacia()){ carretaSaliendo = pilaCarreta2->desapilar(); } else { cout<<"No hay carretas disponibles en este momento, cliente en espera"<<endl; return nullptr; } return carretaSaliendo; } void SuperMarket::asignarCarretaACliente(Nodo* cliente,Nodo* carreta){ cliente->info = carreta; } /* if(clientes->estaVacia()){ Nodo *clienteSaliendo = clientes->descolar(); clienteSaliendo->info = carretaSaliendo; agregarACompras(clienteSaliendo); } else { cout<<"No hay mas clientes que atender"<<endl; return false; } */ Nodo* SuperMarket::sacarClienteDeCompras(){ int totalClientes = this->clientesComprando->totalElementos; srand((int)time(0)); int random = (rand() % 100) + 1; if(random <= totalClientes) { Nodo* cliente = clientesComprando->borrar(random); return cliente; } else { cout<<"No se hizo nada porque el numero random fue "<<random<<" y se esperaba un numero menos de "<<totalClientes<<endl; return nullptr; } } bool SuperMarket::encolarCliente(Nodo* cliente){ this->colaDePagos->encolar(cliente); } void SuperMarket::agregarACompras(Nodo* cliente){ this->clientesComprando->insertar(cliente); } bool SuperMarket::guardarCarreta(Nodo* carreta){ srand((int)time(0)); int pila = (rand() % 2) + 1; if(pila == 1){ this->pilaCarreta1->apilar(carreta); cout<<"Carreta "<<carreta->id<<" guardada en la pila 1"<<endl; } else { this->pilaCarreta2->apilar(carreta); cout<<"Carreta "<<carreta->id<<" guardada en la pila 2"<<endl; } } NodoCaja* SuperMarket::asignarClienteACaja(){ Nodo* cliente = this->colaDePagos->descolar(); NodoCaja* aux = this->cajas->inicio; bool flag = false; while(aux->siguiente != nullptr){ if(!aux->ocupado){ flag = true; break; } aux = aux->siguiente; } if(flag){ aux->ocupado = true; aux->cliente = cliente; return aux; } else { cout<<"Todas las cajas estan ocupadas"<<endl; return nullptr; } } void SuperMarket::atenderEnCaja(NodoCaja* caja){ sleep(caja->tiempoDeServicio); Nodo* carreta = (Nodo*)caja->cliente->info; cout<<"Cliente: "<<caja->cliente->id<<" atendido en caja "<<caja->id<<"."<<endl; caja->vaciarCaja(); this->guardarCarreta(carreta); } Nodo* SuperMarket::crearCliente(int id){ Nodo* nuevoCliente = new Nodo(id,nullptr); return nuevoCliente; } NodoCaja* SuperMarket::crearCaja(int id){ NodoCaja* nuevaCaja = new NodoCaja(id); return nuevaCaja; } Nodo* SuperMarket::crearCarreta(int id){ Nodo* carreta = new Nodo(id,nullptr); return carreta; } void SuperMarket::agregarCajaAlSistema(NodoCaja* caja){ this->cajas->insertar(caja); }
[ "anclenius@gmail.com" ]
anclenius@gmail.com
4e8300150d7f0ec8aeb9314bbadd3be24d8ea5ce
cd1f25c01cfe4bd596fd38d0226c469772351a50
/CBP/src/qt/tradingdialog.h
878bf574dfdcf555c60470ea4c30aa811c67d59d
[ "MIT" ]
permissive
Crypto-Block-Pay/CBP
74a7f7fd1b52ab09101e5be5e8e2760b18375b26
cf0a3b8b70efa8879de7902659c9b4c1dde8423e
refs/heads/master
2020-03-21T11:02:41.049666
2018-06-29T20:54:18
2018-06-29T20:54:18
138,486,046
0
0
null
null
null
null
UTF-8
C++
false
false
3,714
h
#ifndef TRADINGDIALOG_H #define TRADINGDIALOG_H #include <QDialog> #include <QObject> #include <stdint.h> #include "ui_tradingdialog.h" #include "clientmodel.h" #include "walletmodel.h" #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include <QJsonObject> #include <QJsonArray> namespace Ui { class tradingDialog; } class WalletModel; class tradingDialog : public QDialog { Q_OBJECT public: explicit tradingDialog(QWidget *parent = 0); ~tradingDialog(); void setModel(WalletModel *model); private slots: void InitTrading(); void on_TradingTabWidget_tabBarClicked(int index); void ParseAndPopulateOrderBookTables(QString Response); void ParseAndPopulateMarketHistoryTable(QString Response); void ParseAndPopulateAccountHistoryTable(QString Response); void ParseAndPopulateOpenOrdersTable(QString Response); void UpdaterFunction(); void CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader); void DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response); void DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2); void DisplayBalance(QLabel &BalanceLabel, QString Response); void ActionsOnSwitch(int index); void CancelOrderSlot(int row, int col); void on_UpdateKeys_clicked(bool Save=false, bool Load=false); void on_LoadKeys_clicked(); void on_SaveKeys_clicked(); void on_GenDepositBTN_clicked(); void CalculateBuyCostLabel(); void on_Buy_Max_Amount_clicked(); void on_BuyBidcomboBox_currentIndexChanged(const QString &arg1); void on_UnitsInput_textChanged(const QString &arg1); void on_BuyBidPriceEdit_textChanged(const QString &arg1); void on_BuyCBP_clicked(); void CalculateSellCostLabel(); void on_Sell_Max_Amount_clicked(); void on_SellBidcomboBox_currentIndexChanged(const QString &arg1); void on_UnitsInputCBP_textChanged(const QString &arg1); void on_SellBidPriceEdit_textChanged(const QString &arg1); void on_SellCBPBTN_clicked(); void CalculateCSReceiveLabel(); void on_CSUnitsInput_textChanged(const QString &arg1); void on_CSUnitsBtn_clicked(); void on_CS_Max_Amount_clicked(); void on_Withdraw_Max_Amount_clicked(); void on_WithdrawUnitsBtn_clicked(); void on_KeyPasteButton_clicked(); void on_SecretPasteButton_clicked(); void on_CSPasteButton_clicked(); void on_WithdrawPasteButton_clicked(); void on_DepositCopyButton_clicked(); int SetExchangeInfoTextLabels(); QString BittrexTimeStampToReadable(QString DateTime); QString CancelOrder(QString Orderid); QString BuyCBP(QString OrderType, double Quantity, double Rate); QString SellCBP(QString OrderType, double Quantity, double Rate); QString Withdraw(double Amount, QString Address, QString Coin); QString GetMarketHistory(); QString GetMarketSummary(); QString GetOrderBook(); QString GetOpenOrders(); QString GetAccountHistory(); QString GetBalance(QString Currency); QString GetDepositAddress(); QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); QString sendRequest(QString url); string encryptDecrypt(string toEncrypt, string password); QJsonObject GetResultObjectFromJSONObject(QString response); QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); public slots: private: Ui::tradingDialog *ui; //Socket *socket; int timerid; QTimer *timer; QString ApiKey; QString SecretKey; WalletModel *model; }; #endif // TRADINGDIALOG_H
[ "info@magtvireland.com" ]
info@magtvireland.com
26e6ea8e5036014c23699d00ef9ab8a06802d888
fb2707e4b05250576fcc4c84950c40d3c17346a2
/trex/utils/bits/SingletonDummy.hh
14e2b3118e09f942a9aff15dcdb32bc69bf5bdff
[ "BSD-3-Clause" ]
permissive
fredpy/trex2-agent
649d4b0b3b8f24e38620ccb3f31f99db3cd62af3
156bb198b7d058b54f710331da3b008a68a51793
refs/heads/trex_stable
2021-11-23T11:32:10.087191
2021-10-26T11:44:29
2021-10-26T11:44:29
32,430,406
14
15
null
2017-06-28T08:23:33
2015-03-18T01:20:53
C++
UTF-8
C++
false
false
4,880
hh
/** @file "SingletonDummy.hh" * @brief Defintion of the SingletonDummy class * * This header is for internal use and define an * abstract definition of the SingletonWrapper * used to create and manipulate phoenix singletons * internally * * @author Frederic Py <fpy@mbari.org> * @ingroup utils */ /********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2011, MBARI. * 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 TREX Project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef H_SingletonDummy # define H_SingletonDummy # include <string> # include <boost/utility.hpp> # include "SingletonServer_fwd.hh" namespace TREX { namespace utils { namespace internal { class SingletonDummy; /** @brief Abstract factor for singleton * * This functor provides an abstract functor to produce new * singleton wrappers * * @author Frederic Py * * @relates SingletonDummy * @ingroup utils */ struct sdummy_factory { /** @brief Destructor */ virtual ~sdummy_factory() {}; /** @brief singelton wrapper creation * * This class is used by SingletonServer to crweates * the wrapper for a given singleton when this one does * not exist yet. * * @return The newly created singleton wrapper */ virtual SingletonDummy *create() const =0; }; // TREX::utils::internal::sdummy_factory /** @brief Abstract class for singleton control * * This class implements the general utilites used to control * the lifetime of a phoenix singleton. It is derived by * SingeltonWrapper that is the class that really encapsulates * the singleton instance. This class just provide an abstract * entry point to ease the registering andf life-time control * of the singletons. * * @author Frederic Py <fpy@mbari.org> * @ingroup utils */ class SingletonDummy: boost::noncopyable { protected: /** @brief Constructor */ SingletonDummy(); /** @brief Destructor */ virtual ~SingletonDummy() =0; /** @brief Singleton creation * @param name singleton identifier * @param factory singleton creation functor * * This method connect to the SingletonServer and looks for * the existance of the wrapper to the key @a name if this one * does not exist, it uses @a factory to create this neew entry * in the server. * * @post A new singleton is attached to the identifier @a name * @sa SingletonDummy *sdummy_factory::create() */ static SingletonDummy *attach(std::string const &name, sdummy_factory const &factory); /** @brief reference end notification * @param name singleton identifier * * This methods notifies that the singleton @a name just lost * one reference. If the count reach 0 this singleton is then * destroyed from the SingletonServer */ static void detach(std::string const &name); static void disable(); private: /** @brief reference counting increment */ void incr_ref() const; /** @brief reference counting decrement */ bool decr_ref() const; /** @brief reference counter */ mutable size_t ref_counter; friend class SingletonServer; }; // TREX::utils::internal::SingletonDummy } } } #endif // H_SingletonDummy
[ "fredpy@gmail.com@eff219cc-a5a7-32d8-cb09-f88e880e2402" ]
fredpy@gmail.com@eff219cc-a5a7-32d8-cb09-f88e880e2402
0ebe921b8c0ce4a5d5b8ceadbd1684a729f6991f
1210453e38968431db342cc34260b281db07b923
/example-AllComponentsGui/src/ofApp.h
09e4b95c3130b530bb7c9ef8cc1be6b3aee516cb
[ "MIT" ]
permissive
braitsch/ofxDatGui
d56d08c88e906dad07e7afae13a3a6e26d889bf9
21dadfe612c16bf364d9bcdfe5a6055ab4eb2891
refs/heads/master
2023-08-07T05:00:58.808296
2018-12-17T22:07:56
2018-12-17T22:07:56
41,451,953
485
129
NOASSERTION
2022-01-26T14:21:28
2015-08-26T21:59:31
C++
UTF-8
C++
false
false
817
h
#pragma once #include "ofMain.h" #include "ofxDatGui.h" class ofApp : public ofBaseApp{ public: void setup(); void draw(); void update(); ofxDatGui* gui; bool mFullscreen; void refreshWindow(); void toggleFullscreen(); void keyPressed(int key); void onButtonEvent(ofxDatGuiButtonEvent e); void onToggleEvent(ofxDatGuiToggleEvent e); void onSliderEvent(ofxDatGuiSliderEvent e); void onTextInputEvent(ofxDatGuiTextInputEvent e); void on2dPadEvent(ofxDatGui2dPadEvent e); void onDropdownEvent(ofxDatGuiDropdownEvent e); void onColorPickerEvent(ofxDatGuiColorPickerEvent e); void onMatrixEvent(ofxDatGuiMatrixEvent e); uint tIndex; vector<ofxDatGuiTheme*> themes; };
[ "stephen@braitsch.io" ]
stephen@braitsch.io
9e58139ca15a65e3f46c4bc9807a7aed0d0d57ca
a93593acd72dccc2bf92d349c8ffd619f2dd1be0
/NameRunner/NameRunner/proj.win32/Map.h
6d098700d4d1c6dccb3cc193145842ec9a6ea1a5
[]
no_license
opp0615/batwing
0586ee08e377bee70df1c608f87be540601a648d
414ca0b50badba58893587da618d26477454afb0
refs/heads/master
2016-09-06T19:33:48.918485
2014-02-17T02:47:44
2014-02-17T02:47:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
274
h
#pragma once #include "cocos2d.h" using namespace cocos2d; class Map { private: CCSprite* m_map1; CCSprite* m_map2; int m_game_speed; int width,height; public: Map(CCSprite* g_map1,CCSprite* g_map2,int g_game_speed); void Scrolling(); CCSprite* getMap(int n); };
[ "opp0615@naver.com" ]
opp0615@naver.com
b097f5f33f6bd79dc5c9b13b95a63c74f0433ed8
a92b18defb50c5d1118a11bc364f17b148312028
/src/prod/src/retail/native/FabricDnsService/fabric/FabricAsyncOperationCallback.h
89a5b77f32bb7c3650352b233a5bdcb628ca3361
[ "MIT" ]
permissive
KDSBest/service-fabric
34694e150fde662286e25f048fb763c97606382e
fe61c45b15a30fb089ad891c68c893b3a976e404
refs/heads/master
2023-01-28T23:19:25.040275
2020-11-30T11:11:58
2020-11-30T11:11:58
301,365,601
1
0
MIT
2020-11-30T11:11:59
2020-10-05T10:05:53
null
UTF-8
C++
false
false
1,255
h
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #pragma once namespace DNS { using ::_delete; class FabricAsyncOperationCallback : public KShared<FabricAsyncOperationCallback>, public IFabricAsyncOperationCallback { K_FORCE_SHARED(FabricAsyncOperationCallback); K_BEGIN_COM_INTERFACE_LIST(FabricAsyncOperationCallback) K_COM_INTERFACE_ITEM(__uuidof(IUnknown), IFabricAsyncOperationCallback) K_COM_INTERFACE_ITEM(IID_IFabricAsyncOperationCallback, IFabricAsyncOperationCallback) K_END_COM_INTERFACE_LIST() public: static void Create( __out FabricAsyncOperationCallback::SPtr& spCallback, __in KAllocator& allocator ); public: virtual void Invoke( __in IFabricAsyncOperationContext *context ); public: bool Wait( __in ULONG timeoutInMilliseconds ); private: Common::ManualResetEvent _event; }; }
[ "noreply-sfteam@microsoft.com" ]
noreply-sfteam@microsoft.com
de9c4034f4db87dc386269571c350a855a8b8767
23389702ae1c5b167672cfef069fcb7e99025e2c
/lab5/lab5/lab5/BinarySearchTreeNode.h
c701949c715da6dafb645baf9c130380b9a7baab
[]
no_license
verdande2/CST276-Design-Patterns-Winter-13
07d11378a56394b0ad5219dfc9825592e0ef8788
bf1919031e13ebeb7e34f37e1276d7c76caa5481
refs/heads/master
2020-09-23T03:19:58.396694
2016-08-23T17:10:14
2016-08-23T17:10:14
66,387,169
0
0
null
null
null
null
UTF-8
C++
false
false
9,507
h
/************************************************************************ * Class: BinarySearchTreeNode * * Purpose: This class is a node of a binary search tree. * * Manager functions: * BinarySearchTreeNode() * BinarySearchTreeNode(Node* left, Node* right, T data) * BinarySearchTreeNode(T data) * BinarySearchTreeNode(Node const& copy) * Various constructors to set up the object with the given parameters. * ~BinarySearchTreeNode() * destructor * operator=() * Assignment operator * * Methods: * GetData() * Returns node's data * isInTree(T data) * returns true is data is in the tree, false otherwise * Insert(T data) * Inserts data into the tree * InOrderTraversal() * PreOrderTraversal() * PostOrderTraversal() * BreadthFirstTraversal() * Various traversal methods for hte tree * *************************************************************************/ #pragma once #include <queue> using std::queue; template <class T> class BinarySearchTreeNode { private: BinarySearchTreeNode<T>* m_left; BinarySearchTreeNode<T>* m_right; T m_data; BinarySearchTreeNode(void); BinarySearchTreeNode(BinarySearchTreeNode<T>* left, BinarySearchTreeNode<T>* right, T const& data); BinarySearchTreeNode(T const& data); BinarySearchTreeNode(BinarySearchTreeNode<T> const& copy); BinarySearchTreeNode<T> const& operator=(BinarySearchTreeNode<T> const& rhs); void Insert(T const& data); T GetData(void) const; bool isInTree(T const& data) const; void InOrderTraversal(void (*traverseFunc)(T& data)); void PreOrderTraversal(void (*traverseFunc)(T& data)); void PostOrderTraversal(void (*traverseFunc)(T& data)); void BreadthFirstTraversal(void (*traverseFunc)(T& data)); void InOrderTraversal(void (*traverseFunc)(T const& data)) const; void PreOrderTraversal(void (*traverseFunc)(T const& data)) const; void PostOrderTraversal(void (*traverseFunc)(T const& data)) const; void BreadthFirstTraversal(void (*traverseFunc)(T const& data)) const; ~BinarySearchTreeNode(void); public: template <class T> friend class BinarySearchTree; template <class T> friend class BinarySearchTreePreOrderIterator; template <class T> friend class BinarySearchTreeInOrderIterator; template <class T> friend class BinarySearchTreePostOrderIterator; }; /********************************************************************** * Purpose: Various constructors for BinarySearchTreeNodes. Acceptable forms: * Note: "Node" used as shorthand for BinarySearchTreeNode * BinarySearchTreeNode() (default constructor) * BinarySearchTreeNode(T data) (1arg constructor) * BinarySearchTreeNode(Node* left, Node* right, T data) (3arg constructor) * BinarySearchTreeNode(Node) (copy constructor) * * Entry: * Parameters: * data is of type T * left, right, are of type BinarySearchTreeNode* * * Exit: An object is created with the given parameters. * ************************************************************************/ template <class T> BinarySearchTreeNode<T>::BinarySearchTreeNode(void) : m_data(T()), m_left(nullptr), m_right(nullptr) { } template <class T> BinarySearchTreeNode<T>::BinarySearchTreeNode(T const& data) : m_data(data), m_left(nullptr), m_right(nullptr) { } template <class T> BinarySearchTreeNode<T>::BinarySearchTreeNode(BinarySearchTreeNode<T>* left, BinarySearchTreeNode<T>* right, T const& data) : m_data(data), m_left(left), m_right(right) { } template <class T> BinarySearchTreeNode<T>::BinarySearchTreeNode(BinarySearchTreeNode<T> const& copy) : m_data(copy.m_data), m_left(copy.m_left), m_right(copy.m_right) { } /********************************************************************** * Purpose: Assignment operator * * Entry: None. * * Exit: Current object is assigned the same values as the rhs'. Note: INTENTIONAL SHALLOW COPY * ************************************************************************/ template <class T> BinarySearchTreeNode<T> const& BinarySearchTreeNode<T>::operator=(BinarySearchTreeNode<T> const& rhs) { m_data = rhs.m_data; m_left = rhs.m_left; m_right = rhs.m_right; return *this; } /********************************************************************** * Purpose: Destructor * Note: Intentionally does not clean up any children nodes. * That is handled entirely in the tree class. * * Entry: None. * * Exit: Object is destructed * ************************************************************************/ template <class T> BinarySearchTreeNode<T>::~BinarySearchTreeNode(void) { } /********************************************************************** * Purpose: Used to insert data into the tree, only used by tree class * * Entry: * Parameters: * data is of type T * * Exit: Tree now contains data. * ************************************************************************/ template <class T> void BinarySearchTreeNode<T>::Insert(T const& data) { if(data == m_data) // this node is the same as the node being inserted { // either add to left, right, or ignore duplicate data (unique keys) // current implementation is to ignore duplicate data, as searching the // tree is implemented to only find the first node matching key } else if(data > m_data) { if(m_right) { m_right->Insert(data); } else { m_right = new BinarySearchTreeNode<T>(nullptr, nullptr, data); } } else { if(m_left) { m_left->Insert(data); } else { m_left = new BinarySearchTreeNode<T>(nullptr, nullptr, data); } } } /********************************************************************** * Purpose: Returns node's data * ************************************************************************/ template <class T> T BinarySearchTreeNode<T>::GetData(void) const { return m_data; } /********************************************************************** * Purpose: Used to determine if a value is in the tree. * * Entry: * Parameters: * data is of type T * * Exit: Return bool representing if the data was found in the tree. * ************************************************************************/ template <class T> bool BinarySearchTreeNode<T>::isInTree(T const& data) const { bool inTree = false; if(m_data == data) { inTree = true; } else if(data > m_data) { if(m_right) { inTree = m_right->isInTree(data); } } else if(data < m_data) { if(m_left) { inTree = m_left->isInTree(data); } } return inTree; } /********************************************************************** * Purpose: Various traversal methods for the binary search tree. * Includes: * In-order * Pre-order * Post-order * Breadth-First * As well as const flavors of each. * Used for traversing the tree and performing a function on each node's data. * These are all built assuming the current node is the root of the tree, * and traverses through all children of current node. * * Entry: * Parameters: * traverseFunc is a function pointer to a function that takes data * by & or by const& respectively. * * Exit: The object is traversed and the traverseFunc is called on each node's data. * ************************************************************************/ template <class T> void BinarySearchTreeNode<T>::InOrderTraversal(void (*traverseFunc)(T& data)) { if(m_left) { m_left->InOrderTraversal(traverseFunc); } traverseFunc(m_data); if(m_right) { m_right->InOrderTraversal(traverseFunc); } } template <class T> void BinarySearchTreeNode<T>::InOrderTraversal(void (*traverseFunc)(T const& data)) const { if(m_left) { m_left->InOrderTraversal(traverseFunc); } traverseFunc(m_data); if(m_right) { m_right->InOrderTraversal(traverseFunc); } } template <class T> void BinarySearchTreeNode<T>::PreOrderTraversal(void (*traverseFunc)(T& data)) { traverseFunc(m_data); if(m_left) { m_left->PreOrderTraversal(traverseFunc); } if(m_right) { m_right->PreOrderTraversal(traverseFunc); } } template <class T> void BinarySearchTreeNode<T>::PreOrderTraversal(void (*traverseFunc)(T const& data)) const { traverseFunc(m_data); if(m_left) { m_left->PreOrderTraversal(traverseFunc); } if(m_right) { m_right->PreOrderTraversal(traverseFunc); } } template <class T> void BinarySearchTreeNode<T>::PostOrderTraversal(void (*traverseFunc)(T& data)) { if(m_left) { m_left->PostOrderTraversal(traverseFunc); } if(m_right) { m_right->PostOrderTraversal(traverseFunc); } traverseFunc(m_data); } template <class T> void BinarySearchTreeNode<T>::PostOrderTraversal(void (*traverseFunc)(T const& data)) const { if(m_left) { m_left->PostOrderTraversal(traverseFunc); } if(m_right) { m_right->PostOrderTraversal(traverseFunc); } traverseFunc(m_data); } template <class T> void BinarySearchTreeNode<T>::BreadthFirstTraversal(void (*traverseFunc)(T& data)) { queue< BinarySearchTreeNode<T>* > q; q.push(this); BinarySearchTreeNode<T>* ptr = nullptr; while(!q.empty()) { ptr = q.front(); q.pop(); traverseFunc(ptr->m_data); if(ptr->m_left) { q.push(ptr->m_left); } if(ptr->m_right) { q.push(ptr->m_right); } } } template <class T> void BinarySearchTreeNode<T>::BreadthFirstTraversal(void (*traverseFunc)(T const& data)) const { queue< BinarySearchTreeNode<T> const* > q; q.push(this); BinarySearchTreeNode<T> const* ptr = nullptr; while(!q.empty()) { ptr = q.front(); q.pop(); traverseFunc(ptr->m_data); if(ptr->m_left) { q.push(ptr->m_left); } if(ptr->m_right) { q.push(ptr->m_right); } } }
[ "ASparkes@jeldwen.com" ]
ASparkes@jeldwen.com
5aad0e9bfe1156183a577909eedf219fd1cd8862
f648f462fbdd8055b321f44c12e7a6b18a0df1f3
/1369.cpp
e0d9cc8071afb8abb82f55e5c9ca97443cef6e8f
[]
no_license
ShuangjiaMo/OJ
ffb26561c14e9b9c8e5b507ac3f49b28a9bee19f
d219d6cbe028a27ac05c60f72460a715c4a52f24
refs/heads/master
2021-01-21T14:12:16.569083
2016-02-29T11:51:26
2016-02-29T11:51:26
35,718,197
1
0
null
null
null
null
UTF-8
C++
false
false
412
cpp
#include <iostream> using namespace std; int jump(int n, int s, int l) { if(n==0) return 0; else if(n==s) return 1; else if(n==l && l%s != 0) return 1; else if(n==l && l%s == 0) return 2; else if(n>l) return jump(n-s, s, l)+jump(n-l, s, l); } int main() { int n, a, b; long long ans; cin >> n >> a >> b; if (a >= b) ans = jump(n, b, a); else ans = jump(n, a, b); cout << ans; }
[ "1055289361@qq.com" ]
1055289361@qq.com
c637875023c0e0f9f38c0ff7e8b497be8b49530f
08c70a61aea3186ec199d3bf2932cdb3feb6c5b4
/UVA-Online-Judge-Solved-problems/toph pythagorianRocks.cpp
4cfa75da7d3909fc094aae422fe83dd73d5be09e
[]
no_license
Ash-ik/Programming-Problems-Solutions
28d7063eeaa356d3bc1ac28ac770d2bb15d35cff
4950c2c6e5326502f7758a15c82498ea9c96d85b
refs/heads/master
2021-01-12T06:19:20.081560
2017-01-18T11:14:27
2017-01-18T11:14:27
77,342,181
8
3
null
null
null
null
UTF-8
C++
false
false
194
cpp
#include<stdio.h> int maxi(int a,int b) { if(a>b) return a; return b; } int main() { int a,b,c; scanf("%d %d %d",&a,&b,&c); printf("%d\n",maxi(a,maxi(b,c))); return 0; }
[ "ashikcse12@gmail.com" ]
ashikcse12@gmail.com
5d6e536f7da4e59b10df87e272e854e143bf3389
960e1519a2339633b9094fe5dea7695d13eb6854
/Day1/3Looping/digsum.cpp
3c4dd556b87fa356221fe6a3d0c5e9f5453d4f79
[]
no_license
shardik99/psuc-workshop
1425336e695682e5448b834e67971f28c815aba5
0a4d848d54f9dd775bbdbeec53bb0aac2a4707a5
refs/heads/master
2021-07-24T23:57:11.474235
2017-11-04T18:08:38
2017-11-04T18:08:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
260
cpp
//Program to calculate sum of digits of a number #include<iostream> using namespace std; int main(){ int num, sum, dig; cin>>num; sum=0; while(num!=0){ dig=num%10; sum+=dig; num/=10; } cout<<"Sum: "<<sum<<endl; }
[ "shardik99@gmail.com" ]
shardik99@gmail.com
a884cb9b9abefbf860367bfbdd62f5079c9cefbe
9c1c77f33cc17042c09dde624f9f56a24b2a9094
/Classes/LevelConfigUtil.h
c5e1b98fe211b0ae0bf1ea6d9da14ed55c6e08f2
[]
no_license
spocklin/spockTower
9601fda1aa0df3b23176adffb505f99e1ba4ef1c
da20117b3615fd22fab73a9a00c587557c95399b
refs/heads/master
2020-04-06T06:28:03.646344
2016-09-30T10:05:51
2016-09-30T10:05:51
69,004,890
1
1
null
null
null
null
UTF-8
C++
false
false
1,207
h
// // LevelConfigUtil.h // CarrotFantasy // // Created by Yan on 14-9-26. // // #ifndef __CarrotFantasy__LevelConfigUtil__ #define __CarrotFantasy__LevelConfigUtil__ #include "PublicDefine.h" class LevelConfigUtil:public Ref { public: CREATE_INSTANCE_FUNC(LevelConfigUtil); DESTROY_INSTANCE_FUNC(); virtual void loadLevelConfig(); virtual std::tuple<int, int, int, std::vector<std::string>> getLevelConfig()const; virtual std::vector<std::string> getCurLevelTowersInfo()const; virtual int getCurLevelMonsterBatchCount()const; virtual void buildLevelConfig(); virtual int getCurLevelMoney()const; protected: virtual bool init(); protected: int _iCurPageIndex = 0; int _iCurLevelIndex = 0; int _iCurLevelMoney = 0; int _iMonsterBatchCount = 0; std::vector<std::string> *_pEffectTowers = nullptr; private: LevelConfigUtil(); virtual ~LevelConfigUtil(); LevelConfigUtil(const LevelConfigUtil &) = delete; LevelConfigUtil &operator=(const LevelConfigUtil &) = delete; }; #endif /* defined(__CarrotFantasy__LevelConfigUtil__) */
[ "mac@macdeMac-Pro-5.local" ]
mac@macdeMac-Pro-5.local
c2cc42c13bcf20ece58df2ced1e8656cf0eb61fa
ffcabd96a938aadefc02dd2e3e010099bcf531c7
/src/state_initializer.cpp
ebbd9a3b741bdc889ab47242f5781e84528c7be5
[]
no_license
jarsam/tonav_msckf
246d93a68c9df1b7632e167aa45bf1309222b0c6
3aa91e59831e01998e2dd8c72e1e6783874a0706
refs/heads/master
2021-06-16T06:23:11.087884
2017-05-07T07:50:39
2017-05-07T07:50:39
90,516,937
0
1
null
null
null
null
UTF-8
C++
false
false
798
cpp
#include "state_initializer.h" #include <Eigen/Core> #include "quaternion.h" StateInitializer::StateInitializer() : orientation_(Quaternion::identity()) { position_ = Eigen::Vector3d::Zero(); velocity_ = Eigen::Vector3d::Zero(); } void StateInitializer::setOrientation(const Quaternion& orientation) { orientation_ = orientation; } Quaternion StateInitializer::getOrientation() const { return orientation_; } void StateInitializer::setPosition(const Eigen::Vector3d& position) { position_ = position; } Eigen::Vector3d StateInitializer::getPosition() const { return position_; } void StateInitializer::setVelocity(const Eigen::Vector3d& velocity) { velocity_ = velocity; } Eigen::Vector3d StateInitializer::getVelocity() const { return velocity_; }
[ "jackshirobots@gmail.com" ]
jackshirobots@gmail.com
3119883d03425b1530196d1a91704b836b20f15f
7cfd43ff5627c7cb71cfbea5e1cb1e18665ebdb7
/src/RTSLogicSystem.cpp
70cd46368943efb6528364c497e7540c181ac9d3
[ "MIT" ]
permissive
RHUL-CS-Projects/towersAndMuskets
1d0a89012fda161e7c74e1e9fbbc1eeaa2535287
6679857813e6bcd55e3bfc4f587e23e76da6e603
refs/heads/master
2021-01-17T08:04:13.858526
2016-06-12T21:33:55
2016-06-12T21:33:55
60,636,214
8
1
null
null
null
null
UTF-8
C++
false
false
33,470
cpp
#include <RTSLogicSystem.h> #include <EventReceiver.h> #include <ObjectManager.h> #include <list> #include <RenderManager.h> #include <StatePlaying.h> #include <RTSLogicComponent.h> #include <SelectableComponent.h> #include <PathMovementComponent.h> #include <SteeringComponent.h> #include <TransformComponent.h> #include <AnimatorComponent.h> #include <HealthComponent.h> #include <RenderComponent.h> #include <TowerComponent.h> #include <PathFinder.h> #include <FaceDirectionComponent.h> #include <Quadtree.h> #include <Game.h> #include <irrlicht/irrlicht.h> #include <Enums.h> #include <GroupPathMover.h> #include <thread> using namespace irr; using namespace core; using namespace video; using namespace io; using namespace scene; void RTSLogicSystem::update ( float timestep ) { updateClickPoints(); pathMover = GroupPathMover(); // Get the object object manager ObjectManager* mgr = Game::game.getObjMgr(); // Get all objects with an RTSLogicComponent std::list<int> objects = mgr->getObjectsWithComponent("RTSLogicComponent"); // Iterate over objects for (int i : objects) { currentRTSComp = mgr->getObjectComponent<RTSLogicComponent>(i, "RTSLogicComponent"); currentSteerComp = mgr->getObjectComponent<SteeringComponent>(i, "SteeringComponent"); currentHealthComp = mgr->getObjectComponent<HealthComponent>(i, "HealthComponent"); currentTransComp = mgr->getObjectComponent<TransformComponent>(i, "TransformComponent"); currentRendComp = mgr->getObjectComponent<RenderComponent>(i, "RenderComponent"); currentTeamComp = mgr->getObjectComponent<TeamComponent>(i, "TeamComponent"); // Assert that the object has the necessary components to operate correctly if (!currentRTSComp || !currentSteerComp || !currentHealthComp || !currentTransComp || !currentRendComp || !currentTeamComp) continue; currentSelectComp = mgr->getObjectComponent<SelectableComponent>(i, "SelectableComponent"); currentAnimComp = mgr->getObjectComponent<AnimatorComponent>(i, "AnimatorComponent"); currentPathComp = mgr->getObjectComponent<PathMovementComponent>(i, "PathMovementComponent"); RTS_UNIT_STATE currentState; if (currentRTSComp->stateStack.size() == 0) currentRTSComp->stateStack.push(IDLE); currentState = currentRTSComp->stateStack.top(); bool selected = (currentSelectComp == nullptr) ? false : ((currentSelectComp->selected) ? true : false); if (currentHealthComp->health <= 0) { currentRTSComp->stateStack.push(DEAD); currentState = currentRTSComp->stateStack.top(); } // Perform behaviours of current state switch (currentState) { case IDLE: stateIdle(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "IDLE" << std::endl; break; case WALKING: stateWalking(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "WALKING" << std::endl; break; case MOVE_TO_ATTACK: stateMoveToAttack(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "MOVE_TO_ATTACK" << std::endl; break; case ATTACKING: stateAttacking(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "ATTACKING" << std::endl; break; case RELOADING: stateReloading(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "RELOADING" << std::endl; break; case DEAD: stateDead(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "DEAD" << std::endl; break; case TAKE_AIM: stateTakeAim(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "TAKE_AIM" << std::endl; break; case RELEASE_AIM: stateReleaseAim(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "RELEASE_AIM" << std::endl; break; case GARRISSONED: stateGarrissoned(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "GARRISSONED" << std::endl; break; case CLIMB_UP: stateClimbUp(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "CLIMB_UP" << std::endl; break; case CLIMB_DOWN: stateClimbDown(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "CLIMB_DOWN" << std::endl; break; case MOVE_TO_TOWER: stateMoveToTower(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "MOVE_TO_TOWER" << std::endl; break; case AIMING: stateAiming(mgr, i); if (DebugValues::UNIT_STATES && selected) std::cout << "AIMING" << std::endl; break; } } // Update flashing towers objects = mgr->getObjectsWithComponent("TowerComponent"); for (int i : objects) { TowerComponent* resComp = mgr->getObjectComponent<TowerComponent>(i, "TowerComponent"); if (resComp->flashNum > 0) { if (resComp->flashTimer > 0) { resComp->flashTimer--; } else { resComp->flashNum--; resComp->flashTimer = 5; resComp->flashOn = !resComp->flashOn; } } } pathMover.startCalc(); rightMousePressed = false; } void RTSLogicSystem::draw ( float timestep ) { // Draw flashing boxes under clicked towers std::list<int> objects = Game::game.getObjMgr()->getObjectsWithComponent("TowerComponent"); for (int i : objects) { TowerComponent* towerComp = Game::game.getObjMgr()->getObjectComponent<TowerComponent>(i, "TowerComponent"); SMaterial m; ITerrainSceneNode* terrain = (ITerrainSceneNode*)Game::game.getRendMgr()->getSceneManager()->getSceneNodeFromName("MainTerrain"); if (towerComp->flashNum > 0 && towerComp->flashOn) { m.Lighting = false; m.Thickness = 1.0f; Game::game.getRendMgr()->getDriver()->setMaterial(m); Game::game.getRendMgr()->getDriver()->setTransform(video::ETS_WORLD, IdentityMatrix); TransformComponent* transComp = Game::game.getObjMgr()->getObjectComponent<TransformComponent>(i, "TransformComponent"); vector3df pos = transComp->worldPosition; float gridSize = Game::game.getObjMgr()->worldManager->gridSize; vector3df p1 = pos+vector3df(-gridSize,2,-gridSize); vector3df p2 = pos+vector3df(-gridSize,2,gridSize); vector3df p3 = pos+vector3df(gridSize,2,-gridSize); vector3df p4 = pos+vector3df(gridSize,2,gridSize); p1.Y = terrain->getHeight(p1.X, p1.Z) + 0.5f; p2.Y = terrain->getHeight(p2.X, p2.Z) + 0.5f; p3.Y = terrain->getHeight(p3.X, p3.Z) + 0.5f; p4.Y = terrain->getHeight(p4.X, p4.Z) + 0.5f; Game::game.getRendMgr()->getDriver()->draw3DLine(p1, p2, SColor(255,255,255,255)); Game::game.getRendMgr()->getDriver()->draw3DLine(p1, p3, SColor(255,255,255,255)); Game::game.getRendMgr()->getDriver()->draw3DLine(p3, p4, SColor(255,255,255,255)); Game::game.getRendMgr()->getDriver()->draw3DLine(p2, p4, SColor(255,255,255,255)); } } } void RTSLogicSystem::updateClickPoints() { clickedObject = -1; clickedTower = -1; // Check if the right mouse button was clicked on the terrain or a game object if (EventReceiver::getMouseState()->rightPressed && !rightMouseDown) { rightMouseDown = true; rightMousePressed = true; // Calculate click point on terrain ISceneCollisionManager* colmgr = Game::game.getRendMgr()->getSceneManager()->getSceneCollisionManager(); line3df ray = colmgr->getRayFromScreenCoordinates(EventReceiver::getMouseState()->position); triangle3df triangle; ISceneNode* node; // Check if the user clicked on terrain or object colmgr->getCollisionPoint(ray, Game::game.getRendMgr()->getSceneManager()->getSceneNodeFromName("MainTerrain")->getTriangleSelector(), terrainPoint, triangle, node); ObjectManager* mgr = Game::game.getObjMgr(); int hitID = -1; if ((hitID = EventReceiver::getHoverObject()) > -1) { if (mgr->getObjectComponent<TransformComponent>(hitID, "TransformComponent") != nullptr) { if (mgr->getObjectComponent<HealthComponent>(hitID, "HealthComponent") != nullptr) { clickedObject = hitID; objectPoint = mgr->getObjectComponent<TransformComponent>(hitID, "TransformComponent")->worldPosition; } if (mgr->getObjectComponent<TowerComponent>(hitID, "TowerComponent") != nullptr) { clickedTower = hitID; } } } } else { if (!EventReceiver::getMouseState()->rightPressed) rightMouseDown = false; } } void RTSLogicSystem::setPath ( ObjectManager* mgr, int id, vector3df point ) { currentRTSComp->stateStack.push(WAIT); if (currentSelectComp != nullptr && currentSelectComp->selected && currentRTSComp->towerID == -1) { pathMover.requestPath(id, point); } else { std::thread t(&RTSLogicSystem::calcPathSynch, mgr, id, point); t.detach(); } } void RTSLogicSystem::calcPathSynch ( ObjectManager* mgr, int id, vector3df point ) { // Get only selected selectable objects TransformComponent* transComp = mgr->getObjectComponent<TransformComponent>(id, "TransformComponent"); if (transComp == nullptr) return; // Get object's steering system SteeringComponent* steerComp = mgr->getObjectComponent<SteeringComponent>(id, "SteeringComponent"); if (steerComp == nullptr) return; steerComp->path.resetPath(); PathFinder pathFinder(mgr->worldManager); steerComp->path = pathFinder.findPath(transComp->worldPosition, point); RTSLogicComponent* rtsComp = mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent"); if (rtsComp != nullptr) { rtsComp->stateStack.pop(); rtsComp->pathSet = true; } } bool RTSLogicSystem::animationComplete() { if (currentAnimComp != nullptr) { if (currentRendComp->sceneNode->getFrameNr() >= currentRendComp->sceneNode->getEndFrame()) return true; else return false; } return true; } bool RTSLogicSystem::selected() { if (currentSelectComp == nullptr) return false; return currentSelectComp->selected; } void RTSLogicSystem::setAnimation ( std::string animation, bool loop ) { if (currentAnimComp != nullptr) { if (currentAnimComp->currentAnimation != animation) { currentAnimComp->setAnimation(animation, currentRendComp->sceneNode); currentRendComp->sceneNode->setLoopMode(loop); } } } float RTSLogicSystem::distanceToObjectSq ( ObjectManager* mgr, int otherID ) { TransformComponent* otherTransComp = mgr->getObjectComponent<TransformComponent>(otherID, "TransformComponent"); return currentTransComp->worldPosition.getDistanceFromSQ(otherTransComp->worldPosition); } bool RTSLogicSystem::targetAlive ( ObjectManager* mgr ) { HealthComponent* otherHealthComp = mgr->getObjectComponent<HealthComponent>(currentRTSComp->attackTargetID, "HealthComponent"); if (otherHealthComp == nullptr || otherHealthComp->health <= 0) return false; return true; } void RTSLogicSystem::faceTarget ( ObjectManager* mgr, int id ) { FaceDirectionComponent* faceComp = mgr->getObjectComponent<FaceDirectionComponent>(id, "FaceDirectionComponent"); if (faceComp != nullptr) { if (currentRTSComp->attackTargetID > -1) { vector3df dif = currentTransComp->worldPosition - attackTargetPosition(mgr); faceComp->targetYRot = radToDeg(atan2(dif.X, dif.Z)); } } } bool RTSLogicSystem::checkTargetDifferentTeam ( ObjectManager* mgr, int target ) { TeamComponent* otherTeamComp = mgr->getObjectComponent<TeamComponent>(target, "TeamComponent"); return otherTeamComp->teamID != currentTeamComp->teamID; } vector3df RTSLogicSystem::attackTargetPosition(ObjectManager* mgr) { TransformComponent* otherTransComp = mgr->getObjectComponent<TransformComponent>(currentRTSComp->attackTargetID, "TransformComponent"); if (otherTransComp != nullptr) return otherTransComp->worldPosition; return currentTransComp->worldPosition; } vector3df RTSLogicSystem::towerTargetPosition ( ObjectManager* mgr, int towerID ) { TransformComponent* otherTransComp = mgr->getObjectComponent<TransformComponent>(towerID, "TransformComponent"); TowerComponent* towerComp = mgr->getObjectComponent<TowerComponent>(towerID, "TowerComponent"); if (otherTransComp != nullptr) { /*return vector3df(otherTransComp->worldPosition.X + towerComp->doorOffset.X * mgr->worldManager->gridSize, 0 + towerComp->doorOffset.Y * mgr->worldManager->gridSize, otherTransComp->worldPosition.Z + towerComp->doorOffset.Z * mgr->worldManager->gridSize);*/ vector3df nearest = otherTransComp->worldPosition; double dist = -1; double angle = 360 / 8; double gridSize = mgr->worldManager->gridSize; vector3df mid = otherTransComp->worldPosition; for (int i = 0; i < 8; i++) { vector3df unit(cos(degToRad(i*angle)) * gridSize, 0, sin(degToRad(i*angle)) * gridSize); unit *= 1.5; vector3df tempNearest = mid + unit; if (!mgr->worldManager->checkPassable(tempNearest)) continue; double tempDist = (currentTransComp->worldPosition - tempNearest).getLengthSQ(); if (dist == -1 || tempDist < dist) { dist = tempDist; nearest = tempNearest; } } return nearest; } return currentTransComp->worldPosition; } int RTSLogicSystem::getNearestOnOtherTeam ( ObjectManager* mgr, int id ) { std::vector<int> objects = TeamComponent::getObjectsOnTeam((currentTeamComp->teamID + 1) % 2); double dist = currentRTSComp->rangeInSquares * mgr->worldManager->gridSize; // Multiply range by 1.5 to get a tentative line of sight dist *= 1.5; dist *= dist; int best = -1; for (int i : objects) { if (!mgr->objectExists(i)) { continue; } if (!mgr->objectHasComponent(i, "TeamComponent") || !mgr->objectHasComponent(i, "HealthComponent") || !mgr->objectHasComponent(i, "TransformComponent")) continue; TeamComponent* otherTeamComp = mgr->getObjectComponent<TeamComponent>(i, "TeamComponent"); TransformComponent* otherTransComp = mgr->getObjectComponent<TransformComponent>(i, "TransformComponent"); HealthComponent* otherHealthComp = mgr->getObjectComponent<HealthComponent>(i, "HealthComponent"); if (otherHealthComp->health <= 0) continue; double dx = otherTransComp->worldPosition.X - currentTransComp->worldPosition.X; double dz = otherTransComp->worldPosition.Z - currentTransComp->worldPosition.Z; double distsq = dx*dx + dz*dz; if (distsq < dist) { dist = distsq; best = i; break; } } return best; } void RTSLogicSystem::stateDead ( ObjectManager* mgr, int id ) { if (currentRTSComp->garrissoned) { TowerComponent* towerComp = mgr->getObjectComponent<TowerComponent>(currentRTSComp->towerID, "TowerComponent"); for (int i = 0; i < 4; i++) { if (towerComp->freeSpace[i] == id) { towerComp->freeSpace[i] = -1; break; } } } mgr->detachComponent(id, "SteeringComponent"); mgr->detachComponent(id, "RTSLogicComponent"); mgr->detachComponent(id, "TeamComponent"); AnimatorComponent* animComp = mgr->getObjectComponent<AnimatorComponent>(id, "AnimatorComponent"); RenderComponent* rendComp = mgr->getObjectComponent<RenderComponent>(id, "RenderComponent"); SelectableComponent* selectComp = mgr->getObjectComponent<SelectableComponent>(id, "SelectableComponent"); if (selectComp != nullptr) { selectComp->selected = false; selectComp->sceneNode->setVisible(false); } mgr->detachComponent(id, "SelectableComponent"); HealthComponent* healthComp = mgr->getObjectComponent<HealthComponent>(id, "HealthComponent"); if (healthComp != nullptr) { healthComp->alpha = 0; healthComp->billboardNode->setVisible(false); } mgr->detachComponent(id, "HealthComponent"); if (animComp != nullptr && rendComp != nullptr) { animComp->setAnimation("DEATH1", rendComp->sceneNode); rendComp->sceneNode->setLoopMode(false); } } void RTSLogicSystem::stateIdle ( ObjectManager* mgr, int id ) { if (currentSteerComp->velocity.getLength() > 0.01) { setAnimation("WALK", true); FaceDirectionComponent* faceComp = mgr->getObjectComponent<FaceDirectionComponent>(id, "FaceDirectionComponent"); if (faceComp != nullptr) faceComp->targetYRot = radToDeg(atan2(-currentSteerComp->velocity.X,-currentSteerComp->velocity.Z)); } else { setAnimation("IDLE", true); } // Start walking to attack target if (selected() && clickedObject >= 0 && checkTargetDifferentTeam(mgr, clickedObject)) { currentRTSComp->attackTargetID = clickedObject; currentRTSComp->pathSet = false; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_ATTACK); mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } int nearestEnemy = -1; currentRTSComp->nearestEnemyDelay--; if (currentRTSComp->nearestEnemyDelay <= 0) { currentRTSComp->nearestEnemyDelay += 60; nearestEnemy = getNearestOnOtherTeam(mgr, id); // Start walking to attack nearby target if (nearestEnemy >= 0) { currentRTSComp->attackTargetID = nearestEnemy; currentRTSComp->pathSet = false; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_ATTACK); return; } } // Start walking to tower target if (selected() && clickedTower >= 0) { currentRTSComp->towerID = clickedTower; currentRTSComp->pathSet = false; currentSteerComp->path.resetPath(); currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_TOWER); return; } // Start walking to position if (selected() && rightMousePressed) { currentRTSComp->attackTargetID = -1; currentRTSComp->pathSet = false; currentRTSComp->terrainPoint = terrainPoint; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(WALKING); mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } } void RTSLogicSystem::stateMoveToAttack ( ObjectManager* mgr, int id ) { setAnimation("WALK", true); if (!currentRTSComp->pathSet) { RTSLogicComponent* otherRTSComp = mgr->getObjectComponent<RTSLogicComponent>(currentRTSComp->attackTargetID, "RTSLogicComponent"); if (otherRTSComp == nullptr || !otherRTSComp->garrissoned) { setPath(mgr, id, attackTargetPosition(mgr)); currentRTSComp->pathSet = true; } else { setPath(mgr, id, towerTargetPosition(mgr, otherRTSComp->towerID)); currentRTSComp->pathSet = true; } return; } // Start walking to attack target if (selected() && clickedObject >= 0 && checkTargetDifferentTeam(mgr, clickedObject) && clickedObject != currentRTSComp->attackTargetID) { currentRTSComp->attackTargetID = clickedObject; currentRTSComp->pathSet = false; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_ATTACK); mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } // Start walking to tower target if (selected() && clickedTower >= 0) { currentRTSComp->towerID = clickedTower; currentRTSComp->pathSet = false; currentSteerComp->path.resetPath(); currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_TOWER); return; } float distSq = (mgr->worldManager->gridSize * currentRTSComp->rangeInSquares) * (mgr->worldManager->gridSize * currentRTSComp->rangeInSquares); //std::cout << currentRTSComp->attackTargetID << std::endl; // Start aiming at target if (currentRTSComp->attackTargetID >= 0 && distanceToObjectSq(mgr, currentRTSComp->attackTargetID) < distSq) { currentRTSComp->pathSet = false; currentSteerComp->path.resetPath(); currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(AIMING); currentRTSComp->stateStack.push(TAKE_AIM); return; } // Start walking to position if (selected() && rightMousePressed) { currentRTSComp->attackTargetID = -1; currentRTSComp->pathSet = false; currentRTSComp->terrainPoint = terrainPoint; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(WALKING); mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } // Finished walking if (currentSteerComp->path.ended()) { currentRTSComp->attackTargetID = -1; currentRTSComp->pathSet = false; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(IDLE); return; } } void RTSLogicSystem::stateAttacking ( ObjectManager* mgr, int id ) { setAnimation("SHOOT", false); // Reload if (animationComplete()) { currentRTSComp->stateStack.pop(); return; } } void RTSLogicSystem::stateReloading ( ObjectManager* mgr, int id ) { setAnimation("RELOAD", false); // Return to aiming if (animationComplete()) { currentRTSComp->stateStack.pop(); return; } } void RTSLogicSystem::stateWalking ( ObjectManager* mgr, int id ) { setAnimation("WALK", true); if (!currentRTSComp->pathSet) { setPath(mgr, id, currentRTSComp->terrainPoint); currentRTSComp->pathSet = true; } // Start walking to attack target if (selected() && clickedObject >= 0 && checkTargetDifferentTeam(mgr, clickedObject)) { currentRTSComp->attackTargetID = clickedObject; currentRTSComp->pathSet = false; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_ATTACK); mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } // Start walking to tower target if (selected() && clickedTower >= 0) { currentRTSComp->towerID = clickedTower; currentRTSComp->pathSet = false; currentSteerComp->path.resetPath(); currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_TOWER); return; } // Start walking to position if (selected() && rightMousePressed) { currentRTSComp->attackTargetID = -1; currentRTSComp->pathSet = false; currentRTSComp->terrainPoint = terrainPoint; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(WALKING); mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } // Position reached if (currentSteerComp->path.ended()) { currentRTSComp->pathSet = false; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(IDLE); return; } } void RTSLogicSystem::stateClimbDown ( ObjectManager* mgr, int id ) { setAnimation("IDLE", true); currentRTSComp->garrissoned = true; TowerComponent* towerComp = mgr->getObjectComponent<TowerComponent>(currentRTSComp->towerID, "TowerComponent"); TransformComponent* towerTransComp = mgr->getObjectComponent<TransformComponent>(currentRTSComp->towerID, "TransformComponent"); currentTransComp->worldPosition = towerTargetPosition(mgr, currentRTSComp->towerID); for (int i = 0; i < 4; i++) { if (towerComp->freeSpace[i] == id) { towerComp->freeSpace[i] = -1; break; } } currentSteerComp->enabled = true; currentSteerComp->velocity = vector3df(0,0,0); currentRTSComp->stateStack.pop(); FaceDirectionComponent* faceComp = mgr->getObjectComponent<FaceDirectionComponent>(id, "FaceDirectionComponent"); if (faceComp != nullptr) { faceComp->targetYRot = 0; faceComp->currentYRot = 0; } setAnimation("IDLE", true); currentRTSComp->garrissoned = false; // Climbed down } void RTSLogicSystem::stateClimbUp ( ObjectManager* mgr, int id ) { setAnimation("IDLE", true); currentSteerComp->path.resetPath(); if (!currentRTSComp->canGarrisson) { ((StatePlaying*)Game::game.currentState())->message(SHOW_MESSAGE_BAD, "This unit is too large to be garrissoned"); currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(IDLE); return; } TowerComponent* towerComp = mgr->getObjectComponent<TowerComponent>(currentRTSComp->towerID, "TowerComponent"); TransformComponent* towerTransComp = mgr->getObjectComponent<TransformComponent>(currentRTSComp->towerID, "TransformComponent"); int garrissonPos = 0; bool foundSpace = false; for (int i = 0; i < 4; i++) { if (towerComp->freeSpace[i] == -1) { garrissonPos = i; towerComp->freeSpace[i] = id; foundSpace = true; break; } } if (!foundSpace) { ((StatePlaying*)Game::game.currentState())->message(SHOW_MESSAGE_BAD, "Not enough space to garrisson this unit"); currentRTSComp->towerID = -1; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(IDLE); return; } currentRTSComp->garrissoned = true; int xTowerPos = garrissonPos % 2; int yTowerPos = floor(garrissonPos / 2); float gridSize = mgr->worldManager->gridSize; currentTransComp->worldPosition.Y = towerTransComp->worldPosition.Y + towerComp->platformHeight; currentTransComp->worldPosition.X = (towerTransComp->worldPosition.X - 0.5f * gridSize) + xTowerPos * gridSize; currentTransComp->worldPosition.Z = (towerTransComp->worldPosition.Z - 0.5f * gridSize) + yTowerPos * gridSize; currentSteerComp->enabled = false; currentRTSComp->stateStack.pop(); } void RTSLogicSystem::stateGarrissoned ( ObjectManager* mgr, int id ) { /*if (!currentRTSComp->pathSet) { setPath(mgr, id, towerTargetPosition(mgr)); currentRTSComp->pathSet = true; }*/ // Start walking to attack target if (selected() && clickedObject >= 0 && checkTargetDifferentTeam(mgr, clickedObject)) { currentRTSComp->attackTargetID = clickedObject; currentRTSComp->pathSet = false; currentRTSComp->stateStack.push(CLIMB_DOWN); stateClimbDown(mgr, id); currentRTSComp->towerID = -1; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_ATTACK); mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } // Start walking to tower target if (selected() && clickedTower >= 0 && clickedTower != currentRTSComp->towerID) { currentRTSComp->pathSet = false; currentSteerComp->path.resetPath(); currentRTSComp->stateStack.push(CLIMB_DOWN); stateClimbDown(mgr, id); currentRTSComp->towerID = clickedTower; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_TOWER); return; } // Start walking to position if (selected() && rightMousePressed) { currentRTSComp->pathSet = false; currentRTSComp->stateStack.push(CLIMB_DOWN); stateClimbDown(mgr, id); currentRTSComp->towerID = -1; currentRTSComp->terrainPoint = terrainPoint; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(WALKING); mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } setAnimation("IDLE", true); float rangeBonus = currentRTSComp->garrissoned ? 1.5f : 1; float dist = (mgr->worldManager->gridSize * currentRTSComp->rangeInSquares * rangeBonus); float distSq = dist * dist; int nearestEnemy = -1; currentRTSComp->nearestEnemyDelay--; if (currentRTSComp->nearestEnemyDelay <= 0) { currentRTSComp->nearestEnemyDelay += 60; nearestEnemy = getNearestOnOtherTeam(mgr, id); // Start walking to attack nearby target if (nearestEnemy >= 0 && distanceToObjectSq(mgr, nearestEnemy) < distSq) { currentRTSComp->attackTargetID = nearestEnemy; currentRTSComp->pathSet = false; currentRTSComp->stateStack.push(AIMING); return; } } } void RTSLogicSystem::stateMoveToTower ( ObjectManager* mgr, int id ) { setAnimation("WALK", true); if (!currentRTSComp->canGarrisson) { ((StatePlaying*)Game::game.currentState())->message(SHOW_MESSAGE_BAD, "This unit is too large to be garrissoned"); currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(IDLE); currentRTSComp->pathSet = false; currentSteerComp->path.resetPath(); return; } if (!currentRTSComp->pathSet) { setPath(mgr, id, towerTargetPosition(mgr, currentRTSComp->towerID)); currentRTSComp->pathSet = true; TowerComponent* resComp = mgr->getObjectComponent<TowerComponent>(currentRTSComp->towerID, "TowerComponent"); resComp->flashNum = 8; resComp->flashTimer = 5; Game::game.resources.loadSound("garrisson.ogg")->play(); return; } // Could not move to tower if (currentSteerComp->path.ended() && distanceToObjectSq(mgr, currentRTSComp->towerID) > (mgr->worldManager->gridSize*2)*(mgr->worldManager->gridSize*2)) { currentRTSComp->towerID = -1; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(IDLE); currentRTSComp->pathSet = false; currentSteerComp->path.resetPath(); return; } // Start walking to attack target if (selected() && clickedObject >= 0 && checkTargetDifferentTeam(mgr, clickedObject)) { currentRTSComp->towerID = -1; currentRTSComp->attackTargetID = clickedObject; currentRTSComp->pathSet = false; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_ATTACK); mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } // Start walking to tower target if (selected() && clickedTower >= 0 && clickedTower != currentRTSComp->towerID) { currentRTSComp->towerID = clickedTower; currentRTSComp->pathSet = false; currentSteerComp->path.resetPath(); currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_TOWER); return; } // Start walking to position if (selected() && rightMousePressed) { currentRTSComp->towerID = -1; currentRTSComp->pathSet = false; currentRTSComp->terrainPoint = terrainPoint; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(WALKING); mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } // Start climbing tower if (currentSteerComp->path.ended() || distanceToObjectSq(mgr, currentRTSComp->towerID) < (mgr->worldManager->gridSize*1.5)*(mgr->worldManager->gridSize*1.5)) { currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(GARRISSONED); currentRTSComp->stateStack.push(CLIMB_UP); return; } } void RTSLogicSystem::stateAiming ( ObjectManager* mgr, int id ) { setAnimation("AIM", true); faceTarget(mgr, id); currentRTSComp->shootCounter--; currentRTSComp->pathSet = false; currentSteerComp->path.resetPath(); // Start moving to target if (selected() && clickedObject >= 0 && checkTargetDifferentTeam(mgr, clickedObject)) { currentRTSComp->towerID = -1; currentRTSComp->attackTargetID = clickedObject; currentRTSComp->pathSet = false; currentRTSComp->shootCounter = currentRTSComp->shootDelay; if (currentRTSComp->garrissoned) { currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_ATTACK); currentRTSComp->stateStack.push(CLIMB_DOWN); currentRTSComp->stateStack.push(RELEASE_AIM); } else { currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(MOVE_TO_ATTACK); currentRTSComp->stateStack.push(RELEASE_AIM); } mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } // Start moving to tower // Go back to idling in tower // Start moving to position if (selected() && rightMousePressed) { currentRTSComp->terrainPoint = terrainPoint; currentRTSComp->shootCounter = currentRTSComp->shootDelay; if (currentRTSComp->garrissoned) { currentRTSComp->towerID = -1; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(WALKING); currentRTSComp->stateStack.push(CLIMB_DOWN); currentRTSComp->stateStack.push(RELEASE_AIM); } else { currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(WALKING); currentRTSComp->stateStack.push(RELEASE_AIM); } mgr->getObjectComponent<RTSLogicComponent>(id, "RTSLogicComponent")->walkSound->play(); return; } // Attack if (currentRTSComp->shootCounter <= 0 && targetAlive(mgr)) { currentRTSComp->shootCounter = currentRTSComp->shootDelay; currentRTSComp->stateStack.push(RELOADING); currentRTSComp->stateStack.push(ATTACKING); HealthComponent* otherHealthComp = mgr->getObjectComponent<HealthComponent>(currentRTSComp->attackTargetID, "HealthComponent"); otherHealthComp->health -= currentRTSComp->attackDamage * ((currentRTSComp->garrissoned) ? 2 : 1); otherHealthComp->alpha = 2; currentRTSComp->shootSound->setPosition(currentTransComp->worldPosition.X, currentTransComp->worldPosition.Y, currentTransComp->worldPosition.Z); currentRTSComp->shootSound->setVolume(100); currentRTSComp->shootSound->setRelativeToListener(false); currentRTSComp->shootSound->setAttenuation(0.1f); currentRTSComp->shootSound->setPitch(0.9f + (1.0f/1000*(rand()%1000))*0.2f); currentRTSComp->shootSound->play(); vector3df start = currentTransComp->worldPosition; vector3df end = attackTargetPosition(mgr); FaceDirectionComponent* faceComp = mgr->getObjectComponent<FaceDirectionComponent>(id, "FaceDirectionComponent"); ((StatePlaying*)Game::game.currentState())->particleManager.spawnEffect(start, end, vector3df(0, faceComp->currentYRot, 0), currentRTSComp->effectType); return; } float rangeBonus = currentRTSComp->garrissoned ? 1.5f : 1; float dist = (mgr->worldManager->gridSize * currentRTSComp->rangeInSquares * rangeBonus); float distSq = dist * dist; // Go back to idling if (!targetAlive(mgr) || distanceToObjectSq(mgr, currentRTSComp->attackTargetID) > distSq) { currentRTSComp->attackTargetID = -1; currentRTSComp->stateStack.pop(); currentRTSComp->stateStack.push(currentRTSComp->garrissoned ? GARRISSONED : IDLE); currentRTSComp->stateStack.push(RELEASE_AIM); } } void RTSLogicSystem::stateReleaseAim ( ObjectManager* mgr, int id ) { setAnimation("REST", false); // Release aim if (animationComplete()) { currentRTSComp->stateStack.pop(); return; } } void RTSLogicSystem::stateTakeAim ( ObjectManager* mgr, int id ) { setAnimation("TAKEAIM", false); faceTarget(mgr, id); // Take aim if (animationComplete()) { currentRTSComp->stateStack.pop(); return; } }
[ "zyvb031@029d1f5e-ba45-47f3-9ba4-d89dc58e0cf9" ]
zyvb031@029d1f5e-ba45-47f3-9ba4-d89dc58e0cf9
ba9708d7736dd52159a3ffc6fd4abe902f79a640
062f73b7e41f6a3a9f6a33845e60788638bcadb5
/src/SteenX/LLVM/MetadataExtractor.cpp
4837077818ccc27ae9f3047f296e1a21b909c44c
[ "MIT" ]
permissive
cherusker/racehog
7a75d98391b98f1c9d76d1d7f13c19c635fd7d0b
30f6285866f528fae0e05a8e8f2c354b1e171b1f
refs/heads/master
2020-05-22T14:10:14.931131
2019-05-13T08:35:56
2019-05-28T20:13:52
186,378,936
0
0
null
null
null
null
UTF-8
C++
false
false
1,353
cpp
#include "SteenX/LLVM/MetadataExtractor.h" #include "llvm/IR/DebugInfoMetadata.h" // TODO: Avoid (some of the) duplicate code in here? racehog::Function::MetadataReference racehog::MetadataExtractor:: extractFrom(const llvm::Function& func) { const auto sub = func.getSubprogram(); if (sub == nullptr) return Function::MetadataReference(); auto meta = namedpool.create(); (void) meta->setDirectory(strings.insert(sub->getDirectory())); (void) meta->setFilename(strings.insert(sub->getFilename())); (void) meta->setLine(sub->getLine()); (void) meta->setColumn(0); // We don't extract this information (yet). (void) meta->setName(strings.insert(sub->getName())); return meta; } racehog::Instruction::MetadataReference racehog::MetadataExtractor:: extractFrom(const llvm::Instruction& inst) { const auto loc = inst.getDebugLoc().get(); if (loc == nullptr) return Instruction::MetadataReference(); // No metadata available. const auto scope = loc->getScope(); if (scope == nullptr) return Instruction::MetadataReference(); // No scope, no data. auto meta = plainpool.create(); (void) meta->setDirectory(strings.insert(scope->getDirectory())); (void) meta->setFilename(strings.insert(scope->getFilename())); (void) meta->setLine(loc->getLine()); (void) meta->setColumn(loc->getColumn()); return meta; }
[ "prince.cherusker@gmail.com" ]
prince.cherusker@gmail.com
12c773b201bc5f619a32afd6aa9dcec310ff3805
6465cf427614315cacb8c17c2bcb9fcbace99dac
/32blit-pico/display.hpp
bef4ce0de786cf62e29f21dcc9e70e56eb435f21
[ "MIT" ]
permissive
lenardg/32blit-beta
0d7be7f6cfec4187c9617c6b9f61837665ee4516
f40b0292c29fd866e50c67c7edcee3f9b1614265
refs/heads/master
2022-10-26T04:51:34.091856
2022-09-30T10:49:00
2022-09-30T10:49:00
227,807,088
0
0
MIT
2019-12-13T09:48:01
2019-12-13T09:48:01
null
UTF-8
C++
false
false
379
hpp
#pragma once #include <cstdint> #include "engine/api_private.hpp" void init_display(); void update_display(uint32_t time); bool display_render_needed(); blit::SurfaceInfo &set_screen_mode(blit::ScreenMode mode); bool set_screen_mode_format(blit::ScreenMode new_mode, blit::SurfaceTemplate &new_surf_template); void set_screen_palette(const blit::Pen *colours, int num_cols);
[ "charlie@daft.games" ]
charlie@daft.games
f7f2feb941f3f38ed61032b0b285466e90682a0a
2ea35e2e0a5eae434841eef54a480e4402f2f3e7
/s7/Buffer.cpp
8fb513a5adfe5aa8ae532d9d96fff54955e4f821
[]
no_license
zhangwenxiao/Cpp-Reactor-Networklib
0566017e748d7237e8e69389aaaf709fe614612b
e236bea8cd02a0f474f0ff2ed6d858baf94e59f5
refs/heads/master
2020-03-26T01:42:01.399151
2018-08-26T13:58:54
2018-08-26T13:58:54
144,378,371
0
0
null
null
null
null
UTF-8
C++
false
false
741
cpp
#include "Buffer.h" #include "SocketsOps.h" #include <muduo/base/Logging.h> #include <errno.h> #include <memory.h> #include <sys/uio.h> using namespace muduo; ssize_t Buffer::readFd(int fd, int* savedErrno) { char extrabuf[65536]; struct iovec vec[2]; const size_t writable = writableBytes(); vec[0].iov_base = begin() + writerIndex_; vec[0].iov_len = writable; vec[1].iov_base = extrabuf; vec[1].iov_len = sizeof(extrabuf); const ssize_t n = readv(fd, vec, 2); if(n < 0) { *savedErrno = errno; } else if(implicit_cast<size_t>(n) <= writable) { writerIndex_ += n; } else { writerIndex_ = buffer_.size(); append(extrabuf, n - writable); } return n; }
[ "1321457973@qq.com" ]
1321457973@qq.com
a052a46b6f78d0a857087e2e0318e7009d99575b
38f055a979a0e4acecf5d2a5ad0d0344d1f52db2
/src/mess/includes/newbrain.h
c0410f885b3cd60d23c98a65b6ec43e96852fae0
[]
no_license
poliva/mame-rr
0cc05bed2a80addbb906e97b8f25633496eecab6
124dbb66844bc6d8747b19b8483cefa28fb6b7fb
refs/heads/master
2021-01-22T05:16:42.247183
2015-04-24T08:59:22
2015-04-24T08:59:22
34,506,421
3
0
null
null
null
null
UTF-8
C++
false
false
6,593
h
#pragma once #ifndef __NEWBRAIN__ #define __NEWBRAIN__ #define ADDRESS_MAP_MODERN #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/z80/z80daisy.h" #include "cpu/cop400/cop400.h" #include "machine/upd765.h" #include "machine/6850acia.h" #include "machine/adc0808.h" #include "machine/z80ctc.h" #include "machine/z80sio.h" #include "imagedev/flopdrv.h" #include "formats/basicdsk.h" #include "imagedev/cassette.h" #include "machine/rescap.h" #include "machine/ram.h" #define SCREEN_TAG "screen" #define Z80_TAG "409" #define COP420_TAG "419" #define MC6850_TAG "459" #define ADC0809_TAG "427" #define DAC0808_TAG "461" #define Z80CTC_TAG "458" #define FDC_Z80_TAG "416" #define UPD765_TAG "418" #define NEWBRAIN_EIM_RAM_SIZE 0x10000 #define NEWBRAIN_ENRG1_CLK 0x01 #define NEWBRAIN_ENRG1_TVP 0x04 #define NEWBRAIN_ENRG1_CTS 0x10 #define NEWBRAIN_ENRG1_DO 0x20 #define NEWBRAIN_ENRG1_PO 0x80 #define NEWBRAIN_ENRG1_UST_BIT_1_MASK 0x30 #define NEWBRAIN_ENRG1_UST_BIT_0_MASK 0xc0 #define NEWBRAIN_ENRG2_USERP 0x01 #define NEWBRAIN_ENRG2_ANP 0x02 #define NEWBRAIN_ENRG2_MLTMD 0x04 #define NEWBRAIN_ENRG2_MSPD 0x08 #define NEWBRAIN_ENRG2_ENOR 0x10 #define NEWBRAIN_ENRG2_ANSW 0x20 #define NEWBRAIN_ENRG2_ENOT 0x40 #define NEWBRAIN_ENRG2_CENTRONICS_OUT 0x80 #define NEWBRAIN_VIDEO_RV 0x01 #define NEWBRAIN_VIDEO_FS 0x02 #define NEWBRAIN_VIDEO_32_40 0x04 #define NEWBRAIN_VIDEO_UCR 0x08 #define NEWBRAIN_VIDEO_80L 0x40 class newbrain_state : public driver_device { public: newbrain_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, Z80_TAG), m_copcpu(*this, COP420_TAG), m_cassette1(*this, CASSETTE_TAG), m_cassette2(*this, CASSETTE2_TAG) { } required_device<cpu_device> m_maincpu; required_device<cpu_device> m_copcpu; required_device<cassette_image_device> m_cassette1; required_device<cassette_image_device> m_cassette2; virtual void machine_start(); virtual void machine_reset(); virtual void video_start(); virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect); DECLARE_WRITE8_MEMBER( enrg1_w ); DECLARE_WRITE8_MEMBER( a_enrg1_w ); DECLARE_READ8_MEMBER( ust_r ); DECLARE_READ8_MEMBER( a_ust_r ); DECLARE_READ8_MEMBER( user_r ); DECLARE_WRITE8_MEMBER( user_w ); DECLARE_READ8_MEMBER( clclk_r ); DECLARE_WRITE8_MEMBER( clclk_w ); DECLARE_READ8_MEMBER( clusr_r ); DECLARE_WRITE8_MEMBER( clusr_w ); DECLARE_READ8_MEMBER( cop_l_r ); DECLARE_WRITE8_MEMBER( cop_l_w ); DECLARE_WRITE8_MEMBER( cop_g_w ); DECLARE_READ8_MEMBER( cop_g_r ); DECLARE_WRITE8_MEMBER( cop_d_w ); DECLARE_READ8_MEMBER( cop_in_r ); DECLARE_WRITE8_MEMBER( cop_sk_w ); DECLARE_READ8_MEMBER( cop_si_r ); DECLARE_WRITE8_MEMBER( cop_so_w ); DECLARE_READ8_MEMBER( tvl_r ); DECLARE_WRITE8_MEMBER( tvl_w ); DECLARE_WRITE8_MEMBER( tvctl_w ); DECLARE_READ8_MEMBER( cop_r ); DECLARE_WRITE8_MEMBER( cop_w ); void check_interrupt(); void bankswitch(); void tvram_w(UINT8 data, int a6); inline int get_reset_t(); inline int get_pwrup_t(); void screen_update(bitmap_t *bitmap, const rectangle *cliprect); // processor state int m_pwrup; // power up int m_userint; // user interrupt int m_userint0; // parallel port interrupt int m_clkint; // clock interrupt int m_aciaint; // ACIA interrupt int m_copint; // COP interrupt int m_anint; // A/DC interrupt int m_bee; // identity UINT8 m_enrg1; // enable register 1 UINT8 m_enrg2; // enable register 2 int m_acia_rxd; // ACIA receive int m_acia_txd; // ACIA transmit // COP420 state UINT8 m_cop_bus; // data bus int m_cop_so; // serial out int m_cop_tdo; // tape data output int m_cop_tdi; // tape data input int m_cop_rd; // memory read int m_cop_wr; // memory write int m_cop_access; // COP access // keyboard state int m_keylatch; // keyboard row int m_keydata; // keyboard column // video state int m_segment_data[16]; // VF segment data int m_tvcnsl; // TV console required int m_tvctl; // TV control register UINT16 m_tvram; // TV start address UINT8 *m_char_rom; // character ROM // user bus state UINT8 m_user; // timers emu_timer *m_reset_timer; // power on reset timer emu_timer *m_pwrup_timer; // power up timer // devices UINT8 m_copdata; int m_copstate; int m_copbytes; int m_copregint; }; class newbrain_eim_state : public newbrain_state { public: newbrain_eim_state(const machine_config &mconfig, device_type type, const char *tag) : newbrain_state(mconfig, type, tag), m_fdccpu(*this, FDC_Z80_TAG), m_ctc(*this, Z80CTC_TAG), m_acia(*this, MC6850_TAG), m_fdc(*this, UPD765_TAG), m_floppy(*this, FLOPPY_0) { } required_device<cpu_device> m_fdccpu; required_device<z80ctc_device> m_ctc; required_device<acia6850_device> m_acia; required_device<device_t> m_fdc; required_device<device_t> m_floppy; virtual void machine_start(); DECLARE_WRITE8_MEMBER( fdc_auxiliary_w ); DECLARE_READ8_MEMBER( fdc_control_r ); DECLARE_READ8_MEMBER( ust2_r ); DECLARE_WRITE8_MEMBER( enrg2_w ); DECLARE_WRITE8_MEMBER( pr_w ); DECLARE_READ8_MEMBER( user_r ); DECLARE_WRITE8_MEMBER( user_w ); DECLARE_READ8_MEMBER( anout_r ); DECLARE_WRITE8_MEMBER( anout_w ); DECLARE_READ8_MEMBER( anin_r ); DECLARE_WRITE8_MEMBER( anio_w ); DECLARE_READ8_MEMBER( st0_r ); DECLARE_READ8_MEMBER( st1_r ); DECLARE_READ8_MEMBER( st2_r ); DECLARE_READ8_MEMBER( usbs_r ); DECLARE_WRITE8_MEMBER( usbs_w ); DECLARE_WRITE8_MEMBER( paging_w ); DECLARE_READ_LINE_MEMBER( acia_rx ); DECLARE_WRITE_LINE_MEMBER( acia_tx ); DECLARE_WRITE_LINE_MEMBER( acia_interrupt ); DECLARE_WRITE_LINE_MEMBER( fdc_interrupt ); DECLARE_WRITE_LINE_MEMBER( ctc_z0_w ); DECLARE_WRITE_LINE_MEMBER( ctc_z1_w ); DECLARE_WRITE_LINE_MEMBER( ctc_z2_w ); DECLARE_WRITE_LINE_MEMBER( adc_eoc_w ); void bankswitch(); // paging state int m_paging; // paging enabled int m_mpm; // multi paging mode ? int m_a16; // address line 16 UINT8 m_pr[16]; // expansion interface paging register UINT8 *m_eim_ram; // expansion interface RAM // floppy state int m_fdc_int; // interrupt int m_fdc_att; // attention }; // ---------- defined in video/newbrain.c ---------- MACHINE_CONFIG_EXTERN( newbrain_video ); #endif
[ "pau@eslack.org" ]
pau@eslack.org
b627674bcb169c79bb94808c9e7f3580cb83a554
b4828cf9403fedde5dd346b3338a5f4bf0f1eb96
/leetcode_sol/39-Combination_Sum.cpp
1daa6de278e243fbfd5844ae0f199e58f6e1e9c6
[]
no_license
Masters-Akt/CS_codes
9ab3d87ca384ebd364c7b87c8da94b753082a7e3
1aaa107439f2e208bb67b0bcca676f90b6bc6a11
refs/heads/master
2023-01-24T00:11:05.151592
2023-01-21T18:45:57
2023-01-21T18:45:57
292,529,160
6
7
null
null
null
null
UTF-8
C++
false
false
714
cpp
class Solution { private: void backtrack(vector<vector<int>>& ans, vector<int>& candidates, vector<int> temp, int target, int start){ if(target<0) return; if(target==0) ans.push_back(temp); else{ for(int i=start; i<candidates.size();i++){ temp.push_back(candidates[i]); backtrack(ans, candidates, temp, target-candidates[i], i); temp.pop_back(); } } } public: vector<vector<int>> combinationSum(vector<int>& candidates, int target) { vector<vector<int>> ans; sort(candidates.begin(), candidates.end()); backtrack(ans, candidates, {}, target, 0); return ans; } };
[ "64123046+Masters-Akt@users.noreply.github.com" ]
64123046+Masters-Akt@users.noreply.github.com
172e6899e2704a6d3343ffbd097bcf956a7e1da1
270f8f38fa57bea3e99199450439da1c8106ad23
/src/engine/seeder.cpp
538d0dac23d70d1b5a3f337a3726c37865f8adac
[]
no_license
volodymyrkochyn/qttetris
b19dfa5a72f76b39721c4193e9b85191a162803d
8a271c83ce6cb85cbfd412be7adef5865d9d5fb8
refs/heads/master
2020-06-16T17:43:58.320734
2016-12-06T00:46:01
2016-12-06T00:46:01
75,079,117
0
0
null
null
null
null
UTF-8
C++
false
false
109
cpp
#include "seeder.h" #include <QTime> uint Seeder::seed() const { return QTime::currentTime().msec(); }
[ "vovakochun@gmail.com" ]
vovakochun@gmail.com
87751bf93e011afcf8453a3b4723e316f91ce716
70c7eaeade3152e2471dbed3e6dd1ac2372d8e16
/firmware/main/controller.hpp
7ba40d7e05bcad62130d9d773ae1ce00d9f517b8
[]
no_license
samsface/boop
b656afde87aa9bf0422527bafa2cc1f2a9e18f20
ead5580f1bb7ae5cbc7dbcb0292c9b88a9289328
refs/heads/master
2020-04-15T01:05:13.540245
2019-01-13T23:15:20
2019-01-13T23:15:20
164,263,115
0
0
null
null
null
null
UTF-8
C++
false
false
2,964
hpp
#pragma once #include "config.hpp" #include "comm.hpp" #include "script.hpp" void(*g_reboot)(void) = 0; struct comms { const config::config& c; comm::client<comm::channel::hardware_serial, comm::protocol> serial; comm::client<comm::channel::wifi, comm::protocol> wifi; comms(const config::config& c) : c{ c } {} void write(const message& m) { serial.write(m); wifi.write(m); } template<typename ...Args> void write_event(Args ...args) { serial.write_event(args...); wifi.write_event(args...); } template<typename ...Args> void write_ack(Args ...args) { serial.write_ack(args...); wifi.write_ack(args...); } }; class controller { config::config config_; comms comm_; script::runner script_runner_; void handle_ack(const message& msg) { if(msg.address == config_.address.get()) { script_runner_.clear_ack(msg.ack); } if(config_.is_relay.get()) { comm_.write(msg); } } void handle_function(const message& msg) { if(msg.address == config_.address.get()) { if(msg.function_code == reboot) g_reboot(); else if(msg.function_code == set_script0) script_runner_.set(0, msg.value); else if(msg.function_code == set_script1) script_runner_.set(1, msg.value); else if(msg.function_code == set_script2) script_runner_.set(2, msg.value); else if(msg.function_code == set_script3) script_runner_.set(3, msg.value); else if(msg.function_code == set_address) config_.address.set(msg.value[1]); else if(msg.function_code == set_is_relay) config_.is_relay.set(msg.value[0]); else if(msg.function_code == set_wifi_ssid) config_.wifi_ssid.set(msg.value); else if(msg.function_code == set_wifi_pass) config_.wifi_pass.set(msg.value); comm_.write_ack(msg.address, msg.ack); } else if(config_.is_relay.get()) { comm_.write(msg); } } void handle_event(const message& msg) { if(config_.is_relay.get()) { comm_.write(msg); } } void handle_message(const optional<message>& optional_msg) { if(optional_msg) { const auto& msg = optional_msg.value(); if(msg.is_ack()) handle_ack(msg); else if(msg.is_function()) handle_function(msg); else if(msg.is_event()) handle_event(msg); } } void read_comms() { comm_.wifi.keep_alive(); handle_message(comm_.serial.read()); handle_message(comm_.wifi.read()); } void run_scripts() { auto reading = script_runner_.tick(); if(reading) { comm_.write_event( config_.address.get(), reading->ack, reading->instruction, reading->value); } } public: controller() : comm_{ config_ } {} void tick() { read_comms(); run_scripts(); } void tick(size_t count) { while(--count + 1 != 0) tick(); } };
[ "samsface@gmail.com" ]
samsface@gmail.com
0a381e4ef1fdfdbfa79e92782a5692a993de96a4
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
/NT/drivers/serveravailability/watchdog/main.cpp
fce9b7feb2ee9ab048bce39510c3b2eb6e77262f
[]
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
6,922
cpp
/*++ Copyright (c) 1991 - 2001 Microsoft Corporation Module Name: ## ## ### #### ## # #### ##### ##### ### ### ### ## ### # ## # ## ## ## ## ######## ## ## ## #### # ## ## ## ## ## # ### ## ## ## ## # #### ## ## ## ## ## # # ## ####### ## # ### ## ##### ##### # ## ## ## ## # ## ## ## # ## ## # ## ## ## #### # # ## #### ## ## Abstract: This module contains the driver initializtion code. Author: Wesley Witt (wesw) 23-Jan-2002 Environment: Kernel mode only. Notes: --*/ #include "internal.h" #ifdef ALLOC_PRAGMA #pragma alloc_text(INIT,DriverEntry) #pragma alloc_text(PAGE,WdSystemControl) #pragma alloc_text(PAGE,WdDefaultDispatch) #pragma alloc_text(PAGE,WdShutdown) #endif // // Watchdog timer resource table // PWATCHDOG_TIMER_RESOURCE_TABLE WdTable; // // Control values // ULONG ShutdownCountTime; ULONG RunningCountTime; NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath ) /*++ Routine Description: Temporary entry point needed to initialize the scsi port driver. Arguments: DriverObject - Pointer to the driver object created by the system. RegistryPath - String containing the path to the driver's registry data Return Value: STATUS_SUCCESS --*/ { NTSTATUS Status = STATUS_SUCCESS; PKEY_VALUE_FULL_INFORMATION KeyInformation = NULL; PVOID WdTableTmp; #if DBG // // Get the debug level value from the registry // WdDebugLevel = 0; Status = ReadRegistryValue( RegistryPath, L"DebugLevel", &KeyInformation ); if (NT_SUCCESS(Status) && KeyInformation->Type == REG_DWORD) { WdDebugLevel = *(PULONG)((PUCHAR)KeyInformation + KeyInformation->DataOffset); } if (KeyInformation) { ExFreePool( KeyInformation ); } // // Get the OS version; this is used by the // port driver and the mini-ports to have // OS dependent code that is dynamic at runtime // GetOsVersion(); // // Print a banner that includes the // OS version and the version/build date // of the driver // PrintDriverVersion( DriverObject ); #endif // // Read in the registry control values // Status = ReadRegistryValue( RegistryPath, L"RunningCountTime", &KeyInformation ); if (NT_SUCCESS(Status) && KeyInformation->Type == REG_DWORD) { RunningCountTime = *(PULONG)((PUCHAR)KeyInformation + KeyInformation->DataOffset); } if (KeyInformation) { ExFreePool( KeyInformation ); } Status = ReadRegistryValue( RegistryPath, L"ShutdownCountTime", &KeyInformation ); if (NT_SUCCESS(Status) && KeyInformation->Type == REG_DWORD) { ShutdownCountTime = *(PULONG)((PUCHAR)KeyInformation + KeyInformation->DataOffset); } if (KeyInformation) { ExFreePool( KeyInformation ); } // // Set up the device driver entry points. // for (ULONG i=0; i<=IRP_MJ_MAXIMUM_FUNCTION; i++) { DriverObject->MajorFunction[i] = WdDefaultDispatch; } // // Set up the device driver's pnp-power routine & add routine // DriverObject->DriverExtension->AddDevice = WdAddDevice; // // Get a copy of the watchdog ACPI fixed table // WdTableTmp = (PVOID) WdGetAcpiTable( WDTT_SIGNATURE ); if (WdTableTmp) { DriverObject->MajorFunction[IRP_MJ_PNP] = WdPnp; DriverObject->MajorFunction[IRP_MJ_POWER] = WdPower; DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = WdShutdown; DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = WdSystemControl; WdTable = (PWATCHDOG_TIMER_RESOURCE_TABLE) ExAllocatePool( NonPagedPool, sizeof(WATCHDOG_TIMER_RESOURCE_TABLE) ); if (WdTable == NULL) { return STATUS_INSUFFICIENT_RESOURCES; } RtlCopyMemory( WdTable, WdTableTmp, sizeof(WATCHDOG_TIMER_RESOURCE_TABLE) ); // // Validate the registry settings // if (RunningCountTime) { RunningCountTime = ConvertTimeoutFromMilliseconds( WdTable->Units, RunningCountTime ); if (RunningCountTime > WdTable->MaxCount) { RunningCountTime = WdTable->MaxCount; } } if (ShutdownCountTime) { ShutdownCountTime = ConvertTimeoutFromMilliseconds( WdTable->Units, ShutdownCountTime ); if (ShutdownCountTime > WdTable->MaxCount) { ShutdownCountTime = WdTable->MaxCount; } } } return STATUS_SUCCESS; } NTSTATUS WdDefaultDispatch( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) /*++ Routine Description: This routine is the default dispatch which passes down to the next layer. Arguments: DeviceObject - Supplies the device object. Irp - Supplies the IO request packet. Return Value: NTSTATUS --*/ { UNREFERENCED_PARAMETER(DeviceObject); return CompleteRequest( Irp, STATUS_INVALID_DEVICE_REQUEST, 0 ); } NTSTATUS WdSystemControl( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) /*++ Routine Description: IRP_MJ_SYSTEM_CONTROL dispatch routine. Currently, we don't handle this. So, if this is FDO just pass it to the lower driver. If this is PDO complete the irp with changing the irp status. Arguments: DeviceObject - a pointer to the object that represents the device that I/O is to be done on. Irp - a pointer to the I/O Request Packet for this request. Return Value: --*/ { PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; IoSkipCurrentIrpStackLocation( Irp ); return IoCallDriver( DeviceExtension->TargetObject, Irp ); } NTSTATUS WdShutdown( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) /*++ Routine Description: This routine is called only rarely by the I/O system; it's mainly for layered drivers to call. All it does is complete the IRP successfully. Arguments: DeviceObject - a pointer to the object that represents the device that I/O is to be done on. Irp - a pointer to the I/O Request Packet for this request. Return Value: Always returns STATUS_SUCCESS, since this is a null operation. --*/ { NTSTATUS Status = STATUS_SUCCESS; PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); return ForwardRequest( Irp, DeviceExtension->TargetObject ); }
[ "seta7D5@protonmail.com" ]
seta7D5@protonmail.com
fcada4c9ccc791bd0c96796428df70d8b2cac9c9
d4d2b9b61c28947542b3d0b9a3d84b9031a04d30
/Menu.cpp
8b0d3c5b3dbd4653a69c7aa0cf052b2f5e5975bb
[]
no_license
DougHughes8906/find-the-thief
7a9d2c484529c027f4e1b1a369b10186f46046e7
6c31e8d26f9f957c1dca85f7265b1efeae2367fa
refs/heads/master
2020-09-19T16:19:40.421724
2019-12-16T17:38:26
2019-12-16T17:38:26
224,244,225
0
0
null
null
null
null
UTF-8
C++
false
false
5,256
cpp
/********************************************************************* ** Program name: Menu.cpp ** Author: Doug Hughes ** Date: December 2, 2019 ** Description: Implementation file for the Menu class. ** The class allows for the creation, storage, and use ** of a dynamic menu. The sole member variable is a ** vector of strings which holds all of the current ** options in the menu. There is both a method to ** add a single option and another method (actually ** same method name but overloaded) to add a list ** (represented as vector) of options. Additionally, ** there is a method to clear all options from the menu. ** Lastly, there is a method to prompt the user to select ** an option. The method will continue re-prompting the ** user until a valid option is selected and then will ** return the value of the option (represented as an ** integer). ** * Added November 20, 2019 - the changeOption method which ** allows individual options in the menu to be changed. ** * Added December 2, 2019 - the deleteLast method which ** deletes the last option in the menu. *********************************************************************/ #include "Menu.hpp" #include "intValid.hpp" #include <vector> #include <string> #include <iostream> /*********************************************************************** Default constructor for a Menu object. The constructor does not take any action. Simply serves to initialize a Menu object. ***********************************************************************/ Menu::Menu() {} /*********************************************************************** Constructor with a vector of strings parameter. All options in the parameter are added to the menu. ***********************************************************************/ Menu::Menu(std::vector<std::string> ops) { options = ops; } /*********************************************************************** Returns the number of options currently in the menu. ***********************************************************************/ int Menu::getNumOptions() const { return options.size(); } /*********************************************************************** Adds the value of the string parameter as an option to the menu. The option will be added to the end of the menu (i.e. it will now be the last option). ***********************************************************************/ void Menu::addOption(std::string op) { options.push_back(op); } /*********************************************************************** Adds all strings in the vector parameter as options to the menu. The options are added to the end of the menu in the order of the their index in the parameter (from lowest to highest). ***********************************************************************/ void Menu::addOption(std::vector<std::string> ops) { for (std::string op : ops) options.push_back(op); } /*********************************************************************** Changes a single option in the menu with the argument passed. The first parameter is the option value to change (the option values start at 1 and are the same as the menu output) and the second parameter is the new text of the option. The method returns false and does nothing if the option value passed does not exist for the menu, and returns true otherwise. ***********************************************************************/ bool Menu::changeOption(int opVal, std::string op) { if (opVal < 1 || opVal > options.size()) { return false; } else { options[opVal - 1] = op; return true; } } /*********************************************************************** Deletes all options from the menu (i.e. after a call to this function the size of the vector member variable options will be 0). ***********************************************************************/ void Menu::clearMenu() { options.clear(); } /*********************************************************************** Prompts the user to select an option from the menu and returns the number of the option selected. The numbers start at 1 and end at the number of options available (the number selected by the user is the number returned by this function, so the return value for the first option being selected will be 1 rather than 0). The function returns -1 if there are no options currently in the menu (and there are no prompts to the user). ***********************************************************************/ int Menu::chooseOption() const { // return -1 if no options in menu if (options.size() == 0) return -1; std::cout << "Please select one of the options below.\n" << "To select an option, type the number next to the " << "option and press ENTER.\n"; int opNum = 1; while (opNum <= options.size()) { std::cout << "(" << opNum << ") " << options[opNum - 1] << "\n"; opNum++; } return intValid(1, options.size()); } /*********************************************************************** Deletes the last option in the menu. The method takes no parameters and has no return value. ***********************************************************************/ void Menu::deleteLast() { options.pop_back(); }
[ "dhughes8906@gmail.com" ]
dhughes8906@gmail.com
2fc1e5d12a4bad7722d2cf655f848518f86f7a3c
0e330acab757857fb0855b8a03e4f1c113e64b13
/src/LatMRGRoutines.cc
34b128e4ffc50f372d2cf1560f6b198ab4ce8037
[]
no_license
erwanbou/LatMRG
8ce14730ac68feba840f1c04d45a0ce251bff8f1
8ecc3a9c95c211f0fe534de54c4217f1baaf1a63
refs/heads/master
2021-01-23T12:33:45.686517
2017-09-01T22:09:56
2017-09-01T22:09:56
93,171,349
0
2
null
null
null
null
UTF-8
C++
false
false
10,424
cc
// This file is part of LatMRG. // // LatMRG // Copyright (C) 2012-2016 Pierre L'Ecuyer and Universite de Montreal // // 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 <fnmatch.h> #include <dirent.h> #include <sys/types.h> #include <cerrno> #include <vector> #include <string> #include <iostream> #include "latticetester/Types.h" #include "latticetester/Util.h" #include "latticetester/Const.h" #include "latmrg/LatConfig.h" #include "latmrg/ParamReaderLat.h" #include "latmrg/KorobovLattice.h" #include "latmrg/Rank1Lattice.h" #include "latmrg/MRGLatticeFactory.h" #include "latmrg/MRGLattice.h" #include "latmrg/MRGLatticeLac.h" #include "latmrg/MMRGLattice.h" #include "latmrg/LatTestAll.h" #include "latmrg/LatTestBeyer.h" #include "latmrg/LatTestSpectral.h" #include "latmrg/LatTestPalpha.h" #include "latmrg/Formatter.h" #include "latmrg/WriterRes.h" #include "latmrg/ReportHeaderLat.h" #include "latmrg/ReportFooterLat.h" #include "latmrg/ReportLat.h" #include "latticetester/Normalizer.h" #include "latticetester/NormaPalpha.h" #include "latmrg/TestProjections.h" #include "latmrg/LatMRGRoutines.h" using namespace std; // using namespace NTL; using namespace LatMRG; using namespace LatticeTester; namespace LatMRG { //*============================================================================================= std::vector<double> ComputeFigureOfMerit (LatConfig& config) { //Writer* rw = createWriter (infile, config.outputType); std::vector<double> result; LatMRG::IntLattice *lattice = 0; LatMRG::IntLattice *master = 0; Lacunary *plac = 0; bool stationary = true; int toDim = config.td[1]; int fromDim = config.td[0]; bool memLacF = true; // Lacunary with only used lines-columns of bases //memLacF = false; // Lacunary with all lines-columns of bases if (config.J > 1) { //Several MRG lattice = MRGLatticeFactory::fromCombMRG (config.comp, config.J, toDim, 0, config.latType, config.norm); } else { if (config.latType == PRIMEPOWER) { config.comp[0]->module.reduceM (config.comp[0]->a[0]); if (memLacF && config.lacunary) lattice = new MRGLatticeLac (config.comp[0]->module.mRed, config.comp[0]->a, toDim, config.comp[0]->k, config.Lac, config.latType, config.norm); else{ lattice = new MRGLattice (config.comp[0]->module.mRed, config.comp[0]->a, toDim, config.comp[0]->k, config.latType, config.norm); } } else if (config.genType[0] == MRG || config.genType[0] == LCG) { if (memLacF && config.lacunary){ lattice = new MRGLatticeLac (config.comp[0]->module.mRed, config.comp[0]->a, toDim, config.comp[0]->k, config.Lac, config.latType, config.norm); } else{ lattice = new MRGLattice (config.comp[0]->module.mRed, config.comp[0]->a, toDim, config.comp[0]->k, config.latType, config.norm); } } else if (config.genType[0] == KOROBOV) { lattice = new KorobovLattice (config.comp[0]->getM (), config.comp[0]->a[1], toDim, config.norm); } else if (config.genType[0] == RANK1) { stationary = false; lattice = new Rank1Lattice (config.comp[0]->getM (), config.comp[0]->a, config.comp[0]->k, config.norm); } else if (config.genType[0] == MMRG) { if (memLacF && config.lacunary) { lattice = new MMRGLattice (config.comp[0]->getM(), config.comp[0]->A, toDim,config.comp[0]->k, config.lacunaryType, config.Lac, config.norm); } else { lattice = new MMRGLattice (config.comp[0]->getM(), config.comp[0]->A, toDim,config.comp[0]->k, config.norm); } } } double minVal[1 + toDim]; SetZero (minVal, toDim); Normalizer *normal = 0; if (config.criter == SPECTRAL) { normal = lattice->getNormalizer (config.norma, 0, config.dualF); // creates and returns the normalizer corresponding to config.norma normal->setNorm (config.norm); } else if (config.criter == PALPHA && (config.calcPalpha == NORMPAL || config.calcPalpha == BAL)) { normal = new NormaPalpha (lattice->getModulo(), config.alpha, toDim); } if (!memLacF && config.lacunary) { plac = new Lacunary (config.Lac, toDim); lattice->setLac (*plac); } switch (config.criter) { case SPECTRAL: { LatTestSpectral spectralTest (normal, lattice); lattice->buildBasis (fromDim - 1); //spectralTest.attach (&report); //report.printHeader (); spectralTest.setDualFlag (config.dualF); spectralTest.setInvertFlag (config.invertF); spectralTest.setDetailFlag (config.detailF); spectralTest.setMaxAllDimFlag (true); spectralTest.setMaxNodesBB (config.maxNodesBB); if (1 == config.d) { spectralTest.test (fromDim, toDim, minVal); // lattice->write(); //footer.setLatticeTest (&spectralTest); //report.printTable (); //report.printFooter (); } else { if (config.genType[0] == MRG || config.genType[0] == LCG) master = new MRGLattice (*(MRGLattice *) lattice); else if (config.genType[0] == KOROBOV) master = new KorobovLattice (*(KorobovLattice *) lattice); else if (config.genType[0] == RANK1) master = new Rank1Lattice (*(Rank1Lattice *) lattice); master->buildBasis (toDim); TestProjections proj (master, lattice, &spectralTest, config.td, config.d); //proj. setOutput (rw); proj.setDualFlag (config.dualF); proj.setPrintF (true); double merit = proj.run (stationary, false, minVal); int nbProj = proj.getNumProjections (); /*rw->writeString ("\nMin merit: "); rw->writeDouble (sqrt (merit)); rw->newLine (); rw->writeString ("Num projections: "); rw->writeInt (nbProj); rw->newLine ();*/ // nbProj = proj.calcNumProjections(stationary, false); // cout << "Num projections2: " << nbProj << endl << endl; delete master; } // storing the figures of merit in result for (int i = fromDim; i <= toDim; i++) result.push_back(spectralTest.getMerit().getNormVal(i)); } break; case BEYER: { LatTestBeyer beyerTest (lattice); lattice->buildBasis (fromDim - 1); //beyerTest.attach (&report); //report.printHeader (); beyerTest.setDualFlag (config.dualF); beyerTest.setMaxAllDimFlag (true); beyerTest.setMaxNodesBB (config.maxNodesBB); beyerTest.setDetailFlag (config.detailF); beyerTest.test (fromDim, toDim, minVal); //footer.setLatticeTest (&beyerTest); //report.printTable (); //report.printFooter (); //rw->writeString (lattice->toStringDualBasis ()); // storing the figures of merit in result for (int i = fromDim; i <= toDim; i++) result.push_back(beyerTest.getMerit().getNormVal(i)); } break; case PALPHA: { LatTestPalpha palphaTest (normal, lattice); palphaTest.setConfig (&config); //palphaTest.attach (&report); //report.printHeader (); if (1 == config.d) { palphaTest.test (fromDim, toDim, minVal); //footer.setLatticeTest (&palphaTest); //report.printTable (); //report.printFooter (); } else { MRGLattice master = MRGLattice (*(MRGLattice *) lattice); master.buildBasis (toDim); TestProjections proj (&master, lattice, &palphaTest, config.td, config.d); //proj. setOutput (rw); double merit = proj.run (true, false, minVal); int nbProj = proj.getNumProjections (); /*rw->writeString ("\n\nMin merit: "); rw->writeDouble (sqrt (merit)); rw->newLine (); rw->writeString ("Num projections: "); rw->writeInt (nbProj); rw->newLine (); rw->newLine ();*/ } // storing the figures of merit in result for (int i = fromDim; i <= toDim; i++) result.push_back(palphaTest.getMerit().getNormVal(i)); } break; default: cerr << "Default case for config.criter" << endl; return result; } if (normal != 0) delete normal; if (!memLacF && config.lacunary) delete plac; delete lattice; //delete rw; return result; } //*============================================================================================= void printResult(const std::vector<double> & result, const int & fromDim) { cout << "Result: " << endl; for (int i = 0; i < result.size(); ++i) cout << " dim " << fromDim+i << " = " << sqrt(result[i]) << endl; } //*============================================================================================= void initConfigSpectralTest(LatConfig& config) {} //*============================================================================================= void initConfigBeyerTest(LatConfig& config) {} //*============================================================================================= void initConfigPalphaTest(LatConfig& config) {} //*============================================================================================= }
[ "paul.wambergue@gmail.com" ]
paul.wambergue@gmail.com
6108b014744b36a430f03d4bd50b66dd2500e3b9
715023da006513f0dd09e5c4267d371b8ba4e4f6
/xray-svn-trunk/xr_3da/line_edit_control.cpp
9f5defe269d3b8bbb6f16cb7b6e72482296d06cf
[]
no_license
tsnest/lost-alpha-dc-sources-master
5727d58878b1d4036e8f68df9780f3d078e89f21
fbb61af25da7e722d21492cbaebd6670d84e211c
refs/heads/main
2023-02-11T16:37:16.570856
2021-01-09T17:09:49
2021-01-09T17:09:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
23,081
cpp
//////////////////////////////////////////////////////////////////////////// // Module : line_edit_control.cpp // Created : 21.02.2008 // Author : Evgeniy Sokolov // Description : line edit control class implementation //////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "line_edit_control.h" #include "../xrCore/os_clipboard.h" #include "xrGame/object_broker.h" #include "xr_input.h" #include "edit_actions.h" ENGINE_API float g_console_sensitive = 0.15f; namespace text_editor { static bool terminate_char( char c, bool check_space = false ) { switch ( c ) { case ' ': return check_space; case '(': case ')': case '{': case '}': case '[': case ']': case '<': case '>': case '\'': case '\"': case '=': case '+': case '-': case '*': case '\\': case '/': case '&': case '|': case '!': case '@': case '#': case '~': case '`': case '$': case '%': case '^': case ':': case ';': case '?': case ',': case '.': case '_': return true; } return false; } // ------------------------------------------------------------------------------------------------- line_edit_control::line_edit_control( u32 str_buffer_size, bool translate ) { m_edit_str = NULL; m_inserted = NULL; m_undo_buf = NULL; m_buf0 = NULL; m_buf1 = NULL; m_buf2 = NULL; m_buf3 = NULL; for ( u32 i = 0; i < DIK_COUNT; ++i ) { m_actions[i] = NULL; } init( str_buffer_size, im_standart, translate); update_key_states (); } line_edit_control::~line_edit_control() { xr_free( m_edit_str ); xr_free( m_inserted ); xr_free( m_undo_buf ); xr_free( m_buf0 ); xr_free( m_buf1 ); xr_free( m_buf2 ); xr_free( m_buf3 ); size_t const array_size = sizeof(m_actions)/sizeof(m_actions[0]); buffer_vector<Base*> actions(m_actions, array_size, &m_actions[0], &m_actions[0] + array_size); std::sort (actions.begin(), actions.end()); actions.erase ( std::unique( actions.begin(), actions.end() ), actions.end() ); delete_data ( actions ); } static inline bool get_caps_lock_state () { #if 0 static bool first_time = true; static bool is_windows_vista_or_later = false; if ( first_time ) { first_time = false; OSVERSIONINFO version_info; ZeroMemory ( &version_info, sizeof(version_info) ); version_info.dwOSVersionInfoSize = sizeof(version_info); GetVersionEx ( &version_info ); is_windows_vista_or_later = version_info.dwMajorVersion >= 6; } if ( is_windows_vista_or_later ) return !!(GetKeyState(VK_CAPITAL) & 1); else #else // #if 0 return false; #endif // #if 0 } void line_edit_control::update_key_states () { m_key_state.zero( ); set_key_state ( ks_LShift, !!pInput->iGetAsyncKeyState(DIK_LSHIFT) ); set_key_state ( ks_RShift, !!pInput->iGetAsyncKeyState(DIK_RSHIFT) ); set_key_state ( ks_LCtrl, !!pInput->iGetAsyncKeyState(DIK_LCONTROL) ); set_key_state ( ks_RCtrl, !!pInput->iGetAsyncKeyState(DIK_RCONTROL) ); set_key_state ( ks_LAlt, !!pInput->iGetAsyncKeyState(DIK_LALT) ); set_key_state ( ks_RAlt, !!pInput->iGetAsyncKeyState(DIK_RALT) ); set_key_state ( ks_CapsLock, text_editor::get_caps_lock_state() ); } void line_edit_control::clear_states() { m_edit_str[0] = 0; clear_inserted(); m_undo_buf[0] = 0; m_buf0[0] = 0; m_buf1[0] = 0; m_buf2[0] = 0; m_buf3[0] = 0; m_cur_pos = 0; m_select_start = 0; m_p1 = 0; m_p2 = 0; m_accel = 1.0f; m_cur_time = 0.0f; m_rep_time = 0.0f; m_last_frame_time = 0; m_last_key_time = 0.0f; m_last_changed_frame = 0; m_hold_mode = false; m_insert_mode = false; m_repeat_mode = false; m_mark = false; m_cursor_view = false; m_need_update = false; m_unselected_mode = false; update_key_states ( ); } void line_edit_control::init( u32 str_buffer_size, init_mode mode, bool translate ) { m_buffer_size = str_buffer_size; clamp( m_buffer_size, (int)MIN_BUF_SIZE, (int)MAX_BUF_SIZE ); xr_free( m_edit_str ); m_edit_str = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_inserted ); m_inserted = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_undo_buf ); m_undo_buf = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_buf0 ); m_buf0 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_buf1 ); m_buf1 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_buf2 ); m_buf2 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); xr_free( m_buf3 ); m_buf3 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) ); clear_states(); for ( u32 i = 0; i < DIK_COUNT; ++i ) { xr_delete( m_actions[i] ); m_actions[i] = NULL; } if ( mode == im_read_only ) { assign_callback( DIK_A , ks_Ctrl, Callback( this, &line_edit_control::select_all_buf ) ); assign_callback( DIK_C , ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard ) ); assign_callback( DIK_INSERT, ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard ) ); assign_callback( DIK_HOME , ks_free, Callback( this, &line_edit_control::move_pos_home ) ); assign_callback( DIK_END , ks_free, Callback( this, &line_edit_control::move_pos_end ) ); assign_callback( DIK_LEFT , ks_free, Callback( this, &line_edit_control::move_pos_left ) ); assign_callback( DIK_RIGHT , ks_free, Callback( this, &line_edit_control::move_pos_right ) ); assign_callback( DIK_LEFT , ks_Ctrl, Callback( this, &line_edit_control::move_pos_left_word ) ); assign_callback( DIK_RIGHT , ks_Ctrl, Callback( this, &line_edit_control::move_pos_right_word ) ); } else { assign_char_pairs( mode, translate ); assign_callback( DIK_INSERT, ks_free, Callback( this, &line_edit_control::flip_insert_mode ) ); assign_callback( DIK_A , ks_Ctrl, Callback( this, &line_edit_control::select_all_buf ) ); assign_callback( DIK_Z , ks_Ctrl, Callback( this, &line_edit_control::undo_buf ) ); assign_callback( DIK_C , ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard ) ); assign_callback( DIK_V , ks_Ctrl, Callback( this, &line_edit_control::paste_from_clipboard ) ); assign_callback( DIK_X , ks_Ctrl, Callback( this, &line_edit_control::cut_to_clipboard ) ); assign_callback( DIK_INSERT, ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard ) ); assign_callback( DIK_INSERT, ks_Shift,Callback( this, &line_edit_control::paste_from_clipboard ) ); assign_callback( DIK_DELETE, ks_Shift,Callback( this, &line_edit_control::cut_to_clipboard ) ); assign_callback( DIK_HOME , ks_free, Callback( this, &line_edit_control::move_pos_home ) ); assign_callback( DIK_END , ks_free, Callback( this, &line_edit_control::move_pos_end ) ); assign_callback( DIK_LEFT , ks_free, Callback( this, &line_edit_control::move_pos_left ) ); assign_callback( DIK_RIGHT , ks_free, Callback( this, &line_edit_control::move_pos_right ) ); assign_callback( DIK_LEFT , ks_Ctrl, Callback( this, &line_edit_control::move_pos_left_word ) ); assign_callback( DIK_RIGHT , ks_Ctrl, Callback( this, &line_edit_control::move_pos_right_word ) ); assign_callback( DIK_BACK , ks_free, Callback( this, &line_edit_control::delete_selected_back ) ); assign_callback( DIK_DELETE, ks_free, Callback( this, &line_edit_control::delete_selected_forward ) ); assign_callback( DIK_BACK , ks_Ctrl, Callback( this, &line_edit_control::delete_word_back ) ); assign_callback( DIK_DELETE, ks_Ctrl, Callback( this, &line_edit_control::delete_word_forward ) ); assign_callback( DIK_LSHIFT, ks_Ctrl, Callback( this, &line_edit_control::SwitchKL ) ); assign_callback( DIK_LSHIFT, ks_Alt, Callback( this, &line_edit_control::SwitchKL ) ); } // if mode create_key_state( DIK_LSHIFT , ks_LShift ); create_key_state( DIK_RSHIFT , ks_RShift ); create_key_state( DIK_LCONTROL, ks_LCtrl ); create_key_state( DIK_RCONTROL, ks_RCtrl ); create_key_state( DIK_LALT , ks_LAlt ); create_key_state( DIK_RALT , ks_RAlt ); } void line_edit_control::assign_char_pairs( init_mode mode, bool translate) { create_char_pair( DIK_NUMPAD0, '0', '0' ); create_char_pair( DIK_NUMPAD1, '1', '1' ); create_char_pair( DIK_NUMPAD2, '2', '2' ); create_char_pair( DIK_NUMPAD3, '3', '3' ); create_char_pair( DIK_NUMPAD4, '4', '4' ); create_char_pair( DIK_NUMPAD5, '5', '5' ); create_char_pair( DIK_NUMPAD6, '6', '6' ); create_char_pair( DIK_NUMPAD7, '7', '7' ); create_char_pair( DIK_NUMPAD8, '8', '8' ); create_char_pair( DIK_NUMPAD9, '9', '9' ); if ( mode == im_number_only ) { create_char_pair( DIK_0, '0', '0' ); create_char_pair( DIK_1, '1', '1' ); create_char_pair( DIK_2, '2', '2' ); create_char_pair( DIK_3, '3', '3' ); create_char_pair( DIK_4, '4', '4' ); create_char_pair( DIK_5, '5', '5' ); create_char_pair( DIK_6, '6', '6' ); create_char_pair( DIK_7, '7', '7' ); create_char_pair( DIK_8, '8', '8' ); create_char_pair( DIK_9, '9', '9' ); create_char_pair( DIK_NUMPADMINUS , '-', '-' ); create_char_pair( DIK_MINUS , '-', '-' ); create_char_pair( DIK_NUMPADPLUS , '+', '+' ); create_char_pair( DIK_EQUALS , '+', '+' ); return; } if ( mode != im_file_name_mode ) { create_char_pair( DIK_0, '0', ')', translate ); create_char_pair( DIK_1, '1', '!', translate ); create_char_pair( DIK_2, '2', '@', translate ); create_char_pair( DIK_3, '3', '#', translate ); create_char_pair( DIK_4, '4', '$', translate ); create_char_pair( DIK_5, '5', '%', translate ); create_char_pair( DIK_6, '6', '^', translate ); create_char_pair( DIK_7, '7', '&', translate ); create_char_pair( DIK_8, '8', '*', translate ); create_char_pair( DIK_9, '9', '(', translate ); create_char_pair( DIK_BACKSLASH , '\\', '|', translate ); create_char_pair( DIK_LBRACKET , '[' , '{', translate ); create_char_pair( DIK_RBRACKET , ']' , '}', translate ); create_char_pair( DIK_APOSTROPHE, '\'', '\"',translate ); create_char_pair( DIK_COMMA , ',' , '<', translate ); create_char_pair( DIK_PERIOD , '.' , '>', translate ); create_char_pair( DIK_EQUALS , '=' , '+', translate ); create_char_pair( DIK_SEMICOLON , ';' , ':', translate ); create_char_pair( DIK_SLASH , '/' , '?', translate ); create_char_pair( DIK_NUMPADSTAR , '*', '*' ); create_char_pair( DIK_NUMPADSLASH, '/', '/' ); } else { create_char_pair( DIK_0, '0', '0' ); create_char_pair( DIK_1, '1', '1' ); create_char_pair( DIK_2, '2', '2' ); create_char_pair( DIK_3, '3', '3' ); create_char_pair( DIK_4, '4', '4' ); create_char_pair( DIK_5, '5', '5' ); create_char_pair( DIK_6, '6', '6' ); create_char_pair( DIK_7, '7', '7' ); create_char_pair( DIK_8, '8', '8' ); create_char_pair( DIK_9, '9', '9' ); } create_char_pair( DIK_NUMPADMINUS , '-', '-' ); create_char_pair( DIK_NUMPADPLUS , '+', '+' ); create_char_pair( DIK_NUMPADPERIOD, '.', '.' ); create_char_pair( DIK_MINUS , '-', '_', translate ); create_char_pair( DIK_SPACE , ' ', ' ' ); create_char_pair( DIK_GRAVE , '`', '~', translate ); create_char_pair( DIK_A, 'a', 'A', translate ); create_char_pair( DIK_B, 'b', 'B', translate ); create_char_pair( DIK_C, 'c', 'C', translate ); create_char_pair( DIK_D, 'd', 'D', translate ); create_char_pair( DIK_E, 'e', 'E', translate ); create_char_pair( DIK_F, 'f', 'F', translate ); create_char_pair( DIK_G, 'g', 'G', translate ); create_char_pair( DIK_H, 'h', 'H', translate ); create_char_pair( DIK_I, 'i', 'I', translate ); create_char_pair( DIK_J, 'j', 'J', translate ); create_char_pair( DIK_K, 'k', 'K', translate ); create_char_pair( DIK_L, 'l', 'L', translate ); create_char_pair( DIK_M, 'm', 'M', translate ); create_char_pair( DIK_N, 'n', 'N', translate ); create_char_pair( DIK_O, 'o', 'O', translate ); create_char_pair( DIK_P, 'p', 'P', translate ); create_char_pair( DIK_Q, 'q', 'Q', translate ); create_char_pair( DIK_R, 'r', 'R', translate ); create_char_pair( DIK_S, 's', 'S', translate ); create_char_pair( DIK_T, 't', 'T', translate ); create_char_pair( DIK_U, 'u', 'U', translate ); create_char_pair( DIK_V, 'v', 'V', translate ); create_char_pair( DIK_W, 'w', 'W', translate ); create_char_pair( DIK_X, 'x', 'X', translate ); create_char_pair( DIK_Y, 'y', 'Y', translate ); create_char_pair( DIK_Z, 'z', 'Z', translate ); } void line_edit_control::create_key_state( u32 const dik, key_state state ) { Base* prev = m_actions[dik]; //if ( m_actions[dik] ) //{ // xr_delete( m_actions[dik] ); //} m_actions[dik] = new text_editor::key_state_base( state, prev ); } void line_edit_control::create_char_pair( u32 const dik, char c, char c_shift, bool translate ) { if ( m_actions[dik] ) { xr_delete( m_actions[dik] ); } m_actions[dik] = new text_editor::type_pair( dik, c, c_shift, translate ); } void line_edit_control::assign_callback( u32 const dik, key_state state, Callback const& callback ) { VERIFY( dik < DIK_COUNT ); Base* prev_action = m_actions[dik]; m_actions[dik] = new text_editor::callback_base( callback, state ); m_actions[dik]->on_assign( prev_action ); } void line_edit_control::insert_character( char c ) { m_inserted[0] = c; } void line_edit_control::clear_inserted() { m_inserted[0] = m_inserted[1] = 0; } bool line_edit_control::empty_inserted() { return (m_inserted[0] == 0); } void line_edit_control::set_edit( LPCSTR str ) { u32 str_size = xr_strlen( str ); clamp( str_size, (u32)0, (u32)(m_buffer_size-1) ); strncpy_s( m_edit_str, m_buffer_size, str, str_size ); m_edit_str[str_size] = 0; m_cur_pos = str_size; m_select_start = m_cur_pos; m_accel = 1.0f; update_bufs(); } // ======================================================== void line_edit_control::on_key_press( int dik ) { if ( DIK_COUNT <= dik ) { return; } if ( !m_hold_mode ) { m_last_key_time = 0.0f; m_accel = 1.0f; } m_mark = true; clamp_cur_pos(); clear_inserted(); compute_positions(); if ( m_actions[dik] ) { m_actions[dik]->on_key_press( this ); } // =========== if ( dik == DIK_LCONTROL || dik == DIK_RCONTROL ) { m_mark = false; } m_edit_str[m_buffer_size-1] = 0; clamp_cur_pos(); add_inserted_text(); if ( m_mark && (!get_key_state( ks_Shift ) || !empty_inserted() ) ) { m_select_start = m_cur_pos; } compute_positions(); m_repeat_mode = false; m_rep_time = 0.0f; update_key_states( ); update_bufs(); } // ------------------------------------------------------------------------------------------------- void line_edit_control::on_key_hold( int dik ) { update_key_states( ); update_bufs(); switch ( dik ) { case DIK_TAB: case DIK_LSHIFT: case DIK_RSHIFT: case DIK_LCONTROL: case DIK_RCONTROL: case DIK_LALT: case DIK_RALT: return; break; } if ( m_repeat_mode && m_last_key_time > 5.0f * g_console_sensitive ) { float buf_time = m_rep_time; m_hold_mode = true; on_key_press( dik ); m_hold_mode = false; m_rep_time = buf_time; } } void line_edit_control::on_key_release( int dik ) { m_accel = 1.0f; m_rep_time = 0.0f; m_last_key_time = 0.0f; update_key_states( ); update_bufs ( ); } void line_edit_control::on_frame() { update_key_states ( ); u32 fr_time = Device.dwTimeContinual; float dt = (fr_time - m_last_frame_time) * 0.001f; if ( dt > 0.06666f ) { dt = 0.06666f; } m_last_frame_time = fr_time; m_cur_time += dt; m_cursor_view = true; if ( m_cur_time > 0.3f ) { m_cursor_view = false; } if ( m_cur_time > 0.4f ) { m_cur_time = 0.0f; } m_rep_time += dt * m_accel; if ( m_rep_time > g_console_sensitive )//0.2 { m_rep_time = 0.0f; m_repeat_mode = true; m_accel += 0.2f; } m_last_key_time += dt; if ( m_last_changed_frame + 1 < Device.dwFrame ) { m_need_update = false; } /*if ( Device.dwFrame % 100 == 0 ) { Msg( " cur_time=%.2f re=%d acc=%.2f rep_time=%.2f", cur_time, bRepeat, fAccel, rep_time ); }*/ } void line_edit_control::update_bufs() { //separate_buffer m_buf0[0] = 0; m_buf1[0] = 0; m_buf2[0] = 0; m_buf3[0] = 0; int edit_size = (int)xr_strlen( m_edit_str ); int ds = (m_cursor_view && m_insert_mode && m_p2 < edit_size)? 1 : 0; strncpy_s( m_buf0, m_buffer_size, m_edit_str, m_cur_pos ); strncpy_s( m_buf1, m_buffer_size, m_edit_str, m_p1 ); strncpy_s( m_buf2, m_buffer_size, m_edit_str + m_p1, m_p2 - m_p1 + ds ); strncpy_s( m_buf3, m_buffer_size, m_edit_str + m_p2 + ds, edit_size - m_p2 - ds ); m_need_update = true; m_last_changed_frame = Device.dwFrame; // if ( m_cursor_view ) { // Msg( " m_p1=%d m_p2=%d cur=%d sstart=%d", m_p1, m_p2, m_cur_pos, m_select_start ); } } void line_edit_control::add_inserted_text() { if ( empty_inserted() ) { return; } int old_edit_size = (int)xr_strlen( m_edit_str ); for ( int i = 0; i < old_edit_size; ++i ) { if ( ( m_edit_str[i] == '\n' ) || ( m_edit_str[i] == '\t' ) ) { m_edit_str[i]=' '; } } PSTR buf = (PSTR)_alloca( (m_buffer_size + 1) * sizeof(char) ); strncpy_s( buf, m_buffer_size, m_edit_str, m_p1 ); // part 1 strncpy_s( m_undo_buf, m_buffer_size, m_edit_str + m_p1, m_p2 - m_p1 ); int new_size = (int)xr_strlen( m_inserted ); if ( m_buffer_size - 1 < m_p1 + new_size ) { m_inserted[m_buffer_size - 1 - m_p1] = 0; new_size = xr_strlen( m_inserted ); } strncpy_s( buf + m_p1, m_buffer_size, m_inserted, _min(new_size, m_buffer_size - m_p1) ); // part 2 u8 ds = (m_insert_mode && m_p2 < old_edit_size)? 1 : 0; strncpy_s( buf + m_p1 + new_size, m_buffer_size, m_edit_str + m_p2 + ds, _min(old_edit_size - m_p2 - ds, m_buffer_size - m_p1 - new_size) ); // part 3 buf[m_buffer_size] = 0; int szn = m_p1 + new_size + old_edit_size - m_p2 - ds; if ( szn < m_buffer_size ) { strncpy_s( m_edit_str, m_buffer_size, buf, szn ); // part 1+2+3 m_edit_str[m_buffer_size-1] = 0; m_cur_pos = m_p1 + new_size; } clamp_cur_pos(); } //------------------------------------------------ void line_edit_control::copy_to_clipboard() { if ( m_p1 >= m_p2 ) { return; } u32 edit_len = xr_strlen( m_edit_str ); PSTR buf = (PSTR)_alloca( (edit_len + 1) * sizeof(char) ); strncpy_s( buf, edit_len + 1, m_edit_str + m_p1, m_p2 - m_p1 ); buf[edit_len] = 0; os_clipboard::copy_to_clipboard( buf ); m_mark = false; } void line_edit_control::paste_from_clipboard() { os_clipboard::paste_from_clipboard( m_inserted, m_buffer_size-1 ); } void line_edit_control::cut_to_clipboard() { copy_to_clipboard(); delete_selected_forward(); } // ================================================================================================= void line_edit_control::undo_buf() { xr_strcpy( m_inserted, m_buffer_size, m_undo_buf ); m_undo_buf[0] = 0; } void line_edit_control::select_all_buf() { m_select_start = 0; m_cur_pos = (int)xr_strlen( m_edit_str ); m_mark = false; } void line_edit_control::flip_insert_mode() { m_insert_mode = !m_insert_mode; } void line_edit_control::delete_selected_back() { delete_selected( true ); } void line_edit_control::delete_selected_forward() { delete_selected( false ); } void line_edit_control::delete_selected( bool back ) { clamp_cur_pos(); int edit_len = (int)xr_strlen( m_edit_str ); if ( edit_len > 0 ) { if ( back ) { u8 dp = ( (m_p1 == m_p2) && m_p1 > 0 )? 1 : 0; strncpy_s( m_undo_buf, m_buffer_size, m_edit_str + m_p1 - dp, m_p2 - m_p1 + dp ); strncpy_s( m_edit_str + m_p1 - dp, m_buffer_size, m_edit_str + m_p2, edit_len - m_p2 ); m_cur_pos = m_p1 - dp; } else { u8 dn = ( (m_p1 == m_p2) && m_p2 < edit_len )? 1 : 0; strncpy_s( m_undo_buf, m_buffer_size, m_edit_str + m_p1, m_p2 - m_p1 + dn ); strncpy_s( m_edit_str + m_p1, m_buffer_size, m_edit_str + m_p2 + dn, edit_len - m_p2 - dn ); m_cur_pos = m_p1; } clamp_cur_pos(); } m_select_start = m_cur_pos; } void line_edit_control::delete_word_back() { bool const left_shift = get_key_state(ks_LShift); bool const right_shift = get_key_state(ks_RShift); set_key_state ( ks_Shift, true ); move_pos_left_word ( ); compute_positions ( ); delete_selected ( true ); set_key_state ( ks_LShift, left_shift ); set_key_state ( ks_RShift, right_shift ); } void line_edit_control::delete_word_forward() { set_key_state( ks_Shift, true ); move_pos_right_word(); compute_positions(); delete_selected( false ); set_key_state( ks_Shift, false ); } void line_edit_control::move_pos_home() { m_cur_pos = 0; } void line_edit_control::move_pos_end() { m_cur_pos = (int)xr_strlen( m_edit_str ); } void line_edit_control::move_pos_left() { --m_cur_pos; } void line_edit_control::move_pos_right() { ++m_cur_pos; } void line_edit_control::move_pos_left_word() { int i = m_cur_pos - 1; while ( i >= 0 && m_edit_str[i] == ' ' ) { --i; } if ( !terminate_char( m_edit_str[i] ) ) { while ( i >= 0 && !terminate_char( m_edit_str[i], true ) ) { --i; } ++i; } m_cur_pos = i; } void line_edit_control::move_pos_right_word() { int edit_len = (int)xr_strlen( m_edit_str ); int i = m_cur_pos + 1; while( i < edit_len && !terminate_char( m_edit_str[i], true ) ) { ++i; } //while( i < edit_len && terminate_char( m_edit_str[i] ) ) { ++i; } while( i < edit_len && m_edit_str[i] == ' ' ) { ++i; } m_cur_pos = i; } void line_edit_control::compute_positions() { m_p1 = m_cur_pos; m_p2 = m_cur_pos; if ( m_unselected_mode ) { return; } if( m_cur_pos > m_select_start ) { m_p1 = m_select_start; } else if( m_cur_pos < m_select_start ) { m_p2 = m_select_start; } } void line_edit_control::clamp_cur_pos() { clamp( m_cur_pos, 0, (int)xr_strlen( m_edit_str ) ); } void line_edit_control::SwitchKL() { ActivateKeyboardLayout( (HKL)HKL_NEXT, 0 ); } // ------------------------------------------------------------------------------------------------- void remove_spaces( PSTR str ) // in & out { u32 str_size = xr_strlen( str ); if ( str_size < 1 ) { return; } PSTR new_str = (PSTR)_alloca( (str_size + 1) * sizeof(char) ); new_str[0] = 0; u32 a = 0, b = 0, i = 0; while ( b < str_size ) { a = b; while ( a < str_size && str[a] == ' ' ) { ++a; } b = a; while ( b < str_size && str[b] != ' ' ) { ++b; } strncpy_s( new_str + i, str_size+1, str + a, b - a ); i += (b-a); if ( i < str_size ) { new_str[i] = ' '; } ++b; ++i; } --i; if ( i < str_size ) { strncpy_s( str, str_size, new_str, i ); } } void split_cmd( PSTR first, PSTR second, LPCSTR str ) { first[0] = 0; second[0] = 0; u32 str_size = xr_strlen( str ); if ( str_size < 1 ) { return; } // split into =>>(cmd) (params) u32 a = 0; while ( a < str_size && str[a] != ' ' ) { ++a; } strncpy_s( first, str_size+1, str, a ); if ( a < str_size ) { first[a] = 0; } else { first[str_size] = 0; } ++a; if ( a < str_size ) { strncpy_s( second, str_size+1, str + a, str_size - a ); second[str_size - a] = 0; } } } // namespace text_editor
[ "58656613+NikitaNikson@users.noreply.github.com" ]
58656613+NikitaNikson@users.noreply.github.com
d19965de3b4a29a2108be6380d1221d2d0f1286f
bc1c43d7ebb8fbb23d022f1554e1639285f276b2
/osl/sample/performance/isCheckPerf.cc
9e4301c1ed788ebc57924015c43990d4bf4989bc
[]
no_license
ai5/gpsfish
d1eafdece0c7c203c32603892ff9263a8fbcba59
b6ed91f77478fdb51b8747e2fcd78042d79271d5
refs/heads/master
2020-12-24T06:54:11.062234
2016-07-02T20:42:10
2016-07-02T20:42:10
62,468,733
1
0
null
null
null
null
UTF-8
C++
false
false
1,547
cc
/** * 王手判定の速さを見る */ #include "osl/numEffectState.h" #include "osl/move_generator/allMoves.h" #include "osl/move_generator/move_action.h" #include "osl/move_classifier/check_.h" #include "osl/csa.h" #include "osl/misc/perfmon.h" #include <iostream> #include <cstdio> using namespace osl; int main(int argc,char **argv) { // extern char *optarg; char c; while ((c = getopt(argc, argv, "vh")) != EOF) { switch(c) { default: std::cerr << "unknown option\n"; return 1; } } NumEffectState state((CsaString( "P1-KY * * * -KY * -FU-KE * \n" "P2 * * * * -OU * * * * \n" "P3 * * * -FU-FU+RY * * -KY\n" "P4-FU * * -GI * * * * * \n" "P5 * * * * * * * * * \n" "P6+FU * * +RY * * +FU * * \n" "P7 * +FU * +FU+FU+FU * * * \n" "P8 * * +OU * -TO * * * * \n" "P9+KY * * * * * * +KE * \n" "P+00KI00GI00GI00GI00KE00KE00FU00FU00FU00KI\n" "P-00KA00KA00KI00FU00FU00FU00FU00KI\n" "-\n").initialState())); MoveVector moves; GenerateAllMoves::generate(state.turn(),state,moves); int count = 0; misc::PerfMon clock; for (size_t i=0; i<moves.size(); ++i) { if (move_classifier::Check<WHITE>::isMember (state, moves[i].ptype(), moves[i].from(), moves[i].to())) ++count; } clock.stop("total", moves.size()); std::cerr << "checks " << count << " / " << moves.size() << "\n"; } // ;;; Local Variables: // ;;; mode:c++ // ;;; c-basic-offset:2 // ;;; coding:utf-8 // ;;; End:
[ "taibarax@gmail.com" ]
taibarax@gmail.com
1b04a28f4365cfc5d3fa8642ed6c1396c9d4eafa
fe7c6ccb491b4203a42f956a67a43c236dc75f11
/mbgl-core/src/mbgl/text/tagged_string.cpp
251e21726cce0083a5eab7c97be11188b734361b
[]
no_license
luyufanzhi/win_mapbox
f571fef859bb39927b6590df606ea37f3eef9d73
4e024cbd35237e4994b65adb61b265bebed41ea9
refs/heads/master
2023-04-14T20:45:09.734962
2020-05-19T11:18:27
2020-05-19T11:18:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,611
cpp
#include <mbgl/text/tagged_string.hpp> #include <mbgl/math/minmax.hpp> #include <mbgl/util/i18n.hpp> namespace mbgl { void TaggedString::addSection(const std::u16string& sectionText, double scale, FontStack fontStack, optional<Color> textColor) { styledText.first += sectionText; sections.emplace_back(scale, fontStack, std::move(textColor)); styledText.second.resize(styledText.first.size(), sections.size() - 1); } void TaggedString::trim() { std::size_t beginningWhitespace = styledText.first.find_first_not_of(u" \t\n\v\f\r"); if (beginningWhitespace == std::u16string::npos) { // Entirely whitespace styledText.first.clear(); styledText.second.clear(); } else { std::size_t trailingWhitespace = styledText.first.find_last_not_of(u" \t\n\v\f\r") + 1; styledText.first = styledText.first.substr(beginningWhitespace, trailingWhitespace - beginningWhitespace); styledText.second = std::vector<uint8_t>(styledText.second.begin() + beginningWhitespace, styledText.second.begin() + trailingWhitespace); } } double TaggedString::getMaxScale() const { double maxScale = 0.0; for (std::size_t i = 0; i < styledText.first.length(); i++) { maxScale = util::max(maxScale, getSection(i).scale); } return maxScale; } void TaggedString::verticalizePunctuation() { // Relies on verticalization changing characters in place so that style indices don't need updating styledText.first = util::i18n::verticalizePunctuation(styledText.first); } } // namespace mbgl
[ "machfe@126.com" ]
machfe@126.com
b830ef10885819244b8e5c9598a80b513e984d95
992df225867ed5530649e3e739b8345cb89d8489
/nfcthread.h
9b2818ad5ddfff1d675c330146fcf0fd54a97493
[]
no_license
vamanea/nfcdoor-qtlock
f11586cabadc41b04eb8a3ce541a6788b9c2e662
79ee63db198fa774f0f0a99a4a81bfafec9b6247
refs/heads/master
2021-01-20T12:20:40.166217
2015-07-06T19:01:06
2015-07-06T19:01:06
38,389,457
1
0
null
null
null
null
UTF-8
C++
false
false
704
h
#ifndef NFCTHREAD_H #define NFCTHREAD_H #include <QThread> #include <QVariant> #include <QTemporaryFile> #include <nfc/nfc.h> class NFCThread : public QThread { Q_OBJECT public: explicit NFCThread(QObject *parent = 0); void run(); signals: void nfcLog(const QVariant &line); void certValidated(const QVariant &valid, const QVariant &certName); void sigValidated(const QVariant &valid); public slots: void terminate(); private: nfc_device *m_nfcDevice = NULL; nfc_context *m_nfcContext = NULL; QTemporaryFile *caFile; void debugLine(QString line); int send(uint8_t *capdu, size_t capdulen, uint8_t *rapdu, size_t *rapdulen); }; #endif // NFCTHREAD_H
[ "valentin.manea@gmail.com" ]
valentin.manea@gmail.com
0aa62a5aa02acd1a35b105009a1b6178646db0b5
a615de86e07d0723d6fe24eaadc0a2efc0efacb4
/ArduinoJson.h
1c573262a9afd32f9c1f90e6f8046ce4d3cb290d
[]
no_license
Cyrhades/Compteur-Youtube-Arduino-NodeMCU-ESP8266
da011a2d86a6d9d0b6c7c01d18c03e9218c460c1
0a0369b82dc77957497c529784ef09f3376f6a96
refs/heads/master
2020-07-09T02:43:53.260109
2019-08-22T18:55:20
2019-08-22T18:55:20
203,852,598
1
0
null
null
null
null
UTF-8
C++
false
false
97,402
h
// Copyright Benoit Blanchon 2014-2017 // MIT License // // Arduino JSON library // https://bblanchon.github.io/ArduinoJson/ // If you like this project, please add a star! #pragma once #include <stddef.h> // for size_t #include <stdint.h> // for uint8_t #include <string.h> namespace ArduinoJson { namespace Internals { class NonCopyable { protected: NonCopyable() {} private: NonCopyable(const NonCopyable&); NonCopyable& operator=(const NonCopyable&); }; } } #ifndef ARDUINOJSON_EMBEDDED_MODE #if defined(ARDUINO) || defined(__IAR_SYSTEMS_ICC__) #define ARDUINOJSON_EMBEDDED_MODE 1 #else #define ARDUINOJSON_EMBEDDED_MODE 0 #endif #endif #if ARDUINOJSON_EMBEDDED_MODE #ifndef ARDUINOJSON_USE_DOUBLE #define ARDUINOJSON_USE_DOUBLE 0 #endif #ifndef ARDUINOJSON_USE_LONG_LONG #define ARDUINOJSON_USE_LONG_LONG 0 #endif #ifndef ARDUINOJSON_USE_INT64 #define ARDUINOJSON_USE_INT64 0 #endif #ifndef ARDUINOJSON_ENABLE_STD_STRING #define ARDUINOJSON_ENABLE_STD_STRING 0 #endif #ifndef ARDUINOJSON_ENABLE_STD_STREAM #define ARDUINOJSON_ENABLE_STD_STREAM 0 #endif #ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT #define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10 #endif #else // ARDUINOJSON_EMBEDDED_MODE #ifndef ARDUINOJSON_USE_DOUBLE #define ARDUINOJSON_USE_DOUBLE 1 #endif #ifndef ARDUINOJSON_USE_LONG_LONG #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) #define ARDUINOJSON_USE_LONG_LONG 1 #else #define ARDUINOJSON_USE_LONG_LONG 0 #endif #endif #ifndef ARDUINOJSON_USE_INT64 #if defined(_MSC_VER) && _MSC_VER <= 1700 #define ARDUINOJSON_USE_INT64 1 #else #define ARDUINOJSON_USE_INT64 0 #endif #endif #ifndef ARDUINOJSON_ENABLE_STD_STRING #define ARDUINOJSON_ENABLE_STD_STRING 1 #endif #ifndef ARDUINOJSON_ENABLE_STD_STREAM #define ARDUINOJSON_ENABLE_STD_STREAM 1 #endif #ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT #define ARDUINOJSON_DEFAULT_NESTING_LIMIT 50 #endif #endif // ARDUINOJSON_EMBEDDED_MODE #ifdef ARDUINO #ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #endif #ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM #define ARDUINOJSON_ENABLE_ARDUINO_STREAM 1 #endif #else // ARDUINO #ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING #define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 #endif #ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM #define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0 #endif #endif // ARDUINO #ifndef ARDUINOJSON_ENABLE_PROGMEM #ifdef PROGMEM #define ARDUINOJSON_ENABLE_PROGMEM 1 #else #define ARDUINOJSON_ENABLE_PROGMEM 0 #endif #endif #ifndef ARDUINOJSON_ENABLE_ALIGNMENT #ifdef ARDUINO_ARCH_AVR #define ARDUINOJSON_ENABLE_ALIGNMENT 0 #else #define ARDUINOJSON_ENABLE_ALIGNMENT 1 #endif #endif #ifndef ARDUINOJSON_ENABLE_DEPRECATED #define ARDUINOJSON_ENABLE_DEPRECATED 1 #endif #ifndef ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD #define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e7 #endif #ifndef ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD #define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5 #endif #if ARDUINOJSON_USE_LONG_LONG && ARDUINOJSON_USE_INT64 #error ARDUINOJSON_USE_LONG_LONG and ARDUINOJSON_USE_INT64 cannot be set together #endif namespace ArduinoJson { namespace Internals { #if ARDUINOJSON_USE_DOUBLE typedef double JsonFloat; #else typedef float JsonFloat; #endif } } namespace ArduinoJson { namespace Internals { #if ARDUINOJSON_USE_LONG_LONG typedef long long JsonInteger; typedef unsigned long long JsonUInt; #elif ARDUINOJSON_USE_INT64 typedef __int64 JsonInteger; typedef unsigned _int64 JsonUInt; #else typedef long JsonInteger; typedef unsigned long JsonUInt; #endif } } namespace ArduinoJson { class JsonArray; class JsonObject; namespace Internals { union JsonVariantContent { JsonFloat asFloat; // used for double and float JsonUInt asInteger; // used for bool, char, short, int and longs const char* asString; // asString can be null JsonArray* asArray; // asArray cannot be null JsonObject* asObject; // asObject cannot be null }; } } namespace ArduinoJson { namespace Internals { template <typename T> struct JsonVariantDefault { static T get() { return T(); } }; template <typename T> struct JsonVariantDefault<const T> : JsonVariantDefault<T> {}; template <typename T> struct JsonVariantDefault<T&> : JsonVariantDefault<T> {}; } } namespace ArduinoJson { class JsonArray; class JsonObject; namespace Internals { enum JsonVariantType { JSON_UNDEFINED, // JsonVariant has not been initialized JSON_UNPARSED, // JsonVariant contains an unparsed string JSON_STRING, // JsonVariant stores a const char* JSON_BOOLEAN, // JsonVariant stores a bool JSON_POSITIVE_INTEGER, // JsonVariant stores an JsonUInt JSON_NEGATIVE_INTEGER, // JsonVariant stores an JsonUInt that must be negated JSON_ARRAY, // JsonVariant stores a pointer to a JsonArray JSON_OBJECT, // JsonVariant stores a pointer to a JsonObject JSON_FLOAT // JsonVariant stores a JsonFloat }; } } namespace ArduinoJson { namespace Internals { template <typename T> struct JsonVariantAs { typedef T type; }; template <> struct JsonVariantAs<char*> { typedef const char* type; }; template <> struct JsonVariantAs<JsonArray> { typedef JsonArray& type; }; template <> struct JsonVariantAs<const JsonArray> { typedef const JsonArray& type; }; template <> struct JsonVariantAs<JsonObject> { typedef JsonObject& type; }; template <> struct JsonVariantAs<const JsonObject> { typedef const JsonObject& type; }; } } #ifdef _MSC_VER // Visual Studio #define FORCE_INLINE __forceinline #define NO_INLINE __declspec(noinline) #define DEPRECATED(msg) __declspec(deprecated(msg)) #elif defined(__GNUC__) // GCC or Clang #define FORCE_INLINE __attribute__((always_inline)) #define NO_INLINE __attribute__((noinline)) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) #define DEPRECATED(msg) __attribute__((deprecated(msg))) #else #define DEPRECATED(msg) __attribute__((deprecated)) #endif #else // Other compilers #define FORCE_INLINE #define NO_INLINE #define DEPRECATED(msg) #endif namespace ArduinoJson { namespace TypeTraits { template <bool Condition, typename T = void> struct EnableIf {}; template <typename T> struct EnableIf<true, T> { typedef T type; }; } } namespace ArduinoJson { namespace Internals { class DummyPrint { public: size_t print(char) { return 1; } size_t print(const char* s) { return strlen(s); } }; } } namespace ArduinoJson { namespace TypeTraits { template <typename TBase, typename TDerived> class IsBaseOf { protected: // <- to avoid GCC's "all member functions in class are private" typedef char Yes[1]; typedef char No[2]; static Yes &probe(const TBase *); static No &probe(...); public: enum { value = sizeof(probe(reinterpret_cast<TDerived *>(0))) == sizeof(Yes) }; }; } } namespace ArduinoJson { namespace TypeTraits { template <typename T, typename U> struct IsSame { static const bool value = false; }; template <typename T> struct IsSame<T, T> { static const bool value = true; }; } } namespace ArduinoJson { namespace TypeTraits { template <typename T> struct IsChar { static const bool value = IsSame<T, char>::value || IsSame<T, signed char>::value || IsSame<T, unsigned char>::value; }; template <typename T> struct IsChar<const T> : IsChar<T> {}; } } namespace ArduinoJson { namespace TypeTraits { template <typename T> struct RemoveReference { typedef T type; }; template <typename T> struct RemoveReference<T&> { typedef T type; }; } } namespace ArduinoJson { namespace Internals { template <typename TString, typename Enable = void> struct StringTraits {}; template <typename TString> struct StringTraits<const TString, void> : StringTraits<TString> {}; template <typename TString> struct StringTraits<TString&, void> : StringTraits<TString> {}; } } #if ARDUINOJSON_ENABLE_ARDUINO_STREAM #include <Stream.h> namespace ArduinoJson { namespace Internals { struct ArduinoStreamTraits { class Reader { Stream& _stream; char _current, _next; public: Reader(Stream& stream) : _stream(stream), _current(0), _next(0) {} void move() { _current = _next; _next = 0; } char current() { if (!_current) _current = read(); return _current; } char next() { if (!_next) _next = read(); return _next; } private: char read() { char c = 0; _stream.readBytes(&c, 1); return c; } }; }; template <typename TStream> struct StringTraits<TStream, typename TypeTraits::EnableIf<TypeTraits::IsBaseOf< Stream, typename TypeTraits::RemoveReference< TStream>::type>::value>::type> : ArduinoStreamTraits {}; } } #endif namespace ArduinoJson { namespace Internals { template <typename TChar> struct CharPointerTraits { class Reader { const TChar* _ptr; public: Reader(const TChar* ptr) : _ptr(ptr ? ptr : reinterpret_cast<const TChar*>("")) {} void move() { ++_ptr; } char current() const { return char(_ptr[0]); } char next() const { return char(_ptr[1]); } }; static bool equals(const TChar* str, const char* expected) { return strcmp(reinterpret_cast<const char*>(str), expected) == 0; } template <typename Buffer> static char* duplicate(const TChar* str, Buffer* buffer) { if (!str) return NULL; size_t size = strlen(reinterpret_cast<const char*>(str)) + 1; void* dup = buffer->alloc(size); if (dup != NULL) memcpy(dup, str, size); return static_cast<char*>(dup); } static const bool has_append = false; static const bool has_equals = true; static const bool should_duplicate = false; }; template <typename TChar> struct StringTraits<TChar*, typename TypeTraits::EnableIf< TypeTraits::IsChar<TChar>::value>::type> : CharPointerTraits<TChar> {}; } } #if ARDUINOJSON_ENABLE_PROGMEM namespace ArduinoJson { namespace Internals { template <> struct StringTraits<const __FlashStringHelper*, void> { class Reader { const char* _ptr; public: Reader(const __FlashStringHelper* ptr) : _ptr(reinterpret_cast<const char*>(ptr)) {} void move() { _ptr++; } char current() const { return pgm_read_byte_near(_ptr); } char next() const { return pgm_read_byte_near(_ptr + 1); } }; static bool equals(const __FlashStringHelper* str, const char* expected) { return strcmp_P(expected, (const char*)str) == 0; } template <typename Buffer> static char* duplicate(const __FlashStringHelper* str, Buffer* buffer) { if (!str) return NULL; size_t size = strlen_P((const char*)str) + 1; void* dup = buffer->alloc(size); if (dup != NULL) memcpy_P(dup, (const char*)str, size); return static_cast<char*>(dup); } static const bool has_append = false; static const bool has_equals = true; static const bool should_duplicate = true; }; } } #endif #if ARDUINOJSON_ENABLE_STD_STREAM #include <istream> namespace ArduinoJson { namespace Internals { struct StdStreamTraits { class Reader { std::istream& _stream; char _current, _next; public: Reader(std::istream& stream) : _stream(stream), _current(0), _next(0) {} void move() { _current = _next; _next = 0; } char current() { if (!_current) _current = read(); return _current; } char next() { if (!_next) _next = read(); return _next; } private: Reader& operator=(const Reader&); // Visual Studio C4512 char read() { return _stream.eof() ? '\0' : static_cast<char>(_stream.get()); } }; }; template <typename TStream> struct StringTraits<TStream, typename TypeTraits::EnableIf<TypeTraits::IsBaseOf< std::istream, typename TypeTraits::RemoveReference< TStream>::type>::value>::type> : StdStreamTraits {}; } } #endif #if ARDUINOJSON_ENABLE_STD_STRING || ARDUINOJSON_ENABLE_ARDUINO_STRING #if ARDUINOJSON_ENABLE_ARDUINO_STRING #include <WString.h> #endif #if ARDUINOJSON_ENABLE_STD_STRING #include <string> #endif namespace ArduinoJson { namespace Internals { template <typename TString> struct StdStringTraits { template <typename Buffer> static char* duplicate(const TString& str, Buffer* buffer) { if (!str.c_str()) return NULL; // <- Arduino string can return NULL size_t size = str.length() + 1; void* dup = buffer->alloc(size); if (dup != NULL) memcpy(dup, str.c_str(), size); return static_cast<char*>(dup); } struct Reader : CharPointerTraits<char>::Reader { Reader(const TString& str) : CharPointerTraits<char>::Reader(str.c_str()) {} }; static bool equals(const TString& str, const char* expected) { return 0 == strcmp(str.c_str(), expected); } static void append(TString& str, char c) { str += c; } static void append(TString& str, const char* s) { str += s; } static const bool has_append = true; static const bool has_equals = true; static const bool should_duplicate = true; }; #if ARDUINOJSON_ENABLE_ARDUINO_STRING template <> struct StringTraits<String, void> : StdStringTraits<String> {}; template <> struct StringTraits<StringSumHelper, void> : StdStringTraits<StringSumHelper> { }; #endif #if ARDUINOJSON_ENABLE_STD_STRING template <> struct StringTraits<std::string, void> : StdStringTraits<std::string> {}; #endif } } #endif namespace ArduinoJson { namespace TypeTraits { template <typename T, typename Enable = void> struct IsString { static const bool value = false; }; template <typename T> struct IsString<T, typename TypeTraits::EnableIf< Internals::StringTraits<T>::has_equals>::type> { static const bool value = Internals::StringTraits<T>::has_equals; }; } } namespace ArduinoJson { namespace Internals { template <typename TString> class DynamicStringBuilder { public: DynamicStringBuilder(TString &str) : _str(str) {} size_t print(char c) { StringTraits<TString>::append(_str, c); return 1; } size_t print(const char *s) { size_t initialLen = _str.length(); StringTraits<TString>::append(_str, s); return _str.length() - initialLen; } private: DynamicStringBuilder &operator=(const DynamicStringBuilder &); TString &_str; }; } } namespace ArduinoJson { namespace Internals { template <typename Print> class IndentedPrint { public: explicit IndentedPrint(Print &p) : sink(&p) { level = 0; tabSize = 2; isNewLine = true; } size_t print(char c) { size_t n = 0; if (isNewLine) n += writeTabs(); n += sink->print(c); isNewLine = c == '\n'; return n; } size_t print(const char *s) { size_t n = 0; while (*s) n += print(*s++); return n; } void indent() { if (level < MAX_LEVEL) level++; } void unindent() { if (level > 0) level--; } void setTabSize(uint8_t n) { if (n < MAX_TAB_SIZE) tabSize = n & MAX_TAB_SIZE; } private: Print *sink; uint8_t level : 4; uint8_t tabSize : 3; bool isNewLine : 1; size_t writeTabs() { size_t n = 0; for (int i = 0; i < level * tabSize; i++) n += sink->print(' '); return n; } static const int MAX_LEVEL = 15; // because it's only 4 bits static const int MAX_TAB_SIZE = 7; // because it's only 3 bits }; } } namespace ArduinoJson { namespace Internals { class Encoding { public: static char escapeChar(char c) { const char *p = escapeTable(false); while (p[0] && p[1] != c) { p += 2; } return p[0]; } static char unescapeChar(char c) { const char *p = escapeTable(true); for (;;) { if (p[0] == '\0') return c; if (p[0] == c) return p[1]; p += 2; } } private: static const char *escapeTable(bool excludeIdenticals) { return &"\"\"\\\\b\bf\fn\nr\rt\t"[excludeIdenticals ? 4 : 0]; } }; } } namespace ArduinoJson { namespace Polyfills { template <typename T> bool isNaN(T x) { return x != x; } template <typename T> bool isInfinity(T x) { return x != 0.0 && x * 2 == x; } } } #include <stdlib.h> // for size_t namespace ArduinoJson { namespace TypeTraits { template <typename T, size_t = sizeof(T)> struct FloatTraits {}; template <typename T> struct FloatTraits<T, 8 /*64bits*/> { typedef int64_t mantissa_type; static const short mantissa_bits = 52; static const mantissa_type mantissa_max = (static_cast<mantissa_type>(1) << mantissa_bits) - 1; typedef int16_t exponent_type; static const exponent_type exponent_max = 308; template <typename TExponent> static T make_float(T m, TExponent e) { if (e > 0) { for (uint8_t index = 0; e != 0; index++) { if (e & 1) m *= positiveBinaryPowerOfTen(index); e >>= 1; } } else { e = TExponent(-e); for (uint8_t index = 0; e != 0; index++) { if (e & 1) m *= negativeBinaryPowerOfTen(index); e >>= 1; } } return m; } static T positiveBinaryPowerOfTen(int index) { static T factors[] = { 1e1, 1e2, 1e4, 1e8, 1e16, 1e32, forge(0x4D384F03, 0xE93FF9F5), forge(0x5A827748, 0xF9301D32), forge(0x75154FDD, 0x7F73BF3C)}; return factors[index]; } static T negativeBinaryPowerOfTen(int index) { static T factors[] = { 1e-1, 1e-2, 1e-4, 1e-8, 1e-16, 1e-32, forge(0x32A50FFD, 0x44F4A73D), forge(0x255BBA08, 0xCF8C979D), forge(0x0AC80628, 0x64AC6F43)}; return factors[index]; } static T negativeBinaryPowerOfTenPlusOne(int index) { static T factors[] = { 1e0, 1e-1, 1e-3, 1e-7, 1e-15, 1e-31, forge(0x32DA53FC, 0x9631D10D), forge(0x25915445, 0x81B7DEC2), forge(0x0AFE07B2, 0x7DD78B14)}; return factors[index]; } static T nan() { return forge(0x7ff80000, 0x00000000); } static T inf() { return forge(0x7ff00000, 0x00000000); } static T forge(uint32_t msb, uint32_t lsb) { union { uint64_t integerBits; T floatBits; }; integerBits = (uint64_t(msb) << 32) | lsb; return floatBits; } }; template <typename T> struct FloatTraits<T, 4 /*32bits*/> { typedef int32_t mantissa_type; static const short mantissa_bits = 23; static const mantissa_type mantissa_max = (static_cast<mantissa_type>(1) << mantissa_bits) - 1; typedef int8_t exponent_type; static const exponent_type exponent_max = 38; template <typename TExponent> static T make_float(T m, TExponent e) { if (e > 0) { for (uint8_t index = 0; e != 0; index++) { if (e & 1) m *= positiveBinaryPowerOfTen(index); e >>= 1; } } else { e = -e; for (uint8_t index = 0; e != 0; index++) { if (e & 1) m *= negativeBinaryPowerOfTen(index); e >>= 1; } } return m; } static T positiveBinaryPowerOfTen(int index) { static T factors[] = {1e1f, 1e2f, 1e4f, 1e8f, 1e16f, 1e32f}; return factors[index]; } static T negativeBinaryPowerOfTen(int index) { static T factors[] = {1e-1f, 1e-2f, 1e-4f, 1e-8f, 1e-16f, 1e-32f}; return factors[index]; } static T negativeBinaryPowerOfTenPlusOne(int index) { static T factors[] = {1e0f, 1e-1f, 1e-3f, 1e-7f, 1e-15f, 1e-31f}; return factors[index]; } static T forge(uint32_t bits) { union { uint32_t integerBits; T floatBits; }; integerBits = bits; return floatBits; } static T nan() { return forge(0x7fc00000); } static T inf() { return forge(0x7f800000); } }; } } namespace ArduinoJson { namespace Internals { template <typename TFloat> struct FloatParts { uint32_t integral; uint32_t decimal; int16_t exponent; int8_t decimalPlaces; FloatParts(TFloat value) { const uint32_t maxDecimalPart = sizeof(TFloat) >= 8 ? 1000000000 : 1000000; exponent = normalize(value); integral = uint32_t(value); TFloat remainder = value - TFloat(integral); remainder *= maxDecimalPart; decimal = uint32_t(remainder); remainder = remainder - TFloat(decimal); decimal += uint32_t(remainder * 2); if (decimal >= maxDecimalPart) { decimal = 0; integral++; if (exponent && integral >= 10) { exponent++; integral = 1; } } decimalPlaces = sizeof(TFloat) >= 8 ? 9 : 6; for (uint32_t tmp = integral; tmp >= 10; tmp /= 10) { decimal /= 10; decimalPlaces--; } while (decimal % 10 == 0 && decimalPlaces > 0) { decimal /= 10; decimalPlaces--; } } static int16_t normalize(TFloat& value) { typedef TypeTraits::FloatTraits<TFloat> traits; int16_t powersOf10 = 0; int8_t index = sizeof(TFloat) == 8 ? 8 : 5; int bit = 1 << index; if (value >= ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD) { for (; index >= 0; index--) { if (value >= traits::positiveBinaryPowerOfTen(index)) { value *= traits::negativeBinaryPowerOfTen(index); powersOf10 = int16_t(powersOf10 + bit); } bit >>= 1; } } if (value > 0 && value <= ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD) { for (; index >= 0; index--) { if (value < traits::negativeBinaryPowerOfTenPlusOne(index)) { value *= traits::positiveBinaryPowerOfTen(index); powersOf10 = int16_t(powersOf10 - bit); } bit >>= 1; } } return powersOf10; } }; } } namespace ArduinoJson { namespace Internals { template <typename Print> class JsonWriter { public: explicit JsonWriter(Print &sink) : _sink(sink), _length(0) {} size_t bytesWritten() const { return _length; } void beginArray() { writeRaw('['); } void endArray() { writeRaw(']'); } void beginObject() { writeRaw('{'); } void endObject() { writeRaw('}'); } void writeColon() { writeRaw(':'); } void writeComma() { writeRaw(','); } void writeBoolean(bool value) { writeRaw(value ? "true" : "false"); } void writeString(const char *value) { if (!value) { writeRaw("null"); } else { writeRaw('\"'); while (*value) writeChar(*value++); writeRaw('\"'); } } void writeChar(char c) { char specialChar = Encoding::escapeChar(c); if (specialChar) { writeRaw('\\'); writeRaw(specialChar); } else { writeRaw(c); } } template <typename TFloat> void writeFloat(TFloat value) { if (Polyfills::isNaN(value)) return writeRaw("NaN"); if (value < 0.0) { writeRaw('-'); value = -value; } if (Polyfills::isInfinity(value)) return writeRaw("Infinity"); FloatParts<TFloat> parts(value); writeInteger(parts.integral); if (parts.decimalPlaces) writeDecimals(parts.decimal, parts.decimalPlaces); if (parts.exponent < 0) { writeRaw("e-"); writeInteger(-parts.exponent); } if (parts.exponent > 0) { writeRaw('e'); writeInteger(parts.exponent); } } template <typename UInt> void writeInteger(UInt value) { char buffer[22]; char *end = buffer + sizeof(buffer) - 1; char *ptr = end; *ptr = 0; do { *--ptr = char(value % 10 + '0'); value = UInt(value / 10); } while (value); writeRaw(ptr); } void writeDecimals(uint32_t value, int8_t width) { char buffer[16]; char *ptr = buffer + sizeof(buffer) - 1; *ptr = 0; while (width--) { *--ptr = char(value % 10 + '0'); value /= 10; } *--ptr = '.'; writeRaw(ptr); } void writeRaw(const char *s) { _length += _sink.print(s); } void writeRaw(char c) { _length += _sink.print(c); } protected: Print &_sink; size_t _length; private: JsonWriter &operator=(const JsonWriter &); // cannot be assigned }; } } namespace ArduinoJson { class JsonArray; class JsonArraySubscript; class JsonObject; template <typename TKey> class JsonObjectSubscript; class JsonVariant; namespace Internals { template <typename Writer> class JsonSerializer { public: static void serialize(const JsonArray &, Writer &); static void serialize(const JsonArraySubscript &, Writer &); static void serialize(const JsonObject &, Writer &); template <typename TKey> static void serialize(const JsonObjectSubscript<TKey> &, Writer &); static void serialize(const JsonVariant &, Writer &); }; } } namespace ArduinoJson { namespace Internals { template <typename Print> class Prettyfier { public: explicit Prettyfier(IndentedPrint<Print>& p) : _sink(p) { _previousChar = 0; _inString = false; } size_t print(char c) { size_t n = _inString ? handleStringChar(c) : handleMarkupChar(c); _previousChar = c; return n; } size_t print(const char* s) { size_t n = 0; while (*s) n += print(*s++); return n; } private: Prettyfier& operator=(const Prettyfier&); // cannot be assigned bool inEmptyBlock() { return _previousChar == '{' || _previousChar == '['; } size_t handleStringChar(char c) { bool isQuote = c == '"' && _previousChar != '\\'; if (isQuote) _inString = false; return _sink.print(c); } size_t handleMarkupChar(char c) { switch (c) { case '{': case '[': return writeBlockOpen(c); case '}': case ']': return writeBlockClose(c); case ':': return writeColon(); case ',': return writeComma(); case '"': return writeQuoteOpen(); default: return writeNormalChar(c); } } size_t writeBlockClose(char c) { size_t n = 0; n += unindentIfNeeded(); n += _sink.print(c); return n; } size_t writeBlockOpen(char c) { size_t n = 0; n += indentIfNeeded(); n += _sink.print(c); return n; } size_t writeColon() { size_t n = 0; n += _sink.print(": "); return n; } size_t writeComma() { size_t n = 0; n += _sink.print(",\r\n"); return n; } size_t writeQuoteOpen() { _inString = true; size_t n = 0; n += indentIfNeeded(); n += _sink.print('"'); return n; } size_t writeNormalChar(char c) { size_t n = 0; n += indentIfNeeded(); n += _sink.print(c); return n; } size_t indentIfNeeded() { if (!inEmptyBlock()) return 0; _sink.indent(); return _sink.print("\r\n"); } size_t unindentIfNeeded() { if (inEmptyBlock()) return 0; _sink.unindent(); return _sink.print("\r\n"); } char _previousChar; IndentedPrint<Print>& _sink; bool _inString; }; } } namespace ArduinoJson { namespace Internals { class StaticStringBuilder { public: StaticStringBuilder(char *buf, size_t size) : end(buf + size - 1), p(buf) { *p = '\0'; } size_t print(char c) { if (p >= end) return 0; *p++ = c; *p = '\0'; return 1; } size_t print(const char *s) { char *begin = p; while (p < end && *s) *p++ = *s++; *p = '\0'; return size_t(p - begin); } private: char *end; char *p; }; } } #if ARDUINOJSON_ENABLE_STD_STREAM #if ARDUINOJSON_ENABLE_STD_STREAM #include <ostream> namespace ArduinoJson { namespace Internals { class StreamPrintAdapter { public: explicit StreamPrintAdapter(std::ostream& os) : _os(os) {} size_t print(char c) { _os << c; return 1; } size_t print(const char* s) { _os << s; return strlen(s); } private: StreamPrintAdapter& operator=(const StreamPrintAdapter&); std::ostream& _os; }; } } #endif // ARDUINOJSON_ENABLE_STD_STREAM #endif namespace ArduinoJson { namespace Internals { template <typename T> class JsonPrintable { public: template <typename Print> typename TypeTraits::EnableIf<!TypeTraits::IsString<Print>::value, size_t>::type printTo(Print &print) const { JsonWriter<Print> writer(print); JsonSerializer<JsonWriter<Print> >::serialize(downcast(), writer); return writer.bytesWritten(); } #if ARDUINOJSON_ENABLE_STD_STREAM std::ostream &printTo(std::ostream &os) const { StreamPrintAdapter adapter(os); printTo(adapter); return os; } #endif size_t printTo(char *buffer, size_t bufferSize) const { StaticStringBuilder sb(buffer, bufferSize); return printTo(sb); } template <size_t N> size_t printTo(char (&buffer)[N]) const { return printTo(buffer, N); } template <typename TString> typename TypeTraits::EnableIf<StringTraits<TString>::has_append, size_t>::type printTo(TString &str) const { DynamicStringBuilder<TString> sb(str); return printTo(sb); } template <typename Print> size_t prettyPrintTo(IndentedPrint<Print> &print) const { Prettyfier<Print> p(print); return printTo(p); } size_t prettyPrintTo(char *buffer, size_t bufferSize) const { StaticStringBuilder sb(buffer, bufferSize); return prettyPrintTo(sb); } template <size_t N> size_t prettyPrintTo(char (&buffer)[N]) const { return prettyPrintTo(buffer, N); } template <typename Print> typename TypeTraits::EnableIf<!TypeTraits::IsString<Print>::value, size_t>::type prettyPrintTo(Print &print) const { IndentedPrint<Print> indentedPrint(print); return prettyPrintTo(indentedPrint); } template <typename TString> typename TypeTraits::EnableIf<StringTraits<TString>::has_append, size_t>::type prettyPrintTo(TString &str) const { DynamicStringBuilder<TString> sb(str); return prettyPrintTo(sb); } size_t measureLength() const { DummyPrint dp; return printTo(dp); } size_t measurePrettyLength() const { DummyPrint dp; return prettyPrintTo(dp); } private: const T &downcast() const { return *static_cast<const T *>(this); } }; #if ARDUINOJSON_ENABLE_STD_STREAM template <typename T> inline std::ostream &operator<<(std::ostream &os, const JsonPrintable<T> &v) { return v.printTo(os); } #endif } } namespace ArduinoJson { class JsonArraySubscript; template <typename TKey> class JsonObjectSubscript; template <typename TImpl> class JsonVariantBase : public Internals::JsonPrintable<TImpl> { public: #if ARDUINOJSON_ENABLE_DEPRECATED DEPRECATED("use as<JsonArray>() instead") FORCE_INLINE JsonArray &asArray() const { return as<JsonArray>(); } DEPRECATED("use as<JsonObject>() instead") FORCE_INLINE JsonObject &asObject() const { return as<JsonObject>(); } DEPRECATED("use as<char*>() instead") FORCE_INLINE const char *asString() const { return as<const char *>(); } #endif FORCE_INLINE operator JsonArray &() const { return as<JsonArray &>(); } FORCE_INLINE operator JsonObject &() const { return as<JsonObject &>(); } template <typename T> FORCE_INLINE operator T() const { return as<T>(); } template <typename T> FORCE_INLINE const typename Internals::JsonVariantAs<T>::type as() const { return impl()->template as<T>(); } template <typename T> FORCE_INLINE bool is() const { return impl()->template is<T>(); } size_t size() const { return as<JsonArray>().size() + as<JsonObject>().size(); } FORCE_INLINE const JsonArraySubscript operator[](size_t index) const; FORCE_INLINE JsonArraySubscript operator[](size_t index); template <typename TString> FORCE_INLINE typename TypeTraits::EnableIf< Internals::StringTraits<TString>::has_equals, const JsonObjectSubscript<const TString &> >::type operator[](const TString &key) const { return as<JsonObject>()[key]; } template <typename TString> FORCE_INLINE typename TypeTraits::EnableIf< Internals::StringTraits<TString>::has_equals, JsonObjectSubscript<const TString &> >::type operator[](const TString &key) { return as<JsonObject>()[key]; } template <typename TString> FORCE_INLINE typename TypeTraits::EnableIf< Internals::StringTraits<const TString *>::has_equals, JsonObjectSubscript<const TString *> >::type operator[](const TString *key) { return as<JsonObject>()[key]; } template <typename TString> FORCE_INLINE typename TypeTraits::EnableIf< Internals::StringTraits<TString *>::has_equals, const JsonObjectSubscript<const TString *> >::type operator[](const TString *key) const { return as<JsonObject>()[key]; } private: const TImpl *impl() const { return static_cast<const TImpl *>(this); } }; namespace TypeTraits { template <typename T> struct IsVariant : IsBaseOf<JsonVariantBase<T>, T> {}; } } namespace ArduinoJson { class RawJson { public: explicit RawJson(const char* str) : _str(str) {} operator const char*() const { return _str; } private: const char* _str; }; } namespace ArduinoJson { namespace TypeTraits { template <typename T> struct IsFloatingPoint { static const bool value = IsSame<T, float>::value || IsSame<T, double>::value; }; } } namespace ArduinoJson { namespace TypeTraits { template <typename T> struct IsSignedIntegral { static const bool value = TypeTraits::IsSame<T, signed char>::value || TypeTraits::IsSame<T, signed short>::value || TypeTraits::IsSame<T, signed int>::value || TypeTraits::IsSame<T, signed long>::value || #if ARDUINOJSON_USE_LONG_LONG TypeTraits::IsSame<T, signed long long>::value || #endif #if ARDUINOJSON_USE_INT64 TypeTraits::IsSame<T, signed __int64>::value || #endif false; }; } } namespace ArduinoJson { namespace TypeTraits { template <typename T> struct IsUnsignedIntegral { static const bool value = TypeTraits::IsSame<T, unsigned char>::value || TypeTraits::IsSame<T, unsigned short>::value || TypeTraits::IsSame<T, unsigned int>::value || TypeTraits::IsSame<T, unsigned long>::value || #if ARDUINOJSON_USE_LONG_LONG TypeTraits::IsSame<T, unsigned long long>::value || #endif #if ARDUINOJSON_USE_INT64 TypeTraits::IsSame<T, unsigned __int64>::value || #endif false; }; } } namespace ArduinoJson { namespace TypeTraits { template <typename T> struct IsIntegral { static const bool value = TypeTraits::IsSignedIntegral<T>::value || TypeTraits::IsUnsignedIntegral<T>::value || TypeTraits::IsSame<T, char>::value; }; template <typename T> struct IsIntegral<const T> : IsIntegral<T> {}; } } namespace ArduinoJson { namespace TypeTraits { template <typename T> struct RemoveConst { typedef T type; }; template <typename T> struct RemoveConst<const T> { typedef T type; }; } } namespace ArduinoJson { class JsonArray; class JsonObject; class JsonVariant : public JsonVariantBase<JsonVariant> { template <typename Print> friend class Internals::JsonSerializer; public: JsonVariant() : _type(Internals::JSON_UNDEFINED) {} JsonVariant(bool value) { using namespace Internals; _type = JSON_BOOLEAN; _content.asInteger = static_cast<JsonUInt>(value); } template <typename T> JsonVariant(T value, typename TypeTraits::EnableIf< TypeTraits::IsFloatingPoint<T>::value>::type * = 0) { using namespace Internals; _type = JSON_FLOAT; _content.asFloat = static_cast<JsonFloat>(value); } template <typename T> DEPRECATED("Second argument is not supported anymore") JsonVariant(T value, uint8_t, typename TypeTraits::EnableIf< TypeTraits::IsFloatingPoint<T>::value>::type * = 0) { using namespace Internals; _type = JSON_FLOAT; _content.asFloat = static_cast<JsonFloat>(value); } template <typename T> JsonVariant(T value, typename TypeTraits::EnableIf< TypeTraits::IsSignedIntegral<T>::value || TypeTraits::IsSame<T, char>::value>::type * = 0) { using namespace Internals; if (value >= 0) { _type = JSON_POSITIVE_INTEGER; _content.asInteger = static_cast<JsonUInt>(value); } else { _type = JSON_NEGATIVE_INTEGER; _content.asInteger = static_cast<JsonUInt>(-value); } } template <typename T> JsonVariant(T value, typename TypeTraits::EnableIf< TypeTraits::IsUnsignedIntegral<T>::value>::type * = 0) { using namespace Internals; _type = JSON_POSITIVE_INTEGER; _content.asInteger = static_cast<JsonUInt>(value); } template <typename TChar> JsonVariant( const TChar *value, typename TypeTraits::EnableIf<TypeTraits::IsChar<TChar>::value>::type * = 0) { _type = Internals::JSON_STRING; _content.asString = reinterpret_cast<const char *>(value); } JsonVariant(RawJson value) { _type = Internals::JSON_UNPARSED; _content.asString = value; } JsonVariant(const JsonArray &array); JsonVariant(const JsonObject &object); template <typename T> const typename TypeTraits::EnableIf<TypeTraits::IsIntegral<T>::value, T>::type as() const { return variantAsInteger<T>(); } template <typename T> const typename TypeTraits::EnableIf<TypeTraits::IsSame<T, bool>::value, T>::type as() const { return variantAsInteger<int>() != 0; } template <typename T> const typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<T>::value, T>::type as() const { return variantAsFloat<T>(); } template <typename T> typename TypeTraits::EnableIf<TypeTraits::IsSame<T, const char *>::value || TypeTraits::IsSame<T, char *>::value, const char *>::type as() const { return variantAsString(); } template <typename T> typename TypeTraits::EnableIf<Internals::StringTraits<T>::has_append, T>::type as() const { const char *cstr = variantAsString(); if (cstr) return T(cstr); T s; printTo(s); return s; } template <typename T> typename TypeTraits::EnableIf< TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type, JsonArray>::value, JsonArray &>::type as() const { return variantAsArray(); } template <typename T> typename TypeTraits::EnableIf< TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type, const JsonArray>::value, const JsonArray &>::type as() const { return variantAsArray(); } template <typename T> typename TypeTraits::EnableIf< TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type, JsonObject>::value, JsonObject &>::type as() const { return variantAsObject(); } template <typename T> typename TypeTraits::EnableIf< TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type, const JsonObject>::value, const JsonObject &>::type as() const { return variantAsObject(); } template <typename T> typename TypeTraits::EnableIf<TypeTraits::IsSame<T, JsonVariant>::value, T>::type as() const { return *this; } template <typename T> typename TypeTraits::EnableIf<TypeTraits::IsIntegral<T>::value, bool>::type is() const { return variantIsInteger(); } template <typename T> typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<T>::value, bool>::type is() const { return variantIsFloat(); } template <typename T> typename TypeTraits::EnableIf<TypeTraits::IsSame<T, bool>::value, bool>::type is() const { return variantIsBoolean(); } template <typename T> typename TypeTraits::EnableIf<TypeTraits::IsSame<T, const char *>::value || TypeTraits::IsSame<T, char *>::value, bool>::type is() const { return variantIsString(); } template <typename T> typename TypeTraits::EnableIf< TypeTraits::IsSame< typename TypeTraits::RemoveConst< typename TypeTraits::RemoveReference<T>::type>::type, JsonArray>::value, bool>::type is() const { return variantIsArray(); } template <typename T> typename TypeTraits::EnableIf< TypeTraits::IsSame< typename TypeTraits::RemoveConst< typename TypeTraits::RemoveReference<T>::type>::type, JsonObject>::value, bool>::type is() const { return variantIsObject(); } bool success() const { return _type != Internals::JSON_UNDEFINED; } private: JsonArray &variantAsArray() const; JsonObject &variantAsObject() const; const char *variantAsString() const; template <typename T> T variantAsFloat() const; template <typename T> T variantAsInteger() const; bool variantIsBoolean() const; bool variantIsFloat() const; bool variantIsInteger() const; bool variantIsArray() const { return _type == Internals::JSON_ARRAY; } bool variantIsObject() const { return _type == Internals::JSON_OBJECT; } bool variantIsString() const { return _type == Internals::JSON_STRING || (_type == Internals::JSON_UNPARSED && _content.asString && !strcmp("null", _content.asString)); } Internals::JsonVariantType _type; Internals::JsonVariantContent _content; }; DEPRECATED("Decimal places are ignored, use the float value instead") inline JsonVariant float_with_n_digits(float value, uint8_t) { return JsonVariant(value); } DEPRECATED("Decimal places are ignored, use the double value instead") inline JsonVariant double_with_n_digits(double value, uint8_t) { return JsonVariant(value); } } namespace ArduinoJson { namespace TypeTraits { template <typename T> struct IsArray { static const bool value = false; }; template <typename T> struct IsArray<T[]> { static const bool value = true; }; template <typename T, size_t N> struct IsArray<T[N]> { static const bool value = true; }; } } #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnon-virtual-dtor" #elif defined(__GNUC__) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #pragma GCC diagnostic push #endif #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif namespace ArduinoJson { class JsonArray; class JsonObject; class JsonBuffer : Internals::NonCopyable { public: JsonArray &createArray(); JsonObject &createObject(); template <typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, char *>::type strdup(const TString &src) { return Internals::StringTraits<TString>::duplicate(src, this); } template <typename TString> char *strdup(const TString *src) { return Internals::StringTraits<const TString *>::duplicate(src, this); } virtual void *alloc(size_t size) = 0; protected: static FORCE_INLINE size_t round_size_up(size_t bytes) { #if ARDUINOJSON_ENABLE_ALIGNMENT const size_t x = sizeof(void *) - 1; return (bytes + x) & ~x; #else return bytes; #endif } }; } #if defined(__clang__) #pragma clang diagnostic pop #elif defined(__GNUC__) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #pragma GCC diagnostic pop #endif #endif namespace ArduinoJson { namespace TypeTraits { template <typename T> struct IsConst { static const bool value = false; }; template <typename T> struct IsConst<const T> { static const bool value = true; }; } } namespace ArduinoJson { namespace Internals { template <typename TChar> class StringWriter { public: class String { public: String(TChar** ptr) : _writePtr(ptr), _startPtr(*ptr) {} void append(char c) { *(*_writePtr)++ = TChar(c); } const char* c_str() const { *(*_writePtr)++ = 0; return reinterpret_cast<const char*>(_startPtr); } private: TChar** _writePtr; TChar* _startPtr; }; StringWriter(TChar* buffer) : _ptr(buffer) {} String startString() { return String(&_ptr); } private: TChar* _ptr; }; } } namespace ArduinoJson { namespace Internals { template <typename TReader, typename TWriter> class JsonParser { public: JsonParser(JsonBuffer *buffer, TReader reader, TWriter writer, uint8_t nestingLimit) : _buffer(buffer), _reader(reader), _writer(writer), _nestingLimit(nestingLimit) {} JsonArray &parseArray(); JsonObject &parseObject(); JsonVariant parseVariant() { JsonVariant result; parseAnythingTo(&result); return result; } private: JsonParser &operator=(const JsonParser &); // non-copiable static bool eat(TReader &, char charToSkip); FORCE_INLINE bool eat(char charToSkip) { return eat(_reader, charToSkip); } const char *parseString(); bool parseAnythingTo(JsonVariant *destination); FORCE_INLINE bool parseAnythingToUnsafe(JsonVariant *destination); inline bool parseArrayTo(JsonVariant *destination); inline bool parseObjectTo(JsonVariant *destination); inline bool parseStringTo(JsonVariant *destination); static inline bool isInRange(char c, char min, char max) { return min <= c && c <= max; } static inline bool isLetterOrNumber(char c) { return isInRange(c, '0', '9') || isInRange(c, 'a', 'z') || isInRange(c, 'A', 'Z') || c == '+' || c == '-' || c == '.'; } static inline bool isQuote(char c) { return c == '\'' || c == '\"'; } JsonBuffer *_buffer; TReader _reader; TWriter _writer; uint8_t _nestingLimit; }; template <typename TJsonBuffer, typename TString, typename Enable = void> struct JsonParserBuilder { typedef typename Internals::StringTraits<TString>::Reader InputReader; typedef JsonParser<InputReader, TJsonBuffer &> TParser; static TParser makeParser(TJsonBuffer *buffer, TString &json, uint8_t nestingLimit) { return TParser(buffer, InputReader(json), *buffer, nestingLimit); } }; template <typename TJsonBuffer, typename TChar> struct JsonParserBuilder< TJsonBuffer, TChar *, typename TypeTraits::EnableIf<!TypeTraits::IsConst<TChar>::value>::type> { typedef typename Internals::StringTraits<TChar *>::Reader TReader; typedef StringWriter<TChar> TWriter; typedef JsonParser<TReader, TWriter> TParser; static TParser makeParser(TJsonBuffer *buffer, TChar *json, uint8_t nestingLimit) { return TParser(buffer, TReader(json), TWriter(json), nestingLimit); } }; template <typename TJsonBuffer, typename TString> inline typename JsonParserBuilder<TJsonBuffer, TString>::TParser makeParser( TJsonBuffer *buffer, TString &json, uint8_t nestingLimit) { return JsonParserBuilder<TJsonBuffer, TString>::makeParser(buffer, json, nestingLimit); } } } #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnon-virtual-dtor" #elif defined(__GNUC__) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #pragma GCC diagnostic push #endif #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif namespace ArduinoJson { template <typename TDerived> class JsonBufferBase : public JsonBuffer { public: template <typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, JsonArray &>::type parseArray(const TString &json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseArray(); } template <typename TString> JsonArray &parseArray( TString *json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseArray(); } template <typename TString> JsonArray &parseArray( TString &json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseArray(); } template <typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, JsonObject &>::type parseObject(const TString &json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseObject(); } template <typename TString> JsonObject &parseObject( TString *json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseObject(); } template <typename TString> JsonObject &parseObject( TString &json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseObject(); } template <typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, JsonVariant>::type parse(const TString &json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseVariant(); } template <typename TString> JsonVariant parse(TString *json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseVariant(); } template <typename TString> JsonVariant parse(TString &json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseVariant(); } private: TDerived *that() { return static_cast<TDerived *>(this); } }; } #if defined(__clang__) #pragma clang diagnostic pop #elif defined(__GNUC__) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #pragma GCC diagnostic pop #endif #endif #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnon-virtual-dtor" #elif defined(__GNUC__) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #pragma GCC diagnostic push #endif #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif namespace ArduinoJson { class DefaultAllocator { public: void* allocate(size_t size) { return malloc(size); } void deallocate(void* pointer) { free(pointer); } }; template <typename TAllocator> class DynamicJsonBufferBase : public JsonBufferBase<DynamicJsonBufferBase<TAllocator> > { struct Block; struct EmptyBlock { Block* next; size_t capacity; size_t size; }; struct Block : EmptyBlock { uint8_t data[1]; }; public: enum { EmptyBlockSize = sizeof(EmptyBlock) }; DynamicJsonBufferBase(size_t initialSize = 256) : _head(NULL), _nextBlockCapacity(initialSize) {} ~DynamicJsonBufferBase() { freeAllBlocks(); } size_t size() const { size_t total = 0; for (const Block* b = _head; b; b = b->next) total += b->size; return total; } virtual void* alloc(size_t bytes) { alignNextAlloc(); return canAllocInHead(bytes) ? allocInHead(bytes) : allocInNewBlock(bytes); } void clear() { freeAllBlocks(); _head = 0; } class String { public: String(DynamicJsonBufferBase* parent) : _parent(parent), _start(NULL), _length(0) {} void append(char c) { if (_parent->canAllocInHead(1)) { char* end = static_cast<char*>(_parent->allocInHead(1)); *end = c; if (_length == 0) _start = end; } else { char* newStart = static_cast<char*>(_parent->allocInNewBlock(_length + 1)); if (_start && newStart) memcpy(newStart, _start, _length); if (newStart) newStart[_length] = c; _start = newStart; } _length++; } const char* c_str() { append(0); return _start; } private: DynamicJsonBufferBase* _parent; char* _start; size_t _length; }; String startString() { return String(this); } private: void alignNextAlloc() { if (_head) _head->size = this->round_size_up(_head->size); } bool canAllocInHead(size_t bytes) const { return _head != NULL && _head->size + bytes <= _head->capacity; } void* allocInHead(size_t bytes) { void* p = _head->data + _head->size; _head->size += bytes; return p; } void* allocInNewBlock(size_t bytes) { size_t capacity = _nextBlockCapacity; if (bytes > capacity) capacity = bytes; if (!addNewBlock(capacity)) return NULL; _nextBlockCapacity *= 2; return allocInHead(bytes); } bool addNewBlock(size_t capacity) { size_t bytes = EmptyBlockSize + capacity; Block* block = static_cast<Block*>(_allocator.allocate(bytes)); if (block == NULL) return false; block->capacity = capacity; block->size = 0; block->next = _head; _head = block; return true; } void freeAllBlocks() { Block* currentBlock = _head; while (currentBlock != NULL) { Block* nextBlock = currentBlock->next; _allocator.deallocate(currentBlock); currentBlock = nextBlock; } } TAllocator _allocator; Block* _head; size_t _nextBlockCapacity; }; #if defined(__clang__) #pragma clang diagnostic pop #elif defined(__GNUC__) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #pragma GCC diagnostic pop #endif #endif typedef DynamicJsonBufferBase<DefaultAllocator> DynamicJsonBuffer; } namespace ArduinoJson { namespace Internals { class JsonBufferAllocated { public: void *operator new(size_t n, JsonBuffer *jsonBuffer) throw() { if (!jsonBuffer) return NULL; return jsonBuffer->alloc(n); } void operator delete(void *, JsonBuffer *)throw(); }; } } namespace ArduinoJson { namespace Internals { template <typename T> struct ListNode : public Internals::JsonBufferAllocated { ListNode() throw() : next(NULL) {} ListNode<T> *next; T content; }; } } namespace ArduinoJson { namespace Internals { template <typename T> class ListConstIterator { public: explicit ListConstIterator(const ListNode<T> *node = NULL) : _node(node) {} const T &operator*() const { return _node->content; } const T *operator->() { return &_node->content; } bool operator==(const ListConstIterator<T> &other) const { return _node == other._node; } bool operator!=(const ListConstIterator<T> &other) const { return _node != other._node; } ListConstIterator<T> &operator++() { if (_node) _node = _node->next; return *this; } ListConstIterator<T> &operator+=(size_t distance) { while (_node && distance) { _node = _node->next; --distance; } return *this; } private: const ListNode<T> *_node; }; } } namespace ArduinoJson { namespace Internals { template <typename T> class List; template <typename T> class ListIterator { friend class List<T>; public: explicit ListIterator(ListNode<T> *node = NULL) : _node(node) {} T &operator*() const { return _node->content; } T *operator->() { return &_node->content; } bool operator==(const ListIterator<T> &other) const { return _node == other._node; } bool operator!=(const ListIterator<T> &other) const { return _node != other._node; } ListIterator<T> &operator++() { if (_node) _node = _node->next; return *this; } ListIterator<T> &operator+=(size_t distance) { while (_node && distance) { _node = _node->next; --distance; } return *this; } operator ListConstIterator<T>() const { return ListConstIterator<T>(_node); } private: ListNode<T> *_node; }; } } namespace ArduinoJson { namespace Internals { template <typename T> class List { public: typedef T value_type; typedef ListNode<T> node_type; typedef ListIterator<T> iterator; typedef ListConstIterator<T> const_iterator; explicit List(JsonBuffer *buffer) : _buffer(buffer), _firstNode(NULL) {} bool success() const { return _buffer != NULL; } size_t size() const { size_t nodeCount = 0; for (node_type *node = _firstNode; node; node = node->next) nodeCount++; return nodeCount; } iterator add() { node_type *newNode = new (_buffer) node_type(); if (_firstNode) { node_type *lastNode = _firstNode; while (lastNode->next) lastNode = lastNode->next; lastNode->next = newNode; } else { _firstNode = newNode; } return iterator(newNode); } iterator begin() { return iterator(_firstNode); } iterator end() { return iterator(NULL); } const_iterator begin() const { return const_iterator(_firstNode); } const_iterator end() const { return const_iterator(NULL); } void remove(iterator it) { node_type *nodeToRemove = it._node; if (!nodeToRemove) return; if (nodeToRemove == _firstNode) { _firstNode = nodeToRemove->next; } else { for (node_type *node = _firstNode; node; node = node->next) if (node->next == nodeToRemove) node->next = nodeToRemove->next; } } protected: JsonBuffer *_buffer; private: node_type *_firstNode; }; } } namespace ArduinoJson { namespace Internals { class ReferenceType { public: bool operator==(const ReferenceType& other) const { return this == &other; } bool operator!=(const ReferenceType& other) const { return this != &other; } }; } } namespace ArduinoJson { namespace Internals { template <typename TSourceRef, typename Enable = void> struct ValueSetter { template <typename TDestination> static bool set(JsonBuffer*, TDestination& destination, TSourceRef source) { destination = source; return true; } }; template <typename TSourceRef> struct ValueSetter<TSourceRef, typename TypeTraits::EnableIf<StringTraits< TSourceRef>::should_duplicate>::type> { template <typename TDestination> static bool set(JsonBuffer* buffer, TDestination& destination, TSourceRef source) { const char* copy = buffer->strdup(source); if (!copy) return false; destination = copy; return true; } }; template <typename TSourceRef> struct ValueSetter<TSourceRef, typename TypeTraits::EnableIf<!StringTraits< TSourceRef>::should_duplicate>::type> { template <typename TDestination> static bool set(JsonBuffer*, TDestination& destination, TSourceRef source) { destination = reinterpret_cast<const char*>(source); return true; } }; } } #define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \ (sizeof(JsonArray) + (NUMBER_OF_ELEMENTS) * sizeof(JsonArray::node_type)) namespace ArduinoJson { class JsonObject; class JsonBuffer; class JsonArraySubscript; class JsonArray : public Internals::JsonPrintable<JsonArray>, public Internals::ReferenceType, public Internals::NonCopyable, public Internals::List<JsonVariant>, public Internals::JsonBufferAllocated { public: explicit JsonArray(JsonBuffer *buffer) throw() : Internals::List<JsonVariant>(buffer) {} const JsonArraySubscript operator[](size_t index) const; JsonArraySubscript operator[](size_t index); template <typename T> typename TypeTraits::EnableIf<!TypeTraits::IsArray<T>::value, bool>::type add( const T &value) { return add_impl<const T &>(value); } template <typename T> bool add(const T *value) { return add_impl<const T *>(value); } template <typename T> DEPRECATED("Second argument is not supported anymore") bool add(T value, uint8_t) { return add_impl<const JsonVariant &>(JsonVariant(value)); } template <typename T> typename TypeTraits::EnableIf<!TypeTraits::IsArray<T>::value, bool>::type set( size_t index, const T &value) { return set_impl<const T &>(index, value); } template <typename T> bool set(size_t index, const T *value) { return set_impl<const T *>(index, value); } template <typename T> typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<T>::value, bool>::type set(size_t index, T value, uint8_t decimals) { return set_impl<const JsonVariant &>(index, JsonVariant(value, decimals)); } template <typename T> typename Internals::JsonVariantAs<T>::type get(size_t index) const { const_iterator it = begin() += index; return it != end() ? it->as<T>() : Internals::JsonVariantDefault<T>::get(); } template <typename T> bool is(size_t index) const { const_iterator it = begin() += index; return it != end() ? it->is<T>() : false; } JsonArray &createNestedArray(); JsonObject &createNestedObject(); void remove(size_t index) { remove(begin() += index); } using Internals::List<JsonVariant>::remove; static JsonArray &invalid() { static JsonArray instance(NULL); return instance; } template <typename T, size_t N> bool copyFrom(T (&array)[N]) { return copyFrom(array, N); } template <typename T> bool copyFrom(T *array, size_t len) { bool ok = true; for (size_t i = 0; i < len; i++) { ok &= add(array[i]); } return ok; } template <typename T, size_t N1, size_t N2> bool copyFrom(T (&array)[N1][N2]) { bool ok = true; for (size_t i = 0; i < N1; i++) { JsonArray &nestedArray = createNestedArray(); for (size_t j = 0; j < N2; j++) { ok &= nestedArray.add(array[i][j]); } } return ok; } template <typename T, size_t N> size_t copyTo(T (&array)[N]) const { return copyTo(array, N); } template <typename T> size_t copyTo(T *array, size_t len) const { size_t i = 0; for (const_iterator it = begin(); it != end() && i < len; ++it) array[i++] = *it; return i; } template <typename T, size_t N1, size_t N2> void copyTo(T (&array)[N1][N2]) const { size_t i = 0; for (const_iterator it = begin(); it != end() && i < N1; ++it) { it->as<JsonArray>().copyTo(array[i++]); } } #if ARDUINOJSON_ENABLE_DEPRECATED DEPRECATED("use remove() instead") FORCE_INLINE void removeAt(size_t index) { return remove(index); } #endif private: template <typename TValueRef> bool set_impl(size_t index, TValueRef value) { iterator it = begin() += index; if (it == end()) return false; return Internals::ValueSetter<TValueRef>::set(_buffer, *it, value); } template <typename TValueRef> bool add_impl(TValueRef value) { iterator it = Internals::List<JsonVariant>::add(); if (it == end()) return false; return Internals::ValueSetter<TValueRef>::set(_buffer, *it, value); } }; namespace Internals { template <> struct JsonVariantDefault<JsonArray> { static JsonArray &get() { return JsonArray::invalid(); } }; } } namespace ArduinoJson { struct JsonPair { const char* key; JsonVariant value; }; } #define JSON_OBJECT_SIZE(NUMBER_OF_ELEMENTS) \ (sizeof(JsonObject) + (NUMBER_OF_ELEMENTS) * sizeof(JsonObject::node_type)) namespace ArduinoJson { class JsonArray; class JsonBuffer; class JsonObject : public Internals::JsonPrintable<JsonObject>, public Internals::ReferenceType, public Internals::NonCopyable, public Internals::List<JsonPair>, public Internals::JsonBufferAllocated { public: explicit JsonObject(JsonBuffer* buffer) throw() : Internals::List<JsonPair>(buffer) {} template <typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, JsonObjectSubscript<const TString&> >::type operator[](const TString& key) { return JsonObjectSubscript<const TString&>(*this, key); } template <typename TString> JsonObjectSubscript<const TString*> operator[](const TString* key) { return JsonObjectSubscript<const TString*>(*this, key); } template <typename TString> typename TypeTraits::EnableIf< !TypeTraits::IsArray<TString>::value, const JsonObjectSubscript<const TString&> >::type operator[](const TString& key) const { return JsonObjectSubscript<const TString&>(*const_cast<JsonObject*>(this), key); } template <typename TString> const JsonObjectSubscript<const TString*> operator[]( const TString* key) const { return JsonObjectSubscript<const TString*>(*const_cast<JsonObject*>(this), key); } template <typename TValue, typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value && !TypeTraits::IsArray<TValue>::value, bool>::type set(const TString& key, const TValue& value) { return set_impl<const TString&, const TValue&>(key, value); } template <typename TValue, typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, bool>::type set(const TString& key, const TValue* value) { return set_impl<const TString&, const TValue*>(key, value); } template <typename TValue, typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TValue>::value, bool>::type set(const TString* key, const TValue& value) { return set_impl<const TString*, const TValue&>(key, value); } template <typename TValue, typename TString> bool set(const TString* key, const TValue* value) { return set_impl<const TString*, const TValue*>(key, value); } template <typename TValue, typename TString> DEPRECATED("Second argument is not supported anymore") typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<TValue>::value && !TypeTraits::IsArray<TString>::value, bool>::type set(const TString& key, TValue value, uint8_t) { return set_impl<const TString&, const JsonVariant&>(key, JsonVariant(value)); } template <typename TValue, typename TString> DEPRECATED("Second argument is not supported anymore") typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<TValue>::value, bool>::type set(const TString* key, TValue value, uint8_t) { return set_impl<const TString*, const JsonVariant&>(key, JsonVariant(value)); } template <typename TValue, typename TString> typename TypeTraits::EnableIf< !TypeTraits::IsArray<TString>::value, typename Internals::JsonVariantAs<TValue>::type>::type get(const TString& key) const { return get_impl<const TString&, TValue>(key); } template <typename TValue, typename TString> typename Internals::JsonVariantAs<TValue>::type get( const TString* key) const { return get_impl<const TString*, TValue>(key); } template <typename TValue, typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, bool>::type is(const TString& key) const { return is_impl<const TString&, TValue>(key); } template <typename TValue, typename TString> bool is(const TString* key) const { return is_impl<const TString*, TValue>(key); } template <typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, JsonArray&>::type createNestedArray(const TString& key) { return createNestedArray_impl<const TString&>(key); } template <typename TString> JsonArray& createNestedArray(const TString* key) { return createNestedArray_impl<const TString*>(key); } template <typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, JsonObject&>::type createNestedObject(const TString& key) { return createNestedObject_impl<const TString&>(key); } template <typename TString> JsonObject& createNestedObject(const TString* key) { return createNestedObject_impl<const TString*>(key); } template <typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, bool>::type containsKey(const TString& key) const { return findKey<const TString&>(key) != end(); } template <typename TString> bool containsKey(const TString* key) const { return findKey<const TString*>(key) != end(); } template <typename TString> typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, void>::type remove(const TString& key) { remove(findKey<const TString&>(key)); } template <typename TString> void remove(const TString* key) { remove(findKey<const TString*>(key)); } using Internals::List<JsonPair>::remove; static JsonObject& invalid() { static JsonObject instance(NULL); return instance; } private: template <typename TStringRef> iterator findKey(TStringRef key) { iterator it; for (it = begin(); it != end(); ++it) { if (Internals::StringTraits<TStringRef>::equals(key, it->key)) break; } return it; } template <typename TStringRef> const_iterator findKey(TStringRef key) const { return const_cast<JsonObject*>(this)->findKey<TStringRef>(key); } template <typename TStringRef, typename TValue> typename Internals::JsonVariantAs<TValue>::type get_impl( TStringRef key) const { const_iterator it = findKey<TStringRef>(key); return it != end() ? it->value.as<TValue>() : Internals::JsonVariantDefault<TValue>::get(); } template <typename TStringRef, typename TValueRef> bool set_impl(TStringRef key, TValueRef value) { iterator it = findKey<TStringRef>(key); if (it == end()) { it = Internals::List<JsonPair>::add(); if (it == end()) return false; bool key_ok = Internals::ValueSetter<TStringRef>::set(_buffer, it->key, key); if (!key_ok) return false; } return Internals::ValueSetter<TValueRef>::set(_buffer, it->value, value); } template <typename TStringRef, typename TValue> bool is_impl(TStringRef key) const { const_iterator it = findKey<TStringRef>(key); return it != end() ? it->value.is<TValue>() : false; } template <typename TStringRef> JsonArray& createNestedArray_impl(TStringRef key); template <typename TStringRef> JsonObject& createNestedObject_impl(TStringRef key); }; namespace Internals { template <> struct JsonVariantDefault<JsonObject> { static JsonObject& get() { return JsonObject::invalid(); } }; } } namespace ArduinoJson { namespace Internals { template <typename TComparand, typename Enable = void> struct JsonVariantComparer {}; template <typename TString> struct JsonVariantComparer< TString, typename TypeTraits::EnableIf<TypeTraits::IsString<TString>::value>::type> { template <typename TVariant> static bool equals(const JsonVariantBase<TVariant> &variant, const TString &comparand) { const char *value = variant.template as<const char *>(); return Internals::StringTraits<TString>::equals(comparand, value); } }; template <typename TComparand> struct JsonVariantComparer< TComparand, typename TypeTraits::EnableIf< !TypeTraits::IsVariant<TComparand>::value && !TypeTraits::IsString<TComparand>::value>::type> { template <typename TVariant> static bool equals(const JsonVariantBase<TVariant> &variant, const TComparand &comparand) { return variant.template as<TComparand>() == comparand; } }; template <typename TVariant2> struct JsonVariantComparer<TVariant2, typename TypeTraits::EnableIf< TypeTraits::IsVariant<TVariant2>::value>::type> { template <typename TVariant1> static bool equals(const JsonVariantBase<TVariant1> &left, const TVariant2 &right) { if (left.template is<bool>() && right.template is<bool>()) return left.template as<bool>() == right.template as<bool>(); if (left.template is<JsonInteger>() && right.template is<JsonInteger>()) return left.template as<JsonInteger>() == right.template as<JsonInteger>(); if (left.template is<JsonFloat>() && right.template is<JsonFloat>()) return left.template as<JsonFloat>() == right.template as<JsonFloat>(); if (left.template is<JsonArray>() && right.template is<JsonArray>()) return left.template as<JsonArray>() == right.template as<JsonArray>(); if (left.template is<JsonObject>() && right.template is<JsonObject>()) return left.template as<JsonObject>() == right.template as<JsonObject>(); if (left.template is<char *>() && right.template is<char *>()) return strcmp(left.template as<char *>(), right.template as<char *>()) == 0; return false; } }; } } namespace ArduinoJson { template <typename TVariant, typename TComparand> inline bool operator==(const JsonVariantBase<TVariant> &variant, TComparand comparand) { return Internals::JsonVariantComparer<TComparand>::equals(variant, comparand); } template <typename TVariant, typename TComparand> inline typename TypeTraits::EnableIf<!TypeTraits::IsVariant<TComparand>::value, bool>::type operator==(TComparand comparand, const JsonVariantBase<TVariant> &variant) { return Internals::JsonVariantComparer<TComparand>::equals(variant, comparand); } template <typename TVariant, typename TComparand> inline bool operator!=(const JsonVariantBase<TVariant> &variant, TComparand comparand) { return !Internals::JsonVariantComparer<TComparand>::equals(variant, comparand); } template <typename TVariant, typename TComparand> inline typename TypeTraits::EnableIf<!TypeTraits::IsVariant<TComparand>::value, bool>::type operator!=(TComparand comparand, const JsonVariantBase<TVariant> &variant) { return !Internals::JsonVariantComparer<TComparand>::equals(variant, comparand); } template <typename TVariant, typename TComparand> inline bool operator<=(const JsonVariantBase<TVariant> &left, TComparand right) { return left.template as<TComparand>() <= right; } template <typename TVariant, typename TComparand> inline bool operator<=(TComparand comparand, const JsonVariantBase<TVariant> &variant) { return comparand <= variant.template as<TComparand>(); } template <typename TVariant, typename TComparand> inline bool operator>=(const JsonVariantBase<TVariant> &variant, TComparand comparand) { return variant.template as<TComparand>() >= comparand; } template <typename TVariant, typename TComparand> inline bool operator>=(TComparand comparand, const JsonVariantBase<TVariant> &variant) { return comparand >= variant.template as<TComparand>(); } template <typename TVariant, typename TComparand> inline bool operator<(const JsonVariantBase<TVariant> &varian, TComparand comparand) { return varian.template as<TComparand>() < comparand; } template <typename TVariant, typename TComparand> inline bool operator<(TComparand comparand, const JsonVariantBase<TVariant> &variant) { return comparand < variant.template as<TComparand>(); } template <typename TVariant, typename TComparand> inline bool operator>(const JsonVariantBase<TVariant> &variant, TComparand comparand) { return variant.template as<TComparand>() > comparand; } template <typename TVariant, typename TComparand> inline bool operator>(TComparand comparand, const JsonVariantBase<TVariant> &variant) { return comparand > variant.template as<TComparand>(); } } #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnon-virtual-dtor" #elif defined(__GNUC__) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #pragma GCC diagnostic push #endif #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif namespace ArduinoJson { class StaticJsonBufferBase : public JsonBufferBase<StaticJsonBufferBase> { public: class String { public: String(StaticJsonBufferBase* parent) : _parent(parent) { _start = parent->_buffer + parent->_size; } void append(char c) { if (_parent->canAlloc(1)) { char* last = static_cast<char*>(_parent->doAlloc(1)); *last = c; } } const char* c_str() const { if (_parent->canAlloc(1)) { char* last = static_cast<char*>(_parent->doAlloc(1)); *last = '\0'; return _start; } else { return NULL; } } private: StaticJsonBufferBase* _parent; char* _start; }; StaticJsonBufferBase(char* buffer, size_t capa) : _buffer(buffer), _capacity(capa), _size(0) {} size_t capacity() const { return _capacity; } size_t size() const { return _size; } virtual void* alloc(size_t bytes) { alignNextAlloc(); if (!canAlloc(bytes)) return NULL; return doAlloc(bytes); } void clear() { _size = 0; } String startString() { return String(this); } private: void alignNextAlloc() { _size = round_size_up(_size); } bool canAlloc(size_t bytes) const { return _size + bytes <= _capacity; } void* doAlloc(size_t bytes) { void* p = &_buffer[_size]; _size += bytes; return p; } char* _buffer; size_t _capacity; size_t _size; }; template <size_t CAPACITY> class StaticJsonBuffer : public StaticJsonBufferBase { public: explicit StaticJsonBuffer() : StaticJsonBufferBase(_buffer, CAPACITY) {} private: char _buffer[CAPACITY]; }; } #if defined(__clang__) #pragma clang diagnostic pop #elif defined(__GNUC__) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #pragma GCC diagnostic pop #endif #endif namespace ArduinoJson { namespace Internals { template <typename TInput> void skipSpacesAndComments(TInput& input) { for (;;) { switch (input.current()) { case ' ': case '\t': case '\r': case '\n': input.move(); continue; case '/': switch (input.next()) { case '*': input.move(); // skip '/' for (;;) { input.move(); if (input.current() == '\0') return; if (input.current() == '*' && input.next() == '/') { input.move(); // skip '*' input.move(); // skip '/' break; } } break; case '/': for (;;) { input.move(); if (input.current() == '\0') return; if (input.current() == '\n') break; } break; default: return; } break; default: return; } } } } } template <typename TReader, typename TWriter> inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::eat( TReader &reader, char charToSkip) { skipSpacesAndComments(reader); if (reader.current() != charToSkip) return false; reader.move(); return true; } template <typename TReader, typename TWriter> inline bool ArduinoJson::Internals::JsonParser< TReader, TWriter>::parseAnythingTo(JsonVariant *destination) { if (_nestingLimit == 0) return false; _nestingLimit--; bool success = parseAnythingToUnsafe(destination); _nestingLimit++; return success; } template <typename TReader, typename TWriter> inline bool ArduinoJson::Internals::JsonParser< TReader, TWriter>::parseAnythingToUnsafe(JsonVariant *destination) { skipSpacesAndComments(_reader); switch (_reader.current()) { case '[': return parseArrayTo(destination); case '{': return parseObjectTo(destination); default: return parseStringTo(destination); } } template <typename TReader, typename TWriter> inline ArduinoJson::JsonArray & ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseArray() { JsonArray &array = _buffer->createArray(); if (!eat('[')) goto ERROR_MISSING_BRACKET; if (eat(']')) goto SUCCESS_EMPTY_ARRAY; for (;;) { JsonVariant value; if (!parseAnythingTo(&value)) goto ERROR_INVALID_VALUE; if (!array.add(value)) goto ERROR_NO_MEMORY; if (eat(']')) goto SUCCES_NON_EMPTY_ARRAY; if (!eat(',')) goto ERROR_MISSING_COMMA; } SUCCESS_EMPTY_ARRAY: SUCCES_NON_EMPTY_ARRAY: return array; ERROR_INVALID_VALUE: ERROR_MISSING_BRACKET: ERROR_MISSING_COMMA: ERROR_NO_MEMORY: return JsonArray::invalid(); } template <typename TReader, typename TWriter> inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseArrayTo( JsonVariant *destination) { JsonArray &array = parseArray(); if (!array.success()) return false; *destination = array; return true; } template <typename TReader, typename TWriter> inline ArduinoJson::JsonObject & ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseObject() { JsonObject &object = _buffer->createObject(); if (!eat('{')) goto ERROR_MISSING_BRACE; if (eat('}')) goto SUCCESS_EMPTY_OBJECT; for (;;) { const char *key = parseString(); if (!key) goto ERROR_INVALID_KEY; if (!eat(':')) goto ERROR_MISSING_COLON; JsonVariant value; if (!parseAnythingTo(&value)) goto ERROR_INVALID_VALUE; if (!object.set(key, value)) goto ERROR_NO_MEMORY; if (eat('}')) goto SUCCESS_NON_EMPTY_OBJECT; if (!eat(',')) goto ERROR_MISSING_COMMA; } SUCCESS_EMPTY_OBJECT: SUCCESS_NON_EMPTY_OBJECT: return object; ERROR_INVALID_KEY: ERROR_INVALID_VALUE: ERROR_MISSING_BRACE: ERROR_MISSING_COLON: ERROR_MISSING_COMMA: ERROR_NO_MEMORY: return JsonObject::invalid(); } template <typename TReader, typename TWriter> inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseObjectTo( JsonVariant *destination) { JsonObject &object = parseObject(); if (!object.success()) return false; *destination = object; return true; } template <typename TReader, typename TWriter> inline const char * ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseString() { typename TypeTraits::RemoveReference<TWriter>::type::String str = _writer.startString(); skipSpacesAndComments(_reader); char c = _reader.current(); if (isQuote(c)) { // quotes _reader.move(); char stopChar = c; for (;;) { c = _reader.current(); if (c == '\0') break; _reader.move(); if (c == stopChar) break; if (c == '\\') { c = Encoding::unescapeChar(_reader.current()); if (c == '\0') break; _reader.move(); } str.append(c); } } else { // no quotes for (;;) { if (!isLetterOrNumber(c)) break; _reader.move(); str.append(c); c = _reader.current(); } } return str.c_str(); } template <typename TReader, typename TWriter> inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseStringTo( JsonVariant *destination) { bool hasQuotes = isQuote(_reader.current()); const char *value = parseString(); if (value == NULL) return false; if (hasQuotes) { *destination = value; } else { *destination = RawJson(value); } return true; } #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4522) #endif namespace ArduinoJson { class JsonArraySubscript : public JsonVariantBase<JsonArraySubscript> { public: FORCE_INLINE JsonArraySubscript(JsonArray& array, size_t index) : _array(array), _index(index) {} FORCE_INLINE JsonArraySubscript& operator=(const JsonArraySubscript& src) { _array.set(_index, src); return *this; } template <typename T> FORCE_INLINE JsonArraySubscript& operator=(const T& src) { _array.set(_index, src); return *this; } template <typename T> FORCE_INLINE JsonArraySubscript& operator=(const T* src) { _array.set(_index, src); return *this; } FORCE_INLINE bool success() const { return _index < _array.size(); } template <typename T> FORCE_INLINE typename Internals::JsonVariantAs<T>::type as() const { return _array.get<T>(_index); } template <typename T> FORCE_INLINE bool is() const { return _array.is<T>(_index); } template <typename TValue> FORCE_INLINE bool set(const TValue& value) { return _array.set(_index, value); } template <typename TValue> FORCE_INLINE bool set(const TValue* value) { return _array.set(_index, value); } template <typename TValue> DEPRECATED("Second argument is not supported anymore") FORCE_INLINE bool set(const TValue& value, uint8_t) { return _array.set(_index, value); } private: JsonArray& _array; const size_t _index; }; #if ARDUINOJSON_ENABLE_STD_STREAM inline std::ostream& operator<<(std::ostream& os, const JsonArraySubscript& source) { return source.printTo(os); } #endif inline JsonArraySubscript JsonArray::operator[](size_t index) { return JsonArraySubscript(*this, index); } inline const JsonArraySubscript JsonArray::operator[](size_t index) const { return JsonArraySubscript(*const_cast<JsonArray*>(this), index); } template <typename TImplem> inline JsonArraySubscript JsonVariantBase<TImplem>::operator[](size_t index) { return as<JsonArray>()[index]; } template <typename TImplem> inline const JsonArraySubscript JsonVariantBase<TImplem>::operator[]( size_t index) const { return as<JsonArray>()[index]; } } // namespace ArduinoJson #ifdef _MSC_VER #pragma warning(pop) #endif namespace ArduinoJson { inline JsonArray &JsonArray::createNestedArray() { if (!_buffer) return JsonArray::invalid(); JsonArray &array = _buffer->createArray(); add(array); return array; } inline JsonObject &JsonArray::createNestedObject() { if (!_buffer) return JsonObject::invalid(); JsonObject &object = _buffer->createObject(); add(object); return object; } } inline ArduinoJson::JsonArray &ArduinoJson::JsonBuffer::createArray() { JsonArray *ptr = new (this) JsonArray(this); return ptr ? *ptr : JsonArray::invalid(); } inline ArduinoJson::JsonObject &ArduinoJson::JsonBuffer::createObject() { JsonObject *ptr = new (this) JsonObject(this); return ptr ? *ptr : JsonObject::invalid(); } #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4522) #endif namespace ArduinoJson { template <typename TStringRef> class JsonObjectSubscript : public JsonVariantBase<JsonObjectSubscript<TStringRef> > { typedef JsonObjectSubscript<TStringRef> this_type; public: FORCE_INLINE JsonObjectSubscript(JsonObject& object, TStringRef key) : _object(object), _key(key) {} FORCE_INLINE this_type& operator=(const this_type& src) { _object.set(_key, src); return *this; } template <typename TValue> FORCE_INLINE typename TypeTraits::EnableIf<!TypeTraits::IsArray<TValue>::value, this_type&>::type operator=(const TValue& src) { _object.set(_key, src); return *this; } template <typename TValue> FORCE_INLINE this_type& operator=(const TValue* src) { _object.set(_key, src); return *this; } FORCE_INLINE bool success() const { return _object.containsKey(_key); } template <typename TValue> FORCE_INLINE typename Internals::JsonVariantAs<TValue>::type as() const { return _object.get<TValue>(_key); } template <typename TValue> FORCE_INLINE bool is() const { return _object.is<TValue>(_key); } template <typename TValue> FORCE_INLINE typename TypeTraits::EnableIf<!TypeTraits::IsArray<TValue>::value, bool>::type set(const TValue& value) { return _object.set(_key, value); } template <typename TValue> FORCE_INLINE bool set(const TValue* value) { return _object.set(_key, value); } template <typename TValue> DEPRECATED("Second argument is not supported anymore") FORCE_INLINE bool set(const TValue& value, uint8_t) { return _object.set(_key, value); } private: JsonObject& _object; TStringRef _key; }; #if ARDUINOJSON_ENABLE_STD_STREAM template <typename TStringRef> inline std::ostream& operator<<(std::ostream& os, const JsonObjectSubscript<TStringRef>& source) { return source.printTo(os); } #endif } // namespace ArduinoJson #ifdef _MSC_VER #pragma warning(pop) #endif namespace ArduinoJson { template <typename TStringRef> inline JsonArray &JsonObject::createNestedArray_impl(TStringRef key) { if (!_buffer) return JsonArray::invalid(); JsonArray &array = _buffer->createArray(); set(key, array); return array; } template <typename TStringRef> inline JsonObject &JsonObject::createNestedObject_impl(TStringRef key) { if (!_buffer) return JsonObject::invalid(); JsonObject &object = _buffer->createObject(); set(key, object); return object; } } namespace ArduinoJson { namespace Polyfills { inline bool isdigit(char c) { return '0' <= c && c <= '9'; } inline bool issign(char c) { return '-' == c || c == '+'; } } } namespace ArduinoJson { namespace Polyfills { inline bool isFloat(const char* s) { if (!s) return false; if (!strcmp(s, "NaN")) return true; if (issign(*s)) s++; if (!strcmp(s, "Infinity")) return true; if (*s == '\0') return false; while (isdigit(*s)) s++; if (*s == '.') { s++; while (isdigit(*s)) s++; } if (*s == 'e' || *s == 'E') { s++; if (issign(*s)) s++; if (!isdigit(*s)) return false; while (isdigit(*s)) s++; } return *s == '\0'; } } } namespace ArduinoJson { namespace Polyfills { inline bool isInteger(const char* s) { if (!s) return false; if (issign(*s)) s++; while (isdigit(*s)) s++; return *s == '\0'; } } } namespace ArduinoJson { namespace Polyfills { template <typename T> inline T parseFloat(const char* s) { typedef TypeTraits::FloatTraits<T> traits; typedef typename traits::mantissa_type mantissa_t; typedef typename traits::exponent_type exponent_t; if (!s) return 0; // NULL bool negative_result = false; switch (*s) { case '-': negative_result = true; s++; break; case '+': s++; break; } if (*s == 't') return 1; // true if (*s == 'n' || *s == 'N') return traits::nan(); if (*s == 'i' || *s == 'I') return negative_result ? -traits::inf() : traits::inf(); mantissa_t mantissa = 0; exponent_t exponent_offset = 0; while (isdigit(*s)) { if (mantissa < traits::mantissa_max / 10) mantissa = mantissa * 10 + (*s - '0'); else exponent_offset++; s++; } if (*s == '.') { s++; while (isdigit(*s)) { if (mantissa < traits::mantissa_max / 10) { mantissa = mantissa * 10 + (*s - '0'); exponent_offset--; } s++; } } int exponent = 0; if (*s == 'e' || *s == 'E') { s++; bool negative_exponent = false; if (*s == '-') { negative_exponent = true; s++; } else if (*s == '+') { s++; } while (isdigit(*s)) { exponent = exponent * 10 + (*s - '0'); if (exponent + exponent_offset > traits::exponent_max) { if (negative_exponent) return negative_result ? -0.0f : 0.0f; else return negative_result ? -traits::inf() : traits::inf(); } s++; } if (negative_exponent) exponent = -exponent; } exponent += exponent_offset; T result = traits::make_float(static_cast<T>(mantissa), exponent); return negative_result ? -result : result; } } } namespace ArduinoJson { namespace Polyfills { template <typename T> T parseInteger(const char *s) { if (!s) return 0; // NULL if (*s == 't') return 1; // "true" T result = 0; bool negative_result = false; switch (*s) { case '-': negative_result = true; s++; break; case '+': s++; break; } while (isdigit(*s)) { result = T(result * 10 + T(*s - '0')); s++; } return negative_result ? T(~result + 1) : result; } } } namespace ArduinoJson { inline JsonVariant::JsonVariant(const JsonArray &array) { if (array.success()) { _type = Internals::JSON_ARRAY; _content.asArray = const_cast<JsonArray *>(&array); } else { _type = Internals::JSON_UNDEFINED; } } inline JsonVariant::JsonVariant(const JsonObject &object) { if (object.success()) { _type = Internals::JSON_OBJECT; _content.asObject = const_cast<JsonObject *>(&object); } else { _type = Internals::JSON_UNDEFINED; } } inline JsonArray &JsonVariant::variantAsArray() const { if (_type == Internals::JSON_ARRAY) return *_content.asArray; return JsonArray::invalid(); } inline JsonObject &JsonVariant::variantAsObject() const { if (_type == Internals::JSON_OBJECT) return *_content.asObject; return JsonObject::invalid(); } template <typename T> inline T JsonVariant::variantAsInteger() const { using namespace Internals; switch (_type) { case JSON_UNDEFINED: return 0; case JSON_POSITIVE_INTEGER: case JSON_BOOLEAN: return T(_content.asInteger); case JSON_NEGATIVE_INTEGER: return T(~_content.asInteger + 1); case JSON_STRING: case JSON_UNPARSED: return Polyfills::parseInteger<T>(_content.asString); default: return T(_content.asFloat); } } inline const char *JsonVariant::variantAsString() const { using namespace Internals; if (_type == JSON_UNPARSED && _content.asString && !strcmp("null", _content.asString)) return NULL; if (_type == JSON_STRING || _type == JSON_UNPARSED) return _content.asString; return NULL; } template <typename T> inline T JsonVariant::variantAsFloat() const { using namespace Internals; switch (_type) { case JSON_UNDEFINED: return 0; case JSON_POSITIVE_INTEGER: case JSON_BOOLEAN: return static_cast<T>(_content.asInteger); case JSON_NEGATIVE_INTEGER: return -static_cast<T>(_content.asInteger); case JSON_STRING: case JSON_UNPARSED: return Polyfills::parseFloat<T>(_content.asString); default: return static_cast<T>(_content.asFloat); } } inline bool JsonVariant::variantIsBoolean() const { using namespace Internals; if (_type == JSON_BOOLEAN) return true; if (_type != JSON_UNPARSED || _content.asString == NULL) return false; return !strcmp(_content.asString, "true") || !strcmp(_content.asString, "false"); } inline bool JsonVariant::variantIsInteger() const { using namespace Internals; return _type == JSON_POSITIVE_INTEGER || _type == JSON_NEGATIVE_INTEGER || (_type == JSON_UNPARSED && Polyfills::isInteger(_content.asString)); } inline bool JsonVariant::variantIsFloat() const { using namespace Internals; return _type == JSON_FLOAT || _type == JSON_POSITIVE_INTEGER || _type == JSON_NEGATIVE_INTEGER || (_type == JSON_UNPARSED && Polyfills::isFloat(_content.asString)); } #if ARDUINOJSON_ENABLE_STD_STREAM inline std::ostream &operator<<(std::ostream &os, const JsonVariant &source) { return source.printTo(os); } #endif } // namespace ArduinoJson template <typename Writer> inline void ArduinoJson::Internals::JsonSerializer<Writer>::serialize( const JsonArray& array, Writer& writer) { writer.beginArray(); JsonArray::const_iterator it = array.begin(); while (it != array.end()) { serialize(*it, writer); ++it; if (it == array.end()) break; writer.writeComma(); } writer.endArray(); } template <typename Writer> inline void ArduinoJson::Internals::JsonSerializer<Writer>::serialize( const JsonArraySubscript& arraySubscript, Writer& writer) { serialize(arraySubscript.as<JsonVariant>(), writer); } template <typename Writer> inline void ArduinoJson::Internals::JsonSerializer<Writer>::serialize( const JsonObject& object, Writer& writer) { writer.beginObject(); JsonObject::const_iterator it = object.begin(); while (it != object.end()) { writer.writeString(it->key); writer.writeColon(); serialize(it->value, writer); ++it; if (it == object.end()) break; writer.writeComma(); } writer.endObject(); } template <typename Writer> template <typename TKey> inline void ArduinoJson::Internals::JsonSerializer<Writer>::serialize( const JsonObjectSubscript<TKey>& objectSubscript, Writer& writer) { serialize(objectSubscript.template as<JsonVariant>(), writer); } template <typename Writer> inline void ArduinoJson::Internals::JsonSerializer<Writer>::serialize( const JsonVariant& variant, Writer& writer) { switch (variant._type) { case JSON_FLOAT: writer.writeFloat(variant._content.asFloat); return; case JSON_ARRAY: serialize(*variant._content.asArray, writer); return; case JSON_OBJECT: serialize(*variant._content.asObject, writer); return; case JSON_STRING: writer.writeString(variant._content.asString); return; case JSON_UNPARSED: writer.writeRaw(variant._content.asString); return; case JSON_NEGATIVE_INTEGER: writer.writeRaw('-'); case JSON_POSITIVE_INTEGER: writer.writeInteger(variant._content.asInteger); return; case JSON_BOOLEAN: writer.writeBoolean(variant._content.asInteger != 0); return; default: // JSON_UNDEFINED return; } } using namespace ArduinoJson;
[ "cyrhades76+heroku@gmail.com" ]
cyrhades76+heroku@gmail.com
ebb94a9ba8e6284bbb833b12c682ee8018ed1d23
8ce14cc6b531cc4be6acbf5295d701dd49c851f1
/Client/include/connectionHandler.h
763be8ce3f3377b2cebc56dff72fdf8a93b9e9a0
[]
no_license
danielab1/SocialNetwork
2db807dbb4647e558ef201301c6a9ff2f854be5e
b31990f0bc2f243301c3459611a24136c4506058
refs/heads/master
2022-12-15T14:22:21.132465
2020-09-15T19:20:49
2020-09-15T19:20:49
295,826,822
0
0
null
null
null
null
UTF-8
C++
false
false
1,873
h
#ifndef CONNECTION_HANDLER__ #define CONNECTION_HANDLER__ #include <string> #include <iostream> #include <boost/asio.hpp> #include <condition_variable> using boost::asio::ip::tcp; class ConnectionHandler { private: const std::string host_; const short port_; boost::asio::io_service io_service_; // Provides core I/O functionality tcp::socket socket_; bool loggedIn; public: ConnectionHandler(std::string host, short port); virtual ~ConnectionHandler(); // Connect to the remote machine bool connect(); // Read a fixed number of bytes from the server - blocking. // Returns false in case the connection is closed before bytesToRead bytes can be read. bool getBytes(char bytes[], unsigned int bytesToRead); // Send a fixed number of bytes from the client - blocking. // Returns false in case the connection is closed before all the data is sent. bool sendBytes(const char bytes[], int bytesToWrite); // Read an ascii line from the server // Returns false in case connection closed before a newline can be read. bool getLine(std::string& line); // Send an ascii line from the server // Returns false in case connection closed before all the data is sent. bool sendLine(std::string& line); // Get Ascii data from the server until the delimiter character // Returns false in case connection closed before null can be read. bool getFrameAscii(std::string& frame, char delimiter); // Send a message to the remote host. // Returns false in case connection is closed before all the data is sent. bool sendFrameAscii(const std::string& frame, char delimiter); // Close down the connection properly. void close(); bool getLoggedIn(); void setLoggedIn(bool shouldTerminate); }; //class ConnectionHandler #endif
[ "danielab@post.bgu.ac.il" ]
danielab@post.bgu.ac.il
28d354f19dc3e8252dbd14eb1b7756e77ef6d80e
c6d77298e99ee0193cb1f7dc11b71b64196e2e66
/plugin/jit.h
3ec44d4233f06a93824db28a51b144e60bf1f58d
[ "BSD-2-Clause" ]
permissive
blackeagle1122/samp-plugin-jit
6764a1cd25f9e13ae2194774d2ac2d28f3b1c012
5d51b7225ce9ed27634ddbaacb126dfe2d303ad3
refs/heads/master
2021-01-16T22:03:31.375658
2014-03-30T15:38:04
2014-03-30T15:40:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,685
h
// Copyright (c) 2012-2014 Zeex // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. #ifndef JIT_H #define JIT_H #include "amxservice.h" namespace amxjit { class CompileOutput; } class JIT: public AMXService<JIT> { friend class AMXService<JIT>; public: int Exec(cell *retval, int index); private: explicit JIT(AMX *amx); ~JIT(); private: amxjit::CompileOutput *code_; }; #endif // !JIT_H
[ "zeex@rocketmail.com" ]
zeex@rocketmail.com
4c6bea20429463089dbbff698087aabd22dcd8da
5ee7b59b955ebde297f0dd924382a96a79771681
/plnrcmbd/CrdPlnrNav/PnlPlnrNavGlobal.h
ad5a398250653cca0d4ef6f129009197671bdf9b
[]
no_license
epsitech/planar
a3b22468e6718342218143538a93e7af50debee0
e97374190feaf229dac4ec941e19f6661150e400
refs/heads/master
2021-01-21T04:25:32.542626
2016-08-07T19:20:49
2016-08-07T19:20:49
48,572,177
0
0
null
null
null
null
UTF-8
C++
false
false
6,729
h
/** * \file PnlPlnrNavGlobal.h * job handler for job PnlPlnrNavGlobal (declarations) * \author Alexander Wirthmueller * \date created: 4 Dec 2015 * \date modified: 4 Dec 2015 */ #ifndef PNLPLNRNAVGLOBAL_H #define PNLPLNRNAVGLOBAL_H // IP custInclude --- INSERT /** * PnlPlnrNavGlobal */ class PnlPlnrNavGlobal : public JobPlnr { public: /** * VecVDo (full: VecVPlnrNavGlobalDo) */ class VecVDo { public: static const uint BUTDTPVIEWCLICK = 1; static const uint BUTDTPNEWCRDCLICK = 2; static const uint BUTCTPVIEWCLICK = 3; static const uint BUTCTPNEWCRDCLICK = 4; static const uint BUTMATVIEWCLICK = 5; static const uint BUTMATNEWCRDCLICK = 6; static uint getIx(const string& sref); static string getSref(const uint ix); }; /** * ContIac (full: ContIacPlnrNavGlobal) */ class ContIac : public Block { public: static const uint NUMFLSTDTP = 1; static const uint NUMFLSTCTP = 2; static const uint NUMFLSTMAT = 3; public: ContIac(const uint numFLstDtp = 1, const uint numFLstCtp = 1, const uint numFLstMat = 1); public: uint numFLstDtp; uint numFLstCtp; uint numFLstMat; public: bool readXML(xmlXPathContext* docctx, string basexpath = "", bool addbasetag = false); void writeXML(xmlTextWriter* wr, string difftag = "", bool shorttags = true); set<uint> comm(const ContIac* comp); set<uint> diff(const ContIac* comp); }; /** * StatApp (full: StatAppPlnrNavGlobal) */ class StatApp { public: static void writeXML(xmlTextWriter* wr, string difftag = "", bool shorttags = true, const uint ixPlnrVExpstate = VecPlnrVExpstate::MIND, const bool LstDtpAlt = true, const bool LstCtpAlt = true, const bool LstMatAlt = true, const uint LstDtpNumFirstdisp = 1, const uint LstCtpNumFirstdisp = 1, const uint LstMatNumFirstdisp = 1); }; /** * StatShr (full: StatShrPlnrNavGlobal) */ class StatShr : public Block { public: static const uint LSTDTPAVAIL = 1; static const uint BUTDTPVIEWACTIVE = 2; static const uint LSTCTPAVAIL = 3; static const uint BUTCTPVIEWACTIVE = 4; static const uint LSTMATAVAIL = 5; static const uint BUTMATVIEWACTIVE = 6; public: StatShr(const bool LstDtpAvail = true, const bool ButDtpViewActive = true, const bool LstCtpAvail = true, const bool ButCtpViewActive = true, const bool LstMatAvail = true, const bool ButMatViewActive = true); public: bool LstDtpAvail; bool ButDtpViewActive; bool LstCtpAvail; bool ButCtpViewActive; bool LstMatAvail; bool ButMatViewActive; public: void writeXML(xmlTextWriter* wr, string difftag = "", bool shorttags = true); set<uint> comm(const StatShr* comp); set<uint> diff(const StatShr* comp); }; /** * Tag (full: TagPlnrNavGlobal) */ class Tag { public: static void writeXML(const uint ixPlnrVLocale, xmlTextWriter* wr, string difftag = "", bool shorttags = true); }; /** * DpchAppData (full: DpchAppPlnrNavGlobalData) */ class DpchAppData : public DpchAppPlnr { public: static const uint JREF = 1; static const uint CONTIAC = 2; public: DpchAppData(); public: ContIac contiac; public: void readXML(pthread_mutex_t* mScr, map<string,ubigint>& descr, xmlXPathContext* docctx, string basexpath = "", bool addbasetag = false); }; /** * DpchAppDo (full: DpchAppPlnrNavGlobalDo) */ class DpchAppDo : public DpchAppPlnr { public: static const uint JREF = 1; static const uint IXVDO = 2; public: DpchAppDo(); public: uint ixVDo; public: void readXML(pthread_mutex_t* mScr, map<string,ubigint>& descr, xmlXPathContext* docctx, string basexpath = "", bool addbasetag = false); }; /** * DpchEngData (full: DpchEngPlnrNavGlobalData) */ class DpchEngData : public DpchEngPlnr { public: static const uint JREF = 1; static const uint CONTIAC = 2; static const uint FEEDFLSTCTP = 3; static const uint FEEDFLSTDTP = 4; static const uint FEEDFLSTMAT = 5; static const uint STATAPP = 6; static const uint STATSHR = 7; static const uint TAG = 8; static const uint ALL = 9; public: DpchEngData(const ubigint jref = 0, ContIac* contiac = NULL, Feed* feedFLstCtp = NULL, Feed* feedFLstDtp = NULL, Feed* feedFLstMat = NULL, StatShr* statshr = NULL, const set<uint>& mask = {NONE}); public: ContIac contiac; Feed feedFLstCtp; Feed feedFLstDtp; Feed feedFLstMat; StatShr statshr; public: void merge(DpchEngPlnr* dpcheng); void writeXML(const uint ixPlnrVLocale, pthread_mutex_t* mScr, map<ubigint,string>& scr, map<string,ubigint>& descr, xmlTextWriter* wr); }; bool evalLstDtpAvail(DbsPlnr* dbsplnr); bool evalButDtpViewActive(DbsPlnr* dbsplnr); bool evalLstCtpAvail(DbsPlnr* dbsplnr); bool evalButCtpViewActive(DbsPlnr* dbsplnr); bool evalLstMatAvail(DbsPlnr* dbsplnr); bool evalButMatViewActive(DbsPlnr* dbsplnr); public: // IP constructor --- BEGIN PnlPlnrNavGlobal(XchgPlnr* xchg, DbsPlnr* dbsplnr, const ubigint jrefSup, const uint ixPlnrVLocale); // IP constructor --- END ~PnlPlnrNavGlobal(); public: ContIac contiac; StatShr statshr; Feed feedFLstCtp; Feed feedFLstDtp; Feed feedFLstMat; bool muteRefresh; // IP custVar --- INSERT public: // IP cust --- INSERT public: DpchEngPlnr* getNewDpchEng(set<uint> items); void refreshLstDtp(DbsPlnr* dbsplnr, set<uint>& moditems); void refreshDtp(DbsPlnr* dbsplnr, set<uint>& moditems); void refreshLstCtp(DbsPlnr* dbsplnr, set<uint>& moditems); void refreshCtp(DbsPlnr* dbsplnr, set<uint>& moditems); void refreshLstMat(DbsPlnr* dbsplnr, set<uint>& moditems); void refreshMat(DbsPlnr* dbsplnr, set<uint>& moditems); void refresh(DbsPlnr* dbsplnr, set<uint>& moditems); void updatePreset(DbsPlnr* dbsplnr, const uint ixPlnrVPreset, const ubigint jrefTrig, const bool notif = false); public: void handleRequest(DbsPlnr* dbsplnr, ReqPlnr* req); void handleDpchAppPlnrInit(DbsPlnr* dbsplnr, DpchAppPlnrInit* dpchappplnrinit, DpchEngPlnr** dpcheng); void handleDpchAppDataContiac(DbsPlnr* dbsplnr, ContIac* _contiac, DpchEngPlnr** dpcheng); void handleDpchAppDoButDtpViewClick(DbsPlnr* dbsplnr, DpchEngPlnr** dpcheng); void handleDpchAppDoButDtpNewcrdClick(DbsPlnr* dbsplnr, DpchEngPlnr** dpcheng); void handleDpchAppDoButCtpViewClick(DbsPlnr* dbsplnr, DpchEngPlnr** dpcheng); void handleDpchAppDoButCtpNewcrdClick(DbsPlnr* dbsplnr, DpchEngPlnr** dpcheng); void handleDpchAppDoButMatViewClick(DbsPlnr* dbsplnr, DpchEngPlnr** dpcheng); void handleDpchAppDoButMatNewcrdClick(DbsPlnr* dbsplnr, DpchEngPlnr** dpcheng); // IP handleCall --- BEGIN void handleCall(DbsPlnr* dbsplnr, Call* call); // IP handleCall --- END bool handleCallPlnrHusrRunvMod_crdUsrEq(DbsPlnr* dbsplnr, const ubigint jrefTrig, const uint ixInv, const ubigint refInv); }; #endif
[ "awirthm@gmail.com" ]
awirthm@gmail.com
018f7e9d2d0c9d54f3682de1c5d57e2d4a9c1411
2884129fa8b1e0d6e3f028b56dbbece804bcc689
/myLib.cpp
889e6202cad4d632c3da7f5ee09f184541e2179f
[]
no_license
RahulRocks/9LetterWordGame
8ab4690ee5c47a76ec6a4b87b6ba950a9ed5d2ec
163db0fd5ae94df750b7ebe28e958c114d3cf447
refs/heads/master
2022-12-03T22:56:13.120230
2020-08-02T00:15:52
2020-08-02T00:15:52
284,359,739
0
0
null
null
null
null
UTF-8
C++
false
false
4,873
cpp
#include <myLib.h> #include <algorithm> #include <random> #include <unordered_map> // Global variables std::vector<std::string> dictionary; // A function to check if a string is a valid English word ucm::json checkWord(std::string word){ ucm::json x; x["word"] = word; x["valid"] = false; auto got = std::find(dictionary.begin(), dictionary.end(), word); if (got != dictionary.end()){ x["valid"] = true; } return x; } // A function that generates 9 letters as a starting set for the game ucm::json getList(){ dictionary = readWordsFile("misc/english.txt"); std::random_device dev; std::mt19937 rng(dev()); std::uniform_int_distribution<std::mt19937::result_type> dist(65, 90); ucm::json result; for (int i = 0; i < 9; i++){ int r = dist(rng); result.push_back(r); } return result; } // A function that finds all words that can be made up of a given word ucm::json allSubWords(std::string word){ ucm::json answer; answer.push_back("NO SOLUTION AVAILABLE"); answer.push_back("PLEASE IMPLEMENT IT."); return answer; } // Helper functions... std::vector<std::string> distinct_powerset(std::string str){ if (str.size() == 0){ std::vector<std::string> result; result.push_back(""); return result; } else{ char head = str[0]; std::string tail; tail = str.substr (1,std::string::npos); std::vector<std::string> res = distinct_powerset(tail); std::vector<std::string> ans = res; for (auto element : res){ std::string temp = element; temp.insert(temp.begin(), head); bool found = false; for (std::string curr : ans){ if (curr == temp){ found = true; break; } else{ if (curr != "" && std::is_permutation(temp.begin(), temp.end(), curr.begin())){ found = true; break; } } } if (!found){ ans.push_back(temp); } } return ans; } } bool isShuffled(std::vector<char> one, std::vector<char> two){ bool different = !std::equal(one.begin(), one.end(), two.begin()); bool permutation = std::is_permutation(one.begin(), one.end(), two.begin()); return different && permutation; } void permute(std::string a, int l, int r, std::unordered_map<std::string, bool>& results) { if (l == r) { auto got = results.find(a); if (got == results.end()){ results.insert({a, true}); } } else { for (int i = l; i <= r; i++) { char temp = a[l]; a[l] = a[i]; a[i] = temp; permute(a, l+1, r, results); temp = a[l]; a[l] = a[i]; a[i] = temp; } } } bool equivalent(std::vector<std::string> one, std::vector<std::string> two){ if (one.size() == two.size()){ bool oneInTwo = true; for (int i = 0; i < one.size(); i++){ bool found = false; for (std::string curr : two){ if (curr == one[i] || std::is_permutation(one[i].begin(), one[i].end(), curr.begin())){ found = true; break; } } if (!found){ oneInTwo = false; break; } } return oneInTwo; } else{ return false; } } std::vector<std::string> getAllPossibleSubstrings(std::string word){ std::vector<std::string> ps = distinct_powerset(word); std::vector<std::string> possible; for (std::string item : ps){ //std::cout << item << std::endl; if(item.size() > 0){ if (item.size() == 1){ possible.push_back(item); } else{ std::unordered_map<std::string, bool> curr; permute(item, 0, item.size()-1, curr); for (auto element : curr){ possible.push_back(element.first); } } } } return possible; } std::vector<char> mixup(std::string word){ // Transfer the characters of the string into a vector of chars std::vector<char> result; for (int i = 0; i < word.size(); i++){ result.push_back(word[i]); } // Shuffle the vector std::random_shuffle(result.begin(), result.end()); return result; } std::vector<std::string> readWordsFile(std::string filename){ std::ifstream file(filename); std::string str; std::vector<std::string> words; while (std::getline(file, str)){ words.push_back(boost::to_upper_copy(str)); } return words; }
[ "rahul8848@gmail.com" ]
rahul8848@gmail.com
e36aeed956ce870ba54b946663d4460b54b589b6
169bd4618ac6e2301296bdb82b1de06e7f84ef59
/include/hmac_sha512.h
4ed65c4464ce73ed1ab8fbcf1c7d15dfee4bc663
[ "Apache-2.0" ]
permissive
madMAx43v3r/mmx-node
be9eeff35c9f6b11d45ebcc2b695b90c149550df
a0f4fdfede7cfdbd6c548a00c8a4905e6a76506c
refs/heads/master
2023-08-23T06:32:15.434280
2023-08-18T08:17:15
2023-08-18T08:17:15
431,829,941
203
55
Apache-2.0
2023-09-01T10:52:52
2021-11-25T12:02:35
C++
UTF-8
C++
false
false
772
h
// Copyright (c) 2014-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. #ifndef BITCOIN_CRYPTO_HMAC_SHA512_H #define BITCOIN_CRYPTO_HMAC_SHA512_H #include <sha512.h> #include <stdint.h> #include <stdlib.h> /** A hasher class for HMAC-SHA-512. */ class HMAC_SHA512 { private: SHA512 outer; SHA512 inner; public: static const size_t OUTPUT_SIZE = 64; HMAC_SHA512(const unsigned char* key, size_t keylen); HMAC_SHA512& Write(const unsigned char* data, size_t len) { inner.Write(data, len); return *this; } void Finalize(unsigned char hash[OUTPUT_SIZE]); }; #endif // BITCOIN_CRYPTO_HMAC_SHA512_H
[ "max.wittal@mwittal.de" ]
max.wittal@mwittal.de
85c3f9e86daa24b9800df2efe3f9b768490517d8
89f8351a69ead623623dd30806df829adb2a677f
/16-模型视图投影矩阵/模型视图投影矩阵/main.cpp
02ba0a31ac397cf20684be8fa0d09ab4119a4f86
[ "Apache-2.0" ]
permissive
AlanGeIT/OpenGL
1bba917c0f3e8cf8710b2a5487cd5076368169b0
4e49c72aa1eb587ecc0ce12ab73c3356c08a99cd
refs/heads/master
2022-11-06T09:55:23.095504
2020-06-28T09:45:52
2020-06-28T09:45:52
275,553,784
2
0
null
null
null
null
UTF-8
C++
false
false
4,253
cpp
// // main.cpp // 模型视图投影矩阵 // // Created by Alan Ge on 2020/4/19. // Copyright © 2020 AlanGe. All rights reserved. // #include <stdio.h> #include "GLTools.h" #include "GLMatrixStack.h" #include "GLFrame.h" #include "GLFrustum.h" #include "GLGeometryTransform.h" #include "GLBatch.h" #include "StopWatch.h" #include <math.h> #ifdef __APPLE__ #include <glut/glut.h> #else #define FREEGLUT_STATIC #include <GL/glut.h> #endif GLFrustum viewFrustum; // 视景体-投影矩阵通过它来设置 GLShaderManager shaderManager; // 固定着色管理器 GLTriangleBatch torusBatch; // 三角形批次类,绘制图形 // 设置视口和投影矩阵 void ChangeSize(int w, int h) { if (h==0) { h = 1; } glViewport(0, 0, w, h); // 创建投影矩阵,并将它载入投影矩阵堆栈中 // setPerspective函数的参数是一个从顶点方向看去的视场角度(用角度值表示) // 设置透视模式,初始化其透视矩阵 // 第一个参数一般是35,或者45 viewFrustum.SetPerspective(35.0f, float(w)/float(h), 1.0f, 1000.0f); } // 召唤场景 void RenderScene(void) { // 建立一个基于时间变化的动画 static CStopWatch rotTimer; // 当前时间 * 60s float yRot = rotTimer.GetElapsedSeconds() * 60.0f; // 清除颜色缓冲区 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // 矩阵变量 mRotate:旋转,mModelView:模型视图,mModelViewProjection:模型矩阵最终保存到这 M3DMatrix44f mTranlate,mRotate,mModelView,mModelViewProjection; // 将圆球像Z轴负方向移动2.5个单位长度 (mTranlate(结果保存的地方),x,y,z) m3dTranslationMatrix44(mTranlate, 0.0f, 0.0f,-2.5f); // 围绕y轴旋转(mRotate(旋转结果保存的地方),m3dDegToRad(yRot)(旋转角度),x,y,z) m3dRotationMatrix44(mRotate, m3dDegToRad(yRot), 0.0f, 1.0f, 0.0f); // 将平移和旋转的矩阵进行叉乘,产生一个新的矩阵mModelView // mModelView:最终结果矩阵,mTranlate:平移矩阵,mRotate:旋转矩阵 m3dMatrixMultiply44(mModelView, mTranlate, mRotate); // 模型视图矩阵 和 投影矩阵 相乘 // 将投影矩阵 与 模型视图矩阵进行叉乘,将变化最终结果通过矩阵叉乘的方式应用到mModelViewProjection中来 // mModelViewProjection:结果,viewFrustum.GetProjectionMatrix():获取投影矩阵,mModelView:上面处理的结果矩阵 m3dMatrixMultiply44(mModelViewProjection, viewFrustum.GetProjectionMatrix(), mModelView); // 定义一个颜色 GLfloat vBlack[] = {0.0f,0.0f,0.0f,1.0f}; // 调用平面着色器来渲染图像 shaderManager.UseStockShader(GLT_SHADER_FLAT,mModelViewProjection,vBlack); // 开始绘图 torusBatch.Draw(); glutSwapBuffers();// 交换两个缓冲区指针 glutPostRedisplay(); } void SetupRC() { // 设置背影颜色 glClearColor(0.8f, 0.8f, 0.8f, 1.0f); // 开启深度测试 glEnable(GL_DEPTH_TEST); // 初始化着色管理器 shaderManager.InitializeStockShaders(); //球 /* gltMakeSphere(GLTriangleBatch& sphereBatch, GLfloat fRadius, GLint iSlices, GLint iStacks); 参数1:三角形批次类对象 参数2:球体的半径 参数3:从球体底部到顶部的三角形带的数量.其实球体是一圈一圈的三角形带组成的. 参数4:围绕球体一圈排列的三角形对数 */ gltMakeSphere(torusBatch, 0.4f, 10, 20); // 图形填充方式(前面和背面,线段) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } int main(int argc, char* argv[]) { gltSetWorkingDirectory(argv[0]); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); glutInitWindowSize(800, 600); glutCreateWindow("ModelViewProjection Example"); glutReshapeFunc(ChangeSize); glutDisplayFunc(RenderScene); GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); return 1; } SetupRC(); glutMainLoop(); return 0; }
[ "alange@Alan16.local" ]
alange@Alan16.local
ecde547969687bf2d53e909606e9d70f0fecc303
346c17a1b3feba55e3c8a0513ae97a4282399c05
/CodeGenere/photogram/cEqAppui_GL__PTInc_M2CPolyn4.h
cc1d33d6482627e11291d9ba8627c393e5cdd0fa
[ "LicenseRef-scancode-cecill-b-en" ]
permissive
micmacIGN/micmac
af4ab545c3e1d9c04b4c83ac7e926a3ff7707df6
6e5721ddc65cb9b480e53b5914e2e2391d5ae722
refs/heads/master
2023-09-01T15:06:30.805394
2023-07-25T09:18:43
2023-08-30T11:35:30
74,707,998
603
156
NOASSERTION
2023-06-19T12:53:13
2016-11-24T22:09:54
C++
UTF-8
C++
false
false
1,325
h
// File Automatically generated by eLiSe #include "general/all.h" #include "private/all.h" class cEqAppui_GL__PTInc_M2CPolyn4: public cElCompiledFonc { public : cEqAppui_GL__PTInc_M2CPolyn4(); void ComputeVal(); void ComputeValDeriv(); void ComputeValDerivHessian(); double * AdrVarLocFromString(const std::string &); void SetGL_0_0(double); void SetGL_0_1(double); void SetGL_0_2(double); void SetGL_1_0(double); void SetGL_1_1(double); void SetGL_1_2(double); void SetGL_2_0(double); void SetGL_2_1(double); void SetGL_2_2(double); void SetPolyn4_State_0_0(double); void SetPolyn4_State_1_0(double); void SetPolyn4_State_2_0(double); void SetScNorm(double); void SetXIm(double); void SetYIm(double); static cAutoAddEntry mTheAuto; static cElCompiledFonc * Alloc(); private : double mLocGL_0_0; double mLocGL_0_1; double mLocGL_0_2; double mLocGL_1_0; double mLocGL_1_1; double mLocGL_1_2; double mLocGL_2_0; double mLocGL_2_1; double mLocGL_2_2; double mLocPolyn4_State_0_0; double mLocPolyn4_State_1_0; double mLocPolyn4_State_2_0; double mLocScNorm; double mLocXIm; double mLocYIm; };
[ "deseilligny@users.noreply.github.com" ]
deseilligny@users.noreply.github.com
1514e097a07a660e87eb79d4ab17a2b271b018ea
ae90b21a75bcada2db96474f5624d73291459487
/RRS_Transmitter/out/WLANT/demodulator.cpp
f79c8ff4f52b33d6bff13437c5b230c3b98449b7
[]
no_license
Elizarspbspb/RRFI
c8f5803cfb76b99b460f81855916065f32bae06b
827b3eeaddea1dda9a14137b87ea47ba11a929bf
refs/heads/master
2023-07-11T06:24:28.333827
2021-08-13T16:04:02
2021-08-13T16:04:02
394,362,396
0
0
null
null
null
null
UTF-8
C++
false
false
5,714
cpp
/* File History * $History: demodulator.c $ * * ***************** Version 5 ***************** * User: Akozlov Date: 16.12.04 Time: 16:12 * Updated in $/WLAN * Calculating of channel_sq_amplitudies changed * */ #include "demodulator.h" #include "sim_params.h" #include "sim_consts.h" #include "model.h" /** //////////////////////////////////////////////////////////////////////////////// // Name: demodulator_11a // // Purpose: Implements QAM - demodulation // // Author: Alexandr Kozlov // // Parameters: soft_bits - output, Soft-output demodulated data bits // // freq_OFDM_syms - input, Demodulated symbols // // channel_estimate - input, Estimated transfer factors of channels // // bits_per_QAM_symbol - Bits per QAM symbol // // num_of_OFDM_syms - input, Number of OFDM symbols // // channel_sq_amplitudies - output, Channel square amplitudies // // Returning value: None //////////////////////////////////////////////////////////////////////////////// */ void demodulator_11a( int* soft_bits, fxp_complex* freq_OFDM_syms, fxp_complex* channel_estimate, unsigned num_of_OFDM_syms, unsigned bits_per_QAM_symbol, int* channel_sq_amplitudies ) { unsigned i,j,k; int* cur_dest; int threshold; int last_soft_metric1; int last_soft_metric2; char overflow_flag; #ifdef LOGGING logging( "demodulator_11a...\n", 1 ); #endif //[ Calculate channel amplitudes for ( j = 0; j < NumOfDataSubcarriers; j++ ) { #ifdef LOGGING sprintf( overflow_comment, "Overflow: channel_sq_amplitudies[%d] = \n", j ); #endif channel_sq_amplitudies[j] = fxp_complex_abs2( channel_estimate[ sim_consts.DataSubcPatt[j] - 1 ], fxp_params.Demodulator_precision, fxp_params.Demodulator_exp_position, &overflow_flag, overflow_comment ); /*channel_sq_amplitudies[j] = fxp_complex_mul( channel_estimate[ sim_consts.DataSubcPatt[j] - 1 ], fxp_complex_conjugate( channel_estimate[ sim_consts.DataSubcPatt[j] - 1 ], fxp_params.Demodulator_precision, &overflow_flag, overflow_comment ), fxp_params.Demodulator_precision, fxp_params.Demodulator_exp_position, &overflow_flag, overflow_comment ).re;*/ } //] //[ Demodulate cur_dest = soft_bits; for ( i = 0; i < num_of_OFDM_syms; i++ ) { for ( k = 0; k < NumOfDataSubcarriers; k++ ) { if ( bits_per_QAM_symbol != 1 ) { #ifdef LOGGING sprintf( overflow_comment, "Overflow: threshold = fxp_mul, i = %d\n", i ); #endif threshold = fxp_mul( sim_consts.QAMThresholds[0][bits_per_QAM_symbol / 2], channel_sq_amplitudies[k], fxp_params.Demodulator_precision, fxp_params.Demodulator_exp_position, &overflow_flag, overflow_comment ); last_soft_metric1 = *cur_dest = freq_OFDM_syms[i * NumOfSubcarriers + sim_consts.DataSubcIdx[k] - 1].re; cur_dest ++; for( j = 1; j < bits_per_QAM_symbol / 2; j++ ) { #ifdef LOGGING sprintf( overflow_comment, "Overflow: last_soft_metric1, i = %d, j = %d\n", i, j ); #endif last_soft_metric1 = *cur_dest = fxp_sub( threshold, last_soft_metric1 > 0 ? last_soft_metric1 : -last_soft_metric1, fxp_params.Demodulator_precision, &overflow_flag, overflow_comment ); cur_dest++; threshold >>= 1; } threshold = fxp_mul( sim_consts.QAMThresholds[0][bits_per_QAM_symbol / 2], channel_sq_amplitudies[k], fxp_params.Demodulator_precision, fxp_params.Demodulator_exp_position, &overflow_flag, overflow_comment ); last_soft_metric2 = *cur_dest = freq_OFDM_syms[i * NumOfSubcarriers + sim_consts.DataSubcIdx[k] - 1].im; cur_dest++; for( j = 1; j < bits_per_QAM_symbol / 2; j++ ) { #ifdef LOGGING sprintf( overflow_comment, "Overflow: last_soft_metric2, i = %d, j = %d\n", i, j ); #endif last_soft_metric2 = *cur_dest = fxp_sub( threshold, last_soft_metric2 > 0 ? last_soft_metric2 : -last_soft_metric2, fxp_params.Demodulator_precision, &overflow_flag, overflow_comment ); cur_dest++; threshold >>= 1; } // cur_dest += bits_per_QAM_symbol; } else { (*cur_dest) = freq_OFDM_syms[ i * NumOfSubcarriers + sim_consts.DataSubcIdx[k] - 1 ].re; cur_dest ++; } } } //] #ifdef LOGGING logging( "demodulator_11a finished\n", -1 ); #endif }
[ "valera81368@mail.ru" ]
valera81368@mail.ru
640ce138073c268f5c45804527a3ca9320d05f99
b3217a155f290e78fb90f91ecf33e16a6f6310f0
/c2c/Builder/ManifestWriter.h
344508df2f419c7f040602248a9f9a2b19c4fde1
[]
no_license
Alikvk/c2compiler
f7925353dc2c8770f50f28f302f80d5fd8bccdbb
b3f2a05a76b02f8b6fc35dd739b182c117290bda
refs/heads/master
2021-05-08T10:26:37.262223
2017-12-28T11:38:56
2017-12-28T11:38:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
964
h
/* Copyright 2013-2017 Bas van den Berg * * 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 BUILDER_MANIFEST_WRITER_H #define BUILDER_MANIFEST_WRITER_H #include <string> namespace C2 { class Component; class ManifestWriter { public: ManifestWriter(const Component& component_) : component(component_) {} ~ManifestWriter() {} void write(const std::string& filename) const; private: const Component& component; }; } #endif
[ "b.van.den.berg.nl@gmail.com" ]
b.van.den.berg.nl@gmail.com
ef24ded4ab4c71078a61c7da769b01f7682c2e12
a51a1a17ed8ffe31df94aa2b5890cce04fd21849
/tests/test-hdr/queue/hdr_intrusive_segmented_queue_hp.cpp
41264b72c7a93c4a0f8637b0e877177a571aee1f
[ "BSD-2-Clause" ]
permissive
pranith/libcds
3e72c84ecb0e264a417b4fdd2a2a314702d65b11
eda369d5593612cafa68dc359874f8b61b1a6bb6
refs/heads/master
2020-07-10T11:37:47.980600
2014-10-01T04:28:00
2014-10-01T04:28:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,982
cpp
//$$CDS-header$$ #include "hdr_intrusive_segmented_queue.h" #include <cds/intrusive/segmented_queue.h> #include <cds/gc/hp.h> namespace queue { void HdrIntrusiveSegmentedQueue::SegmQueue_HP() { typedef cds::intrusive::SegmentedQueue< cds::gc::HP, item, cds::intrusive::segmented_queue::make_traits< cds::intrusive::opt::disposer< Disposer > >::type > queue_type; test<queue_type>(); } void HdrIntrusiveSegmentedQueue::SegmQueue_HP_mutex() { typedef cds::intrusive::SegmentedQueue< cds::gc::HP, item, cds::intrusive::segmented_queue::make_traits< cds::intrusive::opt::disposer< Disposer > ,cds::opt::lock_type< std::mutex > >::type > queue_type; test<queue_type>(); } void HdrIntrusiveSegmentedQueue::SegmQueue_HP_shuffle() { typedef cds::intrusive::SegmentedQueue< cds::gc::HP, item, cds::intrusive::segmented_queue::make_traits< cds::intrusive::opt::disposer< Disposer > ,cds::opt::item_counter< cds::atomicity::item_counter > ,cds::opt::permutation_generator< cds::opt::v::random_shuffle_permutation<> > >::type > queue_type; test<queue_type>(); } void HdrIntrusiveSegmentedQueue::SegmQueue_HP_stat() { typedef cds::intrusive::SegmentedQueue< cds::gc::HP, item, cds::intrusive::segmented_queue::make_traits< cds::intrusive::opt::disposer< Disposer > ,cds::opt::item_counter< cds::atomicity::item_counter > ,cds::opt::permutation_generator< cds::opt::v::random_permutation<> > ,cds::opt::stat< cds::intrusive::segmented_queue::stat<> > >::type > queue_type; test<queue_type>(); } } // namespace queue CPPUNIT_TEST_SUITE_REGISTRATION(queue::HdrIntrusiveSegmentedQueue);
[ "khizmax@gmail.com" ]
khizmax@gmail.com
b2f6235ec403bac7d2e4cb5c1199dd0a2b473c5c
eecf0603c8336a49d35ca87f12ad7b2769115422
/QOSS-V1.0/DenisovRadiator/CodeJin/SourceModeGenerationD.cpp
2ec894beae3a7b3e7d35b79437ef3c20312be3c2
[]
no_license
Devil-ly/QOSS-V1.0
e90fab43f9a69fdd16f5cbfc5f95db83fa09e656
73e15f398be7567e187cb2814415a2dd23caaf63
refs/heads/master
2021-05-06T19:12:02.890104
2018-05-26T07:49:56
2018-05-26T07:49:56
112,161,447
2
4
null
2018-04-12T06:13:32
2017-11-27T07:15:17
C++
GB18030
C++
false
false
25,931
cpp
#include "SourceModeGenerationD.h" calculation::SourceModeGenerationD::SourceModeGenerationD( int _SourceKind, int _SourceType, int _Rotation, int _m, int _n, double _Frequency, double _Radius, double _Height, double _Width, int _N) : SourceKind(_SourceKind), SourceType(_SourceType), Rotation(_Rotation), m(_m), n(_n), Frequency(_Frequency), Radius(_Radius), Height(_Height), Width(_Width), N(_N) { ds= _Radius * 2.0 / _N;//采样间距,默认为圆波导类型 EX.resize(_N); HX.resize(_N); EY.resize(_N); HY.resize(_N); EZ.resize(_N); HZ.resize(_N); for (int i = 0; i < _N; i++) { EX[i].resize(_N); HX[i].resize(_N); EY[i].resize(_N); HY[i].resize(_N); EZ[i].resize(_N); HZ[i].resize(_N); }//生成6个分量的矩阵尺寸:N*N }//构造函数定义 //析构函数还需要定义吗? //设置圆波导的参数 void calculation::SourceModeGenerationD::SetSource_Circular(int sourcekind, int sourcetype, int rotation, int m0, int n0, double frequency, double radius) { SourceKind = sourcekind;//只能是1或者2 SourceType = sourcetype; Rotation = rotation; m = m0; n = n0; Frequency = frequency; Radius = radius; ds = 2.0*Radius / N ; Height = 0; Width = 0; } void calculation::SourceModeGenerationD::SetSource_Rectangle(int sourcekind, int sourcetype, int m0, int n0, double frequency, double height, double width) { SourceKind = sourcekind;//只能是3 SourceType = sourcetype; m = m0; n = n0; Frequency = frequency; Radius = 0; Height = height; Width = width; ds = Height / (N - 1); } void calculation::SourceModeGenerationD::SetOutputProperty(int n1) { N = n1;//采样点 if (SourceKind==1 || SourceKind == 2)//如果是圆波导的话 ds = Radius * 2.0 / N;//圆波导的采样间距 else ds = Height / N ;//矩形波导的采样间距,以长边为准 EX.resize(N); HX.resize(N); EY.resize(N); HY.resize(N); EZ.resize(N); HZ.resize(N); for (int i = 0; i < N; i++) { EX[i].resize(N); HX[i].resize(N); EY[i].resize(N); HY[i].resize(N); EZ[i].resize(N); HZ[i].resize(N); }//生成6个分量的矩阵尺寸:N*N //20171030:需要李赟检查一下写的对不对 } bool calculation::SourceModeGenerationD::SetWaveguideMode(int m0, int n0) { if ((m0 < 0) || (n0 < 0)) return false; m = m0; n = n0; return true; } //计算并输出圆波导模式场分布-切向电磁场-金铭改写 201712 bool calculation::SourceModeGenerationD::FieldCalculation_CircularT() { //开始计算场分布 double Lamda = C_Speed / Frequency; double K0 = 2 * Pi / Lamda; double Omega = 2 * Pi * Frequency; //之前利用取较小delta根据公式求导的方式精度不达标, //因此听取白老师的意见,对bessel函数的级数展开式进行求导,再利用夹逼法得到导数零点值 //20171026金铭学长给出快速计算导数根公式,采用 const int MaxLoopNumber = 10000;//最大循环次数 const double step0 = 0.1; //粗扫的步进 const double step1 = step0 / MaxLoopNumber;//第一次细扫的步进 int n0 = 0;//第n0个导数根的初始化 int i0 = 0;//找到了第n个导数根后的区间标记 for (int i = 1; i <= MaxLoopNumber; i++)//特意不从0开始 { if ((D1_J(m, i*step0) >= 0.0 && D1_J(m, (i + 1)*step0) <= 0.0) || (D1_J(m, i*step0) <= 0.0 && D1_J(m, (i + 1)*step0) >= 0.0)) { n0 = n0 + 1;//开始计数 i0 = i;//记下该区间 } if (n0 == n) break;//找到第n个导数根后直接跳出循环,此时导数根落在[i0*ds,(i0+1)*ds]区间上 } //开始第一次细扫[i0*step0,(i0+1)*step0]区间,间隔更小 int j0 = 0;//找到了第n个导数根后的区间标记 for (int j = 0; j <= MaxLoopNumber; j++)//从0开始 { if ((D1_J(m, j*step1 + i0*step0) >= 0.0 && D1_J(m, (j + 1)*step1 + i0*step0) <= 0.0) || (D1_J(m, j*step1 + i0*step0) <= 0.0 && D1_J(m, (j + 1)*step1 + i0*step0) >= 0.0)) { j0 = j;//找到了这个区间,并记下该区间下标 break;//找到第n个导数根后直接跳出循环,此时导数根落在[i*ds,(i+1)*ds]区间上 } } double Xmn = 0.5*((j0*step1 + i0*step0) + ((j0 + 1)*step1 + i0*step0)); //20171026已经验证,完全符合MathCad计算结果 Good! double Kr = Xmn / Radius; if (Kr > K0) return false;//截止 double Kz = pow((K0*K0 - Kr*Kr), 0.5); double Lamda_c = 2.0 * Pi / Kr; double Beta = 2.0 * Pi*Frequency / C_Speed*pow((1.0 - Lamda*Lamda / Lamda_c / Lamda_c), 0.5); //下面开始编写输出场分布 vector <double> X(N);//X坐标,点数为N vector <double> Y(N);//Y坐标,点数为N vector <vector <double>> R(N), JUDGE(N), PHI(N); vector <vector <complex <double>>> ER(N), HR(N), EPhi(N), HPhi(N);//复数矩阵 for (int i = 0; i < N; i++) { R[i].resize(N); JUDGE[i].resize(N); PHI[i].resize(N); ER[i].resize(N); HR[i].resize(N); EPhi[i].resize(N); HPhi[i].resize(N); }//生成R以及相关矩阵的尺寸:N*N ds = Radius * 2.0 / N; //First Generate Ex Hy for (int i = 0; i < N; i++) { X[i] = ds*(i - (N - 1.0) / 2.0); for (int j = 0; j < N; j++) { Y[j] = ds*(j - (N) / 2.0); R[i][j] = pow((X[i] * X[i] + Y[j] * Y[j]), 0.5); JUDGE[i][j] = 0.0; if (R[i][j]<Radius) JUDGE[i][j] = 1.0;//点在半径范围内JUDGE就为1,否则为0 if ((X[i] == 0) && (Y[j] == 0)) PHI[i][j] = 0.0; else PHI[i][j] = atan2(Y[j], X[i]);//各点对应的夹角phi //atan2 就是求相角 2Pi空间 if (JUDGE[i][j] != 0.0)//如果在波导内部 { if (Rotation != 1)//非左旋 { ER[i][j] = E_r(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HR[i][j] = H_r(Kz, Kr, m, R[i][j], PHI[i][j]); EPhi[i][j] = E_phi(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HPhi[i][j] = H_phi(Kz, Kr, m, R[i][j], PHI[i][j]); } else //如果是左旋 { ER[i][j] = E_r_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HR[i][j] = H_r_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j]); EPhi[i][j] = E_phi_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HPhi[i][j] = H_phi_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j]); } EX[i][j] = cos(PHI[i][j])*ER[i][j] - sin(PHI[i][j])*EPhi[i][j]; HY[i][j] = sin(PHI[i][j])*HR[i][j] + cos(PHI[i][j])*HPhi[i][j]; } else//如果在波导外部 { ER[i][j] = 0; HR[i][j] = 0; EPhi[i][j] = 0; HPhi[i][j] = 0; EX[i][j] = 0; HY[i][j] = 0; }//在圆波导范围外场值全为0 }//j }//i //Then Generate Ey Hx for (int i = 0; i < N; i++) { X[i] = ds*(i - N / 2.0); for (int j = 0; j < N; j++) { Y[j] = ds*(j - (N - 1.0) / 2.0); R[i][j] = pow((X[i] * X[i] + Y[j] * Y[j]), 0.5); JUDGE[i][j] = 0.0; if (R[i][j]<Radius) JUDGE[i][j] = 1.0;//点在半径范围内JUDGE就为1,否则为0 if ((X[i] == 0) && (Y[j] == 0)) PHI[i][j] = 0.0; else PHI[i][j] = atan2(Y[j], X[i]);//各点对应的夹角phi //atan2 就是求相角 2Pi空间 if (JUDGE[i][j] != 0.0)//如果在波导内部 { if (Rotation != 1)//非左旋 { ER[i][j] = E_r(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HR[i][j] = H_r(Kz, Kr, m, R[i][j], PHI[i][j]); EPhi[i][j] = E_phi(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HPhi[i][j] = H_phi(Kz, Kr, m, R[i][j], PHI[i][j]); } else //如果是左旋 { ER[i][j] = E_r_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HR[i][j] = H_r_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j]); EPhi[i][j] = E_phi_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HPhi[i][j] = H_phi_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j]); } EY[i][j] = sin(PHI[i][j])*ER[i][j] + cos(PHI[i][j])*EPhi[i][j]; HX[i][j] = cos(PHI[i][j])*HR[i][j] - sin(PHI[i][j])*HPhi[i][j]; } else//如果在波导外部 { ER[i][j] = 0; HR[i][j] = 0; EPhi[i][j] = 0; HPhi[i][j] = 0; EY[i][j] = 0; HX[i][j] = 0; }//在圆波导范围外场值全为0 }//j }//i return true;//算完了 } //计算并输出圆波导模式场分布 - 不改了 bool calculation::SourceModeGenerationD::FieldCalculation_Circular() { //开始计算场分布 double Lamda = C_Speed / Frequency; double K0 = 2 * Pi / Lamda; double Omega= 2 * Pi * Frequency; //之前利用取较小delta根据公式求导的方式精度不达标, //因此听取白老师的意见,对bessel函数的级数展开式进行求导,再利用夹逼法得到导数零点值 //20171026金铭学长给出快速计算导数根公式,采用 const int MaxLoopNumber = 10000;//最大循环次数 const double step0 = 0.1; //粗扫的步进 const double step1 = step0 / MaxLoopNumber;//第一次细扫的步进 int n0 = 0;//第n0个导数根的初始化 int i0 = 0;//找到了第n个导数根后的区间标记 for (int i = 1; i <= MaxLoopNumber; i++)//特意不从0开始 { if ((D1_J(m,i*step0)>=0.0 && D1_J(m, (i+1)*step0)<=0.0) || (D1_J(m, i*step0) <= 0.0 && D1_J(m, (i + 1)*step0) >= 0.0)) { n0 = n0 + 1;//开始计数 i0 = i;//记下该区间 } if (n0 == n) break;//找到第n个导数根后直接跳出循环,此时导数根落在[i0*ds,(i0+1)*ds]区间上 } //开始第一次细扫[i0*step0,(i0+1)*step0]区间,间隔更小 int j0 = 0;//找到了第n个导数根后的区间标记 for (int j = 0; j <= MaxLoopNumber; j++)//从0开始 { if ((D1_J(m, j*step1 +i0*step0) >= 0.0 && D1_J(m, (j+1)*step1 + i0*step0) <= 0.0) || (D1_J(m, j*step1 + i0*step0) <= 0.0 && D1_J(m, (j + 1)*step1 + i0*step0) >= 0.0)) { j0 = j;//找到了这个区间,并记下该区间下标 break;//找到第n个导数根后直接跳出循环,此时导数根落在[i*ds,(i+1)*ds]区间上 } } double Xmn = 0.5*((j0*step1 + i0*step0) + ((j0 + 1)*step1 + i0*step0)); //20171026已经验证,完全符合MathCad计算结果 double Kr = Xmn / Radius; if (Kr > K0) return false;//截止 double Kz = pow((K0*K0 - Kr*Kr), 0.5); double Lamda_c = 2.0 * Pi / Kr; double Beta= 2.0 * Pi*Frequency/C_Speed*pow((1.0 - Lamda*Lamda/ Lamda_c/Lamda_c), 0.5); //下面开始编写输出场分布 vector <double> X(N);//X坐标,点数为N vector <double> Y(N);//Y坐标,点数为N vector <vector <double>> R(N), JUDGE(N), PHI(N); vector <vector <complex <double>>> ER(N), HR(N), EPhi(N), HPhi(N);//复数矩阵 for (int i = 0; i < N; i++) { R[i].resize(N); JUDGE[i].resize(N); PHI[i].resize(N); ER[i].resize(N); HR[i].resize(N); EPhi[i].resize(N); HPhi[i].resize(N); }//生成R以及相关矩阵的尺寸:N*N for (int i = 0; i < N; i++) { X[i] = ds*(i - (N - 1.0) / 2.0); for (int j = 0; j < N; j++) { Y[j] = ds*(j - (N - 1.0) / 2.0); R[i][j] = pow((X[i] * X[i] + Y[j] * Y[j]), 0.5); JUDGE[i][j] = 0.0; if (R[i][j]<Radius) JUDGE[i][j] = 1.0;//点在半径范围内JUDGE就为1,否则为0 if ((X[i] == 0) && (Y[j] == 0)) PHI[i][j] = 0.0; else PHI[i][j] = atan2(Y[j] , X[i]);//各点对应的夹角phi //atan输出范围-pi/2到pi/2 相角范围是-PI~ PI! EZ[i][j] = 0;//TE模式,Ez为0 if (JUDGE[i][j] != 0.0)//如果在波导内部 { if (Rotation != 1)//非左旋 { ER[i][j] = E_r(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HR[i][j] = H_r(Kz, Kr, m, R[i][j], PHI[i][j]); EPhi[i][j] = E_phi(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HPhi[i][j] = H_phi(Kz, Kr, m, R[i][j], PHI[i][j]); HZ[i][j] = H_z(Kr, m, R[i][j], PHI[i][j]); } else //如果是左旋 { ER[i][j] = E_r_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HR[i][j] = H_r_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j]); EPhi[i][j] = E_phi_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j], Omega, Beta); HPhi[i][j] = H_phi_LeftRo(Kz, Kr, m, R[i][j], PHI[i][j]); HZ[i][j] = H_z_LeftRo(Kr, m, R[i][j], PHI[i][j]); } EX[i][j] = cos(PHI[i][j])*ER[i][j] - sin(PHI[i][j])*EPhi[i][j]; HX[i][j] = cos(PHI[i][j])*HR[i][j] - sin(PHI[i][j])*HPhi[i][j]; EY[i][j] = sin(PHI[i][j])*ER[i][j] + cos(PHI[i][j])*EPhi[i][j]; HY[i][j] = sin(PHI[i][j])*HR[i][j] + cos(PHI[i][j])*HPhi[i][j]; } else//如果在波导外部 { ER[i][j]=0; HR[i][j]=0; EPhi[i][j] = 0; HPhi[i][j] = 0; HZ[i][j] = 0; EX[i][j] = 0; HX[i][j] = 0; EY[i][j] = 0; HY[i][j] = 0; }//在圆波导范围外场值全为0 } } return true;//算完了 } bool calculation::SourceModeGenerationD::GetJ_R(vector<complex<double>> &_HPhi, vector<complex<double>> &_Hz, int _Nphi) { int Nphi = _Nphi; double dp = 2 * Pi / Nphi; SourceModeGenerationD::HPhi_r.resize(Nphi); SourceModeGenerationD::Hz_r.resize(Nphi); //开始计算场分布 double Lamda = C_Speed / Frequency; double K0 = 2 * Pi / Lamda; double Omega = 2 * Pi * Frequency; //之前利用取较小delta根据公式求导的方式精度不达标, //因此听取白老师的意见,对bessel函数的级数展开式进行求导,再利用夹逼法得到导数零点值 //20171026金铭学长给出快速计算导数根公式,采用 const int MaxLoopNumber = 10000;//最大循环次数 const double step0 = 0.1; //粗扫的步进 const double step1 = step0 / MaxLoopNumber;//第一次细扫的步进 int n0 = 0;//第n0个导数根的初始化 int i0 = 0;//找到了第n个导数根后的区间标记 for (int i = 1; i <= MaxLoopNumber; i++)//特意不从0开始 { if ((D1_J(m, i*step0) >= 0.0 && D1_J(m, (i + 1)*step0) <= 0.0) || (D1_J(m, i*step0) <= 0.0 && D1_J(m, (i + 1)*step0) >= 0.0)) { n0 = n0 + 1;//开始计数 i0 = i;//记下该区间 } if (n0 == n) break;//找到第n个导数根后直接跳出循环,此时导数根落在[i0*ds,(i0+1)*ds]区间上 } //开始第一次细扫[i0*step0,(i0+1)*step0]区间,间隔更小 int j0 = 0;//找到了第n个导数根后的区间标记 for (int j = 0; j <= MaxLoopNumber; j++)//从0开始 { if ((D1_J(m, j*step1 + i0*step0) >= 0.0 && D1_J(m, (j + 1)*step1 + i0*step0) <= 0.0) || (D1_J(m, j*step1 + i0*step0) <= 0.0 && D1_J(m, (j + 1)*step1 + i0*step0) >= 0.0)) { j0 = j;//找到了这个区间,并记下该区间下标 break;//找到第n个导数根后直接跳出循环,此时导数根落在[i*ds,(i+1)*ds]区间上 } } double Xmn = 0.5*((j0*step1 + i0*step0) + ((j0 + 1)*step1 + i0*step0)); //20171026已经验证,完全符合MathCad计算结果 double Kr = Xmn / Radius; if (Kr > K0) return false;//截止 double Kz = pow((K0*K0 - Kr*Kr), 0.5); double Lamda_c = 2.0 * Pi / Kr; double Beta = 2.0 * Pi*Frequency / C_Speed*pow((1.0 - Lamda*Lamda / Lamda_c / Lamda_c), 0.5); double phi; for (int p = 0; p < Nphi; p++) { phi = (p + 0.5)*dp; if (Rotation != 1)//非左旋 { SourceModeGenerationD::HPhi_r[p] = H_phi(Kz, Kr, SourceModeGenerationD::m, SourceModeGenerationD::Radius, phi); SourceModeGenerationD::Hz_r[p] = H_z(Kr, SourceModeGenerationD::m, SourceModeGenerationD::Radius, phi); } else //如果是左旋 { SourceModeGenerationD::HPhi_r[p] = H_phi_LeftRo(Kz, Kr, SourceModeGenerationD::m, SourceModeGenerationD::Radius, phi); SourceModeGenerationD::Hz_r[p] = H_z_LeftRo(Kr, SourceModeGenerationD::m, SourceModeGenerationD::Radius, phi); } } for (int p = 0; p < Nphi; p++) { _HPhi[p] = SourceModeGenerationD::HPhi_r[p]; _Hz[p] = SourceModeGenerationD::Hz_r[p]; } SourceModeGenerationD::HPhi_r.resize(0); SourceModeGenerationD::Hz_r.resize(0); } //计算矩形波导场分布 bool calculation::SourceModeGenerationD::FieldCalculation_Rectangle() { double Lamda = C_Speed / Frequency; double K0 = 2 * Pi / Lamda; double Omega = 2 * Pi * Frequency; double Lamda_c = 2.0 / pow((m*m*Pi*Pi/Height/ Height + n*n*Pi*Pi/Width/Width), 0.5); double Kc = 2.0 * Pi / Lamda_c; if (Kc > K0) return false;//Kc大于K0时,波导截止,不用再算下去了 double Beta = 2.0 * Pi*Frequency / C_Speed*pow((1.0 - Lamda*Lamda / Lamda_c / Lamda_c), 0.5); complex <double> a1(0, 1);//定义虚数j //下面开始编写矩形波导输出场分布 vector <double> X(N);//X坐标,点数为N vector <double> Y(N);//Y坐标,点数为N vector <vector <double>> JUDGE(N); for (int i = 0; i < N; i++) { JUDGE[i].resize(N); }//生成JUDGE以及相关矩阵的尺寸:N*N for (int i = 0; i < N; i++) { X[i] = ds*i;//这里的X与Y的起始点为(0,0),终点为(a,b) for (int j = 0; j < N; j++) { Y[j] = ds*j; JUDGE[i][j] = 0; if ((abs((X[i])-ds*(N - 1.0) / 2.0) < 0.5*Height) && (abs((Y[j]- ds*(N - 1.0) / 2.0)) < 0.5*Width)) JUDGE[i][j] = 1;//在波导内部的时候JUDGE值为1 if (JUDGE[i][j] != 0.0)//如果在波导内部 { if (SourceType == 1)//TE模式 { HX[i][j] = a1*Beta / Kc / Kc*(m*Pi / Height)*sin(m*Pi / Height*X[i])*cos(n*Pi / Width*Y[i]); HY[i][j] = a1*Beta / Kc / Kc*(n*Pi / Width)*cos(m*Pi / Height*X[i])*sin(n*Pi / Width*Y[i]); HZ[i][j] = cos(m*Pi / Height*X[i])*cos(n*Pi / Width*Y[i]); EX[i][j] = Omega*Mu0 / Beta*HY[i][j]; EY[i][j] = -Omega*Mu0 / Beta*HX[i][j]; EZ[i][j] = 0; } if (SourceType == 2)//TM模式 { EX[i][j] = -a1*Beta/Kc/Kc*(m*Pi/Height)*cos(m*Pi / Height*X[i])*sin(n*Pi / Width*Y[i]); EY[i][j] = -a1*Beta/Kc/Kc*(n*Pi/Width)*sin(m*Pi / Height*X[i])*cos(n*Pi / Width*Y[i]); EZ[i][j] = sin(m*Pi / Height*X[i])*sin(n*Pi / Width*Y[i]); HX[i][j] = -Omega*Eps0 / Beta*EY[i][j]; HY[i][j] = Omega*Eps0 / Beta*EX[i][j]; HZ[i][j] = 0; } } else//如果在矩形波导外部 { EX[i][j] = 0; EY[i][j] = 0; EZ[i][j] = 0; HX[i][j] = 0; HY[i][j] = 0; HZ[i][j] = 0; }//在矩形波导范围外场值全为0 } } return true;//算完了 } //设置场强归一化幅度值 bool calculation::SourceModeGenerationD::SetFieldAmplitude(double K) { if (K<=0.0) return false;//K不能为负值 double MAX_EX=0.0, MAX_EY = 0.0,MAX_EZ = 0.0,MAX = 0.0;//初始化归零 for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (abs(EX[i][j]) >= MAX_EX) MAX_EX = abs(EX[i][j]); if (abs(EY[i][j]) >= MAX_EY) MAX_EY = abs(EY[i][j]); if (abs(EZ[i][j]) >= MAX_EZ) MAX_EZ = abs(EZ[i][j]); } } if (MAX_EX >= MAX_EY) MAX = MAX_EX; else MAX = MAX_EY; if (MAX_EZ >= MAX) MAX = MAX_EZ;//得到电场场强最大值MAX for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { EX[i][j] = EX[i][j] / MAX*K; HX[i][j] = HX[i][j] / MAX*K; EY[i][j] = EY[i][j] / MAX*K; HY[i][j] = HY[i][j] / MAX*K; EZ[i][j] = EZ[i][j] / MAX*K; HZ[i][j] = HZ[i][j] / MAX*K; } }//至此电场分布最大值为指定值K return true; } bool calculation::SourceModeGenerationD::GetCircularWaveguideProperty(double &phi1, double &theta1, double &Rc, double &Lc) { if (SourceKind == 3) return false;//该函数不适用于矩形波导 //再次使用上述已经被验证过的求贝塞尔函数一阶导数根的方法 double Lamda = C_Speed / Frequency; double K0 = 2 * Pi / Lamda; double Omega = 2 * Pi * Frequency; const int MaxLoopNumber = 10000;//最大循环次数 const double step0 = 0.1; //粗扫的步进 const double step1 = step0 / MaxLoopNumber;//第一次细扫的步进 int n0 = 0;//第n0个导数根的初始化 int i0 = 0;//找到了第n个导数根后的区间标记 for (int i = 1; i <= MaxLoopNumber; i++)//特意不从0开始 { if ((D1_J(m, i*step0) >= 0.0 && D1_J(m, (i + 1)*step0) <= 0.0) || (D1_J(m, i*step0) <= 0.0 && D1_J(m, (i + 1)*step0) >= 0.0)) { n0 = n0 + 1;//开始计数 i0 = i;//记下该区间 } if (n0 == n) break;//找到第n个导数根后直接跳出循环,此时导数根落在[i0*ds,(i0+1)*ds]区间上 } //开始第一次细扫[i0*step0,(i0+1)*step0]区间,间隔更小 int j0 = 0;//找到了第n个导数根后的区间标记 for (int j = 0; j <= MaxLoopNumber; j++)//从0开始 { if ((D1_J(m, j*step1 + i0*step0) >= 0.0 && D1_J(m, (j + 1)*step1 + i0*step0) <= 0.0) || (D1_J(m, j*step1 + i0*step0) <= 0.0 && D1_J(m, (j + 1)*step1 + i0*step0) >= 0.0)) { j0 = j;//找到了这个区间,并记下该区间下标 break;//找到第n个导数根后直接跳出循环,此时导数根落在[i*ds,(i+1)*ds]区间上 } } double Xmn = 0.5*((j0*step1 + i0*step0) + ((j0 + 1)*step1 + i0*step0)); //20171026已经验证,完全符合MathCad计算结果 double Kr = Xmn / Radius; if (Kr > K0) return false;//截止 double Kz = pow((K0*K0 - Kr*Kr), 0.5); double Lamda_c = 2.0 * Pi / Kr; double Beta = 2.0 * Pi*Frequency / C_Speed*pow((1.0 - Lamda*Lamda / Lamda_c / Lamda_c), 0.5); //下面开始计算布里渊角等相关参数 phi1 = asin(Kr / K0);//phi1是布里渊角 theta1 = acos(m / Xmn); //theta1是方向矢量在横向的投影与波导切线的夹角 Rc = Radius*m / Xmn;//Rc是焦散圆的半径 //Modified by Ming Jin 20171213 if (SourceKind == 1) {//TE mode Lc = 2 * Radius*tan(Pi * 0.5 - phi1); //2*a*cotphi } else if (SourceKind == 2) {//TM mode Lc = 2 * Pi * Radius * Radius * Kz / Xmn * sqrt(1 - pow(m / Xmn, 2)) / acos(m / Xmn); } return true; } bool calculation::SourceModeGenerationD::GetCircularConverterLauncherTriangle_TE0n( Vector3 &P1, Vector3 &P2, Vector3 &P3) { if ((SourceKind !=1) && (SourceType != 1) && (m!=0)) return false; P1= Vector3(-Radius, 0, 0); P2= Vector3(Radius, 0, 0); double phi; double theta; double Rc; if (GetCircularWaveguideProperty(phi, theta, Rc,Lc)) P3 = Vector3(Radius, 0, 2.0*Radius / (tan(phi))); return true; } bool calculation::SourceModeGenerationD::GetCircularSystemOpticalPath_TE0n_2Mirrors( Vector3 & P4, Vector3 & V1, double & Length1, double & theta1, Vector3 & V2, double & Length2, double & theta2, Vector3 & V3) { if ((SourceKind != 1) && (SourceType != 1) && (m != 0)) return false; P4 = Vector3(Radius, 0, 0); double phi; double theta; double Rc; if (GetCircularWaveguideProperty(phi, theta, Rc,Lc))//让李赟帮我检查一下 V1 = Vector3(-1, 0, 1 / (tan(phi))); Length1 = (1 + 1 * 1.25)*Radius / (sin(phi)); theta1 = Pi - 2.0*phi; V2 = Vector3(1, 0, 1 / (tan(phi))); Length2 = 4 * 1.25*Radius / (cos(0.5*theta1)); theta2 = 0.5*theta1; V3 = Vector3(-1, 0, 0); return true; } //双镜面光路初值设置完成 bool calculation::SourceModeGenerationD::GetCircularSystemOpticalPath_TE0n_3Mirrors( Vector3 & P4, Vector3 & V1, double & Length1, double & theta1, Vector3 & V2, double & Length2, double & theta2, Vector3 & V3, double & Length3, double & theta3, Vector3 & V4) { if ((SourceKind != 1) && (SourceType != 1) && (m != 0)) return false; P4 = Vector3(Radius, 0, 0); double phi; double theta; double Rc; if (GetCircularWaveguideProperty(phi, theta, Rc,Lc))//让李赟帮我检查一下 V1 = Vector3(-1, 0, 1 / (tan(phi))); Length1 = (1 + 1 * 1.25)*Radius / (sin(phi)); theta1 = Pi - 2.0*phi; V2 = Vector3(1, 0, 1 / (tan(phi))); Length2 = 4 * 1.25*Radius / (cos(0.5*theta1)); theta2 = 0.75*theta1; V3 = Vector3(-1, 0, 1*tan(0.25*theta1)); Length3= 7 * 1.25*Radius / (cos(0.25*theta1)); theta3 = 0.25*theta1; V4 = Vector3(1, 0, 0); return true; } //三镜面光路初值设置完成 bool calculation::SourceModeGenerationD::GetCircularSystemOpticalPath_TE0n_4Mirrors( Vector3 & P4, Vector3 & V1, double & Length1, double & theta1, Vector3 & V2, double & Length2, double & theta2, Vector3 & V3, double & Length3, double & theta3, Vector3 & V4, double & Length4, double & theta4, Vector3 & V5) { if ((SourceKind != 1) && (SourceType != 1) && (m != 0)) return false; P4 = Vector3(Radius, 0, 0); double phi; double theta; double Rc; if (GetCircularWaveguideProperty(phi, theta, Rc,Lc))//让李赟帮我检查一下 V1 = Vector3(-1, 0, 1 / (tan(phi))); Length1 = (1 + 1 * 1.25)*Radius / (sin(phi)); theta1 = Pi - 2.0*phi; V2 = Vector3(1, 0, 1 / (tan(phi))); Length2 = 4 * 1.25*Radius / (cos(0.5*theta1)); theta2 = 0.75*theta1; V3 = Vector3(-1, 0, 1 * tan(0.25*theta1)); Length3 = 7 * 1.25*Radius / (cos(0.25*theta1)); theta3 = 0.5*theta1; V4 = Vector3(1, 0, 1 * tan(0.25*theta1)); Length4 = 7 * 1.25*Radius / (cos(0.25*theta1)); theta4 = 0.25*theta1; V4 = Vector3(-1, 0, 0); return true; } //四镜面光路初值设置完成20171116 void calculation::SourceModeGenerationD::GetEX(vector<vector<complex<double>>>& EX0) { EX0.resize(N); for (int i = 0; i < N; i++) { EX0[i].resize(N); }//生成矩阵尺寸:N*N //下面开始赋值 for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { EX0[i][j] = EX[i][j]; } } } void calculation::SourceModeGenerationD::GetHX(vector<vector<complex<double>>>& HX0) { HX0.resize(N); for (int i = 0; i < N; i++) { HX0[i].resize(N); }//生成矩阵尺寸:N*N //下面开始赋值 for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { HX0[i][j] = HX[i][j]; } } } void calculation::SourceModeGenerationD::GetEY(vector<vector<complex<double>>>& EY0) { EY0.resize(N); for (int i = 0; i < N; i++) { EY0[i].resize(N); }//生成矩阵尺寸:N*N //下面开始赋值 for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { EY0[i][j] = EY[i][j]; } } } void calculation::SourceModeGenerationD::GetHY(vector<vector<complex<double>>>& HY0) { HY0.resize(N); for (int i = 0; i < N; i++) { HY0[i].resize(N); }//生成矩阵尺寸:N*N //下面开始赋值 for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { HY0[i][j] = HY[i][j]; } } } void calculation::SourceModeGenerationD::GetEZ(vector<vector<complex<double>>>& EZ0) { EZ0.resize(N); for (int i = 0; i < N; i++) { EZ0[i].resize(N); }//生成矩阵尺寸:N*N //下面开始赋值 for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { EZ0[i][j] = EZ[i][j]; } } } void calculation::SourceModeGenerationD::GetHZ(vector<vector<complex<double>>>& HZ0) { HZ0.resize(N); for (int i = 0; i < N; i++) { HZ0[i].resize(N); }//生成矩阵尺寸:N*N //下面开始赋值 for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { HZ0[i][j] = HZ[i][j]; } } }
[ "Administrator@PC201303161919" ]
Administrator@PC201303161919
3817b2e51c43818ee9d61b80b17e90d1a6dee0dc
390549e8876a05cded4eacb501f3171b5bbf3679
/Template class LL/Data.hpp
4ac86f728d33cc7ca14dfb7b2bbdae23158d5953
[]
no_license
swilliams511/Linked-List
cd5fbffb7f9cea2ea334ba7b97585624632b47d7
713e1dbd38fae5f3cf8ba263eb8c3600fec1664d
refs/heads/master
2021-01-17T08:38:42.980636
2017-04-19T06:41:23
2017-04-19T06:41:23
60,288,945
0
0
null
null
null
null
UTF-8
C++
false
false
1,643
hpp
#ifndef _DATA #define _DATA #include <string> #include <iostream> //sample data object to be used by a template class class Data{ public: //base object functions Data(); //default constructor Data(int v, std::string n); //parameter constructor ~Data(); //destructor Data(const Data& otherData); //copy constructor Data(Data&& otherData); //move constructor //Data operator=(Data otherData); //copy/swap assignment operator (can replace below 2 overloads_ ///using the below two overloads instead of the one saves 1 move call per assignment Data& operator=(const Data& otherData); //standard assignment operator Data& operator=(Data&& otherData); //move assignment operator ///overloaded for sorting the data bool operator<(const Data& otherData) const; bool operator>(const Data& otherData) const; ///overloaded for finding specified data bool operator==(const Data& otherData) const; bool operator!=(const Data& otherData) const; //getters/setters for private variables. Shouldn't appear in other class implementation (only main) //or specified print functions int getValue() const {return value;} void setValue(int v) {value = v;} std::string getName() const {return name;} void setName(std::string n) {name = n;} void print() const; private: //private variables int value; //holds an int std::string name; //holds a string //helper functions void swap(Data& otherData); //helper function for assignment }; #endif // _DATA
[ "williasc@seawolf.sonoma.edu" ]
williasc@seawolf.sonoma.edu
b94171c97fc12229f8480b4692be8b863af22488
e9762514d154dc51779c24ea31e2c811331444f6
/Classes/Receptor.h
09d815803ba62a095149718d69e945bd0d591b27
[ "MIT" ]
permissive
otakuidoru/Reflection
03eeadc1c6c5c65d547b84e31f090f6f0b423ac9
05d55655a75813c7d4f0f5dee4d69a2c05476396
refs/heads/master
2022-12-10T11:37:27.651073
2020-08-23T20:22:50
2020-08-23T20:22:50
254,940,690
0
0
null
null
null
null
UTF-8
C++
false
false
1,753
h
/**************************************************************************** Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. http://www.cocos2d-x.org 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. ****************************************************************************/ #ifndef __RECEPTOR_H__ #define __RECEPTOR_H__ #include <string> #include "cocos2d.h" #include "ColorType.h" #include "GameObject.h" class Receptor : public GameObject { protected: Receptor(int id, ColorType colorType); public: static Receptor* create(int id, ColorType colorType); virtual ~Receptor(); virtual bool initWithFile(const std::string& filename) override; virtual cocos2d::Plane getPlane(unsigned int index) override; }; #endif // __RECEPTOR_H__
[ "chuck.marshall@gmail.com" ]
chuck.marshall@gmail.com
88b5ebda770226199a7102d5f40af2e0c54ca017
d2d211505131fc69695ff7c9b61a38c0ebe5736e
/leet011_maxArea.cpp
372e77ccf9f8f855275184cbf4288c379abaeba2
[]
no_license
csijun/leetcode
3a7135b6023f39776c785fabee1701404e456369
9cd1fc1f4383d16ef95ef6d06223523fb8537e39
refs/heads/master
2021-08-14T14:41:00.414575
2017-11-16T01:48:43
2017-11-16T01:48:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
946
cpp
#include<iostream> #include<string> #include<stdlib.h> #include<vector> using namespace std; class Solution { public: int maxAreaOld001(vector<int>& height) { int area = 0; for(int i = 0; i < height.size()-1; i++){ for(int j = i+1; j < height.size(); j++){ int mi = min(height[i],height[j]); area = max(mi*(j-i),area); } } return area; } int maxArea(vector<int>& height) { int area = 0; int l = 0, r = height.size()-1; while(l < r && l >= 0 && r < height.size()){ area = max(area,min(height[l],height[r])*(r-l)); if(height[l] > height[r]){ r--; }else{ l++; } } return area; } }; int main(){ int a[] = {3, 4, 8, 5, 7, 6}; vector<int> vec(a,a+6); Solution su; cout<<su.maxArea(vec); return 0; }
[ "sdgl0505@163.com" ]
sdgl0505@163.com
d5728057beadb6d0c7f67ea859a1235e942b54e3
3db023edb0af1dcf8a1da83434d219c3a96362ba
/windows_nt_3_5_source_code/NT-782/PRIVATE/CAIROLE/STG/OFSSTG/OFSPSTG.CXX
6989b4511aaf73e9d446b0ecd83f87b1995bd70a
[]
no_license
xiaoqgao/windows_nt_3_5_source_code
de30e9b95856bc09469d4008d76191f94379c884
d2894c9125ff1c14028435ed1b21164f6b2b871a
refs/heads/master
2022-12-23T17:58:33.768209
2020-09-28T20:20:18
2020-09-28T20:20:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,833
cxx
//+--------------------------------------------------------------------------- // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1992 - 1993. // // File: ofspstg.cxx // // Contents: COfsPropStg implementation // // Classes: COfsPropStg // // History: 10-Jun-93 DrewB Created // //---------------------------------------------------------------------------- #include "headers.cxx" #pragma hdrstop // Remove for MAC build #include <iofsprop.h> #include <props.hxx> #include <ofspstg.hxx> #include <ofspenm.hxx> #include <logfile.hxx> //+--------------------------------------------------------------------------- // // Member: COfsPropStg::COfsPropStg, public // // Synopsis: Constructor // // History: 17-Aug-93 DrewB Created // //---------------------------------------------------------------------------- COfsPropStg::COfsPropStg(void) { olDebugOut((DEB_ITRACE, "In COfsPropStg::COfsPropStg:%p()\n", this)); _sig = 0; olDebugOut((DEB_ITRACE, "Out COfsPropStg::COfsPropStg\n")); ENLIST_TRACKING(COfsPropStg); } //+--------------------------------------------------------------------------- // // Member: COfsPropStg::InitFromHandle, public // // Synopsis: Constructor // // Arguments: [h] - Property set parent handle // [riid] - Property set IID // // Returns: Appropriate status code // // History: 10-Jun-93 DrewB Created // //---------------------------------------------------------------------------- SCODE COfsPropStg::InitFromHandle(HANDLE h, REFIID riid) { SCODE sc; olDebugOut((DEB_ITRACE, "In COfsPropStg::InitFromHandle:%p(%p, riid)\n", this, h)); olChk(DupNtHandle(h, &_h)); _iid = riid; _sig = COFSPROPSTG_SIG; olDebugOut((DEB_ITRACE, "Out COfsPropStg::InitFromHandle\n")); EH_Err: return sc; } //+--------------------------------------------------------------------------- // // Member: COfsPropStg::~COfsPropStg, public // // Synopsis: Destructor // // History: 10-Jun-93 DrewB Created // //---------------------------------------------------------------------------- COfsPropStg::~COfsPropStg(void) { olDebugOut((DEB_ITRACE, "In COfsPropStg::~COfsPropStg:%p()\n", this)); _sig = COFSPROPSTG_SIGDEL; olDebugOut((DEB_ITRACE, "Out COfsPropStg::~COfsPropStg\n")); } //+--------------------------------------------------------------------------- // // Member: COfsPropStg::QueryInterface, public // // Synopsis: Return supported interfaces // // Arguments: [riid] - Interface // [ppv] - Object return // // Returns: Appropriate status code // // Modifies: [ppv] // // History: 10-Jun-93 DrewB Created // //---------------------------------------------------------------------------- STDMETHODIMP COfsPropStg::QueryInterface(REFIID riid, void **ppv) { SCODE sc; olDebugOut((DEB_TRACE, "In COfsPropStg::QueryInterface:%p(riid, %p)\n", this, ppv)); if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IPropertyStorage)) { sc = S_OK; *ppv = this; COfsPropStg::AddRef(); } else { sc = E_NOINTERFACE; *ppv = NULL; } olDebugOut((DEB_TRACE, "Out COfsPropStg::QueryInterface => %p\n", *ppv)); return ResultFromScode(sc); } //+--------------------------------------------------------------------------- // // Member: COfsPropStg::ReadMultiple, public // // Synopsis: Gets property values // // Arguments: [cpspec] - Count of properties // [rgpspec] - Property names // [pftmModified] - Modify time // [rgpropid] - Id return // [pprgdpv] - Value array return // // Returns: Appropriate status code // // Modifies: [pprgdpv] // [rgpropid] // // History: 09-Jun-93 DrewB Created // //---------------------------------------------------------------------------- STDMETHODIMP COfsPropStg::ReadMultiple(ULONG cpspec, PROPSPEC rgpspec[], FILETIME *pftmModified, PROPID rgpropid[], STGVARIANT rgdpv[]) { SCODE sc = S_OK; NTSTATUS nts; TTL ttl; FILE_BASIC_INFORMATION fbi; IO_STATUS_BLOCK iosb; olLog(("%p::In COfsPropStg::ReadMultiple(%lu, %p, %p, %p, %p)\n", this, cpspec, rgpspec, pftmModified, rgpropid, rgdpv)); olDebugOut((DEB_ITRACE, "In COfsPropStg::ReadMultiple:%p(" "%lu, %p, %p, %p, %p)\n", this, cpspec, rgpspec, pftmModified, rgpropid, rgdpv)); olChk(Validate()); nts = NtQueryInformationFile(_h, &iosb, &fbi, sizeof(FILE_BASIC_INFORMATION), FileBasicInformation); if (!NT_SUCCESS(nts)) olErr(EH_Err, NtStatusToScode(nts)); if (pftmModified) { LARGE_INTEGER_TO_FILETIME(&fbi.LastWriteTime, pftmModified); } nts = OFSGetProp(_h, _iid, cpspec, rgpspec, rgpropid, &ttl, rgdpv, CoTaskMemAlloc); if (!NT_SUCCESS(nts)) { olErr(EH_Err, NtStatusToScode(nts)); } sc = S_OK; olDebugOut((DEB_ITRACE, "Out COfsPropStg::ReadMultiple\n")); EH_Err: olLog(("%p::Out COfsPropStg::ReadMultiple(). sc == %lX\n", this, sc)); return ResultFromScode(sc); } //+--------------------------------------------------------------------------- // // Member: COfsPropStg::WriteMultiple, public // // Synopsis: Sets property values // // Arguments: [cpspec] - Count of properties // [rgpspec] - Property names // [rgpropid] - Property id return // [rgdpv] - Value array // // Returns: Appropriate status code // // Modifies: [rgpropid] // // History: 09-Jun-93 DrewB Created // //---------------------------------------------------------------------------- STDMETHODIMP COfsPropStg::WriteMultiple(ULONG cpspec, PROPSPEC rgpspec[], PROPID rgpropid[], STGVARIANT rgdpv[]) { SCODE sc = S_OK; NTSTATUS nts; olLog(("%p::In COfsPropStg::WriteMultiple(%lu, %p, %p, %p)\n", this, cpspec, rgpspec, rgpropid, rgdpv)); olDebugOut((DEB_ITRACE, "In COfsPropStg::WriteMultiple:%p(" "%lu, %p, %p, %p)\n", this, cpspec, rgpspec, rgpropid, rgdpv)); olChk(Validate()); nts = OFSSetProp(_h, _iid, cpspec, rgpspec, rgpropid, rgdpv); if (!NT_SUCCESS(nts)) sc = NtStatusToScode(nts); else sc = S_OK; olDebugOut((DEB_ITRACE, "Out COfsPropStg::WriteMultiple\n")); EH_Err: olLog(("%p::Out COfsPropStg::WriteMultiple(). sc == %lX\n", this, sc)); return ResultFromScode(sc); } //+--------------------------------------------------------------------------- // // Member: COfsPropStg::DeleteMultiple, public // // Synopsis: Deletes properties // // Arguments: [cpspec] - Count of names // [rgpspec] - Names // // Returns: Appropriate status code // // History: 09-Jun-93 DrewB Created // //---------------------------------------------------------------------------- STDMETHODIMP COfsPropStg::DeleteMultiple(ULONG cpspec, PROPSPEC rgpspec[]) { SCODE sc; NTSTATUS nts; olLog(("%p::In COfsPropStg::DeleteMultiple(%lu, %p)\n", this, cpspec, rgpspec)); olDebugOut((DEB_ITRACE, "In COfsPropStg::DeleteMultiple:%p(" "%lu, %p)\n", this, cpspec, rgpspec)); olChk(Validate()); nts = OFSDeleteProp(_h, _iid, cpspec, rgpspec); if (!NT_SUCCESS(nts)) sc = NtStatusToScode(nts); else sc = S_OK; olDebugOut((DEB_ITRACE, "Out COfsPropStg::DeleteMultiple\n")); EH_Err: return ResultFromScode(sc); } //+--------------------------------------------------------------------------- // // Member: COfsPropStg::Enum, public // // Synopsis: Create a property enumerator // // Arguments: [ppenm] - Enumerator return // // Returns: Appropriate status code // // Modifies: [ppenm] // // History: 09-Jun-93 DrewB Created // //---------------------------------------------------------------------------- STDMETHODIMP COfsPropStg::Enum(IEnumSTATPROPSTG **ppenm) { SCODE sc; SafeCOfsPropStgEnum popge; olLog(("%p::In COfsPropStg::Enum(%p)\n", this, ppenm)); olDebugOut((DEB_ITRACE, "In COfsPropStg::Enum:%p(%p)\n", this, ppenm)); olChk(Validate()); popge.Attach(new COfsPropStgEnum); olMem((COfsPropStgEnum *)popge); olChk(popge->InitFromHandle(_h, _iid, 0)); TRANSFER_INTERFACE(popge, IEnumSTATPROPSTG, ppenm); olDebugOut((DEB_ITRACE, "Out COfsPropStg::Enum\n")); EH_Err: olLog(("%p::Out COfsPropStg::Enum(). sc == %lX\n", sc)); return ResultFromScode(sc); } //+--------------------------------------------------------------------------- // // Member: COfsPropStg::Commit, public // // Synopsis: Commits transacted changes // // Arguments: [grfCommitFlags] - Flags controlling commit // // Returns: Appropriate status code // // History: 30-Nov-93 DrewB Created // //---------------------------------------------------------------------------- STDMETHODIMP COfsPropStg::Commit(DWORD grfCommitFlags) { SCODE sc; olDebugOut((DEB_ITRACE, "In COfsPropStg::Commit:%p(%lX)\n", this, grfCommitFlags)); // Right now OFS property sets can't be transacted so this doesn't // do anything olChk(Validate()); olDebugOut((DEB_ITRACE, "Out COfsPropStg::Commit\n")); EH_Err: return sc; } //+--------------------------------------------------------------------------- // // Member: COfsPropStg::Revert, public // // Synopsis: Reverts transacted changes // // Returns: Appropriate status code // // History: 30-Nov-93 DrewB Created // //---------------------------------------------------------------------------- STDMETHODIMP COfsPropStg::Revert(void) { SCODE sc; olDebugOut((DEB_ITRACE, "In COfsPropStg::Revert:%p()\n", this)); // Right now OFS property sets can't be transacted so this doesn't // do anything olChk(Validate()); olDebugOut((DEB_ITRACE, "Out COfsPropStg::Revert\n")); EH_Err: return sc; } //+--------------------------------------------------------------------------- // // Member: COfsPropStg::Stat, public // // Synopsis: Returns information about this property set // // Arguments: [pstat] - Stat structure to fill in // // Returns: Appropriate status code // // Modifies: [pstat] // // History: 30-Nov-93 DrewB Created // //---------------------------------------------------------------------------- STDMETHODIMP COfsPropStg::Stat(STATPROPSETSTG *pstat) { SCODE sc; olDebugOut((DEB_ITRACE, "In COfsPropStg::Stat:%p(%p)\n", this, pstat)); olChk(Validate()); // We can't fill in the times right now so zero them memset(pstat, 0, sizeof(STATPROPSETSTG)); pstat->iid = _iid; olDebugOut((DEB_ITRACE, "Out COfsPropStg::Stat\n")); EH_Err: return sc; }
[ "benjamin.barratt@icloud.com" ]
benjamin.barratt@icloud.com
8e01d1094e90f244a8ef94595aec72cae9aa8985
9ec53dadacad0615ea99342d151a562d4ea8c27a
/MakeSkims/CS_GJets/SkimmingGJets.cc_0Pho
1c40a4382b31924945acc4a7700e4d4fde7ff6df
[]
no_license
vhegde91/SUSY_Photon
97e855b039a7ed4f4b8579155bced815fa24b0da
a55515069b8093541a941717c764dbe71869bd74
refs/heads/master
2021-01-01T15:41:58.520062
2018-06-29T07:01:29
2018-06-29T07:01:29
97,674,573
0
1
null
null
null
null
UTF-8
C++
false
false
3,960
#define SkimmingGJets_cxx #include "SkimmingGJets.h" #include <TH2.h> #include <TStyle.h> #include <TCanvas.h> #include <iostream> #include <vector> #include <cstring> #include <string> #include <fstream> using namespace std; int main(int argc, char* argv[]) { if (argc < 2) { cerr << "Please give 3 arguments " << "runList " << " " << "outputFileName" << " " << "dataset" << endl; return -1; } const char *inputFileList = argv[1]; const char *outFileName = argv[2]; const char *data = argv[3]; SkimmingGJets ana(inputFileList, outFileName, data); cout << "dataset " << data << " " << endl; ana.EventLoop(data,inputFileList); return 0; } void SkimmingGJets::EventLoop(const char *data,const char *inputFileList) { if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); cout << "nentries " << nentries << endl; cout << "Analyzing dataset " << data << " " << endl; Long64_t nbytes = 0, nb = 0; int decade = 0; TTree *newtree = fChain->CloneTree(0); string s_data=data; for (Long64_t jentry=0; jentry<nentries;jentry++) { // ==============print number of events done == == == == == == == = // double progress = 10.0 * jentry / (1.0 * nentries); // int k = int (progress); // if (k > decade) // cout << 10 * k << " %" <<endl; // decade = k; // cout<<"j:"<<jentry<<" fcurrent:"<<fCurrent<<endl; // ===============read this entry == == == == == == == == == == == Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; h_selectBaselineYields_->Fill(0); if( Electrons->size() == 0 && Muons->size()==0 ) h_selectBaselineYields_->Fill(1); else continue;//veto leptons //about photons TLorentzVector bestPhoton=getBestPhoton(); // if(bestPhoton.Pt()<100) continue; // h_selectBaselineYields_->Fill(2); //calculate ST and nHadJets int minDRindx=-100,phoMatchingJetIndx=-100,nHadJets=0; double minDR=99999,ST=0; vector<TLorentzVector> hadJets; if(bestPhoton.Pt()>100){ h_selectBaselineYields_->Fill(2); for(int i=0;i<Jets->size();i++){ if( ((*Jets)[i].Pt() > 30.0) && (abs((*Jets)[i].Eta()) <= 2.4) ){ double dR=bestPhoton.DeltaR((*Jets)[i]); if(dR<minDR){minDR=dR;minDRindx=i;} } } for(int i=0;i<Jets->size();i++){ if( ((*Jets)[i].Pt() > 30.0) && (abs((*Jets)[i].Eta()) <= 2.4) ){ if( !(minDR < 0.3 && i==minDRindx) ) hadJets.push_back((*Jets)[i]); } } if( minDR<0.3 ) phoMatchingJetIndx=minDRindx; for(int i=0;i<hadJets.size();i++){ if( (abs(hadJets[i].Eta()) < 2.4) ){ST=ST+(hadJets[i].Pt());} if( (abs(hadJets[i].Eta()) < 2.4) ){nHadJets++;} } if( minDR<0.3 ) ST=ST+bestPhoton.Pt();//add the pt of photon if and only if there is a matching jet. } else{ ST = HT; nHadJets = NJets; } //----------------------------------------------------------------------- //select skimming parameters if( nHadJets >= 2 ) h_selectBaselineYields_->Fill(3); else continue; if( ST>500.) h_selectBaselineYields_->Fill(4); else continue; if( MET>100. ) h_selectBaselineYields_->Fill(5); else continue; //end of select skimming parameters // newtree->Fill(); } // loop over entries // newtree->AutoSave(); } TLorentzVector SkimmingGJets::getBestPhoton(){ int bestPhoIndx=-100; TLorentzVector v1; vector<TLorentzVector> goodPho; for(int iPhoton=0;iPhoton<Photons->size();iPhoton++){ if( ((*Photons_fullID)[iPhoton]) && ((*Photons_hasPixelSeed)[iPhoton]<0.001) ) goodPho.push_back( (*Photons)[iPhoton] ); } if(goodPho.size()==0) return v1; else if(goodPho.size()==1) return goodPho[0]; else{ for(int i=0;i<goodPho.size();i++){ if(i==0) bestPhoIndx=0; else if(goodPho[bestPhoIndx].Pt() < goodPho[i].Pt()) bestPhoIndx=i; } return goodPho[bestPhoIndx]; } }
[ "vhegde91@gmail.com" ]
vhegde91@gmail.com
a8b67d658395e4e97382169fbc1f95e892779ab9
d15ca1dc87cd19c67ec186d29e9e857859781f69
/match/main1.1.cpp
efcfc75104485563104ec56e07fe213c5a843c3d
[]
no_license
Vole23/leetcode
8aebea25cd7d096ee018fbc4a14bad9ebdb0625f
09f8f5bdf574a761174176cb17905e976d8415dc
refs/heads/master
2023-09-02T13:55:01.940024
2021-10-23T08:18:52
2021-10-23T08:18:52
326,338,506
0
0
null
null
null
null
UTF-8
C++
false
false
9,159
cpp
#include<bits/stdc++.h> #include<fcntl.h> #include<unistd.h> #include<sys/mman.h> #include<mutex> #include<sys/stat.h> using namespace std; typedef unsigned long long ll; auto usingtime = 0.0; auto begintime = clock(); auto endtime = clock(); char* result[6]{}; ll number = 0; class ArcNode{ public: ll srcId; ll dstId; ll timestamp1; ll timestamp2; float amount1; float amount2; ll trace[10]; ll times[10]; float money[10]; ArcNode* nextdst{nullptr}; ArcNode(){ this->srcId = 0; this->dstId = 0; this->timestamp1 = 0; this->timestamp2 = 0; this->amount1 = 0; this->amount2 = 0; this->trace[0] = 0; nextdst = nullptr; } ArcNode(ll inits, ll initd, ll initt1, ll initt2, float inita1, float inita2){ this->srcId = inits; this->dstId = initd; this->timestamp1 = initt1; this->timestamp2 = initt2; this->amount1 = inita1; this->amount2 = inita2; this->trace[0] = 0; add_trace(inits, initt1, inita1); nextdst = nullptr; } void add_trace(ll t,ll tim, float amo){ ll trn = this->trace[0]; trn =trn+1; this->trace[0] = trn; this->trace[trn] = t; this->times[trn] = tim; this->money[trn] = amo; } bool check(ll t){ for(unsigned int i=1; i<=this->trace[0]; i++){ if(this->trace[i]==t) return true; } return false; } }; map<ll, int> mKey; typedef struct Node{ ll src; ArcNode* nextdst; }; Node nodeList[1000050],node2[1000050],node3[1000050]; char* mmapread(char* path, ll &len) { ll fd = open(path, O_RDONLY); if(fd == -1) { fd = open(path, O_RDWR|O_CREAT, 0666); if(fd == -1){ exit(-1); } } len = lseek(fd,0,SEEK_END); char* buf = (char*)mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0); close(fd); return buf; } // read all node // init nodeList and backList // node length == nodeList[0].src // node from 1 to length // map is mKey which is transform longlong to nodeid for nodeList. void readin1(char* inputFilePath1) { int t = 0; ll num = 0; ll len1 =0; nodeList[0].src = 0; char* buf = mmapread(inputFilePath1, len1); for (char* p = buf ; *p && p-buf < len1;) { while (*p && *p>='0' && *p<='9') num = num*10 + (*(p++)-'0'); p++; //printf("%lld\n", num); if(num>0){ nodeList[0].src++; t=nodeList[0].src; mKey[num]=t; nodeList[t].src=num;nodeList[t].nextdst=nullptr; node2[t].src = num; node2[t].nextdst = nullptr; num=0; } } munmap(buf,len1); } // read all edge // add edge to nodeList and backList void readin2(char* inputFilePath2) { ll num = 0; ll src = 0; ll dst = 0; ll tim = 0; ll len2 = 0; ll t = 0; float amo = 0; char* buf = mmapread(inputFilePath2, len2); for (char* p = buf ; *p && p-buf < len2 ; ) { while (*p && *p>='0' && *p<='9') num = num*10 + (*(p++)-'0'); p++;src = num;num = 0; while (*p && *p>='0' && *p<='9') num = num*10 + (*(p++)-'0'); p++;dst = num;num = 0; while (*p && *p>='0' && *p<='9') num = num*10 + (*(p++)-'0'); p++;tim = num;num = 0; while (*p && *p>='0' && *p<='9') num = num*10 + (*(p++)-'0'); p++;amo = num;num = 0; ll ten=1; while (*p && *p>='0' && *p<='9') num = num*10 + (*(p++)-'0'), ten = ten * 10; p++;amo = amo + (float)num/ten;num = 0; //maybe we can try the adj Maxtrix int head = 0; int tail = 0; head = mKey[src]; tail = mKey[dst]; ArcNode *q = new ArcNode(head, tail, tim, tim, amo, amo); q->nextdst = nodeList[head].nextdst;nodeList[head].nextdst = q; q = nullptr;delete q;q = NULL; t++; if(t%1000000==0) std::printf("%lld\n",t); if(t==500000) break; } munmap(buf,len2); } // calculate node2 void dfs_2() { for (unsigned int i=1; i<=nodeList[0].src; i++) { ArcNode *q; Node head=nodeList[i]; q = head.nextdst; while (q!=nullptr) { ll did = q->dstId; ArcNode *d; Node dhead = nodeList[did]; d = dhead.nextdst; while(d!=nullptr) { if(d->dstId!=q->srcId && d->timestamp1>q->timestamp2 && d->amount1 > q->amount2*0.9 && d->amount1 < q->amount2*1.1) { ArcNode *o = new ArcNode(q->srcId, d->dstId, q->timestamp1, d->timestamp2, q->amount1, d->amount2); o->add_trace(d->trace[1],d->times[1], d->money[1]); o->nextdst = node2[q->srcId].nextdst; node2[q->srcId].nextdst = o; o = nullptr; delete o; o = NULL; } d = d->nextdst; } d = nullptr; delete d; d= NULL; q = q->nextdst; } q = nullptr; delete q; q = NULL; } } void dfs_3() { for (unsigned int i=1; i<=nodeList[0].src; i++) { ArcNode *q; Node head=nodeList[i]; q = head.nextdst; while (q!=nullptr) { ArcNode *d; Node dhead = node2[q->dstId]; d = dhead.nextdst; while(d!=nullptr) { if(d->dstId!=q->srcId && d->timestamp1>q->timestamp2 && d->amount1 > q->amount2*0.9 && d->amount1 < q->amount2*1.1) { ArcNode *o = new ArcNode(q->srcId, d->dstId, q->timestamp1, d->timestamp2, q->amount1, d->amount2); o->add_trace(d->trace[1],d->times[1], d->money[1]); o->add_trace(d->trace[2],d->times[2], d->money[2]); o->nextdst = node3[q->srcId].nextdst; node3[q->srcId].nextdst = o; o = nullptr; delete o; o = NULL; } d = d->nextdst; } d = nullptr; delete d; d= NULL; q = q->nextdst; } q = nullptr; delete q; q = NULL; } } void gooooood(){ number+=1; //std::printf("%lld\n",number); } //find two links from l1 and l2, link them, length equal lens, write into l3. //if find right circle ,gooooood! void dfs_com(Node* l1, Node* l2) { for(unsigned int i=1; i<= nodeList[0].src; i++) { ArcNode* q; Node head = l1[i]; q = head.nextdst; while(q!=nullptr) { ArcNode* d; Node dhead = l2[q->dstId]; d = dhead.nextdst; while(d!=nullptr) { bool flag = true;//check same vercex for(unsigned int i=1; i<=d->trace[0]; i++){ if(q->check(d->trace[i])){ flag = false; break; } } if(flag){ if(d->dstId == q->srcId){ if (d->timestamp1>q->timestamp2 && d->amount1 > q->amount2*0.9 && d->amount1 < q->amount2*1.1){ if (q->trace[0]+d->trace[0]>=3 && q->trace[0]+d->trace[0]<=6){//right circle gooooood(); for(unsigned int i=1; i<=q->trace[0]; i++) { std::printf("(%lld)-[%lld,%.2f]->",nodeList[q->trace[i]].src,q->times[i],q->money[i]); } for(unsigned int i=1; i<=d->trace[0]; i++) { std::printf("(%lld)-[%lld,%.2f]->",nodeList[d->trace[i]].src,d->times[i],d->money[i]); } std::printf("(%lld)\n",nodeList[q->srcId].src); } } } } d = d->nextdst; } d = nullptr; delete d; d = NULL; q = q->nextdst; } q = nullptr; delete q; q = NULL; } } void deep(int dep) { if(dep==3) { dfs_com(nodeList, node2); } if(dep==4) { dfs_com(node2, node2); } if(dep==5) { dfs_com(node2, node3); } if(dep==6) { dfs_com(node3, node3); } } void dfs_method() { dfs_2(); dfs_3(); deep(3); deep(4); deep(5); deep(6); } int main(){ //baseline1: /* char* inputFilePath1 = (char*)"/home/kaos/Desktop/C++/test/dataset/account.csv"; char* inputFilePath2 = (char*)"/home/kaos/Desktop/C++/test/dataset/transfer.csv"; */ char* inputFilePath1 = (char*)"/home/kaos/Desktop/C++/test/dataset/testaccount.csv"; char* inputFilePath2 = (char*)"/home/kaos/Desktop/C++/test/dataset/testtransfer.csv"; char* outputFilePath = (char*)"/home/kaos/Desktop/C++/test/result.csv"; readin1(inputFilePath1); readin2(inputFilePath2); dfs_method(); std::printf("%lld\n",number); return 0; }
[ "123566548@qq.com" ]
123566548@qq.com
69feae13acdd189122d75d183c14e111a1183221
8bfc0b8cb378acab599cdf57e6aee01743589632
/src/platform_dependant.h
19c467c232c9e923eafde8c7b9c67c907c6fc424
[ "MIT" ]
permissive
jayden97/DataStructures-team5
039794088e823ec3a8441acd80c986c53a4510b7
fc1f5a4de6efe5d2e73bf7f0837e03cf0294885b
refs/heads/main
2023-01-30T20:21:57.199914
2020-12-11T10:22:09
2020-12-11T10:22:09
308,786,322
0
0
null
null
null
null
UTF-8
C++
false
false
679
h
#ifndef DSP_TEAM_PROJECT_PLATFORM_DEPENDANT_H #define DSP_TEAM_PROJECT_PLATFORM_DEPENDANT_H #if !defined(CONSOLE_OUTPUT_MODE_ANSI) && !defined(CONSOLE_OUTPUT_MODE_NCURSES) #if defined WIN32 #define CONSOLE_OUTPUT_MODE_ANSI #else #define CONSOLE_OUTPUT_MODE_NCURSES #endif // defined WIN32 #endif #include <string> #include "attributes.h" void init_screen(); int get_char(); void close_screen(); void clear_screen(); void cursor_move(int x, int y); void set_cursor_color(int foreground, int background); void screen_print_text(const std::string& text); arrow is_arrow_key(int c); void get_width_height(int& x, int& y); #endif //DSP_TEAM_PROJECT_PLATFORM_DEPENDANT_H
[ "jyc00410@gmail.com" ]
jyc00410@gmail.com
b8f06cce44c12ae7a758b38f77f17949dec8766f
afee7d79003616df7e215715aad78a8ec01657e2
/UVA/11286 - Conformity.cpp
83f693ed947b757ceac9d09e00111601a7303a36
[]
no_license
elgharib94/Problem-Solving-Solution
d8c7eb0cac4f555bb7cba84687bc8fa0fca64fd6
e9ae560bddcafa6f91c7d586e40ff22ad18fe92e
refs/heads/master
2023-01-04T17:35:41.741788
2020-10-29T13:09:21
2020-10-29T13:09:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
646
cpp
#include <bits/stdc++.h> using namespace std; int main() { map<set<int>, int> m; map<set<int>, int>::iterator it; set<int> s; int n, x, mx; int c = 0; while (cin >> n && n != 0) { mx = 1; c = 0; for (int i = 0; i < n; ++i) { for (int i = 0; i < 5; ++i) { cin >> x; s.insert(x); } //////////////////////////////// if (m.find(s) != m.end()) { m[s]++; mx = max(mx, m[s]); } else { m[s] = 1; } //////////////////////////////// s.clear(); } for (it = m.begin(); it != m.end(); ++it) { if (it->second == mx) { c++; } } cout << mx * c << endl; m.clear(); } return 0; }
[ "aelghareb.ext@orange.com" ]
aelghareb.ext@orange.com
3e175a7376326703ac00b688a7bfa9a4ea85e589
e71fc363e9f8988e3a471d7f9c69c0eabdc017b4
/opt_jr/src/search_factory.hh
30a9598a6d45cff2650297e23e5746b8ea4aabe9
[]
no_license
davide-burba/PACS_PROJECT
e58b34c2abbbe48453d7e1e373bc9fe17d73bb40
1fd26a1a8f6e959b0a5e29db1d8154750af9519b
refs/heads/master
2021-09-04T20:52:12.370760
2018-01-22T10:24:55
2018-01-22T10:24:55
108,164,261
0
1
null
null
null
null
UTF-8
C++
false
false
640
hh
#ifndef SEARCH_SELECTOR #define SEARCH_SELECTOR #include <memory> #include <iostream> #include "search_base.hh" #include "batch.hh" #include "opt_jr_parameters.hh" /** Search_factory is a factory of search objects. search_builder method chooses a policy for search template class according to parameters stored in the Opt_jr_parameters object */ class Search_factory{ public: /** search_builder method chooses a policy for search template class according to parameters stored in the Opt_jr_parameters object. */ static std::unique_ptr<Search_base> search_builder(Opt_jr_parameters &par, Batch &app_manager); }; #endif
[ "davide.burba@mail.polimi.it" ]
davide.burba@mail.polimi.it
24357053388664e7112f09d19f6cf8349aefa46c
fc214bfc7caf6050eec8ec5201e7f7eb568e3a17
/Windows/Qt/Qt5.9-msvc2017/5.9/msvc2017/include/Qt3DRender/5.9.2/Qt3DRender/private/qcollisionqueryresult_p.h
c9d6e25e6fae60ced5897de3af963ecaa454df71
[]
no_license
MediaArea/MediaArea-Utils-Binaries
44402a1dacb43e19ef6857da46a48289b106137d
5cde31480dba6092e195dfae96478c261018bf32
refs/heads/master
2023-09-01T04:54:34.216269
2023-04-11T08:44:15
2023-04-11T08:44:15
57,366,211
4
1
null
2023-04-11T08:44:16
2016-04-29T07:51:36
C++
UTF-8
C++
false
false
5,283
h
/**************************************************************************** ** ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt3D module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QT3DRENDER_QCOLLISIONQUERYRESULT_P_H #define QT3DRENDER_QCOLLISIONQUERYRESULT_P_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists for the convenience // of other Qt classes. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include <Qt3DRender/qt3drender_global.h> #include <Qt3DCore/qnodeid.h> #include <QVector> #include <QVector3D> #include <QSharedData> QT_BEGIN_NAMESPACE namespace Qt3DRender { namespace RayCasting { typedef int QQueryHandle; class QCollisionQueryResultPrivate; class QT3DRENDERSHARED_EXPORT QCollisionQueryResult { public: struct Hit { Hit() : m_distance(-1.f) , m_triangleIndex(0) { m_vertexIndex[0] = m_vertexIndex[1] = m_vertexIndex[2] = 0; } Hit(Qt3DCore::QNodeId entity, const QVector3D &intersection, float distance, const QVector3D &uvw) : m_entityId(entity) , m_intersection(intersection) , m_distance(distance) , m_uvw(uvw) { } Qt3DCore::QNodeId m_entityId; QVector3D m_intersection; float m_distance; uint m_triangleIndex; uint m_vertexIndex[3]; QVector3D m_uvw; }; QCollisionQueryResult(); QCollisionQueryResult(const QCollisionQueryResult &); ~QCollisionQueryResult(); QCollisionQueryResult &operator=(const QCollisionQueryResult &); #ifdef Q_COMPILER_RVALUE_REFS QCollisionQueryResult &operator=(QCollisionQueryResult &&other) Q_DECL_NOTHROW { swap(other); return *this; } #endif void swap(QCollisionQueryResult &other) Q_DECL_NOTHROW { qSwap(d_ptr, other.d_ptr); } QQueryHandle handle() const; QVector<Hit> hits() const; QVector<Qt3DCore::QNodeId> entitiesHit() const; private: friend class QAbstractCollisionQueryService; explicit QCollisionQueryResult(QCollisionQueryResultPrivate &p); QSharedDataPointer<QCollisionQueryResultPrivate> d_ptr; // Q_DECLARE_PRIVATE equivalent for shared data pointers QCollisionQueryResultPrivate *d_func(); inline const QCollisionQueryResultPrivate *d_func() const { return d_ptr.constData(); } }; QT3D_DECLARE_TYPEINFO_2(Qt3DRender, RayCasting, QCollisionQueryResult::Hit, Q_PRIMITIVE_TYPE) QT3D_DECLARE_SHARED_2(Qt3DRender, RayCasting, QCollisionQueryResult) class QCollisionQueryResultPrivate : public QSharedData { public: explicit QCollisionQueryResultPrivate(); explicit QCollisionQueryResultPrivate(const QCollisionQueryResultPrivate &copy); void setHandle(const QQueryHandle &handle); void addEntityHit(Qt3DCore::QNodeId entity, const QVector3D& intersection, float distance, const QVector3D& uvw); QQueryHandle m_handle; QVector<QCollisionQueryResult::Hit> m_hits; }; inline bool operator==(const QCollisionQueryResult::Hit& left, const QCollisionQueryResult::Hit& right) { return left.m_entityId == right.m_entityId; } } // RayCasting } // Qt3DRender QT_END_NAMESPACE #endif // QT3DRENDER_QCOLLISIONQUERYRESULT_P_H
[ "you@example.com" ]
you@example.com
638428a02b15f080d81f55df4a13af302e24a949
3b9b4049a8e7d38b49e07bb752780b2f1d792851
/src/ui/views/win/hwnd_message_handler.cc
b035fd32716f75454a44aa5dd02b652a0c6dceba
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
webosce/chromium53
f8e745e91363586aee9620c609aacf15b3261540
9171447efcf0bb393d41d1dc877c7c13c46d8e38
refs/heads/webosce
2020-03-26T23:08:14.416858
2018-08-23T08:35:17
2018-09-20T14:25:18
145,513,343
0
2
Apache-2.0
2019-08-21T22:44:55
2018-08-21T05:52:31
null
UTF-8
C++
false
false
107,584
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 "ui/views/win/hwnd_message_handler.h" #include <dwmapi.h> #include <oleacc.h> #include <shellapi.h> #include <tchar.h> #include <utility> #include "base/bind.h" #include "base/bind_helpers.h" #include "base/debug/alias.h" #include "base/location.h" #include "base/macros.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "base/win/scoped_gdi_object.h" #include "base/win/windows_version.h" #include "ui/base/touch/touch_enabled.h" #include "ui/base/view_prop.h" #include "ui/base/win/internal_constants.h" #include "ui/base/win/lock_state.h" #include "ui/base/win/mouse_wheel_util.h" #include "ui/base/win/shell.h" #include "ui/base/win/touch_input.h" #include "ui/display/win/dpi.h" #include "ui/events/event.h" #include "ui/events/event_utils.h" #include "ui/events/keycodes/keyboard_code_conversion_win.h" #include "ui/events/win/system_event_state_lookup.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/insets.h" #include "ui/gfx/icon_util.h" #include "ui/gfx/path.h" #include "ui/gfx/path_win.h" #include "ui/gfx/win/direct_manipulation.h" #include "ui/gfx/win/hwnd_util.h" #include "ui/gfx/win/rendering_window_manager.h" #include "ui/native_theme/native_theme_win.h" #include "ui/views/views_delegate.h" #include "ui/views/widget/monitor_win.h" #include "ui/views/widget/widget_hwnd_utils.h" #include "ui/views/win/fullscreen_handler.h" #include "ui/views/win/hwnd_message_handler_delegate.h" #include "ui/views/win/scoped_fullscreen_visibility.h" #include "ui/views/win/windows_session_change_observer.h" namespace views { namespace { // MoveLoopMouseWatcher is used to determine if the user canceled or completed a // move. win32 doesn't appear to offer a way to determine the result of a move, // so we install hooks to determine if we got a mouse up and assume the move // completed. class MoveLoopMouseWatcher { public: MoveLoopMouseWatcher(HWNDMessageHandler* host, bool hide_on_escape); ~MoveLoopMouseWatcher(); // Returns true if the mouse is up, or if we couldn't install the hook. bool got_mouse_up() const { return got_mouse_up_; } private: // Instance that owns the hook. We only allow one instance to hook the mouse // at a time. static MoveLoopMouseWatcher* instance_; // Key and mouse callbacks from the hook. static LRESULT CALLBACK MouseHook(int n_code, WPARAM w_param, LPARAM l_param); static LRESULT CALLBACK KeyHook(int n_code, WPARAM w_param, LPARAM l_param); void Unhook(); // HWNDMessageHandler that created us. HWNDMessageHandler* host_; // Should the window be hidden when escape is pressed? const bool hide_on_escape_; // Did we get a mouse up? bool got_mouse_up_; // Hook identifiers. HHOOK mouse_hook_; HHOOK key_hook_; DISALLOW_COPY_AND_ASSIGN(MoveLoopMouseWatcher); }; // static MoveLoopMouseWatcher* MoveLoopMouseWatcher::instance_ = NULL; MoveLoopMouseWatcher::MoveLoopMouseWatcher(HWNDMessageHandler* host, bool hide_on_escape) : host_(host), hide_on_escape_(hide_on_escape), got_mouse_up_(false), mouse_hook_(NULL), key_hook_(NULL) { // Only one instance can be active at a time. if (instance_) instance_->Unhook(); mouse_hook_ = SetWindowsHookEx( WH_MOUSE, &MouseHook, NULL, GetCurrentThreadId()); if (mouse_hook_) { instance_ = this; // We don't care if setting the key hook succeeded. key_hook_ = SetWindowsHookEx( WH_KEYBOARD, &KeyHook, NULL, GetCurrentThreadId()); } if (instance_ != this) { // Failed installation. Assume we got a mouse up in this case, otherwise // we'll think all drags were canceled. got_mouse_up_ = true; } } MoveLoopMouseWatcher::~MoveLoopMouseWatcher() { Unhook(); } void MoveLoopMouseWatcher::Unhook() { if (instance_ != this) return; DCHECK(mouse_hook_); UnhookWindowsHookEx(mouse_hook_); if (key_hook_) UnhookWindowsHookEx(key_hook_); key_hook_ = NULL; mouse_hook_ = NULL; instance_ = NULL; } // static LRESULT CALLBACK MoveLoopMouseWatcher::MouseHook(int n_code, WPARAM w_param, LPARAM l_param) { DCHECK(instance_); if (n_code == HC_ACTION && w_param == WM_LBUTTONUP) instance_->got_mouse_up_ = true; return CallNextHookEx(instance_->mouse_hook_, n_code, w_param, l_param); } // static LRESULT CALLBACK MoveLoopMouseWatcher::KeyHook(int n_code, WPARAM w_param, LPARAM l_param) { if (n_code == HC_ACTION && w_param == VK_ESCAPE) { int value = TRUE; DwmSetWindowAttribute(instance_->host_->hwnd(), DWMWA_TRANSITIONS_FORCEDISABLED, &value, sizeof(value)); if (instance_->hide_on_escape_) instance_->host_->Hide(); } return CallNextHookEx(instance_->key_hook_, n_code, w_param, l_param); } // Called from OnNCActivate. BOOL CALLBACK EnumChildWindowsForRedraw(HWND hwnd, LPARAM lparam) { DWORD process_id; GetWindowThreadProcessId(hwnd, &process_id); int flags = RDW_INVALIDATE | RDW_NOCHILDREN | RDW_FRAME; if (process_id == GetCurrentProcessId()) flags |= RDW_UPDATENOW; RedrawWindow(hwnd, NULL, NULL, flags); return TRUE; } bool GetMonitorAndRects(const RECT& rect, HMONITOR* monitor, gfx::Rect* monitor_rect, gfx::Rect* work_area) { DCHECK(monitor); DCHECK(monitor_rect); DCHECK(work_area); *monitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONULL); if (!*monitor) return false; MONITORINFO monitor_info = { 0 }; monitor_info.cbSize = sizeof(monitor_info); GetMonitorInfo(*monitor, &monitor_info); *monitor_rect = gfx::Rect(monitor_info.rcMonitor); *work_area = gfx::Rect(monitor_info.rcWork); return true; } struct FindOwnedWindowsData { HWND window; std::vector<Widget*> owned_widgets; }; // Enables or disables the menu item for the specified command and menu. void EnableMenuItemByCommand(HMENU menu, UINT command, bool enabled) { UINT flags = MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED); EnableMenuItem(menu, command, flags); } // Callback used to notify child windows that the top level window received a // DWMCompositionChanged message. BOOL CALLBACK SendDwmCompositionChanged(HWND window, LPARAM param) { SendMessage(window, WM_DWMCOMPOSITIONCHANGED, 0, 0); return TRUE; } // The thickness of an auto-hide taskbar in pixels. const int kAutoHideTaskbarThicknessPx = 2; bool IsTopLevelWindow(HWND window) { long style = ::GetWindowLong(window, GWL_STYLE); if (!(style & WS_CHILD)) return true; HWND parent = ::GetParent(window); return !parent || (parent == ::GetDesktopWindow()); } void AddScrollStylesToWindow(HWND window) { if (::IsWindow(window)) { long current_style = ::GetWindowLong(window, GWL_STYLE); ::SetWindowLong(window, GWL_STYLE, current_style | WS_VSCROLL | WS_HSCROLL); } } const int kTouchDownContextResetTimeout = 500; // Windows does not flag synthesized mouse messages from touch in all cases. // This causes us grief as we don't want to process touch and mouse messages // concurrently. Hack as per msdn is to check if the time difference between // the touch message and the mouse move is within 500 ms and at the same // location as the cursor. const int kSynthesizedMouseTouchMessagesTimeDifference = 500; } // namespace // A scoping class that prevents a window from being able to redraw in response // to invalidations that may occur within it for the lifetime of the object. // // Why would we want such a thing? Well, it turns out Windows has some // "unorthodox" behavior when it comes to painting its non-client areas. // Occasionally, Windows will paint portions of the default non-client area // right over the top of the custom frame. This is not simply fixed by handling // WM_NCPAINT/WM_PAINT, with some investigation it turns out that this // rendering is being done *inside* the default implementation of some message // handlers and functions: // . WM_SETTEXT // . WM_SETICON // . WM_NCLBUTTONDOWN // . EnableMenuItem, called from our WM_INITMENU handler // The solution is to handle these messages and call DefWindowProc ourselves, // but prevent the window from being able to update itself for the duration of // the call. We do this with this class, which automatically calls its // associated Window's lock and unlock functions as it is created and destroyed. // See documentation in those methods for the technique used. // // The lock only has an effect if the window was visible upon lock creation, as // it doesn't guard against direct visiblility changes, and multiple locks may // exist simultaneously to handle certain nested Windows messages. // // IMPORTANT: Do not use this scoping object for large scopes or periods of // time! IT WILL PREVENT THE WINDOW FROM BEING REDRAWN! (duh). // // I would love to hear Raymond Chen's explanation for all this. And maybe a // list of other messages that this applies to ;-) class HWNDMessageHandler::ScopedRedrawLock { public: explicit ScopedRedrawLock(HWNDMessageHandler* owner) : owner_(owner), hwnd_(owner_->hwnd()), was_visible_(owner_->IsVisible()), cancel_unlock_(false), force_(!(GetWindowLong(hwnd_, GWL_STYLE) & WS_CAPTION)) { if (was_visible_ && ::IsWindow(hwnd_)) owner_->LockUpdates(force_); } ~ScopedRedrawLock() { if (!cancel_unlock_ && was_visible_ && ::IsWindow(hwnd_)) owner_->UnlockUpdates(force_); } // Cancel the unlock operation, call this if the Widget is being destroyed. void CancelUnlockOperation() { cancel_unlock_ = true; } private: // The owner having its style changed. HWNDMessageHandler* owner_; // The owner's HWND, cached to avoid action after window destruction. HWND hwnd_; // Records the HWND visibility at the time of creation. bool was_visible_; // A flag indicating that the unlock operation was canceled. bool cancel_unlock_; // If true, perform the redraw lock regardless of Aero state. bool force_; DISALLOW_COPY_AND_ASSIGN(ScopedRedrawLock); }; // static HWNDMessageHandler member initialization. base::LazyInstance<HWNDMessageHandler::FullscreenWindowMonitorMap> HWNDMessageHandler::fullscreen_monitor_map_ = LAZY_INSTANCE_INITIALIZER; //////////////////////////////////////////////////////////////////////////////// // HWNDMessageHandler, public: long HWNDMessageHandler::last_touch_message_time_ = 0; HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate) : msg_handled_(FALSE), delegate_(delegate), fullscreen_handler_(new FullscreenHandler), waiting_for_close_now_(false), use_system_default_icon_(false), restored_enabled_(false), current_cursor_(NULL), previous_cursor_(NULL), active_mouse_tracking_flags_(0), is_right_mouse_pressed_on_caption_(false), lock_updates_count_(0), ignore_window_pos_changes_(false), last_monitor_(NULL), is_first_nccalc_(true), menu_depth_(0), id_generator_(0), needs_scroll_styles_(false), in_size_loop_(false), touch_down_contexts_(0), last_mouse_hwheel_time_(0), dwm_transition_desired_(false), sent_window_size_changing_(false), left_button_down_on_caption_(false), background_fullscreen_hack_(false), autohide_factory_(this), weak_factory_(this) {} HWNDMessageHandler::~HWNDMessageHandler() { delegate_ = NULL; // Prevent calls back into this class via WNDPROC now that we've been // destroyed. ClearUserData(); } void HWNDMessageHandler::Init(HWND parent, const gfx::Rect& bounds) { TRACE_EVENT0("views", "HWNDMessageHandler::Init"); GetMonitorAndRects(bounds.ToRECT(), &last_monitor_, &last_monitor_rect_, &last_work_area_); // Create the window. WindowImpl::Init(parent, bounds); // TODO(ananta) // Remove the scrolling hack code once we have scrolling working well. #if defined(ENABLE_SCROLL_HACK) // Certain trackpad drivers on Windows have bugs where in they don't generate // WM_MOUSEWHEEL messages for the trackpoint and trackpad scrolling gestures // unless there is an entry for Chrome with the class name of the Window. // These drivers check if the window under the trackpoint has the WS_VSCROLL/ // WS_HSCROLL style and if yes they generate the legacy WM_VSCROLL/WM_HSCROLL // messages. We add these styles to ensure that trackpad/trackpoint scrolling // work. // TODO(ananta) // Look into moving the WS_VSCROLL and WS_HSCROLL style setting logic to the // CalculateWindowStylesFromInitParams function. Doing it there seems to // cause some interactive tests to fail. Investigation needed. if (IsTopLevelWindow(hwnd())) { long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); if (!(current_style & WS_POPUP)) { AddScrollStylesToWindow(hwnd()); needs_scroll_styles_ = true; } } #endif prop_window_target_.reset(new ui::ViewProp(hwnd(), ui::WindowEventTarget::kWin32InputEventTarget, static_cast<ui::WindowEventTarget*>(this))); // Direct Manipulation is enabled on Windows 10+. The CreateInstance function // returns NULL if Direct Manipulation is not available. direct_manipulation_helper_ = gfx::win::DirectManipulationHelper::CreateInstance(); if (direct_manipulation_helper_) direct_manipulation_helper_->Initialize(hwnd()); // Disable pen flicks (http://crbug.com/506977) base::win::DisableFlicks(hwnd()); } void HWNDMessageHandler::InitModalType(ui::ModalType modal_type) { if (modal_type == ui::MODAL_TYPE_NONE) return; // We implement modality by crawling up the hierarchy of windows starting // at the owner, disabling all of them so that they don't receive input // messages. HWND start = ::GetWindow(hwnd(), GW_OWNER); while (start) { ::EnableWindow(start, FALSE); start = ::GetParent(start); } } void HWNDMessageHandler::Close() { if (!IsWindow(hwnd())) return; // No need to do anything. // Let's hide ourselves right away. Hide(); // Modal dialog windows disable their owner windows; re-enable them now so // they can activate as foreground windows upon this window's destruction. RestoreEnabledIfNecessary(); // Re-enable flicks which removes the window property. base::win::EnableFlicks(hwnd()); if (!waiting_for_close_now_) { // And we delay the close so that if we are called from an ATL callback, // we don't destroy the window before the callback returned (as the caller // may delete ourselves on destroy and the ATL callback would still // dereference us when the callback returns). waiting_for_close_now_ = true; base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&HWNDMessageHandler::CloseNow, weak_factory_.GetWeakPtr())); } } void HWNDMessageHandler::CloseNow() { // We may already have been destroyed if the selection resulted in a tab // switch which will have reactivated the browser window and closed us, so // we need to check to see if we're still a window before trying to destroy // ourself. waiting_for_close_now_ = false; if (IsWindow(hwnd())) DestroyWindow(hwnd()); } gfx::Rect HWNDMessageHandler::GetWindowBoundsInScreen() const { RECT r; GetWindowRect(hwnd(), &r); return gfx::Rect(r); } gfx::Rect HWNDMessageHandler::GetClientAreaBoundsInScreen() const { RECT r; GetClientRect(hwnd(), &r); POINT point = { r.left, r.top }; ClientToScreen(hwnd(), &point); return gfx::Rect(point.x, point.y, r.right - r.left, r.bottom - r.top); } gfx::Rect HWNDMessageHandler::GetRestoredBounds() const { // If we're in fullscreen mode, we've changed the normal bounds to the monitor // rect, so return the saved bounds instead. if (IsFullscreen()) return fullscreen_handler_->GetRestoreBounds(); gfx::Rect bounds; GetWindowPlacement(&bounds, NULL); return bounds; } gfx::Rect HWNDMessageHandler::GetClientAreaBounds() const { if (IsMinimized()) return gfx::Rect(); if (delegate_->WidgetSizeIsClientSize()) return GetClientAreaBoundsInScreen(); return GetWindowBoundsInScreen(); } void HWNDMessageHandler::GetWindowPlacement( gfx::Rect* bounds, ui::WindowShowState* show_state) const { WINDOWPLACEMENT wp; wp.length = sizeof(wp); const bool succeeded = !!::GetWindowPlacement(hwnd(), &wp); DCHECK(succeeded); if (bounds != NULL) { if (wp.showCmd == SW_SHOWNORMAL) { // GetWindowPlacement can return misleading position if a normalized // window was resized using Aero Snap feature (see comment 9 in bug // 36421). As a workaround, using GetWindowRect for normalized windows. const bool succeeded = GetWindowRect(hwnd(), &wp.rcNormalPosition) != 0; DCHECK(succeeded); *bounds = gfx::Rect(wp.rcNormalPosition); } else { MONITORINFO mi; mi.cbSize = sizeof(mi); const bool succeeded = GetMonitorInfo( MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST), &mi) != 0; DCHECK(succeeded); *bounds = gfx::Rect(wp.rcNormalPosition); // Convert normal position from workarea coordinates to screen // coordinates. bounds->Offset(mi.rcWork.left - mi.rcMonitor.left, mi.rcWork.top - mi.rcMonitor.top); } } if (show_state) { if (wp.showCmd == SW_SHOWMAXIMIZED) *show_state = ui::SHOW_STATE_MAXIMIZED; else if (wp.showCmd == SW_SHOWMINIMIZED) *show_state = ui::SHOW_STATE_MINIMIZED; else *show_state = ui::SHOW_STATE_NORMAL; } } void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds_in_pixels, bool force_size_changed) { background_fullscreen_hack_ = false; SetBoundsInternal(bounds_in_pixels, force_size_changed); } void HWNDMessageHandler::SetDwmFrameExtension(DwmFrameState state) { if (!delegate_->HasFrame() && ui::win::IsAeroGlassEnabled() && (window_ex_style() & WS_EX_COMPOSITED) == 0) { MARGINS m = {0, 0, 0, 0}; if (state == DwmFrameState::ON) m = {0, 0, 1, 0}; DwmExtendFrameIntoClientArea(hwnd(), &m); } } void HWNDMessageHandler::SetSize(const gfx::Size& size) { SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); } void HWNDMessageHandler::CenterWindow(const gfx::Size& size) { HWND parent = GetParent(hwnd()); if (!IsWindow(hwnd())) parent = ::GetWindow(hwnd(), GW_OWNER); gfx::CenterAndSizeWindow(parent, hwnd(), size); } void HWNDMessageHandler::SetRegion(HRGN region) { custom_window_region_.reset(region); ResetWindowRegion(true, true); } void HWNDMessageHandler::StackAbove(HWND other_hwnd) { // Windows API allows to stack behind another windows only. DCHECK(other_hwnd); HWND next_window = GetNextWindow(other_hwnd, GW_HWNDPREV); SetWindowPos(hwnd(), next_window ? next_window : HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); } void HWNDMessageHandler::StackAtTop() { SetWindowPos(hwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); } void HWNDMessageHandler::Show() { if (IsWindow(hwnd())) { if (!(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_TRANSPARENT) && !(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE)) { ShowWindowWithState(ui::SHOW_STATE_NORMAL); } else { ShowWindowWithState(ui::SHOW_STATE_INACTIVE); } } if (direct_manipulation_helper_) direct_manipulation_helper_->Activate(hwnd()); } void HWNDMessageHandler::ShowWindowWithState(ui::WindowShowState show_state) { TRACE_EVENT0("views", "HWNDMessageHandler::ShowWindowWithState"); DWORD native_show_state; switch (show_state) { case ui::SHOW_STATE_INACTIVE: native_show_state = SW_SHOWNOACTIVATE; break; case ui::SHOW_STATE_MAXIMIZED: native_show_state = SW_SHOWMAXIMIZED; break; case ui::SHOW_STATE_MINIMIZED: native_show_state = SW_SHOWMINIMIZED; break; case ui::SHOW_STATE_NORMAL: native_show_state = SW_SHOWNORMAL; break; case ui::SHOW_STATE_FULLSCREEN: native_show_state = SW_SHOWNORMAL; SetFullscreen(true); break; default: native_show_state = delegate_->GetInitialShowState(); break; } ShowWindow(hwnd(), native_show_state); // When launched from certain programs like bash and Windows Live Messenger, // show_state is set to SW_HIDE, so we need to correct that condition. We // don't just change show_state to SW_SHOWNORMAL because MSDN says we must // always first call ShowWindow with the specified value from STARTUPINFO, // otherwise all future ShowWindow calls will be ignored (!!#@@#!). Instead, // we call ShowWindow again in this case. if (native_show_state == SW_HIDE) { native_show_state = SW_SHOWNORMAL; ShowWindow(hwnd(), native_show_state); } // We need to explicitly activate the window if we've been shown with a state // that should activate, because if we're opened from a desktop shortcut while // an existing window is already running it doesn't seem to be enough to use // one of these flags to activate the window. if (native_show_state == SW_SHOWNORMAL || native_show_state == SW_SHOWMAXIMIZED) Activate(); if (!delegate_->HandleInitialFocus(show_state)) SetInitialFocus(); } void HWNDMessageHandler::ShowMaximizedWithBounds(const gfx::Rect& bounds) { WINDOWPLACEMENT placement = { 0 }; placement.length = sizeof(WINDOWPLACEMENT); placement.showCmd = SW_SHOWMAXIMIZED; placement.rcNormalPosition = bounds.ToRECT(); SetWindowPlacement(hwnd(), &placement); // We need to explicitly activate the window, because if we're opened from a // desktop shortcut while an existing window is already running it doesn't // seem to be enough to use SW_SHOWMAXIMIZED to activate the window. Activate(); } void HWNDMessageHandler::Hide() { if (IsWindow(hwnd())) { // NOTE: Be careful not to activate any windows here (for example, calling // ShowWindow(SW_HIDE) will automatically activate another window). This // code can be called while a window is being deactivated, and activating // another window will screw up the activation that is already in progress. SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER); } } void HWNDMessageHandler::Maximize() { ExecuteSystemMenuCommand(SC_MAXIMIZE); } void HWNDMessageHandler::Minimize() { ExecuteSystemMenuCommand(SC_MINIMIZE); delegate_->HandleNativeBlur(NULL); } void HWNDMessageHandler::Restore() { ExecuteSystemMenuCommand(SC_RESTORE); } void HWNDMessageHandler::Activate() { if (IsMinimized()) ::ShowWindow(hwnd(), SW_RESTORE); ::SetWindowPos(hwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); SetForegroundWindow(hwnd()); } void HWNDMessageHandler::Deactivate() { HWND next_hwnd = ::GetNextWindow(hwnd(), GW_HWNDNEXT); while (next_hwnd) { if (::IsWindowVisible(next_hwnd)) { ::SetForegroundWindow(next_hwnd); return; } next_hwnd = ::GetNextWindow(next_hwnd, GW_HWNDNEXT); } } void HWNDMessageHandler::SetAlwaysOnTop(bool on_top) { ::SetWindowPos(hwnd(), on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); } bool HWNDMessageHandler::IsVisible() const { return !!::IsWindowVisible(hwnd()); } bool HWNDMessageHandler::IsActive() const { return GetActiveWindow() == hwnd(); } bool HWNDMessageHandler::IsMinimized() const { return !!::IsIconic(hwnd()); } bool HWNDMessageHandler::IsMaximized() const { return !!::IsZoomed(hwnd()) && !IsFullscreen(); } bool HWNDMessageHandler::IsFullscreen() const { return fullscreen_handler_->fullscreen(); } bool HWNDMessageHandler::IsAlwaysOnTop() const { return (GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_TOPMOST) != 0; } bool HWNDMessageHandler::RunMoveLoop(const gfx::Vector2d& drag_offset, bool hide_on_escape) { ReleaseCapture(); MoveLoopMouseWatcher watcher(this, hide_on_escape); // In Aura, we handle touch events asynchronously. So we need to allow nested // tasks while in windows move loop. base::MessageLoop::ScopedNestableTaskAllower allow_nested( base::MessageLoop::current()); SendMessage(hwnd(), WM_SYSCOMMAND, SC_MOVE | 0x0002, GetMessagePos()); // Windows doesn't appear to offer a way to determine whether the user // canceled the move or not. We assume if the user released the mouse it was // successful. return watcher.got_mouse_up(); } void HWNDMessageHandler::EndMoveLoop() { SendMessage(hwnd(), WM_CANCELMODE, 0, 0); } void HWNDMessageHandler::SendFrameChanged() { SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREPOSITION | SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOZORDER); } void HWNDMessageHandler::FlashFrame(bool flash) { FLASHWINFO fwi; fwi.cbSize = sizeof(fwi); fwi.hwnd = hwnd(); if (flash) { fwi.dwFlags = custom_window_region_.is_valid() ? FLASHW_TRAY : FLASHW_ALL; fwi.uCount = 4; fwi.dwTimeout = 0; } else { fwi.dwFlags = FLASHW_STOP; } FlashWindowEx(&fwi); } void HWNDMessageHandler::ClearNativeFocus() { ::SetFocus(hwnd()); } void HWNDMessageHandler::SetCapture() { DCHECK(!HasCapture()); ::SetCapture(hwnd()); } void HWNDMessageHandler::ReleaseCapture() { if (HasCapture()) ::ReleaseCapture(); } bool HWNDMessageHandler::HasCapture() const { return ::GetCapture() == hwnd(); } void HWNDMessageHandler::SetVisibilityChangedAnimationsEnabled(bool enabled) { int dwm_value = enabled ? FALSE : TRUE; DwmSetWindowAttribute(hwnd(), DWMWA_TRANSITIONS_FORCEDISABLED, &dwm_value, sizeof(dwm_value)); } bool HWNDMessageHandler::SetTitle(const base::string16& title) { base::string16 current_title; size_t len_with_null = GetWindowTextLength(hwnd()) + 1; if (len_with_null == 1 && title.length() == 0) return false; if (len_with_null - 1 == title.length() && GetWindowText(hwnd(), base::WriteInto(&current_title, len_with_null), len_with_null) && current_title == title) return false; SetWindowText(hwnd(), title.c_str()); return true; } void HWNDMessageHandler::SetCursor(HCURSOR cursor) { if (cursor) { previous_cursor_ = ::SetCursor(cursor); current_cursor_ = cursor; } else if (previous_cursor_) { ::SetCursor(previous_cursor_); previous_cursor_ = NULL; } } void HWNDMessageHandler::FrameTypeChanged() { if (!custom_window_region_.is_valid() && delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN) dwm_transition_desired_ = true; if (!dwm_transition_desired_ || !IsFullscreen()) PerformDwmTransition(); } void HWNDMessageHandler::SetWindowIcons(const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) { if (!window_icon.isNull()) { base::win::ScopedHICON previous_icon = std::move(window_icon_); window_icon_ = IconUtil::CreateHICONFromSkBitmap(*window_icon.bitmap()); SendMessage(hwnd(), WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(window_icon_.get())); } if (!app_icon.isNull()) { base::win::ScopedHICON previous_icon = std::move(app_icon_); app_icon_ = IconUtil::CreateHICONFromSkBitmap(*app_icon.bitmap()); SendMessage(hwnd(), WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(app_icon_.get())); } } void HWNDMessageHandler::SetFullscreen(bool fullscreen) { background_fullscreen_hack_ = false; fullscreen_handler()->SetFullscreen(fullscreen); // If we are out of fullscreen and there was a pending DWM transition for the // window, then go ahead and do it now. if (!fullscreen && dwm_transition_desired_) PerformDwmTransition(); // Add the fullscreen window to the fullscreen window map which is used to // handle window activations. HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY); if (fullscreen) { (fullscreen_monitor_map_.Get())[monitor] = this; } else { FullscreenWindowMonitorMap::iterator iter = fullscreen_monitor_map_.Get().find(monitor); if (iter != fullscreen_monitor_map_.Get().end()) fullscreen_monitor_map_.Get().erase(iter); } } void HWNDMessageHandler::SizeConstraintsChanged() { LONG style = GetWindowLong(hwnd(), GWL_STYLE); // Ignore if this is not a standard window. if (style & (WS_POPUP | WS_CHILD)) return; LONG exstyle = GetWindowLong(hwnd(), GWL_EXSTYLE); // Windows cannot have WS_THICKFRAME set if WS_EX_COMPOSITED is set. // See CalculateWindowStylesFromInitParams(). if (delegate_->CanResize() && (exstyle & WS_EX_COMPOSITED) == 0) { style |= WS_THICKFRAME | WS_MAXIMIZEBOX; if (!delegate_->CanMaximize()) style &= ~WS_MAXIMIZEBOX; } else { style &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX); } if (delegate_->CanMinimize()) { style |= WS_MINIMIZEBOX; } else { style &= ~WS_MINIMIZEBOX; } SetWindowLong(hwnd(), GWL_STYLE, style); } bool HWNDMessageHandler::HasChildRenderingWindow() { // This can change dynamically if the system switches between GPU and // software rendering. return gfx::RenderingWindowManager::GetInstance()->HasValidChildWindow( hwnd()); } //////////////////////////////////////////////////////////////////////////////// // HWNDMessageHandler, gfx::WindowImpl overrides: HICON HWNDMessageHandler::GetDefaultWindowIcon() const { if (use_system_default_icon_) return nullptr; return ViewsDelegate::GetInstance() ? ViewsDelegate::GetInstance()->GetDefaultWindowIcon() : nullptr; } HICON HWNDMessageHandler::GetSmallWindowIcon() const { if (use_system_default_icon_) return nullptr; return ViewsDelegate::GetInstance() ? ViewsDelegate::GetInstance()->GetSmallWindowIcon() : nullptr; } LRESULT HWNDMessageHandler::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { HWND window = hwnd(); LRESULT result = 0; if (delegate_ && delegate_->PreHandleMSG(message, w_param, l_param, &result)) return result; // Otherwise we handle everything else. // NOTE: We inline ProcessWindowMessage() as 'this' may be destroyed during // dispatch and ProcessWindowMessage() doesn't deal with that well. const BOOL old_msg_handled = msg_handled_; base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); const BOOL processed = _ProcessWindowMessage(window, message, w_param, l_param, result, 0); if (!ref) return 0; msg_handled_ = old_msg_handled; if (!processed) { result = DefWindowProc(window, message, w_param, l_param); // DefWindowProc() may have destroyed the window and/or us in a nested // message loop. if (!ref || !::IsWindow(window)) return result; } if (delegate_) { delegate_->PostHandleMSG(message, w_param, l_param); if (message == WM_NCDESTROY) { RestoreEnabledIfNecessary(); delegate_->HandleDestroyed(); } } if (message == WM_ACTIVATE && IsTopLevelWindow(window)) PostProcessActivateMessage(LOWORD(w_param), !!HIWORD(w_param), reinterpret_cast<HWND>(l_param)); return result; } LRESULT HWNDMessageHandler::HandleMouseMessage(unsigned int message, WPARAM w_param, LPARAM l_param, bool* handled) { // Don't track forwarded mouse messages. We expect the caller to track the // mouse. base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); LRESULT ret = HandleMouseEventInternal(message, w_param, l_param, false); *handled = IsMsgHandled(); return ret; } LRESULT HWNDMessageHandler::HandleKeyboardMessage(unsigned int message, WPARAM w_param, LPARAM l_param, bool* handled) { base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); LRESULT ret = 0; if ((message == WM_CHAR) || (message == WM_SYSCHAR)) ret = OnImeMessages(message, w_param, l_param); else ret = OnKeyEvent(message, w_param, l_param); *handled = IsMsgHandled(); return ret; } LRESULT HWNDMessageHandler::HandleTouchMessage(unsigned int message, WPARAM w_param, LPARAM l_param, bool* handled) { base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); LRESULT ret = OnTouchEvent(message, w_param, l_param); *handled = IsMsgHandled(); return ret; } LRESULT HWNDMessageHandler::HandleScrollMessage(unsigned int message, WPARAM w_param, LPARAM l_param, bool* handled) { base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); LRESULT ret = OnScrollMessage(message, w_param, l_param); *handled = IsMsgHandled(); return ret; } LRESULT HWNDMessageHandler::HandleNcHitTestMessage(unsigned int message, WPARAM w_param, LPARAM l_param, bool* handled) { base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); LRESULT ret = OnNCHitTest( gfx::Point(CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param))); *handled = IsMsgHandled(); return ret; } void HWNDMessageHandler::HandleParentChanged() { // If the forwarder window's parent is changed then we need to reset our // context as we will not receive touch releases if the touch was initiated // in the forwarder window. touch_ids_.clear(); } //////////////////////////////////////////////////////////////////////////////// // HWNDMessageHandler, private: int HWNDMessageHandler::GetAppbarAutohideEdges(HMONITOR monitor) { autohide_factory_.InvalidateWeakPtrs(); return ViewsDelegate::GetInstance() ? ViewsDelegate::GetInstance()->GetAppbarAutohideEdges( monitor, base::Bind(&HWNDMessageHandler::OnAppbarAutohideEdgesChanged, autohide_factory_.GetWeakPtr())) : ViewsDelegate::EDGE_BOTTOM; } void HWNDMessageHandler::OnAppbarAutohideEdgesChanged() { // This triggers querying WM_NCCALCSIZE again. RECT client; GetWindowRect(hwnd(), &client); SetWindowPos(hwnd(), NULL, client.left, client.top, client.right - client.left, client.bottom - client.top, SWP_FRAMECHANGED); } void HWNDMessageHandler::SetInitialFocus() { if (!(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_TRANSPARENT) && !(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE)) { // The window does not get keyboard messages unless we focus it. SetFocus(hwnd()); } } void HWNDMessageHandler::PostProcessActivateMessage( int activation_state, bool minimized, HWND window_gaining_or_losing_activation) { DCHECK(IsTopLevelWindow(hwnd())); const bool active = activation_state != WA_INACTIVE && !minimized; if (delegate_->CanActivate()) delegate_->HandleActivationChanged(active); if (!::IsWindow(window_gaining_or_losing_activation)) window_gaining_or_losing_activation = ::GetForegroundWindow(); // If the window losing activation is a fullscreen window, we reduce the size // of the window by 1px. i.e. Not fullscreen. This is to work around an // apparent bug in the Windows taskbar where in it tracks fullscreen state on // a per thread basis. This causes it not be a topmost window when any // maximized window on a thread which has a fullscreen window is active. This // affects the way these windows interact with the taskbar, they obscure it // when maximized, autohide does not work correctly, etc. // By reducing the size of the fullscreen window by 1px, we ensure that the // taskbar no longer treats the window and in turn the thread as a fullscreen // thread. This in turn ensures that maximized windows on the same thread // don't obscure the taskbar, etc. // Please note that this taskbar behavior only occurs if the window becoming // active is on the same monitor as the fullscreen window. if (!active) { if (IsFullscreen() && ::IsWindow(window_gaining_or_losing_activation)) { HMONITOR active_window_monitor = MonitorFromWindow( window_gaining_or_losing_activation, MONITOR_DEFAULTTOPRIMARY); HMONITOR fullscreen_window_monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY); if (active_window_monitor == fullscreen_window_monitor) OnBackgroundFullscreen(); } } else if (background_fullscreen_hack_) { // Restore the bounds of the window to fullscreen. DCHECK(IsFullscreen()); MONITORINFO monitor_info = {sizeof(monitor_info)}; GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), &monitor_info); SetBoundsInternal(gfx::Rect(monitor_info.rcMonitor), false); background_fullscreen_hack_ = false; } else { // If the window becoming active has a fullscreen window on the same // monitor then we need to reduce the size of the fullscreen window by // 1 px. Please refer to the comments above for the reasoning behind // this. CheckAndHandleBackgroundFullscreenOnMonitor( window_gaining_or_losing_activation); } } void HWNDMessageHandler::RestoreEnabledIfNecessary() { if (delegate_->IsModal() && !restored_enabled_) { restored_enabled_ = true; // If we were run modally, we need to undo the disabled-ness we inflicted on // the owner's parent hierarchy. HWND start = ::GetWindow(hwnd(), GW_OWNER); while (start) { ::EnableWindow(start, TRUE); start = ::GetParent(start); } } } void HWNDMessageHandler::ExecuteSystemMenuCommand(int command) { if (command) SendMessage(hwnd(), WM_SYSCOMMAND, command, 0); } void HWNDMessageHandler::TrackMouseEvents(DWORD mouse_tracking_flags) { // Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE // when the user moves the mouse outside this HWND's bounds. if (active_mouse_tracking_flags_ == 0 || mouse_tracking_flags & TME_CANCEL) { if (mouse_tracking_flags & TME_CANCEL) { // We're about to cancel active mouse tracking, so empty out the stored // state. active_mouse_tracking_flags_ = 0; } else { active_mouse_tracking_flags_ = mouse_tracking_flags; } TRACKMOUSEEVENT tme; tme.cbSize = sizeof(tme); tme.dwFlags = mouse_tracking_flags; tme.hwndTrack = hwnd(); tme.dwHoverTime = 0; TrackMouseEvent(&tme); } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); TrackMouseEvents(mouse_tracking_flags); } } void HWNDMessageHandler::ClientAreaSizeChanged() { // Ignore size changes due to fullscreen windows losing activation. if (background_fullscreen_hack_ && !sent_window_size_changing_) return; gfx::Size s = GetClientAreaBounds().size(); delegate_->HandleClientSizeChanged(s); } bool HWNDMessageHandler::GetClientAreaInsets(gfx::Insets* insets) const { if (delegate_->GetClientAreaInsets(insets)) return true; DCHECK(insets->IsEmpty()); // Returning false causes the default handling in OnNCCalcSize() to // be invoked. if (!delegate_->HasNonClientView() || HasSystemFrame()) return false; if (IsMaximized()) { // Windows automatically adds a standard width border to all sides when a // window is maximized. int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); if (!delegate_->HasFrame()) border_thickness -= 1; *insets = gfx::Insets( border_thickness, border_thickness, border_thickness, border_thickness); return true; } *insets = gfx::Insets(); return true; } void HWNDMessageHandler::ResetWindowRegion(bool force, bool redraw) { // A native frame uses the native window region, and we don't want to mess // with it. // WS_EX_COMPOSITED is used instead of WS_EX_LAYERED under aura. WS_EX_LAYERED // automatically makes clicks on transparent pixels fall through, that isn't // the case with WS_EX_COMPOSITED. So, we route WS_EX_COMPOSITED through to // the delegate to allow for a custom hit mask. if ((window_ex_style() & WS_EX_COMPOSITED) == 0 && !custom_window_region_.is_valid() && (delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN || !delegate_->HasNonClientView())) { if (force) SetWindowRgn(hwnd(), NULL, redraw); return; } // Changing the window region is going to force a paint. Only change the // window region if the region really differs. base::win::ScopedRegion current_rgn(CreateRectRgn(0, 0, 0, 0)); GetWindowRgn(hwnd(), current_rgn.get()); RECT window_rect; GetWindowRect(hwnd(), &window_rect); base::win::ScopedRegion new_region; if (custom_window_region_.is_valid()) { new_region.reset(CreateRectRgn(0, 0, 0, 0)); CombineRgn(new_region.get(), custom_window_region_.get(), NULL, RGN_COPY); } else if (IsMaximized()) { HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST); MONITORINFO mi; mi.cbSize = sizeof mi; GetMonitorInfo(monitor, &mi); RECT work_rect = mi.rcWork; OffsetRect(&work_rect, -window_rect.left, -window_rect.top); new_region.reset(CreateRectRgnIndirect(&work_rect)); } else { gfx::Path window_mask; delegate_->GetWindowMask(gfx::Size(window_rect.right - window_rect.left, window_rect.bottom - window_rect.top), &window_mask); if (!window_mask.isEmpty()) new_region.reset(gfx::CreateHRGNFromSkPath(window_mask)); } const bool has_current_region = current_rgn != 0; const bool has_new_region = new_region != 0; if (has_current_region != has_new_region || (has_current_region && !EqualRgn(current_rgn.get(), new_region.get()))) { // SetWindowRgn takes ownership of the HRGN. SetWindowRgn(hwnd(), new_region.release(), redraw); } } void HWNDMessageHandler::UpdateDwmNcRenderingPolicy() { if (IsFullscreen()) return; DWMNCRENDERINGPOLICY policy = custom_window_region_.is_valid() || delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN ? DWMNCRP_DISABLED : DWMNCRP_ENABLED; DwmSetWindowAttribute(hwnd(), DWMWA_NCRENDERING_POLICY, &policy, sizeof(DWMNCRENDERINGPOLICY)); } LRESULT HWNDMessageHandler::DefWindowProcWithRedrawLock(UINT message, WPARAM w_param, LPARAM l_param) { ScopedRedrawLock lock(this); // The Widget and HWND can be destroyed in the call to DefWindowProc, so use // the WeakPtrFactory to avoid unlocking (and crashing) after destruction. base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); LRESULT result = DefWindowProc(hwnd(), message, w_param, l_param); if (!ref) lock.CancelUnlockOperation(); return result; } void HWNDMessageHandler::LockUpdates(bool force) { // We skip locked updates when Aero is on for two reasons: // 1. Because it isn't necessary // 2. Because toggling the WS_VISIBLE flag may occur while the GPU process is // attempting to present a child window's backbuffer onscreen. When these // two actions race with one another, the child window will either flicker // or will simply stop updating entirely. if ((force || !ui::win::IsAeroGlassEnabled()) && ++lock_updates_count_ == 1) { SetWindowLong(hwnd(), GWL_STYLE, GetWindowLong(hwnd(), GWL_STYLE) & ~WS_VISIBLE); } } void HWNDMessageHandler::UnlockUpdates(bool force) { if ((force || !ui::win::IsAeroGlassEnabled()) && --lock_updates_count_ <= 0) { SetWindowLong(hwnd(), GWL_STYLE, GetWindowLong(hwnd(), GWL_STYLE) | WS_VISIBLE); lock_updates_count_ = 0; } } void HWNDMessageHandler::ForceRedrawWindow(int attempts) { if (ui::IsWorkstationLocked()) { // Presents will continue to fail as long as the input desktop is // unavailable. if (--attempts <= 0) return; base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&HWNDMessageHandler::ForceRedrawWindow, weak_factory_.GetWeakPtr(), attempts), base::TimeDelta::FromMilliseconds(500)); return; } InvalidateRect(hwnd(), NULL, FALSE); } bool HWNDMessageHandler::HasSystemFrame() const { return delegate_->HasFrame() && delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN; } // Message handlers ------------------------------------------------------------ void HWNDMessageHandler::OnActivateApp(BOOL active, DWORD thread_id) { if (delegate_->HasNonClientView() && !active && thread_id != GetCurrentThreadId()) { delegate_->HandleAppDeactivated(); // Also update the native frame if it is rendering the non-client area. if (HasSystemFrame()) DefWindowProcWithRedrawLock(WM_NCACTIVATE, FALSE, 0); } } BOOL HWNDMessageHandler::OnAppCommand(HWND window, short command, WORD device, int keystate) { BOOL handled = !!delegate_->HandleAppCommand(command); SetMsgHandled(handled); // Make sure to return TRUE if the event was handled or in some cases the // system will execute the default handler which can cause bugs like going // forward or back two pages instead of one. return handled; } void HWNDMessageHandler::OnCancelMode() { delegate_->HandleCancelMode(); // Need default handling, otherwise capture and other things aren't canceled. SetMsgHandled(FALSE); } void HWNDMessageHandler::OnCaptureChanged(HWND window) { delegate_->HandleCaptureLost(); } void HWNDMessageHandler::OnClose() { delegate_->HandleClose(); } void HWNDMessageHandler::OnCommand(UINT notification_code, int command, HWND window) { // If the notification code is > 1 it means it is control specific and we // should ignore it. if (notification_code > 1 || delegate_->HandleAppCommand(command)) SetMsgHandled(FALSE); } LRESULT HWNDMessageHandler::OnCreate(CREATESTRUCT* create_struct) { if (window_ex_style() & WS_EX_COMPOSITED) { // This is part of the magic to emulate layered windows with Aura // see the explanation elsewere when we set WS_EX_COMPOSITED style. MARGINS margins = {-1, -1, -1, -1}; DwmExtendFrameIntoClientArea(hwnd(), &margins); } fullscreen_handler_->set_hwnd(hwnd()); // This message initializes the window so that focus border are shown for // windows. SendMessage(hwnd(), WM_CHANGEUISTATE, MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0); if (!delegate_->HasFrame()) { SetWindowLong(hwnd(), GWL_STYLE, GetWindowLong(hwnd(), GWL_STYLE) & ~WS_CAPTION); SendFrameChanged(); } // Get access to a modifiable copy of the system menu. GetSystemMenu(hwnd(), false); if (ui::AreTouchEventsEnabled()) RegisterTouchWindow(hwnd(), TWF_WANTPALM); // We need to allow the delegate to size its contents since the window may not // receive a size notification when its initial bounds are specified at window // creation time. ClientAreaSizeChanged(); delegate_->HandleCreate(); windows_session_change_observer_.reset(new WindowsSessionChangeObserver( base::Bind(&HWNDMessageHandler::OnSessionChange, base::Unretained(this)))); // TODO(beng): move more of NWW::OnCreate here. return 0; } void HWNDMessageHandler::OnDestroy() { windows_session_change_observer_.reset(nullptr); delegate_->HandleDestroying(); // If the window going away is a fullscreen window then remove its references // from the full screen window map. for (auto iter = fullscreen_monitor_map_.Get().begin(); iter != fullscreen_monitor_map_.Get().end(); iter++) { if (iter->second == this) { fullscreen_monitor_map_.Get().erase(iter); break; } } } void HWNDMessageHandler::OnDisplayChange(UINT bits_per_pixel, const gfx::Size& screen_size) { delegate_->HandleDisplayChange(); // Force a WM_NCCALCSIZE to occur to ensure that we handle auto hide // taskbars correctly. SendFrameChanged(); } LRESULT HWNDMessageHandler::OnDwmCompositionChanged(UINT msg, WPARAM w_param, LPARAM l_param) { if (!delegate_->HasNonClientView()) { SetMsgHandled(FALSE); return 0; } FrameTypeChanged(); return 0; } LRESULT HWNDMessageHandler::OnDpiChanged(UINT msg, WPARAM w_param, LPARAM l_param) { if (LOWORD(w_param) != HIWORD(w_param)) NOTIMPLEMENTED() << "Received non-square scaling factors"; SetBoundsInternal(gfx::Rect(*reinterpret_cast<RECT*>(l_param)), false); delegate_->HandleWindowScaleFactorChanged( display::win::GetScalingFactorFromDPI(LOWORD(w_param))); return 0; } void HWNDMessageHandler::OnEnterMenuLoop(BOOL from_track_popup_menu) { if (menu_depth_++ == 0) delegate_->HandleMenuLoop(true); } void HWNDMessageHandler::OnEnterSizeMove() { // Please refer to the comments in the OnSize function about the scrollbar // hack. // Hide the Windows scrollbar if the scroll styles are present to ensure // that a paint flicker does not occur while sizing. if (in_size_loop_ && needs_scroll_styles_) ShowScrollBar(hwnd(), SB_BOTH, FALSE); delegate_->HandleBeginWMSizeMove(); SetMsgHandled(FALSE); } LRESULT HWNDMessageHandler::OnEraseBkgnd(HDC dc) { // Needed to prevent resize flicker. return 1; } void HWNDMessageHandler::OnExitMenuLoop(BOOL is_shortcut_menu) { if (--menu_depth_ == 0) delegate_->HandleMenuLoop(false); DCHECK_GE(0, menu_depth_); } void HWNDMessageHandler::OnExitSizeMove() { delegate_->HandleEndWMSizeMove(); SetMsgHandled(FALSE); // Please refer to the notes in the OnSize function for information about // the scrolling hack. // We hide the Windows scrollbar in the OnEnterSizeMove function. We need // to add the scroll styles back to ensure that scrolling works in legacy // trackpoint drivers. if (in_size_loop_ && needs_scroll_styles_) AddScrollStylesToWindow(hwnd()); // If the window was moved to a monitor which has a fullscreen window active, // we need to reduce the size of the fullscreen window by 1px. CheckAndHandleBackgroundFullscreenOnMonitor(hwnd()); } void HWNDMessageHandler::OnGetMinMaxInfo(MINMAXINFO* minmax_info) { gfx::Size min_window_size; gfx::Size max_window_size; delegate_->GetMinMaxSize(&min_window_size, &max_window_size); min_window_size = delegate_->DIPToScreenSize(min_window_size); max_window_size = delegate_->DIPToScreenSize(max_window_size); // Add the native frame border size to the minimum and maximum size if the // view reports its size as the client size. if (delegate_->WidgetSizeIsClientSize()) { RECT client_rect, window_rect; GetClientRect(hwnd(), &client_rect); GetWindowRect(hwnd(), &window_rect); CR_DEFLATE_RECT(&window_rect, &client_rect); min_window_size.Enlarge(window_rect.right - window_rect.left, window_rect.bottom - window_rect.top); // Either axis may be zero, so enlarge them independently. if (max_window_size.width()) max_window_size.Enlarge(window_rect.right - window_rect.left, 0); if (max_window_size.height()) max_window_size.Enlarge(0, window_rect.bottom - window_rect.top); } minmax_info->ptMinTrackSize.x = min_window_size.width(); minmax_info->ptMinTrackSize.y = min_window_size.height(); if (max_window_size.width() || max_window_size.height()) { if (!max_window_size.width()) max_window_size.set_width(GetSystemMetrics(SM_CXMAXTRACK)); if (!max_window_size.height()) max_window_size.set_height(GetSystemMetrics(SM_CYMAXTRACK)); minmax_info->ptMaxTrackSize.x = max_window_size.width(); minmax_info->ptMaxTrackSize.y = max_window_size.height(); } SetMsgHandled(FALSE); } LRESULT HWNDMessageHandler::OnGetObject(UINT message, WPARAM w_param, LPARAM l_param) { LRESULT reference_result = static_cast<LRESULT>(0L); // Only the lower 32 bits of l_param are valid when checking the object id // because it sometimes gets sign-extended incorrectly (but not always). DWORD obj_id = static_cast<DWORD>(static_cast<DWORD_PTR>(l_param)); // Accessibility readers will send an OBJID_CLIENT message if (static_cast<DWORD>(OBJID_CLIENT) == obj_id) { // Retrieve MSAA dispatch object for the root view. base::win::ScopedComPtr<IAccessible> root( delegate_->GetNativeViewAccessible()); // Create a reference that MSAA will marshall to the client. reference_result = LresultFromObject(IID_IAccessible, w_param, static_cast<IAccessible*>(root.Detach())); } return reference_result; } LRESULT HWNDMessageHandler::OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param) { LRESULT result = 0; base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); const bool msg_handled = delegate_->HandleIMEMessage(message, w_param, l_param, &result); if (ref.get()) SetMsgHandled(msg_handled); return result; } void HWNDMessageHandler::OnInitMenu(HMENU menu) { bool is_fullscreen = IsFullscreen(); bool is_minimized = IsMinimized(); bool is_maximized = IsMaximized(); bool is_restored = !is_fullscreen && !is_minimized && !is_maximized; ScopedRedrawLock lock(this); EnableMenuItemByCommand(menu, SC_RESTORE, delegate_->CanResize() && (is_minimized || is_maximized)); EnableMenuItemByCommand(menu, SC_MOVE, is_restored); EnableMenuItemByCommand(menu, SC_SIZE, delegate_->CanResize() && is_restored); EnableMenuItemByCommand(menu, SC_MAXIMIZE, delegate_->CanMaximize() && !is_fullscreen && !is_maximized); EnableMenuItemByCommand(menu, SC_MINIMIZE, delegate_->CanMinimize() && !is_minimized); if (is_maximized && delegate_->CanResize()) ::SetMenuDefaultItem(menu, SC_RESTORE, FALSE); else if (!is_maximized && delegate_->CanMaximize()) ::SetMenuDefaultItem(menu, SC_MAXIMIZE, FALSE); } void HWNDMessageHandler::OnInputLangChange(DWORD character_set, HKL input_language_id) { delegate_->HandleInputLanguageChange(character_set, input_language_id); } LRESULT HWNDMessageHandler::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { MSG msg = { hwnd(), message, w_param, l_param, static_cast<DWORD>(GetMessageTime())}; ui::KeyEvent key(msg); base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); delegate_->HandleKeyEvent(&key); if (!ref) return 0; if (!key.handled()) SetMsgHandled(FALSE); return 0; } void HWNDMessageHandler::OnKillFocus(HWND focused_window) { delegate_->HandleNativeBlur(focused_window); SetMsgHandled(FALSE); } LRESULT HWNDMessageHandler::OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param) { // Please refer to the comments in the header for the touch_down_contexts_ // member for the if statement below. if (touch_down_contexts_) return MA_NOACTIVATE; // On Windows, if we select the menu item by touch and if the window at the // location is another window on the same thread, that window gets a // WM_MOUSEACTIVATE message and ends up activating itself, which is not // correct. We workaround this by setting a property on the window at the // current cursor location. We check for this property in our // WM_MOUSEACTIVATE handler and don't activate the window if the property is // set. if (::GetProp(hwnd(), ui::kIgnoreTouchMouseActivateForWindow)) { ::RemoveProp(hwnd(), ui::kIgnoreTouchMouseActivateForWindow); return MA_NOACTIVATE; } // TODO(beng): resolve this with the GetWindowLong() check on the subsequent // line. if (delegate_->HasNonClientView()) { if (delegate_->CanActivate()) return MA_ACTIVATE; if (delegate_->WantsMouseEventsWhenInactive()) return MA_NOACTIVATE; return MA_NOACTIVATEANDEAT; } if (GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE) return MA_NOACTIVATE; SetMsgHandled(FALSE); return MA_ACTIVATE; } LRESULT HWNDMessageHandler::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { return HandleMouseEventInternal(message, w_param, l_param, true); } // On some systems with a high-resolution track pad and running Windows 10, // using the scrolling gesture (two-finger scroll) on the track pad // causes it to also generate a WM_POINTERDOWN message if the window // isn't focused. This leads to a WM_POINTERACTIVATE message and the window // gaining focus and coming to the front. This code detects a // WM_POINTERACTIVATE coming from the track pad and kills the activation // of the window. NOTE: most other trackpad messages come in as mouse // messages, including WM_MOUSEWHEEL instead of WM_POINTERWHEEL. LRESULT HWNDMessageHandler::OnPointerActivate(UINT message, WPARAM w_param, LPARAM l_param) { using GetPointerTypeFn = BOOL(WINAPI*)(UINT32, POINTER_INPUT_TYPE*); UINT32 pointer_id = GET_POINTERID_WPARAM(w_param); POINTER_INPUT_TYPE pointer_type; static GetPointerTypeFn get_pointer_type = reinterpret_cast<GetPointerTypeFn>( GetProcAddress(GetModuleHandleA("user32.dll"), "GetPointerType")); if (get_pointer_type && get_pointer_type(pointer_id, &pointer_type) && pointer_type == PT_TOUCHPAD) return PA_NOACTIVATE; SetMsgHandled(FALSE); return -1; } void HWNDMessageHandler::OnMove(const gfx::Point& point) { delegate_->HandleMove(); SetMsgHandled(FALSE); } void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) { delegate_->HandleMove(); } LRESULT HWNDMessageHandler::OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param) { // Per MSDN, w_param is either TRUE or FALSE. However, MSDN also hints that: // "If the window is minimized when this message is received, the application // should pass the message to the DefWindowProc function." // It is found out that the high word of w_param might be set when the window // is minimized or restored. To handle this, w_param's high word should be // cleared before it is converted to BOOL. BOOL active = static_cast<BOOL>(LOWORD(w_param)); bool render_as_active = delegate_->IsAlwaysRenderAsActive(); if (!delegate_->HasNonClientView()) { SetMsgHandled(FALSE); return 0; } if (!delegate_->CanActivate()) return TRUE; // On activation, lift any prior restriction against rendering as inactive. if (active && render_as_active) delegate_->SetAlwaysRenderAsActive(false); if (delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN) { // TODO(beng, et al): Hack to redraw this window and child windows // synchronously upon activation. Not all child windows are redrawing // themselves leading to issues like http://crbug.com/74604 // We redraw out-of-process HWNDs asynchronously to avoid hanging the // whole app if a child HWND belonging to a hung plugin is encountered. RedrawWindow(hwnd(), NULL, NULL, RDW_NOCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW); EnumChildWindows(hwnd(), EnumChildWindowsForRedraw, NULL); } // The frame may need to redraw as a result of the activation change. // We can get WM_NCACTIVATE before we're actually visible. If we're not // visible, no need to paint. if (IsVisible()) delegate_->SchedulePaint(); if (delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN) { SetMsgHandled(TRUE); return TRUE; } return DefWindowProcWithRedrawLock( WM_NCACTIVATE, render_as_active || active, 0); } LRESULT HWNDMessageHandler::OnNCCalcSize(BOOL mode, LPARAM l_param) { // We only override the default handling if we need to specify a custom // non-client edge width. Note that in most cases "no insets" means no // custom width, but in fullscreen mode or when the NonClientFrameView // requests it, we want a custom width of 0. // Let User32 handle the first nccalcsize for captioned windows // so it updates its internal structures (specifically caption-present) // Without this Tile & Cascade windows won't work. // See http://code.google.com/p/chromium/issues/detail?id=900 if (is_first_nccalc_) { is_first_nccalc_ = false; if (GetWindowLong(hwnd(), GWL_STYLE) & WS_CAPTION) { SetMsgHandled(FALSE); return 0; } } gfx::Insets insets; bool got_insets = GetClientAreaInsets(&insets); if (!got_insets && !IsFullscreen() && !(mode && !delegate_->HasFrame())) { SetMsgHandled(FALSE); return 0; } RECT* client_rect = mode ? &(reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0]) : reinterpret_cast<RECT*>(l_param); client_rect->left += insets.left(); client_rect->top += insets.top(); client_rect->bottom -= insets.bottom(); client_rect->right -= insets.right(); if (IsMaximized()) { // Find all auto-hide taskbars along the screen edges and adjust in by the // thickness of the auto-hide taskbar on each such edge, so the window isn't // treated as a "fullscreen app", which would cause the taskbars to // disappear. HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONULL); if (!monitor) { // We might end up here if the window was previously minimized and the // user clicks on the taskbar button to restore it in the previously // maximized position. In that case WM_NCCALCSIZE is sent before the // window coordinates are restored to their previous values, so our // (left,top) would probably be (-32000,-32000) like all minimized // windows. So the above MonitorFromWindow call fails, but if we check // the window rect given with WM_NCCALCSIZE (which is our previous // restored window position) we will get the correct monitor handle. monitor = MonitorFromRect(client_rect, MONITOR_DEFAULTTONULL); if (!monitor) { // This is probably an extreme case that we won't hit, but if we don't // intersect any monitor, let us not adjust the client rect since our // window will not be visible anyway. return 0; } } const int autohide_edges = GetAppbarAutohideEdges(monitor); if (autohide_edges & ViewsDelegate::EDGE_LEFT) client_rect->left += kAutoHideTaskbarThicknessPx; if (autohide_edges & ViewsDelegate::EDGE_TOP) { if (delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN) { // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of // WM_NCHITTEST, having any nonclient area atop the window causes the // caption buttons to draw onscreen but not respond to mouse // hover/clicks. // So for a taskbar at the screen top, we can't push the // client_rect->top down; instead, we move the bottom up by one pixel, // which is the smallest change we can make and still get a client area // less than the screen size. This is visibly ugly, but there seems to // be no better solution. --client_rect->bottom; } else { client_rect->top += kAutoHideTaskbarThicknessPx; } } if (autohide_edges & ViewsDelegate::EDGE_RIGHT) client_rect->right -= kAutoHideTaskbarThicknessPx; if (autohide_edges & ViewsDelegate::EDGE_BOTTOM) client_rect->bottom -= kAutoHideTaskbarThicknessPx; // We cannot return WVR_REDRAW when there is nonclient area, or Windows // exhibits bugs where client pixels and child HWNDs are mispositioned by // the width/height of the upper-left nonclient area. return 0; } // If the window bounds change, we're going to relayout and repaint anyway. // Returning WVR_REDRAW avoids an extra paint before that of the old client // pixels in the (now wrong) location, and thus makes actions like resizing a // window from the left edge look slightly less broken. // We special case when left or top insets are 0, since these conditions // actually require another repaint to correct the layout after glass gets // turned on and off. if (insets.left() == 0 || insets.top() == 0) return 0; return mode ? WVR_REDRAW : 0; } LRESULT HWNDMessageHandler::OnNCHitTest(const gfx::Point& point) { if (!delegate_->HasNonClientView()) { SetMsgHandled(FALSE); return 0; } // Some views may overlap the non client area of the window. // This means that we should look for these views before handing the // hittest message off to DWM or DefWindowProc. // If the hittest returned from the search for a view returns HTCLIENT // then it means that we have a view overlapping the non client area. // In all other cases we can fallback to the system default handling. // Allow the NonClientView to handle the hittest to see if we have a view // overlapping the non client area of the window. POINT temp = { point.x(), point.y() }; MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1); int component = delegate_->GetNonClientComponent(gfx::Point(temp)); if (component == HTCLIENT) return component; // If the DWM is rendering the window controls, we need to give the DWM's // default window procedure first chance to handle hit testing. if (HasSystemFrame()) { LRESULT result; if (DwmDefWindowProc(hwnd(), WM_NCHITTEST, 0, MAKELPARAM(point.x(), point.y()), &result)) { return result; } } // If the point is specified as custom or system nonclient item, return it. if (component != HTNOWHERE) return component; // Otherwise, we let Windows do all the native frame non-client handling for // us. LRESULT hit_test_code = DefWindowProc(hwnd(), WM_NCHITTEST, 0, MAKELPARAM(point.x(), point.y())); if (needs_scroll_styles_) { switch (hit_test_code) { // If we faked the WS_VSCROLL and WS_HSCROLL styles for this window, then // Windows returns the HTVSCROLL or HTHSCROLL hit test codes if we hover // or click on the non client portions of the window where the OS // scrollbars would be drawn. These hittest codes are returned even when // the scrollbars are hidden, which is the case in Aura. We fake the // hittest code as HTCLIENT in this case to ensure that we receive client // mouse messages as opposed to non client mouse messages. case HTVSCROLL: case HTHSCROLL: hit_test_code = HTCLIENT; break; case HTBOTTOMRIGHT: { // Normally the HTBOTTOMRIGHT hittest code is received when we hover // near the bottom right of the window. However due to our fake scroll // styles, we get this code even when we hover around the area where // the vertical scrollar down arrow would be drawn. // We check if the hittest coordinates lie in this region and if yes // we return HTCLIENT. int border_width = ::GetSystemMetrics(SM_CXSIZEFRAME); int border_height = ::GetSystemMetrics(SM_CYSIZEFRAME); int scroll_width = ::GetSystemMetrics(SM_CXVSCROLL); int scroll_height = ::GetSystemMetrics(SM_CYVSCROLL); RECT window_rect; ::GetWindowRect(hwnd(), &window_rect); window_rect.bottom -= border_height; window_rect.right -= border_width; window_rect.left = window_rect.right - scroll_width; window_rect.top = window_rect.bottom - scroll_height; POINT pt; pt.x = point.x(); pt.y = point.y(); if (::PtInRect(&window_rect, pt)) hit_test_code = HTCLIENT; break; } default: break; } } return hit_test_code; } void HWNDMessageHandler::OnNCPaint(HRGN rgn) { RECT window_rect; GetWindowRect(hwnd(), &window_rect); RECT dirty_region; // A value of 1 indicates paint all. if (!rgn || rgn == reinterpret_cast<HRGN>(1)) { dirty_region.left = 0; dirty_region.top = 0; dirty_region.right = window_rect.right - window_rect.left; dirty_region.bottom = window_rect.bottom - window_rect.top; } else { RECT rgn_bounding_box; GetRgnBox(rgn, &rgn_bounding_box); if (!IntersectRect(&dirty_region, &rgn_bounding_box, &window_rect)) { SetMsgHandled(FALSE); return; // Dirty region doesn't intersect window bounds, bail. } // rgn_bounding_box is in screen coordinates. Map it to window coordinates. OffsetRect(&dirty_region, -window_rect.left, -window_rect.top); } // We only do non-client painting if we're not using the system frame. // It's required to avoid some native painting artifacts from appearing when // the window is resized. if (!delegate_->HasNonClientView() || delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN) { if (ui::win::IsAeroGlassEnabled()) { // The default WM_NCPAINT handler under Aero Glass doesn't clear the // nonclient area, so it'll remain the default white color. That area is // invisible initially (covered by the window border) but can become // temporarily visible on maximizing or fullscreening, so clear it here. HDC dc = GetWindowDC(hwnd()); RECT client_rect; ::GetClientRect(hwnd(), &client_rect); ::MapWindowPoints(hwnd(), nullptr, reinterpret_cast<POINT*>(&client_rect), 2); ::OffsetRect(&client_rect, -window_rect.left, -window_rect.top); // client_rect now is in window space. base::win::ScopedRegion base(::CreateRectRgnIndirect(&dirty_region)); base::win::ScopedRegion client(::CreateRectRgnIndirect(&client_rect)); base::win::ScopedRegion nonclient(::CreateRectRgn(0, 0, 0, 0)); ::CombineRgn(nonclient.get(), base.get(), client.get(), RGN_DIFF); ::SelectClipRgn(dc, nonclient.get()); HBRUSH brush = CreateSolidBrush(0); ::FillRect(dc, &dirty_region, brush); ::DeleteObject(brush); ::ReleaseDC(hwnd(), dc); } SetMsgHandled(FALSE); return; } gfx::Size root_view_size = delegate_->GetRootViewSize(); if (gfx::Size(window_rect.right - window_rect.left, window_rect.bottom - window_rect.top) != root_view_size) { // If the size of the window differs from the size of the root view it // means we're being asked to paint before we've gotten a WM_SIZE. This can // happen when the user is interactively resizing the window. To avoid // mass flickering we don't do anything here. Once we get the WM_SIZE we'll // reset the region of the window which triggers another WM_NCPAINT and // all is well. return; } delegate_->HandlePaintAccelerated(gfx::Rect(dirty_region)); // When using a custom frame, we want to avoid calling DefWindowProc() since // that may render artifacts. SetMsgHandled(delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN); } LRESULT HWNDMessageHandler::OnNCUAHDrawCaption(UINT message, WPARAM w_param, LPARAM l_param) { // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for // an explanation about why we need to handle this message. SetMsgHandled(delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN); return 0; } LRESULT HWNDMessageHandler::OnNCUAHDrawFrame(UINT message, WPARAM w_param, LPARAM l_param) { // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for // an explanation about why we need to handle this message. SetMsgHandled(delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN); return 0; } LRESULT HWNDMessageHandler::OnNotify(int w_param, NMHDR* l_param) { LRESULT l_result = 0; SetMsgHandled(delegate_->HandleTooltipNotify(w_param, l_param, &l_result)); return l_result; } void HWNDMessageHandler::OnPaint(HDC dc) { // Call BeginPaint()/EndPaint() around the paint handling, as that seems // to do more to actually validate the window's drawing region. This only // appears to matter for Windows that have the WS_EX_COMPOSITED style set // but will be valid in general too. PAINTSTRUCT ps; HDC display_dc = BeginPaint(hwnd(), &ps); if (!display_dc) { // Collect some information as to why this may have happened and preserve // it on the stack so it shows up in a dump. // This is temporary data collection code in service of // http://crbug.com/512945 DWORD last_error = GetLastError(); size_t current_gdi_objects = GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS); size_t peak_gdi_objects = GetGuiResources( GetCurrentProcess(), GR_GDIOBJECTS_PEAK); base::debug::Alias(&last_error); base::debug::Alias(&current_gdi_objects); base::debug::Alias(&peak_gdi_objects); LOG(FATAL) << "Failed to create DC in BeginPaint(). GLE = " << last_error << ", GDI object count: " << current_gdi_objects << ", GDI peak count: " << peak_gdi_objects; } if (!IsRectEmpty(&ps.rcPaint)) { if (HasChildRenderingWindow()) { // If there's a child window that's being rendered to then clear the // area outside it (as WS_CLIPCHILDREN is set) with transparent black. // Otherwise, other portions of the backing store for the window can // flicker opaque black. http://crbug.com/586454 FillRect(ps.hdc, &ps.rcPaint, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))); } delegate_->HandlePaintAccelerated(gfx::Rect(ps.rcPaint)); } EndPaint(hwnd(), &ps); } LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message, WPARAM w_param, LPARAM l_param) { SetMsgHandled(FALSE); return 0; } LRESULT HWNDMessageHandler::OnScrollMessage(UINT message, WPARAM w_param, LPARAM l_param) { MSG msg = { hwnd(), message, w_param, l_param, static_cast<DWORD>(GetMessageTime())}; ui::ScrollEvent event(msg); delegate_->HandleScrollEvent(event); return 0; } LRESULT HWNDMessageHandler::OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param) { // Reimplement the necessary default behavior here. Calling DefWindowProc can // trigger weird non-client painting for non-glass windows with custom frames. // Using a ScopedRedrawLock to prevent caption rendering artifacts may allow // content behind this window to incorrectly paint in front of this window. // Invalidating the window to paint over either set of artifacts is not ideal. wchar_t* cursor = IDC_ARROW; switch (LOWORD(l_param)) { case HTSIZE: cursor = IDC_SIZENWSE; break; case HTLEFT: case HTRIGHT: cursor = IDC_SIZEWE; break; case HTTOP: case HTBOTTOM: cursor = IDC_SIZENS; break; case HTTOPLEFT: case HTBOTTOMRIGHT: cursor = IDC_SIZENWSE; break; case HTTOPRIGHT: case HTBOTTOMLEFT: cursor = IDC_SIZENESW; break; case HTCLIENT: SetCursor(current_cursor_); return 1; case LOWORD(HTERROR): // Use HTERROR's LOWORD value for valid comparison. SetMsgHandled(FALSE); break; default: // Use the default value, IDC_ARROW. break; } ::SetCursor(LoadCursor(NULL, cursor)); return 1; } void HWNDMessageHandler::OnSetFocus(HWND last_focused_window) { delegate_->HandleNativeFocus(last_focused_window); SetMsgHandled(FALSE); } LRESULT HWNDMessageHandler::OnSetIcon(UINT size_type, HICON new_icon) { // Use a ScopedRedrawLock to avoid weird non-client painting. return DefWindowProcWithRedrawLock(WM_SETICON, size_type, reinterpret_cast<LPARAM>(new_icon)); } LRESULT HWNDMessageHandler::OnSetText(const wchar_t* text) { // Use a ScopedRedrawLock to avoid weird non-client painting. return DefWindowProcWithRedrawLock(WM_SETTEXT, NULL, reinterpret_cast<LPARAM>(text)); } void HWNDMessageHandler::OnSettingChange(UINT flags, const wchar_t* section) { if (!GetParent(hwnd()) && (flags == SPI_SETWORKAREA) && !delegate_->WillProcessWorkAreaChange()) { // Fire a dummy SetWindowPos() call, so we'll trip the code in // OnWindowPosChanging() below that notices work area changes. ::SetWindowPos(hwnd(), 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOOWNERZORDER); SetMsgHandled(TRUE); } else { if (flags == SPI_SETWORKAREA) delegate_->HandleWorkAreaChanged(); SetMsgHandled(FALSE); } // If the work area is changing, then it could be as a result of the taskbar // broadcasting the WM_SETTINGCHANGE message due to changes in auto hide // settings, etc. Force a WM_NCCALCSIZE to occur to ensure that we handle // this correctly. if (flags == SPI_SETWORKAREA) SendFrameChanged(); } void HWNDMessageHandler::OnSize(UINT param, const gfx::Size& size) { RedrawWindow(hwnd(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); // ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've // invoked OnSize we ensure the RootView has been laid out. ResetWindowRegion(false, true); // We add the WS_VSCROLL and WS_HSCROLL styles to top level windows to ensure // that legacy trackpad/trackpoint drivers generate the WM_VSCROLL and // WM_HSCROLL messages and scrolling works. // We want the scroll styles to be present on the window. However we don't // want Windows to draw the scrollbars. To achieve this we hide the scroll // bars and readd them to the window style in a posted task to ensure that we // don't get nested WM_SIZE messages. if (needs_scroll_styles_ && !in_size_loop_) { ShowScrollBar(hwnd(), SB_BOTH, FALSE); base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&AddScrollStylesToWindow, hwnd())); } } void HWNDMessageHandler::OnSysCommand(UINT notification_code, const gfx::Point& point) { if (!delegate_->ShouldHandleSystemCommands()) return; // Windows uses the 4 lower order bits of |notification_code| for type- // specific information so we must exclude this when comparing. static const int sc_mask = 0xFFF0; // Ignore size/move/maximize in fullscreen mode. if (IsFullscreen() && (((notification_code & sc_mask) == SC_SIZE) || ((notification_code & sc_mask) == SC_MOVE) || ((notification_code & sc_mask) == SC_MAXIMIZE))) return; if (delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN) { if ((notification_code & sc_mask) == SC_MINIMIZE || (notification_code & sc_mask) == SC_MAXIMIZE || (notification_code & sc_mask) == SC_RESTORE) { delegate_->ResetWindowControls(); } else if ((notification_code & sc_mask) == SC_MOVE || (notification_code & sc_mask) == SC_SIZE) { if (!IsVisible()) { // Circumvent ScopedRedrawLocks and force visibility before entering a // resize or move modal loop to get continuous sizing/moving feedback. SetWindowLong(hwnd(), GWL_STYLE, GetWindowLong(hwnd(), GWL_STYLE) | WS_VISIBLE); } } } // Handle SC_KEYMENU, which means that the user has pressed the ALT // key and released it, so we should focus the menu bar. if ((notification_code & sc_mask) == SC_KEYMENU && point.x() == 0) { int modifiers = ui::EF_NONE; if (ui::win::IsShiftPressed()) modifiers |= ui::EF_SHIFT_DOWN; if (ui::win::IsCtrlPressed()) modifiers |= ui::EF_CONTROL_DOWN; // Retrieve the status of shift and control keys to prevent consuming // shift+alt keys, which are used by Windows to change input languages. ui::Accelerator accelerator(ui::KeyboardCodeForWindowsKeyCode(VK_MENU), modifiers); delegate_->HandleAccelerator(accelerator); return; } // If the delegate can't handle it, the system implementation will be called. if (!delegate_->HandleCommand(notification_code)) { // If the window is being resized by dragging the borders of the window // with the mouse/touch/keyboard, we flag as being in a size loop. if ((notification_code & sc_mask) == SC_SIZE) in_size_loop_ = true; base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); DefWindowProc(hwnd(), WM_SYSCOMMAND, notification_code, MAKELPARAM(point.x(), point.y())); if (!ref.get()) return; in_size_loop_ = false; } } void HWNDMessageHandler::OnThemeChanged() { ui::NativeThemeWin::instance()->CloseHandles(); } LRESULT HWNDMessageHandler::OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param) { // Handle touch events only on Aura for now. int num_points = LOWORD(w_param); std::unique_ptr<TOUCHINPUT[]> input(new TOUCHINPUT[num_points]); if (ui::GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param), num_points, input.get(), sizeof(TOUCHINPUT))) { // input[i].dwTime doesn't necessarily relate to the system time at all, // so use base::TimeTicks::Now(). const base::TimeTicks event_time = base::TimeTicks::Now(); TouchEvents touch_events; for (int i = 0; i < num_points; ++i) { POINT point; point.x = TOUCH_COORD_TO_PIXEL(input[i].x); point.y = TOUCH_COORD_TO_PIXEL(input[i].y); if (base::win::GetVersion() == base::win::VERSION_WIN7) { // Windows 7 sends touch events for touches in the non-client area, // whereas Windows 8 does not. In order to unify the behaviour, always // ignore touch events in the non-client area. LPARAM l_param_ht = MAKELPARAM(point.x, point.y); LRESULT hittest = SendMessage(hwnd(), WM_NCHITTEST, 0, l_param_ht); if (hittest != HTCLIENT) return 0; } ScreenToClient(hwnd(), &point); last_touch_message_time_ = ::GetMessageTime(); gfx::Point touch_point(point.x, point.y); unsigned int touch_id = id_generator_.GetGeneratedID(input[i].dwID); if (input[i].dwFlags & TOUCHEVENTF_DOWN) { touch_ids_.insert(input[i].dwID); GenerateTouchEvent(ui::ET_TOUCH_PRESSED, touch_point, touch_id, event_time, &touch_events); touch_down_contexts_++; base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&HWNDMessageHandler::ResetTouchDownContext, weak_factory_.GetWeakPtr()), base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout)); } else { if (input[i].dwFlags & TOUCHEVENTF_MOVE) { GenerateTouchEvent(ui::ET_TOUCH_MOVED, touch_point, touch_id, event_time, &touch_events); } if (input[i].dwFlags & TOUCHEVENTF_UP) { touch_ids_.erase(input[i].dwID); GenerateTouchEvent(ui::ET_TOUCH_RELEASED, touch_point, touch_id, event_time, &touch_events); id_generator_.ReleaseNumber(input[i].dwID); } } } // Handle the touch events asynchronously. We need this because touch // events on windows don't fire if we enter a modal loop in the context of // a touch event. base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&HWNDMessageHandler::HandleTouchEvents, weak_factory_.GetWeakPtr(), touch_events)); } CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(l_param)); SetMsgHandled(FALSE); return 0; } void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) { if (ignore_window_pos_changes_) { // If somebody's trying to toggle our visibility, change the nonclient area, // change our Z-order, or activate us, we should probably let it go through. if (!(window_pos->flags & ((IsVisible() ? SWP_HIDEWINDOW : SWP_SHOWWINDOW) | SWP_FRAMECHANGED)) && (window_pos->flags & (SWP_NOZORDER | SWP_NOACTIVATE))) { // Just sizing/moving the window; ignore. window_pos->flags |= SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW; window_pos->flags &= ~(SWP_SHOWWINDOW | SWP_HIDEWINDOW); } } else if (!GetParent(hwnd())) { RECT window_rect; HMONITOR monitor; gfx::Rect monitor_rect, work_area; if (GetWindowRect(hwnd(), &window_rect) && GetMonitorAndRects(window_rect, &monitor, &monitor_rect, &work_area)) { bool work_area_changed = (monitor_rect == last_monitor_rect_) && (work_area != last_work_area_); // If the size of a background fullscreen window changes again, then we // should reset the |background_fullscreen_hack_| flag. if (background_fullscreen_hack_ && (!(window_pos->flags & SWP_NOSIZE) && (monitor_rect.height() - window_pos->cy != 1))) { background_fullscreen_hack_ = false; } if (monitor && (monitor == last_monitor_) && ((IsFullscreen() && !background_fullscreen_hack_) || work_area_changed)) { // A rect for the monitor we're on changed. Normally Windows notifies // us about this (and thus we're reaching here due to the SetWindowPos() // call in OnSettingChange() above), but with some software (e.g. // nVidia's nView desktop manager) the work area can change asynchronous // to any notification, and we're just sent a SetWindowPos() call with a // new (frequently incorrect) position/size. In either case, the best // response is to throw away the existing position/size information in // |window_pos| and recalculate it based on the new work rect. gfx::Rect new_window_rect; if (IsFullscreen()) { new_window_rect = monitor_rect; } else if (IsMaximized()) { new_window_rect = work_area; int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); new_window_rect.Inset(-border_thickness, -border_thickness); } else { new_window_rect = gfx::Rect(window_rect); new_window_rect.AdjustToFit(work_area); } window_pos->x = new_window_rect.x(); window_pos->y = new_window_rect.y(); window_pos->cx = new_window_rect.width(); window_pos->cy = new_window_rect.height(); // WARNING! Don't set SWP_FRAMECHANGED here, it breaks moving the child // HWNDs for some reason. window_pos->flags &= ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW); window_pos->flags |= SWP_NOCOPYBITS; // Now ignore all immediately-following SetWindowPos() changes. Windows // likes to (incorrectly) recalculate what our position/size should be // and send us further updates. ignore_window_pos_changes_ = true; base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&HWNDMessageHandler::StopIgnoringPosChanges, weak_factory_.GetWeakPtr())); } last_monitor_ = monitor; last_monitor_rect_ = monitor_rect; last_work_area_ = work_area; } } RECT window_rect; gfx::Size old_size; if (GetWindowRect(hwnd(), &window_rect)) old_size = gfx::Rect(window_rect).size(); gfx::Size new_size = gfx::Size(window_pos->cx, window_pos->cy); if ((old_size != new_size && !(window_pos->flags & SWP_NOSIZE)) || window_pos->flags & SWP_FRAMECHANGED) { delegate_->HandleWindowSizeChanging(); sent_window_size_changing_ = true; } if (ScopedFullscreenVisibility::IsHiddenForFullscreen(hwnd())) { // Prevent the window from being made visible if we've been asked to do so. // See comment in header as to why we might want this. window_pos->flags &= ~SWP_SHOWWINDOW; } if (window_pos->flags & SWP_SHOWWINDOW) delegate_->HandleVisibilityChanging(true); else if (window_pos->flags & SWP_HIDEWINDOW) { SetDwmFrameExtension(DwmFrameState::OFF); delegate_->HandleVisibilityChanging(false); } SetMsgHandled(FALSE); } void HWNDMessageHandler::OnWindowPosChanged(WINDOWPOS* window_pos) { if (DidClientAreaSizeChange(window_pos)) ClientAreaSizeChanged(); if (window_pos->flags & SWP_FRAMECHANGED) SetDwmFrameExtension(DwmFrameState::ON); if (window_pos->flags & SWP_SHOWWINDOW) { delegate_->HandleVisibilityChanged(true); if (direct_manipulation_helper_) direct_manipulation_helper_->Activate(hwnd()); SetDwmFrameExtension(DwmFrameState::ON); } else if (window_pos->flags & SWP_HIDEWINDOW) { delegate_->HandleVisibilityChanged(false); if (direct_manipulation_helper_) direct_manipulation_helper_->Deactivate(hwnd()); } if (sent_window_size_changing_) { sent_window_size_changing_ = false; delegate_->HandleWindowSizeChanged(); } SetMsgHandled(FALSE); } void HWNDMessageHandler::OnSessionChange(WPARAM status_code) { // Direct3D presents are ignored while the screen is locked, so force the // window to be redrawn on unlock. if (status_code == WTS_SESSION_UNLOCK) ForceRedrawWindow(10); } void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); for (size_t i = 0; i < touch_events.size() && ref; ++i) delegate_->HandleTouchEvent(touch_events[i]); } void HWNDMessageHandler::ResetTouchDownContext() { touch_down_contexts_--; } LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, WPARAM w_param, LPARAM l_param, bool track_mouse) { // We handle touch events on Windows Aura. Windows generates synthesized // mouse messages in response to touch which we should ignore. However touch // messages are only received for the client area. We need to ignore the // synthesized mouse messages for all points in the client area and places // which return HTNOWHERE. // TODO(ananta) // Windows does not reliably set the touch flag on mouse messages. Look into // a better way of identifying mouse messages originating from touch. if (ui::IsMouseEventFromTouch(message)) { LPARAM l_param_ht = l_param; // For mouse events (except wheel events), location is in window coordinates // and should be converted to screen coordinates for WM_NCHITTEST. if (message != WM_MOUSEWHEEL && message != WM_MOUSEHWHEEL) { POINT screen_point = CR_POINT_INITIALIZER_FROM_LPARAM(l_param_ht); MapWindowPoints(hwnd(), HWND_DESKTOP, &screen_point, 1); l_param_ht = MAKELPARAM(screen_point.x, screen_point.y); } LRESULT hittest = SendMessage(hwnd(), WM_NCHITTEST, 0, l_param_ht); if (hittest == HTCLIENT || hittest == HTNOWHERE) return 0; } // Certain logitech drivers send the WM_MOUSEHWHEEL message to the parent // followed by WM_MOUSEWHEEL messages to the child window causing a vertical // scroll. We treat these WM_MOUSEWHEEL messages as WM_MOUSEHWHEEL // messages. if (message == WM_MOUSEHWHEEL) last_mouse_hwheel_time_ = ::GetMessageTime(); if (message == WM_MOUSEWHEEL && ::GetMessageTime() == last_mouse_hwheel_time_) { message = WM_MOUSEHWHEEL; } if (message == WM_RBUTTONUP && is_right_mouse_pressed_on_caption_) { is_right_mouse_pressed_on_caption_ = false; ReleaseCapture(); // |point| is in window coordinates, but WM_NCHITTEST and TrackPopupMenu() // expect screen coordinates. POINT screen_point = CR_POINT_INITIALIZER_FROM_LPARAM(l_param); MapWindowPoints(hwnd(), HWND_DESKTOP, &screen_point, 1); w_param = SendMessage(hwnd(), WM_NCHITTEST, 0, MAKELPARAM(screen_point.x, screen_point.y)); if (w_param == HTCAPTION || w_param == HTSYSMENU) { gfx::ShowSystemMenuAtPoint(hwnd(), gfx::Point(screen_point)); return 0; } } else if (message == WM_NCLBUTTONDOWN && delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN) { switch (w_param) { case HTCLOSE: case HTMINBUTTON: case HTMAXBUTTON: { // When the mouse is pressed down in these specific non-client areas, // we need to tell the RootView to send the mouse pressed event (which // sets capture, allowing subsequent WM_LBUTTONUP (note, _not_ // WM_NCLBUTTONUP) to fire so that the appropriate WM_SYSCOMMAND can be // sent by the applicable button's ButtonListener. We _have_ to do this // way rather than letting Windows just send the syscommand itself (as // would happen if we never did this dance) because for some insane // reason DefWindowProc for WM_NCLBUTTONDOWN also renders the pressed // window control button appearance, in the Windows classic style, over // our view! Ick! By handling this message we prevent Windows from // doing this undesirable thing, but that means we need to roll the // sys-command handling ourselves. // Combine |w_param| with common key state message flags. w_param |= ui::win::IsCtrlPressed() ? MK_CONTROL : 0; w_param |= ui::win::IsShiftPressed() ? MK_SHIFT : 0; } } } else if (message == WM_NCRBUTTONDOWN && (w_param == HTCAPTION || w_param == HTSYSMENU)) { is_right_mouse_pressed_on_caption_ = true; // We SetCapture() to ensure we only show the menu when the button // down and up are both on the caption. Note: this causes the button up to // be WM_RBUTTONUP instead of WM_NCRBUTTONUP. SetCapture(); } long message_time = GetMessageTime(); MSG msg = { hwnd(), message, w_param, l_param, static_cast<DWORD>(message_time), { CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param) } }; ui::MouseEvent event(msg); if (IsSynthesizedMouseMessage(message, message_time, l_param)) event.set_flags(event.flags() | ui::EF_FROM_TOUCH); if (event.type() == ui::ET_MOUSE_MOVED && !HasCapture() && track_mouse) { // Windows only fires WM_MOUSELEAVE events if the application begins // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. TrackMouseEvents((message == WM_NCMOUSEMOVE) ? TME_NONCLIENT | TME_LEAVE : TME_LEAVE); } else if (event.type() == ui::ET_MOUSE_EXITED) { // Reset our tracking flags so future mouse movement over this // NativeWidget results in a new tracking session. Fall through for // OnMouseEvent. active_mouse_tracking_flags_ = 0; } else if (event.type() == ui::ET_MOUSEWHEEL) { // Reroute the mouse wheel to the window under the pointer if applicable. return (ui::RerouteMouseWheel(hwnd(), w_param, l_param) || delegate_->HandleMouseEvent(ui::MouseWheelEvent(msg))) ? 0 : 1; } // There are cases where the code handling the message destroys the window, // so use the weak ptr to check if destruction occured or not. base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); bool handled = delegate_->HandleMouseEvent(event); if (!ref.get()) return 0; if (direct_manipulation_helper_ && track_mouse && (message == WM_MOUSEWHEEL || message == WM_MOUSEHWHEEL)) { direct_manipulation_helper_->HandleMouseWheel(hwnd(), message, w_param, l_param); } if (!handled && message == WM_NCLBUTTONDOWN && w_param != HTSYSMENU && w_param != HTCAPTION && delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN) { // TODO(msw): Eliminate undesired painting, or re-evaluate this workaround. // DefWindowProc for WM_NCLBUTTONDOWN does weird non-client painting, so we // need to call it inside a ScopedRedrawLock. This may cause other negative // side-effects (ex/ stifling non-client mouse releases). DefWindowProcWithRedrawLock(message, w_param, l_param); handled = true; } // We need special processing for mouse input on the caption. // Please refer to the HandleMouseInputForCaption() function for more // information. if (!handled) handled = HandleMouseInputForCaption(message, w_param, l_param); if (ref.get()) SetMsgHandled(handled); return 0; } bool HWNDMessageHandler::IsSynthesizedMouseMessage(unsigned int message, int message_time, LPARAM l_param) { if (ui::IsMouseEventFromTouch(message)) return true; // Ignore mouse messages which occur at the same location as the current // cursor position and within a time difference of 500 ms from the last // touch message. if (last_touch_message_time_ && message_time >= last_touch_message_time_ && ((message_time - last_touch_message_time_) <= kSynthesizedMouseTouchMessagesTimeDifference)) { POINT mouse_location = CR_POINT_INITIALIZER_FROM_LPARAM(l_param); ::ClientToScreen(hwnd(), &mouse_location); POINT cursor_pos = {0}; ::GetCursorPos(&cursor_pos); if (memcmp(&cursor_pos, &mouse_location, sizeof(POINT))) return false; return true; } return false; } void HWNDMessageHandler::PerformDwmTransition() { dwm_transition_desired_ = false; UpdateDwmNcRenderingPolicy(); // Don't redraw the window here, because we need to hide and show the window // which will also trigger a redraw. ResetWindowRegion(true, false); // The non-client view needs to update too. delegate_->HandleFrameChanged(); if (IsVisible() && delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN) { // For some reason, we need to hide the window after we change from a custom // frame to a native frame. If we don't, the client area will be filled // with black. This seems to be related to an interaction between DWM and // SetWindowRgn, but the details aren't clear. Additionally, we need to // specify SWP_NOZORDER here, otherwise if you have multiple chrome windows // open they will re-appear with a non-deterministic Z-order. UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER; SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); } // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want // to notify our children too, since we can have MDI child windows who need to // update their appearance. EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); } void HWNDMessageHandler::GenerateTouchEvent(ui::EventType event_type, const gfx::Point& point, unsigned int id, base::TimeTicks time_stamp, TouchEvents* touch_events) { ui::TouchEvent event(event_type, point, id, time_stamp); event.set_flags(ui::GetModifiersFromKeyState()); event.latency()->AddLatencyNumberWithTimestamp( ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, time_stamp, 1); touch_events->push_back(event); } bool HWNDMessageHandler::HandleMouseInputForCaption(unsigned int message, WPARAM w_param, LPARAM l_param) { // If we are receive a WM_NCLBUTTONDOWN messsage for the caption, the // following things happen. // 1. This message is defproced which will post a WM_SYSCOMMAND message with // SC_MOVE and a constant 0x0002 which is documented on msdn as // SC_DRAGMOVE. // 2. The WM_SYSCOMMAND message is defproced in our handler which works // correctly in all cases except the case when we click on the caption // and hold. The defproc appears to try and detect whether a mouse move // is going to happen presumably via the DragEnter or a similar // implementation which in its modal loop appears to only peek for // mouse input briefly. // 3. Our workhorse message pump relies on the tickler posted message to get // control during modal loops which does not happen in the above case for // a while leading to the problem where activity on the page pauses // briefly or at times stops for a while. // To fix this we don't defproc the WM_NCLBUTTONDOWN message and instead wait // for the subsequent WM_NCMOUSEMOVE/WM_MOUSEMOVE message. Once we receive // these messages and the mouse actually moved, we defproc the // WM_NCLBUTTONDOWN message. bool handled = false; switch (message) { case WM_NCLBUTTONDOWN: { if (w_param == HTCAPTION) { left_button_down_on_caption_ = true; // Cache the location where the click occurred. We use this in the // WM_NCMOUSEMOVE message to determine if the mouse actually moved.F caption_left_button_click_pos_.set_x(CR_GET_X_LPARAM(l_param)); caption_left_button_click_pos_.set_y(CR_GET_Y_LPARAM(l_param)); handled = true; } break; } // WM_NCMOUSEMOVE is received for normal drags which originate on the // caption and stay there. // WM_MOUSEMOVE can be received for drags which originate on the caption // and move towards the client area. case WM_MOUSEMOVE: case WM_NCMOUSEMOVE: { if (!left_button_down_on_caption_) break; bool should_handle_pending_ncl_button_down = true; // Check if the mouse actually moved. if (message == WM_NCMOUSEMOVE) { if (caption_left_button_click_pos_.x() == CR_GET_X_LPARAM(l_param) && caption_left_button_click_pos_.y() == CR_GET_Y_LPARAM(l_param)) { should_handle_pending_ncl_button_down = false; } } if (should_handle_pending_ncl_button_down) { l_param = MAKELPARAM(caption_left_button_click_pos_.x(), caption_left_button_click_pos_.y()); // TODO(msw): Eliminate undesired painting, or re-evaluate this // workaround. // DefWindowProc for WM_NCLBUTTONDOWN does weird non-client painting, // so we need to call it inside a ScopedRedrawLock. This may cause // other negative side-effects // (ex/ stifling non-client mouse releases). // We may be deleted in the context of DefWindowProc. Don't refer to // any member variables after the DefWindowProc call. left_button_down_on_caption_ = false; if (delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN) { DefWindowProcWithRedrawLock(WM_NCLBUTTONDOWN, HTCAPTION, l_param); } else { DefWindowProc(hwnd(), WM_NCLBUTTONDOWN, HTCAPTION, l_param); } } break; } case WM_NCMOUSELEAVE: break; default: left_button_down_on_caption_ = false; break; } return handled; } void HWNDMessageHandler::SetBoundsInternal(const gfx::Rect& bounds_in_pixels, bool force_size_changed) { LONG style = GetWindowLong(hwnd(), GWL_STYLE); if (style & WS_MAXIMIZE) SetWindowLong(hwnd(), GWL_STYLE, style & ~WS_MAXIMIZE); gfx::Size old_size = GetClientAreaBounds().size(); SetWindowPos(hwnd(), NULL, bounds_in_pixels.x(), bounds_in_pixels.y(), bounds_in_pixels.width(), bounds_in_pixels.height(), SWP_NOACTIVATE | SWP_NOZORDER); // If HWND size is not changed, we will not receive standard size change // notifications. If |force_size_changed| is |true|, we should pretend size is // changed. if (old_size == bounds_in_pixels.size() && force_size_changed && !background_fullscreen_hack_) { delegate_->HandleClientSizeChanged(GetClientAreaBounds().size()); ResetWindowRegion(false, true); } if (direct_manipulation_helper_) direct_manipulation_helper_->SetBounds(bounds_in_pixels); } void HWNDMessageHandler::CheckAndHandleBackgroundFullscreenOnMonitor( HWND window) { HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY); FullscreenWindowMonitorMap::iterator iter = fullscreen_monitor_map_.Get().find(monitor); if (iter != fullscreen_monitor_map_.Get().end()) { DCHECK(iter->second); if (window != iter->second->hwnd()) iter->second->OnBackgroundFullscreen(); } } void HWNDMessageHandler::OnBackgroundFullscreen() { // Reduce the bounds of the window by 1px to ensure that Windows does // not treat this like a fullscreen window. MONITORINFO monitor_info = {sizeof(monitor_info)}; GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), &monitor_info); gfx::Rect shrunk_rect(monitor_info.rcMonitor); shrunk_rect.set_height(shrunk_rect.height() - 1); background_fullscreen_hack_ = true; SetBoundsInternal(shrunk_rect, false); } } // namespace views
[ "changhyeok.bae@lge.com" ]
changhyeok.bae@lge.com
11234852a105c2d49af6a3e24fec2f8af69d5d63
c87095bd13b9080224324b3a6dd4fd538912d97e
/Direct3D/Rotating Cube/win_main.cpp
fc43da899e9748deda1e59f5c62149f582853e69
[ "MIT" ]
permissive
Agrelimos/tutorials
6a0a8ef6652a44bd5a35b59bf192326c831367ff
7d2953b8fbb5c56a921a17e7e3cac3d1f4fbb41b
refs/heads/master
2020-04-01T05:26:56.560609
2018-10-13T18:45:56
2018-10-13T18:45:56
152,903,588
0
0
MIT
2018-10-13T18:44:42
2018-10-13T18:44:42
null
WINDOWS-1252
C++
false
false
10,582
cpp
// Done by TheTutor /* If you've spent any time programming 3D applications you've probably seen a rendition of the "rotating cube demo". World renown, the rotating cube app is a beginning rung on the ladder to 3D nirvana. With some handy D3D functions, if you know how to put a cube on the screen, making it rotate is a piece of cake. Before we get rotating, a bit of vocabulary needs to be defined. Now if you're a pilot, the following words are old hat. However if you're not into aviation you may have never seen these before. Yaw -- To turn about the vertical axis (for us that's the Y-axis) Pitch -- To turn about a horizontal axis (for us that's the X-axis) Roll -- To turn about an axis perpendicular to the vertical and horizontal axis (for us that's the Z-axis) So yaw, pitch, and roll essentially just mean rotation around the Y, X, and Z axis respectively. We'll use D3D's function D3DXMatrixRotationYawPitchRoll() to achieve our rotating cube and thus it's necessary to have an understanding of what the terms yaw, pitch, and roll mean :) Additionally we need to talk about index buffers. They are something used readily in 3D programming. So before we get to far into this tutorial, it's important to understand what a index buffer is. Index buffers are memory buffers (arrays) that contain index data. Index data (indices) are integer offsets into vertex buffers (arrays containing vertices) which specify what vertices to use to render a primitive (typically one triangle). Lets go through that definition with a concrete example. Lets suppose we wanted to draw a 3D cube (which we do). Lets look at some numbers we know for a cube: Sides (Square) = 6 Vertices = 8 Triangles = 2 per side * 6 sides = 12 Vertices needed to render = 3 per triangle * 12 triangles = 36 So we'd need 36 vertices (most of which would be redundant) to render a cube. This is where index buffers come into play. Instead of copying the vertices several times we only use one copy, then create an array which indexes into our vertex array and specifies which vertices to use to make the 12 triangles. Why do we do this? The main reason is that it saves memory. Lets prove that quickly. Here's the memory foot print for rendering a cube using 36 vertices struct SVertex { float x, y, z; // World position DWORD color; // Diffuse color }; Size of our vertex = 3 floats + 1 DWORD = 16 bytes Total size = 36 verts * 16 bytes = 576 bytes If we're using indices where each index is a WORD: Size of our vertex = 3 floats + 1 DWORD = 16 bytes Vertex buffer size = 8 verts * 16 bytes = 128 bytes Index buffer size = 36 indices * 2 bytes = 72 bytes Total Size = 128 + 72 = 200 bytes As you can see with just a simple cube we save 376 bytes! If you extend that to a several hundred/thousand vertices model multiplied by the number of models in the application you can imagine how it's gonna add up to huge savings. So without further ado, lets get coding... */ #include <windows.h> #include "d3d_obj.h" // Add the following libraries #pragma comment(lib, "d3d9.lib") #pragma comment(lib, "d3dx9.lib") ///////////// // Macros // /////////// #define DEG2RAD(x) (x * (D3DX_PI / 180.0f)) // Converts degrees to radians #define RAD2DEG(x) (x * (180.0f / D3DX_PI)) // Converts radians to degrees //////////////// // Constants // ////////////// // Width and height of the window (specifically the client rect) const int kWinWid = 640; const int kWinHgt = 480; const char kClassName[] = "GT_D3DRotatingCube"; // WNDCLASSEX's name const int kCubeVertCount = 8; // Number of vertices in the cube const int kCubeIndiceCount = 36; // Number of indices to define the cube as triangles ////////////// // Globals // //////////// // Our 8 cube vertices, half blue and half green SVertex gCubeVerts[kCubeVertCount] = { { -1.0f, -1.0f, -1.0f, D3DCOLOR_RGBA(0, 0, 200, 255), }, { -1.0f, 1.0f, -1.0f, D3DCOLOR_RGBA(0, 0, 200, 255), }, { 1.0f, -1.0f, -1.0f, D3DCOLOR_RGBA(0, 0, 200, 255), }, { 1.0f, 1.0f, -1.0f, D3DCOLOR_RGBA(0, 0, 200, 255), }, { 1.0f, -1.0f, 1.0f, D3DCOLOR_RGBA(0, 200, 0, 255), }, { 1.0f, 1.0f, 1.0f, D3DCOLOR_RGBA(0, 200, 0, 255), }, { -1.0f, -1.0f, 1.0f, D3DCOLOR_RGBA(0, 200, 0, 255), }, { -1.0f, 1.0f, 1.0f, D3DCOLOR_RGBA(0, 200, 0, 255), } }; // Our cube indices // Remember every cube index, is literally an index into // our cube vertices array, since we only have 8 cube vertices, // you'll notice our indices are in the range of 0 - 7 WORD gCubeIndices[kCubeIndiceCount] = { 0, 1, 2, // Triangle 1 2, 1, 3, // Triangle 2 2, 3, 4, // Triangle 3 4, 3, 5, // Triangle 4 4, 5, 6, // Triangle 5 6, 5, 7, // Triangle 6 6, 7, 0, // Triangle 7 0, 7, 1, // Triangle 8 1, 7, 3, // Triangle 9 3, 7, 5, // Triangle 10 0, 2, 6, // Triangle 11 2, 4, 6 }; // Triangle 12 bool LockFrameRate(int frame_rate = 60); // Locks the frame rate void DrawAndRotateCube(); // Guess what this does %) // Standard WinProc LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); // Standard WinMain int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprev, PSTR cmdline, int ishow) { HWND hwnd = NULL; MSG msg = {0}; WNDCLASSEX wndclassex = {0}; // Init fields we care about wndclassex.cbSize = sizeof(WNDCLASSEX); // Always set to size of WNDCLASSEX wndclassex.style = CS_HREDRAW | CS_VREDRAW; wndclassex.lpfnWndProc = WinProc; wndclassex.hInstance = hinstance; wndclassex.lpszClassName = kClassName; wndclassex.hCursor = (HCURSOR)LoadImage(NULL, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0, LR_SHARED); RegisterClassEx(&wndclassex); // Register WNDCLASSEX RECT rect = { 0, 0, kWinWid, kWinHgt }; // Desired window client rect DWORD winStyleEx = WS_EX_CLIENTEDGE; DWORD winStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME; // Adjust window rect so it gives us our desired client rect when we // create the window AdjustWindowRectEx(&rect, winStyle, false, winStyleEx); // Create the window hwnd = CreateWindowEx(winStyleEx, // Window extended style kClassName, "www.GameTutorials.com -- Rotating Cube", winStyle, // Window style CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, hinstance, NULL); // Init our global 3D object if(g3D->init(hwnd) == false) return EXIT_FAILURE; // There's been an error, lets get out of this joint // Get the client rect and make sure our client is the size we want GetClientRect(hwnd, &rect); assert(rect.right == kWinWid && rect.bottom == kWinHgt); // Set up our projection matrix once because it will not change g3D->setProjMatrix(DEG2RAD(60), (float)kWinWid / (float)kWinHgt, 1.0f, 8192.0f); // We set up our view matrix once because it will never change g3D->setViewMatrix(CPos(0.0f, 0.0f, -5.0f), CPos(0.0f, 0.0f, 0.0f)); ShowWindow(hwnd, ishow); UpdateWindow(hwnd); while(1) // While the app is running... { if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Handle messages from the OS { if(msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } else if(LockFrameRate()) // If it's time to render, do so { DrawAndRotateCube(); } else Sleep(1); // Otherwise give the OS some time to process other things } // end of while(1) g3D->deinit(); // Free up the D3D object UnregisterClass(kClassName,hinstance); // Free up WNDCLASSEX return EXIT_SUCCESS; // Application was a success } // WinProc LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { switch(message) { case WM_KEYDOWN: // If the user presses ESC, close the app if(wparam == VK_ESCAPE) SendMessage(hwnd, WM_CLOSE, 0, 0); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wparam, lparam); } // Locks the frame rate at "frame_rate" // Returns true when it's okay to draw, false otherwise bool LockFrameRate(int frame_rate) { static float lastTime = 0.0f; // Get current time in seconds (milliseconds * .001 = seconds) float currentTime = GetTickCount() * 0.001f; // Get the elapsed time by subtracting the current time from the last time // If the desired frame rate amount of seconds has passed -- return true (ie Blit()) if((currentTime - lastTime) > (1.0f / frame_rate)) { // Reset the last time lastTime = currentTime; return true; } return false; } // Draws and rotates our cube void DrawAndRotateCube() { D3DXMATRIXA16 matrix; static int angle = 0; // The angle of rotation g3D->begin(); // Begin the scene g3D->clear(); // Clear the viewport // We add 1° each time we draw and convert to radians float angInRad = DEG2RAD(++angle); // Here's where all the magic happens. This functions fills the matrix we // pass in with a rotation matrix using the angles we pass for yaw, pitch and // roll. So by parameter: // &matrix -- D3DXMATRIX to be filled with the resulting rotation matrix // angInRad -- Angle in radians to rotate around the Y-axis // angInRad -- Angle in radians to rotate around the X-axis // angInRad -- Angle in radians to rotate around the Z-axis D3DXMatrixRotationYawPitchRoll(&matrix, angInRad, angInRad, angInRad); // Set the world matrix // By doing this we apply our rotated matrix to anything we render until // we set the world matrix to something different g3D->setWorldMatrix(&matrix); // Render the cube g3D->render(gCubeVerts, 8, gCubeIndices, 36); g3D->end(); // End the scene } // DirectXion /* Indexed buffers are the way to go when drawing objects that have vertices used by more than one primitive, which is generally most models. The D3DXMatrixRotationYawPitchRoll() function is a great way to fill a matrix with a rotation around all three axis. Check out some of these other nice D3D functions for other rotation needs: D3DXMatrixRotationX() // Rotates around X-axis D3DXMatrixRotationY() // Rotates around Y-axis D3DXMatrixRotationZ() // Rotates around Z-axis D3DXMatrixRotationAxis() // Rotates around arbitrary axis Questions??? Be sure to post 'em at www.GameTutorials.com */ /*-------------------------*\ | Programmed by: TheTutor | | ©2000-2006 GameTutorials | \*-------------------------*/
[ "staff@gametutorials.com" ]
staff@gametutorials.com
bd7a8f9001a900de457fd3e9e33b53c16105e899
5988ea61f0a5b61fef8550601b983b46beba9c5d
/3rd/ACE-5.7.0/ACE_wrappers/apps/drwho/PMS_Usr.cpp
81c4699d3df27da6aead913e2bc69075312e6a5f
[ "MIT" ]
permissive
binghuo365/BaseLab
e2fd1278ee149d8819b29feaa97240dec7c8b293
2b7720f6173672efd9178e45c3c5a9283257732a
refs/heads/master
2016-09-15T07:50:48.426709
2016-05-04T09:46:51
2016-05-04T09:46:51
38,291,364
1
2
null
null
null
null
UTF-8
C++
false
false
2,278
cpp
// $Id: PMS_Usr.cpp 80826 2008-03-04 14:51:23Z wotte $ #include "Options.h" #include "SL_Server.h" #include "PMS_Usr.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_Memory.h" // This function "encodes" a list of friends by putting the userid's in // a contiguous block. This block can then be transmitted over to the // network to servers on other subnets. Several things are added to // make decoding easier on the other end: // // * A count of the number of friends is prepended (assumption: there // are no more than 9999999 friends... ;-)) // * The login userids are separated by a single space. */ int PMS_Usr::encode (char *packet, int &packet_length) { if (Options::get_opt (Options::DEBUGGING) != 0) ACE_DEBUG ((LM_DEBUG, "in PMS_Usr::encode")); char *buf_ptr = packet; // We only send back info on friend that is actually logged in. Protocol_Record *prp = this->get_next_friend (); if (prp) { buf_ptr = this->handle_protocol_entries (ACE_OS::strecpy (buf_ptr, prp->get_login ()), prp->get_drwho_list ()); *buf_ptr++ = '\t'; } *buf_ptr++ = '\n'; packet_length = buf_ptr - packet; if (Options::get_opt (Options::DEBUGGING) != 0) { ACE_DEBUG ((LM_DEBUG, "packet_length = %d\n", packet_length)); ACE_OS::write (ACE_STDERR, packet, packet_length); ACE_DEBUG ((LM_DEBUG, "\n")); } return 1; } // This function takes a packet received from the client and calls the // appropriate Protocol_Manager routine to build the local table of // friends. int PMS_Usr::decode (char *packet, int &packet_length) { if (Options::get_opt (Options::DEBUGGING) != 0) { ACE_DEBUG ((LM_DEBUG, "in PMS_Usr::decode, packet_length = %d\n", packet_length)); ACE_OS::write (ACE_STDERR, packet, packet_length); ACE_DEBUG ((LM_DEBUG, "\n")); } ACE_NEW_RETURN (this->ss, SL_Server (packet), -1); return 1; } PMS_Usr::PMS_Usr (void) { }
[ "binghuo365@hotmail.com" ]
binghuo365@hotmail.com
d2f3c723fd7fc9d44ed466a8b63de17a707fbe30
51a6a2ff1ce6c36e5f601196331645f38916a032
/넷겜플 충돌처리 (2)/SimpleGame/Block.h
60a092122150b2dbee92d27a75a7c2c2523bfe02
[]
no_license
psshoon/NetGameple_hhh
bc2ac3aae6669b41466b06181f3fe8e7ab84ad9c
fe57f78083b21d4ccb4c05ade144e524606c8528
refs/heads/master
2021-08-22T20:59:35.170084
2017-12-01T08:03:51
2017-12-01T08:03:51
109,956,336
0
0
null
null
null
null
UTF-8
C++
false
false
221
h
#pragma once #include "Define.h" #include "Object.h" class Block : public Object { public: Block(); virtual ~Block(); private: public: virtual void SetType(ObjType tType); virtual void update(float elapsedTime); };
[ "psshoon123@naver.com" ]
psshoon123@naver.com
ceef1fa6c7dc3de7cfad8b6c615f55745fd2db2b
8362abae46af490be7d8f2089d97a7a40363de0f
/src/randomize/Distrib.h
2fe4c4db9323bbd72d2ff67382ee3e49b1d997e7
[]
no_license
canercandan/randomize
0753444b81c369871738028d2149e7023bfdc2c5
ff2d13414cc0e94eaeb3373d767e4d442682d299
refs/heads/master
2021-01-01T16:55:52.054473
2011-02-26T15:01:21
2011-02-26T15:01:21
1,371,904
0
0
null
null
null
null
UTF-8
C++
false
false
1,181
h
/* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Copyright (C) 2010 Thales group */ /* Authors: Johann Dréo <johann.dreo@thalesgroup.com> Caner Candan <caner.candan@thalesgroup.com> */ #ifndef _randomize_Distrib_h #define _randomize_Distrib_h #include <core_library/Object.h> namespace randomize { template < typename Atom > class Distrib// : public core_library::Object { public: //! Alias for the type typedef Atom AtomType; virtual ~Distrib(){} }; } #endif // !_randomize_Distrib_h
[ "caner@candan.fr" ]
caner@candan.fr
18a0c52a28fe1bda5c4ae1fa0d0f1695edcc7da4
d8d4b0f9120385fdd78c142b291bce3994a5008d
/SDK/BP_Logo_classes.h
6e7e5250766c72e6035edf0172e5b57b79ca1eda
[]
no_license
xnf4o/DBD_SDK_460
e0dc30ee6fc250478be10171c99776a1172f66ab
efd4049148a88a6ea67643c89f5820b7096e23f8
refs/heads/main
2023-03-30T21:02:20.509098
2021-04-03T01:55:57
2021-04-03T01:55:57
354,176,407
2
0
null
null
null
null
UTF-8
C++
false
false
3,852
h
#pragma once // Name: DBD, Version: 4.6.0 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BP_Logo.BP_Logo_C // 0x0050 (FullSize[0x0280] - InheritedSize[0x0230]) class UBP_Logo_C : public Uactor { public: struct FPointerToUberGraphFrame UberGraphFrame; // 0x0230(0x0008) (ZeroConstructor, Transient, DuplicateTransient) class UMaterialHelper* MaterialHelper; // 0x0238(0x0008) (BlueprintVisible, ZeroConstructor, InstancedReference, IsPlainOldData, NonTransactional, NoDestructor, HasGetValueTypeHash) class UStaticMeshComponent* Cube; // 0x0240(0x0008) (BlueprintVisible, ZeroConstructor, InstancedReference, IsPlainOldData, NonTransactional, NoDestructor, HasGetValueTypeHash) class USceneComponent* DefaultSceneRoot; // 0x0248(0x0008) (BlueprintVisible, ZeroConstructor, InstancedReference, IsPlainOldData, NonTransactional, NoDestructor, HasGetValueTypeHash) float Timeline_0_Fade_E88DB81340E64A2D6C8133B1212395F5; // 0x0250(0x0004) (ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) float Timeline_0_Timing_E88DB81340E64A2D6C8133B1212395F5; // 0x0254(0x0004) (ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) TEnumAsByte<Engine_ETimelineDirection> Timeline_0__Direction_E88DB81340E64A2D6C8133B1212395F5; // 0x0258(0x0001) (ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) unsigned char UnknownData_H7K4[0x7]; // 0x0259(0x0007) MISSED OFFSET (FIX SPACE BETWEEN PREVIOUS PROPERTY) class UTimelineComponent* Timeline_1; // 0x0260(0x0008) (BlueprintVisible, ZeroConstructor, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash) float Anim_Fade_89F4B59C42CBB8068E84979C128BB364; // 0x0268(0x0004) (ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) float Anim_Timing_89F4B59C42CBB8068E84979C128BB364; // 0x026C(0x0004) (ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) TEnumAsByte<Engine_ETimelineDirection> Anim__Direction_89F4B59C42CBB8068E84979C128BB364; // 0x0270(0x0001) (ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) unsigned char UnknownData_PAG8[0x7]; // 0x0271(0x0007) MISSED OFFSET (FIX SPACE BETWEEN PREVIOUS PROPERTY) class UTimelineComponent* Anim; // 0x0278(0x0008) (BlueprintVisible, ZeroConstructor, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash) static UClass* StaticClass() { static auto ptr = nullptr; if (!ptr) ptr = UObject::FindClass("BlueprintGeneratedClass BP_Logo.BP_Logo_C"); return ptr; } void Anim__FinishedFunc(); void Anim__UpdateFunc(); void Timeline_0__FinishedFunc(); void Timeline_0__UpdateFunc(); void ReceiveBeginPlay(); void ExecuteUbergraph_BP_Logo(int EntryPoint); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "xnf4o@inbox.ru" ]
xnf4o@inbox.ru
bbdfd479ca7824a3196e9ee12bc4af19103ec5e5
fca02b395fe1a5d9ae3180466f7c9ca7703c46e9
/HC-SR04/ping_satyam/sketch_mar04a/sketch_mar04a.ino
4a18c5d7a02fe327576f0e234c68e466ec541e03
[]
no_license
Naman311/ReconSubsea-Trainee
d795690ad613184789535323f4607e50f719d30b
582b1668f5948c6672dd691b76d8218cbadee6d4
refs/heads/master
2021-04-27T00:22:37.367003
2018-04-02T19:55:44
2018-04-02T19:55:44
123,801,355
1
0
null
null
null
null
UTF-8
C++
false
false
649
ino
long duration,distance; void setup() { pinMode(LED_BUILTIN, OUTPUT); pinMode(4, OUTPUT); pinMode(12, INPUT); Serial.begin(9600); } void loop() { digitalWrite(4, LOW); //Output to pin 4: 0 delayMicroseconds(2); digitalWrite(4, HIGH); //Output to pin4: 5V delayMicroseconds(10); digitalWrite(4, LOW); //Output to pin 4: 0 duration = pulseIn(12, HIGH); //Input from pin 12 distance= duration*0.034/2; Serial.println("Distance: "); Serial.println(distance); if(distance<15) { Serial.print("Condition Fulfilled"); digitalWrite(LED_BUILTIN, HIGH); delayMicroseconds(2000); digitalWrite(LED_BUILTIN, LOW); } delayMicroseconds(10); }
[ "36452790+satyamambast@users.noreply.github.com" ]
36452790+satyamambast@users.noreply.github.com
cd67eb57eee508346e2163294683200e329a28c4
88b991fc54265c13f62710393169839676f2ffd2
/Lib/Settings/MemSettings.h
4b8e2021073a9006e0178a27413c1df01ddace1f
[]
no_license
RATime360/Code
4b51c6af12e73bd77becf44067aee8d0c97101fe
6694bfd7c71d0247911d02ab6e0c3c41e3479900
refs/heads/master
2023-01-14T10:01:53.356289
2020-11-18T06:41:46
2020-11-18T06:41:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
935
h
#pragma once #include <QMap> #include <Lib/Include/Common.h> #include "SettingsA.h" DefineClassS(QSettings); DefineClassS(MemSettings); class MemSettings: public SettingsA { QMap<QString, QVariant> mDictionary; QString mPrefix; public: /*override */virtual bool Open(const QString&) Q_DECL_OVERRIDE; /*override */virtual bool Sync() Q_DECL_OVERRIDE; /*override */virtual bool BeginGroup(const QString& prefix) Q_DECL_OVERRIDE; /*override */virtual void EndGroup() Q_DECL_OVERRIDE; /*override */virtual QVariant GetMandatoryValue(const QString& key, bool fatal = false) Q_DECL_OVERRIDE; /*override */virtual QVariant GetValue(const QString& key, const QVariant& defaultValue = QVariant()) Q_DECL_OVERRIDE; /*override */virtual void SetValue(const QString& key, const QVariant& value) Q_DECL_OVERRIDE; public: MemSettings(); /*override */~MemSettings(); };
[ "DevilCCCP@gmail.com" ]
DevilCCCP@gmail.com
ddd78e224b5286b95af21ef4075b01e5e1e3a003
6e392062306dbaf5214f61daa6be91c5792fc401
/stack_queues/queueStack.cpp
b238551413b4624572e97ed91ffba504bb9c365a
[]
no_license
NileshKumarGupta/dsaPractice
b1e959441a73247746d0f52d7c3bde5fb52ac1d3
9c431aaae4e9a19c1ab975cd8342f7c0b0415ab5
refs/heads/master
2022-11-09T12:49:26.864730
2020-06-19T15:49:09
2020-06-19T15:49:09
272,737,315
0
0
null
null
null
null
UTF-8
C++
false
false
1,531
cpp
#include<iostream> #include<bits/stdc++.h> using namespace std; class MyQueue{ private: stack<int> forward; stack<int> backward; public: void enqueue(int val){ if(forward.empty()){ int stack_size = backward.size(); for(int i = 0; i < stack_size; i++){ int top_val = backward.top(); forward.push(top_val); backward.pop(); } } forward.push(val); } int dequeue(){ if(backward.empty()){ int stack_size = forward.size(); if(!stack_size) return -1; for(int i = 0; i < stack_size; i++){ int top_val = forward.top(); backward.push(top_val); forward.pop(); } } int return_val = backward.top(); backward.pop(); return return_val; } }; int main(){ cout<<"Hello World\n"; MyQueue myqueue = MyQueue(); myqueue.enqueue(1); myqueue.enqueue(2); cout<<myqueue.dequeue()<<endl; myqueue.enqueue(3); myqueue.enqueue(4); cout<<myqueue.dequeue()<<endl; myqueue.enqueue(5); myqueue.enqueue(6); cout<<myqueue.dequeue()<<endl; cout<<myqueue.dequeue()<<endl; myqueue.enqueue(7); cout<<myqueue.dequeue()<<endl; cout<<myqueue.dequeue()<<endl; myqueue.enqueue(8); cout<<myqueue.dequeue()<<endl; cout<<myqueue.dequeue()<<endl; cout<<myqueue.dequeue()<<endl; myqueue.enqueue(9); cout<<myqueue.dequeue()<<endl; myqueue.enqueue(3); myqueue.enqueue(0); cout<<myqueue.dequeue()<<endl; }
[ "f20180233@goa.bits-pilani.ac.in" ]
f20180233@goa.bits-pilani.ac.in
882cca8a1664c240f4bd39c4e556349e4a7d88ad
bd1fea86d862456a2ec9f56d57f8948456d55ee6
/000/073/692/CWE124_Buffer_Underwrite__CWE839_fscanf_83a.cpp
e2e66ada32698621c8d453723692ddd73b05990a
[]
no_license
CU-0xff/juliet-cpp
d62b8485104d8a9160f29213368324c946f38274
d8586a217bc94cbcfeeec5d39b12d02e9c6045a2
refs/heads/master
2021-03-07T15:44:19.446957
2020-03-10T12:45:40
2020-03-10T12:45:40
246,275,244
0
1
null
null
null
null
UTF-8
C++
false
false
2,255
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE124_Buffer_Underwrite__CWE839_fscanf_83a.cpp Label Definition File: CWE124_Buffer_Underwrite__CWE839.label.xml Template File: sources-sinks-83a.tmpl.cpp */ /* * @description * CWE: 124 Buffer Underwrite * BadSource: fscanf Read data from the console using fscanf() * GoodSource: Non-negative but less than 10 * Sinks: * GoodSink: Ensure the array index is valid * BadSink : Improperly check the array index by not checking the lower bound * Flow Variant: 83 Data flow: data passed to class constructor and destructor by declaring the class object on the stack * * */ #include "std_testcase.h" #include "CWE124_Buffer_Underwrite__CWE839_fscanf_83.h" namespace CWE124_Buffer_Underwrite__CWE839_fscanf_83 { #ifndef OMITBAD void bad() { int data; /* Initialize data */ data = -1; CWE124_Buffer_Underwrite__CWE839_fscanf_83_bad badObject(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ static void goodG2B() { int data; /* Initialize data */ data = -1; CWE124_Buffer_Underwrite__CWE839_fscanf_83_goodG2B goodG2BObject(data); } /* goodG2B uses the BadSource with the GoodSink */ static void goodB2G() { int data; /* Initialize data */ data = -1; CWE124_Buffer_Underwrite__CWE839_fscanf_83_goodB2G goodB2GObject(data); } void good() { goodG2B(); goodB2G(); } #endif /* OMITGOOD */ } /* close namespace */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE124_Buffer_Underwrite__CWE839_fscanf_83; /* so that we can use good and bad easily */ int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
[ "frank@fischer.com.mt" ]
frank@fischer.com.mt
a825bf50d74e69d73c9e6543b397d1126d9603c3
d1b03d4b061305018084b4dc21a4bdba35335c05
/Plugins/SocketIOClient/Source/ThirdParty/websocketpp/test/processors/extension_permessage_compress.cpp
7f26a9dd521db94cf6cd560c9e08b89d96ce6da6
[ "Apache-2.0", "MIT", "Zlib", "BSD-3-Clause" ]
permissive
uetopia/ExampleGame
004b9f1a6f93c725750a82b51cac8d8516c3b769
008ab5d3e817ef763fa42ed551715208682a7ecf
refs/heads/master
2023-03-08T07:56:55.819372
2023-02-26T14:59:42
2023-02-26T14:59:42
205,035,752
36
16
Apache-2.0
2020-05-23T22:14:35
2019-08-28T22:42:22
C++
UTF-8
C++
false
false
7,369
cpp
/* * Copyright (c) 2014, Peter Thorson. 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 WebSocket++ Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON 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. * */ //#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE extension_permessage_deflate #include <boost/test/unit_test.hpp> #include <iostream> #include <string> #include <websocketpp/common/memory.hpp> #include <websocketpp/http/request.hpp> #include <websocketpp/extensions/permessage_deflate/enabled.hpp> struct config { typedef websocketpp::http::parser::request request_type; }; typedef websocketpp::extensions::permessage_deflate::enabled<config> compressor_type; using namespace websocketpp; BOOST_AUTO_TEST_CASE( deflate_init ) { /*compressor_type compressor; websocketpp::http::parser::attribute_list attributes; std::pair<lib::error_code,std::string> neg_ret; neg_ret = compressor.negotiate(attributes); BOOST_CHECK_EQUAL( neg_ret.first, extensions::permessage_deflate::error::invalid_parameters );*/ /** * Window size is primarily controlled by the writer. A stream can only be * read by a window size equal to or greater than the one use to compress * it initially. The default windows size is also the maximum window size. * Thus: * * Outbound window size can be limited unilaterally under the assumption * that the opposite end will be using the default (maximum size which can * read anything) * * Inbound window size must be limited by asking the remote endpoint to * do so and it agreeing. * * Context takeover is also primarily controlled by the writer. If the * compressor does not clear its context between messages then the reader * can't either. * * Outbound messages may clear context between messages unilaterally. * Inbound messages must retain state unless the remote endpoint signals * otherwise. * * Negotiation options: * Client must choose from the following options: * - whether or not to request an inbound window limit * - whether or not to signal that it will honor an outbound window limit * - whether or not to request that the server disallow context takeover * * Server must answer in the following ways * - If client requested a window size limit, is the window size limit * acceptable? * - If client allows window limit requests, should we send one? * - If client requested no context takeover, should we accept? * * * * All Defaults * Req: permessage-compress; method=deflate * Ans: permessage-compress; method=deflate * * # Client wants to limit the size of inbound windows from server * permessage-compress; method="deflate; s2c_max_window_bits=8, deflate" * Ans: permessage-compress; method="deflate; s2c_max_window_bits=8" * OR * Ans: permessage-compress; method=deflate * * # Server wants to limit the size of inbound windows from client * Client: * permessage-compress; method="deflate; c2s_max_window_bits, deflate" * * Server: * permessage-compress; method="deflate; c2s_max_window_bits=8" * * # Client wants to * * * * * * */ /* processor::extensions::deflate_method d(true); http::parser::attribute_list attributes; lib::error_code ec; attributes.push_back(http::parser::attribute("foo","bar")); ec = d.init(attributes); BOOST_CHECK(ec == processor::extensions::error::unknown_method_parameter); attributes.clear(); attributes.push_back(http::parser::attribute("s2c_max_window_bits","bar")); ec = d.init(attributes); BOOST_CHECK(ec == processor::extensions::error::invalid_algorithm_settings); attributes.clear(); attributes.push_back(http::parser::attribute("s2c_max_window_bits","7")); ec = d.init(attributes); BOOST_CHECK(ec == processor::extensions::error::invalid_algorithm_settings); attributes.clear(); attributes.push_back(http::parser::attribute("s2c_max_window_bits","16")); ec = d.init(attributes); BOOST_CHECK(ec == processor::extensions::error::invalid_algorithm_settings); attributes.clear(); attributes.push_back(http::parser::attribute("s2c_max_window_bits","9")); ec = d.init(attributes); BOOST_CHECK( !ec); attributes.clear(); ec = d.init(attributes); BOOST_CHECK( !ec); processor::extensions::deflate_engine de; unsigned char test_in[] = "HelloHelloHelloHello"; unsigned char test_out[30]; uLongf test_out_size = 30; int ret; ret = compress(test_out, &test_out_size, test_in, 20); std::cout << ret << std::endl << websocketpp::utility::to_hex(test_in,20) << std::endl << websocketpp::utility::to_hex(test_out,test_out_size) << std::endl; std::string input = "Hello"; std::string output; ec = de.compress(input,output); BOOST_CHECK( ec == processor::extensions::error::uninitialized ); //std::cout << ec.message() << websocketpp::utility::to_hex(output) << std::endl; ec = de.init(15,15,Z_DEFAULT_COMPRESSION,8,Z_FIXED); //ec = de.init(); BOOST_CHECK( !ec ); ec = de.compress(input,output); std::cout << ec.message() << std::endl << websocketpp::utility::to_hex(input) << std::endl << websocketpp::utility::to_hex(output) << std::endl; output.clear(); ec = de.compress(input,output); std::cout << ec.message() << std::endl << websocketpp::utility::to_hex(input) << std::endl << websocketpp::utility::to_hex(output) << std::endl; input = output; output.clear(); ec = de.decompress(input,output); std::cout << ec.message() << std::endl << websocketpp::utility::to_hex(input) << std::endl << websocketpp::utility::to_hex(output) << std::endl; */ }
[ "ed@uetopia.com" ]
ed@uetopia.com
67991ffeac1da5a8c5f861872792e32e241c5c05
32440b53eb897b377a44b7838719b6a66f2283ef
/src/mobius/ActorComponent.hpp
48a500870469f795e3d9e79aa3a82b1dfde24657
[ "Zlib", "LicenseRef-scancode-unknown-license-reference" ]
permissive
madeso/lolball
7f904900be5acb55ee37fca342ecb4cfe3dcd342
18d831efa9978a07808fcfa51a7cda4925e1ac14
refs/heads/master
2020-06-05T12:23:00.462002
2014-09-24T06:00:50
2014-09-24T06:00:50
24,402,678
0
0
null
null
null
null
UTF-8
C++
false
false
387
hpp
#ifndef ACTOR_COMPONENT_HPP #define ACTOR_COMPONENT_HPP #include "Component3.hpp" class Actor; class ActorComponent : public Component3 { public: ActorComponent(Actor* pActor); virtual void onRender(const World3& pWorld, real pTime, RenderMode& pRenderMode) const = 0; void render(const World3& pWorld, real pTime, RenderMode pRenderMode) const; private: Actor* mActor; }; #endif
[ "sir.gustav.the.coder@gmail.com" ]
sir.gustav.the.coder@gmail.com
0f26b791b4d5cb62353d795532de550f25890039
95570ae3de9febfe81989751982f6a6eafe080ff
/Sources/Database/db_value.cpp
0f65e13ffc96cafa8158a297e36742dbe50f3e0b
[ "Zlib" ]
permissive
kyelin/ClanLib
a552f224c2007598a1ab8acaf4e2caa967908851
2558aba725e6866a81d50b13178cbd5c60ab6edc
refs/heads/master
2021-01-24T21:36:07.499397
2014-11-18T02:09:39
2014-11-18T02:09:39
19,273,763
0
0
null
null
null
null
UTF-8
C++
false
false
3,337
cpp
/* ** ClanLib SDK ** Copyright (c) 1997-2013 The ClanLib Team ** ** This software is provided 'as-is', without any express or implied ** warranty. In no event will the authors be held liable for any damages ** arising from the use of this software. ** ** Permission is granted to anyone to use this software for any purpose, ** including commercial applications, and to alter it and redistribute it ** freely, subject to the following restrictions: ** ** 1. The origin of this software must not be misrepresented; you must not ** claim that you wrote the original software. If you use this software ** in a product, an acknowledgment in the product documentation would be ** appreciated but is not required. ** 2. Altered source versions must be plainly marked as such, and must not be ** misrepresented as being the original software. ** 3. This notice may not be removed or altered from any source distribution. ** ** Note: Some of the libraries ClanLib may link to may have additional ** requirements or restrictions. ** ** File Author(s): ** ** Magnus Norddahl ** Animehunter */ #include "Database/precomp.h" #include "API/Database/db_reader.h" #include "API/Database/db_connection.h" #include "API/Core/System/datetime.h" #include "API/Core/System/databuffer.h" #include "API/Database/db_value.h" #include "db_connection_impl.h" #include "db_reader_impl.h" namespace clan { DBValue::DBValue() { } DBValue::DBValue(const DBReader &db_reader, int column_index) : db_reader(db_reader), column_index(column_index), param_type(cl_index) { } DBValue::DBValue(const DBReader &db_reader, const std::string &column_name) : db_reader(db_reader), column_name(column_name), param_type(cl_name) { } int DBValue::to_integer() const { if (param_type == cl_index) { return db_reader.get_column_int(column_index); } else if (param_type == cl_name) { return db_reader.get_column_int(column_name); } else throw Exception("Invalid column type!"); } std::string DBValue::to_string() const { if (param_type == cl_index) { return db_reader.get_column_string(column_index); } else if (param_type == cl_name) { return db_reader.get_column_string(column_name); } else throw Exception("Invalid column type!"); } bool DBValue::to_boolean() const { if (param_type == cl_index) { return db_reader.get_column_bool(column_index); } else if (param_type == cl_name) { return db_reader.get_column_bool(column_name); } else throw Exception("Invalid column type!"); } double DBValue::to_double() const { if (param_type == cl_index) { return db_reader.get_column_double(column_index); } else if (param_type == cl_name) { return db_reader.get_column_double(column_name); } else throw Exception("Invalid column type!"); } DataBuffer DBValue::to_binary() const { if (param_type == cl_index) { return db_reader.get_column_binary(column_index); } else if (param_type == cl_name) { return db_reader.get_column_binary(column_name); } else throw Exception("Invalid column type!"); } DateTime DBValue::to_datetime() const { if (param_type == cl_index) { return db_reader.get_column_datetime(column_index); } else if (param_type == cl_name) { return db_reader.get_column_datetime(column_name); } else throw Exception("Invalid column type!"); } }
[ "rombust@hotmail.co.uk" ]
rombust@hotmail.co.uk
af6a0769f9e0bdb796c057a3730d6d754d5de594
1ac739e73f504b88275bf3a2ce7f6649c4736331
/SDK/ANAREA_AppleImageUtils_parameters.hpp
62c4335677338ae0e300409e408ca9a1a397572e
[]
no_license
frankie-11/ANAREA-SDK
d6a0974a72ecf75fc016849883d9118791956e7c
b49808b7e1c33afead53c577f88ab7ff89aa993e
refs/heads/master
2022-12-01T06:52:19.732996
2020-08-16T16:13:38
2020-08-16T16:13:38
287,978,810
1
0
null
null
null
null
UTF-8
C++
false
false
5,211
hpp
#pragma once // ANAREA (4.24) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace SDK { //--------------------------------------------------------------------------- //Parameters //--------------------------------------------------------------------------- // Function AppleImageUtils.AppleImageUtilsBaseAsyncTaskBlueprintProxy.CreateProxyObjectForConvertToTIFF struct UAppleImageUtilsBaseAsyncTaskBlueprintProxy_CreateProxyObjectForConvertToTIFF_Params { class UTexture** SourceImage; // (Parm, ZeroConstructor, IsPlainOldData) bool* bWantColor; // (Parm, ZeroConstructor, IsPlainOldData) bool* bUseGpu; // (Parm, ZeroConstructor, IsPlainOldData) float* Scale; // (Parm, ZeroConstructor, IsPlainOldData) ETextureRotationDirection* Rotate; // (Parm, ZeroConstructor, IsPlainOldData) class UAppleImageUtilsBaseAsyncTaskBlueprintProxy* ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) }; // Function AppleImageUtils.AppleImageUtilsBaseAsyncTaskBlueprintProxy.CreateProxyObjectForConvertToPNG struct UAppleImageUtilsBaseAsyncTaskBlueprintProxy_CreateProxyObjectForConvertToPNG_Params { class UTexture** SourceImage; // (Parm, ZeroConstructor, IsPlainOldData) bool* bWantColor; // (Parm, ZeroConstructor, IsPlainOldData) bool* bUseGpu; // (Parm, ZeroConstructor, IsPlainOldData) float* Scale; // (Parm, ZeroConstructor, IsPlainOldData) ETextureRotationDirection* Rotate; // (Parm, ZeroConstructor, IsPlainOldData) class UAppleImageUtilsBaseAsyncTaskBlueprintProxy* ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) }; // Function AppleImageUtils.AppleImageUtilsBaseAsyncTaskBlueprintProxy.CreateProxyObjectForConvertToJPEG struct UAppleImageUtilsBaseAsyncTaskBlueprintProxy_CreateProxyObjectForConvertToJPEG_Params { class UTexture** SourceImage; // (Parm, ZeroConstructor, IsPlainOldData) int* Quality; // (Parm, ZeroConstructor, IsPlainOldData) bool* bWantColor; // (Parm, ZeroConstructor, IsPlainOldData) bool* bUseGpu; // (Parm, ZeroConstructor, IsPlainOldData) float* Scale; // (Parm, ZeroConstructor, IsPlainOldData) ETextureRotationDirection* Rotate; // (Parm, ZeroConstructor, IsPlainOldData) class UAppleImageUtilsBaseAsyncTaskBlueprintProxy* ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) }; // Function AppleImageUtils.AppleImageUtilsBaseAsyncTaskBlueprintProxy.CreateProxyObjectForConvertToHEIF struct UAppleImageUtilsBaseAsyncTaskBlueprintProxy_CreateProxyObjectForConvertToHEIF_Params { class UTexture** SourceImage; // (Parm, ZeroConstructor, IsPlainOldData) int* Quality; // (Parm, ZeroConstructor, IsPlainOldData) bool* bWantColor; // (Parm, ZeroConstructor, IsPlainOldData) bool* bUseGpu; // (Parm, ZeroConstructor, IsPlainOldData) float* Scale; // (Parm, ZeroConstructor, IsPlainOldData) ETextureRotationDirection* Rotate; // (Parm, ZeroConstructor, IsPlainOldData) class UAppleImageUtilsBaseAsyncTaskBlueprintProxy* ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "60810131+frankie-11@users.noreply.github.com" ]
60810131+frankie-11@users.noreply.github.com
e32c302a2e0f8a55265d47089760e6a98214a303
b20b79c19c61259f527f48a80e48e09987522a37
/Lab3/Lab3-eclipse/Employer.h
ee534f35d527432158ae962cf54eddbf94544a4c
[]
no_license
itsbinay/Comp-2012
103327d9e92d0b8735cb668c242282c30123e8ed
baddee21b4d7b9c211a9be179e134a4c99528206
refs/heads/master
2020-04-26T16:24:13.948038
2019-12-16T18:25:45
2019-12-16T18:25:45
173,677,026
0
0
null
null
null
null
UTF-8
C++
false
false
385
h
// TODO: Class declaration of Employer #ifndef _EMPLOYER_H #define _EMPLOYER_H #include "Person.h" #include "Employee.h" #include <string> using namespace std; class Employer : public Person { private: Employee* employee[NUM_MAX_EMPLOYEE]; int num_of_employee; public: Employer(string name); void pay_salary(); void hire(Employee *employee); }; #endif
[ "binaygurung9@gmail.com" ]
binaygurung9@gmail.com
3b2b18840822ab499eb80d20837623093f4a874b
94e3462eeda77497c6f5f0b16bc17eeb34e4b04e
/src/crypto/hash.h
93c5ec257d7e551cc4a277cfc902553ab72ff7bd
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
pdxxxz/intensecoin
9fec0934923a82135c8b99bbec129719ba3f647a
3a6c59c2f136300400e34729f33d4ed5f3fddc22
refs/heads/master
2020-03-11T04:28:56.881078
2018-04-16T16:02:41
2018-04-16T16:02:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,377
h
// Copyright (c) 2014-2017, The Monero Project // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #pragma once #include <stddef.h> #include "common/pod-class.h" #include "generic-ops.h" namespace crypto { extern "C" { #include "hash-ops.h" } #pragma pack(push, 1) POD_CLASS hash { char data[HASH_SIZE]; }; POD_CLASS hash8 { char data[8]; }; #pragma pack(pop) static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size"); static_assert(sizeof(hash8) == 8, "Invalid structure size"); /* Cryptonight hash functions */ inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) { cn_fast_hash(data, length, reinterpret_cast<char *>(&hash)); } inline hash cn_fast_hash(const void *data, std::size_t length) { hash h; cn_fast_hash(data, length, reinterpret_cast<char *>(&h)); return h; } inline void cn_slow_hash(const void *data, std::size_t length, hash &hash) { cn_slow_hash(data, length, reinterpret_cast<char *>(&hash)); } inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) { tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash)); } inline void tree_branch(const hash* hashes, std::size_t count, hash* branch) { tree_branch(reinterpret_cast<const char(*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char(*)[HASH_SIZE]>(branch)); } inline void tree_hash_from_branch(const hash* branch, std::size_t depth, const hash& leaf, const void* path, hash& root_hash) { tree_hash_from_branch(reinterpret_cast<const char(*)[HASH_SIZE]>(branch), depth, reinterpret_cast<const char*>(&leaf), path, reinterpret_cast<char*>(&root_hash)); } } CRYPTO_MAKE_HASHABLE(hash) CRYPTO_MAKE_COMPARABLE(hash8)
[ "valiant1x@users.noreply.github.com" ]
valiant1x@users.noreply.github.com
9f586472494209c177c0f692ba5c36b5577b2237
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/pdfium/fxbarcode/cbc_codebase.h
250cbf3ce2f767c4dbc9e4a99010a235632c3d0e
[ "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "BSD-3-Clause" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
1,317
h
// Copyright 2016 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #ifndef FXBARCODE_CBC_CODEBASE_H_ #define FXBARCODE_CBC_CODEBASE_H_ #include <stdint.h> #include <memory> #include "core/fxcrt/widestring.h" #include "core/fxge/dib/fx_dib.h" #include "fxbarcode/BC_Library.h" class CBC_Writer; class CFX_Matrix; class CFX_RenderDevice; class CBC_CodeBase { public: explicit CBC_CodeBase(std::unique_ptr<CBC_Writer> pWriter); virtual ~CBC_CodeBase(); virtual BC_TYPE GetType() = 0; virtual bool Encode(WideStringView contents) = 0; virtual bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix& matrix) = 0; void SetTextLocation(BC_TEXT_LOC location); bool SetWideNarrowRatio(int8_t ratio); bool SetStartChar(char start); bool SetEndChar(char end); bool SetErrorCorrectionLevel(int32_t level); void SetCharEncoding(BC_CHAR_ENCODING encoding); bool SetModuleHeight(int32_t moduleHeight); bool SetModuleWidth(int32_t moduleWidth); void SetHeight(int32_t height); void SetWidth(int32_t width); protected: std::unique_ptr<CBC_Writer> m_pBCWriter; }; #endif // FXBARCODE_CBC_CODEBASE_H_
[ "jengelh@inai.de" ]
jengelh@inai.de
fd6da473ef8e24aaa713d9e7c1924f66252d981b
d57c4aff70fcce17969023f380b217c6f4946708
/src/demo04.cpp
514ac2b99c10a0efb06a08c633c272bb6e1bad65
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
johangardhage/dos-bcdemos
ec06eb590bd128566dead632bd0013618fba00d3
285c44bb8d44fc2e2939ec6491e7d5f66a0db98f
refs/heads/master
2020-04-01T21:32:46.733918
2018-10-21T14:47:14
2019-07-22T14:22:31
153,662,056
42
2
null
null
null
null
UTF-8
C++
false
false
4,785
cpp
// // Retro programming in Borland C++ 3.1 // // Environment shading demonstration // #include "lib/types.h" #include "lib/engine.h" #include "lib/graphics.h" #include "lib/misc.h" #include "lib/polygons.h" objecttype *objectptr; colortype palette[256]; char filename[] = "assets/chrmface.3d_"; char metalfile[] = "assets/metal.raw"; char palettefile[] = "assets/metal.pal"; word vscreen, enviromap; void drawfacets ( void ) { screentype *v1, *v2, *v3; int bin, bintotal, binfacet, facet; for ( bin = 79; bin >= 0; bin -- ) { bintotal = bincount[bin]; for ( binfacet = 0; binfacet < bintotal; binfacet ++ ) { // get the facet to be drawn bin_ptr = (word far*)MK_FP ( facetorder, ( bin << 8 ) + ( binfacet << 1 ) ); facet = *bin_ptr; // get the offsets to the vertices of this facet v1 = (screentype*)objectptr->objectfacet[facet].a; v2 = (screentype*)objectptr->objectfacet[facet].b; v3 = (screentype*)objectptr->objectfacet[facet].c; envirotriangle ( v1, v2, v3, enviromap, vscreen ); } bincount[bin] = 0; } } void drawframe ( void ) { cls (vscreen); calcangles (objectptr); initmatrix (); rotatevertices (objectptr); rotatenormalsenviro (objectptr); sortfacets (objectptr); drawfacets (); copyscreen ( vscreen, 0xa000 ); } void main ( void ) { dword startcount, endcount, frames; clrscr (); printf ( "\n" ); printf ( "Environment shading demonstration\n\n" ); printf ( " Runtime controls:\n" ); printf ( " '+' and '-' to change object distance\n" ); printf ( " '8' and '2' to change object x rotation\n" ); printf ( " '4' and '6' to change object y rotation\n" ); printf ( " '7' and '9' to change object z rotation\n" ); printf ( " '5' to center object\n\n" ); printf ( " 'spacebar' to toggle rotations\n" ); printf ( " 'q' or 'esc' to quit\n\n" ); printf ( " Press a key to start demonstration" ); getch (); objectptr = initobject (filename); enviromap = initpicture (metalfile); initpalette (palettefile, palette); initsincos (); facetorder = initvirtual (65536); objectptr->rotation = true; objectptr->xrotation = 128; objectptr->yrotation = 0; objectptr->zrotation = 0; objectptr->zdepth = 200; objectptr->xinc = 1; objectptr->yinc = 1; objectptr->zinc = 1; vscreen = initvirtual (65536); setgfxmode(0x13); introsequence (); frames = 0; startcount = gettickcount (); boolean leave = false; do { if ( objectptr->rotation ) { drawframe (); frames ++; } if ( kbhit () ) switch ( getch () ) { // do you want to quit? case 'q': case 27 : leave = true; break; // toggle rotation case ' ': objectptr->rotation = ( objectptr->rotation == false ); break; // increase x rotation case '2' : objectptr->xinc ++; if ( objectptr->xinc > MAX_DELTA ) objectptr->xinc = MAX_DELTA; break; // decrease x rotation case '8' : objectptr->xinc --; if ( objectptr->xinc < -MAX_DELTA ) objectptr->xinc = -MAX_DELTA; break; // increase y rotation case '6' : objectptr->yinc ++; if ( objectptr->yinc > MAX_DELTA ) objectptr->yinc = MAX_DELTA; break; // decrease y rotation case '4' : objectptr->yinc --; if ( objectptr->yinc < -MAX_DELTA ) objectptr->yinc = -MAX_DELTA; break; // increase z rotation case '9' : objectptr->zinc ++; if ( objectptr->zinc > MAX_DELTA ) objectptr->zinc = MAX_DELTA; break; // decrease z rotation case '7' : objectptr->zinc --; if ( objectptr->zinc < -MAX_DELTA ) objectptr->zinc = -MAX_DELTA; break; // center object case '5' : objectptr->rotation = true; objectptr->xrotation = 128; objectptr->yrotation = 0; objectptr->zrotation = 0; objectptr->zdepth = 200; objectptr->xinc = 0; objectptr->yinc = 0; objectptr->zinc = 0; break; // push the object father away case '+' : objectptr->zdepth += 10; if ( objectptr->zdepth > 2000 ) objectptr->zdepth = 2000; break; // bring the object closer case '-' : objectptr->zdepth -= 10; if ( objectptr->zdepth < 200 ) objectptr->zdepth = 200; break; } } while ( !leave ); endcount = gettickcount (); exitsequence (); setgfxmode(0x03); clrscr (); printf ("\n"); printf (" Runtime statistics:\n"); // printf (" Vertices in object - %i\n", totalvertices ); // printf (" Faces in object - %i\n", totalfacets ); printf (" Average Frames Per Second - %f\n\n", (frames*18.2)/(endcount-startcount) ); }
[ "johan.gardhage@gmail.com" ]
johan.gardhage@gmail.com
281bf4675d263353232994ea515fc0d137fc6062
254d642700c75f2ef659a968e778f1ae56b084e3
/exp7-5/exp7-5/exp7-5.cpp
071c1444bc020d5cf54d0a830bc020e29c5ffcee
[]
no_license
cf-GitHub-114/experiments-of-VC
89e5c283258346b05326c890122b55bdcc19aa48
d131b2e1cccd695b8cfe4461037f63a4e716a3d5
refs/heads/master
2021-05-18T10:04:14.209289
2020-07-10T20:55:22
2020-07-10T20:55:22
251,201,578
0
0
null
null
null
null
GB18030
C++
false
false
4,423
cpp
// exp7-5.cpp : 定义应用程序的类行为。 // #include "stdafx.h" #include "afxwinappex.h" #include "afxdialogex.h" #include "exp7-5.h" #include "MainFrm.h" #include "exp7-5Doc.h" #include "exp7-5View.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // Cexp75App BEGIN_MESSAGE_MAP(Cexp75App, CWinApp) ON_COMMAND(ID_APP_ABOUT, &Cexp75App::OnAppAbout) // 基于文件的标准文档命令 ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen) END_MESSAGE_MAP() // Cexp75App 构造 Cexp75App::Cexp75App() { // 支持重新启动管理器 m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; #ifdef _MANAGED // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: // 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 // 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); #endif // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 //为 CompanyName.ProductName.SubProduct.VersionInformation SetAppID(_T("exp7-5.AppID.NoVersion")); // TODO: 在此处添加构造代码, // 将所有重要的初始化放置在 InitInstance 中 } // 唯一的一个 Cexp75App 对象 Cexp75App theApp; // Cexp75App 初始化 BOOL Cexp75App::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); // 初始化 OLE 库 if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // 使用 RichEdit 控件需要 AfxInitRichEdit2() // AfxInitRichEdit2(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) // 注册应用程序的文档模板。 文档模板 // 将用作文档、框架窗口和视图之间的连接 CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(Cexp75Doc), RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 RUNTIME_CLASS(Cexp75View)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 分析标准 shell 命令、DDE、打开文件操作的命令行 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 调度在命令行中指定的命令。 如果 // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 if (!ProcessShellCommand(cmdInfo)) return FALSE; // 唯一的一个窗口已初始化,因此显示它并对其进行更新 m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; } int Cexp75App::ExitInstance() { //TODO: 处理可能已添加的附加资源 AfxOleTerm(FALSE); return CWinApp::ExitInstance(); } // Cexp75App 消息处理程序 // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 class CAboutDlg : public CDialogEx { public: CAboutDlg(); // 对话框数据 #ifdef AFX_DESIGN_TIME enum { IDD = IDD_ABOUTBOX }; #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 // 实现 protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) END_MESSAGE_MAP() // 用于运行对话框的应用程序命令 void Cexp75App::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } // Cexp75App 消息处理程序
[ "1061737971@qq.com" ]
1061737971@qq.com
3e6cf0f66539a9a53233237ebe14dad2ebe9786e
076d699d2ad3c97603a514224634b774271647fb
/AGC028/first.cpp
bff6e67394a907ed4806e8a548bbd5c1b6b46b47
[]
no_license
siberiy4/comp_prog
2d3e612561239cc48226c572cb67187eddd9e952
3ca7070f9ae4ef1aff6d1a39ce8492a076204793
refs/heads/master
2022-12-06T21:23:35.191599
2019-08-18T14:52:02
2019-08-18T14:52:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
112
cpp
#include<iostream> #include <cmath> #include <cstdio> using namespace std; main(){ long double X,pie; }
[ "e1n17075@st.oit.ac.jp" ]
e1n17075@st.oit.ac.jp
84c1af4d4314f6fe68ca1d769f7d0e6e688d7e6f
65e00876bdb944938fc9f80f74c98372268d4d3d
/array/array19.cpp
b953808aa60ede4173c1faffe5f66912a19a343f
[]
no_license
nipunarora-eGov/Coding-Interview-101
372086b1e80f03e3f00a7b5b8616e0966c0a29f6
9fda66bfe0afedc2d161b1657e75a286a0ccdb9e
refs/heads/main
2023-02-15T07:59:33.433792
2021-01-06T09:57:42
2021-01-06T09:57:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
177
cpp
/*take three pointers i,j,k pointing at the start of every array initially increment pointer who points the smallest value if all three point to same element then store in ans*/
[ "aroranipun1@gmail.com" ]
aroranipun1@gmail.com
0c2e6a1b87b163bfe51e77b71715ea62530dd939
01528a046e1c5bfaa1e1b94d30babb35675c9f3a
/trunk/iWinOnline-cocos2dx/iwin/Classes/Network/JsonObject/Game/GetMinMaxBoard.h
688ebdce3cba37943e41fa0fcfcc0a0bc0c6c6b7
[]
no_license
flowerfx/cc_iw_game
f48802b355baaaff887e289d7cd97d2ba8f58082
81309a8651e2ec089d1bd08a07cacb0949d05df7
refs/heads/master
2021-01-21T15:32:22.670075
2020-05-08T09:15:50
2020-05-08T09:15:50
81,444,503
0
2
null
null
null
null
UTF-8
C++
false
false
654
h
#ifndef _GetMinMaxBoard_H_ #define _GetMinMaxBoard_H_ #include "platform/CCPlatformMacros.h" #include <string> #include "json/document.h" #include <vector> #include "Common/Common.h" namespace iwinmesage { class GetMinMaxBoard { CC_SYNTHESIZE(int, gameId, GameId); CC_SYNTHESIZE(int, roomID, RoomID); CC_SYNTHESIZE(int, boardID, BoardID); CC_SYNTHESIZE(int, minMoney, MinMoney); CC_SYNTHESIZE(s64, maxMoney, MaxMoney); CC_SYNTHESIZE(s64, maxMoneyRoom, MaxMoneyRoom); public: GetMinMaxBoard(); virtual ~GetMinMaxBoard(); rapidjson::Document toJson(); void toData(std::string json); void toData(rapidjson::Document & json); }; } #endif
[ "qchien.gl@hotmail.com" ]
qchien.gl@hotmail.com
faf8543327f859ec504d448d7876e777d51b5bde
ad715f9713dc5c6c570a5ac51a18b11932edf548
/tensorflow/lite/kernels/internal/reference/legacy_reference_ops.h
3597a78d65afde8f75b0e95131fcf845fa076598
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause" ]
permissive
rockzhuang/tensorflow
f1f31bc8edfa402b748c500efb97473c001bac95
cb40c060b36c6a75edfefbc4e5fc7ee720273e13
refs/heads/master
2022-11-08T20:41:36.735747
2022-10-21T01:45:52
2022-10-21T01:45:52
161,580,587
27
11
Apache-2.0
2019-01-23T11:00:44
2018-12-13T03:47:28
C++
UTF-8
C++
false
false
108,298
h
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_LEGACY_REFERENCE_OPS_H_ #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_LEGACY_REFERENCE_OPS_H_ #include <stdint.h> #include <sys/types.h> #include <algorithm> #include "public/gemmlowp.h" #include "tensorflow/lite/kernels/internal/common.h" #include "tensorflow/lite/kernels/internal/legacy_types.h" #include "tensorflow/lite/kernels/internal/reference/conv.h" #include "tensorflow/lite/kernels/internal/reference/depthwiseconv_float.h" #include "tensorflow/lite/kernels/internal/reference/depthwiseconv_uint8.h" #include "tensorflow/lite/kernels/internal/reference/reference_ops.h" #include "tensorflow/lite/kernels/internal/reference/tanh.h" #include "tensorflow/lite/kernels/internal/types.h" namespace tflite { namespace reference_ops { static constexpr int kDepthwiseReverseShift = -1; inline void ShapeFromDims(const tflite::Dims<4>& dims, RuntimeShape* shape) { shape->BuildFrom( {dims.sizes[3], dims.sizes[2], dims.sizes[1], dims.sizes[0]}); } inline void DepthwiseConv(const float* input_data, const Dims<4>& input_dims, const float* filter_data, const Dims<4>& filter_dims, const float* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int dilation_width_factor, int dilation_height_factor, int pad_width, int pad_height, int depth_multiplier, float output_activation_min, float output_activation_max, float* output_data, const Dims<4>& output_dims) { tflite::DepthwiseParams op_params; // Padding type is ignored, but still set. op_params.padding_type = PaddingType::kSame; op_params.padding_values.width = pad_width; op_params.padding_values.height = pad_height; op_params.stride_width = stride_width; op_params.stride_height = stride_height; op_params.dilation_width_factor = dilation_width_factor; op_params.dilation_height_factor = dilation_height_factor; op_params.depth_multiplier = depth_multiplier; op_params.float_activation_min = output_activation_min; op_params.float_activation_max = output_activation_max; DepthwiseConv(op_params, DimsToShape(input_dims), input_data, DimsToShape(filter_dims), filter_data, DimsToShape(bias_dims), bias_data, DimsToShape(output_dims), output_data); } inline void DepthwiseConv(const float* input_data, const Dims<4>& input_dims, const float* filter_data, const Dims<4>& filter_dims, const float* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int pad_width, int pad_height, int depth_multiplier, float output_activation_min, float output_activation_max, float* output_data, const Dims<4>& output_dims) { DepthwiseConv(input_data, input_dims, filter_data, filter_dims, bias_data, bias_dims, stride_width, stride_height, 1, 1, pad_width, pad_height, depth_multiplier, output_activation_min, output_activation_max, output_data, output_dims); } // Legacy, for compatibility with old checked-in code. template <FusedActivationFunctionType Ac> void DepthwiseConv(const float* input_data, const Dims<4>& input_dims, const float* filter_data, const Dims<4>& filter_dims, const float* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int pad_width, int pad_height, int depth_multiplier, float* output_data, const Dims<4>& output_dims) { float output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); DepthwiseConv(input_data, input_dims, filter_data, filter_dims, bias_data, bias_dims, stride_width, stride_height, pad_width, pad_height, depth_multiplier, output_activation_min, output_activation_max, output_data, output_dims); } // Legacy, for compatibility with old checked-in code. template <FusedActivationFunctionType Ac> void DepthwiseConv(const float* input_data, const Dims<4>& input_dims, const float* filter_data, const Dims<4>& filter_dims, const float* bias_data, const Dims<4>& bias_dims, int stride, int pad_width, int pad_height, int depth_multiplier, float* output_data, const Dims<4>& output_dims) { DepthwiseConv<Ac>(input_data, input_dims, filter_data, filter_dims, bias_data, bias_dims, stride, stride, pad_width, pad_height, depth_multiplier, output_data, output_dims); } inline void DepthwiseConv(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int dilation_width_factor, int dilation_height_factor, int pad_width, int pad_height, int depth_multiplier, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { tflite::DepthwiseParams op_params; // Padding type is ignored, but still set. op_params.padding_type = PaddingType::kSame; op_params.padding_values.width = pad_width; op_params.padding_values.height = pad_height; op_params.stride_width = stride_width; op_params.stride_height = stride_height; op_params.dilation_width_factor = dilation_width_factor; op_params.dilation_height_factor = dilation_height_factor; op_params.depth_multiplier = depth_multiplier; op_params.quantized_activation_min = output_activation_min; op_params.quantized_activation_max = output_activation_max; op_params.input_offset = input_offset; op_params.weights_offset = filter_offset; op_params.output_offset = output_offset; op_params.output_multiplier = output_multiplier; // Legacy ops used mixed left and right shifts. Now all are +ve-means-left. op_params.output_shift = kDepthwiseReverseShift * output_shift; DepthwiseConv(op_params, DimsToShape(input_dims), input_data, DimsToShape(filter_dims), filter_data, DimsToShape(bias_dims), bias_data, DimsToShape(output_dims), output_data); } inline void DepthwiseConv(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int pad_width, int pad_height, int depth_multiplier, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { DepthwiseConv(input_data, input_dims, input_offset, filter_data, filter_dims, filter_offset, bias_data, bias_dims, stride_width, stride_height, 1, 1, pad_width, pad_height, depth_multiplier, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_data, output_dims); } // Legacy, for compatibility with old checked-in code. template <FusedActivationFunctionType Ac> void DepthwiseConv(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int pad_width, int pad_height, int depth_multiplier, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { if (Ac == FusedActivationFunctionType::kNone) { TFLITE_DCHECK_EQ(output_activation_min, 0); TFLITE_DCHECK_EQ(output_activation_max, 255); } DepthwiseConv(input_data, input_dims, input_offset, filter_data, filter_dims, filter_offset, bias_data, bias_dims, stride_width, stride_height, pad_width, pad_height, depth_multiplier, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_data, output_dims); } // Legacy, for compatibility with old checked-in code. template <FusedActivationFunctionType Ac> void DepthwiseConv(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int stride, int pad_width, int pad_height, int depth_multiplier, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { DepthwiseConv<Ac>(input_data, input_dims, input_offset, filter_data, filter_dims, filter_offset, bias_data, bias_dims, stride, stride, pad_width, pad_height, depth_multiplier, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_data, output_dims); } inline void Conv(const float* input_data, const Dims<4>& input_dims, const float* filter_data, const Dims<4>& filter_dims, const float* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int dilation_width_factor, int dilation_height_factor, int pad_width, int pad_height, float output_activation_min, float output_activation_max, float* output_data, const Dims<4>& output_dims, float* im2col_data, const Dims<4>& im2col_dims) { tflite::ConvParams op_params; // Padding type is ignored, but still set. op_params.padding_type = PaddingType::kSame; op_params.padding_values.width = pad_width; op_params.padding_values.height = pad_height; op_params.stride_width = stride_width; op_params.stride_height = stride_height; op_params.dilation_width_factor = dilation_width_factor; op_params.dilation_height_factor = dilation_height_factor; op_params.float_activation_min = output_activation_min; op_params.float_activation_max = output_activation_max; Conv(op_params, DimsToShape(input_dims), input_data, DimsToShape(filter_dims), filter_data, DimsToShape(bias_dims), bias_data, DimsToShape(output_dims), output_data, DimsToShape(im2col_dims), im2col_data); } template <FusedActivationFunctionType Ac> void Conv(const float* input_data, const Dims<4>& input_dims, const float* filter_data, const Dims<4>& filter_dims, const float* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int dilation_width_factor, int dilation_height_factor, int pad_width, int pad_height, float* output_data, const Dims<4>& output_dims, float* im2col_data, const Dims<4>& im2col_dims) { float output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); Conv(input_data, input_dims, filter_data, filter_dims, bias_data, bias_dims, stride_width, stride_height, dilation_width_factor, dilation_height_factor, pad_width, pad_height, output_activation_min, output_activation_max, output_data, output_dims, im2col_data, im2col_dims); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void Conv(const float* input_data, const Dims<4>& input_dims, const float* filter_data, const Dims<4>& filter_dims, const float* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int pad_width, int pad_height, float* output_data, const Dims<4>& output_dims, float* im2col_data, const Dims<4>& im2col_dims) { float output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); Conv(input_data, input_dims, filter_data, filter_dims, bias_data, bias_dims, stride_width, stride_height, 1, 1, pad_width, pad_height, output_activation_min, output_activation_max, output_data, output_dims, im2col_data, im2col_dims); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void Conv(const float* input_data, const Dims<4>& input_dims, const float* filter_data, const Dims<4>& filter_dims, const float* bias_data, const Dims<4>& bias_dims, int stride, int pad_width, int pad_height, float* output_data, const Dims<4>& output_dims, float* im2col_data, const Dims<4>& im2col_dims) { Conv<Ac>(input_data, input_dims, filter_data, filter_dims, bias_data, bias_dims, stride, stride, 1, 1, pad_width, pad_height, output_data, output_dims, im2col_data, im2col_dims); } inline void Conv(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int dilation_width_factor, int dilation_height_factor, int pad_width, int pad_height, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims, uint8* im2col_data, const Dims<4>& im2col_dims, gemmlowp::GemmContext* gemmlowp_context) { tflite::ConvParams op_params; // Padding type is ignored, but still set. op_params.padding_type = PaddingType::kSame; op_params.padding_values.width = pad_width; op_params.padding_values.height = pad_height; op_params.stride_width = stride_width; op_params.stride_height = stride_height; op_params.dilation_width_factor = dilation_width_factor; op_params.dilation_height_factor = dilation_height_factor; op_params.input_offset = input_offset; op_params.weights_offset = filter_offset; op_params.output_offset = output_offset; op_params.output_multiplier = output_multiplier; // Legacy ops used mixed left and right shifts. Now all are +ve-means-left. op_params.output_shift = kReverseShift * output_shift; op_params.quantized_activation_min = output_activation_min; op_params.quantized_activation_max = output_activation_max; Conv(op_params, DimsToShape(input_dims), input_data, DimsToShape(filter_dims), filter_data, DimsToShape(bias_dims), bias_data, DimsToShape(output_dims), output_data, DimsToShape(im2col_dims), im2col_data, gemmlowp_context); } inline void Conv(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int pad_width, int pad_height, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims, uint8* im2col_data, const Dims<4>& im2col_dims, gemmlowp::GemmContext* gemmlowp_context) { Conv(input_data, input_dims, input_offset, filter_data, filter_dims, filter_offset, bias_data, bias_dims, stride_width, stride_height, 1, 1, pad_width, pad_height, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_data, output_dims, im2col_data, im2col_dims, gemmlowp_context); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> inline void Conv(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int stride_width, int stride_height, int pad_width, int pad_height, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims, uint8* im2col_data, const Dims<4>& im2col_dims, gemmlowp::GemmContext* gemmlowp_context) { static_assert(Ac == FusedActivationFunctionType::kNone || Ac == FusedActivationFunctionType::kRelu || Ac == FusedActivationFunctionType::kRelu6 || Ac == FusedActivationFunctionType::kRelu1, ""); if (Ac == FusedActivationFunctionType::kNone) { TFLITE_DCHECK_EQ(output_activation_min, 0); TFLITE_DCHECK_EQ(output_activation_max, 255); } Conv(input_data, input_dims, input_offset, filter_data, filter_dims, filter_offset, bias_data, bias_dims, stride_width, stride_height, pad_width, pad_height, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_data, output_dims, im2col_data, im2col_dims, gemmlowp_context); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void Conv(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int stride, int pad_width, int pad_height, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims, uint8* im2col_data, const Dims<4>& im2col_dims, gemmlowp::GemmContext* gemmlowp_context) { Conv<Ac>(input_data, input_dims, input_offset, filter_data, filter_dims, filter_offset, bias_data, bias_dims, stride, stride, pad_width, pad_height, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_data, output_dims, im2col_data, im2col_dims, gemmlowp_context); } inline void TransposeConv(const float* input_data, const Dims<4>& input_dims, const float* filter_data, const Dims<4>& filter_dims, int stride_width, int stride_height, int pad_width, int pad_height, float* output_data, const Dims<4>& output_dims, float* im2col_data, const Dims<4>& im2col_dims) { tflite::ConvParams op_params; // Padding type is ignored, but still set. op_params.padding_type = PaddingType::kSame; op_params.padding_values.width = pad_width; op_params.padding_values.height = pad_height; op_params.stride_width = stride_width; op_params.stride_height = stride_height; TransposeConv(op_params, DimsToShape(input_dims), input_data, DimsToShape(filter_dims), filter_data, /*bias_shape*/ RuntimeShape(), /*bias*/ nullptr, DimsToShape(output_dims), output_data, DimsToShape(im2col_dims), im2col_data); } inline void TransposeConv( const ConvParams& params, const RuntimeShape& input_shape, const float* input_data, const RuntimeShape& filter_shape, const float* filter_data, const RuntimeShape& output_shape, float* output_data, const RuntimeShape& im2col_shape, float* im2col_data) { TransposeConv(params, input_shape, input_data, filter_shape, filter_data, /*bias_shape*/ RuntimeShape(), /*bias*/ nullptr, output_shape, output_data, im2col_shape, im2col_data); } inline void FullyConnected(const float* input_data, const Dims<4>& input_dims, const float* weights_data, const Dims<4>& weights_dims, const float* bias_data, const Dims<4>& bias_dims, float output_activation_min, float output_activation_max, float* output_data, const Dims<4>& output_dims) { tflite::FullyConnectedParams op_params; op_params.float_activation_min = output_activation_min; op_params.float_activation_max = output_activation_max; FullyConnected(op_params, DimsToShape(input_dims), input_data, DimsToShape(weights_dims), weights_data, DimsToShape(bias_dims), bias_data, DimsToShape(output_dims), output_data); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void FullyConnected(const float* input_data, const Dims<4>& input_dims, const float* weights_data, const Dims<4>& weights_dims, const float* bias_data, const Dims<4>& bias_dims, float* output_data, const Dims<4>& output_dims) { float output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); FullyConnected(input_data, input_dims, weights_data, weights_dims, bias_data, bias_dims, output_activation_min, output_activation_max, output_data, output_dims); } inline void FullyConnected( const FullyConnectedParams& params, const RuntimeShape& input_shape, const uint8* input_data, const RuntimeShape& filter_shape, const uint8* filter_data, const RuntimeShape& bias_shape, const int32* bias_data, const RuntimeShape& output_shape, uint8* output_data, gemmlowp::GemmContext*) { FullyConnected(params, input_shape, input_data, filter_shape, filter_data, bias_shape, bias_data, output_shape, output_data); } inline void FullyConnected( const FullyConnectedParams& params, const RuntimeShape& input_shape, const uint8* input_data, const RuntimeShape& filter_shape, const uint8* filter_data, const RuntimeShape& bias_shape, const int32* bias_data, const RuntimeShape& output_shape, int16* output_data, gemmlowp::GemmContext*) { FullyConnected(params, input_shape, input_data, filter_shape, filter_data, bias_shape, bias_data, output_shape, output_data); } inline void FullyConnected(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims, gemmlowp::GemmContext* gemmlowp_context) { tflite::FullyConnectedParams op_params; op_params.input_offset = input_offset; op_params.weights_offset = filter_offset; op_params.output_offset = output_offset; op_params.output_multiplier = output_multiplier; // Legacy ops used mixed left and right shifts. Now all are +ve-means-left. op_params.output_shift = kReverseShift * output_shift; op_params.quantized_activation_min = output_activation_min; op_params.quantized_activation_max = output_activation_max; FullyConnected(op_params, DimsToShape(input_dims), input_data, DimsToShape(filter_dims), filter_data, DimsToShape(bias_dims), bias_data, DimsToShape(output_dims), output_data, gemmlowp_context); } inline void FullyConnected(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, int16* output_data, const Dims<4>& output_dims, gemmlowp::GemmContext* gemmlowp_context) { tflite::FullyConnectedParams op_params; op_params.input_offset = input_offset; op_params.weights_offset = filter_offset; op_params.output_offset = output_offset; op_params.output_multiplier = output_multiplier; // Legacy ops used mixed left and right shifts. Now all are +ve-means-left. op_params.output_shift = kReverseShift * output_shift; op_params.quantized_activation_min = output_activation_min; op_params.quantized_activation_max = output_activation_max; FullyConnected(op_params, DimsToShape(input_dims), input_data, DimsToShape(filter_dims), filter_data, DimsToShape(bias_dims), bias_data, DimsToShape(output_dims), output_data, gemmlowp_context); } inline void ShuffledFullyConnected( const FullyConnectedParams& params, const RuntimeShape& input_shape, const uint8* input_data, const RuntimeShape& weights_shape, const uint8* shuffled_weights_data, const RuntimeShape& bias_shape, const int32* bias_data, const RuntimeShape& output_shape, int16* output_data, uint8* shuffled_input_workspace_data, gemmlowp::GemmContext*) { ShuffledFullyConnected(params, input_shape, input_data, weights_shape, shuffled_weights_data, bias_shape, bias_data, output_shape, output_data, shuffled_input_workspace_data); } inline void ShuffledFullyConnected( const uint8* input_data, const Dims<4>& input_dims, const uint8* shuffled_weights_data, const Dims<4>& weights_dims, const int32* bias_data, const Dims<4>& bias_dims, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, int16* output_data, const Dims<4>& output_dims, uint8* shuffled_input_workspace_data, gemmlowp::GemmContext* gemmlowp_context) { tflite::FullyConnectedParams op_params; op_params.output_multiplier = output_multiplier; // Legacy ops used mixed left and right shifts. Now all are +ve-means-left. op_params.output_shift = kReverseShift * output_shift; op_params.quantized_activation_min = output_activation_min; op_params.quantized_activation_max = output_activation_max; ShuffledFullyConnected(op_params, DimsToShape(input_dims), input_data, DimsToShape(weights_dims), shuffled_weights_data, DimsToShape(bias_dims), bias_data, DimsToShape(output_dims), output_data, shuffled_input_workspace_data, gemmlowp_context); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void FullyConnected(const uint8* input_data, const Dims<4>& input_dims, int32 input_offset, const uint8* filter_data, const Dims<4>& filter_dims, int32 filter_offset, const int32* bias_data, const Dims<4>& bias_dims, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims, gemmlowp::GemmContext* gemmlowp_context) { static_assert(Ac == FusedActivationFunctionType::kNone || Ac == FusedActivationFunctionType::kRelu || Ac == FusedActivationFunctionType::kRelu6 || Ac == FusedActivationFunctionType::kRelu1, ""); if (Ac == FusedActivationFunctionType::kNone) { TFLITE_DCHECK_EQ(output_activation_min, 0); TFLITE_DCHECK_EQ(output_activation_max, 255); } FullyConnected(input_data, input_dims, input_offset, filter_data, filter_dims, filter_offset, bias_data, bias_dims, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_data, output_dims, gemmlowp_context); } inline void LstmCell(const float* input_data, const Dims<4>& input_dims, const float* prev_activ_data, const Dims<4>& prev_activ_dims, const float* weights_data, const Dims<4>& weights_dims, const float* bias_data, const Dims<4>& bias_dims, const float* prev_state_data, const Dims<4>& prev_state_dims, float* output_state_data, const Dims<4>& output_state_dims, float* output_activ_data, const Dims<4>& output_activ_dims, float* concat_temp_data, const Dims<4>& concat_temp_dims, float* activ_temp_data, const Dims<4>& activ_temp_dims) { tflite::LstmCellParams op_params; // Float LSTM cell does not need parameters to be set: leave untouched. LstmCell(op_params, DimsToShape(input_dims), input_data, DimsToShape(prev_activ_dims), prev_activ_data, DimsToShape(weights_dims), weights_data, DimsToShape(bias_dims), bias_data, DimsToShape(prev_state_dims), prev_state_data, DimsToShape(output_state_dims), output_state_data, DimsToShape(output_activ_dims), output_activ_data, DimsToShape(concat_temp_dims), concat_temp_data, DimsToShape(activ_temp_dims), activ_temp_data); } template <int StateIntegerBits> void LstmCell(const uint8* input_data_uint8, const Dims<4>& input_dims, const uint8* prev_activ_data_uint8, const Dims<4>& prev_activ_dims, const uint8* weights_data_uint8, const Dims<4>& weights_dims, const int32* bias_data_int32, const Dims<4>& bias_dims, const int16* prev_state_data_int16, const Dims<4>& prev_state_dims, int16* output_state_data_int16, const Dims<4>& output_state_dims, uint8* output_activ_data_uint8, const Dims<4>& output_activ_dims, uint8* concat_temp_data_uint8, const Dims<4>& concat_temp_dims, int16* activ_temp_data_int16, const Dims<4>& activ_temp_dims, int32 weights_zero_point, int32 accum_multiplier, int accum_shift, gemmlowp::GemmContext* gemmlowp_context) { tflite::LstmCellParams op_params; op_params.weights_zero_point = weights_zero_point; op_params.accum_multiplier = accum_multiplier; op_params.accum_shift = accum_shift; LstmCell<StateIntegerBits>( op_params, DimsToShape(input_dims), input_data_uint8, DimsToShape(prev_activ_dims), prev_activ_data_uint8, DimsToShape(weights_dims), weights_data_uint8, DimsToShape(bias_dims), bias_data_int32, DimsToShape(prev_state_dims), prev_state_data_int16, DimsToShape(output_state_dims), output_state_data_int16, DimsToShape(output_activ_dims), output_activ_data_uint8, DimsToShape(concat_temp_dims), concat_temp_data_uint8, DimsToShape(activ_temp_dims), activ_temp_data_int16, gemmlowp_context); } template <typename T> void BroadcastDiv(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T output_activation_min, T output_activation_max, T* output_data, const Dims<4>& output_dims) { tflite::ArithmeticParams op_params; SetActivationParams(output_activation_min, output_activation_max, &op_params); BroadcastDivSlow(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <typename T> inline void Div(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T output_activation_min, T output_activation_max, T* output_data, const Dims<4>& output_dims) { tflite::ArithmeticParams op_params; SetActivationParams(output_activation_min, output_activation_max, &op_params); Div(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <FusedActivationFunctionType Ac, typename Scalar> inline void Concatenation(int concat_dim, const Scalar* const* input_data, const Dims<4>* const* input_dims, int inputs_count, Scalar* output_data, const Dims<4>& output_dims) { // For now we don't have a model with a Concatenation with fused activation. TFLITE_DCHECK_EQ(Ac, FusedActivationFunctionType::kNone); std::vector<RuntimeShape> input_shapes(inputs_count); std::vector<const RuntimeShape*> input_shapes_indirect(inputs_count); for (int i = 0; i < inputs_count; ++i) { ShapeFromDims(*input_dims[i], &input_shapes[i]); input_shapes_indirect[i] = &input_shapes[i]; } tflite::ConcatenationParams op_params; op_params.axis = 3 - concat_dim; op_params.inputs_count = inputs_count; Concatenation(op_params, input_shapes_indirect.data(), input_data, DimsToShape(output_dims), output_data); } inline void Concatenation(int concat_dim, const uint8* const* input_data, const Dims<4>* const* input_dims, const int32* input_zeropoint, const float* input_scale, int inputs_count, uint8* output_data, const Dims<4>& output_dims, const int32 output_zeropoint, const float output_scale) { std::vector<RuntimeShape> input_shapes(inputs_count); std::vector<const RuntimeShape*> input_shapes_indirect(inputs_count); for (int i = 0; i < inputs_count; ++i) { ShapeFromDims(*input_dims[i], &input_shapes[i]); input_shapes_indirect[i] = &input_shapes[i]; } tflite::ConcatenationParams op_params; op_params.axis = 3 - concat_dim; op_params.input_zeropoint = input_zeropoint; op_params.input_scale = input_scale; op_params.inputs_count = inputs_count; op_params.output_zeropoint = output_zeropoint; op_params.output_scale = output_scale; ConcatenationWithScaling(op_params, input_shapes_indirect.data(), input_data, DimsToShape(output_dims), output_data); } template <FusedActivationFunctionType Ac, typename Scalar> void DepthConcatenation(const Scalar* const* input_data, const Dims<4>* const* input_dims, int inputs_count, Scalar* output_data, const Dims<4>& output_dims) { // For now we don't have a model with a Concatenation with fused activation. TFLITE_DCHECK_EQ(Ac, FusedActivationFunctionType::kNone); std::vector<RuntimeShape> input_shapes(inputs_count); std::vector<const RuntimeShape*> input_shapes_indirect(inputs_count); for (int i = 0; i < inputs_count; ++i) { ShapeFromDims(*input_dims[i], &input_shapes[i]); input_shapes_indirect[i] = &input_shapes[i]; } tflite::ConcatenationParams op_params; op_params.inputs_count = inputs_count; DepthConcatenation(op_params, input_shapes_indirect.data(), input_data, DimsToShape(output_dims), output_data); } template <typename Scalar> void TensorFlowSplit(const Scalar* input_data, const Dims<4>& input_dims, int axis, int outputs_count, Scalar* const* output_data, const Dims<4>* const* output_dims) { std::vector<RuntimeShape> output_shapes(outputs_count); std::vector<const RuntimeShape*> output_shapes_indirect(outputs_count); for (int i = 0; i < outputs_count; ++i) { ShapeFromDims(*output_dims[i], &output_shapes[i]); output_shapes_indirect[i] = &output_shapes[i]; } tflite::SplitParams op_params; op_params.axis = 3 - axis; op_params.num_split = outputs_count; Split(op_params, DimsToShape(input_dims), input_data, output_shapes_indirect.data(), output_data); } template <FusedActivationFunctionType Ac, typename Scalar> void TensorFlowSplit(const Scalar* input_data, const Dims<4>& input_dims, int outputs_count, Scalar* const* output_data, const Dims<4>* const* output_dims) { TFLITE_DCHECK_GE(outputs_count, 1); for (int i = 0; i < outputs_count; i++) { /* batches = */ MatchingArraySize(*output_dims[i], 3, input_dims, 3); /* height = */ MatchingArraySize(*output_dims[i], 2, input_dims, 2); /* width = */ MatchingArraySize(*output_dims[i], 1, input_dims, 1); } // For now we don't have a model with a Split with fused activation. TFLITE_DCHECK_EQ(Ac, FusedActivationFunctionType::kNone); TensorFlowSplit(input_data, input_dims, /*axis=*/0, outputs_count, output_data, output_dims); } inline void Softmax(const float* input_data, const RuntimeShape& input_shape, float beta, float* output_data, const RuntimeShape& output_shape) { SoftmaxParams params; params.beta = beta; Softmax(params, input_shape, input_data, output_shape, output_data); } inline void Softmax(const uint8* input_data, const RuntimeShape& input_shape, int32 input_beta_multiplier, int32 input_beta_left_shift, int diff_min, uint8* output_data, const RuntimeShape& output_shape) { SoftmaxParams params; params.input_multiplier = input_beta_multiplier; params.input_left_shift = input_beta_left_shift; params.diff_min = diff_min; Softmax(params, input_shape, input_data, output_shape, output_data); } inline void LogSoftmax(const float* input_data, const RuntimeShape& input_shape, float* output_data, const RuntimeShape& output_shape) { SoftmaxParams params; // No params currently used for float LogSoftmax. LogSoftmax(params, input_shape, input_data, output_shape, output_data); } inline void LogSoftmax(const uint8* input_data, const RuntimeShape& input_shape, int32 input_multiplier, int32 input_left_shift, int32 reverse_scaling_divisor, int32 reverse_scaling_right_shift, int diff_min, uint8* output_data, const RuntimeShape& output_shape) { SoftmaxParams params; params.input_multiplier = input_multiplier; params.input_left_shift = input_left_shift; params.reverse_scaling_divisor = reverse_scaling_divisor; params.reverse_scaling_right_shift = reverse_scaling_right_shift; params.diff_min = diff_min; LogSoftmax(params, input_shape, input_data, output_shape, output_data); } inline void Logistic(const LogisticParams& params, const RuntimeShape& input_shape, const uint8* input_data, const RuntimeShape& output_shape, uint8* output_data) { const int32 input_zero_point = params.input_zero_point; const int32 input_range_radius = params.input_range_radius; const int32 input_multiplier = params.input_multiplier; const int input_left_shift = params.input_left_shift; const int flat_size = MatchingFlatSize(input_shape, output_shape); for (int i = 0; i < flat_size; i++) { const uint8 input_val_u8 = input_data[i]; const int32 input_val_centered = static_cast<int32>(input_val_u8) - input_zero_point; uint8 output_val; if (input_val_centered <= -input_range_radius) { output_val = 0; } else if (input_val_centered >= input_range_radius) { output_val = 255; } else { const int32 input_val_rescaled = MultiplyByQuantizedMultiplierGreaterThanOne( input_val_centered, input_multiplier, input_left_shift); using FixedPoint4 = gemmlowp::FixedPoint<int32, 4>; using FixedPoint0 = gemmlowp::FixedPoint<int32, 0>; const FixedPoint4 input_val_f4 = FixedPoint4::FromRaw(input_val_rescaled); const FixedPoint0 output_val_f0 = gemmlowp::logistic(input_val_f4); // Convert from Q0.31 to Q23.8. using gemmlowp::RoundingDivideByPOT; int32 output_val_s32 = RoundingDivideByPOT(output_val_f0.raw(), 23); if (output_val_s32 == 256) { output_val_s32 = 255; } // Reinterpret as U0.8. TFLITE_DCHECK_GE(output_val_s32, 0); TFLITE_DCHECK_LE(output_val_s32, 255); output_val = static_cast<uint8>(output_val_s32); } output_data[i] = output_val; } } inline void Logistic(const uint8* input_data, const RuntimeShape& input_shape, int32 input_zero_point, int32 input_range_radius, int32 input_multiplier, int input_left_shift, uint8* output_data, const RuntimeShape& output_shape) { LogisticParams params; params.input_zero_point = input_zero_point; params.input_range_radius = input_range_radius; params.input_multiplier = input_multiplier; params.input_left_shift = input_left_shift; Logistic(params, input_shape, input_data, output_shape, output_data); } inline void Logistic(const RuntimeShape& input_shape, const int16* input_data, const RuntimeShape& output_shape, int16* output_data) { LogisticParams params; // No params currently needed by int16 Logistic. Logistic(params, input_shape, input_data, output_shape, output_data); } inline void Tanh(const uint8* input_data, const RuntimeShape& input_shape, int32 input_zero_point, int32 input_range_radius, int32 input_multiplier, int input_left_shift, uint8* output_data, const RuntimeShape& output_shape) { TanhParams params; params.input_zero_point = input_zero_point; params.input_range_radius = input_range_radius; params.input_multiplier = input_multiplier; params.input_left_shift = input_left_shift; Tanh(params, input_shape, input_data, output_shape, output_data); } inline void Tanh(const int16* input_data, const RuntimeShape& input_shape, int input_left_shift, int16* output_data, const RuntimeShape& output_shape) { TanhParams params; params.input_left_shift = input_left_shift; Tanh(params, input_shape, input_data, output_shape, output_data); } inline void Dequantize(const uint8* input_data, const Dims<4>& input_dims, int32 zero_point, double scale, float* output_data, const Dims<4>& output_dims) { tflite::DequantizationParams op_params; op_params.zero_point = zero_point; op_params.scale = scale; Dequantize(op_params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } inline void FakeQuant(const float* input_data, const Dims<4>& input_dims, float rmin, float rmax, int num_bits, float* output_data, const Dims<4>& output_dims) { tflite::FakeQuantParams op_params; op_params.num_bits = num_bits; op_params.minmax.min = rmin; op_params.minmax.max = rmax; FakeQuant(op_params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } template <typename T> inline void Gather(const T* input_data, const Dims<4>& input_dims, int input_rank, const int32* coords_data, const Dims<4>& coords_dims, T* output_data, const Dims<4>& output_dims) { tflite::GatherParams op_params; op_params.axis = 4 - input_rank; op_params.batch_dims = 0; Gather(op_params, DimsToShape(input_dims), input_data, DimsToShape(coords_dims), coords_data, DimsToShape(output_dims), output_data); } inline uint32 LegacyReverseBits32(uint32 n) { n = ((n >> 1) & 0x55555555) | ((n & 0x55555555) << 1); n = ((n >> 2) & 0x33333333) | ((n & 0x33333333) << 2); n = ((n >> 4) & 0x0F0F0F0F) | ((n & 0x0F0F0F0F) << 4); return (((n & 0xFF) << 24) | ((n & 0xFF00) << 8) | ((n & 0xFF0000) >> 8) | ((n & 0xFF000000) >> 24)); } inline void StridedSliceReverseIndices(tflite::StridedSliceParams* p) { TFLITE_CHECK_EQ(p->start_indices_count, p->stop_indices_count); TFLITE_CHECK_EQ(p->stop_indices_count, p->strides_count); std::reverse(p->start_indices, p->start_indices + p->start_indices_count); std::reverse(p->stop_indices, p->stop_indices + p->stop_indices_count); std::reverse(p->strides, p->strides + p->strides_count); p->begin_mask = LegacyReverseBits32(static_cast<uint32>(p->begin_mask)) >> (32 - p->start_indices_count); p->ellipsis_mask = LegacyReverseBits32(static_cast<uint32>(p->ellipsis_mask)) >> (32 - p->start_indices_count); p->end_mask = LegacyReverseBits32(static_cast<uint32>(p->end_mask)) >> (32 - p->start_indices_count); p->new_axis_mask = LegacyReverseBits32(static_cast<uint32>(p->new_axis_mask)) >> (32 - p->start_indices_count); p->shrink_axis_mask = LegacyReverseBits32(static_cast<uint32>(p->shrink_axis_mask)) >> (32 - p->start_indices_count); } template <typename T> inline void StridedSlice(const T* input_data, const Dims<4>& input_dims, int begin_mask, int end_mask, int shrink_axis_mask, const std::vector<int>& start_indices, const std::vector<int>& stop_indices, const std::vector<int>& strides, T* output_data, const Dims<4>& output_dims) { TFLITE_DCHECK_EQ(start_indices.size(), 4); auto op_params = strided_slice::BuildStridedSliceParams( begin_mask, end_mask, shrink_axis_mask, start_indices, stop_indices, strides); StridedSliceReverseIndices(&op_params); StridedSlice(op_params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } template <typename T> inline void Mean(const T* input_data, const Dims<4>& input_dims, const std::vector<int>& reduction_indices, T* output_data, const Dims<4>& output_dims) { tflite::MeanParams op_params; op_params.axis_count = reduction_indices.size(); for (int i = 0; i < op_params.axis_count; ++i) { op_params.axis[i] = reduction_indices[op_params.axis_count - 1 - i]; } Mean(op_params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } template <typename T> void Transpose(const T* input, const Dims<4>& input_dims, T* output, const Dims<4>& output_dims, const int* permuted_axes) { TransposeParams params; params.perm_count = 4; for (int i = 0; i < 4; ++i) { params.perm[i] = 3 - permuted_axes[3 - i]; } Transpose(params, DimsToShape(input_dims), input, DimsToShape(output_dims), output); } template <typename T, ComparisonFn<T> F> inline void Comparison(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, bool* output_data, const Dims<4>& output_dims) { ComparisonParams op_params; // No parameters needed. ComparisonImpl<T, F>(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <typename T, ComparisonFn<int32> F> inline void Comparison(int left_shift, const T* input1_data, const Dims<4>& input1_dims, int32 input1_offset, int32 input1_multiplier, int input1_shift, const T* input2_data, const Dims<4>& input2_dims, int32 input2_offset, int32 input2_multiplier, int input2_shift, bool* output_data, const Dims<4>& output_dims) { tflite::ComparisonParams op_params; op_params.left_shift = left_shift; op_params.input1_offset = input1_offset; op_params.input1_multiplier = input1_multiplier; // Legacy ops used mixed left and right shifts. Now all are +ve-means-left. op_params.input1_shift = kReverseShift * input1_shift; op_params.input2_offset = input2_offset; op_params.input2_multiplier = input2_multiplier; // Legacy ops used mixed left and right shifts. Now all are +ve-means-left. op_params.input2_shift = kReverseShift * input2_shift; ComparisonWithScaling<T, F>(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <typename T, ComparisonFn<T> F> inline void BroadcastComparison(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, bool* output_data, const Dims<4>& output_dims) { ComparisonParams op_params; // No parameters needed. BroadcastComparison4DSlowImpl<T, F>(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <typename T, ComparisonFn<int32> F> inline void BroadcastComparison(int left_shift, const T* input1_data, const Dims<4>& input1_dims, int32 input1_offset, int32 input1_multiplier, int input1_shift, const T* input2_data, const Dims<4>& input2_dims, int32 input2_offset, int32 input2_multiplier, int input2_shift, bool* output_data, const Dims<4>& output_dims) { ComparisonParams op_params; op_params.left_shift = left_shift; op_params.input1_offset = input1_offset; op_params.input1_multiplier = input1_multiplier; // Legacy ops used mixed left and right shifts. Now all are +ve-means-left. op_params.input1_shift = kReverseShift * input1_shift; op_params.input2_offset = input2_offset; op_params.input2_multiplier = input2_multiplier; // Legacy ops used mixed left and right shifts. Now all are +ve-means-left. op_params.input2_shift = kReverseShift * input2_shift; BroadcastComparison4DSlowWithScaling<T, F>( op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } #define TFLITE_LEGACY_COMPARISON_OP(name) \ template <typename T> \ inline void name(const T* input1_data, const Dims<4>& input1_dims, \ const T* input2_data, const Dims<4>& input2_dims, \ bool* output_data, const Dims<4>& output_dims) { \ ruy::profiler::ScopeLabel label(#name); \ Comparison<T, name##Fn>(input1_data, input1_dims, input2_data, \ input2_dims, output_data, output_dims); \ } \ template <typename T> \ inline void name( \ int left_shift, const T* input1_data, const Dims<4>& input1_dims, \ int32 input1_offset, int32 input1_multiplier, int input1_shift, \ const T* input2_data, const Dims<4>& input2_dims, int32 input2_offset, \ int32 input2_multiplier, int input2_shift, bool* output_data, \ const Dims<4>& output_dims) { \ ruy::profiler::ScopeLabel label(#name "/8bit"); \ Comparison<T, name##Fn>(left_shift, input1_data, input1_dims, \ input1_offset, input1_multiplier, input1_shift, \ input2_data, input2_dims, input2_offset, \ input2_multiplier, input2_shift, output_data, \ output_dims); \ } \ template <typename T> \ inline void Broadcast##name( \ const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, \ const Dims<4>& input2_dims, bool* output_data, \ const Dims<4>& output_dims) { \ ruy::profiler::ScopeLabel label("Broadcast" #name); \ BroadcastComparison<T, name##Fn>(input1_data, input1_dims, input2_data, \ input2_dims, output_data, output_dims); \ } \ template <typename T> \ inline void Broadcast##name( \ int left_shift, const T* input1_data, const Dims<4>& input1_dims, \ int32 input1_offset, int32 input1_multiplier, int input1_shift, \ const T* input2_data, const Dims<4>& input2_dims, int32 input2_offset, \ int32 input2_multiplier, int input2_shift, bool* output_data, \ const Dims<4>& output_dims) { \ ruy::profiler::ScopeLabel label("Broadcast" #name "/8bit"); \ BroadcastComparison<T, name##Fn>(left_shift, input1_data, input1_dims, \ input1_offset, input1_multiplier, \ input1_shift, input2_data, input2_dims, \ input2_offset, input2_multiplier, \ input2_shift, output_data, output_dims); \ } TFLITE_LEGACY_COMPARISON_OP(Equal); TFLITE_LEGACY_COMPARISON_OP(NotEqual); TFLITE_LEGACY_COMPARISON_OP(Greater); TFLITE_LEGACY_COMPARISON_OP(GreaterEqual); TFLITE_LEGACY_COMPARISON_OP(Less); TFLITE_LEGACY_COMPARISON_OP(LessEqual); #undef TFLITE_LEGACY_COMPARISON_OP template <typename D, typename T> inline void Select(const D* input_condition_data, const Dims<4>& input_condition_dims, const T* input_x_data, const Dims<4>& input_x_dims, const T* input_y_data, const Dims<4>& input_y_dims, T* output_data, const Dims<4>& output_dims) { Select(DimsToShape(input_condition_dims), input_condition_data, DimsToShape(input_x_dims), input_x_data, DimsToShape(input_y_dims), input_y_data, DimsToShape(output_dims), output_data); } template <typename D, typename T> inline void RankOneSelect(const D* input_condition_data, const Dims<4>& input_condition_dims, const T* input_x_data, const Dims<4>& input_x_dims, const T* input_y_data, const Dims<4>& input_y_dims, T* output_data, const Dims<4>& output_dims) { RankOneSelect(DimsToShape(input_condition_dims), input_condition_data, DimsToShape(input_x_dims), input_x_data, DimsToShape(input_y_dims), input_y_data, DimsToShape(output_dims), output_data); } template <typename T, typename TI> inline void SparseToDense(const std::vector<std::vector<TI>>& indices, const T* values, T default_value, T* output_data, const Dims<4>& output_dims, bool value_is_scalar) { SparseToDense(indices, values, default_value, value_is_scalar, DimsToShape(output_dims), output_data); } template <typename Scalar> void Pack(int dim, const Scalar* const* input_data, const Dims<4>* const* input_dims, int inputs_count, Scalar* output_data, const Dims<4>& output_dims) { std::vector<RuntimeShape> input_shapes(inputs_count); std::vector<const RuntimeShape*> input_shapes_indirect(inputs_count); for (int i = 0; i < inputs_count; ++i) { ShapeFromDims(*input_dims[i], &input_shapes[i]); input_shapes_indirect[i] = &input_shapes[i]; } tflite::PackParams op_params; op_params.axis = 3 - dim; op_params.inputs_count = inputs_count; Pack(op_params, input_shapes_indirect.data(), input_data, DimsToShape(output_dims), output_data); } template <typename Scalar> void Unpack(int axis, const Scalar* input_data, const Dims<4>& input_dims, int dimensions, int outputs_count, Scalar* const* output_datas, const Dims<4>& output_dims) { tflite::UnpackParams op_params; op_params.axis = 3 - axis; op_params.num_split = outputs_count; Unpack(op_params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_datas); } template <typename Scalar> void Pack(int dim, const Scalar* const* input_data, const Dims<4>* const* input_dims, const int32* input_zeropoint, const float* input_scale, int inputs_count, Scalar* output_data, const Dims<4>& output_dims, const int32 output_zeropoint, const float output_scale) { std::vector<RuntimeShape> input_shapes(inputs_count); std::vector<const RuntimeShape*> input_shapes_indirect(inputs_count); for (int i = 0; i < inputs_count; ++i) { ShapeFromDims(*input_dims[i], &input_shapes[i]); input_shapes_indirect[i] = &input_shapes[i]; } tflite::PackParams op_params; op_params.axis = 3 - dim; op_params.input_zeropoint = input_zeropoint; op_params.input_scale = input_scale; op_params.inputs_count = inputs_count; op_params.output_zeropoint = output_zeropoint; op_params.output_scale = output_scale; PackWithScaling(op_params, input_shapes_indirect.data(), input_data, DimsToShape(output_dims), output_data); } template <FusedActivationFunctionType Ac> void L2Normalization(const float* input_data, const RuntimeShape& input_shape, float* output_data, const RuntimeShape& output_shape) { static_assert(Ac == FusedActivationFunctionType::kNone, ""); tflite::L2NormalizationParams op_params; // No params need to be set for float. L2Normalization(op_params, input_shape, input_data, output_shape, output_data); } inline void L2Normalization(const uint8* input_data, const RuntimeShape& input_shape, int32 input_zero_point, uint8* output_data, const RuntimeShape& output_shape) { tflite::L2NormalizationParams op_params; op_params.input_zero_point = input_zero_point; L2Normalization(op_params, input_shape, input_data, output_shape, output_data); } template <FusedActivationFunctionType Ac> void L2Normalization(const float* input_data, const Dims<4>& input_dims, float* output_data, const Dims<4>& output_dims) { L2Normalization<Ac>(input_data, DimsToShape(input_dims), output_data, DimsToShape(output_dims)); } inline void L2Normalization(const uint8* input_data, const Dims<4>& input_dims, int32 input_zero_point, uint8* output_data, const Dims<4>& output_dims) { L2Normalization(input_data, DimsToShape(input_dims), input_zero_point, output_data, DimsToShape(output_dims)); } inline void Relu(const float* input_data, const Dims<4>& input_dims, float* output_data, const Dims<4>& output_dims) { Relu(DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } inline void Relu1(const float* input_data, const Dims<4>& input_dims, float* output_data, const Dims<4>& output_dims) { Relu1(DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } inline void Relu6(const float* input_data, const Dims<4>& input_dims, float* output_data, const Dims<4>& output_dims) { Relu6(DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } inline void ReluX(uint8 min_value, uint8 max_value, const uint8* input_data, const RuntimeShape& input_shape, uint8* output_data, const RuntimeShape& output_shape) { tflite::ActivationParams params; params.quantized_activation_max = max_value; params.quantized_activation_min = min_value; ReluX(params, input_shape, input_data, output_shape, output_data); } template <FusedActivationFunctionType Ac> inline void Add(int left_shift, const uint8* input1_data, const Dims<4>& input1_dims, int32 input1_offset, int32 input1_multiplier, int input1_shift, const uint8* input2_data, const Dims<4>& input2_dims, int32 input2_offset, int32 input2_multiplier, int input2_shift, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { constexpr int kReverseShift = -1; static_assert(Ac == FusedActivationFunctionType::kNone || Ac == FusedActivationFunctionType::kRelu || Ac == FusedActivationFunctionType::kRelu6 || Ac == FusedActivationFunctionType::kRelu1, ""); TFLITE_DCHECK_LE(output_activation_min, output_activation_max); if (Ac == FusedActivationFunctionType::kNone) { TFLITE_DCHECK_EQ(output_activation_min, 0); TFLITE_DCHECK_EQ(output_activation_max, 255); } tflite::ArithmeticParams op_params; op_params.left_shift = left_shift; op_params.input1_offset = input1_offset; op_params.input1_multiplier = input1_multiplier; op_params.input1_shift = kReverseShift * input1_shift; op_params.input2_offset = input2_offset; op_params.input2_multiplier = input2_multiplier; op_params.input2_shift = kReverseShift * input2_shift; op_params.output_offset = output_offset; op_params.output_multiplier = output_multiplier; op_params.output_shift = kReverseShift * output_shift; op_params.quantized_activation_min = output_activation_min; op_params.quantized_activation_max = output_activation_max; Add(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <FusedActivationFunctionType Ac> void Add(const int32* input1_data, const Dims<4>& input1_dims, const int32* input2_data, const Dims<4>& input2_dims, int32* output_data, const Dims<4>& output_dims) { ruy::profiler::ScopeLabel label("Add/int32"); TFLITE_DCHECK(Ac == FusedActivationFunctionType::kNone); tflite::ArithmeticParams op_params; op_params.quantized_activation_min = std::numeric_limits<int32>::min(); op_params.quantized_activation_max = std::numeric_limits<int32>::max(); Add(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <FusedActivationFunctionType Ac> inline void BroadcastAdd(int left_shift, const uint8* input1_data, const Dims<4>& input1_dims, int32 input1_offset, int32 input1_multiplier, int input1_shift, const uint8* input2_data, const Dims<4>& input2_dims, int32 input2_offset, int32 input2_multiplier, int input2_shift, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { constexpr int kReverseShift = -1; static_assert(Ac == FusedActivationFunctionType::kNone || Ac == FusedActivationFunctionType::kRelu || Ac == FusedActivationFunctionType::kRelu6 || Ac == FusedActivationFunctionType::kRelu1, ""); TFLITE_DCHECK_LE(output_activation_min, output_activation_max); if (Ac == FusedActivationFunctionType::kNone) { TFLITE_DCHECK_EQ(output_activation_min, 0); TFLITE_DCHECK_EQ(output_activation_max, 255); } tflite::ArithmeticParams op_params; op_params.left_shift = left_shift; op_params.input1_offset = input1_offset; op_params.input1_multiplier = input1_multiplier; op_params.input1_shift = kReverseShift * input1_shift; op_params.input2_offset = input2_offset; op_params.input2_multiplier = input2_multiplier; op_params.input2_shift = kReverseShift * input2_shift; op_params.output_offset = output_offset; op_params.output_multiplier = output_multiplier; op_params.output_shift = kReverseShift * output_shift; op_params.quantized_activation_min = output_activation_min; op_params.quantized_activation_max = output_activation_max; BroadcastAdd4DSlow(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <FusedActivationFunctionType Ac> void Add(const float* input1_data, const Dims<4>& input1_dims, const float* input2_data, const Dims<4>& input2_dims, float* output_data, const Dims<4>& output_dims) { float output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); tflite::ArithmeticParams op_params; op_params.float_activation_min = output_activation_min; op_params.float_activation_max = output_activation_max; Add(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <typename T> void BroadcastAdd(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T output_activation_min, T output_activation_max, T* output_data, const Dims<4>& output_dims) { tflite::ArithmeticParams op_params; op_params.float_activation_min = output_activation_min; op_params.float_activation_max = output_activation_max; BroadcastAdd4DSlow(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <FusedActivationFunctionType Ac> inline void BroadcastAddFivefold( int y0, int y1, int y2, int y3, int y4, int left_shift, const uint8* input1_data, const Dims<4>& input1_dims, int32 input1_offset, int32 input1_multiplier, int input1_shift, const uint8* input2_data, const Dims<4>& input2_dims, int32 input2_offset, int32 input2_multiplier, int input2_shift, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { constexpr int kReverseShift = -1; static_assert(Ac == FusedActivationFunctionType::kNone || Ac == FusedActivationFunctionType::kRelu || Ac == FusedActivationFunctionType::kRelu6 || Ac == FusedActivationFunctionType::kRelu1, ""); TFLITE_DCHECK_LE(output_activation_min, output_activation_max); if (Ac == FusedActivationFunctionType::kNone) { TFLITE_DCHECK_EQ(output_activation_min, 0); TFLITE_DCHECK_EQ(output_activation_max, 255); } tflite::ArithmeticParams op_params; op_params.broadcast_category = tflite::BroadcastableOpCategory::kFirstInputBroadcastsFast; op_params.left_shift = left_shift; op_params.input1_offset = input1_offset; op_params.input1_multiplier = input1_multiplier; op_params.input1_shift = kReverseShift * input1_shift; op_params.input2_offset = input2_offset; op_params.input2_multiplier = input2_multiplier; op_params.input2_shift = kReverseShift * input2_shift; op_params.output_offset = output_offset; op_params.output_multiplier = output_multiplier; op_params.output_shift = kReverseShift * output_shift; op_params.quantized_activation_min = output_activation_min; op_params.quantized_activation_max = output_activation_max; op_params.broadcast_shape[4] = y0; op_params.broadcast_shape[3] = y1; op_params.broadcast_shape[2] = y2; op_params.broadcast_shape[1] = y3; op_params.broadcast_shape[0] = y4; BroadcastAddFivefold(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac, typename T> void BroadcastAdd(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T* output_data, const Dims<4>& output_dims) { T output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); BroadcastAdd(input1_data, input1_dims, input2_data, input2_dims, output_activation_min, output_activation_max, output_data, output_dims); } template <FusedActivationFunctionType Ac> inline void Add(const int16* input1_data, const Dims<4>& input1_dims, int input1_shift, const int16* input2_data, const Dims<4>& input2_dims, int input2_shift, int16 output_activation_min, int16 output_activation_max, int16* output_data, const Dims<4>& output_dims) { static_assert(Ac == FusedActivationFunctionType::kNone || Ac == FusedActivationFunctionType::kRelu || Ac == FusedActivationFunctionType::kRelu6 || Ac == FusedActivationFunctionType::kRelu1, ""); TFLITE_DCHECK_LE(output_activation_min, output_activation_max); if (Ac == FusedActivationFunctionType::kNone) { TFLITE_DCHECK_EQ(output_activation_min, -32768); TFLITE_DCHECK_EQ(output_activation_max, 32767); } tflite::ArithmeticParams op_params; op_params.input1_shift = kReverseShift * input1_shift; op_params.input2_shift = kReverseShift * input2_shift; op_params.quantized_activation_min = output_activation_min; op_params.quantized_activation_max = output_activation_max; Add(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } inline void Sub(const float* input1_data, const Dims<4>& input1_dims, const float* input2_data, const Dims<4>& input2_dims, float* output_data, const Dims<4>& output_dims) { float output_activation_min, output_activation_max; GetActivationMinMax(FusedActivationFunctionType::kNone, &output_activation_min, &output_activation_max); tflite::ArithmeticParams op_params; op_params.float_activation_min = output_activation_min; op_params.float_activation_max = output_activation_max; Sub(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <typename T> void Sub(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T* output_data, const Dims<4>& output_dims) { tflite::ArithmeticParams op_params; op_params.quantized_activation_min = std::numeric_limits<T>::min(); op_params.quantized_activation_max = std::numeric_limits<T>::max(); Sub(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } inline bool AveragePool(const float* input_data, const Dims<4>& input_dims, int stride_width, int stride_height, int pad_width, int pad_height, int kwidth, int kheight, float output_activation_min, float output_activation_max, float* output_data, const Dims<4>& output_dims) { tflite::PoolParams params; params.stride_height = stride_height; params.stride_width = stride_width; params.filter_height = kheight; params.filter_width = kwidth; params.padding_values.height = pad_height; params.padding_values.width = pad_width; params.float_activation_min = output_activation_min; params.float_activation_max = output_activation_max; return AveragePool(params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } // Transitional version that will be moved shortly to legacy_reference_ops, as // part of RuntimeShape revisions. inline void BroadcastMul4DSlow(const uint8* input1_data, const Dims<4>& input1_dims, int32 input1_offset, const uint8* input2_data, const Dims<4>& input2_dims, int32 input2_offset, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { tflite::ArithmeticParams op_params; SetActivationParams(output_activation_min, output_activation_max, &op_params); op_params.input1_offset = input1_offset; op_params.input2_offset = input2_offset; op_params.output_offset = output_offset; op_params.output_multiplier = output_multiplier; op_params.output_shift = output_shift; BroadcastMul4DSlow(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } inline void BroadcastMul(const uint8* input1_data, const Dims<4>& input1_dims, int32 input1_offset, const uint8* input2_data, const Dims<4>& input2_dims, int32 input2_offset, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { BroadcastMul4DSlow( input1_data, input1_dims, input1_offset, input2_data, input2_dims, input2_offset, output_offset, output_multiplier, // kReverseShift * output_shift, // output_activation_min, output_activation_max, output_data, output_dims); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> inline void BroadcastMul(const uint8* input1_data, const Dims<4>& input1_dims, int32 input1_offset, const uint8* input2_data, const Dims<4>& input2_dims, int32 input2_offset, int32 output_offset, int32 output_multiplier, int output_shift, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { BroadcastMul(input1_data, input1_dims, input1_offset, input2_data, input2_dims, input2_offset, output_offset, output_multiplier, output_shift, output_activation_min, output_activation_max, output_data, output_dims); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> bool AveragePool(const float* input_data, const Dims<4>& input_dims, int stride_width, int stride_height, int pad_width, int pad_height, int kwidth, int kheight, float* output_data, const Dims<4>& output_dims) { float output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); return AveragePool(input_data, input_dims, stride_width, stride_height, pad_width, pad_height, kwidth, kheight, output_activation_min, output_activation_max, output_data, output_dims); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> bool AveragePool(const float* input_data, const Dims<4>& input_dims, int stride, int pad_width, int pad_height, int filter_width, int filter_height, float* output_data, const Dims<4>& output_dims) { return AveragePool<Ac>(input_data, input_dims, stride, stride, pad_width, pad_height, filter_width, filter_height, output_data, output_dims); } inline bool AveragePool(const uint8* input_data, const Dims<4>& input_dims, int stride_width, int stride_height, int pad_width, int pad_height, int filter_width, int filter_height, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { tflite::PoolParams params; params.stride_height = stride_height; params.stride_width = stride_width; params.filter_height = filter_height; params.filter_width = filter_width; params.padding_values.height = pad_height; params.padding_values.width = pad_width; params.quantized_activation_min = output_activation_min; params.quantized_activation_max = output_activation_max; return AveragePool(params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> bool AveragePool(const uint8* input_data, const Dims<4>& input_dims, int stride_width, int stride_height, int pad_width, int pad_height, int filter_width, int filter_height, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { static_assert(Ac == FusedActivationFunctionType::kNone || Ac == FusedActivationFunctionType::kRelu || Ac == FusedActivationFunctionType::kRelu6 || Ac == FusedActivationFunctionType::kRelu1, ""); if (Ac == FusedActivationFunctionType::kNone) { TFLITE_DCHECK_EQ(output_activation_min, 0); TFLITE_DCHECK_EQ(output_activation_max, 255); } return AveragePool(input_data, input_dims, stride_width, stride_height, pad_width, pad_height, filter_width, filter_height, output_activation_min, output_activation_max, output_data, output_dims); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> bool AveragePool(const uint8* input_data, const Dims<4>& input_dims, int stride, int pad_width, int pad_height, int filter_width, int filter_height, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { return AveragePool<Ac>(input_data, input_dims, stride, stride, pad_width, pad_height, filter_width, filter_height, output_activation_min, output_activation_max, output_data, output_dims); } inline void MaxPool(const float* input_data, const Dims<4>& input_dims, int stride_width, int stride_height, int pad_width, int pad_height, int kwidth, int kheight, float output_activation_min, float output_activation_max, float* output_data, const Dims<4>& output_dims) { tflite::PoolParams params; params.stride_height = stride_height; params.stride_width = stride_width; params.filter_height = kheight; params.filter_width = kwidth; params.padding_values.height = pad_height; params.padding_values.width = pad_width; params.float_activation_min = output_activation_min; params.float_activation_max = output_activation_max; MaxPool(params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void MaxPool(const float* input_data, const Dims<4>& input_dims, int stride_width, int stride_height, int pad_width, int pad_height, int kwidth, int kheight, float* output_data, const Dims<4>& output_dims) { float output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); MaxPool(input_data, input_dims, stride_width, stride_height, pad_width, pad_height, kwidth, kheight, output_activation_min, output_activation_max, output_data, output_dims); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void MaxPool(const float* input_data, const Dims<4>& input_dims, int stride, int pad_width, int pad_height, int filter_width, int filter_height, float* output_data, const Dims<4>& output_dims) { MaxPool<Ac>(input_data, input_dims, stride, stride, pad_width, pad_height, filter_width, filter_height, output_data, output_dims); } inline void MaxPool(const uint8* input_data, const Dims<4>& input_dims, int stride_width, int stride_height, int pad_width, int pad_height, int filter_width, int filter_height, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { PoolParams params; params.stride_height = stride_height; params.stride_width = stride_width; params.filter_height = filter_height; params.filter_width = filter_width; params.padding_values.height = pad_height; params.padding_values.width = pad_width; params.quantized_activation_min = output_activation_min; params.quantized_activation_max = output_activation_max; MaxPool(params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void MaxPool(const uint8* input_data, const Dims<4>& input_dims, int stride_width, int stride_height, int pad_width, int pad_height, int filter_width, int filter_height, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { static_assert(Ac == FusedActivationFunctionType::kNone || Ac == FusedActivationFunctionType::kRelu || Ac == FusedActivationFunctionType::kRelu6 || Ac == FusedActivationFunctionType::kRelu1, ""); if (Ac == FusedActivationFunctionType::kNone) { TFLITE_DCHECK_EQ(output_activation_min, 0); TFLITE_DCHECK_EQ(output_activation_max, 255); } MaxPool(input_data, input_dims, stride_width, stride_height, pad_width, pad_height, filter_width, filter_height, output_activation_min, output_activation_max, output_data, output_dims); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void MaxPool(const uint8* input_data, const Dims<4>& input_dims, int stride, int pad_width, int pad_height, int filter_width, int filter_height, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { MaxPool<Ac>(input_data, input_dims, stride, stride, pad_width, pad_height, filter_width, filter_height, output_activation_min, output_activation_max, output_data, output_dims); } inline void L2Pool(const float* input_data, const Dims<4>& input_dims, int stride_width, int stride_height, int pad_width, int pad_height, int filter_width, int filter_height, float output_activation_min, float output_activation_max, float* output_data, const Dims<4>& output_dims) { PoolParams params; params.stride_height = stride_height; params.stride_width = stride_width; params.filter_height = filter_height; params.filter_width = filter_width; params.padding_values.height = pad_height; params.padding_values.width = pad_width; params.float_activation_min = output_activation_min; params.float_activation_max = output_activation_max; L2Pool(params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void L2Pool(const float* input_data, const Dims<4>& input_dims, int stride_width, int stride_height, int pad_width, int pad_height, int filter_width, int filter_height, float* output_data, const Dims<4>& output_dims) { float output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); L2Pool(input_data, input_dims, stride_width, stride_height, pad_width, pad_height, filter_width, filter_height, output_activation_min, output_activation_max, output_data, output_dims); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void L2Pool(const float* input_data, const Dims<4>& input_dims, int stride, int pad_width, int pad_height, int filter_width, int filter_height, float* output_data, const Dims<4>& output_dims) { L2Pool<Ac>(input_data, input_dims, stride, stride, pad_width, pad_height, filter_width, filter_height, output_data, output_dims); } inline void Softmax(const float* input_data, const Dims<4>& input_dims, float beta, float* output_data, const Dims<4>& output_dims) { Softmax(input_data, DimsToShape(input_dims), beta, output_data, DimsToShape(output_dims)); } inline void Softmax(const uint8* input_data, const Dims<4>& input_dims, int32 input_beta_multiplier, int32 input_beta_left_shift, int diff_min, uint8* output_data, const Dims<4>& output_dims) { Softmax(input_data, DimsToShape(input_dims), input_beta_multiplier, input_beta_left_shift, diff_min, output_data, DimsToShape(output_dims)); } inline void LogSoftmax(const float* input_data, const Dims<4>& input_dims, float* output_data, const Dims<4>& output_dims) { LogSoftmax(input_data, DimsToShape(input_dims), output_data, DimsToShape(output_dims)); } inline void LogSoftmax(const uint8* input_data, const Dims<4>& input_dims, int32 input_multiplier, int32 input_left_shift, int32 reverse_scaling_divisor, int32 reverse_scaling_right_shift, int diff_min, uint8* output_data, const Dims<4>& output_dims) { LogSoftmax(input_data, DimsToShape(input_dims), input_multiplier, input_left_shift, reverse_scaling_divisor, reverse_scaling_right_shift, diff_min, output_data, DimsToShape(output_dims)); } inline void Logistic(const float* input_data, const Dims<4>& input_dims, float* output_data, const Dims<4>& output_dims) { Logistic(DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } inline void Logistic(const uint8* input_data, const Dims<4>& input_dims, int32 input_zero_point, int32 input_range_radius, int32 input_multiplier, int input_left_shift, uint8* output_data, const Dims<4>& output_dims) { Logistic(input_data, DimsToShape(input_dims), input_zero_point, input_range_radius, input_multiplier, input_left_shift, output_data, DimsToShape(output_dims)); } inline void Logistic(const int16* input_data, const Dims<4>& input_dims, int16* output_data, const Dims<4>& output_dims) { Logistic(DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } inline void Tanh(const float* input_data, const Dims<4>& input_dims, float* output_data, const Dims<4>& output_dims) { Tanh(DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } inline void Tanh(const uint8* input_data, const Dims<4>& input_dims, int32 input_zero_point, int32 input_range_radius, int32 input_multiplier, int input_left_shift, uint8* output_data, const Dims<4>& output_dims) { Tanh(input_data, DimsToShape(input_dims), input_zero_point, input_range_radius, input_multiplier, input_left_shift, output_data, DimsToShape(output_dims)); } inline void Tanh(const int16* input_data, const Dims<4>& input_dims, int input_left_shift, int16* output_data, const Dims<4>& output_dims) { Tanh(input_data, DimsToShape(input_dims), input_left_shift, output_data, DimsToShape(output_dims)); } template <typename T> inline void DepthToSpace(const T* input_data, const Dims<4>& input_dims, int block_size, T* output_data, const Dims<4>& output_dims) { tflite::DepthToSpaceParams op_params; op_params.block_size = block_size; DepthToSpace(op_params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } template <typename T> inline void SpaceToDepth(const T* input_data, const Dims<4>& input_dims, int block_size, T* output_data, const Dims<4>& output_dims) { tflite::SpaceToDepthParams op_params; op_params.block_size = block_size; SpaceToDepth(op_params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } template <typename T> inline void Mul(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T output_activation_min, T output_activation_max, T* output_data, const Dims<4>& output_dims) { tflite::ArithmeticParams op_params; SetActivationParams(output_activation_min, output_activation_max, &op_params); Mul(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac> void Mul(const float* input1_data, const Dims<4>& input1_dims, const float* input2_data, const Dims<4>& input2_dims, float* output_data, const Dims<4>& output_dims) { float output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); tflite::ArithmeticParams op_params; SetActivationParams(output_activation_min, output_activation_max, &op_params); Mul(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <typename T> void BroadcastMul(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T output_activation_min, T output_activation_max, T* output_data, const Dims<4>& output_dims) { tflite::ArithmeticParams op_params; SetActivationParams(output_activation_min, output_activation_max, &op_params); BroadcastMul4DSlow(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } // legacy, for compatibility with old checked-in code template <FusedActivationFunctionType Ac, typename T> void BroadcastMul(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T* output_data, const Dims<4>& output_dims) { T output_activation_min, output_activation_max; GetActivationMinMax(Ac, &output_activation_min, &output_activation_max); tflite::ArithmeticParams op_params; SetActivationParams(output_activation_min, output_activation_max, &op_params); BroadcastMul4DSlow(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } inline void Mul(const int16* input1_data, const Dims<4>& input1_dims, const int16* input2_data, const Dims<4>& input2_dims, int16* output_data, const Dims<4>& output_dims) { tflite::ArithmeticParams op_params; // No params in this version. Mul(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } inline void Mul(const int16* input1_data, const Dims<4>& input1_dims, const int16* input2_data, const Dims<4>& input2_dims, int32 output_offset, int32 output_activation_min, int32 output_activation_max, uint8* output_data, const Dims<4>& output_dims) { tflite::ArithmeticParams op_params; op_params.quantized_activation_min = output_activation_min; op_params.quantized_activation_max = output_activation_max; op_params.output_offset = output_offset; Mul(op_params, DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } inline void LocalResponseNormalization(const float* input_data, const Dims<4>& input_dims, int range, float bias, float alpha, float beta, float* output_data, const Dims<4>& output_dims) { tflite::LocalResponseNormalizationParams op_params; op_params.range = range; op_params.bias = bias; op_params.alpha = alpha; op_params.beta = beta; LocalResponseNormalization(op_params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } template <typename SrcT, typename DstT> void Cast(const SrcT* input_data, const Dims<4>& input_dims, DstT* output_data, const Dims<4>& output_dims) { Cast(DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } inline void Floor(const float* input_data, const Dims<4>& input_dims, float* output_data, const Dims<4>& output_dims) { Floor(DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } template <typename T> inline void ResizeBilinear(const T* input_data, const Dims<4>& input_dims, const int32* output_size_data, const Dims<4>& output_size_dims, T* output_data, const Dims<4>& output_dims, bool align_corners) { tflite::ResizeBilinearParams op_params; op_params.align_corners = align_corners; op_params.half_pixel_centers = false; ResizeBilinear(op_params, DimsToShape(input_dims), input_data, DimsToShape(output_size_dims), output_size_data, DimsToShape(output_dims), output_data); } // legacy, for compatibility with old checked-in code inline void ResizeBilinear(const float* input_data, const Dims<4>& input_dims, const int32* output_size_data, const Dims<4>& output_size_dims, float* output_data, const Dims<4>& output_dims) { ResizeBilinear<float>(input_data, input_dims, output_size_data, output_size_dims, output_data, output_dims, /*align_corners=*/false); } inline void ResizeBilinear(const uint8* input_data, const Dims<4>& input_dims, const int32* output_size_data, const Dims<4>& output_size_dims, uint8* output_data, const Dims<4>& output_dims) { ResizeBilinear<uint8>(input_data, input_dims, output_size_data, output_size_dims, output_data, output_dims, /*align_corners=*/false); } template <typename T> inline void SpaceToBatchND(const T* input_data, const Dims<4>& input_dims, const int32* block_shape_data, const Dims<4>& block_shape_dims, const int32* paddings_data, const Dims<4>& paddings_dims, T* output_data, const Dims<4>& output_dims, const int32_t pad_value) { tflite::SpaceToBatchParams op_params; op_params.output_offset = pad_value; SpaceToBatchND(op_params, DimsToShape(input_dims), input_data, DimsToShape(block_shape_dims), block_shape_data, DimsToShape(paddings_dims), paddings_data, DimsToShape(output_dims), output_data); } template <typename T> inline void SpaceToBatchND(const T* input_data, const Dims<4>& input_dims, const int32* block_shape_data, const Dims<4>& block_shape_dims, const int32* paddings_data, const Dims<4>& paddings_dims, T* output_data, const Dims<4>& output_dims) { tflite::SpaceToBatchParams op_params; op_params.output_offset = 0; SpaceToBatchND(op_params, DimsToShape(input_dims), input_data, DimsToShape(block_shape_dims), block_shape_data, DimsToShape(paddings_dims), paddings_data, DimsToShape(output_dims), output_data); } template <typename T> inline void BatchToSpaceND(const T* input_data, const Dims<4>& input_dims, const int32* block_shape_data, const Dims<4>& block_shape_dims, const int32* crops_data, const Dims<4>& crops_dims, T* output_data, const Dims<4>& output_dims) { BatchToSpaceND(DimsToShape(input_dims), input_data, DimsToShape(block_shape_dims), block_shape_data, DimsToShape(crops_dims), crops_data, DimsToShape(output_dims), output_data); } // Legacy signature, function covered both Pad and PadV2. template <typename T> inline void PadV2(const T* input_data, const Dims<4>& input_dims, const std::vector<int>& left_paddings, const std::vector<int>& right_paddings, T* output_data, const Dims<4>& output_dims, const T pad_value) { TFLITE_DCHECK_EQ(left_paddings.size(), 4); TFLITE_DCHECK_EQ(right_paddings.size(), 4); tflite::PadParams op_params; op_params.left_padding_count = 4; op_params.right_padding_count = 4; for (int i = 0; i < 4; ++i) { op_params.left_padding[i] = left_paddings[3 - i]; op_params.right_padding[i] = right_paddings[3 - i]; } // SetFloatOrInt(pad_value, &op_params.pad_value); const T pad_value_copy = pad_value; Pad(op_params, DimsToShape(input_dims), input_data, &pad_value_copy, DimsToShape(output_dims), output_data); } // Old Pad that calls legacy PadV2. template <typename T> inline void Pad(const T* input_data, const Dims<4>& input_dims, const std::vector<int>& left_paddings, const std::vector<int>& right_paddings, T* output_data, const Dims<4>& output_dims, const int32_t pad_value) { const T converted_pad_value = static_cast<T>(pad_value); PadV2<T>(input_data, input_dims, left_paddings, right_paddings, output_data, output_dims, converted_pad_value); } // Old Pad that only padded with 0. template <typename T> inline void Pad(const T* input_data, const Dims<4>& input_dims, const std::vector<int>& left_paddings, const std::vector<int>& right_paddings, T* output_data, const Dims<4>& output_dims) { const T pad_value = static_cast<T>(0); PadV2<T>(input_data, input_dims, left_paddings, right_paddings, output_data, output_dims, pad_value); } template <typename T> void TensorFlowMinimum(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, T* output_data, const Dims<4>& output_dims) { Minimum(DimsToShape(input1_dims), input1_data, input2_data, DimsToShape(output_dims), output_data); } template <typename T> void TensorFlowMaximum(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, T* output_data, const Dims<4>& output_dims) { Maximum(DimsToShape(input1_dims), input1_data, input2_data, DimsToShape(output_dims), output_data); } template <typename T, typename Op> void TensorFlowMaximumMinimum(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T* output_data, const Dims<4>& output_dims, Op op) { MaximumMinimumBroadcastSlow(DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data, op); } template <typename T1, typename T2, typename T3> void ArgMax(const T3* axis, const T1* input_data, const tflite::Dims<4>& input_dims, T2* output_data, const tflite::Dims<4>& output_dims) { // Assumes the input always has 4 dimensions, and therefore, // output always has three dimensions. auto output_shape = RuntimeShape( {output_dims.sizes[2], output_dims.sizes[1], output_dims.sizes[0]}); // Another way to interpret this is that output_dims.sizes[4] is always 1. TFLITE_DCHECK_EQ(output_shape.FlatSize(), DimsToShape(output_dims).FlatSize()); // Legacy path only supported this. TFLITE_DCHECK_EQ(axis[0], 3); ArgMinMax(DimsToShape(input_dims), input_data, axis, output_shape, output_data, std::greater<T1>()); } template <typename T1, typename T2, typename T3, typename Cmp> void ArgMinMax(const T3* axis, const T1* input_data, const Dims<4>& input_dims, T2* output_data, const Dims<4>& output_dims, const Cmp& cmp) { ArgMinMax(axis, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data, cmp); } template <typename T> inline void Pow(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T* output_data, const Dims<4>& output_dims) { Pow(DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } template <typename T> inline void BroadcastPow(const T* input1_data, const Dims<4>& input1_dims, const T* input2_data, const Dims<4>& input2_dims, T* output_data, const Dims<4>& output_dims) { BroadcastPow4DSlow(DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data); } // R: Result type. T1: Input 1 type. T2: Input 2 type. template <typename R, typename T1, typename T2> inline void BroadcastBinaryFunction(const T1* input1_data, const Dims<4>& input1_dims, const T2* input2_data, const Dims<4>& input2_dims, R* output_data, const Dims<4>& output_dims, R (*func)(T1, T2)) { BroadcastBinaryFunction(DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data, func); } // R: Result type. T1: Input 1 type. T2: Input 2 type. template <typename R, typename T1, typename T2> inline void BinaryFunction(const T1* input1_data, const Dims<4>& input1_dims, const T2* input2_data, const Dims<4>& input2_dims, R* output_data, const Dims<4>& output_dims, R (*func)(T1, T2)) { BinaryFunction(DimsToShape(input1_dims), input1_data, DimsToShape(input2_dims), input2_data, DimsToShape(output_dims), output_data, func); } template <typename T> inline void Slice(const T* input_data, const Dims<4>& input_dims, const std::vector<int>& begin, const std::vector<int>& size, T* output_data, const Dims<4>& output_dims) { tflite::SliceParams op_params; op_params.begin_count = 4; op_params.size_count = 4; for (int i = 0; i < 4; ++i) { op_params.begin[i] = begin[3 - i]; op_params.size[i] = size[3 - i]; } Slice(op_params, DimsToShape(input_dims), input_data, DimsToShape(output_dims), output_data); } } // namespace reference_ops } // namespace tflite #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_LEGACY_REFERENCE_OPS_H_
[ "gardener@tensorflow.org" ]
gardener@tensorflow.org
720029270cd32c3ce1346ffbe9fde1acca3e2f5a
beda62f6f4a8ab7f5c9c3a66cc3d7ef5a1d21f78
/DrinkWater/DrinkWater/DrinkWaterDlg.cpp
c092a6def849543b39f821c68614d10490bd5563
[]
no_license
radtek/c-
2295287d5757120fa07f17f6a34b0bb293c1e1d3
d0715068462c29d7b4a01ac8905ae76d207db16d
refs/heads/master
2020-11-24T22:20:43.658511
2018-09-19T02:04:26
2018-09-19T02:04:26
null
0
0
null
null
null
null
GB18030
C++
false
false
12,409
cpp
// DrinkWaterDlg.cpp : 实现文件 // #include "stdafx.h" #include "DrinkWater.h" #include "DrinkWaterDlg.h" #include "afxdialogex.h" #ifdef _DEBUG #define new DEBUG_NEW #endif //获取当前文件位置 CString GetCurrentPath() { HMODULE module = GetModuleHandle(0); char pFileName[MAX_PATH]; GetModuleFileName(module, pFileName, MAX_PATH); CString csFullPath(pFileName); int nPos = csFullPath.ReverseFind( _T('\\') ); if( nPos < 0 ) return CString(""); else return csFullPath.Left( nPos ); } // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 class CAboutDlg : public CDialogEx { public: CAboutDlg(); // 对话框数据 enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 // 实现 protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) END_MESSAGE_MAP() // CDrinkWaterDlg 对话框 CDrinkWaterDlg::CDrinkWaterDlg(CWnd* pParent /*=NULL*/) : CDialogEx(CDrinkWaterDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_bIconIsExist = FALSE; m_bPlaySoundOnce = FALSE; } void CDrinkWaterDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_STATIC_PIC, m_pic); } BEGIN_MESSAGE_MAP(CDrinkWaterDlg, CDialogEx) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_CLOSE() ON_BN_CLICKED(IDOK, &CDrinkWaterDlg::OnBnClickedOk) ON_WM_DESTROY() ON_MESSAGE(WM_SYSTEMTRAY, OnSystemtray)//添加消息映射 ON_COMMAND(ID_32777, &CDrinkWaterDlg::On32777) ON_COMMAND(ID_32781, &CDrinkWaterDlg::On32781) ON_WM_TIMER() END_MESSAGE_MAP() // CDrinkWaterDlg 消息处理程序 BOOL CDrinkWaterDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // 将“关于...”菜单项添加到系统菜单中。 // IDM_ABOUTBOX 必须在系统命令范围内。 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); m_strCulPath = GetCurrentPath(); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { BOOL bNameValid; CString strAboutMenu; bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); ASSERT(bNameValid); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 // TODO: 在此添加额外的初始化代码 SetWindowPos(&wndTopMost,0,0,0,0, SWP_NOMOVE | SWP_NOSIZE); if (!m_bIconIsExist) { m_NotifyIcon.cbSize = sizeof(NOTIFYICONDATA); //NotifyIcon.hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_NotifyIcon.hIcon = m_hIcon; //上面那句也可以 m_NotifyIcon.hWnd = m_hWnd; lstrcpy(m_NotifyIcon.szTip,_T("喝水提醒")); m_NotifyIcon.uCallbackMessage = WM_SYSTEMTRAY; m_NotifyIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; m_bIconIsExist = Shell_NotifyIcon(NIM_ADD,&m_NotifyIcon); //MoveWindow(0,0,0,0); //SetTimer(TIMER_HIDE_WINDOW,1,NULL); SetTimer(TIMER_DRINK_WATER,1000,NULL); } m_editFont.CreatePointFont(300, "宋体"); GetDlgItem(IDC_ST_GREET)->SetFont(&m_editFont); GetDlgItem(IDC_ST_DRINK)->SetFont(&m_editFont); m_bStartUp = bGetStartUp(); m_pic.SetIcon(m_hIcon); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE } void CDrinkWaterDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialogEx::OnSysCommand(nID, lParam); } } // 如果向对话框添加最小化按钮,则需要下面的代码 // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序, // 这将由框架自动完成。 void CDrinkWaterDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // 用于绘制的设备上下文 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // 使图标在工作区矩形中居中 int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // 绘制图标 dc.DrawIcon(x, y, m_hIcon); } else { CDialogEx::OnPaint(); } } //当用户拖动最小化窗口时系统调用此函数取得光标 //显示。 HCURSOR CDrinkWaterDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CDrinkWaterDlg::OnClose() { // TODO: 在此添加消息处理程序代码和/或调用默认值 // TODO: 在此添加控件通知处理程序代码 if(Shell_NotifyIcon(NIM_ADD,&m_NotifyIcon)) m_bIconIsExist = TRUE; this->ShowWindow(HIDE_WINDOW); //CDialogEx::OnClose(); } void CDrinkWaterDlg::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 OnClose(); } afx_msg LRESULT CDrinkWaterDlg::OnSystemtray(WPARAM wParam, LPARAM lParam) { //wParam接收的是图标的ID,而lParam接收的是鼠标的行为 // if(wParam!=IDR_MAINFRAME) // return 1; switch(lParam) { case WM_RBUTTONDOWN://右键起来时弹出快捷菜单 { CMenu menuexit; //menu.LoadMenuW(IDR_MENU);//加载菜单资源 if (m_bStartUp) { menuexit.LoadMenu(IDR_MENU1); } else { menuexit.LoadMenu(IDR_MENU2); } CMenu *pPopup=menuexit.GetSubMenu(0); CPoint mypoint; GetCursorPos(&mypoint); //ClientToScreen(&mypoint);//将客户区坐标转换为屏幕坐标 SetForegroundWindow(); PostMessage(WM_NULL,0,0); //显示右键菜单,由视类窗口拥有。 pPopup->TrackPopupMenu(TPM_LEFTALIGN,mypoint.x,mypoint.y,this); } break; case WM_LBUTTONDBLCLK://左键单击的处理 { //ModifyStyleEx(0,WS_EX_TOPMOST); //可以改变窗口的显示风格 //OnTimer(TIMER_DRINK_WATER); showDlg(); } break; } return 0; } void CDrinkWaterDlg::OnBnClickedMfcmenubutton1() { // TODO: 在此添加控件通知处理程序代码 } void CDrinkWaterDlg::OnDestroy() { if(Shell_NotifyIcon(NIM_DELETE,&m_NotifyIcon)) m_bIconIsExist = FALSE; //MessageBox("OnDestroy"); CDialogEx::OnDestroy(); // TODO: 在此处添加消息处理程序代码 } void CDrinkWaterDlg::On32777() { // TODO: 在此添加命令处理程序代码 //托盘右键开机启动 Autostart(); } void CDrinkWaterDlg::On32781() { // TODO: 在此添加命令处理程序代码 //托盘右键退出 CDialogEx::OnCancel(); } void CDrinkWaterDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CTime time = CTime::GetCurrentTime(); CString strHour = time.Format("%H"); CString strMin = time.Format("%M"); CString strSec = time.Format("%S"); int nHour = atoi(strHour); CString strGreet = "问候"; switch(nIDEvent) { case TIMER_HIDE_WINDOW: ShowWindow(SW_HIDE); KillTimer(TIMER_HIDE_WINDOW); break; case TIMER_DRINK_WATER: if (m_bIconIsExist) ;//break; SetDlgItemText(IDC_ST_HOUR,strHour); SetDlgItemText(IDC_ST_MINUTE,strMin); SetDlgItemText(IDC_ST_SECOND,strSec); if (nHour >= 0 && nHour < 5) strGreet = "凌晨好"; else if (nHour >= 5 && nHour < 7) strGreet = "清晨好"; else if (nHour >= 7 && nHour < 9) strGreet = "早上好"; else if (nHour >= 9 && nHour < 12) strGreet = "上午好"; else if (nHour >= 12 && nHour < 14) strGreet = "中午好"; else if (nHour >= 14 && nHour < 17) strGreet = "下午好"; else if (nHour >= 17 && nHour < 19) strGreet = "傍晚好"; else if (nHour >= 19 && nHour < 21) strGreet = "晚上好"; else if (nHour >= 21 && nHour < 24) strGreet = "深夜好"; SetDlgItemText(IDC_ST_GREET,strGreet); UpdateWindow(); GetDlgItem(IDC_ST_DRINK)->ShowWindow(SW_SHOW); SetTimer(TIMER_BLINK,700,NULL); if (m_bPlaySoundOnce) { m_bPlaySoundOnce = FALSE; //PlaySound(m_strCulPath+"\\sound\\drink.wav",NULL, SND_ASYNC|SND_NODEFAULT ); CString strPlaySound = strGreet.Left(4) + "|好|快去喝水了"; DrinkPlaySound(strPlaySound); } if ( (strMin == "30" || strMin == "00") && strSec == "00") showDlg(true); break; case TIMER_BLINK: GetDlgItem(IDC_ST_DRINK)->ShowWindow(SW_HIDE); KillTimer(TIMER_BLINK); break; default: break; } CDialogEx::OnTimer(nIDEvent); } void CDrinkWaterDlg::showDlg(bool bAuto) { m_bIconIsExist = FALSE; if (bAuto) m_bPlaySoundOnce = TRUE; if(Shell_NotifyIcon(NIM_DELETE,&m_NotifyIcon)) m_bIconIsExist = FALSE; CRect cr; GetClientRect(&cr);//获取对话框客户区域大小 ClientToScreen(&cr);//转换为荧幕坐标 int x = GetSystemMetrics ( SM_CXSCREEN ); int y= GetSystemMetrics ( SM_CYSCREEN ); MoveWindow((x - cr.Width())/2 ,cr.top, cr.Width(),cr.Height()); ShowWindow(SW_SHOWNORMAL); } //字符串分割 int SplitString(const CString str, char split, CStringArray &strArray) { strArray.RemoveAll(); CString strTemp = str; int iIndex = 0; while (1) { iIndex = strTemp.Find(split); if(iIndex >= 0) { strArray.Add(strTemp.Left(iIndex)); strTemp = strTemp.Right(strTemp.GetLength()-iIndex-1); } else { break; } } strArray.Add(strTemp); return strArray.GetSize(); } void CDrinkWaterDlg::DrinkPlaySound(CString strSound) { CStringArray strArray; int nArraylength = SplitString(strSound,'|',strArray); if(nArraylength == 0) return; for (int i = 0; i < nArraylength; i++) { CString strPlaySound = m_strCulPath + "\\sound\\" + strArray[i] + ".wav"; //MessageBox(strPlaySound); if (i == nArraylength - 1) PlaySound(strPlaySound,NULL, SND_ASYNC ); else PlaySound(strPlaySound,NULL, SND_SYNC ); } } bool CDrinkWaterDlg::bGetStartUp() { bool bRet = false; HKEY hKey; CString lpRun = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); long lRet = RegOpenKeyEx(HKEY_CURRENT_USER, lpRun, 0, KEY_ALL_ACCESS, &hKey); if(lRet == ERROR_SUCCESS) { DWORD dwType = REG_SZ; DWORD dwSize; RegQueryValueEx(hKey,_T("DrinkWater"),NULL,NULL,NULL,&dwSize); TCHAR *szData = new TCHAR[dwSize]; //szData[dwSize-1] = '\0'; lRet = RegQueryValueEx(hKey,_T("DrinkWater"),NULL,&dwType,(LPBYTE)szData,&dwSize); //lRet = RegSetValueEx(hKey, _T("DrinkWater"), 0, REG_SZ, (LPBYTE)pFileName, (lstrlen(pFileName) + 1)*sizeof(TCHAR)); //lRet = RegQueryValueEx(hKey, _T("ddd"), NULL, NULL, (LPBYTE)&dwData, &dwSize); //关闭注册表 RegCloseKey(hKey); if(lRet == ERROR_SUCCESS) { bRet = true; } else { //MessageBox(_T("读取失败!"),_T("提示")); } delete []szData; } return bRet; } void CDrinkWaterDlg::Autostart() { m_bStartUp = !m_bStartUp; HKEY hKey; //找到系统的启动项 CString lpRun = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); if(m_bStartUp) { //打开启动项Key long lRet = RegOpenKeyEx(HKEY_CURRENT_USER, lpRun, 0, KEY_ALL_ACCESS, &hKey); if(lRet == ERROR_SUCCESS) { TCHAR pFileName[MAX_PATH] = {0}; //得到程序自身的全路径 DWORD dwRet = GetModuleFileName(NULL, pFileName, MAX_PATH); TRACE(pFileName); //添加一个子Key,并设置值 // 下面"Demo"是应用程序名字(不需要加后缀.exe) lRet = RegSetValueEx(hKey, _T("DrinkWater"), 0, REG_SZ, (LPBYTE)pFileName, (lstrlen(pFileName) + 1)*sizeof(TCHAR)); //关闭注册表 RegCloseKey(hKey); if(lRet != ERROR_SUCCESS) { //MessageBox(_T("系统参数错误,设置自启动失败!"),_T("提示")); } else { //MessageBox(_T("开机启动设置成功!"), _T("提示")); } } else { //MessageBox(_T("系统参数错误,设置自启动失败!"),_T("提示")); } } else { long lRet = RegOpenKeyEx(HKEY_CURRENT_USER, lpRun, 0, KEY_ALL_ACCESS, &hKey); if(lRet == ERROR_SUCCESS) { RegDeleteValue(hKey, _T("DrinkWater")); //关闭注册表 RegCloseKey(hKey); //MessageBox(_T("关闭开机启动成功!"), _T("提示")); } } }
[ "625010179@qq.com" ]
625010179@qq.com
1968655776ca19422ee38edea881875fad10e872
5933373d7421235d7978ef1f04c90c84d4c32c6b
/contrib/psol/include/net/instaweb/system/public/system_server_context.h
5805e4a5b8603b289cc9178cb141ff142c6e74b8
[ "MIT" ]
permissive
heartshare/openresty-bundle
1343287bca0c747c562b0ba2e640e613d9db4884
2a8f4a2bff14fad719fc516c5836aac47c289c67
refs/heads/master
2021-01-22T07:27:55.759619
2014-08-27T13:48:42
2014-08-27T13:48:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,089
h
// Copyright 2013 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Author: jefftk@google.com (Jeff Kaufman) #ifndef NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_SERVER_CONTEXT_H_ #define NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_SERVER_CONTEXT_H_ #include "net/instaweb/rewriter/public/server_context.h" #include "net/instaweb/http/public/request_context.h" #include "net/instaweb/util/public/basictypes.h" #include "net/instaweb/util/public/scoped_ptr.h" #include "pagespeed/kernel/base/string_util.h" #include "pagespeed/kernel/base/string.h" namespace net_instaweb { class AbstractMutex; class AsyncFetch; class GoogleUrl; class Histogram; class QueryParams; class RewriteDriver; class RewriteDriverFactory; class RewriteOptions; class RewriteStats; class SharedMemStatistics; class Statistics; class SystemCaches; class SystemRewriteDriverFactory; class SystemRewriteOptions; class UrlAsyncFetcherStats; class Variable; class Writer; // A server context with features specific to a PSOL port on a unix system. class SystemServerContext : public ServerContext { public: // Identifies whether the user arrived at an admin page from a // /pagespeed_admin handler or a /*_pagespeed_statistics handler. // The main difference between these is that the _admin site might in the // future grant more privileges than the statistics site did, such as flushing // cache. But it also affects the syntax of the links created to sub-pages // in the top navigation bar. enum AdminSource { kPageSpeedAdmin, kStatistics, kOther }; SystemServerContext(RewriteDriverFactory* factory, StringPiece hostname, int port); virtual ~SystemServerContext(); // Implementations should call this method on every request, both for html and // resources, to avoid serving stale resources. // // TODO(jmarantz): allow a URL-based mechanism to flush cache, even if // we implement it by simply writing the cache.flush file so other // servers can see it. Note that using shared-memory is not a great // plan because we need the cache-invalidation to persist across server // restart. void FlushCacheIfNecessary(); SystemRewriteOptions* global_system_rewrite_options(); GoogleString hostname_identifier() { return hostname_identifier_; } static void InitStats(Statistics* statistics); // Called by SystemRewriteDriverFactory::ChildInit. See documentation there. virtual void ChildInit(SystemRewriteDriverFactory* factory); // Initialize this ServerContext to have its own statistics domain. Must be // called after global_statistics has been created and had ::InitStats called // on it. void CreateLocalStatistics(Statistics* global_statistics, SystemRewriteDriverFactory* factory); // Whether ChildInit() has been called yet. Exposed so debugging code can // verify initialization proceeded properly. bool initialized() const { return initialized_; } // Normally we just fetch with the default UrlAsyncFetcher, generally serf, // but there are some cases where we need to do something more complex: // - Local requests: requests for resources on this host should go directly // to the local IP. // - Fetches directly from other modules: in Apache we have an experimental // pathway where we can make fetches directly from mod_spdy without going // out to the network. // - Custom fetch headers: before continuing with the fetch we want to add // request headers. // Session fetchers allow us to make these decisions. Here we may update // driver->async_fetcher() to be a special fetcher just for this request. virtual void ApplySessionFetchers(const RequestContextPtr& req, RewriteDriver* driver); // Accumulate in a histogram the amount of time spent rewriting HTML. // TODO(sligocki): Remove in favor of RewriteStats::rewrite_latency_histogram. void AddHtmlRewriteTimeUs(int64 rewrite_time_us); // Hook called after all configuration parsing is done to support implementers // like ApacheServerContext that need to collapse configuration inside the // config overlays into actual RewriteOptions objects. It will also compute // signatures when done, and by default that's the only thing it does. virtual void CollapseConfigOverlaysAndComputeSignatures(); // Returns the spdy-specific configuration, or NULL if there is none // specified. virtual const SystemRewriteOptions* SpdyGlobalConfig() const; // Handler which serves PSOL console. // Note: ConsoleHandler always succeeds. void ConsoleHandler(const SystemRewriteOptions& options, AdminSource source, const QueryParams& query_params, AsyncFetch* fetch); // Displays recent Info/Warning/Error messages. void MessageHistoryHandler(AdminSource source, AsyncFetch* fetch); // Deprecated handler for graphs in the PSOL console. void StatisticsGraphsHandler(Writer* writer); // Handle a request for /pagespeed_admin/*, which is a launching // point for all the administrator pages including stats, // message-histogram, console, etc. void AdminPage(bool is_global, const GoogleUrl& stripped_gurl, const QueryParams& query_params, const RewriteOptions* options, AsyncFetch* fetch); // Handle a request for the legacy /*_pagespeed_statistics page, which also // serves as a launching point for a subset of the admin pages. Because the // admin pages are not uniformly sensitive, an existing PageSpeed user might // have granted public access to /mod_pagespeed_statistics, but we don't // want that to automatically imply access to the server cache. void StatisticsPage(bool is_global, const QueryParams& query_params, const RewriteOptions* options, AsyncFetch* fetch); protected: // Flush the cache by updating the cache flush timestamp in the global // options. This will change its signature, which is part of the cache key, // and so all previously cached entries will be unreachable. // // Returns true if it actually updated the timestamp, false if the existing // cache flush timestamp was newer or the same as the one provided. // // Subclasses which add aditional configurations need to override this method // to additionally update the cache flush timestamp in those other // configurations. See ApacheServerContext::UpdateCacheFlushTimestampMs where // the separate SpdyConfig that mod_pagespeed uses when using SPDY also needs // to have it's timestamp bumped. virtual bool UpdateCacheFlushTimestampMs(int64 timestamp_ms); // Hook for implementations to support fetching directly from the spdy module. virtual void MaybeApplySpdySessionFetcher(const RequestContextPtr& request, RewriteDriver* driver) {} // Returns JSON used by the PageSpeed Console JavaScript. void ConsoleJsonHandler(const QueryParams& params, AsyncFetch* fetch); // Handler for /mod_pagespeed_statistics and // /ngx_pagespeed_statistics, as well as // /...pagespeed__global_statistics. If the latter, // is_global_request should be true. // // Returns NULL on success, otherwise the returned error string // should be passed along to the user and the contents of writer and // content_type should be ignored. // // In systems without a spdy-specific config, spdy_config should be // null. void StatisticsHandler(bool is_global_request, AdminSource source, AsyncFetch* fetch); // Print details fo the SPDY configuration. void PrintSpdyConfig(AdminSource source, AsyncFetch* fetch); // Print details fo the non-SPDY configuration. void PrintNormalConfig(AdminSource source, AsyncFetch* fetch); // Print statistics about the caches. In the future this will also // be a launching point for examining cache entries and purging them. void PrintCaches(bool is_global, AdminSource source, const QueryParams& query_params, const RewriteOptions* options, AsyncFetch* fetch); // Print histograms showing the dynamics of server activity. void PrintHistograms(bool is_global_request, AdminSource source, AsyncFetch* fetch); Variable* statistics_404_count(); private: bool initialized_; bool use_per_vhost_statistics_; // State used to implement periodic polling of $FILE_PREFIX/cache.flush. // last_cache_flush_check_sec_ is ctor-initialized to 0 so the first // time we Poll we will read the file. scoped_ptr<AbstractMutex> cache_flush_mutex_; int64 last_cache_flush_check_sec_; // seconds since 1970 Variable* cache_flush_count_; Variable* cache_flush_timestamp_ms_; Histogram* html_rewrite_time_us_histogram_; // Non-NULL if we have per-vhost stats. scoped_ptr<Statistics> split_statistics_; // May be NULL. Owned by *split_statistics_. SharedMemStatistics* local_statistics_; // These are non-NULL if we have per-vhost stats. scoped_ptr<RewriteStats> local_rewrite_stats_; scoped_ptr<UrlAsyncFetcherStats> stats_fetcher_; // hostname_identifier_ equals to "server_hostname:port" of the server. It's // used to distinguish the name of shared memory so that each vhost has its // own SharedCircularBuffer. GoogleString hostname_identifier_; SystemCaches* system_caches_; DISALLOW_COPY_AND_ASSIGN(SystemServerContext); }; } // namespace net_instaweb #endif // NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_SERVER_CONTEXT_H_
[ "bhanlon@inviqa.com" ]
bhanlon@inviqa.com
a7836607b5819358e36b67aaa46f5ca2ecfc4988
1af49694004c6fbc31deada5618dae37255ce978
/chromeos/components/sensors/fake_sensor_service.h
1a2b6f0e524b0ceed5d0ac436486743712be5689
[ "BSD-3-Clause" ]
permissive
sadrulhc/chromium
59682b173a00269ed036eee5ebfa317ba3a770cc
a4b950c23db47a0fdd63549cccf9ac8acd8e2c41
refs/heads/master
2023-02-02T07:59:20.295144
2020-12-01T21:32:32
2020-12-01T21:32:32
317,678,056
3
0
BSD-3-Clause
2020-12-01T21:56:26
2020-12-01T21:56:25
null
UTF-8
C++
false
false
2,257
h
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROMEOS_COMPONENTS_SENSORS_FAKE_SENSOR_SERVICE_H_ #define CHROMEOS_COMPONENTS_SENSORS_FAKE_SENSOR_SERVICE_H_ #include <map> #include <set> #include <vector> #include "base/sequence_checker.h" #include "chromeos/components/sensors/fake_sensor_device.h" #include "chromeos/components/sensors/mojom/sensor.mojom.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote_set.h" namespace chromeos { namespace sensors { class FakeSensorService final : public mojom::SensorService { public: FakeSensorService(); FakeSensorService(const FakeSensorService&) = delete; FakeSensorService& operator=(const FakeSensorService&) = delete; ~FakeSensorService() override; bool is_bound(); void Bind(mojo::PendingReceiver<mojom::SensorService> pending_receiver); void OnServiceDisconnect(); void SetDevice(int32_t iio_device_id, std::set<mojom::DeviceType> types, std::unique_ptr<FakeSensorDevice> sensor_device); // Implementation of mojom::SensorService. void GetDeviceIds(mojom::DeviceType type, GetDeviceIdsCallback callback) override; void GetAllDeviceIds(GetAllDeviceIdsCallback callback) override; void GetDevice( int32_t iio_device_id, mojo::PendingReceiver<mojom::SensorDevice> device_request) override; void RegisterNewDevicesObserver( mojo::PendingRemote<mojom::SensorServiceNewDevicesObserver> observer) override; private: struct DeviceData { DeviceData(); DeviceData(DeviceData&&); DeviceData& operator=(DeviceData&&); ~DeviceData(); std::set<mojom::DeviceType> types; std::unique_ptr<FakeSensorDevice> sensor_device; }; // First is the iio_device_id, second is the device's data. std::map<int32_t, DeviceData> devices_; mojo::Receiver<mojom::SensorService> receiver_{this}; mojo::RemoteSet<mojom::SensorServiceNewDevicesObserver> observers_; SEQUENCE_CHECKER(sequence_checker_); }; } // namespace sensors } // namespace chromeos #endif // CHROMEOS_COMPONENTS_SENSORS_FAKE_SENSOR_SERVICE_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
4857ba441276bcbc5d5374f1d514ac377df6875f
f7cd49ea71d710e40d5d655aaf745e327e39807a
/Engine_DX_MAKEFILE_PROJ/Engine/Sources/direct_api.cpp
a753dca1f8a868d3e7c42e64ce0fe850c0fd0f9e
[]
no_license
Draver93/oldProjects
01c4df5beed6c8a71b49828ad38d15eaa3cc7ea6
84eab3c327870ee42d996da6b1778265d1a80059
refs/heads/master
2021-08-23T04:43:21.321035
2017-12-03T10:47:07
2017-12-03T10:47:07
112,919,008
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
5,066
cpp
#include "direct_api.h" direct_api::direct_api() { } direct_api::~direct_api() { if (p_direct3d)p_direct3d->Release(); if (p_direct3d_device)p_direct3d_device->Release(); } HRESULT direct_api::create_direct(HWND h_window, bool fullscrean) { p_direct3d = NULL; p_direct3d_device = NULL; ZeroMemory(&display, sizeof(display)); ZeroMemory(&direct3d_parametr, sizeof(direct3d_parametr)); if (FAILED(p_direct3d = Direct3DCreate9(D3D_SDK_VERSION))) return E_FAIL; if (FAILED(p_direct3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, //Выбор видеоадаптера дисплея значение default выбирает первичний адаптер &display //Устанавливается указатель на структуру ))) return E_FAIL; //в которую помещать инфо о режимах текущего адаптера direct3d_parametr.Windowed = fullscrean; //Оконный режим TRUE включен, FALSE выключен direct3d_parametr.BackBufferFormat = display.Format; //Устанавливаем для заднего буфера формат нашего дисплея direct3d_parametr.SwapEffect = D3DSWAPEFFECT_DISCARD; //Настройка заднего буфера direct3d_parametr.EnableAutoDepthStencil = TRUE; //Параметры глубины direct3d_parametr.AutoDepthStencilFormat = D3DFMT_D16; //Параметры глубины direct3d_parametr.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if (direct3d_parametr.Windowed == FALSE) { direct3d_parametr.BackBufferCount = 3; //Количество задних буферов direct3d_parametr.BackBufferHeight = display.Height; //Разрешение экрана direct3d_parametr.BackBufferWidth = display.Width; //Разрешение экрана direct3d_parametr.FullScreen_RefreshRateInHz = display.RefreshRate; //Установка FPS } else { SetWindowPos(h_window, 0, 0, 0, 800, 600, SWP_SHOWWINDOW); //Ресайз оконного режима } p_direct3d->CreateDevice(D3DADAPTER_DEFAULT, //Стандартный адаптор видеокарта D3DDEVTYPE_HAL, //Желаемый тип устройства. D3DDEVTYPE_HAL аппаратно, D3DDEVTYPE_REF программно h_window, //Дискриптор главного окна D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, //Способ обработки вершин HARDWARE видеокарта, SOFTWARE программная обработка &direct3d_parametr, //Для установки наших параметров приложению &p_direct3d_device //В эту переменную присваивается результат ); p_direct3d_device->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); //Параметры глубины p_direct3d_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); //Отсечение не попадающих в кадр полигонов p_direct3d_device->SetRenderState(D3DRS_LIGHTING, FALSE); //Отключение обработки света p_direct3d_device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); p_direct3d_device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); //Этому сдесь не место перенести p_direct3d_device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC); p_direct3d_device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC); p_direct3d_device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_ANISOTROPIC); p_direct3d_device->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, 8); p_direct3d_device->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC); p_direct3d_device->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC); p_direct3d_device->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_ANISOTROPIC); p_direct3d_device->SetSamplerState(1, D3DSAMP_MAXANISOTROPY, 8); return S_OK; } void direct_api::render_scene() { // Очистка буфера p_direct3d_device->Clear(0, //Номер массива прямоугольников подвергающихся очистке NULL, //Адрес массива прямоугольника D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, //По какому принцепу очищать D3DCOLOR_RGBA(150, 150, 255, 1), //Цвет которым очищаем буфер 1.0f, //Глубина Z 0); //Трафарет(не используем) p_direct3d_device->BeginScene(); //Начало построения сцены global_render(); p_direct3d_device->EndScene(); //Завершение построения сцены p_direct3d_device->Present(NULL, NULL, NULL, NULL); //Как я понял это присвоение всей площади окна нашему выводу } IDirect3DDevice9* direct_api::get_device() { return p_direct3d_device; }
[ "draver39@gmail.com" ]
draver39@gmail.com
65589947767f6908ca6d3d7f5b3596ee642c0127
d0fb46aecc3b69983e7f6244331a81dff42d9595
/imagerecog/src/model/RecognizeSceneResult.cc
58ee18c606962c7b96af411e6d1eb858b9a21854
[ "Apache-2.0" ]
permissive
aliyun/aliyun-openapi-cpp-sdk
3d8d051d44ad00753a429817dd03957614c0c66a
e862bd03c844bcb7ccaa90571bceaa2802c7f135
refs/heads/master
2023-08-29T11:54:00.525102
2023-08-29T03:32:48
2023-08-29T03:32:48
115,379,460
104
82
NOASSERTION
2023-09-14T06:13:33
2017-12-26T02:53:27
C++
UTF-8
C++
false
false
1,715
cc
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <alibabacloud/imagerecog/model/RecognizeSceneResult.h> #include <json/json.h> using namespace AlibabaCloud::Imagerecog; using namespace AlibabaCloud::Imagerecog::Model; RecognizeSceneResult::RecognizeSceneResult() : ServiceResult() {} RecognizeSceneResult::RecognizeSceneResult(const std::string &payload) : ServiceResult() { parse(payload); } RecognizeSceneResult::~RecognizeSceneResult() {} void RecognizeSceneResult::parse(const std::string &payload) { Json::Reader reader; Json::Value value; reader.parse(payload, value); setRequestId(value["RequestId"].asString()); auto dataNode = value["Data"]; auto allTagsNode = dataNode["Tags"]["Tag"]; for (auto dataNodeTagsTag : allTagsNode) { Data::Tag tagObject; if(!dataNodeTagsTag["Value"].isNull()) tagObject.value = dataNodeTagsTag["Value"].asString(); if(!dataNodeTagsTag["Confidence"].isNull()) tagObject.confidence = std::stof(dataNodeTagsTag["Confidence"].asString()); data_.tags.push_back(tagObject); } } RecognizeSceneResult::Data RecognizeSceneResult::getData()const { return data_; }
[ "sdk-team@alibabacloud.com" ]
sdk-team@alibabacloud.com
2464f30f83ba22a18c691be3fdd4c215f5e73951
f971907302ae5f36b2eb5bb52b0513b0a7c869aa
/src/drm_1/lib/connector.cpp
18d8179255c7d49407ea50ca440e7794892436dd
[]
no_license
darkenk/bbb_tests
8c13c8ca5073245a7ec0b1690bf61af9245cdb2c
932acdf11e0a3cbca61cf2c84e90c761ca9c5efe
refs/heads/master
2020-05-21T04:40:13.318836
2016-11-18T16:43:08
2016-11-18T16:43:08
53,541,320
0
0
null
null
null
null
UTF-8
C++
false
false
1,469
cpp
#include "connector.hpp" #include "modeinfo.hpp" #include "dk_utils/logger.hpp" Connector::Connector(int fd, uint32_t connectorId) { mFd = fd; mObject = drmModeGetConnector(fd, connectorId); if (not mObject) { throw "Connector not connected"; } } Connector::Connector(Connector&& c) { mFd = c.mFd; mObject = std::move(c.mObject); c.mObject = nullptr; } Connector& Connector::operator=(Connector&& c) { mFd = c.mFd; mObject = std::move(c.mObject); c.mObject = nullptr; return *this; } Connector::~Connector() { if (mObject) { drmModeFreeConnector(mObject); } } Encoder Connector::getEncoder() { return Encoder(mFd, mObject->encoder_id); } drmModeModeInfoPtr Connector::getDefaulModeInfo() { return mObject->modes; } bool Connector::isConnected() { return mObject->connection == DRM_MODE_CONNECTED; } uint32_t Connector::getId() { return mObject->connector_id; } void Connector::dump() { LOGVD("Connector Id: %d\n" "\tConnected encoder: %d\n" "\tType: %d, TypeId: %d\n" "\tConnection: %d\n" "\tWidth %d, \tHeight %d\n", mObject->connector_id, mObject->encoder_id, mObject->connector_type, mObject->connector_type_id, mObject->connection, mObject->mmWidth, mObject->mmHeight); for (auto i = 0; i < mObject->count_modes; i++) { ModeInfo(&mObject->modes[i]).dump(); } }
[ "darkenk@gmail.com" ]
darkenk@gmail.com
24877591f2586801d661b153d6b67e366988ecb5
4d4822b29e666cea6b2d99d5b9d9c41916b455a9
/Example/Pods/Headers/Private/GeoFeatures/boost/mpl/O1_size_fwd.hpp
7995c322ff3a9b22eb8af3e57fe603a298ac7a68
[ "BSL-1.0", "Apache-2.0" ]
permissive
eswiss/geofeatures
7346210128358cca5001a04b0e380afc9d19663b
1ffd5fdc49d859b829bdb8a9147ba6543d8d46c4
refs/heads/master
2020-04-05T19:45:33.653377
2016-01-28T20:11:44
2016-01-28T20:11:44
50,859,811
0
0
null
2016-02-01T18:12:28
2016-02-01T18:12:28
null
UTF-8
C++
false
false
58
hpp
../../../../../../../GeoFeatures/boost/mpl/O1_size_fwd.hpp
[ "hatter24@gmail.com" ]
hatter24@gmail.com
6cefeb2e7e5e4c7261b65132f5efbfddb76fb055
ec3a754ac21137a04250ef7dc9e5152e94fb7bd3
/damBreakFine/0.55/p
7e0dd63db5b2ae02a84464b715f11d8d99e3f4ea
[]
no_license
johnathoncobabe/425
2336a62cd0f575b777cd549a886a15b5799b6c72
e1ee61fb87a1078683d71a1d15131713c435cfae
refs/heads/master
2021-01-10T10:00:11.128510
2015-10-02T17:54:40
2015-10-02T17:54:40
43,466,206
0
0
null
null
null
null
UTF-8
C++
false
false
73,895
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.4.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.55"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [1 -1 -2 0 0 0 0]; internalField nonuniform List<scalar> 7700 ( -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0235435 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.0706305 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.117717 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.164804 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.211891 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.258978 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.306065 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.353152 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.400239 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.447326 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -0.505463 -0.505463 -0.505463 -0.505463 -0.574649 -0.574649 -0.574649 -0.574649 -0.643836 -0.643836 -0.643836 -0.643836 -0.713022 -0.713022 -0.713022 -0.713022 -0.782209 -0.782209 -0.782209 -0.782209 -0.851395 -0.851395 -0.851395 -0.851395 -0.920582 -0.920582 -0.920582 -0.920582 -0.989768 -0.989768 -0.989768 -0.989768 -1.05895 -1.05895 -1.05895 -1.05895 -1.12814 -1.12814 -1.12814 -1.12814 -1.19733 -1.19733 -1.19733 -1.19733 -1.26651 -1.26651 -1.26651 -1.26651 -1.3357 -1.3357 -1.3357 -1.3357 -1.40489 -1.40489 -1.40489 -1.40489 -1.47407 -1.47407 -1.47407 -1.47407 -1.54326 -1.54326 -1.54326 -1.54326 -1.61245 -1.61245 -1.61245 -1.61245 -1.68163 -1.68163 -1.68163 -1.68163 -1.75082 -1.75082 -1.75082 -1.75082 -1.82001 -1.82001 -1.82001 -1.82001 -1.88919 -1.88919 -1.88919 -1.88919 -1.95838 -1.95838 -1.95838 -1.95838 -2.02756 -2.02756 -2.02756 -2.02756 -2.09675 -2.09675 -2.09675 -2.09675 -2.16594 -2.16594 -2.16594 -2.16594 -2.23512 -2.23512 -2.23512 -2.23512 -2.30431 -2.30431 -2.30431 -2.30431 -2.3735 -2.3735 -2.3735 -2.3735 -2.44268 -2.44268 -2.44268 -2.44268 -2.51187 -2.51187 -2.51187 -2.51187 -2.58106 -2.58106 -2.58106 -2.58106 -2.65024 -2.65024 -2.65024 -2.65024 -2.71943 -2.71943 -2.71943 -2.71943 -2.78862 -2.78862 -2.78862 -2.78862 -2.8578 -2.8578 -2.8578 -2.8578 -2.92699 -2.92699 -2.92699 -2.92699 -2.99618 -2.99618 -2.99618 -2.99618 -3.06536 -3.06536 -3.06536 -3.06536 -3.13455 -3.13455 -3.13455 -3.13455 -3.20373 -3.20373 -3.20373 -3.20373 -3.27292 -3.27292 -3.27292 -3.27292 -3.34211 -3.34211 -3.34211 -3.34211 -3.41129 -3.41129 -3.41129 -3.41129 -3.48048 -3.48048 -3.48048 -3.48048 -3.54967 -3.54967 -3.54967 -3.54967 -3.61885 -3.61885 -3.61885 -3.61885 -3.68804 -3.68804 -3.68804 -3.68804 -3.75723 -3.75723 -3.75723 -3.75723 -3.82641 -3.82641 -3.82641 -3.82641 -3.8956 -3.8956 -3.8956 -3.8956 -3.96479 -3.96479 -3.96479 -3.96479 -4.03397 -4.03397 -4.03397 -4.03397 -4.10316 -4.10316 -4.10316 -4.10316 -4.17234 -4.17234 -4.17234 -4.17234 -4.24153 -4.24153 -4.24153 -4.24153 -4.31072 -4.31072 -4.31072 -4.31072 -4.3799 -4.3799 -4.3799 -4.3799 -4.44909 -4.44909 -4.44909 -4.44909 -4.51828 -4.51828 -4.51828 -4.51828 -4.58746 -4.58746 -4.58746 -4.58746 -4.65665 -4.65665 -4.65665 -4.65665 -4.72584 -4.72584 -4.72584 -4.72584 -4.79502 -4.79502 -4.79502 -4.79502 -4.86421 -4.86421 -4.86421 -4.86421 -4.9334 -4.9334 -4.9334 -4.9334 -5.00258 -5.00258 -5.00258 -5.00258 -5.07177 -5.07177 -5.07177 -5.07177 -5.14096 -5.14096 -5.14096 -5.14096 -5.21014 -5.21014 -5.21014 -5.21014 -5.27933 -5.27933 -5.27933 -5.27933 -5.34851 -5.34851 -5.34851 -5.34851 -5.4177 -5.4177 -5.4177 -5.4177 -5.48689 -5.48689 -5.48689 -5.48689 -5.55607 -5.55607 -5.55607 -5.55607 -5.62526 -5.62526 -5.62526 -5.62526 -5.69445 -5.69445 -5.69445 -5.69445 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.505463 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.574649 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.643836 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.713022 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.782209 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.851395 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.920582 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -0.989768 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.05895 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.12814 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.19733 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.26651 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.3357 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.40489 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.47407 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.54326 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.61245 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.68163 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.75082 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.82001 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.88919 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -1.95838 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.02756 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.09675 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.16594 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.23512 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.30431 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.3735 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.44268 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.51187 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.58106 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.65024 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.71943 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.78862 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.8578 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.92699 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -2.99618 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.06536 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.13455 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.20373 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.27292 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.34211 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.41129 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.48048 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.54967 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.61885 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.68804 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.75723 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.82641 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.8956 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -3.96479 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.03397 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.10316 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.17234 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.24153 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.31072 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.3799 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.44909 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.51828 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.58746 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.65665 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.72584 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.79502 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.86421 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -4.9334 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.00258 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.07177 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.14096 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.21014 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.27933 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.34851 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.4177 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.48689 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.55607 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.62526 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 -5.69445 ) ; boundaryField { leftWall { type calculated; value nonuniform List<scalar> 86 ( -0.0235435 -0.0706305 -0.117717 -0.164804 -0.211891 -0.258978 -0.306065 -0.353152 -0.400239 -0.447326 -0.505463 -0.574649 -0.643836 -0.713022 -0.782209 -0.851395 -0.920582 -0.989768 -1.05895 -1.12814 -1.19733 -1.26651 -1.3357 -1.40489 -1.47407 -1.54326 -1.61245 -1.68163 -1.75082 -1.82001 -1.88919 -1.95838 -2.02756 -2.09675 -2.16594 -2.23512 -2.30431 -2.3735 -2.44268 -2.51187 -2.58106 -2.65024 -2.71943 -2.78862 -2.8578 -2.92699 -2.99618 -3.06536 -3.13455 -3.20373 -3.27292 -3.34211 -3.41129 -3.48048 -3.54967 -3.61885 -3.68804 -3.75723 -3.82641 -3.8956 -3.96479 -4.03397 -4.10316 -4.17234 -4.24153 -4.31072 -4.3799 -4.44909 -4.51828 -4.58746 -4.65665 -4.72584 -4.79502 -4.86421 -4.9334 -5.00258 -5.07177 -5.14096 -5.21014 -5.27933 -5.34851 -5.4177 -5.48689 -5.55607 -5.62526 -5.69445 ) ; } rightWall { type calculated; value nonuniform List<scalar> 86 ( -0.0235435 -0.0706305 -0.117717 -0.164804 -0.211891 -0.258978 -0.306065 -0.353152 -0.400239 -0.447326 -0.505463 -0.574649 -0.643836 -0.713022 -0.782209 -0.851395 -0.920582 -0.989768 -1.05895 -1.12814 -1.19733 -1.26651 -1.3357 -1.40489 -1.47407 -1.54326 -1.61245 -1.68163 -1.75082 -1.82001 -1.88919 -1.95838 -2.02756 -2.09675 -2.16594 -2.23512 -2.30431 -2.3735 -2.44268 -2.51187 -2.58106 -2.65024 -2.71943 -2.78862 -2.8578 -2.92699 -2.99618 -3.06536 -3.13455 -3.20373 -3.27292 -3.34211 -3.41129 -3.48048 -3.54967 -3.61885 -3.68804 -3.75723 -3.82641 -3.8956 -3.96479 -4.03397 -4.10316 -4.17234 -4.24153 -4.31072 -4.3799 -4.44909 -4.51828 -4.58746 -4.65665 -4.72584 -4.79502 -4.86421 -4.9334 -5.00258 -5.07177 -5.14096 -5.21014 -5.27933 -5.34851 -5.4177 -5.48689 -5.55607 -5.62526 -5.69445 ) ; } lowerWall { type calculated; value nonuniform List<scalar> 110 ( 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.0235435 -0.0706305 -0.117717 -0.164804 -0.211891 -0.258978 -0.306065 -0.353152 -0.400239 -0.447326 -0.47087 -0.47087 -0.47087 -0.47087 -0.0235435 -0.0706305 -0.117717 -0.164804 -0.211891 -0.258978 -0.306065 -0.353152 -0.400239 -0.447326 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ) ; } atmosphere { type calculated; value uniform -5.72904; } defaultFaces { type empty; } } // ************************************************************************* //
[ "johnathoncobabe@gmail.com" ]
johnathoncobabe@gmail.com
bf8f4138084c6eb5cd34f95f36578aa8a32ed077
01c298cb45df74f8d61ae39cbe80121a4e88b4ea
/TextFile.h
ba9ee1aed05317018787d64a1455cbb37fb7e56c
[]
no_license
knied/LD30
b76080ea4ff6bc7f80bc997762c3757aa0352ce3
61fdba506fe9df2202e417d09b8309df68270730
refs/heads/master
2021-01-20T12:00:53.069619
2014-08-25T23:23:50
2014-08-25T23:23:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
591
h
// // TextFile.h // LD30Xcode // // Created by Kristof Niederholtmeyer on 22.08.14. // Copyright (c) 2014 Kristof Niederholtmeyer. All rights reserved. // #ifndef __LD30Xcode__TextFile__ #define __LD30Xcode__TextFile__ #include <iostream> #include <fstream> #include <streambuf> class TextFile { std::ifstream _file; public: TextFile(std::string const& filename); ~TextFile(); std::string next_line(); std::string content(); void jump_to_top(); bool end_of_file(); bool is_open() const; }; #endif /* defined(__LD30Xcode__TextFile__) */
[ "kristof.niederholtmeyer@rwth-aachen.de" ]
kristof.niederholtmeyer@rwth-aachen.de
8989bda01d98b87d58b0c6268be1e1bc813e34d6
ac57d9b3568f7e3808408721b12f1e325ce06969
/grid.cpp
e13db5b88f4aa1a5ae003caf3f8524e9bd3533cd
[]
no_license
eth-csem/grids
bff609d994ab3430122abc8d8ecb15c0e1458fc9
8b33e9ee90babf962c6310848aa740bc37ef104d
refs/heads/master
2020-12-30T23:09:28.964468
2017-08-24T06:27:37
2017-08-24T06:27:37
80,622,450
0
0
null
null
null
null
UTF-8
C++
false
false
5,820
cpp
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "point_clouds.h" /*! \file \brief Main executable. Read input, calls functions to generate specific types of point clouds, and write the point clouds into a file.. */ /*==========================================================================*/ /* Main function to compute various grids. ---------------------------------*/ /*==========================================================================*/ int main(int argc, char *argv[]) { /* Local variables. ----------------------------------------------------*/ PointCloud C; void print_help(); /* Check which grid to build. ------------------------------------------*/ /* Cubed sphere. -------------------------------------------------------*/ if (!strcmp(argv[1],"cubed_sphere")) { printf("\ncubed sphere\n"); printf("name of refinement list: %s\n",argv[2]); printf("output written to: %s\n",argv[3]); printf("radius of the sphere: %f km\n",atof(argv[4])); printf("minimum point distance: %f km\n",atof(argv[5])); C.cubed_sphere(argv[2],atof(argv[4])); C.write(argv[3],atof(argv[5])); } /* Cubed ball. ---------------------------------------------------------*/ else if (!strcmp(argv[1],"cubed_ball")) { printf("\ncubed ball\n"); printf("name of refinement list: %s\n",argv[2]); printf("output written to: %s\n",argv[3]); printf("minimum point distance: %f km\n",atof(argv[4])); C.cubed_ball(argv[2]); C.write(argv[3], atof(argv[4])); } /* Fibonacci sphere. ---------------------------------------------------*/ else if (!strcmp(argv[1],"fibonacci_sphere")) { printf("\nFibonacci sphere\n"); printf("name of refinement list: %s\n",argv[2]); printf("output written to: %s\n",argv[3]); printf("radius of the sphere: %f km\n",atof(argv[4])); printf("minimum point distance: %f km\n",atof(argv[5])); C.fibonacci_sphere(argv[2],atof(argv[4])); C.write(argv[3], atof(argv[5])); } /* Fibonacci ball. -----------------------------------------------------*/ else if (!strcmp(argv[1],"fibonacci_ball")) { printf("\nFibonacci ball\n"); printf("name of refinement list: %s\n",argv[2]); printf("output written to: %s\n",argv[3]); printf("minimum point distance: %f km\n",atof(argv[4])); C.fibonacci_ball(argv[2]); C.write(argv[3], atof(argv[4])); } /* Regular spherical grid. ---------------------------------------------*/ else if (!strcmp(argv[1],"regular")) { printf("\nregular spherical grid\n"); printf("name of refinement list: %s\n",argv[2]); printf("output written to: %s\n",argv[3]); printf("minimum point distance: %f km\n",atof(argv[4])); C.regular(argv[2]); C.write(argv[3], atof(argv[4])); } /* Vertical profile. ---------------------------------------------------*/ else if (!strcmp(argv[1],"profile")) { printf("\nvertical profile\n"); printf("latitude=%lg deg, longitude=%lg deg\n",atof(argv[2]),atof(argv[3])); printf("radius=%lg:%lg:%lg km\n",atof(argv[4]),atof(argv[6]),atof(argv[5])); C.profile(atof(argv[2]),atof(argv[3]),atof(argv[4]),atof(argv[5]),atof(argv[6])); C.write(argv[7], 0.0); } /* Vertical slice. -----------------------------------------------------*/ else if (!strcmp(argv[1],"slice")) { printf("\nvertical slice\n"); printf("min. latitude=%lg deg, min. longitude=%lg deg, min. radius=%lg km\n",atof(argv[2]),atof(argv[3]),atof(argv[4])); printf("max. latitude=%lg deg, max. longitude=%lg deg, max. radius=%lg km\n",atof(argv[5]),atof(argv[6]),atof(argv[7])); printf("radius increment=%lg km, angular increment=%lg deg\n",atof(argv[8]),atof(argv[9])); C.slice(atof(argv[2]),atof(argv[3]),atof(argv[4]),atof(argv[5]),atof(argv[6]),atof(argv[7]),atof(argv[8]),atof(argv[9])); C.write(argv[10], 0.0); } /* Get help. -----------------------------------------------------------*/ else if (!strcmp(argv[1],"-help")) { print_help(); } /* Error. --------------------------------------------------------------*/ else { printf("ERROR! No valid option!\n"); print_help(); } return 0; } /*==========================================================================*/ /* Print help message. -----------------------------------------------------*/ /*==========================================================================*/ void print_help() { printf("\nUsage of grid:\n"); printf("--------------\n"); printf("grid cubed_sphere [name of refinement list] [output file name] [radius of the sphere (km)] [min. point distance (km)]\n"); printf("grid cubed_ball [name of refinement list] [output file name] [min. point distance (km)]\n"); printf("grid fibonacci_sphere [name of refinement list] [output file name] [radius of the sphere (km)] [min. point distance (km)]\n"); printf("grid fibonacci_ball [name of refinement list] [output file name] [min. point distance (km)]\n"); printf("grid regular [name of refinement list] [output file name] [minimum point distance (km)]\n"); printf("grid profile [latitude (deg)] [longitude (deg)] [min. radius (km)] [max. radius (km)] [radius increment (km)]\n"); printf("grid slice [min. latitude (deg)] [min. longitude (deg)] [min. radius (km)] [max. latitude (deg)] [max. longitude (deg)] [max. radius (km)] [radius increment (km)] [angular increment (deg)]\n"); }
[ "andreas.fichtner@erdw.ethz.ch" ]
andreas.fichtner@erdw.ethz.ch
f244fd2860391f0c9980bc7f65e39dcfa02bbb53
f7f31db1e48966c0658c09ead4c5ccd0d0fd7510
/12.4/stack.h
c0c40eacc5263f174f8cbf3d106d8b1e319e1f6b
[]
no_license
shadimsaleh/C-Plus-Plus-Primer-Plus-Homework
b113d5527162fcbd6e568bd032706a8c38f6f11d
104acd78a353e7a351591e8d6b376f47a8c8db71
refs/heads/master
2021-01-20T11:48:10.620433
2017-03-01T13:14:59
2017-03-01T13:14:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
689
h
// stack.h -- class declaration for the stack ADT typedef unsigned long Item; class Stack { private: enum { MAX = 10 }; // constant specific to class Item *pitems_; // holds stack items int size_; // number of elements in stack int top_; // index for top stack item public: Stack(int n = MAX); // create stack with n elements Stack(const Stack &st); ~Stack(); bool IsEmpty() const; bool IsFull() const; // push() returns false if stack already is full, true otherwise bool Push(const Item &item); // add item to stack // pop() returns false if stack already is empty, true otherwise bool Pop(Item &item); // pop top into item Stack & operator=(const Stack &st); };
[ "mengfanqi0828@163.com" ]
mengfanqi0828@163.com
2b1030f2adaffa712f841d67a7f3d8cb4e91c74e
2d2c69acda9154755be0a22b9ec1b710789a5bf0
/CodeChef/October Challenge/ReplaceForX.cpp
7711a6777efc849b2b0eace72179e269942a8bfa
[]
no_license
Kalit31/cp-playground
2f74282a29222a308c022115e1a733ed2ed8dd6f
572b543403498ffa12e80236a245bd7fb71249dd
refs/heads/master
2023-06-26T21:50:26.676082
2021-07-31T08:45:15
2021-07-31T08:45:15
228,023,746
0
0
null
null
null
null
UTF-8
C++
false
false
2,315
cpp
#include <bits/stdc++.h> #define ll long long int #define deb(x) cout << #x << " " << x << endl; #define fast std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); #define endl "\n" using namespace std; // never use endl, it is much slower than "\n" // dont mess up with LONG_LONG_MAX/LONG_MAX/INT_MAX void solve(vector<ll> A, ll N, ll X, ll p, ll k) { sort(A.begin(), A.end()); ll operations = 0; if (A[p] == X) { cout << operations << endl; return; } if (N == 1) { cout << 1 << endl; return; } if (p == k) { if (X > A[p]) { int i = p; while (i < N) { if (A[i] >= X) { break; } operations++; i++; } } else { int i = p; while (i >= 0) { if (A[i] <= X) { break; } operations++; i--; } } } else if (p < k) { if (A[p] < X) { cout << "-1" << endl; return; } ll i = p; while (i >= 0) { if (A[i] <= X) { break; } operations++; i--; } } else { if (A[p] > X) { cout << "-1" << endl; return; } ll i = p; while (i < N) { if (A[i] >= X) { break; } operations++; i++; } } cout << operations << endl; return; } int main() { fast; #ifndef ONLINE_JUDGE freopen("/home/kalit/Desktop/Data Structures-Algo-Competitive/src/codeforces/input.txt", "r", stdin); freopen("/home/kalit/Desktop/Data Structures-Algo-Competitive/src/codeforces/output.txt", "w", stdout); #endif int T; cin >> T; while (T--) { ll N, X, p, k; cin >> N >> X >> p >> k; vector<ll> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } solve(A, N, X, p - 1, k - 1); } return 0; }
[ "inanikalit31@gmail.com" ]
inanikalit31@gmail.com
63846d5c1b40793df544b6d3b8976b846f5568c0
7888f2f75d277c64bfc71009ec0eb32bc45a1681
/Arquivos_Curso_Arduino/arduino_aula_55/Aula_55/Btn.h
d7511389e1a13fb9e0957d3c596c0de7cfb2b9ea
[ "MIT" ]
permissive
maledicente/cursos
bba06a0d09037fd8cae69927c996805d513ddb25
00ace48da7e48b04485e4ca97b3ca9ba5f33a283
refs/heads/master
2023-08-12T03:01:02.799974
2021-10-11T14:29:35
2021-10-11T14:29:35
273,795,405
1
0
null
null
null
null
UTF-8
C++
false
false
1,031
h
class Btn{ public: int *pino; bool btnclicado; bool btnliberado; int ultimoEstadoBtn=LOW; unsigned long tempoPrimeiroAcionamento=0; unsigned long tempoDebounce=50; typedef void (funcao)(void); //typedef retorno (nome_função)(Parâmetros de entrada); Btn(int p){ btnclicado=false; btnliberado=false; this->pino=p; } void clique(funcao *f){ //Rotina Debounce int leitura=digitalRead(*pino); if(leitura!=ultimoEstadoBtn){ tempoPrimeiroAcionamento=millis(); } if((millis()-tempoPrimeiroAcionamento)>tempoDebounce){ //Debounce tratato, comandos que serão executados no acionamento do botão if(digitalRead(*pino)){ btnclicado=true; btnliberado=false; }else{ btnliberado=true; } if((btnclicado)and(btnliberado)){ btnclicado=false; btnliberado=false; f(); } } ultimoEstadoBtn=leitura; } };
[ "luizpaulonievola@ymail.com" ]
luizpaulonievola@ymail.com
0d7338da75d40d85b7fa1226d3519f6b1fa130b1
9a149637db59ccd94dfe2bb1139d007708b067fe
/bio_data_5_students_structures.cpp
07e414de7c12c435b30d6ddada38870f2787762b
[]
no_license
Nishant-Pall/C-practice
280da609cfc53f32e83e9cf0b221843e03343773
2502cb7d04ea611a7847720262eee3ad93186db2
refs/heads/master
2021-08-15T21:57:15.511091
2020-09-05T16:37:48
2020-09-05T16:37:48
225,806,107
0
0
null
null
null
null
UTF-8
C++
false
false
1,446
cpp
#include<iostream> #include<string.h> using namespace std; struct bio { char name[80]; int roll_no; char branch[20]; int semester; float subject_marks[10]; float total_marks; }; int main() { bio student[5]; cout<<"Enter bio data of 5 students:"<<endl; for(int i=0;i<5;++i) { cout<<"Enter bio data of student "<<i+1<<" student:"<<endl; cout<<"Enter name"<<endl; cin.getline(student[i].name,80); cout<<"Enter roll no."<<endl; cin>>student[i].roll_no; cout<<"Enter Branch:"<<endl; cin.getline(student[i].branch,20); cout<<"Enter semester:"<<endl; cin>>student[i].semester; cout<<"Enter marks of five students:"<<endl; for(int j=0;j<5;j++) { cout<<"Enter marks of "<<j+1<<" subject:"<<endl; cin>>student[i].subject_marks[j]; } student[i].total_marks = student[i].subject_marks[0]+ student[i].subject_marks[1]+ student[i].subject_marks[2]+ student[i].subject_marks[3]+ student[i].subject_marks[4]; } cout<<"Bio-data of students who get more than 400 marks:"<<endl; for(int i=0;i<5;++i) { if((student[i].total_marks)>400) { cout<<"BIO-DATA....."<<endl; cout<<"Name:"<<student[i].name<<endl; cout<<"Roll no. "<<student[i].roll_no; cout<<"Branch:"<<student[i].branch; cout<<"Semester:"<<student[i].semester; cout<<"The marks of five subjects are:"<<endl; for(int j=0;j<5;++j) cout<<student[i].subject_marks[j]<<endl; cout<<"Total marks:"<<student[i].total_marks; cout<<endl; } } return 0; }
[ "palln6935@gmail.com" ]
palln6935@gmail.com
083fa794b4a6ddf024bcf7b8d1eb5df0432db868
a3c4333a4422e62c9f3e3a5443515dc0d507f78a
/src/common/thread.h
19e245e0d0110586aa96ca9393d712178f9f6fbf
[]
no_license
swinsey/cello
8a208e500f759602bd2c216c7f5d5bdc8bf94554
746b6f65ebc55e77f1ff07b2396af42c169ee6dd
refs/heads/master
2021-05-11T03:43:33.470504
2015-04-10T07:14:36
2015-04-10T07:14:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,280
h
#ifndef SRC_COMMON_THREAD_H #define SRC_COMMON_THREAD_H #include <pthread.h> #include <tr1/memory> #include <tr1/functional> using std::tr1::function; using std::tr1::placeholders::_1; using std::tr1::placeholders::_2; namespace cello { class Thread { public: typedef function<void()> ThreadFunc; public: Thread(): m_entry(NULL), m_context(NULL), m_param(0), m_is_running(false) {} Thread(ThreadFunc entry, void* context = NULL, unsigned long long param = 0): m_entry(entry), m_context(context), m_param(param), m_is_running(false) {} virtual ~Thread() {} //void Init(ThreadFunc entry, void* context = NULL, unsigned long long param = 0); void DoStart(); bool Start(); bool Join(); bool IsRunning() { return m_is_running; } void Terminate(); private: static void* Entry(void* in_thread); private: pthread_t m_id; ThreadFunc m_entry; void* m_context; unsigned long long m_param; bool m_is_running; }; } #endif
[ "cj.magina@gmail.com" ]
cj.magina@gmail.com
a39bdd27bae7f61c14cecbcb1fe47e20e5350767
6b89c9bd317f6164a8e7ce3309731db0a6f60a88
/generatedEFGcode.h
ad43f09da5f86863cbd58cb7c4ecf2bb5c84019c
[ "MIT" ]
permissive
amit112amit/minperimeter
3de5cf4f0597e5c118eca93b482e55368457175b
d9b8afd66a463ece18a2a0847c954e8c1a61c846
refs/heads/master
2022-10-26T10:41:11.616654
2020-06-16T11:54:24
2020-06-16T11:54:24
272,694,784
0
0
null
null
null
null
UTF-8
C++
false
false
1,686
h
#ifndef __GENERATEDEFG_CODE_H__ #define __GENERATEDEFG_CODE_H__ #include <tuple> #include "settings.h" typedef std::tuple<scalar, scalar, scalar> tuple3; struct EFGFunc{ tuple3 operator()(const scalar r, const scalar t, const scalar a, const scalar b){ /* Function generated by `generatecode.py` */ //############## Sub-expressions ############## scalar x0 = math::sin(t); scalar x1 = math::cos(t); scalar x2 = r*x1; scalar x3 = PI*(a + x2); scalar x4 = r*x0; scalar x5 = PI*(b + x4); scalar x6 = math::sin(x3)*math::sin(x5); scalar x7 = x0*x6; scalar x8 = math::cos(x3)*math::cos(x5); scalar x9 = x1*x8; scalar x10 = PI*(5*a + 5*x2); scalar x11 = PI*(5*b + 5*x4); scalar x12 = math::cos(x10)*math::cos(x11); scalar x13 = 0.36036036036036034*x0; scalar x14 = math::sin(x10)*math::sin(x11); scalar x15 = 0.36036036036036034*x1; scalar x16 = PI*PI; scalar x17 = 0.30802500000000005*x16; scalar x18 = x0*x0 + x1*x1; scalar x19 = 0.20000000000000001*x0; scalar x20 = 0.20000000000000001*x1; scalar x21 = x0*x8; scalar x22 = x1*x6; //############## Final Expressions ############## scalar E = x17*math::pow(-x12*x13 + x14*x15 + x7 - x9, 2) + x18; scalar F = -r*x16*(-x12*x19 + x14*x20 + 0.55500000000000005*x7 - 0.55500000000000005*x9)*(x12*x20 + x14*x19 - 0.55500000000000005*x21 - 0.55500000000000005*x22); scalar G = r*r*(x17*math::pow(x12*x15 + x13*x14 - x21 - x22, 2) + x18); return {E, F, G}; } }; #endif //__GENERATEDEFG_CODE_H__
[ "amit112amit@gmail.com" ]
amit112amit@gmail.com
74e156c84b13d5b6a17d0613d584876801da581b
31d00495b6fa63bfdcaeea68e6ec38e1ec4158b0
/src/lfant/Material.h
abadc305e3cc9e5564bae6c453ab4dda0c5dc270
[ "Apache-2.0" ]
permissive
loafofpiecrust/lfant
c6e663a3e61afc33bd30112285b2e88177cba419
a38826e325a50dffb5d030d71abcd58de59e8389
refs/heads/master
2021-01-23T14:52:29.782769
2014-12-19T18:56:42
2014-12-19T18:56:42
8,059,823
5
0
null
null
null
null
UTF-8
C++
false
false
912
h
/* * Copyright (C) 2013-2014, by loafofpiecrust * * 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 in the accompanying LICENSE file or at * http://www.apache.org/licenses/LICENSE-2.0 */ #pragma once #include <lfant/stdafx.h> // Internal #include <lfant/Texture.h> #include <lfant/Shader.h> #include <lfant/Object.h> // External namespace lfant { /** @addtogroup Game * @{ */ /** @addtogroup Rendering * @{ */ /** * */ class Material : public Object { public: Material(); virtual void Serialize(Properties *prop); // Path and name for the texture file. std::shared_ptr<Texture> texture; // uint32 textureUnif; std::shared_ptr<Shader> shader; vec2 tiling { 1, 1 }; vec2 offset { 0, 0 }; u8vec4 color { 255, 255, 255, 255 }; // bool loaded = false; }; /// @} /// @} }
[ "taylorsnead@gmail.com" ]
taylorsnead@gmail.com
11c6aba412d8df0c977fe87316e8eba3e68dc523
7d8397e232e6a74fc36d6ef4641b81150fb528b7
/include/parser/ParseTokenCollection.h
0f173fbd9173b253fcae70324542a30a2b232ed6
[]
no_license
suppertails66/clapton
1137badd9103ec672221a7cf51cbfde99fb50feb
0c97455e7259d2d9e821187fc8e24fcada75267f
refs/heads/master
2021-01-13T03:34:20.745947
2017-01-08T18:33:15
2017-01-08T18:33:15
77,308,501
0
0
null
null
null
null
UTF-8
C++
false
false
192
h
#ifndef PARSETOKENCOLLECTION_H #define PARSETOKENCOLLECTION_H #include <vector> namespace Lonely { class ParseToken; typedef std::vector<ParseToken*> ParseTokenCollection; }; #endif
[ "suppertails66@gmail.com" ]
suppertails66@gmail.com
150bba9f7c68e2fe2dbe81faedd223ffdd6e52d6
53b47be6a13c99c278e7281bbb3d9bc842e37d03
/CheckTemplates/checktemplates.h
abcf3966a701b8b2928869e1bba5b64b2b466d51
[]
no_license
hcjjy/CheckTempaltes
762798442ee2df93cad3a26e49c188c69198e7bd
021d294382fcb6a97b37c77bbadb363d4919ba5c
refs/heads/master
2021-01-10T11:37:02.247423
2015-12-03T02:14:35
2015-12-03T02:14:35
47,300,977
0
0
null
null
null
null
UTF-8
C++
false
false
1,365
h
#pragma once #include <QtGui/QDialog> #include <QDomElement> #include "MyWidget.h" #include <QtGui/QTreeWidgetItem> class QPushButton; class MyTreeWidget; class QTreeWidgetItem; class Video; class BlackFrame; class ColorFrame; class Audio; class Silence; class PeakLevel; class StereoCorrelation; class StereoInvertPhase; class StereoSamePhase; class QXmlStreamWriter; class QStackedWidget; class CheckTemplates : public QDialog { Q_OBJECT public: CheckTemplates(QWidget * parent = NULL); virtual ~CheckTemplates(void); public slots: void save(); void saveAs(); void cancel(); void showItem(); void showItem(QTreeWidgetItem* item, int column); protected: virtual void resizeEvent(QResizeEvent *event); private: bool domReadXml(const QString &fileName,QMap<QString ,QTreeWidgetItem* > &nameToPtr); void domReadElement(QDomElement element,QMap<QString ,QTreeWidgetItem* > &nameToPtr); bool domWriteXml(const QString &fileName); void domWriteElement(QDomDocument &doc,QDomElement xmlElement, QTreeWidgetItem *item); QTreeWidgetItem* addTreeWidgetItem(QTreeWidgetItem *parent,QString itemName, MyWidget *widget,QString tagName,QMap<QString ,QTreeWidgetItem* > &nameToPtr); private: MyTreeWidget *m_pTreeWidget; QPushButton *m_pSaveButton; QPushButton *m_pSaveAsButton; QPushButton *m_pCancelButton; QStackedWidget *m_pStackedWidget; };
[ "heqinghui1@163.com" ]
heqinghui1@163.com
67cc95edf003330254346740f81335357df5f717
7ed83918fbdcc2f9946d5fe216f63b2ab9a224d4
/src/pmemkv.h
8b4a78ec2bdc24d21bc80d14c0cffd95deeec27f
[]
no_license
cs-qyzhang/ComboTree
dfd027a22706234308daae0af1005cb93dbd1115
47a4126975930a1255dd69308c6e332a01c29aea
refs/heads/master
2023-02-18T02:32:20.892743
2021-01-19T08:12:27
2021-01-19T08:12:27
283,805,834
0
3
null
2021-01-19T08:12:28
2020-07-30T15:04:20
C++
UTF-8
C++
false
false
2,073
h
#pragma once #include <cassert> #include <cstdlib> #include <libpmemkv.hpp> #include <vector> #include <atomic> #include <mutex> #include <algorithm> #include <vector> namespace combotree { using pmem::kv::status; using pmem::kv::string_view; namespace { const uint64_t SIZE = 512 * 1024UL * 1024UL; } // anonymous namespace class PmemKV { public: explicit PmemKV(std::string path, size_t size = SIZE, std::string engine = "cmap", bool force_create = true); bool Put(uint64_t key, uint64_t value); bool Update(uint64_t key, uint64_t value); bool Get(uint64_t key, uint64_t& value) const; bool Delete(uint64_t key); size_t Scan(uint64_t min_key, uint64_t max_key, uint64_t max_size, void (*callback)(uint64_t,uint64_t,void*), void* arg) const; size_t Scan(uint64_t min_key, uint64_t max_key, uint64_t max_size, std::vector<std::pair<uint64_t,uint64_t>>& kv) const; size_t Size() const { ReadRef_(); if (!read_valid_.load(std::memory_order_acquire)) return -1; size_t size; [[maybe_unused]] auto s = db_->count_all(size); assert(s == status::OK); ReadUnRef_(); return size; } bool NoWriteRef() const { return write_ref_.load() == 0; } bool NoReadRef() const { return read_ref_.load() == 0; } static void SetWriteValid() { write_valid_.store(true, std::memory_order_release); } static void SetWriteUnvalid() { write_valid_.store(false, std::memory_order_release); } static void SetReadValid() { read_valid_.store(true, std::memory_order_release); } static void SetReadUnvalid() { read_valid_.store(false, std::memory_order_release); } private: pmem::kv::db* db_; mutable std::atomic<int> write_ref_; mutable std::atomic<int> read_ref_; static std::atomic<bool> write_valid_; static std::atomic<bool> read_valid_; void WriteRef_() const { write_ref_++; } void WriteUnRef_() const { write_ref_--; } void ReadRef_() const { read_ref_++; } void ReadUnRef_() const { read_ref_--; } }; } // namespace combotree
[ "cs.qyzhang@qq.com" ]
cs.qyzhang@qq.com
561303b1e894e879bbce85bc4bb645b37cbaaff8
9030ce2789a58888904d0c50c21591632eddffd7
/SDK/ARKSurvivalEvolved_DmgType_Melee_ElementTree_functions.cpp
c41eb377f44dc758e5a72b5d937e99215e4a1274
[ "MIT" ]
permissive
2bite/ARK-SDK
8ce93f504b2e3bd4f8e7ced184980b13f127b7bf
ce1f4906ccf82ed38518558c0163c4f92f5f7b14
refs/heads/master
2022-09-19T06:28:20.076298
2022-09-03T17:21:00
2022-09-03T17:21:00
232,411,353
14
5
null
null
null
null
UTF-8
C++
false
false
386
cpp
// ARKSurvivalEvolved (332.8) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_DmgType_Melee_ElementTree_parameters.hpp" namespace sdk { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "sergey.2bite@gmail.com" ]
sergey.2bite@gmail.com
ac4ab5981de81480c0008e723f0030ceedbcbd5e
64181888ec0edfcff8d399b5e35be4a7cf45dfc4
/tek3/CPP/CPP_zia_2019/sources/tools/Thread.hpp
a084ada69b191078a9ec2d6d790bc1a281fc80c5
[]
no_license
simonmeyerrr/epitech_projects
b0ac36262ca0699df87613bb10bb00d3bcb6e46a
6c49a54703da9697c9d292b665542e107b02b3d0
refs/heads/master
2023-03-05T23:43:33.959441
2021-02-19T15:10:47
2021-02-19T15:10:47
331,681,418
0
2
null
null
null
null
UTF-8
C++
false
false
3,071
hpp
#ifndef THREAD_HPP_ #define THREAD_HPP_ #include <thread> #include <future> #include <memory> #include <exception> //////////////////////////////////////////////////////////////////////////////// template<typename R = void, bool B = true> class Thread : public std::thread { public: Thread() noexcept : std::thread::thread(), p{}, f{}, r{}, b{!B} { } Thread(std::thread &&t) noexcept : std::thread::thread{std::move(t)}, b{!B} { } template<typename T = R, typename F, typename ...A, class = typename std::enable_if<!std::is_same<void, T>::value>::type> explicit Thread(F &&f, A &&...a) : std::thread::thread{}, p{}, f{p.get_future()}, r{}, b{!B} { *this = std::move(std::thread{f, std::forward<A>(a)..., std::move(p)}); } template<typename T = R, class = typename std::enable_if<std::is_same<void, T>::value>::type, typename F, typename ...A> explicit Thread(F &&f, A &&...a) : std::thread::thread{f, std::forward<A>(a)...}, p{}, f{}, r{}, b{false} { } Thread(const thread &) noexcept = delete; ~Thread() noexcept { } using std::thread::thread; template<typename T = R> typename std::enable_if<!std::is_same<void, T>::value && !B && std::is_copy_constructible<R>::value, T>::type get() const { return *r; } template<typename T = R> typename std::enable_if<!std::is_same<void, T>::value && B && std::is_copy_constructible<R>::value, T>::type get() const { if (!b) throw "Thread :: get :: Did not end and get was called with safety on"; return *r; } template<typename T = R> typename std::enable_if<!std::is_same<void, T>::value && !B && !std::is_copy_constructible<R>::value, T>::type get() const { return std::move(*r); } template<typename T = R> typename std::enable_if<!std::is_same<void, T>::value && B && !std::is_copy_constructible<R>::value, T>::type get() const { if (!b) throw "Thread :: get :: Did not end and get was called with safety on"; return std::move(*r); } template<typename T = R> typename std::enable_if<std::is_same<void, T>::value, void>::type get() const noexcept = delete; template<typename T = R> typename std::enable_if<!std::is_same<void, T>::value && !B>::type join() { std::thread::join(); r = std::make_shared<R>(f.get()); } template<typename T = R> typename std::enable_if<!std::is_same<void, T>::value && B>::type join() { std::thread::join(); r = std::make_shared<R>(f.get()); b = true; } template<typename T = R> typename std::enable_if<std::is_same<void, T>::value>::type join() { std::thread::join(); } std::future<R> &&detach() { std::thread::detach(); return std::move(f); } Thread &operator=(std::thread &&t) noexcept { std::thread::operator=(std::move(t)); return *this; } Thread &operator=(Thread &t) noexcept { return *this = std::forward<std::thread &&>(t); } private: std::promise<R> p; std::future<R> f; std::shared_ptr<R> r; bool b; }; //////////////////////////////////////////////////////////////////////////////// #endif
[ "simonmeyerrr@gmail.com" ]
simonmeyerrr@gmail.com
db8dfcadae6fb2d27a83ad55993f7bf494c5d069
55d560fe6678a3edc9232ef14de8fafd7b7ece12
/libs/sort/test/float_sort_test.cpp
afbdcc204557384a269e84f5815e2228feb8c782
[ "BSL-1.0" ]
permissive
stardog-union/boost
ec3abeeef1b45389228df031bf25b470d3d123c5
caa4a540db892caa92e5346e0094c63dea51cbfb
refs/heads/stardog/develop
2021-06-25T02:15:10.697006
2020-11-17T19:50:35
2020-11-17T19:50:35
148,681,713
0
0
BSL-1.0
2020-11-17T19:50:36
2018-09-13T18:38:54
C++
UTF-8
C++
false
false
5,295
cpp
// Boost Sort library float_sort_test.cpp file -----------------------------// // Copyright Steven Ross 2014. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/sort for library home page. #include <boost/sort/spreadsort/spreadsort.hpp> // Include unit test framework #include <boost/test/included/test_exec_monitor.hpp> #include <boost/test/test_tools.hpp> #include <vector> using namespace std; using namespace boost::sort::spreadsort; //Casting to an integer before bitshifting struct rightshift { int operator()(const float &x, const unsigned offset) const { return float_mem_cast<float, int>(x) >> offset; } }; struct rightshift_64 { boost::int64_t operator()(const double &x, const boost::uint64_t offset) const { return float_mem_cast<double, boost::int64_t>(x) >> offset; } }; boost::int32_t rand_32(bool sign = true) { boost::int32_t result = rand() | (rand()<< 16); if (rand() % 2) result |= 1 << 15; //Adding the sign bit if (sign && (rand() % 2)) result *= -1; return result; } static const unsigned input_count = 1000000; // Helper class to run tests across all float_sort interface variants. template<class FloatType, class RightShift> void test_vector(vector<FloatType> base_vec, RightShift shifter) { vector<FloatType> sorted_vec = base_vec; vector<FloatType> test_vec = base_vec; std::sort(sorted_vec.begin(), sorted_vec.end()); //Testing boost::sort::spreadsort version test_vec = base_vec; boost::sort::spreadsort::spreadsort(test_vec.begin(), test_vec.end()); BOOST_CHECK(test_vec == sorted_vec); //One functor test_vec = base_vec; float_sort(test_vec.begin(), test_vec.end(), shifter); BOOST_CHECK(test_vec == sorted_vec); //Both functors test_vec = base_vec; float_sort(test_vec.begin(), test_vec.end(), shifter, less<FloatType>()); BOOST_CHECK(test_vec == sorted_vec); } void float_test() { // Prepare inputs vector<float> base_vec; //Generating semirandom numbers that will work for basic testing for (unsigned u = 0; u < input_count; ++u) { float val = float(rand_32()); //As std::sort gives arbitrary results for NaNs and 0.0 vs. -0.0, treat all //those as just 0.0 for testing if (!(val < 0.0) && !(0.0 < val)) base_vec.push_back(0.0); else base_vec.push_back(val); } test_vector(base_vec, rightshift()); // Trying both positive and negative sorted and reverse sorted data. base_vec.clear(); for (int i = 0; i < (int)input_count; ++i) base_vec.push_back(-i); test_vector(base_vec, rightshift()); base_vec.clear(); for (int i = 0; i < (int)input_count; ++i) base_vec.push_back(i - input_count); test_vector(base_vec, rightshift()); base_vec.clear(); for (int i = 0; i < (int)input_count; ++i) base_vec.push_back(input_count - i); test_vector(base_vec, rightshift()); base_vec.clear(); for (size_t i = 0; i < input_count; ++i) base_vec.push_back(i); test_vector(base_vec, rightshift()); base_vec.clear(); for (size_t i = 0; i < input_count; ++i) base_vec.push_back(i); for (size_t i = 0; i < input_count; i += 2) base_vec[i] *= -1; test_vector(base_vec, rightshift()); } void double_test() { vector<double> base_vec; for (unsigned u = 0; u < input_count; ++u) { double val = double ((((boost::int64_t)rand_32()) << ((8 * sizeof(int)) -1)) + rand_32(false)); //As std::sort gives arbitrary results for NaNs and 0.0 vs. -0.0, //treat all those as just 0.0 for testing if (!(val < 0.0) && !(0.0 < val)) base_vec.push_back(0.0); else base_vec.push_back(val); } test_vector(base_vec, rightshift_64()); // Trying both positive and negative sorted and reverse sorted data. base_vec.clear(); for (int i = 0; i < (int)input_count; ++i) base_vec.push_back(-i); test_vector(base_vec, rightshift_64()); base_vec.clear(); for (int i = 0; i < (int)input_count; ++i) base_vec.push_back(i - input_count); test_vector(base_vec, rightshift_64()); base_vec.clear(); for (int i = 0; i < (int)input_count; ++i) base_vec.push_back(input_count - i); test_vector(base_vec, rightshift_64()); base_vec.clear(); for (size_t i = 0; i < input_count; ++i) base_vec.push_back(i); test_vector(base_vec, rightshift_64()); base_vec.clear(); for (size_t i = 0; i < input_count; ++i) base_vec.push_back(i); for (size_t i = 0; i < input_count; i += 2) base_vec[i] *= -1; test_vector(base_vec, rightshift_64()); } // Verify that 0 and 1 elements work correctly. void corner_test() { vector<float> test_vec; boost::sort::spreadsort::spreadsort(test_vec.begin(), test_vec.end()); const float test_value = -0.0; test_vec.push_back(test_value); boost::sort::spreadsort::spreadsort(test_vec.begin(), test_vec.end()); BOOST_CHECK(test_vec.size() == 1); BOOST_CHECK(test_vec[0] == test_value); } // test main int test_main( int, char*[] ) { srand(1); float_test(); double_test(); corner_test(); return 0; }
[ "james.pack@stardog.com" ]
james.pack@stardog.com
5c938d154f919cfe13844cdaceda5a49f399c82f
c910880ce3fb48b9cc038859841f0452fb205afe
/proc21/task21.cpp
099feb68b00564ad23a00041bc835a19691d39b7
[]
no_license
AlexVolkov0404/series_proc_minmax
02d1ed4d3463af74cf6e34a56f66b864abffd5ab
e036ad6766040e833d0a6d46a18860b6b4226356
refs/heads/master
2023-08-20T07:55:15.495350
2021-09-30T17:14:44
2021-09-30T17:14:44
411,020,099
0
0
null
null
null
null
UTF-8
C++
false
false
595
cpp
// proc21.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы. // #include <iostream> using namespace std; int SumRange(int a, int b) { if (b > a) { int s = 0; for (int i = a; i <= b; i++) { s = s + i; } return s; } else { return 0; } } int main() { int a, b,res; cout << "enter A: "; cin >> a; cout << "enter B: "; cin >> b; res = SumRange(a, b); cout << "your sum: " << res; }
[ "Sasha@ACER" ]
Sasha@ACER
ad8443957de9dae6ca56e32b44ff8937e6945fb8
8f53b76f56185dfac28aa6dc050e683215dff06d
/VentaBoletosTeatro/VentaBoletosTeatro/NodoCola.cpp
ccac3c4cde19d0a3ee7a77e3de4628ae55ae325c
[]
no_license
Rafa1390/ProyectoTeatroED
d8877acfc26c74c32d766f7b24b7459dd77f8572
c60728b936028d8877ab9931d51a274436b95d77
refs/heads/master
2020-05-02T10:26:55.319769
2019-04-09T01:16:13
2019-04-09T01:16:13
177,897,151
0
0
null
null
null
null
UTF-8
C++
false
false
329
cpp
#include "pch.h" #include "NodoCola.h" NodoCola::NodoCola() { } NodoCola::NodoCola(string x) { cliente = x; sig = NULL; } void NodoCola::SetCliente(string x) { cliente = x; } string NodoCola::GetCliente() { return cliente; } void NodoCola::SetSig(NodoCola *x) { sig = x; } NodoCola *NodoCola::GetSig() { return sig; }
[ "rafab1390@gmail.com" ]
rafab1390@gmail.com
cdb49b7ea5d9b8f71cffcb5117a15d325d545c9a
cea7881cf4c539c3e27f8645a0e562846f8a0044
/solutions/Arrays.cc
a544f67764ace173daa87fd9708df5937c4689c0
[]
no_license
dianaliu/oop
41e5aa8b2a9183a9ac32e8e729ff5100867bd420
fe6dc17062db90dbacc3d356b86887f896177de7
refs/heads/master
2021-01-03T13:19:33.204082
2011-12-19T09:02:52
2011-12-19T09:02:52
2,583,615
0
0
null
null
null
null
UTF-8
C++
false
false
4,129
cc
#include <iostream> #include "ptr.h" #include "java_lang.h" namespace java { namespace lang { // Forward declaration of datalayout and vt struct __Demo; struct __Demo_VT; typedef __rt::Ptr<__Demo> Demo; // The data layout for Demo struct __Demo { __Demo_VT* __vptr; // Constructor __Demo(); // Destructor static void __delete(__Demo*); static int32_t hashCode(Demo); static bool equals(Demo, Object); static Class getClass(Demo); static String toString(Demo); static String retS(String); static int32_t retI(int32_t); static __Demo_VT __vtable; static Class __class(); }; // The vtable layout for Demo struct __Demo_VT { Class __isa; void (*__delete)(__Demo*); int32_t (*hashCode)(Demo); bool (*equals)(Demo, Object); Class (*getClass)(Demo); String (*toString)(Demo); String (*retS)(String); int32_t (*retI)(int32_t); __Demo_VT(): __isa(__Object::__class()), __delete((void(*)(__Demo*))&__Object::__delete), hashCode((int32_t(*)(Demo))&__Object::hashCode), equals((bool(*)(Demo, Object))&__Object::equals), getClass((Class(*)(Demo))&__Object::getClass), toString((String(*)(Demo))&__Object::toString), retS((String(*)(String))&__Demo::retS), retI((int32_t(*)(int32_t))&__Demo::retI) { } }; // Empty constructors for class and vt __Demo::__Demo() : __vptr(&__vtable) { } __Demo_VT __Demo::__vtable; // Internal accessor for java.lang.Demo's class. Class __Demo::__class() { static Class k = new __Class(__rt::literal("java.lang.Demo"), __Object::__class()); return k; } } } namespace __rt { // Template specialization for array of Demo template<> java::lang::Class Array <java::lang::Demo>::__class() { static java::lang::Class k = new java::lang::__Class(literal("[Ljava.lang.Demo;"), Array<java::lang::Object>::__class(), java::lang::__Demo::__class()); return k; } } // ------------ begin CC file -------------- // #include <iostream> // #include "java_lang.h" using namespace java::lang; String __Demo::retS (String s) { return s; } int32_t __Demo::retI (int32_t i) { return i + 2; } int32_t main() { Demo d = new __Demo(); String s = __rt::literal("soo"); __rt::checkNotNull(d); __rt::checkNotNull(s); std::cout << __rt::literal("d.retS(s) = ") << d->__vptr->retS(s) << std::endl; __rt::checkNotNull(d); std::cout << __rt::literal("d.retI(4) = ") << d->__vptr->retI(4) << std::endl; __rt::checkNotNull(d); __rt::checkNotNull(s); std::cout << __rt::literal("d.retS(s).toString() = ") << d->__vptr->retS(s)->__vptr->toString(d->__vptr->retS(s)) << std::endl; Object o = d; __rt::checkNotNull(o); std::cout << __rt::literal("o class = ") << o->__vptr->getClass(o)->__vptr->toString(o->__vptr->getClass(o)) << std::endl; __rt::Ptr<__rt::Array<String> > ss = new __rt::Array<String>(2); __rt::Ptr<__rt::Array<Object> > oo = new __rt::Array<Object>(2); __rt::Ptr<__rt::Array<int32_t> > ii = new __rt::Array<int32_t>(2); (*ss)[0] = __rt::literal("zero"); __rt::checkNotNull(s); __rt::checkStore(ss,s); (*ss)[1] = s; for (int32_t i = 0; i < 2; i++) { std::cout << __rt::literal("ss = ") << (*ss)[i] << std::endl; } std::cout << __rt::literal("ss[1] = ") << (*ss)[1] << std::endl; __rt::checkNotNull(s); std::cout << __rt::literal("A string s = ") << s << std::endl; // Arrays must be __rt::Ptr<__rt::Array<Demo> > dd = new __rt::Array<Demo>(2); (*dd)[0] = new __Demo(); (*dd)[1] = new __Demo(); bool f = false; for (int32_t i = 0; i < 2; i++) { std::cout << __rt::literal("dd[] = ") << (*dd)[i]->__vptr->getClass((*dd)[i])->__vptr->toString((*dd)[i]->__vptr->getClass((*dd)[i])) << std::endl; } }
[ "dianaliu@nyu.edu" ]
dianaliu@nyu.edu
9073ea1a04e5fdf56e11e7597e683cc747eeb16c
600df3590cce1fe49b9a96e9ca5b5242884a2a70
/remoting/host/local_input_monitor_win.cc
ac6525e3851c5398b04b38020311c8d49f32ced2
[ "BSD-3-Clause" ]
permissive
metux/chromium-suckless
efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a
72a05af97787001756bae2511b7985e61498c965
refs/heads/orig
2022-12-04T23:53:58.681218
2017-04-30T10:59:06
2017-04-30T23:35:58
89,884,931
5
3
BSD-3-Clause
2022-11-23T20:52:53
2017-05-01T00:09:08
null
UTF-8
C++
false
false
8,043
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 "remoting/host/local_input_monitor.h" #include <stdint.h> #include "base/bind.h" #include "base/compiler_specific.h" #include "base/location.h" #include "base/logging.h" #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/threading/non_thread_safe.h" #include "base/win/message_window.h" #include "remoting/host/client_session_control.h" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" namespace remoting { namespace { // From the HID Usage Tables specification. const USHORT kGenericDesktopPage = 1; const USHORT kMouseUsage = 2; class LocalInputMonitorWin : public base::NonThreadSafe, public LocalInputMonitor { public: LocalInputMonitorWin( scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, base::WeakPtr<ClientSessionControl> client_session_control); ~LocalInputMonitorWin() override; private: // The actual implementation resides in LocalInputMonitorWin::Core class. class Core : public base::RefCountedThreadSafe<Core> { public: Core(scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, base::WeakPtr<ClientSessionControl> client_session_control); void Start(); void Stop(); private: friend class base::RefCountedThreadSafe<Core>; virtual ~Core(); void StartOnUiThread(); void StopOnUiThread(); // Handles WM_INPUT messages. LRESULT OnInput(HRAWINPUT input_handle); // Handles messages received by |window_|. bool HandleMessage(UINT message, WPARAM wparam, LPARAM lparam, LRESULT* result); // Task runner on which public methods of this class must be called. scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; // Task runner on which |window_| is created. scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; // Used to receive raw input. std::unique_ptr<base::win::MessageWindow> window_; // Points to the object receiving mouse event notifications. base::WeakPtr<ClientSessionControl> client_session_control_; DISALLOW_COPY_AND_ASSIGN(Core); }; scoped_refptr<Core> core_; DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorWin); }; LocalInputMonitorWin::LocalInputMonitorWin( scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, base::WeakPtr<ClientSessionControl> client_session_control) : core_(new Core(caller_task_runner, ui_task_runner, client_session_control)) { core_->Start(); } LocalInputMonitorWin::~LocalInputMonitorWin() { core_->Stop(); } LocalInputMonitorWin::Core::Core( scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, base::WeakPtr<ClientSessionControl> client_session_control) : caller_task_runner_(caller_task_runner), ui_task_runner_(ui_task_runner), client_session_control_(client_session_control) { DCHECK(client_session_control_); } void LocalInputMonitorWin::Core::Start() { DCHECK(caller_task_runner_->BelongsToCurrentThread()); ui_task_runner_->PostTask(FROM_HERE, base::Bind(&Core::StartOnUiThread, this)); } void LocalInputMonitorWin::Core::Stop() { DCHECK(caller_task_runner_->BelongsToCurrentThread()); ui_task_runner_->PostTask(FROM_HERE, base::Bind(&Core::StopOnUiThread, this)); } LocalInputMonitorWin::Core::~Core() { DCHECK(!window_); } void LocalInputMonitorWin::Core::StartOnUiThread() { DCHECK(ui_task_runner_->BelongsToCurrentThread()); window_.reset(new base::win::MessageWindow()); if (!window_->Create(base::Bind(&Core::HandleMessage, base::Unretained(this)))) { PLOG(ERROR) << "Failed to create the raw input window"; window_.reset(); // If the local input cannot be monitored, the remote user can take over // the session. Disconnect the session now to prevent this. caller_task_runner_->PostTask( FROM_HERE, base::Bind(&ClientSessionControl::DisconnectSession, client_session_control_, protocol::OK)); } } void LocalInputMonitorWin::Core::StopOnUiThread() { DCHECK(ui_task_runner_->BelongsToCurrentThread()); // Stop receiving raw mouse input. if (window_) { RAWINPUTDEVICE device = {0}; device.dwFlags = RIDEV_REMOVE; device.usUsagePage = kGenericDesktopPage; device.usUsage = kMouseUsage; device.hwndTarget = nullptr; // The error is harmless, ignore it. RegisterRawInputDevices(&device, 1, sizeof(device)); } window_.reset(); } LRESULT LocalInputMonitorWin::Core::OnInput(HRAWINPUT input_handle) { DCHECK(ui_task_runner_->BelongsToCurrentThread()); // Get the size of the input record. UINT size = 0; UINT result = GetRawInputData(input_handle, RID_INPUT, nullptr, &size, sizeof(RAWINPUTHEADER)); if (result == static_cast<UINT>(-1)) { PLOG(ERROR) << "GetRawInputData() failed"; return 0; } // Retrieve the input record itself. std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]); RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get()); result = GetRawInputData(input_handle, RID_INPUT, buffer.get(), &size, sizeof(RAWINPUTHEADER)); if (result == static_cast<UINT>(-1)) { PLOG(ERROR) << "GetRawInputData() failed"; return 0; } // Notify the observer about mouse events generated locally. Remote (injected) // mouse events do not specify a device handle (based on observed behavior). if (input->header.dwType == RIM_TYPEMOUSE && input->header.hDevice != nullptr) { POINT position; if (!GetCursorPos(&position)) { position.x = 0; position.y = 0; } caller_task_runner_->PostTask( FROM_HERE, base::Bind(&ClientSessionControl::OnLocalMouseMoved, client_session_control_, webrtc::DesktopVector(position.x, position.y))); } return DefRawInputProc(&input, 1, sizeof(RAWINPUTHEADER)); } bool LocalInputMonitorWin::Core::HandleMessage( UINT message, WPARAM wparam, LPARAM lparam, LRESULT* result) { switch (message) { case WM_CREATE: { // Register to receive raw mouse input. RAWINPUTDEVICE device = {0}; device.dwFlags = RIDEV_INPUTSINK; device.usUsagePage = kGenericDesktopPage; device.usUsage = kMouseUsage; device.hwndTarget = window_->hwnd(); if (RegisterRawInputDevices(&device, 1, sizeof(device))) { *result = 0; } else { PLOG(ERROR) << "RegisterRawInputDevices() failed"; *result = -1; } return true; } case WM_INPUT: *result = OnInput(reinterpret_cast<HRAWINPUT>(lparam)); return true; default: return false; } } } // namespace std::unique_ptr<LocalInputMonitor> LocalInputMonitor::Create( scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, base::WeakPtr<ClientSessionControl> client_session_control) { return base::WrapUnique(new LocalInputMonitorWin( caller_task_runner, ui_task_runner, client_session_control)); } } // namespace remoting
[ "enrico.weigelt@gr13.net" ]
enrico.weigelt@gr13.net