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
93ddd145c79b920c45aad02029d5075488ca426f
2259d06f2d2c14f771b2ed0b2a7bbe39d6530944
/AMSServer/src/HttpServer.cpp
5e0530e3d32717a106d1953203bd44203cf252c0
[]
no_license
crasyangel/AMSServer
ea694340269b4b2deb11bfff87f7476c1a30b284
7bdeba14edd932125c013541487b84d1577ce47b
refs/heads/master
2021-01-19T21:55:46.583425
2014-11-11T00:32:32
2014-11-11T00:32:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,022
cpp
#include "stdafx.h" #include "HttpServer.h" #define PAYLOAD_BUFFERSIZE 256 #define HTTP_GET_LENGTH 256 HttpServer::HttpServer(u_short useport): IOCPServer(useport) { } HttpServer::~HttpServer() { } BOOL HttpServer::DeriveAcceptEx(PerIOData *listeniodata) { AMS_DBUG("do nothing in base class\n"); return TRUE; } BOOL HttpServer::DeriveCheckRecv(DWORD bytestransfer, LPWSABUF recvbuf) { AMS_DBUG("do nothing in base class\n"); return TRUE; } BOOL HttpServer::CheckRecvBufEnd(DWORD bytestransfer, LPWSABUF recvbuf) { //let derived class do its thing if(FALSE == DeriveCheckRecv(bytestransfer, recvbuf)) { AMS_DBUG("DeriveCheckRecv failed: %d\n", WSAGetLastError()); return FALSE; } char tempbuf[5] = {0}; strncpy_s(tempbuf, 5, recvbuf->buf + bytestransfer - 4, 4); AMS_DBUG("receive message end is %s\n", tempbuf); if(0 != strcmp(tempbuf, "\r\n\r\n")) { return FALSE; } return TRUE; } BOOL HttpServer::DoRecv(SocketHandle* connecthandle, PerIOData* connectiodata) { if(NULL == connecthandle || NULL == connectiodata) { AMS_DBUG("you just transfer a NULL pointer\n"); return FALSE; } //process the massage connectiodata->bytestransfer = strlen(connectiodata->databuf.buf); AMS_DBUG("receive message len is %d.\n", connectiodata->bytestransfer); if(TRUE == CheckRecvBufEnd(connectiodata->bytestransfer, &connectiodata->databuf)) { AMS_DBUG("receive from %s:%d, message:\n%s\n", inet_ntoa(connecthandle->ssocketaddr.sin_addr), ntohs(connecthandle->ssocketaddr.sin_port),connectiodata->databuf.buf); //parse the "GET" string if(NULL == strstr(connectiodata->databuf.buf, "GET")) { AMS_DBUG("the client did not send the \"GET\" string, wrong use in http\n"); return FALSE; } CHAR getbuf[HTTP_GET_LENGTH] = {0}; sscanf_s(connectiodata->databuf.buf, "%*[^?]?%s", getbuf); AMS_DBUG("client send \"GET\" context is \n%s\n", getbuf); //new HttpData, transfer the getbuf HttpData* httpdata = new HttpData(getbuf); // usually we need send after recv connectiodata->ResetIOBuf(); if(FALSE == PostSend(connecthandle, connectiodata, httpdata)) { AMS_DBUG("PostSend failed to %s:%d\n", inet_ntoa(connecthandle->ssocketaddr.sin_addr), ntohs(connecthandle->ssocketaddr.sin_port)); } } else { AMS_DBUG("receive message incomplete\n"); PostRecv(connecthandle, connectiodata); } // handle recv signal complete, post new one //MUST not force to release the periodata which hold overlapped struct //new one periodata PerIOData *newconnectiodata = connecthandle->GetNewIOData(); PostRecv(connecthandle, newconnectiodata); return TRUE; } BOOL HttpServer::DeriveBuildSend(LPWSABUF sendbuf) { AMS_DBUG("do nothing in base class\n"); return TRUE; } BOOL HttpServer::BuildSend(LPWSABUF sendbuf, HttpData* httpdata) { strcat_s(sendbuf->buf, sendbuf->len, "HTTP/1.1 200 OK"); strcat_s(sendbuf->buf, sendbuf->len, "\r\n"); strcat_s(sendbuf->buf, sendbuf->len, "Content-Type: text/html"); strcat_s(sendbuf->buf, sendbuf->len, "\r\n"); if(FALSE == httpdata->HandleHttpData()) { AMS_DBUG("failed in httpdata->HandleHttpData\n"); return FALSE; } LPSTR payloadbuf = httpdata->GetPayLoadBuf(); CHAR tmpBuf[32] = {0}; sprintf_s(tmpBuf, 32, "Content-Length: %d", strlen(payloadbuf)); strcat_s(sendbuf->buf, sendbuf->len, tmpBuf); strcat_s(sendbuf->buf, sendbuf->len, "\r\n\r\n"); strcat_s(sendbuf->buf, sendbuf->len, payloadbuf); //let derived class do its thing if(FALSE == DeriveBuildSend(sendbuf)) { AMS_DBUG("failed in httpdata->HandleHttpData\n"); return FALSE; } return TRUE; } //post send BOOL HttpServer::PostSend(SocketHandle* connecthandle, PerIOData* connectiodata, HttpData* httpdata) { if(NULL == connecthandle || NULL == connectiodata) { AMS_DBUG("you just transfer a NULL pointer\n"); return FALSE; } // do some clean // make operationtype signal be SEND_POSTED DWORD flags = 0; DWORD sendbytes = 0; connectiodata->ResetOverLapped(); connectiodata->operationtype = PerIOData::SEND_POSTED; //build the message if(FALSE == BuildSend(&connectiodata->databuf, httpdata)) { AMS_DBUG("failed in BuildSend\n"); delete httpdata; AMS_DBUG("httpdata has been deleted\n"); return FALSE; } *(connectiodata->databuf.buf + strlen(connectiodata->databuf.buf)) = 0; //recycle the memory once finish delete httpdata; AMS_DBUG("httpdata has been deleted\n"); //send the message int nbytes = WSASend(connecthandle->ssocket, &connectiodata->databuf, 1, &sendbytes, flags, &connectiodata->overlapped, NULL ); if ((SOCKET_ERROR == nbytes) && (WSA_IO_PENDING != WSAGetLastError())) { AMS_DBUG("WSASend() failed: %d.\n", WSAGetLastError()); return FALSE; } AMS_DBUG("send to %s:%d, message: \n%s\n", inet_ntoa(connecthandle->ssocketaddr.sin_addr), ntohs(connecthandle->ssocketaddr.sin_port),connectiodata->databuf.buf ); //just do it in the end of one io here //this is dangerous in somewhere else connecthandle->RemoveIOData(connectiodata); return TRUE; }
[ "crasyangel@163.com" ]
crasyangel@163.com
a0ec700da001ebcf1141bb7c97e0d9643a0f2afc
62a59776b662227a38c4e52ed3f8675af5238145
/headers/irrwidget.h
87cae8c506719685653fa6bbaf3f346724f8915f
[]
no_license
wangscript007/Just-Another-Tetris-Game
4a844f8246d269aba0edca46635f9d2ce2db8f44
6cf44a50ba62c28d55528f912719b148a3479e3e
refs/heads/master
2021-05-28T21:12:45.921142
2014-07-06T15:42:31
2014-07-06T15:42:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,987
h
#ifndef QIRRWIDGET_H #define QIRRWIDGET_H #include "CGameApplication.h" #include <QWidget> #include <QResizeEvent> #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-variable" #include <irrlicht.h> #pragma GCC diagnostic warning "-Wunused-parameter" #pragma GCC diagnostic warning "-Wunused-variable" using namespace irr; /** * Irrlicht widget, includes device initialization, game aplication initialization, wrappers for Irrlicht events and render/game loop */ class QirrWidget : public QWidget { Q_OBJECT public: /** * Constructor * * @param parent - Qt pernt widget */ explicit QirrWidget(QWidget *parent = 0); /** * Destructor, drops Irrlicht device and game application */ ~QirrWidget(); /** * Getter * * @return pointer to Irrlicht device */ IrrlichtDevice* getIrrlichtDevice(); /** * Initialize Irrlicht device, game application and timer loop */ void init(); signals: /** * Signal to update Irrlicht, emits from timerEvent and paintEvent * * @param device - Irrlicht device to update */ void updateIrrlichtQuery(IrrlichtDevice* device); public slots: /** * Slot to update Irrlicht, increase timer, render one loop, call game application one loop * * @param device - Irrlicht device to update */ void updateIrrlicht(IrrlichtDevice* device); protected: /** * Documentation for all virtual overriden methods see in Qt include files */ virtual void paintEvent(QPaintEvent* event); /** * Documentation for all virtual overriden methods see in Qt include files */ virtual void timerEvent(QTimerEvent* event); /** * Documentation for all virtual overriden methods see in Qt include files */ virtual void resizeEvent(QResizeEvent* event); /** * Documentation for all virtual overriden methods see in Qt include files */ virtual void keyReleaseEvent(QKeyEvent *event); /** * Documentation for all virtual overriden methods see in Qt include files */ virtual void keyPressEvent(QKeyEvent *event); /** * Documentation for all virtual overriden methods see in Qt include files */ virtual void mousePressEvent(QMouseEvent* event); /** * Documentation for all virtual overriden methods see in Qt include files */ virtual void mouseReleaseEvent(QMouseEvent* event); /** * Documentation for all virtual overriden methods see in Qt include files */ virtual void mouseMoveEvent(QMouseEvent *event); /** * Documentation for all virtual overriden methods see in Qt include files */ virtual void wheelEvent(QWheelEvent* event); /** * render driver type */ irr::video::E_DRIVER_TYPE driverType; /** * Irrlicht device */ IrrlichtDevice *device; private: /** * game application */ CGameApplication* gameApplication; /** * struct for convert and passing Qt event to Irrlicht */ struct SIrrlichtKey { irr::EKEY_CODE code; wchar_t ch; }; /** * Convert Qt key to Irrlicht event key * * @param key - Qt key to convert * @return Irrlicht key and its char code wrapped in structure */ SIrrlichtKey convertToIrrlichtKey(int key); /** * Sends Qt key event to Irrlicht * * @param event - Qt key event to pass * @param pressedDown - true, if key is down, false otherwise */ void sendKeyEventToIrrlicht(QKeyEvent* event, bool pressedDown); /** * Sends Qt mouse event to Irrlicht * * @param event - Qt mouse event to pass * @param pressedDown - true, if key is down, false otherwise */ void sendMouseEventToIrrlicht(QMouseEvent* event, bool pressedDown); }; #endif // QIRRWIDGET_H
[ "hokan@a381b935-a386-e29a-64a5-071a85445432" ]
hokan@a381b935-a386-e29a-64a5-071a85445432
aa4af52793367e48bccc41c77a9c4989baeeabe3
88935ce124c354acdb013df9a499067444829ca0
/solutions/1021.cpp
450228f8725fc355953e8b82605589ff27f95ed5
[]
no_license
pascal-the-elf/TIOJ-ASE
6883e4d0d0a23f02d3f2efe58bf5bd9537952384
181ba41b732d52f9c8c728be247961dda3bd4398
refs/heads/main
2023-06-04T11:40:20.715491
2021-06-27T16:35:40
2021-06-27T16:35:40
377,033,735
0
0
null
null
null
null
UTF-8
C++
false
false
639
cpp
#include <bits/stdc++.h> using namespace std; long long t,n,v[1<<22],h; bool check; main(){ //cout << (2 ^5 ^4 ^10 ^8 ^11 ^9 ) << '\n'; ios_base::sync_with_stdio(0),cin.tie(0); cin >> t; while(t--){ cin >> h; n = (1LL<<h+1)-1; for(int i = 0; i < n; i++) cin >> v[i]; sort(v,v+n); check = true; for(int i = 0; check && i < n; i++) { if(i*2+1>=n) break; if(v[i*2+1] != v[i]*2) check = false; if(i*2+2>=n) break; if(v[i*2+2] != v[i]*2+1) check = false; } if(!check) cout << "do not "; cout << "dodge\n"; } }
[ "jacoblincool@gmail.com" ]
jacoblincool@gmail.com
3fd3a043357569949510376535679a85a9ecde76
476af59c3267d2c865fef50a84a256dcf6dbe191
/C++/Solution475.cpp
18dc8d6a3a5efeca905be1c6afcea408ed16ac34
[]
no_license
yogurt-shadow/leetcode
fb3c2f47e77c3b40b06fa65cffe63095bd6542e7
c824fa13237421afa69d05bb48026e7a2e407d02
refs/heads/master
2023-08-29T04:09:43.859492
2021-11-11T15:16:15
2021-11-11T15:16:15
325,449,621
2
0
null
null
null
null
UTF-8
C++
false
false
787
cpp
#include<iostream> #include<vector> #include<algorithm> #include<unordered_map> #include<unordered_set> using namespace std; typedef long long ll; class Solution475 { public: int findRadius(vector<int>& houses, vector<int>& heaters) { sort(houses.begin(), houses.end()); sort(heaters.begin(), heaters.end()); int index = 0; int ans = 0; for(auto ele: houses){ while(index + 1 < heaters.size() && ele > heaters[index]){ index ++; } int r = INT_MAX; if(index - 1 >= 0){ r = ele - heaters[index - 1]; } r = min(r, abs(ele - heaters[index])); ans = max(ans, r); } return ans; } };
[ "1711143@mail.nankai.edu.cn" ]
1711143@mail.nankai.edu.cn
9613f63fe33917cb6d837be41d31a113ddeaf1ff
419d0b562a0029f0a2b16bd39acb3abdf3fb3641
/c++/数据结构/趣味数学题/24点问题.cpp
af8457a50857101d2e51caa98a7e7a408abafae1
[]
no_license
Livemy/example
a77ec106ba3e00b14b1c7cef3b8f7feeaa1ae664
3e7f9eff66db97867ae2507d7d99e8387fc5a453
refs/heads/master
2020-05-16T16:41:27.342782
2017-10-06T17:19:55
2017-10-06T17:19:55
null
0
0
null
null
null
null
GB18030
C++
false
false
2,825
cpp
#include"iostream.h" #include"stdio.h" const int NUM=5; const int GAME=24; int array[NUM]; char symbol[NUM+1]=" +-*/"; int a,b,c,d; int degree=0; void output(int,int,int); void out(int,int,int); void main() { int p,q,r,s; int k,m,n; int temp,wap; int num,j; cout<<"请输入四个数:"<<endl; for(j=1;j<NUM;j++) cin>>array[j]; for(p=1;p<NUM;p++) for(q=1;q<NUM;q++) for(r=1;r<NUM;r++) for(s=1;s<NUM;s++) {//sssssssssssssssssssssssssssssssssssssssssssss if(q!=p&&r!=p&&r!=q&&s!=p&&s!=q&&s!=r) {a=array[p];b=array[q];c=array[r];d=array[s];} else continue; for(k=1;k<NUM;k++) { switch(k) {//k case 1: num=a+b;break; case 2: if(a>=b) num=a-b; else continue;break; case 3: num=a*b;break; case 4: if(a>=b&&b!=0&&a%b==0) num=a/b; else continue;break; } wap=num; for(m=1;m<NUM;m++) {//m num=wap; switch(m)//###################### { case 1: if(k==3) { if(a*b+c*d==GAME) output(k,m,3); if((c>=d&&d!=0&&c%d==0)&&(a*b+c/d==GAME)) output(k,m,4); } if(k==4) { if(a/b+c*d==GAME) output(k,m,3); if((c>=d&&d!=0&&c%d==0)&&(a/b+c/d==GAME)) output(k,m,4); } num=num+c; break; case 2: if(k==3) { if(a*b>=c*d&&(a*b-c*d==GAME)) output(k,m,3); if((c>=d&&d!=0&&c%d==0&&a*b>=c/d)&&(a*b-c/d==GAME)) output(k,m,4); } if(k==4) { if(a/b>=c*d&&(a/b-c*d==GAME)) output(k,m,3); if((c>=d&&d!=0&&(c%d==0))&&a/b>c/d&&(a/b-c/d==GAME)) output(k,m,4); } if(num>=c) num=num-c; else continue; break; case 3: num=num*c;break; case 4: if(num>=c&&c!=0&&num%c==0) num=num/c; else continue;break; }//############################# temp=num; for(n=1;n<NUM;n++) {//n num=temp; switch(n) { case 1: num=num+d;break; case 2: if(num>=d) num=num-d; else continue;break; case 3: num=num*d;break; case 4: if(num>=d&&d!=0&&num%d==0) num=num/d; else continue;break; } if(num==GAME) { out(k,m,n); //goto END; } }///n }///m }///k }//sssssssssssssssssssssssssssssssssssssssssssssssssssssss //END:; if(!degree) cout<<"对不起,这四个数无解。"<<endl; } void output(int k,int m,int n) { degree=1; printf("%d%c%d%c%d%c%d\t",a,symbol[k], b,symbol[m],c,symbol[n],d); } void out(int k,int m,int n) { degree=1; if(n==1||n==2) {//n if(m==1||m==2) {//m printf("%d%c%d%c%d%c%d\t",a,symbol[k], b,symbol[m],c,symbol[n],d); }else///m { if(k==1||k==2) printf("(%d%c%d)%c%d%c%d\t",a,symbol[k], b,symbol[m],c,symbol[n],d);//(a+b)*c else printf("%d%c%d%c%d%c%d\t",a,symbol[k], b,symbol[m],c,symbol[n],d);//a*b*c }////m }else///n { if(m==1||m==2) {//m printf("(%d%c%d%c%d)%c%d\t",a,symbol[k], b,symbol[m],c,symbol[n],d);//(a+b+c)*d }else///m { if(k==1||k==2) printf("(%d%c%d)%c%d%c%d\t",a,symbol[k], b,symbol[m],c,symbol[n],d);//(a+b)*c*d else printf("%d%c%d%c%d%c%d\t",a,symbol[k], b,symbol[m],c,symbol[n],d); }////m }////n }
[ "wuguijiadeyu@gmail.com" ]
wuguijiadeyu@gmail.com
3a8584cf162325ba95d8cbcc782c1c1cbd36853d
856b77df352a85e1c63187d614a11827defdc4ea
/training/testOfTryToMatrix/test_tryToMatrix.cpp
5b4001d6886c9bfc6c433f91c7e9463f83fd1e18
[]
no_license
KartoonYoko/tryToClasses
4d4a495437ca0c32c6e3c327f91e0d94c25e30be
5ec4c4553229d23b5145c6d44f7f5ad84483f9d6
refs/heads/master
2020-08-11T19:24:44.530400
2020-01-07T17:34:03
2020-01-07T17:34:03
214,614,610
0
0
null
null
null
null
UTF-8
C++
false
false
2,763
cpp
#include <iostream> #include <cassert> #include "test_tryToMatrix.h" using namespace std; void test_ClassMyMatrix_constructor() { { MyMatrix a; assert((a(0,0) == 0) && "MyMatrix a;"); } { MyMatrix a(2, 2); assert((a(1, 1) == 0) && "MyMatrix a(1, 1);"); } { MyMatrix a(2, 2, 3); assert((a(1, 1) == 3) && "MyMatrix a(1, 1, 3);"); } { try { MyMatrix a(-3, 4); assert(0 && "MyMatrix a(-3, 4); // it doesnt throw exeption"); } catch (MatrixException e) {;} } { try { MyMatrix a(3, -4); assert(0 && "MyMatrix a(3, -4); // it doesnt throw exeption"); } catch (MatrixException e) {;} } cout << "test_MyMatrix_constructor OK" << endl; } void test_ClassMyMatrix_fill() { { MyMatrix a; a.fillRand(2, 12); assert( (a(0, 0) <= 12) && (a(0, 0) >= 2) && a(0, 0) && "a.fill();" ); } cout << "test_ClassMatrix_fill OK" << endl; } void test_ClassMyMatrix_expand() { { MyMatrix a(2, 2, 6); a.expand(4, 4, 3); assert(a(3, 3) == 3 && "a.expand(4, 4, 3);"); } { try { MyMatrix a(2, 2, 6); a.expand(2, 2, 3); assert(0 && "dont catch exeption"); } catch (MatrixException e) {;} } cout << "test_ClassMyMatrix_expand OK" << endl; } void test_ClassMyMatrix_MatrixMultMatrix() { { try { MyMatrix a(3, 2), b(3, 2); MyMatrix result = a * b; assert(0 && "dont catch exeption"); } catch (MatrixException e) { ; } } { MyMatrix a(3, 2, 2), b(2, 2, 4); MyMatrix result = a * b; assert((result.getRowCount() == 3) && (result.getColCount() == 2) && (result.getItem(0, 0) == 16) &&""); } cout << "test_ClassMyMatrix_MatrixMultMatrix OK" << endl; } void test_ClassMatrix_transpose() { { MyMatrix a(2, 2, 4); a(0, 0) = 2; a(0, 1) = 3; a(1, 0) = 5; a.outputConsole(); cout << endl << "_____________" << endl ; a.transpose(); a.outputConsole(); } cout << "test_ClassMatrix_transpose OK" << endl; } void test_ClassMatrix_determinant() { { MyMatrix a(2, 2, 3); double result = a.determinant(); assert((result == 0) && "double result = a.determinant();"); } { MyMatrix a(2, 2, 1); a(0, 1) = 2; a(1, 0) = 3; a(1, 1) = 4; double result = a.determinant(); assert((result == -2) && "double result = a.determinant();"); } cout << "test_ClassMatrix_determinant OK" << endl; } void test_ClassMyMatrix_all() { test_ClassMyMatrix_constructor(); test_ClassMyMatrix_fill(); test_ClassMyMatrix_expand(); test_ClassMyMatrix_MatrixMultMatrix(); test_ClassMatrix_transpose(); test_ClassMatrix_determinant(); cout << "_________________________________test_ClassMyMatrix_all OK!" << endl << endl << endl; }
[ "crashed9001@gmail.com" ]
crashed9001@gmail.com
792177324929ef3e976a4967f97f2214f2d443ee
98d32633a148aa9c7343830abf83b9e9fb61141d
/슬라이딩 윈도우/2096/2096.cpp
b374819820b21976513fa2e783f7af7373361d5a
[]
no_license
Astro86/baekjoon
d4f6fba1d87a97a790a06d24c62cb0b0561fb49f
e39172a621cff82c13ff0adf70a75fbd59dee3fb
refs/heads/master
2022-10-24T13:17:55.911169
2020-06-11T02:33:24
2020-06-11T02:33:24
245,296,350
1
0
null
null
null
null
UTF-8
C++
false
false
1,340
cpp
#include <bits/stdc++.h> using namespace std; int dp_max[3]; int dp_min[3]; int main(void) { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < 3; i++) { cin >> dp_max[i]; dp_min[i] = dp_max[i]; } for (int i = 1; i < n; i++) { int arr[3]; for (int j = 0; j < 3; j++) { cin >> arr[j]; } int next_max_dp[3]; for (int j = 0; j < 3; j++) { next_max_dp[j] = arr[j] + dp_max[j]; if (j - 1 >= 0) next_max_dp[j] = max(next_max_dp[j], arr[j] + dp_max[j - 1]); if (j + 1 < 3) next_max_dp[j] = max(next_max_dp[j], arr[j] + dp_max[j + 1]); } int next_min_dp[3]; for (int j = 0; j < 3; j++) { next_min_dp[j] = arr[j] + dp_min[j]; if (j - 1 >= 0) next_min_dp[j] = min(next_min_dp[j], arr[j] + dp_min[j - 1]); if (j + 1 < 3) next_min_dp[j] = min(next_min_dp[j], arr[j] + dp_min[j + 1]); } for (int j = 0; j < 3; j++) { dp_max[j] = next_max_dp[j]; dp_min[j] = next_min_dp[j]; } } cout << *max_element(dp_max, dp_max + 3) << " " << *min_element(dp_min, dp_min + 3) << '\n'; return 0; }
[ "ckck803@naver.com" ]
ckck803@naver.com
2fb84b5cb09cadc8288ec85c8f5bdef9788f659e
77da632163112ccab3acfe1ae0da5f820034ebd5
/playerlibrary/src/main/cpp/MediaPlayer/source/sync/MediaSync.h
59fa86796a9b7520284e145b3052b8a340abb178
[]
no_license
zhumingwei/DafuPlayer
d9b1e3f2e104f2e8a664823f4b756db583c02a96
ca506b6bf9c7f5eb2200a21f9aa728e69f07d3d3
refs/heads/master
2022-11-17T17:07:01.799959
2020-07-16T03:29:40
2020-07-16T03:29:40
272,461,479
0
0
null
null
null
null
UTF-8
C++
false
false
2,243
h
// // Created by zhumingwei on 2020/7/7. // #ifndef DAFUPLAYER_MEDIASYNC_H #define DAFUPLAYER_MEDIASYNC_H #include <Thread.h> #include <player/PlayerState.h> #include <decoder/VideoDecoder.h> #include <decoder/AudioDecoder.h> #include <device/VideoDevice.h> /** * 视频同步器 */ class MediaSync : public Runnable { public: MediaSync(PlayerState * playerState); virtual ~MediaSync(); void reset(); void start(VideoDecoder *videoDecoder, AudioDecoder *audioDecoder); void stop(); //设置视频输出设备 void setVideoDevice(VideoDevice *device); //设置帧最大间隔 void setMaxDuration(double maxDuration); //更新视频帧的计时器 void refreshVideoTimer(); //更新音频时钟 void updateAudioClock(double pts, double time); // 获取音频时钟与主时钟的差值 double getAudioDiffClock(); // 获取外部时钟 void updateExternalClock(double pts); double getMasterClock(); void run() override ; MediaClock *getAudioClock(); MediaClock *getVideoClock(); MediaClock *getExternalClock(); private: void refreshVideo(double *remaining_time); void checkExternalClockSpeed(); double calculateDelay(double delay); double calculateDuration(Frame *vp, Frame *nextvp); void renderVideo(); private: PlayerState *playerState; //播放器状态 bool abortRequest; //停止 bool mExit; MediaClock *audioClock; //音频时钟 MediaClock *videoClock; //视频时钟 MediaClock *extClock; //外部时钟 VideoDecoder *videoDecoder; // 视频解码器 AudioDecoder *audioDecoder; // 音频解码器 Mutex mMutex; Condition mCondition; Thread *syncThread; //同步线程 int forceRefresh; //强制刷新标志 double maxFrameDuration; //最大延迟时 int frameTimerRefresh; //刷新时钟 double frameTimer; //视频时钟 VideoDevice *videoDevice; //视频输出设备 AVFrame *pFrameARGB; uint8_t *mBuffer; SwsContext *swsContext; }; #endif //DAFUPLAYER_MEDIASYNC_H
[ "zhumingwei2016@gmail.com" ]
zhumingwei2016@gmail.com
6afbdd80744a78351aa5352fb9ac8cf36675e017
82a716560b1be3956352e21e674a326950ff6dc3
/MachineObject/source/MachineObj_Comm.cpp
0cce6f469f63821ee0debd9c7eeec285c3e7031d
[]
no_license
lake2010/LaserMachine_NoWorktable
0e4103b8fa994be80ef31f14d2e9e7ee11927c98
06b5d14f5001ade3423dbc7576e15b25be994e85
refs/heads/master
2023-03-24T05:10:04.827484
2021-03-23T03:45:46
2021-03-23T03:45:46
null
0
0
null
null
null
null
GB18030
C++
false
false
4,562
cpp
// MachineObj_Comm.cpp : 实现文件 // #include "stdafx.h" #include "MachineObj_Comm.h" #include "MachineObjPoint.h" #include "MachineObjLine.h" #include "MachineObjCircle.h" #include "MachineObjEllipse.h" #include "MachineObjArc.h" #include "MachineObjArcEll.h" #include "MachineObjTiltEllipse.h" #include "MachineObjPolyline.h" #include "MachineObjGroup.h" #include "MachineObjWLine.h" // CMachineObj_Comm 构造函数 CMachineObj_Comm::CMachineObj_Comm() { m_bIsObjStatus = IsObjNormal; } CMachineObj_Comm::~CMachineObj_Comm() { } // CMachineObj_Comm 成员函数 // 公开函数 int CMachineObj_Comm::GetObjType() { return m_ObjType; } ObjRect CMachineObj_Comm::GetObjBound() { return m_ObjBound; } ObjPoint CMachineObj_Comm::GetObjStart(CMachineObj_Comm* pObj) { ObjPoint point; switch (pObj->m_ObjType) { case MachineObj_Type_Point: CMachineObjPoint* pPoint; pPoint = (CMachineObjPoint*)pObj; return pPoint->GetPoint(); case MachineObj_Type_Line: CMachineObjLine* pLine; pLine = (CMachineObjLine*)pObj; return pLine->GetLineStart(); case MachineObj_Type_Circle: CMachineObjCircle* pCircle; pCircle = (CMachineObjCircle*)pObj; return pCircle->GetCircleStart(); case MachineObj_Type_Arc: CMachineObjArc* pArc; pArc = (CMachineObjArc*)pObj; return pArc->GetArcStart(); case MachineObj_Type_Ellipse: CMachineObjEllipse* pEllipse; pEllipse = (CMachineObjEllipse*)pObj; return pEllipse->GetEllipseStart(); case MachineObj_Type_ArcEll: CMachineObjArcEll* pArcEll; pArcEll = (CMachineObjArcEll*)pObj; return pArcEll->GetArcStart(); case MachineObj_Type_TiltEllipse: CMachineObjTiltEllipse* pTiltEll; pTiltEll = (CMachineObjTiltEllipse*)pObj; return pTiltEll->GetTiltEllipseStart(); case MachineObj_Type_Polyline: CMachineObjPolyline* pPolyline; pPolyline = (CMachineObjPolyline*)pObj; point.x = pPolyline->GetPolylineStart().x; point.y = pPolyline->GetPolylineStart().y; return point; default: break; } return ObjPoint(0, 0); } ObjPoint CMachineObj_Comm::GetObjEnd(CMachineObj_Comm* pObj) { ObjPoint point; switch (pObj->m_ObjType) { case MachineObj_Type_Line: CMachineObjLine* pLine; pLine = (CMachineObjLine*)pObj; return pLine->GetLineEnd(); case MachineObj_Type_Circle: CMachineObjCircle* pCircle; pCircle = (CMachineObjCircle*)pObj; return pCircle->GetCircleStart(); case MachineObj_Type_Arc: CMachineObjArc* pArc; pArc = (CMachineObjArc*)pObj; return pArc->GetArcEnd(); case MachineObj_Type_Ellipse: CMachineObjEllipse* pEllipse; pEllipse = (CMachineObjEllipse*)pObj; return pEllipse->GetEllipseStart(); case MachineObj_Type_ArcEll: CMachineObjArcEll* pArcEll; pArcEll = (CMachineObjArcEll*)pObj; return pArcEll->GetArcEnd(); case MachineObj_Type_TiltEllipse: CMachineObjTiltEllipse* pTiltEll; pTiltEll = (CMachineObjTiltEllipse*)pObj; return pTiltEll->GetTiltEllipseEnd(); case MachineObj_Type_Polyline: CMachineObjPolyline* pPolyline; pPolyline = (CMachineObjPolyline*)pObj; point.x = pPolyline->GetPolylineEnd().x; point.y = pPolyline->GetPolylineEnd().y; return point; default: break; } return ObjPoint(0, 0); } CMachineObj_Comm* CMachineObj_Comm::ExchangeStartAndEnd(CMachineObj_Comm* pObj) { int Number; int nType = pObj->GetObjType(); switch (nType) { case MachineObj_Type_Line: CMachineObjLine* pLine; pLine = (CMachineObjLine*)pObj; pLine->ExchangeStartAndEnd(pLine); break; case MachineObj_Type_Circle: CMachineObjCircle* pCircle; pCircle = (CMachineObjCircle*)pObj; Number = pCircle->GetCircleStartNum(); Number++; if (Number > 3) Number = 0; pCircle->SetCircleStart(Number); break; case MachineObj_Type_Arc: CMachineObjArc* pArc; pArc = (CMachineObjArc*)pObj; pArc->ExchangeStartAndEnd(pArc); break; case MachineObj_Type_Ellipse: CMachineObjEllipse* pEllipse; pEllipse = (CMachineObjEllipse*)pObj; Number = pEllipse->GetEllipseStartNum(); Number++; if (Number > 3) Number = 0; pEllipse->SetEllipseStart(Number); break; case MachineObj_Type_ArcEll: CMachineObjArcEll* pArcEll; pArcEll = (CMachineObjArcEll*)pObj; pArcEll->ExchangeStartAndEnd(pArcEll); break; case MachineObj_Type_TiltEllipse: CMachineObjTiltEllipse* pTiltEllArc; pTiltEllArc = (CMachineObjTiltEllipse*)pObj; pTiltEllArc->ExchangeStartAndEnd(pTiltEllArc); break; case MachineObj_Type_Polyline: CMachineObjPolyline* pPolyline; pPolyline = (CMachineObjPolyline*)pObj; pPolyline->ExchangeStartAndEnd(pPolyline); break; default: break; } return pObj; }
[ "67619262+forkidd214@users.noreply.github.com" ]
67619262+forkidd214@users.noreply.github.com
03614db0706eb2f8fe5760cb41b25269e260df89
68104eb0f7ec8038879d2a38fe6b7d40b912549e
/tests/myconnection.cpp
978c4ca1eec52b07232836eb8f05c49aa77915f2
[ "Apache-2.0" ]
permissive
RakhithJK/REACT-CPP-AMQP
5bbe233d7f7a1334190ab3645ab9360dd82f9320
c9ee219af64247fb0573eaf8e4ef301a33118cb0
refs/heads/master
2021-12-06T10:17:14.797780
2015-10-30T11:10:51
2015-10-30T11:10:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,716
cpp
/** * MyConnection.cpp * * @copyright 2014 Copernica BV */ #include "myconnection.h" /** * Constructor */ MyConnection::MyConnection(React::Loop *loop, const std::string& host) : _loop(loop), _connection(loop, this, host, 5672, AMQP::Login("guest", "guest"), "/"), _channel(nullptr) {} /** * Method that is called when the connection succeeded * @param connection Pointer to the connection */ void MyConnection::onConnected(React::AMQP::Connection *connection) { // report connection std::cout << "connected" << std::endl; // create a new channel _channel = std::unique_ptr<React::AMQP::Channel>(new React::AMQP::Channel(&_connection)); // watch for the channel becoming ready _channel->onReady([this]() { // show that we are ready std::cout << "AMQP channel ready, id: " << (int) _channel->id() << std::endl; }); // and of course for channel errors _channel->onError([this](const std::string& message) { // inform the user of the error std::cerr << "AMQP channel error on channel " << _channel->id() << ": " << message << std::endl; // delete the channel _channel = nullptr; // close the connection _connection.close(); }); // declare a queue and let us know when it succeeds _channel->declareQueue("my_queue").onSuccess([](const std::string &name, uint32_t messageCount, uint32_t consumerCount){ // queue was successfully declared std::cout << "AMQP Queue declared with name '" << name << "', " << messageCount << " messages and " << consumerCount << " consumer" << std::endl; }); // also declare an exchange _channel->declareExchange("my_exchange", AMQP::direct).onSuccess([]() { // exchange successfully declared std::cout << "AMQP exchange declared" << std::endl; }); // bind the queue to the exchange _channel->bindQueue("my_exchange", "my_queue", "key").onSuccess([]() { // queue successfully bound to exchange std::cout << "AMQP Queue bound" << std::endl; }); // set quality of service _channel->setQos(1).onSuccess([]() { // quality of service successfully set std::cout << "AMQP Quality of Service set" << std::endl; }); // publish a message to the exchange if (!_channel->publish("my_exchange", "key", "my_message")) { // we could not publish the message, something is wrong somewhere std::cerr << "Unable to publish message" << std::endl; // close the channel _channel->close().onSuccess([this]() { // also close the connection _connection.close(); }); } // consume the message we just published _channel->consume("my_queue", "my_consumer", AMQP::exclusive) .onReceived([this](const AMQP::Message &message, uint64_t deliveryTag, bool redelivered) { // show the message data std::cout << "AMQP consumed: " << message.message() << std::endl; // ack the message _channel->ack(deliveryTag); // and stop consuming (there is only one message anyways) _channel->cancel("my_consumer").onSuccess([this](const std::string& tag) { // we successfully stopped consuming std::cout << "Stopped consuming under tag " << tag << std::endl; }); // unbind the queue again _channel->unbindQueue("my_exchange", "my_queue", "key").onSuccess([]() { // queueu successfully unbound std::cout << "Queue unbound" << std::endl; }); // the queue should now be empty, so we can delete it _channel->removeQueue("my_queue").onSuccess([](uint32_t messageCount) { // queue was removed, it should have been empty, so messageCount should be 0 if (messageCount) std::cerr << "Removed queue which should have been empty but contained " << messageCount << " messages" << std::endl; // no messages is the expected behavior else std::cout << "Queue removed" << std::endl; }); // also remove the exchange _channel->removeExchange("my_exchange").onSuccess([]() { // exchange was successfully removed std::cout << "Removed exchange" << std::endl; }); // everything done, close the channel _channel->close().onSuccess([this]() { // channel was closed std::cout << "Channel closed" << std::endl; // close the connection too _connection.close(); }); }) .onSuccess([]() { // consumer was started std::cout << "Started consuming" << std::endl; }); } /** * Method that is called when the socket is closed (as a result of a TcpSocket::close() call) * @param connection Pointer to the connection */ void MyConnection::onClosed(React::AMQP::Connection *connection) { // show std::cout << "myconnection closed" << std::endl; // close the channel and connection _channel = nullptr; // stop the loop _loop->stop(); } /** * When the connection ends up in an error state this method is called. * This happens when data comes in that does not match the AMQP protocol * * After this method is called, the connection no longer is in a valid * state and can be used. In normal circumstances this method is not called. * * @param connection The connection that entered the error state * @param message Error message */ void MyConnection::onError(React::AMQP::Connection *connection, const char *message) { // report error std::cout << "AMQP Connection error: " << message << std::endl; }
[ "martijn.otto@copernica.com" ]
martijn.otto@copernica.com
c79cff82bbdd715cbadff580ddca753e7c3b7f84
e2c5261fc9b04a9972f98f05dd10dfd24da5f662
/C_Dominant_Piranha.cpp
8e73606fb4067f2726412f5e7577b5d6745d9aa8
[]
no_license
sash7410/coding
baf9d8735b6553f0da31f9dceb49c5d6f7db71ce
2a67e5ffe8d2176e2072b3c92a3c7c471f1edb6f
refs/heads/master
2023-03-26T18:20:43.140308
2021-03-16T19:26:37
2021-03-16T19:26:37
299,128,014
1
3
null
2020-10-19T05:51:38
2020-09-27T22:08:49
C++
UTF-8
C++
false
false
2,642
cpp
#include<bits/stdc++.h> using namespace std; #define gc getchar_unlocked #define fo(i,a,b) for(int i=a;i<b;i++) #define rfo(i,a,b) for(int i=a;i>=b;i--) #define mfo(it,m) for(auto it=m.begin(); it!=m.end(); it++) #define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1) #define ll long long int #define si(x) scanf("%d",&x) #define sl(x) scanf("%lld",&x) #define ss(s) scanf("%s",s) #define pi(x) printf("%d\n",x) #define pl(x) printf("%lld\n",x) #define ps(s) printf("%s\n",s) #define deb(x) cout << #x << "=" << x << endl #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof(x)) #define sortall(x) sort(all(x)) #define PI 3.1415926535897932384626 typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vpii; typedef vector<vi> vvi; //======================= mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count()); int rng(int lim) { uniform_int_distribution<int> uid(0,lim-1); return uid(rang); } const int mod = 1000000007; bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second < b.second); } int solve() { int n,mi=INT_MAX,ma=INT_MIN; cin >> n; int a[n]; fo(i,0,n){ cin>>a[i]; mi=min(a[i],mi); ma=max(ma,a[i]); } /* if(ma-mi<0) return -1; if(n==0) return -1; if(n==1) return 0; if(a[0]>a[1]&&a[0]+1>a[1]) return 0; if(a[n-1]>a[n-2]&&a[n-1]+1>a[n-2]) return n-1; */ vector<pair<int, int>> b; fo(i,1,n-1){ if(a[i]>a[i+1]||a[i]>a[i-1]) b.push_back( make_pair(i,a[i]) ); } /* fo(i,2,n){ if(a[i]>a[i-1]&&a[i]+1>a[i-2]) return i; } if(a[n-2]>a[n-1]&&a[n-2]+1>a[n-3]) return n-2; if(a[1]>a[0]&&a[1]+1>a[2]) return 0; return -1;*/ if(n>1&&a[0]>a[1]) b.push_back( make_pair(0,a[0]) ); if(a[n-1]>a[n-2]) b.push_back( make_pair(n-1,a[n-1]) ); if(b.size()>=1) { sort(b.begin(), b.end(), sortbysec); return b[b.size()-1].first; } return -1; } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); srand(chrono::high_resolution_clock::now().time_since_epoch().count()); int t = 1; cin >> t; //deb(t); while(t--) { int z=solve(); if(z==-1) cout<<-1<<endl; else { cout<<z+1<<endl; } //cout<<solve()<<endl; } return 0; } int mpow(int base, int exp) { base %= mod; int result = 1; while (exp > 0) { if (exp & 1) result = ((ll)result * base) % mod; base = ((ll)base * base) % mod; exp >>= 1; } return result; }
[ "sashankrm11@gmail.com" ]
sashankrm11@gmail.com
e177a1b9834f78966523d4b1c5b6a46efd39de29
1b091302660b32d47d22ce3c4834af5f002c7ca3
/UWPSamples/IntroGraphics/SimpleMSAA_UWP/SimpleMSAA.cpp
bf5e9c8589a4d13a1fa2801a4116a47304af4209
[ "MIT" ]
permissive
lb-YoshikiDomae/Xbox-ATG-Samples
bf13c65a82f453b74b270af24b88461b42e99c03
76d236e3bd372aceec18b2ad0556a7879dbd9628
refs/heads/master
2021-07-08T14:42:56.429213
2017-10-03T00:28:02
2017-10-03T00:28:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,610
cpp
//-------------------------------------------------------------------------------------- // SimpleMSAA.cpp // // This sample demonstrates setting up a MSAA render target for DirectX 11 // // Advanced Technology Group (ATG) // Copyright (C) Microsoft Corporation. All rights reserved. //-------------------------------------------------------------------------------------- #include "pch.h" #include "SimpleMSAA.h" #include "ATGColors.h" #include "ControllerFont.h" extern void ExitSample(); using namespace DirectX; using namespace DirectX::SimpleMath; using Microsoft::WRL::ComPtr; namespace { const DXGI_FORMAT c_backBufferFormat = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; const DXGI_FORMAT c_depthBufferFormat = DXGI_FORMAT_D32_FLOAT; // This is a workaround for a bug in the Windows 10 validation layer when using sRGB formats. const DXGI_FORMAT c_msaaFormat = DXGI_FORMAT_B8G8R8A8_TYPELESS; const DXGI_FORMAT c_resolveFormat = DXGI_FORMAT_B8G8R8A8_UNORM; unsigned int c_targetSampleCount = 4; } Sample::Sample() : m_sampleCount(0), m_msaa(true), m_gamepadPresent(false) { m_deviceResources = std::make_unique<DX::DeviceResources>( c_backBufferFormat, c_depthBufferFormat, /* If we were only doing MSAA rendering, we could skip the non-MSAA depth/stencil buffer with DXGI_FORMAT_UNKNOWN */ 2); m_deviceResources->RegisterDeviceNotify(this); // // In Win32 'classic' DirectX 11, you can create the 'swapchain' backbuffer as a multisample buffer. Present took care of the // resolve as part of the swapchain management. This implicit resolve behavior is not supported for UWP. // } // Initialize the Direct3D resources required to run. void Sample::Initialize(::IUnknown* window, int width, int height, DXGI_MODE_ROTATION rotation) { m_gamePad = std::make_unique<GamePad>(); m_keyboard = std::make_unique<Keyboard>(); m_keyboard->SetWindow(reinterpret_cast<ABI::Windows::UI::Core::ICoreWindow*>(window)); m_deviceResources->SetWindow(window, width, height, rotation); m_deviceResources->CreateDeviceResources(); CreateDeviceDependentResources(); m_deviceResources->CreateWindowSizeDependentResources(); CreateWindowSizeDependentResources(); } #pragma region Frame Update // Executes basic render loop. void Sample::Tick() { m_timer.Tick([&]() { Update(m_timer); }); Render(); } // Updates the world. void Sample::Update(DX::StepTimer const& timer) { PIXBeginEvent(PIX_COLOR_DEFAULT, L"Update"); float time = float(timer.GetTotalSeconds()); m_world = Matrix::CreateRotationZ(cosf(time / 4.f)); auto pad = m_gamePad->GetState(0); m_gamepadPresent = pad.IsConnected(); if (m_gamepadPresent) { m_gamePadButtons.Update(pad); if (pad.IsViewPressed()) { ExitSample(); } if (m_gamePadButtons.a == GamePad::ButtonStateTracker::PRESSED) { m_msaa = !m_msaa; } } else { m_gamePadButtons.Reset(); } auto kb = m_keyboard->GetState(); m_keyboardButtons.Update(kb); if (kb.Escape) { ExitSample(); } if (m_keyboardButtons.IsKeyPressed(Keyboard::Keys::Space)) { m_msaa = !m_msaa; } PIXEndEvent(); } #pragma endregion #pragma region Frame Render // Draws the scene. void Sample::Render() { // Don't try to render anything before the first Update. if (m_timer.GetFrameCount() == 0) { return; } // Prepare the render target to render a new frame. Clear(); auto context = m_deviceResources->GetD3DDeviceContext(); PIXBeginEvent(context, PIX_COLOR_DEFAULT, L"Render"); // Draw the scene. m_model->Draw(context, *m_states, m_world, m_view, m_proj); PIXEndEvent(context); if (m_msaa) { // Resolve the MSAA render target. PIXBeginEvent(context, PIX_COLOR_DEFAULT, L"Resolve"); auto backBuffer = m_deviceResources->GetRenderTarget(); context->ResolveSubresource(backBuffer, 0, m_msaaRenderTarget.Get(), 0, c_resolveFormat); PIXEndEvent(context); // Set render target for UI which is typically rendered without MSAA. auto renderTarget = m_deviceResources->GetRenderTargetView(); context->OMSetRenderTargets(1, &renderTarget, nullptr); } // Draw UI PIXBeginEvent(context, PIX_COLOR_DEFAULT, L"Draw UI"); auto size = m_deviceResources->GetOutputSize(); auto safe = SimpleMath::Viewport::ComputeTitleSafeArea(size.right, size.bottom); m_batch->Begin(); wchar_t str[32] = {}; swprintf_s(str, L"Sample count: %u", m_msaa ? m_sampleCount : 1); m_smallFont->DrawString(m_batch.get(), str, XMFLOAT2(float(safe.left), float(safe.top)), ATG::Colors::White); const wchar_t* legend = m_gamepadPresent ? L"[A] Toggle MSAA [View] Exit" : L"Space: Toggle MSAA Esc: Exit"; DX::DrawControllerString(m_batch.get(), m_smallFont.get(), m_ctrlFont.get(), legend, XMFLOAT2(float(safe.left), float(safe.bottom) - m_smallFont->GetLineSpacing()), ATG::Colors::LightGrey); m_batch->End(); PIXEndEvent(context); // Show the new frame. PIXBeginEvent(PIX_COLOR_DEFAULT, L"Present"); m_deviceResources->Present(); PIXEndEvent(); } // Helper method to clear the back buffers. void Sample::Clear() { auto context = m_deviceResources->GetD3DDeviceContext(); PIXBeginEvent(context, PIX_COLOR_DEFAULT, L"Clear"); // Clear the views. if (m_msaa) { // // Rather than operate on the swapchain render target, we set up to render the scene to our MSAA resources instead. // context->ClearRenderTargetView(m_msaaRenderTargetView.Get(), ATG::ColorsLinear::Background); context->ClearDepthStencilView(m_msaaDepthStencilView.Get(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); context->OMSetRenderTargets(1, m_msaaRenderTargetView.GetAddressOf(), m_msaaDepthStencilView.Get()); } else { auto renderTarget = m_deviceResources->GetRenderTargetView(); auto depthStencil = m_deviceResources->GetDepthStencilView(); context->ClearRenderTargetView(renderTarget, ATG::ColorsLinear::Background); context->ClearDepthStencilView(depthStencil, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); context->OMSetRenderTargets(1, &renderTarget, depthStencil); } // Set the viewport. auto viewport = m_deviceResources->GetScreenViewport(); context->RSSetViewports(1, &viewport); PIXEndEvent(context); } #pragma endregion #pragma region Message Handlers // Message handlers void Sample::OnActivated() { } void Sample::OnDeactivated() { } void Sample::OnSuspending() { auto context = m_deviceResources->GetD3DDeviceContext(); context->ClearState(); m_deviceResources->Trim(); } void Sample::OnResuming() { m_timer.ResetElapsedTime(); m_gamePadButtons.Reset(); m_keyboardButtons.Reset(); } void Sample::OnWindowSizeChanged(int width, int height, DXGI_MODE_ROTATION rotation) { if (!m_deviceResources->WindowSizeChanged(width, height, rotation)) return; CreateWindowSizeDependentResources(); } void Sample::ValidateDevice() { m_deviceResources->ValidateDevice(); } // Properties void Sample::GetDefaultSize(int& width, int& height) const { width = 1280; height = 720; } #pragma endregion #pragma region Direct3D Resources // These are the resources that depend on the device. void Sample::CreateDeviceDependentResources() { auto device = m_deviceResources->GetD3DDevice(); auto context = m_deviceResources->GetD3DDeviceContext(); m_batch = std::make_unique<SpriteBatch>(context); m_states = std::make_unique<CommonStates>(device); m_fxFactory = std::make_unique<EffectFactory>(device); m_model = Model::CreateFromSDKMESH(device, L"CityBlockConcrete.sdkmesh", *m_fxFactory); m_world = Matrix::Identity; // Load UI. m_smallFont = std::make_unique<SpriteFont>(device, L"SegoeUI_18.spritefont"); m_ctrlFont = std::make_unique<SpriteFont>(device, L"XboxOneControllerLegendSmall.spritefont"); // // Check for MSAA support. // // Note that 4x MSAA is required for Direct3D Feature Level 10.1 or better // 8x MSAA is required for Direct3D Feature Level 11.0 or better // for (m_sampleCount = c_targetSampleCount; m_sampleCount > 1; m_sampleCount--) { UINT levels = 0; if (FAILED(device->CheckMultisampleQualityLevels(c_backBufferFormat, m_sampleCount, &levels))) continue; if (levels > 0) break; } if (m_sampleCount < 2) { throw std::exception("MSAA not supported"); } } // Allocate all memory resources that change on a window SizeChanged event. void Sample::CreateWindowSizeDependentResources() { auto output = m_deviceResources->GetOutputSize(); // Determine the render target size in pixels. UINT backBufferWidth = std::max<UINT>(output.right - output.left, 1); UINT backBufferHeight = std::max<UINT>(output.bottom - output.top, 1); // Create an MSAA render target. CD3D11_TEXTURE2D_DESC renderTargetDesc( c_msaaFormat, backBufferWidth, backBufferHeight, 1, // The render target view has only one texture. 1, // Use a single mipmap level. D3D11_BIND_RENDER_TARGET, D3D11_USAGE_DEFAULT, 0, m_sampleCount ); auto device = m_deviceResources->GetD3DDevice(); DX::ThrowIfFailed(device->CreateTexture2D( &renderTargetDesc, nullptr, m_msaaRenderTarget.ReleaseAndGetAddressOf() )); CD3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc(D3D11_RTV_DIMENSION_TEXTURE2DMS, c_backBufferFormat); DX::ThrowIfFailed(device->CreateRenderTargetView( m_msaaRenderTarget.Get(), &renderTargetViewDesc, m_msaaRenderTargetView.ReleaseAndGetAddressOf() )); // Create an MSAA depth stencil view. CD3D11_TEXTURE2D_DESC depthStencilDesc( c_depthBufferFormat, backBufferWidth, backBufferHeight, 1, // This depth stencil view has only one texture. 1, // Use a single mipmap level. D3D11_BIND_DEPTH_STENCIL, D3D11_USAGE_DEFAULT, 0, m_sampleCount ); ComPtr<ID3D11Texture2D> depthStencil; DX::ThrowIfFailed(device->CreateTexture2D( &depthStencilDesc, nullptr, depthStencil.GetAddressOf() )); DX::ThrowIfFailed(device->CreateDepthStencilView( depthStencil.Get(), nullptr, m_msaaDepthStencilView.ReleaseAndGetAddressOf() )); // Setup test scene. m_view = Matrix::CreateLookAt(Vector3(0, -211.f, -23.f), Vector3(6.f, 0.f, -37.f), -Vector3::UnitZ); m_proj = Matrix::CreatePerspectiveFieldOfView(XM_PI / 4.f, float(backBufferWidth) / float(backBufferHeight), 0.1f, 1000.f); auto viewport = m_deviceResources->GetScreenViewport(); m_batch->SetViewport(viewport); } void Sample::OnDeviceLost() { m_msaaRenderTarget.Reset(); m_msaaRenderTargetView.Reset(); m_msaaDepthStencilView.Reset(); m_batch.reset(); m_smallFont.reset(); m_ctrlFont.reset(); m_states.reset(); m_model.reset(); m_fxFactory.reset(); } void Sample::OnDeviceRestored() { CreateDeviceDependentResources(); CreateWindowSizeDependentResources(); } #pragma endregion
[ "chuckw@windows.microsoft.com" ]
chuckw@windows.microsoft.com
d3361adec403c8982ce7fb18ed1496839777369f
d2660af113b6d8f3c4ea1753cf517ba4385dd745
/client/src/viewmodel/ViewModel.cpp
f2d023083a97e61edb48043ac05e49e4360e1002
[]
no_license
INanaay/CPP_babel_2018
fcb289c4801af53ba32c4927ec194ca629aeaf85
c0a7ec8db87369b5121d865e85537e271ea2f02e
refs/heads/master
2020-12-27T23:25:07.366437
2018-10-08T12:09:13
2018-10-08T12:09:13
238,103,445
0
0
null
null
null
null
UTF-8
C++
false
false
1,869
cpp
// // Created by NANAA on 28/09/18. // #include <client/inc/viewmodel/ViewModel.hpp> #include <thread> ViewModel::ViewModel() : m_mainWindow(nullptr) { m_loginScreen = new loginScreen(); m_client = new Client(); if (m_client == nullptr || m_loginScreen == nullptr) throw std::exception(); m_client->setM_viewModel(this); m_loginScreen->setM_viewModel(this); } void ViewModel::start() const { m_loginScreen->show(); } void ViewModel::startMainApplication() { m_mainWindow = new MainWindow(); if (m_mainWindow == nullptr) throw std::exception(); m_mainWindow->setM_viewModel(this); populateContactList(); //m_mainWindow->populateContactList(m_client->getM_contacts()); m_loginScreen->hide(); m_mainWindow->show(); m_client->startWorker(); m_client->startUdpWorker(); } void ViewModel::setClientUsername(const std::string &username) { m_client->setM_username(username); } void ViewModel::connectToServer() const { m_client->connectToServer(); } void ViewModel::populateContactList() const { m_mainWindow->populateContactList(m_client->getM_contacts()); } void ViewModel::startCall(int index) const { m_client->tryToCall(index); } void ViewModel::setIpServer(const std::string &ip) { m_client->setM_serverIp(ip); } void ViewModel::hidePopup() const { m_mainWindow->hideCallPopup(); } void ViewModel::showPopup(const std::string &username) const { m_mainWindow->showCallPopup(username); } void ViewModel::acceptCall() const { m_client->acceptCall(); } void ViewModel::showError() const { m_loginScreen->showError(); } void ViewModel::changeCallButtons() const { m_mainWindow->startCall(); } void ViewModel::changeHangButton() const { std::cout << "Stopping call" << std::endl; m_mainWindow->stopCall(); } void ViewModel::stopCall() const { std::cout << "Pressed hang up" << std::endl; m_client->sendStopPacket(); }
[ "nathan.lebon@epitech.eu" ]
nathan.lebon@epitech.eu
f6167c3bd829b4323011951bf66be84140618d1c
d372fe6989bfff97a264b72509fa65284efadb0e
/src/Subsystems/IntakeSystem.cpp
dfa7d62fd756dc0766af75527665205623a46b02
[]
no_license
Robodox-599/Emma_CommandBased
89918618ffb84844e91eec915fbf6a4d3e9ce0c0
b6cd3124246c220e7a451213e23c0eef70fa0251
refs/heads/master
2020-03-21T21:36:00.419728
2018-12-11T00:37:55
2018-12-11T00:37:55
139,072,799
0
0
null
null
null
null
UTF-8
C++
false
false
1,188
cpp
/*----------------------------------------------------------------------------*/ /* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*----------------------------------------------------------------------------*/ #include "IntakeSystem.h" #include <CTRE/Phoenix.h> #include <WPILib.h> #include "../RobotMap.h" #include <Commands/IntakeSlow.h> IntakeSystem::IntakeSystem() : Subsystem("IntakeSystem") { leftIntakeMotor = new TalonSRX(5); rightIntakeMotor = new TalonSRX(8); } void IntakeSystem::InitDefaultCommand() { // Set the default command for a subsystem here. // SetDefaultCommand(new MySpecialCommand()); //SetDefaultCommand(new IntakeSlow()); } // Put methods for controlling this subsystem // here. Call these from Commands. void IntakeSystem::IntakeRoll(float speed) { leftIntakeMotor->Set(ControlMode::PercentOutput, -speed); rightIntakeMotor->Set(ControlMode::PercentOutput, speed); }
[ "hungryleo9316@gmail.com" ]
hungryleo9316@gmail.com
3013c2bdb0ff272c22de3bbf747b13165184adb4
78a6919f17d1eb4b1b570fd3ff60476d8cf4f702
/node_modules/core/GradeLevel.h
b8e30f47dbd16d0ea495c7cd64b1af0cfb00d046
[]
no_license
limiteegod/football
c5b4f770d81d74ebfdb31003018bb8bb52ade1ad
7a9f531506a77e05e1c9bdead5ada6ac28d7bc8d
refs/heads/master
2021-01-02T08:33:53.450156
2014-11-18T15:02:22
2014-11-18T15:02:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
643
h
#ifndef GRADELEVEL_H #define GRADELEVEL_H #include <node.h> class GradeLevel:public node::ObjectWrap { public: static void Init(); static v8::Handle<v8::Value> NewInstance(const v8::Arguments& args); private: explicit GradeLevel(int levelCount = 0); ~GradeLevel(); static v8::Handle<v8::Value> New(const v8::Arguments& args); static v8::Handle<v8::Value> SetBonus(const v8::Arguments& args); static v8::Handle<v8::Value> GetBonus(const v8::Arguments& args); static v8::Persistent<v8::Function> constructor; long *bonusArray; int levelCount; }; #endif
[ "limiteemail@163.com" ]
limiteemail@163.com
08a8d27fb77630342684d012c335b9f81b961512
f1533c3b39e8f2e1d9dc8790a8fbd0c485d544e9
/Queue_ReversalUsingRecursion_Webinar.cpp
820e94fe7b092d7ae6e584256aedd38bfadecf17
[]
no_license
sweetyburnwal/Coding-Block
953cffe9ca0c51f72d77bf5e13a13fa2ffb62418
23ed1e23091ba66dc1daefa3861e71948b14999c
refs/heads/master
2020-12-26T18:40:41.626354
2020-02-01T10:55:47
2020-02-01T10:55:47
237,599,582
0
0
null
null
null
null
UTF-8
C++
false
false
475
cpp
#include<iostream> #include<queue> using namespace std; void reverseQueue(queue<int> &q) { if(q.empty()) { return; } int frontElement=q.front(); q.pop(); reverseQueue(q); q.push(frontElement); } void print(queue<int> q) { while(!q.empty()) { cout<<q.front()<<endl; q.pop(); } } int main() { queue<int> q; q.push(4); q.push(3); q.push(2); q.push(1); print(q); reverseQueue(q); print(q); return 0; }
[ "sweetyburnwal013@gmail.com" ]
sweetyburnwal013@gmail.com
eadc9c5bed0e21590407ea6c3da0ff636cd588ed
6ef3a9321d3da3a3aa3aa832cf81f9b6df64d597
/CocosWidget/ToggleView.cpp
5fb1f4f8ce76d0de7132c092b5fe13b2345f0f82
[]
no_license
live17909/Tui-x
389db3917e274687d7822fe61178003d5c82f81f
e4c75af95cc4b5777e3edeffc7f4215a38edada0
refs/heads/master
2021-01-22T11:05:00.354815
2014-05-12T16:22:20
2014-05-12T16:22:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,999
cpp
/**************************************************************************** Copyright (c) 2014 Lijunlin - Jason lee Created by Lijunlin - Jason lee on 2014 jason.lee.c@foxmail.com 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. ****************************************************************************/ #include "ToggleView.h" NS_CC_WIDGET_BEGIN #define CC_SAFE_SET_VISIBLE(__ITEM__, __VAR__) if( __ITEM__ ) __ITEM__->setVisible(__VAR__) CToggleView::CToggleView() { } CToggleView::~CToggleView() { } void CToggleView::setEnabled(bool bEnabled) { if( m_bEnabled != bEnabled ) { if( bEnabled ) { CC_SAFE_SET_VISIBLE(m_pNormalImage, true); CC_SAFE_SET_VISIBLE(m_pSelectedImage, false); CC_SAFE_SET_VISIBLE(m_pDisabledImage, false); } else { setChecked(false); CC_SAFE_SET_VISIBLE(m_pNormalImage, false); CC_SAFE_SET_VISIBLE(m_pSelectedImage, false); CC_SAFE_SET_VISIBLE(m_pDisabledImage, true); } m_bEnabled = bEnabled; } } void CToggleView::setChecked(bool bChecked) { if( m_bChecked != bChecked && m_bEnabled ) { if( bChecked ) { CC_SAFE_SET_VISIBLE(m_pNormalImage, false); CC_SAFE_SET_VISIBLE(m_pSelectedImage, true); CC_SAFE_SET_VISIBLE(m_pDisabledImage, false); setUnCheckedForOtherWidgetsByExclusion(_parent); } else { CC_SAFE_SET_VISIBLE(m_pNormalImage, true); CC_SAFE_SET_VISIBLE(m_pSelectedImage, false); CC_SAFE_SET_VISIBLE(m_pDisabledImage, false); } m_bChecked = bChecked; executeCheckHandler(this, m_bChecked); } } CWidgetTouchModel CToggleView::onTouchBegan(Touch *pTouch) { CC_WIDGET_LONGCLICK_ONTOUCHBEGAN; return eWidgetTouchTransient; } void CToggleView::onTouchMoved(Touch *pTouch, float fDuration) { CC_WIDGET_LONGCLICK_ONTOUCHMOVED; } void CToggleView::onTouchEnded(Touch *pTouch, float fDuration) { CC_WIDGET_LONGCLICK_ONTOUCHENDED; Point touchPointInView = _parent->convertToNodeSpace(pTouch->getLocation()); if( getBoundingBox().containsPoint(touchPointInView) ) { setChecked(!m_bChecked); executeClickHandler(this); } } void CToggleView::onTouchCancelled(Touch *pTouch, float fDuration) { CC_WIDGET_LONGCLICK_ONTOUCHCANCELLED; } CToggleView* CToggleView::create() { CToggleView *pRet = new CToggleView(); if( pRet && pRet->init() ) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; } CToggleView* CToggleView::create(const char* pNormal, const char* pSelected, const char* pDisabled) { CToggleView *pRet = new CToggleView(); if( pRet && pRet->initWithFile(pNormal, pSelected, pDisabled) ) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; } CToggleView* CToggleView::createWith9Sprite(const Size& tSize, const char* pNormal, const char* pSelected, const char* pDisabled) { CToggleView* pRet = new CToggleView(); if( pRet && pRet->initWith9Sprite(tSize, pNormal, pSelected, pDisabled) ) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; } NS_CC_WIDGET_END
[ "342854406@qq.com" ]
342854406@qq.com
6adc87608110a3d65118d3116cd6e749d1b60bb7
5c4331a9981faf34a386ca62ccfe049946d78289
/src/compiler/code-assembler.cc
4844355abb08e61a694f9ae669e201477a21cf67
[ "BSD-3-Clause", "SunPro", "bzip2-1.0.6" ]
permissive
stefb965/v8
391c624aa9283e8b7ca256d4b9b33c9a23288e44
679b31c21425ecdd86c40a8a02ac131b72f7bc6b
refs/heads/master
2021-01-13T17:20:28.139535
2016-12-21T15:14:16
2016-12-21T15:14:16
77,066,477
0
0
NOASSERTION
2019-05-11T23:58:31
2016-12-21T16:09:34
C++
UTF-8
C++
false
false
27,053
cc
// Copyright 2015 the V8 project 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 "src/compiler/code-assembler.h" #include <ostream> #include "src/code-factory.h" #include "src/compiler/graph.h" #include "src/compiler/instruction-selector.h" #include "src/compiler/linkage.h" #include "src/compiler/node-matchers.h" #include "src/compiler/pipeline.h" #include "src/compiler/raw-machine-assembler.h" #include "src/compiler/schedule.h" #include "src/frames.h" #include "src/interface-descriptors.h" #include "src/interpreter/bytecodes.h" #include "src/machine-type.h" #include "src/macro-assembler.h" #include "src/utils.h" #include "src/zone/zone.h" #define REPEAT_1_TO_2(V, T) V(T) V(T, T) #define REPEAT_1_TO_3(V, T) REPEAT_1_TO_2(V, T) V(T, T, T) #define REPEAT_1_TO_4(V, T) REPEAT_1_TO_3(V, T) V(T, T, T, T) #define REPEAT_1_TO_5(V, T) REPEAT_1_TO_4(V, T) V(T, T, T, T, T) #define REPEAT_1_TO_6(V, T) REPEAT_1_TO_5(V, T) V(T, T, T, T, T, T) #define REPEAT_1_TO_7(V, T) REPEAT_1_TO_6(V, T) V(T, T, T, T, T, T, T) #define REPEAT_1_TO_8(V, T) REPEAT_1_TO_7(V, T) V(T, T, T, T, T, T, T, T) #define REPEAT_1_TO_9(V, T) REPEAT_1_TO_8(V, T) V(T, T, T, T, T, T, T, T, T) namespace v8 { namespace internal { namespace compiler { CodeAssemblerState::CodeAssemblerState( Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, Code::Flags flags, const char* name, size_t result_size) : CodeAssemblerState( isolate, zone, Linkage::GetStubCallDescriptor( isolate, zone, descriptor, descriptor.GetStackParameterCount(), CallDescriptor::kNoFlags, Operator::kNoProperties, MachineType::AnyTagged(), result_size), flags, name) {} CodeAssemblerState::CodeAssemblerState(Isolate* isolate, Zone* zone, int parameter_count, Code::Flags flags, const char* name) : CodeAssemblerState(isolate, zone, Linkage::GetJSCallDescriptor( zone, false, parameter_count, Code::ExtractKindFromFlags(flags) == Code::BUILTIN ? CallDescriptor::kPushArgumentCount : CallDescriptor::kNoFlags), flags, name) {} CodeAssemblerState::CodeAssemblerState(Isolate* isolate, Zone* zone, CallDescriptor* call_descriptor, Code::Flags flags, const char* name) : raw_assembler_(new RawMachineAssembler( isolate, new (zone) Graph(zone), call_descriptor, MachineType::PointerRepresentation(), InstructionSelector::SupportedMachineOperatorFlags(), InstructionSelector::AlignmentRequirements())), flags_(flags), name_(name), code_generated_(false), variables_(zone) {} CodeAssemblerState::~CodeAssemblerState() {} CodeAssembler::~CodeAssembler() {} class BreakOnNodeDecorator final : public GraphDecorator { public: explicit BreakOnNodeDecorator(NodeId node_id) : node_id_(node_id) {} void Decorate(Node* node) final { if (node->id() == node_id_) { base::OS::DebugBreak(); } } private: NodeId node_id_; }; void CodeAssembler::BreakOnNode(int node_id) { Graph* graph = raw_assembler()->graph(); Zone* zone = graph->zone(); GraphDecorator* decorator = new (zone) BreakOnNodeDecorator(static_cast<NodeId>(node_id)); graph->AddDecorator(decorator); } void CodeAssembler::CallPrologue() {} void CodeAssembler::CallEpilogue() {} // static Handle<Code> CodeAssembler::GenerateCode(CodeAssemblerState* state) { DCHECK(!state->code_generated_); RawMachineAssembler* rasm = state->raw_assembler_.get(); Schedule* schedule = rasm->Export(); Handle<Code> code = Pipeline::GenerateCodeForCodeStub( rasm->isolate(), rasm->call_descriptor(), rasm->graph(), schedule, state->flags_, state->name_); state->code_generated_ = true; return code; } bool CodeAssembler::Is64() const { return raw_assembler()->machine()->Is64(); } bool CodeAssembler::IsFloat64RoundUpSupported() const { return raw_assembler()->machine()->Float64RoundUp().IsSupported(); } bool CodeAssembler::IsFloat64RoundDownSupported() const { return raw_assembler()->machine()->Float64RoundDown().IsSupported(); } bool CodeAssembler::IsFloat64RoundTiesEvenSupported() const { return raw_assembler()->machine()->Float64RoundTiesEven().IsSupported(); } bool CodeAssembler::IsFloat64RoundTruncateSupported() const { return raw_assembler()->machine()->Float64RoundTruncate().IsSupported(); } Node* CodeAssembler::Int32Constant(int32_t value) { return raw_assembler()->Int32Constant(value); } Node* CodeAssembler::Int64Constant(int64_t value) { return raw_assembler()->Int64Constant(value); } Node* CodeAssembler::IntPtrConstant(intptr_t value) { return raw_assembler()->IntPtrConstant(value); } Node* CodeAssembler::NumberConstant(double value) { return raw_assembler()->NumberConstant(value); } Node* CodeAssembler::SmiConstant(Smi* value) { return BitcastWordToTaggedSigned(IntPtrConstant(bit_cast<intptr_t>(value))); } Node* CodeAssembler::SmiConstant(int value) { return SmiConstant(Smi::FromInt(value)); } Node* CodeAssembler::HeapConstant(Handle<HeapObject> object) { return raw_assembler()->HeapConstant(object); } Node* CodeAssembler::BooleanConstant(bool value) { return raw_assembler()->BooleanConstant(value); } Node* CodeAssembler::ExternalConstant(ExternalReference address) { return raw_assembler()->ExternalConstant(address); } Node* CodeAssembler::Float64Constant(double value) { return raw_assembler()->Float64Constant(value); } Node* CodeAssembler::NaNConstant() { return LoadRoot(Heap::kNanValueRootIndex); } bool CodeAssembler::ToInt32Constant(Node* node, int32_t& out_value) { Int64Matcher m(node); if (m.HasValue() && m.IsInRange(std::numeric_limits<int32_t>::min(), std::numeric_limits<int32_t>::max())) { out_value = static_cast<int32_t>(m.Value()); return true; } return false; } bool CodeAssembler::ToInt64Constant(Node* node, int64_t& out_value) { Int64Matcher m(node); if (m.HasValue()) out_value = m.Value(); return m.HasValue(); } bool CodeAssembler::ToSmiConstant(Node* node, Smi*& out_value) { if (node->opcode() == IrOpcode::kBitcastWordToTaggedSigned) { node = node->InputAt(0); } else { return false; } IntPtrMatcher m(node); if (m.HasValue()) { out_value = Smi::cast(bit_cast<Object*>(m.Value())); return true; } return false; } bool CodeAssembler::ToIntPtrConstant(Node* node, intptr_t& out_value) { IntPtrMatcher m(node); if (m.HasValue()) out_value = m.Value(); return m.HasValue(); } Node* CodeAssembler::Parameter(int value) { return raw_assembler()->Parameter(value); } void CodeAssembler::Return(Node* value) { return raw_assembler()->Return(value); } void CodeAssembler::PopAndReturn(Node* pop, Node* value) { return raw_assembler()->PopAndReturn(pop, value); } void CodeAssembler::DebugBreak() { raw_assembler()->DebugBreak(); } void CodeAssembler::Comment(const char* format, ...) { if (!FLAG_code_comments) return; char buffer[4 * KB]; StringBuilder builder(buffer, arraysize(buffer)); va_list arguments; va_start(arguments, format); builder.AddFormattedList(format, arguments); va_end(arguments); // Copy the string before recording it in the assembler to avoid // issues when the stack allocated buffer goes out of scope. const int prefix_len = 2; int length = builder.position() + 1; char* copy = reinterpret_cast<char*>(malloc(length + prefix_len)); MemCopy(copy + prefix_len, builder.Finalize(), length); copy[0] = ';'; copy[1] = ' '; raw_assembler()->Comment(copy); } void CodeAssembler::Bind(Label* label) { return label->Bind(); } Node* CodeAssembler::LoadFramePointer() { return raw_assembler()->LoadFramePointer(); } Node* CodeAssembler::LoadParentFramePointer() { return raw_assembler()->LoadParentFramePointer(); } Node* CodeAssembler::LoadStackPointer() { return raw_assembler()->LoadStackPointer(); } #define DEFINE_CODE_ASSEMBLER_BINARY_OP(name) \ Node* CodeAssembler::name(Node* a, Node* b) { \ return raw_assembler()->name(a, b); \ } CODE_ASSEMBLER_BINARY_OP_LIST(DEFINE_CODE_ASSEMBLER_BINARY_OP) #undef DEFINE_CODE_ASSEMBLER_BINARY_OP Node* CodeAssembler::WordShl(Node* value, int shift) { return (shift != 0) ? raw_assembler()->WordShl(value, IntPtrConstant(shift)) : value; } Node* CodeAssembler::WordShr(Node* value, int shift) { return (shift != 0) ? raw_assembler()->WordShr(value, IntPtrConstant(shift)) : value; } Node* CodeAssembler::Word32Shr(Node* value, int shift) { return (shift != 0) ? raw_assembler()->Word32Shr(value, Int32Constant(shift)) : value; } Node* CodeAssembler::ChangeUint32ToWord(Node* value) { if (raw_assembler()->machine()->Is64()) { value = raw_assembler()->ChangeUint32ToUint64(value); } return value; } Node* CodeAssembler::ChangeInt32ToIntPtr(Node* value) { if (raw_assembler()->machine()->Is64()) { value = raw_assembler()->ChangeInt32ToInt64(value); } return value; } Node* CodeAssembler::RoundIntPtrToFloat64(Node* value) { if (raw_assembler()->machine()->Is64()) { return raw_assembler()->RoundInt64ToFloat64(value); } return raw_assembler()->ChangeInt32ToFloat64(value); } #define DEFINE_CODE_ASSEMBLER_UNARY_OP(name) \ Node* CodeAssembler::name(Node* a) { return raw_assembler()->name(a); } CODE_ASSEMBLER_UNARY_OP_LIST(DEFINE_CODE_ASSEMBLER_UNARY_OP) #undef DEFINE_CODE_ASSEMBLER_UNARY_OP Node* CodeAssembler::Load(MachineType rep, Node* base) { return raw_assembler()->Load(rep, base); } Node* CodeAssembler::Load(MachineType rep, Node* base, Node* offset) { return raw_assembler()->Load(rep, base, offset); } Node* CodeAssembler::AtomicLoad(MachineType rep, Node* base, Node* offset) { return raw_assembler()->AtomicLoad(rep, base, offset); } Node* CodeAssembler::LoadRoot(Heap::RootListIndex root_index) { if (isolate()->heap()->RootCanBeTreatedAsConstant(root_index)) { Handle<Object> root = isolate()->heap()->root_handle(root_index); if (root->IsSmi()) { return SmiConstant(Smi::cast(*root)); } else { return HeapConstant(Handle<HeapObject>::cast(root)); } } Node* roots_array_start = ExternalConstant(ExternalReference::roots_array_start(isolate())); return Load(MachineType::AnyTagged(), roots_array_start, IntPtrConstant(root_index * kPointerSize)); } Node* CodeAssembler::Store(Node* base, Node* value) { return raw_assembler()->Store(MachineRepresentation::kTagged, base, value, kFullWriteBarrier); } Node* CodeAssembler::Store(Node* base, Node* offset, Node* value) { return raw_assembler()->Store(MachineRepresentation::kTagged, base, offset, value, kFullWriteBarrier); } Node* CodeAssembler::StoreWithMapWriteBarrier(Node* base, Node* offset, Node* value) { return raw_assembler()->Store(MachineRepresentation::kTagged, base, offset, value, kMapWriteBarrier); } Node* CodeAssembler::StoreNoWriteBarrier(MachineRepresentation rep, Node* base, Node* value) { return raw_assembler()->Store(rep, base, value, kNoWriteBarrier); } Node* CodeAssembler::StoreNoWriteBarrier(MachineRepresentation rep, Node* base, Node* offset, Node* value) { return raw_assembler()->Store(rep, base, offset, value, kNoWriteBarrier); } Node* CodeAssembler::AtomicStore(MachineRepresentation rep, Node* base, Node* offset, Node* value) { return raw_assembler()->AtomicStore(rep, base, offset, value); } Node* CodeAssembler::StoreRoot(Heap::RootListIndex root_index, Node* value) { DCHECK(Heap::RootCanBeWrittenAfterInitialization(root_index)); Node* roots_array_start = ExternalConstant(ExternalReference::roots_array_start(isolate())); return StoreNoWriteBarrier(MachineRepresentation::kTagged, roots_array_start, IntPtrConstant(root_index * kPointerSize), value); } Node* CodeAssembler::Retain(Node* value) { return raw_assembler()->Retain(value); } Node* CodeAssembler::Projection(int index, Node* value) { return raw_assembler()->Projection(index, value); } void CodeAssembler::GotoIfException(Node* node, Label* if_exception, Variable* exception_var) { Label success(this), exception(this, Label::kDeferred); success.MergeVariables(); exception.MergeVariables(); DCHECK(!node->op()->HasProperty(Operator::kNoThrow)); raw_assembler()->Continuations(node, success.label_, exception.label_); Bind(&exception); const Operator* op = raw_assembler()->common()->IfException(); Node* exception_value = raw_assembler()->AddNode(op, node, node); if (exception_var != nullptr) { exception_var->Bind(exception_value); } Goto(if_exception); Bind(&success); } template <class... TArgs> Node* CodeAssembler::CallRuntime(Runtime::FunctionId function, Node* context, TArgs... args) { int argc = static_cast<int>(sizeof...(args)); CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( zone(), function, argc, Operator::kNoProperties, CallDescriptor::kNoFlags); int return_count = static_cast<int>(desc->ReturnCount()); Node* centry = HeapConstant(CodeFactory::RuntimeCEntry(isolate(), return_count)); Node* ref = ExternalConstant(ExternalReference(function, isolate())); Node* arity = Int32Constant(argc); Node* nodes[] = {centry, args..., ref, arity, context}; CallPrologue(); Node* return_value = raw_assembler()->CallN(desc, arraysize(nodes), nodes); CallEpilogue(); return return_value; } // Instantiate CallRuntime() with up to 5 arguments. #define INSTANTIATE(...) \ template V8_EXPORT_PRIVATE Node* CodeAssembler::CallRuntime( \ Runtime::FunctionId, __VA_ARGS__); REPEAT_1_TO_6(INSTANTIATE, Node*) #undef INSTANTIATE template <class... TArgs> Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function, Node* context, TArgs... args) { int argc = static_cast<int>(sizeof...(args)); CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( zone(), function, argc, Operator::kNoProperties, CallDescriptor::kSupportsTailCalls); int return_count = static_cast<int>(desc->ReturnCount()); Node* centry = HeapConstant(CodeFactory::RuntimeCEntry(isolate(), return_count)); Node* ref = ExternalConstant(ExternalReference(function, isolate())); Node* arity = Int32Constant(argc); Node* nodes[] = {centry, args..., ref, arity, context}; CallPrologue(); Node* return_value = raw_assembler()->TailCallN(desc, arraysize(nodes), nodes); CallEpilogue(); return return_value; } // Instantiate TailCallRuntime() with up to 6 arguments. #define INSTANTIATE(...) \ template V8_EXPORT_PRIVATE Node* CodeAssembler::TailCallRuntime( \ Runtime::FunctionId, __VA_ARGS__); REPEAT_1_TO_7(INSTANTIATE, Node*) #undef INSTANTIATE template <class... TArgs> Node* CodeAssembler::CallStubR(const CallInterfaceDescriptor& descriptor, size_t result_size, Node* target, Node* context, TArgs... args) { Node* nodes[] = {target, args..., context}; return CallStubN(descriptor, result_size, arraysize(nodes), nodes); } // Instantiate CallStubR() with up to 6 arguments. #define INSTANTIATE(...) \ template V8_EXPORT_PRIVATE Node* CodeAssembler::CallStubR( \ const CallInterfaceDescriptor& descriptor, size_t, Node*, __VA_ARGS__); REPEAT_1_TO_7(INSTANTIATE, Node*) #undef INSTANTIATE Node* CodeAssembler::CallStubN(const CallInterfaceDescriptor& descriptor, size_t result_size, int input_count, Node* const* inputs) { // 2 is for target and context. DCHECK_LE(2, input_count); int argc = input_count - 2; DCHECK_LE(descriptor.GetParameterCount(), argc); // Extra arguments not mentioned in the descriptor are passed on the stack. int stack_parameter_count = argc - descriptor.GetRegisterParameterCount(); DCHECK_LE(descriptor.GetStackParameterCount(), stack_parameter_count); CallDescriptor* desc = Linkage::GetStubCallDescriptor( isolate(), zone(), descriptor, stack_parameter_count, CallDescriptor::kNoFlags, Operator::kNoProperties, MachineType::AnyTagged(), result_size); CallPrologue(); Node* return_value = raw_assembler()->CallN(desc, input_count, inputs); CallEpilogue(); return return_value; } template <class... TArgs> Node* CodeAssembler::TailCallStub(const CallInterfaceDescriptor& descriptor, Node* target, Node* context, TArgs... args) { DCHECK_EQ(descriptor.GetParameterCount(), sizeof...(args)); size_t result_size = 1; CallDescriptor* desc = Linkage::GetStubCallDescriptor( isolate(), zone(), descriptor, descriptor.GetStackParameterCount(), CallDescriptor::kSupportsTailCalls, Operator::kNoProperties, MachineType::AnyTagged(), result_size); Node* nodes[] = {target, args..., context}; return raw_assembler()->TailCallN(desc, arraysize(nodes), nodes); } // Instantiate TailCallStub() with up to 6 arguments. #define INSTANTIATE(...) \ template V8_EXPORT_PRIVATE Node* CodeAssembler::TailCallStub( \ const CallInterfaceDescriptor& descriptor, Node*, __VA_ARGS__); REPEAT_1_TO_7(INSTANTIATE, Node*) #undef INSTANTIATE template <class... TArgs> Node* CodeAssembler::TailCallBytecodeDispatch( const CallInterfaceDescriptor& descriptor, Node* target, TArgs... args) { DCHECK_EQ(descriptor.GetParameterCount(), sizeof...(args)); CallDescriptor* desc = Linkage::GetBytecodeDispatchCallDescriptor( isolate(), zone(), descriptor, descriptor.GetStackParameterCount()); Node* nodes[] = {target, args...}; return raw_assembler()->TailCallN(desc, arraysize(nodes), nodes); } // Instantiate TailCallBytecodeDispatch() with 4 arguments. template V8_EXPORT_PRIVATE Node* CodeAssembler::TailCallBytecodeDispatch( const CallInterfaceDescriptor& descriptor, Node* target, Node*, Node*, Node*, Node*); Node* CodeAssembler::CallCFunction2(MachineType return_type, MachineType arg0_type, MachineType arg1_type, Node* function, Node* arg0, Node* arg1) { return raw_assembler()->CallCFunction2(return_type, arg0_type, arg1_type, function, arg0, arg1); } Node* CodeAssembler::CallCFunction3(MachineType return_type, MachineType arg0_type, MachineType arg1_type, MachineType arg2_type, Node* function, Node* arg0, Node* arg1, Node* arg2) { return raw_assembler()->CallCFunction3(return_type, arg0_type, arg1_type, arg2_type, function, arg0, arg1, arg2); } void CodeAssembler::Goto(Label* label) { label->MergeVariables(); raw_assembler()->Goto(label->label_); } void CodeAssembler::GotoIf(Node* condition, Label* true_label) { Label false_label(this); Branch(condition, true_label, &false_label); Bind(&false_label); } void CodeAssembler::GotoUnless(Node* condition, Label* false_label) { Label true_label(this); Branch(condition, &true_label, false_label); Bind(&true_label); } void CodeAssembler::Branch(Node* condition, Label* true_label, Label* false_label) { true_label->MergeVariables(); false_label->MergeVariables(); return raw_assembler()->Branch(condition, true_label->label_, false_label->label_); } void CodeAssembler::Switch(Node* index, Label* default_label, const int32_t* case_values, Label** case_labels, size_t case_count) { RawMachineLabel** labels = new (zone()->New(sizeof(RawMachineLabel*) * case_count)) RawMachineLabel*[case_count]; for (size_t i = 0; i < case_count; ++i) { labels[i] = case_labels[i]->label_; case_labels[i]->MergeVariables(); default_label->MergeVariables(); } return raw_assembler()->Switch(index, default_label->label_, case_values, labels, case_count); } // RawMachineAssembler delegate helpers: Isolate* CodeAssembler::isolate() const { return raw_assembler()->isolate(); } Factory* CodeAssembler::factory() const { return isolate()->factory(); } Zone* CodeAssembler::zone() const { return raw_assembler()->zone(); } RawMachineAssembler* CodeAssembler::raw_assembler() const { return state_->raw_assembler_.get(); } // The core implementation of Variable is stored through an indirection so // that it can outlive the often block-scoped Variable declarations. This is // needed to ensure that variable binding and merging through phis can // properly be verified. class CodeAssemblerVariable::Impl : public ZoneObject { public: explicit Impl(MachineRepresentation rep) : value_(nullptr), rep_(rep) {} Node* value_; MachineRepresentation rep_; }; CodeAssemblerVariable::CodeAssemblerVariable(CodeAssembler* assembler, MachineRepresentation rep) : impl_(new (assembler->zone()) Impl(rep)), state_(assembler->state()) { state_->variables_.insert(impl_); } CodeAssemblerVariable::~CodeAssemblerVariable() { state_->variables_.erase(impl_); } void CodeAssemblerVariable::Bind(Node* value) { impl_->value_ = value; } Node* CodeAssemblerVariable::value() const { DCHECK_NOT_NULL(impl_->value_); return impl_->value_; } MachineRepresentation CodeAssemblerVariable::rep() const { return impl_->rep_; } bool CodeAssemblerVariable::IsBound() const { return impl_->value_ != nullptr; } CodeAssemblerLabel::CodeAssemblerLabel(CodeAssembler* assembler, size_t vars_count, CodeAssemblerVariable** vars, CodeAssemblerLabel::Type type) : bound_(false), merge_count_(0), state_(assembler->state()), label_(nullptr) { void* buffer = assembler->zone()->New(sizeof(RawMachineLabel)); label_ = new (buffer) RawMachineLabel(type == kDeferred ? RawMachineLabel::kDeferred : RawMachineLabel::kNonDeferred); for (size_t i = 0; i < vars_count; ++i) { variable_phis_[vars[i]->impl_] = nullptr; } } void CodeAssemblerLabel::MergeVariables() { ++merge_count_; for (auto var : state_->variables_) { size_t count = 0; Node* node = var->value_; if (node != nullptr) { auto i = variable_merges_.find(var); if (i != variable_merges_.end()) { i->second.push_back(node); count = i->second.size(); } else { count = 1; variable_merges_[var] = std::vector<Node*>(1, node); } } // If the following asserts, then you've jumped to a label without a bound // variable along that path that expects to merge its value into a phi. DCHECK(variable_phis_.find(var) == variable_phis_.end() || count == merge_count_); USE(count); // If the label is already bound, we already know the set of variables to // merge and phi nodes have already been created. if (bound_) { auto phi = variable_phis_.find(var); if (phi != variable_phis_.end()) { DCHECK_NOT_NULL(phi->second); state_->raw_assembler_->AppendPhiInput(phi->second, node); } else { auto i = variable_merges_.find(var); if (i != variable_merges_.end()) { // If the following assert fires, then you've declared a variable that // has the same bound value along all paths up until the point you // bound this label, but then later merged a path with a new value for // the variable after the label bind (it's not possible to add phis to // the bound label after the fact, just make sure to list the variable // in the label's constructor's list of merged variables). DCHECK(find_if(i->second.begin(), i->second.end(), [node](Node* e) -> bool { return node != e; }) == i->second.end()); } } } } } void CodeAssemblerLabel::Bind() { DCHECK(!bound_); state_->raw_assembler_->Bind(label_); // Make sure that all variables that have changed along any path up to this // point are marked as merge variables. for (auto var : state_->variables_) { Node* shared_value = nullptr; auto i = variable_merges_.find(var); if (i != variable_merges_.end()) { for (auto value : i->second) { DCHECK(value != nullptr); if (value != shared_value) { if (shared_value == nullptr) { shared_value = value; } else { variable_phis_[var] = nullptr; } } } } } for (auto var : variable_phis_) { CodeAssemblerVariable::Impl* var_impl = var.first; auto i = variable_merges_.find(var_impl); // If the following asserts fire, then a variable that has been marked as // being merged at the label--either by explicitly marking it so in the // label constructor or by having seen different bound values at branches // into the label--doesn't have a bound value along all of the paths that // have been merged into the label up to this point. DCHECK(i != variable_merges_.end()); DCHECK_EQ(i->second.size(), merge_count_); Node* phi = state_->raw_assembler_->Phi( var.first->rep_, static_cast<int>(merge_count_), &(i->second[0])); variable_phis_[var_impl] = phi; } // Bind all variables to a merge phi, the common value along all paths or // null. for (auto var : state_->variables_) { auto i = variable_phis_.find(var); if (i != variable_phis_.end()) { var->value_ = i->second; } else { auto j = variable_merges_.find(var); if (j != variable_merges_.end() && j->second.size() == merge_count_) { var->value_ = j->second.back(); } else { var->value_ = nullptr; } } } bound_ = true; } } // namespace compiler } // namespace internal } // namespace v8
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
fa8a530bc615ae394c4c38b854fb555377173b7c
81c637923a054d1255e150c0488dca2936bee8a9
/dialog.h
bc07c3a0928299db2e9aa0e3e49bdf62a3652797
[]
no_license
IIaKyJIuH/Morse-Translator
d01ca86b3037c37795619a610a9976155e3f3eed
c70e3074282623362b8b5c9c2aa234236ca81cb1
refs/heads/master
2023-05-28T01:00:41.458335
2021-06-21T10:08:02
2021-06-21T10:08:02
378,883,720
0
0
null
null
null
null
UTF-8
C++
false
false
303
h
#ifndef DIALOG_H #define DIALOG_H #include <QDialog> namespace Ui { class Dialog; } class MTAboutDialog : public QDialog { Q_OBJECT public: explicit MTAboutDialog(QWidget *parent = nullptr); ~MTAboutDialog(); private: Ui::Dialog *ui; void setLabelText(); }; #endif // DIALOG_H
[ "pakylin3@mail.ru" ]
pakylin3@mail.ru
e56cbc13139707fee133dbd8262ad6353add5d43
a7261fb9bf2df817e6592d409b056f35fa84b10b
/src/opentrade/adapter.h
14c6b21c03c0b772b8f39bca3ceb234b249c5a33
[ "Apache-2.0" ]
permissive
yssource/opentrade
3a194d1cd46414a3b097ab3f801f5b1cd5bb2710
738cb330e9656e9a1eade48d6e0b9b601a62178b
refs/heads/master
2020-04-22T15:52:08.431348
2019-03-27T13:44:51
2019-03-27T13:44:51
170,490,117
0
0
Apache-2.0
2019-02-13T10:41:22
2019-02-13T10:41:22
null
UTF-8
C++
false
false
1,748
h
#ifndef OPENTRADE_ADAPTER_H_ #define OPENTRADE_ADAPTER_H_ #include <tbb/atomic.h> #include <memory> #include <string> #include <unordered_map> #include "utility.h" namespace opentrade { static const char* kApiVersion = #ifdef BACKTEST "backtest_" #endif "1"; class Adapter { public: virtual ~Adapter(); typedef std::unordered_map<std::string, std::string> StrMap; const std::string& name() const { return name_; } void set_name(const std::string& name) { name_ = name; } void set_config(const StrMap& config) { config_ = config; } std::string GetVersion() const { return kApiVersion; } typedef Adapter* (*CFunc)(); typedef std::function<Adapter*()> Func; Adapter* Clone() { auto inst = create_func_(); inst->set_name(name()); inst->set_config(config()); return inst; } const StrMap& config() const { return config_; } std::string config(const std::string& name) const { return FindInMap(config_, name); } static Adapter* Load(const std::string& sofile); virtual void Start() noexcept = 0; protected: std::string name_; StrMap config_; Func create_func_; }; class NetworkAdapter : public Adapter { public: virtual void Reconnect() noexcept {} virtual bool connected() const noexcept { return 1 == connected_; } protected: tbb::atomic<int> connected_ = 0; }; template <typename T> class AdapterManager { public: typedef std::unordered_map<std::string, T*> AdapterMap; void Add(T* adapter) { adapters_[adapter->name()] = adapter; } T* GetAdapter(const std::string& name) { return FindInMap(adapters_, name); } const AdapterMap& adapters() { return adapters_; } private: AdapterMap adapters_; }; } // namespace opentrade #endif // OPENTRADE_ADAPTER_H_
[ "info@opentradesolutions.com" ]
info@opentradesolutions.com
15d6d159d6d464d5ae08b2b26700d1dc8078df9d
bae98443e5b6c44422937930adbc7719e98173d5
/KommandoZeilenParameter.cpp
836dfbf50f2a5dcaf56ae815c1645a499b0e876b
[]
no_license
OSSGames/GAME-SPORTS-BillardGL
cca9c63f5b99839d928b4926cb36b9c370c07544
0626fc1691dce8bd5948584013fa7388b54cd4d4
refs/heads/master
2020-04-30T20:19:19.409090
2019-03-25T15:55:24
2019-03-25T15:55:24
177,062,762
0
0
null
null
null
null
UTF-8
C++
false
false
10,507
cpp
#include <GL/glut.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "Namen.h" #include "KommandoZeilenParameter.h" void SchreibeKonfiguration(){ FILE *f; #ifndef _WIN32 char dateiname[40]; sprintf(dateiname,"%s/.BillardGL.conf.v7",getenv("HOME")); f=fopen(dateiname,"w+"); #endif #ifdef _WIN32 f=fopen("BillardGL.conf.v7","wb+"); #endif if (f) { char Spieler1temp[10]; char Spieler2temp[10]; char NetzwerkSpielertemp[10]; for (int i=0;i<10;i++) { if (Spieler1[i]==' ') { Spieler1temp[i]='%'; } else { Spieler1temp[i]=Spieler1[i]; } if (Spieler2[i]==' ') { Spieler2temp[i]='%'; } else { Spieler2temp[i]=Spieler2[i]; } if (NetzwerkSpieler[i]==' ') { NetzwerkSpielertemp[i]='%'; } else { NetzwerkSpielertemp[i]=NetzwerkSpieler[i]; } } fprintf(f,"%i\n",Texturgroesse); fprintf(f,"%i\n",AnzeigeTexturgroesse); fprintf(f,"%i\n",TischTexturgroesse); fprintf(f,"%i\n",KugelAufloesung); fprintf(f,"%f\n",MouseSpeed); fprintf(f,"%i\n",InvertX); fprintf(f,"%i\n",InvertY); fprintf(f,"%i\n",BildschirmAufloesung); fprintf(f,"%i\n",Farbtiefe); fprintf(f,"%i\n",Reflektionen); fprintf(f,"%i\n",Schatten); fprintf(f,"%i\n",TexMMM); fprintf(f,"%i\n",Sprache); fprintf(f,"%i\n",ZeigeFPS); fprintf(f,"%i\n",AmbientesLicht); fprintf(f,"%i\n",TischLampen); fprintf(f,"%i\n",GrueneLampe); fprintf(f,"%f\n",EffektLautstaerke); fprintf(f,"%f\n",MusikLautstaerke); fprintf(f,"%s\n",Spieler1temp); fprintf(f,"%s\n",Spieler2temp); fprintf(f,"%s\n",NetzwerkSpielertemp); fclose(f); } } void LeseKonfiguration(){ FILE *f; #ifndef _WIN32 char dateiname[40]; sprintf(dateiname,"%s/.BillardGL.conf.v7",getenv("HOME")); f=fopen(dateiname,"r"); #endif #ifdef _WIN32 f=fopen("BillardGL.conf.v7","rb"); #endif if (f) { char Spieler1temp[10]; char Spieler2temp[10]; char NetzwerkSpielertemp[10]; fscanf(f,"%i",&Texturgroesse); fscanf(f,"%i",&AnzeigeTexturgroesse); fscanf(f,"%i",&TischTexturgroesse); fscanf(f,"%i",&KugelAufloesung); fscanf(f,"%f",&MouseSpeed); fscanf(f,"%i",&InvertX); fscanf(f,"%i",&InvertY); fscanf(f,"%i",&BildschirmAufloesung); fscanf(f,"%i",&Farbtiefe); fscanf(f,"%i",&Reflektionen); fscanf(f,"%i",&Schatten); fscanf(f,"%i",&TexMMM); fscanf(f,"%i",&Sprache); fscanf(f,"%i",&ZeigeFPS); fscanf(f,"%i",&AmbientesLicht); fscanf(f,"%i",&TischLampen); fscanf(f,"%i",&GrueneLampe); fscanf(f,"%f",&EffektLautstaerke); fscanf(f,"%f",&MusikLautstaerke); fscanf(f,"%s",Spieler1temp); fscanf(f,"%s",Spieler2temp); fscanf(f,"%s",NetzwerkSpielertemp); for (int i=0;i<10;i++) { if (Spieler1temp[i]=='%') { Spieler1[i]=' '; } else { Spieler1[i]=Spieler1temp[i]; } if (Spieler2temp[i]=='%') { Spieler2[i]=' '; } else { Spieler2[i]=Spieler2temp[i]; } if (NetzwerkSpieler[i]=='%') { NetzwerkSpieler[i]=' '; } else { NetzwerkSpieler[i]=NetzwerkSpielertemp[i]; } } } } void KommandoZeilenParameter(int argc,char **argv) { // Titeltext //#ifndef _WIN32 printf("\n BillardGL (C) 2001, 2002 Tobias Nopper, Stefan Disch, Martina Welte\n\n"); //#endif //Defaultwerte Texturgroesse = 2; AnzeigeTexturgroesse = 1; TischTexturgroesse = 2; KugelAufloesung = 7; InvertX = 0; InvertY = 0; Spiel = ACHTBALL; Schatten = 1; TexMMM = 3; Epsilon = 0.05; MouseSpeed = 0.4; PhysikFrequenz = 400; ReibungsFaktor = 1.2; BandenFaktor = 0.4; KollisionsFaktor = 0.95; ZBufferLoeschen = 1; BildschirmAufloesung = 800; Farbtiefe = 16; Reflektionen = 0; Sprache = 0; ZeigeFPS = 0; AmbientesLicht = 1; TischLampen = 2; GrueneLampe = 0; FullScreen = 1; EffektLautstaerke = .5; MusikLautstaerke = .5; sprintf(Spieler1,"Name 1"); sprintf(Spieler2,"Name 2"); sprintf(NetzwerkSpieler,"Name"); LeseKonfiguration(); // Einlesen der Kommandozeilenparameter int i=1; while (i<argc) { if (!strcmp(argv[i],"-y")||!strcmp(argv[i],"-inverty")) { InvertY = 1; } else if (!strcmp(argv[i],"-x")||!strcmp(argv[i],"-invertx")) { InvertX = 1; } else if (!strcmp(argv[i],"-z")||!strcmp(argv[i],"-zbuffer")) { ZBufferLoeschen = 0; } else if (!strcmp(argv[i],"-f")||!strcmp(argv[i],"-fullscreen")) { FullScreen = 1; } else if (!strcmp(argv[i],"-w")||!strcmp(argv[i],"-windowed")) { FullScreen = 0; } else if (!strcmp(argv[i],"-hq")||!strcmp(argv[i],"-highquality")) { Texturgroesse=2; AnzeigeTexturgroesse = 2; TischTexturgroesse = 1; KugelAufloesung = 9; BildschirmAufloesung = 1024; Farbtiefe = 32; Reflektionen = 1; } else if (!strcmp(argv[i],"-t")||!strcmp(argv[i],"-texturen")) { i++; if (!strcmp(argv[i],"1")||!strcmp(argv[i],"voll")) { Texturgroesse=1; } else if (!strcmp(argv[i],"2")||!strcmp(argv[i],"halb")) { Texturgroesse=2; } else if (!strcmp(argv[i],"4")||!strcmp(argv[i],"viertel")) { Texturgroesse=4; } else if (!strcmp(argv[i],"8")||!strcmp(argv[i],"achtel")) { Texturgroesse=8; } else if (!strcmp(argv[i],"0")||!strcmp(argv[i],"aus")) { Texturgroesse=0; } } else if (!strcmp(argv[i],"-at")||!strcmp(argv[i],"-atexturen")) { i++; if (!strcmp(argv[i],"1")||!strcmp(argv[i],"voll")) { AnzeigeTexturgroesse=1; } else if (!strcmp(argv[i],"2")||!strcmp(argv[i],"halb")) { AnzeigeTexturgroesse=2; } else if (!strcmp(argv[i],"4")||!strcmp(argv[i],"viertel")) { AnzeigeTexturgroesse=4; } else if (!strcmp(argv[i],"8")||!strcmp(argv[i],"achtel")) { AnzeigeTexturgroesse=8; } else if (!strcmp(argv[i],"0")||!strcmp(argv[i],"aus")) { AnzeigeTexturgroesse=0; } } else if (!strcmp(argv[i],"-tt")||!strcmp(argv[i],"-ttexturen")) { i++; if (!strcmp(argv[i],"1")||!strcmp(argv[i],"voll")) { TischTexturgroesse=1; } else if (!strcmp(argv[i],"2")||!strcmp(argv[i],"halb")) { TischTexturgroesse=2; } else if (!strcmp(argv[i],"4")||!strcmp(argv[i],"viertel")) { TischTexturgroesse=4; } else if (!strcmp(argv[i],"8")||!strcmp(argv[i],"achtel")) { TischTexturgroesse=8; } else if (!strcmp(argv[i],"0")||!strcmp(argv[i],"aus")) { TischTexturgroesse=0; } } else if (!strcmp(argv[i],"-a")||!strcmp(argv[i],"-aufstellung")) { i++; if (!strcmp(argv[i],"2")||!strcmp(argv[i],"s")||!strcmp(argv[i],"simpel")||!strcmp(argv[i],"zweibaelle")) { Spiel=ZWEIBAELLE; } else if (!strcmp(argv[i],"8")||!strcmp(argv[i],"a")||!strcmp(argv[i],"achtball")||!strcmp(argv[i],"8ball")||!strcmp(argv[i],"8-ball")) { Spiel=ACHTBALL; } else if (!strcmp(argv[i],"9")||!strcmp(argv[i],"n")||!strcmp(argv[i],"neunball")||!strcmp(argv[i],"9ball")||!strcmp(argv[i],"9-ball")) { Spiel=NEUNBALL; } else if (!strcmp(argv[i],"0")||!strcmp(argv[i],"l")||!strcmp(argv[i],"leer")) { Spiel=LEER; } else if (!strcmp(argv[i],"z")||!strcmp(argv[i],"zufall")) { Spiel=ZUFALL; } } else if (!strcmp(argv[i],"-s")||!strcmp(argv[i],"-schatten")) { Schatten=0; } else if (!strcmp(argv[i],"-g")||!strcmp(argv[i],"-geometrie")) { i++; KugelAufloesung=atoi(argv[i]); } else if (!strcmp(argv[i],"-ep")||!strcmp(argv[i],"-epsilon")) { i++; Epsilon=atof(argv[i]); } else if (!strcmp(argv[i],"-m")||!strcmp(argv[i],"-mousespeed")) { i++; MouseSpeed=atof(argv[i]); } else if (!strcmp(argv[i],"-p")||!strcmp(argv[i],"-physik")) { i++; PhysikFrequenz=atoi(argv[i]); } else if (!strcmp(argv[i],"-r")||!strcmp(argv[i],"-reibung")) { i++; ReibungsFaktor=atof(argv[i]); } else if (!strcmp(argv[i],"-k")||!strcmp(argv[i],"-kollision")) { i++; KollisionsFaktor=atof(argv[i]); } else if (!strcmp(argv[i],"-b")||!strcmp(argv[i],"-banden")) { i++; BandenFaktor=atof(argv[i]); } i++; } SchreibeKonfiguration(); //#ifndef _WIN32 //Ausgabe der Parameter /* printf(" Ball textures : "); switch (Texturgroesse) { case 1: printf("High");break; case 2: printf("Normal");break; case 4: printf("Low");break; case 8: printf("Very low");break; case 0: printf("Off");break; } printf("\n Menu textures : "); switch (AnzeigeTexturgroesse) { case 1: printf("Normal");break; case 2: printf("Low");break; case 4: printf("Groesse 4 - Viertel");break; case 8: printf("Groesse 8 - Achtel");break; case 0: printf("Aus");break; } printf("\n Table texture : "); switch (TischTexturgroesse) { case 1: printf("High");break; case 2: printf("Normal");break; case 4: printf("Low");break; case 8: printf("Very Low");break; case 0: printf("Off");break; } printf("\n"); if (ZBufferLoeschen) { printf(" ZBufferLoesch.: Ein\n"); } else { printf(" ZBufferLoesch.: Aus\n"); AnzeigeTexturgroesse=0; Schatten=0; } printf(" Ball Res. : %i\n",KugelAufloesung); printf(" Shadows : "); switch (Schatten) { case 1: printf("On");break; case 0: printf("Off");break; } // printf(" Epsilon : %f\n",Epsilon); printf("\n Mousespeed : %f\n",MouseSpeed); if (InvertX) { printf(" InvertX : On\n"); } else { printf(" InvertX : Off\n"); } if (InvertY) { printf(" InvertY : On\n"); } else { printf(" InvertY : Off\n"); } printf(" Spiel : "); switch (Spiel) { case ZWEIBAELLE: printf("Zwei Kugeln");break; case ACHTBALL: printf("8-Ball");break; case NEUNBALL: printf("9-Ball");break; case ZUFALL: printf("Zufall");break; case LEER: printf("Aus");break; } //printf("\n Physikfrequenz: %i\n",PhysikFrequenz); //printf(" Reibungsfaktor: %f\n",ReibungsFaktor); //printf(" Bandenfaktor : %f\n",BandenFaktor); //printf(" Koll.faktor : %f\n",KollisionsFaktor); //printf(" Bildschirmaufl: %i\n",BildschirmAufloesung); printf("\n"); //#endif */ }
[ "martiniturbide@gmail.com" ]
martiniturbide@gmail.com
15423a2065c87cf94e370c20859b1ad4df490523
8ec5482489a05f29172dae9b95b70b03d386af03
/sources/utils/converter/opcode/OPC_AABBCollider.h
8e2b3e4116b4102e22f6293595d2a88008d9bdaf
[]
no_license
abramcumner/xray_re-tools
ed4d364a3d3aeda31cfebeb5df03a3d724f1f531
2222ad023c0656cbbdbe7e93d59f7bed29387e5d
refs/heads/master
2023-05-27T01:30:07.434712
2023-05-20T11:56:05
2023-05-20T11:57:23
65,939,733
31
17
null
2023-05-21T13:07:14
2016-08-17T20:30:04
C++
UTF-8
C++
false
false
4,536
h
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* * OPCODE - Optimized Collision Detection * Copyright (C) 2001 Pierre Terdiman * Homepage: http://www.codercorner.com/Opcode.htm */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Contains code for an AABB collider. * \file OPC_AABBCollider.h * \author Pierre Terdiman * \date January, 1st, 2002 */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Include Guard #ifndef __OPC_AABBCOLLIDER_H__ #define __OPC_AABBCOLLIDER_H__ struct OPCODE_API AABBCache : VolumeCache { AABBCache() : FatCoeff(1.1f) { FatBox.mCenter.Zero(); FatBox.mExtents.Zero(); } // Cached faces signature CollisionAABB FatBox; //!< Box used when performing the query resulting in cached faces // User settings float FatCoeff; //!< mRadius2 multiplier used to create a fat sphere }; class OPCODE_API AABBCollider : public VolumeCollider { public: // Constructor / Destructor AABBCollider(); virtual ~AABBCollider(); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Generic collision query for generic OPCODE models. After the call, access the results: * - with GetContactStatus() * - with GetNbTouchedPrimitives() * - with GetTouchedPrimitives() * * \param cache [in/out] a box cache * \param box [in] collision AABB in world space * \param model [in] Opcode model to collide with * \return true if success * \warning SCALE NOT SUPPORTED. The matrices must contain rotation & translation parts only. */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Collide(AABBCache& cache, const CollisionAABB& box, const Model& model); // bool Collide(AABBCache& cache, const CollisionAABB& box, const AABBTree* tree); protected: CollisionAABB mBox; //!< Query box in (center, extents) form Point mMin; //!< Query box min point Point mMax; //!< Query box max point // Leaf description Point mLeafVerts[3]; //!< Triangle vertices // Internal methods void _Collide(const AABBCollisionNode* node); void _Collide(const AABBNoLeafNode* node); void _Collide(const AABBQuantizedNode* node); void _Collide(const AABBQuantizedNoLeafNode* node); void _Collide(const AABBTreeNode* node); void _CollideNoPrimitiveTest(const AABBCollisionNode* node); void _CollideNoPrimitiveTest(const AABBNoLeafNode* node); void _CollideNoPrimitiveTest(const AABBQuantizedNode* node); void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node); // Overlap tests inline_ BOOL AABBContainsBox(const Point& bc, const Point& be); inline_ BOOL AABBAABBOverlap(const Point& b, const Point& Pb); inline_ BOOL TriBoxOverlap(); // Init methods BOOL InitQuery(AABBCache& cache, const CollisionAABB& box); }; class OPCODE_API HybridAABBCollider : public AABBCollider { public: // Constructor / Destructor HybridAABBCollider(); virtual ~HybridAABBCollider(); bool Collide(AABBCache& cache, const CollisionAABB& box, const HybridModel& model); protected: Container mTouchedBoxes; }; #endif // __OPC_AABBCOLLIDER_H__
[ "SND\\abramcumner_cp" ]
SND\abramcumner_cp
a2400f5926e9527f17562bd8122b7163fde3dd2d
034c3ed44f6dced89da705351497564242ebd51b
/PinEngine/PinEngine/Utility/BuildPath.cpp
f9791d4c97d64258e144eebbd52c4e2dc340944c
[]
no_license
magnetsrev/PinEngine
42038dc76552c7410b6d666a2f429d617f028b93
bc59a9a7257735452ca0b74400ccacf57a9643dc
refs/heads/master
2021-05-19T12:28:23.806498
2019-12-28T23:49:08
2019-12-28T23:49:08
251,698,360
1
0
null
2020-03-31T18:39:23
2020-03-31T18:39:22
null
UTF-8
C++
false
false
364
cpp
#include "BuildPath.h" namespace PinEngine { std::wstring BuildPath() { #ifdef _DEBUG //Debug Mode #ifdef _WIN64 //x64 return L"..\\x64\\Debug\\"; #else //x86 (Win32) return L"..\\Debug\\"; #endif #else //Release Mode #ifdef _WIN64 //x64 return L"..\\x64\\Release\\"; #else //x86 (Win32) return L"..\\Release\\"; #endif #endif } }
[ "pindrought@gmail.com" ]
pindrought@gmail.com
10158bf64fab94819cc4d865dd01df4ada394e67
ce056f70c1b52f221feda19cda470de45c9e0d48
/device/bluetooth/test/fake_remote_gatt_characteristic.h
d6776e9c1f700d4454ca595ec4c8da068a6b6805
[ "BSD-3-Clause" ]
permissive
Nagist91/chromium
454b4a480cefa88ac1bdcb66092653ffae5b1f49
b6da71c648bf7961a73fe6fc5e2bfca7d1eeee2b
refs/heads/master
2023-01-02T03:28:50.786182
2020-05-19T11:59:13
2020-05-19T11:59:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,042
h
// Copyright 2017 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 DEVICE_BLUETOOTH_TEST_FAKE_REMOTE_GATT_CHARACTERISTIC_H_ #define DEVICE_BLUETOOTH_TEST_FAKE_REMOTE_GATT_CHARACTERISTIC_H_ #include <map> #include <memory> #include <string> #include <vector> #include "base/memory/weak_ptr.h" #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" #include "device/bluetooth/public/cpp/bluetooth_uuid.h" #include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom-forward.h" #include "device/bluetooth/test/fake_read_response.h" #include "device/bluetooth/test/fake_remote_gatt_descriptor.h" namespace device { class BluetoothRemoteGattService; class BluetoothRemoteGattDescriptor; } // namespace device namespace bluetooth { // Implements device::BluetoothRemoteGattCharacteristics. Meant to be used // by FakeRemoteGattService to keep track of the characteristic's state and // attributes. // // Not intended for direct use by clients. See README.md. class FakeRemoteGattCharacteristic : public device::BluetoothRemoteGattCharacteristic { public: FakeRemoteGattCharacteristic(const std::string& characteristic_id, const device::BluetoothUUID& characteristic_uuid, mojom::CharacteristicPropertiesPtr properties, device::BluetoothRemoteGattService* service); ~FakeRemoteGattCharacteristic() override; // Adds a fake descriptor with |descriptor_uuid| to this characteristic. // Returns the descriptor's Id. std::string AddFakeDescriptor(const device::BluetoothUUID& descriptor_uuid); // Removes a fake descriptor with |identifier| from this characteristic. bool RemoveFakeDescriptor(const std::string& identifier); // If |gatt_code| is mojom::kGATTSuccess the next read request will call // its success callback with |value|. Otherwise it will call its error // callback. void SetNextReadResponse(uint16_t gatt_code, const base::Optional<std::vector<uint8_t>>& value); // If |gatt_code| is mojom::kGATTSuccess the next write with response request // will call its success callback. Otherwise it will call its error callback. void SetNextWriteResponse(uint16_t gatt_code); // If |gatt_code| is mojom::kGATTSuccess the next subscribe to notifications // with response request will call its success callback. Otherwise it will // call its error callback. void SetNextSubscribeToNotificationsResponse(uint16_t gatt_code); // If |gatt_code| is mojom::kGATTSuccess the next unsubscribe to notifications // with response request will call its success callback. Otherwise it will // call its error callback. void SetNextUnsubscribeFromNotificationsResponse(uint16_t gatt_code); // Returns true if there are no pending responses for this characteristc or // any of its descriptors. bool AllResponsesConsumed(); // Returns the last sucessfully written value to the characteristic. Returns // nullopt if no value has been written yet. const base::Optional<std::vector<uint8_t>>& last_written_value() { return last_written_value_; } // device::BluetoothGattCharacteristic overrides: std::string GetIdentifier() const override; device::BluetoothUUID GetUUID() const override; Properties GetProperties() const override; Permissions GetPermissions() const override; // device::BluetoothRemoteGattCharacteristic overrides: const std::vector<uint8_t>& GetValue() const override; device::BluetoothRemoteGattService* GetService() const override; void ReadRemoteCharacteristic(ValueCallback callback, ErrorCallback error_callback) override; void WriteRemoteCharacteristic(const std::vector<uint8_t>& value, WriteType write_type, base::OnceClosure callback, ErrorCallback error_callback) override; void DeprecatedWriteRemoteCharacteristic( const std::vector<uint8_t>& value, base::OnceClosure callback, ErrorCallback error_callback) override; #if defined(OS_CHROMEOS) void PrepareWriteRemoteCharacteristic(const std::vector<uint8_t>& value, base::OnceClosure callback, ErrorCallback error_callback) override; #endif bool WriteWithoutResponse(base::span<const uint8_t> value) override; protected: #if defined(OS_CHROMEOS) // device::BluetoothRemoteGattCharacteristic overrides: void SubscribeToNotifications( device::BluetoothRemoteGattDescriptor* ccc_descriptor, NotificationType notification_type, base::OnceClosure callback, ErrorCallback error_callback) override; #else // device::BluetoothRemoteGattCharacteristic overrides: void SubscribeToNotifications( device::BluetoothRemoteGattDescriptor* ccc_descriptor, base::OnceClosure callback, ErrorCallback error_callback) override; #endif void UnsubscribeFromNotifications( device::BluetoothRemoteGattDescriptor* ccc_descriptor, base::OnceClosure callback, ErrorCallback error_callback) override; private: void DispatchReadResponse(ValueCallback callback, ErrorCallback error_callback); void DispatchWriteResponse(base::OnceClosure callback, ErrorCallback error_callback, const std::vector<uint8_t>& value); void DispatchSubscribeToNotificationsResponse(base::OnceClosure callback, ErrorCallback error_callback); void DispatchUnsubscribeFromNotificationsResponse( base::OnceClosure callback, ErrorCallback error_callback); const std::string characteristic_id_; const device::BluetoothUUID characteristic_uuid_; Properties properties_; device::BluetoothRemoteGattService* service_; std::vector<uint8_t> value_; // Last successfully written value to the characteristic. base::Optional<std::vector<uint8_t>> last_written_value_; // Used to decide which callback should be called when // ReadRemoteCharacteristic is called. base::Optional<FakeReadResponse> next_read_response_; // Used to decide which callback should be called when // WriteRemoteCharacteristic is called. base::Optional<uint16_t> next_write_response_; // Used to decide which callback should be called when // SubscribeToNotifications is called. base::Optional<uint16_t> next_subscribe_to_notifications_response_; // Used to decide which callback should be called when // UnsubscribeFromNotifications is called. base::Optional<uint16_t> next_unsubscribe_from_notifications_response_; size_t last_descriptor_id_; base::WeakPtrFactory<FakeRemoteGattCharacteristic> weak_ptr_factory_{this}; }; } // namespace bluetooth #endif // DEVICE_BLUETOOTH_TEST_FAKE_REMOTE_GATT_CHARACTERISTIC_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
a908018c50c4c30d1de5a8bed7ec6e5f2f6804d1
6aa1adec9d0bbf9a62aab0dbd1c03740e8004665
/src/CApp.cpp
65a91af0f552ca9760e606d3737066ab4d465f5b
[]
no_license
samowitsch/sdl-project-template-makefile
1b757e3819aee56983afbc76d5419ba25d7e5bab
96b98714faeb6dc098e074d7e80f2cafcb8641d4
refs/heads/master
2021-05-04T06:20:17.867807
2020-03-29T20:10:01
2020-03-29T20:10:01
71,060,848
2
0
null
null
null
null
UTF-8
C++
false
false
10,004
cpp
// ============================================================================ // [Include Section] // ============================================================================ #include "Common/CGGlobals.h" #include "CApp.h" #include "CppCangaja/CGSprite.h" // ============================================================================ // [Defines & Constants] // ============================================================================ #define APPTITLE "SDL2 Template Program" const int SCREEN_WIDTH = 800; const int SCREEN_HEIGHT = 600; // image SDL_Texture *bitmapTex = NULL; SDL_Surface *bitmapSurface = NULL; // sound Mix_Music *music = NULL; // ttf font SDL_Color fontColor = {0, 0, 255, 255}; SDL_Rect fontRect = {20, 20, 400, 100}; SDL_Texture *fontImage; // mouse position int pointerX = 50; int pointerY = 50; CGSprite sprite = CGSprite(50, 50); CApp::CApp() : running(false) { } CApp::~CApp() { OnCleanup(); } int CApp::OnInit() { b2Vec2 vec; vec.IsValid(); b2World world = b2World(vec); world.GetGravity(); world.Dump(); SDL_Log("b2world gravity: %f, %f\n", world.GetGravity().x, world.GetGravity().y); // Initialize the SDL library. if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { SDL_Log("SDL_Init() failed: %s\n", SDL_GetError()); return APP_FAILED; } SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight"); //Initialize SDL_mixer if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { SDL_Log("SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError()); } //Initialize PNG loading int imgFlags = IMG_INIT_PNG | IMG_INIT_JPG; if (!(IMG_Init(imgFlags) & imgFlags)) { SDL_Log("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError()); } basePath = SDL_GetBasePath(); SDL_Log("basePath: %s\n", basePath); // create the window window = SDL_CreateWindow(APPTITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL); if (window != NULL) { // create renderer renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255); // image loading example //bitmapSurface = SDL_LoadBMP("Pics/example.bmp"); // load bmp over SDL bitmapSurface = IMG_Load("Pics/example.png"); // load png over SDL_image bitmapTex = SDL_CreateTextureFromSurface(renderer, bitmapSurface); SDL_FreeSurface(bitmapSurface); sprite.loadTexture("Pics/mario.png"); // music loading example music = Mix_LoadMUS("Sfx/beat.wav"); Mix_PlayMusic(music, -1); } /* start SDL_ttf */ if (TTF_Init() == -1) { SDL_Log("TTF_Init: %s\n", TTF_GetError()); } fontImage = RenderText("TTF fonts are cool!", "Fonts/FreeSerifBold.ttf", fontColor, 32, renderer); // Success return APP_OK; } void CApp::OnCleanup() { if (renderer != NULL) { SDL_DestroyRenderer(renderer); } if (window != NULL) { Mix_FreeMusic(music); music = NULL; SDL_DestroyWindow(window); } SDL_free(basePath); IMG_Quit(); Mix_Quit(); TTF_Quit(); SDL_Quit(); } int CApp::OnExecute() { SDL_Log("Before preprocessor OnExecute => __IPHONEOS__ => HandleAppEvents?"); #if __IPHONEOS__ SDL_Log("OnExecute => __IPHONEOS__ => HandleAppEvents?"); //iOS test //SDL_SetEventFilter(HandleAppEvents, NULL); #endif // Initialize application. int state = OnInit(); if (state != APP_OK) { return state; } // Enter the SDL event loop. SDL_Event event; running = true; while (running) { while (SDL_PollEvent(&event)) { OnEvent(&event); } OnUpdate(); OnRender(); } return state; } void CApp::OnEvent(SDL_Event *event) { switch (event->type) { case SDL_MOUSEMOTION: //sprite.position->x = event->motion.x; //sprite.position->y = event->motion.y; break; case SDL_QUIT: running = false; break; case SDL_KEYDOWN: if (event->key.keysym.sym == SDLK_ESCAPE) { running = false; } if (event->key.keysym.sym == SDLK_LEFT) { sprite.position->x -= 10; } if (event->key.keysym.sym == SDLK_RIGHT) { sprite.position->x += 10; } if (event->key.keysym.sym == SDLK_UP) { sprite.position->y -= 10; } if (event->key.keysym.sym == SDLK_DOWN) { sprite.position->y += 10; } default: break; } } void CApp::OnUpdate() { // Update your game logic here sprite.Update(); } void CApp::OnRender() { SDL_RenderClear(renderer); // Do your drawing here SDL_RenderCopy(renderer, bitmapTex, NULL, NULL); sprite.Draw(); RenderTexture(fontImage, renderer, 100, 200); SDL_RenderPresent(renderer); } /** * Render the message we want to display to a texture for drawing * @param message The message we want to display * @param fontFile The font we want to use to render the text * @param color The color we want the text to be * @param fontSize The size we want the font to be * @param renderer The renderer to load the texture in * @return An SDL_Texture containing the rendered message, or nullptr if something went wrong */ SDL_Texture *CApp::RenderText(const std::string &message, const std::string &fontFile, SDL_Color &color, int fontSize, SDL_Renderer *renderer) { //Open the font TTF_Font *font = TTF_OpenFont(fontFile.c_str(), fontSize); if (font == nullptr) { return nullptr; } //We need to first render to a surface as that's what TTF_RenderText //returns, then load that surface into a texture SDL_Surface *surf = TTF_RenderText_Blended(font, message.c_str(), color); if (surf == nullptr) { TTF_CloseFont(font); return nullptr; } SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, surf); if (texture == nullptr) { } //Clean up the surface and font SDL_FreeSurface(surf); TTF_CloseFont(font); return texture; } /** * Draw an SDL_Texture to an SDL_Renderer at some destination rect * taking a clip of the texture if desired * @param tex The source texture we want to draw * @param ren The renderer we want to draw to * @param dst The destination rectangle to render the texture to * @param clip The sub-section of the texture to draw (clipping rect) * default of nullptr draws the entire texture */ void CApp::RenderTexture(SDL_Texture *tex, SDL_Renderer *ren, SDL_Rect dst, SDL_Rect *clip) { SDL_RenderCopy(ren, tex, clip, &dst); } /** * Draw an SDL_Texture to an SDL_Renderer at position x, y, preserving * the texture's width and height and taking a clip of the texture if desired * If a clip is passed, the clip's width and height will be used instead of * the texture's * @param tex The source texture we want to draw * @param ren The renderer we want to draw to * @param x The x coordinate to draw to * @param y The y coordinate to draw to * @param clip The sub-section of the texture to draw (clipping rect) * default of nullptr draws the entire texture */ void CApp::RenderTexture(SDL_Texture *tex, SDL_Renderer *ren, int x, int y, SDL_Rect *clip) { SDL_Rect dst; dst.x = x; dst.y = y; if (clip != nullptr) { dst.w = clip->w; dst.h = clip->h; } else { SDL_QueryTexture(tex, NULL, NULL, &dst.w, &dst.h); } RenderTexture(tex, ren, dst, clip); } /** * * @param userdata * @param event * @return */ int CApp::HandleAppEvents(void *userdata, SDL_Event *event) { switch (event->type) { case SDL_APP_TERMINATING: /* Terminate the app. Shut everything down before returning from this function. */ SDL_Log("SDL_APP_TERMINATING"); return 0; case SDL_APP_LOWMEMORY: /* You will get this when your app is paused and iOS wants more memory. Release as much memory as possible. */ SDL_Log("SDL_APP_LOWMEMORY"); return 0; case SDL_APP_WILLENTERBACKGROUND: /* Prepare your app to go into the background. Stop loops, etc. This gets called when the user hits the home button, or gets a call. */ SDL_Log("SDL_APP_WILLENTERBACKGROUND"); return 0; case SDL_APP_DIDENTERBACKGROUND: /* This will get called if the user accepted whatever sent your app to the background. If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops. When you get this, you have 5 seconds to save all your state or the app will be terminated. Your app is NOT active at this point. */ SDL_Log("SDL_APP_DIDENTERBACKGROUND"); return 0; case SDL_APP_WILLENTERFOREGROUND: /* This call happens when your app is coming back to the foreground. Restore all your state here. */ SDL_Log("SDL_APP_WILLENTERFOREGROUND"); return 0; case SDL_APP_DIDENTERFOREGROUND: /* Restart your loops here. Your app is interactive and getting CPU again. */ SDL_Log("SDL_APP_DIDENTERFOREGROUND"); return 0; default: /* No special processing, add it to the event queue */ return 1; } }
[ "info@motions-media.de" ]
info@motions-media.de
15267c551b3b2875864f221bfd0961853e6098df
772b7ad6e8b7d1bd31ef986b90efd86bd2ef56f2
/source/main.cpp
62cdcc0e81e51c7161c403d0895c81c988a788e6
[ "MIT" ]
permissive
TricksterGuy/switch-template
9e931920c970471a90c3be1df7d978a9d5bf5eaa
01e46e3203f820be42a4434a0a5e01b759164d8d
refs/heads/master
2022-09-01T11:14:15.500971
2020-05-31T03:09:06
2020-05-31T03:09:06
266,689,349
3
0
null
null
null
null
UTF-8
C++
false
false
1,090
cpp
#include <string.h> #include <stdio.h> #include <switch.h> int main(int argc, char **argv) { // Initialize console. Using NULL as the second argument tells the console library to use the internal console structure as current one. consoleInit(NULL); // Switch console is 80x44 // To move the cursor you have to print "\x1b[r;cH", where r and c are respectively // the row and column where you want your cursor to move // These strings are drawn at the center of the screen. printf("\x1b[21;27HTest Code::Blocks project!\n"); printf("\x1b[22;30HPress Start to exit."); while(appletMainLoop()) { // Scan all the inputs. This should be done once for each frame hidScanInput(); // hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame) u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); if (kDown & KEY_PLUS) break; // break in order to return to hbmenu // Updates the screen. consoleUpdate(NULL); } consoleExit(NULL); return 0; }
[ "tricksterguy87@gmail.com" ]
tricksterguy87@gmail.com
a8d549ee4b9261c0b09d5a707f0218596fc54a74
62886cb2c0658d4b3a9609709c5f7de4156e17bc
/old/19S/CS112/LABS/lab01/PlayListTester.cpp
65b3fa863773c962980cb640e80bf3613709f545
[]
no_license
Jacob-Brink/Notes
a3f69e5342b64ede7ccda7b070056a80dc2e1652
9e33b0d9d4a6b20880dc9f87c09ce3817c842b53
refs/heads/master
2022-12-10T10:21:45.527189
2020-09-10T04:49:41
2020-09-10T04:49:41
294,305,478
0
0
null
null
null
null
UTF-8
C++
false
false
3,515
cpp
/* PlayListTester.cpp defines the PlayList test-methods. * Student Name: jpb34 * Date: Feb 5, 2019 * Lab: 01 * Begun by: Joel Adams, for CS 112 at Calvin College. */ #include "PlayListTester.h" #include "PlayList.h" #include <cassert> #include <iostream> using namespace std; void PlayListTester::runTests() { cout << "\nTesting class PlayList..." << endl; testConstructors(); testSearchByArtist(); testSearchByYear(); testSearchByTitlePhrase(); testAddRemoveSong(); testSave(); cout << "All tests passed!" << endl; } void PlayListTester::testConstructors() { cout << "- constructors..." << flush; PlayList pList("testSongs.txt"); assert( pList.getNumSongs() == 4 ); cout << " 0 " << flush; cout << " Passed! " << endl; } void PlayListTester::testSearchByArtist() { cout << "- searchByArtist()... " << flush; // load a playlist with test songs PlayList pList("testSongs.txt"); // empty case (0) vector<Song> searchResult = pList.searchByArtist("Cream"); assert( searchResult.size() == 0 ); cout << " 0 " << flush; // case of 1 searchResult = pList.searchByArtist("Baez"); assert( searchResult.size() == 1 ); assert( searchResult[0].getTitle() == "Let It Be" ); cout << " 1 " << flush; // case of 2 searchResult = pList.searchByArtist("Beatles"); assert( searchResult.size() == 2 ); assert( searchResult[0].getTitle() == "Let It Be" ); assert( searchResult[1].getTitle() == "Penny Lane" ); cout << " 2 " << flush; cout << " Passed!" << endl; } void PlayListTester::testSearchByYear() { cout << "- searchByYear... " << flush; // load a playlist with test songs PlayList pList("testSongs.txt"); // empty case (0) vector<Song> searchResult = pList.searchByYear(2015); assert( searchResult.size() == 0 ); cout << " 0 " << flush; // 1 returned case searchResult = pList.searchByYear(2012); assert( searchResult.size() == 1); cout << " 1 " << flush; // 2 returned case searchResult = pList.searchByYear(1967); assert( searchResult.size() == 2); cout << " 2 " << flush; cout << " Passed!" << endl; } void PlayListTester::testSearchByTitlePhrase() { cout << "- searchByTitlePhrase... " << flush; // load a playlist with test songs PlayList pList("testSongs.txt"); // empty case (0) vector<Song> searchResult = pList.searchByTitlePhrase("non-existent title"); assert( searchResult.size() == 0 ); cout << " 0 " << flush; // 1 returned case searchResult = pList.searchByTitlePhrase("Penny Lane"); assert( searchResult.size() == 1); cout << " 1 " << flush; // 2 returned case searchResult = pList.searchByTitlePhrase("Let It Be"); assert( searchResult.size() == 2); cout << " 2 " << flush; // only part of the title case searchResult = pList.searchByTitlePhrase("Penny"); assert( searchResult.size() == 1); cout << " 3 " << flush; cout << " Passed!" << endl; } void PlayListTester::testAddRemoveSong() { cout << "- AddRemoveSong... " << flush; Song s1("Title", "Artist", 2019); PlayList pList("testSongs.txt"); // add song and check if length of list increases and song is included pList.addSong(s1); assert( pList.getNumSongs() == 5); cout << " 0 " << flush; assert( pList.searchByYear(2019).size() == 1); // remove added song and check if length and list are same to original pList.removeSong(s1); assert(pList.getNumSongs() == 4); assert(pList.searchByYear(2019).size() == 0); cout << " 1 " << flush; cout << " Passed!" << endl; } void PlayListTester::testSave() { cout << "- Save... " << flush; }
[ "jacob@localhost" ]
jacob@localhost
ae1c39ac9af01b72150eb32e8a95d90d0ef066b8
43324425eda25c2f9760701896e87051e22fa1a2
/filter.cxx
fbe469cf0c8bec05a6e766bc648ada82adc073fd
[]
no_license
Brookii/hw4
71061895da522e06da23c353176fcf225ba7cdbc
35f89526a1bd400bfa07f775d6c30f300288e64f
refs/heads/master
2020-12-31T01:11:50.672279
2015-11-24T15:01:34
2015-11-24T15:01:34
46,434,015
0
0
null
2015-11-18T17:03:37
2015-11-18T17:03:37
null
UTF-8
C++
false
false
1,069
cxx
#include <cmath> #include <iostream> #include <cstdlib> #include <fstream> #include <string> using namespace std; void reading(const int N, double* p, const string noisy); void Ausgabe_auf_englisch(const int N, double* p, const string noisy); void filtern(const int N, double* p, const string noisy); int main(){ const int N = 237; const string noisy = "noisy.txt"; double* p = new double[N]; reading(N,p,noisy); filtern(N,p,noisy); Ausgabe_auf_englisch(N,p,noisy); delete[] p; return 0; } void filtern(const int N, double* p, const string noisy){ double altp, neup = p[N-1]; for(int u = 0; u < 3;u++){ for(int i = 0; i < N; i++){ altp = p[i]; p[i] = (neup + p[i] +p[i+1])/3.0; neup = altp; } } } void reading(const int N, double* p, const string noisy){ ifstream in(noisy.c_str()); for(int i = 0; i < N; i++){ in >> p[i]; } in.close(); } void Ausgabe_auf_englisch(const int N, double* p, const string noisy){ ofstream out("gefiltert_3.txt"); for(int i = 0; i < N; i++){ out << p[i] << endl; } out.close(); }
[ "martin.boeckmann@uni-duesseldorf.de" ]
martin.boeckmann@uni-duesseldorf.de
c1aa34a71b14660f099f454c7782b1e91f6e0757
293279d940b97ad5a2b98f27d2fe8368f7a7f50c
/gammaee/luminosity/src/CrystalStudy/Class/CrystalStudy.cc
98e88857437e3f992c529e9a0dc4bd3a503cc5b9
[]
no_license
jpivarski-talks/1999-2006_gradschool-1
51a59a9d262a34d4d613d84bd6a78a0e2675db06
11abf09e8dc3b901627e9a7349d9c98bea250647
refs/heads/master
2022-11-19T12:16:19.477335
2020-07-25T01:18:29
2020-07-25T01:18:29
282,235,487
0
0
null
null
null
null
UTF-8
C++
false
false
7,409
cc
// -*- C++ -*- // // Package: CrystalStudy // Module: CrystalStudy // // Description: <one line class summary> // // Implementation: // <Notes on implementation> // // Author: Jim Pivarski // Created: Thu Apr 14 11:41:14 EDT 2005 // $Id$ // // Revision history // // $Log$ // #include "Experiment/Experiment.h" // system include files // user include files #include "CrystalStudy/CrystalStudy.h" #include "Experiment/report.h" #include "Experiment/units.h" // for converting to/from standard CLEO units #include "DataHandler/Record.h" #include "DataHandler/Frame.h" #include "FrameAccess/extract.h" #include "FrameAccess/FAItem.h" #include "FrameAccess/FATable.h" #include "EventProperties/EventProperties.h" #include "Navigation/NavShower.h" #include "C3cc/CcShowerAttributes.h" // STL classes // You may have to uncomment some of these or other stl headers // depending on what other header files you include (e.g. FrameAccess etc.)! //#include <string> //#include <vector> //#include <set> //#include <map> //#include <algorithm> //#include <utility> // // constants, enums and typedefs // static const char* const kFacilityString = "Processor.CrystalStudy" ; // ---- cvs-based strings (Id and Tag with which file was checked out) static const char* const kIdString = "$Id: processor.cc,v 1.40 2005/02/10 16:03:57 chengp Exp $"; static const char* const kTagString = "$Name: v07_02_00 $"; // // static data member definitions // // // constructors and destructor // CrystalStudy::CrystalStudy( void ) // anal1 : Processor( "CrystalStudy" ) { report( DEBUG, kFacilityString ) << "here in ctor()" << endl; // ---- bind a method to a stream ----- // These lines ARE VERY IMPORTANT! If you don't bind the // code you've just written (the "action") to a stream, // your code won't get executed! bind( &CrystalStudy::event, Stream::kEvent ); //bind( &CrystalStudy::beginRun, Stream::kBeginRun ); //bind( &CrystalStudy::endRun, Stream::kEndRun ); // do anything here that needs to be done at creation time // (e.g. allocate resources etc.) } CrystalStudy::~CrystalStudy() // anal5 { report( DEBUG, kFacilityString ) << "here in dtor()" << endl; // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) } // // member functions // // ------------ methods for beginning/end "Interactive" ------------ // --------------------------- init method ------------------------- void CrystalStudy::init( void ) // anal1 "Interactive" { report( DEBUG, kFacilityString ) << "here in init()" << endl; // do any initialization here based on Parameter Input by User // (e.g. run expensive algorithms that are based on parameters // specified by user at run-time) } // -------------------- terminate method ---------------------------- void CrystalStudy::terminate( void ) // anal5 "Interactive" { report( DEBUG, kFacilityString ) << "here in terminate()" << endl; // do anything here BEFORE New Parameter Change // (e.g. write out result based on parameters from user-input) } // ---------------- standard place to book histograms --------------- void CrystalStudy::hist_book( HIHistoManager& iHistoManager ) { report( DEBUG, kFacilityString ) << "here in hist_book()" << endl; // book your histograms here const char* label[kNumEntries] = { "hot1", "en1", "ener1", "th1", "ther1", "phi1", "phier1", "d1", "e9251", "mass1", "wid1", "zwid1", "neff1", "nhit1", "nhitu1", "ring1", "cell1", "naive1", "thb1", "phb1", "thp1", "php1", "pock1", "hot2", "en2", "ener2", "th2", "ther2", "phi2", "phier2", "d2", "e9252", "mass2", "wid2", "zwid2", "neff2", "nhit2", "nhitu2", "ring2", "cell2", "naive2", "thb2", "phb2", "thp2", "php2", "pock2", }; m_ntuple = iHistoManager.ntuple( 1, "vars", kNumEntries, 262144, label); } // --------------------- methods bound to streams ------------------- ActionBase::ActionResult CrystalStudy::event( Frame& iFrame ) // anal3 equiv. { report( DEBUG, kFacilityString ) << "here in event()" << endl; FAItem<EventProperties> props; extract(iFrame.record(Stream::kEvent), props); if (props->nbChargedTracks() > 1) return ActionBase::kFailed; FATable<NavShower> showers; extract(iFrame.record(Stream::kEvent), showers); FATable<NavShower>::const_iterator s1 = showers.find(props->firstShowerIdentifier()); FATable<NavShower>::const_iterator s2 = showers.find(props->secondShowerIdentifier()); float v[kNumEntries]; for (int i = 0; i < kNumEntries; i++) v[i] = -1000.; if (s1 != showers.end()) { v[k_hot1] = s1->attributes().hot(); v[k_en1] = s1->attributes().energy(); v[k_ener1] = s1->attributes().errEnergy(); v[k_th1] = s1->attributes().theta(); v[k_ther1] = s1->attributes().errTheta(); v[k_phi1] = s1->attributes().phi(); v[k_phier1] = s1->attributes().errPhi(); v[k_d1] = s1->attributes().distance(); v[k_e9251] = s1->attributes().e9oe25(); v[k_mass1] = s1->attributes().mass(); v[k_wid1] = s1->attributes().width(); v[k_zwid1] = s1->attributes().zWidth(); v[k_neff1] = s1->attributes().nEffective(); v[k_nhit1] = s1->attributes().nHits(); v[k_nhitu1] = s1->attributes().nHitsUsed(); v[k_ring1] = s1->attributes().ringId(); v[k_cell1] = s1->attributes().bigCellId(); v[k_naive1] = s1->attributes().naiveEnergy(); v[k_thb1] = s1->attributes().thetaBlock(); v[k_phb1] = s1->attributes().phiBlock(); v[k_thp1] = s1->attributes().thetaPock(); v[k_php1] = s1->attributes().phiPock(); v[k_pock1] = s1->attributes().pocket(); } if (s2 != showers.end()) { v[k_hot2] = s2->attributes().hot(); v[k_en2] = s2->attributes().energy(); v[k_ener2] = s2->attributes().errEnergy(); v[k_th2] = s2->attributes().theta(); v[k_ther2] = s2->attributes().errTheta(); v[k_phi2] = s2->attributes().phi(); v[k_phier2] = s2->attributes().errPhi(); v[k_d2] = s2->attributes().distance(); v[k_e9252] = s2->attributes().e9oe25(); v[k_mass2] = s2->attributes().mass(); v[k_wid2] = s2->attributes().width(); v[k_zwid2] = s2->attributes().zWidth(); v[k_neff2] = s2->attributes().nEffective(); v[k_nhit2] = s2->attributes().nHits(); v[k_nhitu2] = s2->attributes().nHitsUsed(); v[k_ring2] = s2->attributes().ringId(); v[k_cell2] = s2->attributes().bigCellId(); v[k_naive2] = s2->attributes().naiveEnergy(); v[k_thb2] = s2->attributes().thetaBlock(); v[k_phb2] = s2->attributes().phiBlock(); v[k_thp2] = s2->attributes().thetaPock(); v[k_php2] = s2->attributes().phiPock(); v[k_pock2] = s2->attributes().pocket(); } m_ntuple->fill(v); return ActionBase::kPassed; } /* ActionBase::ActionResult CrystalStudy::beginRun( Frame& iFrame ) // anal2 equiv. { report( DEBUG, kFacilityString ) << "here in beginRun()" << endl; return ActionBase::kPassed; } */ /* ActionBase::ActionResult CrystalStudy::endRun( Frame& iFrame ) // anal4 equiv. { report( DEBUG, kFacilityString ) << "here in endRun()" << endl; return ActionBase::kPassed; } */ // // const member functions // // // static member functions //
[ "jpivarski@gmail.com" ]
jpivarski@gmail.com
38b81b61c089bb0ddb86e69f166d231becf59cf2
204201d53fd444670dc23999e0de0862559512a2
/Asignatura.cpp
337bf2ada59fdb964fb3ff3ca2bd9638f3804b01
[]
no_license
cristian6aston/tenoinflab
11de21f61cd719e00bc257529ec8829ff0ac27fb
1f8904a82040f0a7ac8695ac470277931232152b
refs/heads/master
2021-01-09T06:38:47.654553
2016-06-14T00:03:22
2016-06-14T00:03:22
61,076,866
0
1
null
2016-06-14T00:03:23
2016-06-13T23:39:02
C++
UTF-8
C++
false
false
1,104
cpp
#include <string> #include <iostream> #include "Asignatura.h" using namespace std; Asignatura::Asignatura(){ this->codigo = 0; this->nombre = " "; this->creditos = 0; } Asignatura::Asignatura(const Asignatura& asignatura){ this->codigo = asignatura.codigo; this->nombre = asignatura.nombre; this->creditos = asignatura.creditos; } Asignatura::Asignatura(int codigo, string nombre, int creditos){ this->codigo = codigo; this->nombre = nombre; this->creditos = creditos; } int Asignatura::getCodigo() const{ return this->codigo; } string Asignatura::getNombre() const{ return this->nombre; } int Asignatura::getCreditos() const{ return this->creditos; } void Asignatura::setCodigo(int codigo){ this->codigo = codigo; } void Asignatura::setNombre(string nombre){ this->nombre = nombre; } void Asignatura::setCreditos(int creditos){ this->creditos = creditos; } DtAsignatura Asignatura::getDtAsignatura(){ DtAsignatura dta; return dta = DtAsignatura(this->codigo, this->nombre, this->creditos); } Asignatura::~Asignatura(){}
[ "cristian6aston@gmail.com" ]
cristian6aston@gmail.com
b30068cb1cf3662db55aac28304230a15ff66611
5d0ddbd6f42843ded4d5ba18966dc130725607d2
/c13.code/uintah/branches/pearls/src/Core/Geometry/Plane.h
e32a7a3f542ae987e0780da50edf244307a12a31
[ "MIT" ]
permissive
alvarodlg/lotsofcoresbook2code
b93ad62e015d205e4f550028ceb54254023021ee
a2dbeb306fa29ae6663ae29b2c4c132608375cf0
refs/heads/master
2020-12-31T03:02:22.579614
2015-09-02T15:23:18
2015-09-02T15:23:18
54,509,919
2
1
null
2016-03-22T21:27:56
2016-03-22T21:27:56
null
UTF-8
C++
false
false
2,368
h
/* * The MIT License * * Copyright (c) 1997-2015 The University of Utah * * 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. */ /* * Plane.h: Directed plane * * Written by: * David Weinstein * Department of Computer Science * University of Utah * October 1994 * */ #ifndef SCI_project_Plane_h #define SCI_project_Plane_h 1 #include <Core/Geometry/Vector.h> namespace SCIRun { class Point; class Plane { Vector n; double d; public: Plane(const Plane &copy); Plane(const Point &p1, const Point &p2, const Point &p3); Plane(const Point &p, const Vector &n); Plane(); Plane(double a, double b, double c, double d); ~Plane(); double eval_point(const Point &p) const; void flip(); Point project(const Point& p) const; Vector project(const Vector& v) const; Vector normal() const; void get(double (&abcd)[4]) const; // changes the plane ( n and d ) void ChangePlane( const Point &p1, const Point &p2, const Point &p3 ); void ChangePlane( const Point &p1, const Vector &v); // returns true if the line v*t+s for -inf < t < inf intersects // the plane. if so, hit contains the point of intersection. int Intersect( Point s, Vector v, Point& hit ); int Intersect( Point s, Vector v, double &t ) const; }; } // End namespace SCIRun #endif
[ "ryan.g.coleman@gmail.com" ]
ryan.g.coleman@gmail.com
efa184801b1f02f76eff3743b96c8d899acd80df
428989cb9837b6fedeb95e4fcc0a89f705542b24
/erle/ros2_ws/install/include/rcl_interfaces/srv/dds_opensplice/list_parameters__type_support.cpp
44777f9d3c4879e1c12683244e585e7916caafa7
[]
no_license
swift-nav/ros_rover
70406572cfcf413ce13cf6e6b47a43d5298d64fc
308f10114b35c70b933ee2a47be342e6c2f2887a
refs/heads/master
2020-04-14T22:51:38.911378
2016-07-08T21:44:22
2016-07-08T21:44:22
60,873,336
1
2
null
null
null
null
UTF-8
C++
false
false
141
cpp
/home/erle/ros2_ws/build/rcl_interfaces/rosidl_typesupport_opensplice_cpp/rcl_interfaces/srv/dds_opensplice/list_parameters__type_support.cpp
[ "igdoty@swiftnav.com" ]
igdoty@swiftnav.com
73757743bc4c748f351e35c2737bae812ff5dee6
ed375380b4eb9d572dc837bb2b9899b230152392
/variety_const_instance_implementation.h
ae130c11cb76f5e6eba8aa898c8188c35e51acb6
[]
no_license
fdt1/collection
53ad8bd14265a4d7640cee6a241b952dd0001b9e
2b7eb8860dcd856a6d46561478532b5b09872c4c
refs/heads/master
2021-01-19T20:19:04.220488
2015-12-20T14:25:44
2015-12-20T14:25:44
37,906,930
0
0
null
null
null
null
UTF-8
C++
false
false
982
h
/* * variety_const_instance_implementation.h * collection * * Created by Francois et Fabienne on 11/11/10. * Copyright 2010 __MyCompanyName__. All rights reserved. * */ #pragma once #include "variety_static_types.h" #include "variety_adapter.h" namespace variety { namespace internal { template <typename static_types_template, typename base_template> class const_instance_implementation : public virtual adapter<static_types_template, base_template> { public: typedef base_template base_type; private: const base_type _base; public: const_instance_implementation(base_type& base) : _base(base) {} virtual ~const_instance_implementation() {} virtual const base_type& get_base() const { return _base; } virtual base_type& get_base() { assert(false); } virtual const_instance_implementation* duplicate() const { return new const_instance_implementation(_base); } }; } // namespace internal } // namespace variety
[ "FDT1@LW5-FDT1-CEM.dsone.3ds.com" ]
FDT1@LW5-FDT1-CEM.dsone.3ds.com
9bb6db84c597990af8c30cbae681dbcd4095de2b
962213848e5f4989c2f1b692ef9baa604b2c3152
/910.cpp
396e314cef8e86981371cc8665758b4084de442a
[ "MIT" ]
permissive
BYOUINZAKA/LeetCodeNotes
bfc9634bf538b711edefcd7e38a383b625744bda
48e1b4522c1f769eeec4944cfbd57abf1281d09a
refs/heads/master
2022-12-02T14:12:14.855840
2020-08-22T10:41:06
2020-08-22T10:41:06
283,944,029
0
0
null
null
null
null
UTF-8
C++
false
false
666
cpp
/* * @Author: Hata * @Date: 2020-05-20 16:42:02 * @LastEditors: Hata * @LastEditTime: 2020-05-20 16:51:57 * @FilePath: \LeetCode\910.cpp * @Description: https://leetcode-cn.com/problems/smallest-range-ii/ */ #include <bits/stdc++.h> class Solution { public: int smallestRangeII(std::vector<int> &A, int K) { std::sort(A.begin(), A.end()); int res = A.back() - A.front(); for (auto it = A.begin(); it != A.end() - 1;) { int max = std::max(A.back() - K, *it + K); int min = std::min(A.front() + K, *(++it) - K); res = std::min(res, max - min); } return res; } };
[ "2606675531@qq.com" ]
2606675531@qq.com
0ddb799b0f086f2d9533068861e350cfd1ecb39b
12684d47f6bf95f141b4e03ff3af97f5e0808ded
/src/configmanager.hpp
1c22a08148d1136398a16074747b545a6102086a
[ "MIT" ]
permissive
olekolek1000/MPS
41b27c1bed5a1a9e5a16ba52ca6ee5668f469ef0
30461844febb50fadf744cfbaeef88fbfdd5538f
refs/heads/master
2021-06-11T20:06:40.926236
2021-06-05T21:21:11
2021-06-05T21:21:11
117,428,019
9
9
MIT
2021-06-05T21:21:12
2018-01-14T12:27:27
C++
UTF-8
C++
false
false
400
hpp
#pragma once #include <string> #include <map> #include <fstream> class ConfigManager{ std::string filename; std::map<std::string, std::string> options; std::fstream file; bool good=false; public: ~ConfigManager(); bool open(const char* filename); std::string getvarS(const char* n); int getvarI(const char* n); float getvarF(const char* n); bool isGood(); };
[ "aleksander@olekolek1000.com" ]
aleksander@olekolek1000.com
26509e2e87408b67193e222d1990a21a8c1c5a65
df90ed23a49dba79f61e5a28366424f0ecec60de
/src/security/uncipher_file.cpp
ff33d72c325c211d4d3fc095788cf9d9d02f254c
[ "BSD-2-Clause" ]
permissive
Damdoshi/LibLapin
306e8ae8be70be9e4de93db60913c4f092a714a7
41491d3d3926b8e42e3aec8d1621340501841aae
refs/heads/master
2023-09-03T10:11:06.743172
2023-08-25T08:03:33
2023-08-25T08:03:33
64,509,332
39
12
NOASSERTION
2021-02-03T17:18:22
2016-07-29T20:43:25
C++
UTF-8
C++
false
false
833
cpp
// Jason Brillante "Damdoshi" // Hanged Bunny Studio 2014-2018 // // Lapin library #include "lapin_private.h" #define PATTERN "%s file, %d ciphering algorithm, %p key -> %s" bool bunny_uncipher_file(const char *file, t_bunny_ciphering cip, const t_bunny_cipher_key *key) { char *cnt; size_t len; bool ret; if (bunny_load_file(file, (void**)&cnt, &len) == -1) scream_error_if(return (false), bunny_errno, PATTERN, "security", file, cip, key, "false"); bunny_uncipher_data(cnt, len, cip, key); ret = bunny_save_file(file, cnt, len); len = bunny_errno; bunny_delete_file(cnt, file); if (ret == false) scream_error_if(return (false), len, PATTERN, "security", file, cip, key, "false"); scream_log_if(PATTERN, "security", file, cip, key, "true"); return (ret); }
[ "jbrillante@anevia.com" ]
jbrillante@anevia.com
a8bfd06a72074627717a81eb363f96d5fb2dac0e
b7f3edb5b7c62174bed808079c3b21fb9ea51d52
/components/autofill_assistant/browser/actions/select_option_action.cc
9e807659668d9b1a89bee41675f7ac1b0626d438
[ "BSD-3-Clause" ]
permissive
otcshare/chromium-src
26a7372773b53b236784c51677c566dc0ad839e4
64bee65c921db7e78e25d08f1e98da2668b57be5
refs/heads/webml
2023-03-21T03:20:15.377034
2020-11-16T01:40:14
2020-11-16T01:40:14
209,262,645
18
21
BSD-3-Clause
2023-03-23T06:20:07
2019-09-18T08:52:07
null
UTF-8
C++
false
false
2,608
cc
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/autofill_assistant/browser/actions/select_option_action.h" #include <utility> #include "base/bind.h" #include "base/callback.h" #include "components/autofill_assistant/browser/actions/action_delegate.h" #include "components/autofill_assistant/browser/client_status.h" namespace autofill_assistant { SelectOptionAction::SelectOptionAction(ActionDelegate* delegate, const ActionProto& proto) : Action(delegate, proto) { DCHECK(proto_.has_select_option()); } SelectOptionAction::~SelectOptionAction() {} void SelectOptionAction::InternalProcessAction(ProcessActionCallback callback) { const SelectOptionProto& select_option = proto_.select_option(); // A non prefilled |select_option| is not supported. if (!select_option.has_selected_option()) { VLOG(1) << __func__ << ": empty option"; UpdateProcessedAction(INVALID_ACTION); std::move(callback).Run(std::move(processed_action_proto_)); return; } Selector selector = Selector(select_option.element()); if (selector.empty()) { VLOG(1) << __func__ << ": empty selector"; UpdateProcessedAction(INVALID_SELECTOR); std::move(callback).Run(std::move(processed_action_proto_)); return; } delegate_->ShortWaitForElement( selector, base::BindOnce(&SelectOptionAction::OnWaitForElement, weak_ptr_factory_.GetWeakPtr(), std::move(callback), selector)); } void SelectOptionAction::OnWaitForElement(ProcessActionCallback callback, const Selector& selector, const ClientStatus& element_status) { if (!element_status.ok()) { UpdateProcessedAction(element_status.proto_status()); std::move(callback).Run(std::move(processed_action_proto_)); return; } delegate_->SelectOption( selector, proto_.select_option().selected_option(), proto_.select_option().select_strategy(), base::BindOnce(&::autofill_assistant::SelectOptionAction::OnSelectOption, weak_ptr_factory_.GetWeakPtr(), std::move(callback))); } void SelectOptionAction::OnSelectOption(ProcessActionCallback callback, const ClientStatus& status) { UpdateProcessedAction(status); std::move(callback).Run(std::move(processed_action_proto_)); } } // namespace autofill_assistant
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
8c429cbdb847d750eb1a35fa3b9d67c76b5c76a5
404798431504c0ef33fe97979de436a48717d552
/VehicleRouting/IO/read.hpp
0fb86a2bce257eb34c3e189882818fb56b913519
[]
no_license
ShiyaoBian6639/KoalaOpt
ec887077f5d528096cafe6cee68a722a0d54e3bb
d12602e3f43b9ee6b23a3d6202be7d29dce764bb
refs/heads/master
2023-03-19T08:29:31.529617
2021-03-08T16:36:27
2021-03-08T16:36:27
327,836,993
0
0
null
null
null
null
UTF-8
C++
false
false
742
hpp
#pragma once #ifndef _READ #define _READ #include<iostream> #include<string> #include<fstream> #include<chrono> #include<boost/unordered/unordered_set.hpp> #include<boost/numeric/ublas/vector.hpp> using namespace std; class Read { public: /* class attributes */ string fileName; string instanceName; int numVehicle, capacity, numCustomer; vector<vector<int>> customer; /* constructor of Read */ Read(string inputFileName) { fileName = inputFileName; ifstream instance; instance.open(fileName); if (!instance.is_open()) { cout << "instance " << fileName << " is not valid!" << endl; return; } } /* class methods */ string getFileName(void); void read(void); void printCustomer(void); }; #endif // !_READ
[ "biansyao@gmail.com" ]
biansyao@gmail.com
615bde32b5d98b0d853dd9b862eafcbbfe7bf30d
6953ba98fa153dfd717373de0297768d3489b2b9
/ZoyeeUtils/IPCInterface.cpp
009deb9e9fc4c70b0232d817b6475ed3d54e1fb5
[]
no_license
cnsuhao/ZoyeeStudio
dfbad9788b61b44f88bb9ebd1f10d88010a49ce4
f557b532ec3c541905df57819c1773d6f661d387
refs/heads/master
2021-08-23T14:20:50.915373
2017-11-02T09:44:05
2017-11-02T09:44:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,021
cpp
#include "IPCInterface.h" #include "ShareMemory.h" #include <iostream> using namespace ZoyeeUtils; void ZoyeeUtils::IPC_Object::SetRecvFunctionPtr( pfnIPCRecv pfn ) { if (pfn){ m_pfnRecv = pfn; }else{ m_pfnRecv = DefaultRecv; } } void ZoyeeUtils::IPC_Object::DefaultRecv( const char* pbuff, const int nLen, IPC_Object* pIpcObj ) { printf("[%p]:[%d][%s]\n", pIpcObj, nLen, pbuff); } int ZoyeeUtils::IPC_Object::GetId() { return nId; } void ZoyeeUtils::IPC_Object::SetId( int nId ) { this->nId = nId; } int ZoyeeUtils::IPC_Object::Close() { return this->Send("Close", 5); } IPC_Object* ZoyeeUtils::IPC_Interface::CreateIPCObject( IPC_Type type ) { switch(type){ case Share_Memory_Client: return new CShareMemoryClient; break; case Share_Memory_Server: return new CShareMemoryServerManage; break; default: break; } return nullptr; } void ZoyeeUtils::IPC_Interface::DestroyIPCObject( IPC_Object* ptr ) { delete ptr; ptr = nullptr; }
[ "fatezhou@1f32d0c8-6060-4c7c-b718-6400a953a10a" ]
fatezhou@1f32d0c8-6060-4c7c-b718-6400a953a10a
c46cc1ea6ea20ddb8ecc623af0904232c5c94a66
6b5a3513abb161f1aedca6e7e6a3c0cbd350d54d
/Ship.cpp
d86f57c9d298ab30b61ea0a936227e99afdae5c9
[]
no_license
CharlyBong/Algo_Atlantik
0de65180f29298612e0b88542000da84f934b187
8d3d8ba3ba91c7e7d0148fe92c5b10ddadec7977
refs/heads/master
2021-01-18T15:17:00.007658
2015-01-29T08:31:46
2015-01-29T08:31:46
29,136,634
0
1
null
null
null
null
UTF-8
C++
false
false
922
cpp
#include "Ship.h" #include "KestrelEngine.h" #include "KestrelHull.h" using namespace std; Ship::Ship(){ _nom = "Defaultname"; _engine = new KestrelEngine(); _hull = new KestrelHull(); } Ship::Ship(string nom, Engine* e, Hull* h){ _nom = nom; _engine = e; _hull = h; } Ship::Ship(const Ship&){ _nom = Ship::_nom; } Ship::Ship(string nom, StealthPartsFactory *SPF) { _nom = nom; _engine = SPF->createEngine(); _hull = SPF->createHull(); } Ship::Ship(string nom, KestrelPartsFactory *KPF) { _nom = nom; _engine = KPF->createEngine(); _hull = KPF->createHull(); } Ship::~Ship() { /*delete _engine; delete _hull;*/ } void Ship::SetNom(string nom){ _nom = nom; } Ship& Ship::operator=(const Ship& p){ _nom = p._nom; _engine = p._engine; _hull = p._hull; return *this; } string Ship::getNom() const{ return _nom; }
[ "CharlyBong@users.noreply.github.com" ]
CharlyBong@users.noreply.github.com
e0777d1f93696547293ffe7b5e604d6b2b156dbd
a6b698105aec67701cdd509cb9a48528786049d2
/RegainEarthCheat/SDK/WB_PlayButton_parameters.h
d7b827f29d95df98de27caf66cdc4b360756d8f3
[]
no_license
ejiaogl/RegainEarth-Cheat
859d44d8400a3694b4e946061b20d30561c6304f
4136c2c11e78e9dbb305e55556928dfba7f4f620
refs/heads/master
2023-08-29T09:39:45.222291
2021-10-19T19:56:05
2021-10-19T19:56:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,667
h
#pragma once // Name: RegainEart-FirtstStrike, Version: Version-1 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Parameters //--------------------------------------------------------------------------- // Function WB_PlayButton.WB_PlayButton_C.SetFrameBlockColor struct UWB_PlayButton_C_SetFrameBlockColor_Params { struct FLinearColor Color; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.GetCurrentScale struct UWB_PlayButton_C_GetCurrentScale_Params { struct FVector2D Scale; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.UpdateImageSaturation struct UWB_PlayButton_C_UpdateImageSaturation_Params { }; // Function WB_PlayButton.WB_PlayButton_C.UpdateImageColors struct UWB_PlayButton_C_UpdateImageColors_Params { }; // Function WB_PlayButton.WB_PlayButton_C.RemoveContentWidget struct UWB_PlayButton_C_RemoveContentWidget_Params { }; // Function WB_PlayButton.WB_PlayButton_C.CreateContentWidget struct UWB_PlayButton_C_CreateContentWidget_Params { class UClass* ContentWidget; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.IsContentWidgetValid struct UWB_PlayButton_C_IsContentWidgetValid_Params { bool ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData, NoDestructor) }; // Function WB_PlayButton.WB_PlayButton_C.Set_AllFrameColours struct UWB_PlayButton_C_Set_AllFrameColours_Params { }; // Function WB_PlayButton.WB_PlayButton_C.UpdateIsEnabled struct UWB_PlayButton_C_UpdateIsEnabled_Params { bool BIsEnabled; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor) }; // Function WB_PlayButton.WB_PlayButton_C.SetFontInfo_OnDisabled struct UWB_PlayButton_C_SetFontInfo_OnDisabled_Params { }; // Function WB_PlayButton.WB_PlayButton_C.SetButtonSizeScale struct UWB_PlayButton_C_SetButtonSizeScale_Params { struct FVector2D Size; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.SetResponsiveHoveringToNativeButton struct UWB_PlayButton_C_SetResponsiveHoveringToNativeButton_Params { }; // Function WB_PlayButton.WB_PlayButton_C.UnhoverAllNativeButtons struct UWB_PlayButton_C_UnhoverAllNativeButtons_Params { }; // Function WB_PlayButton.WB_PlayButton_C.SetButtonSounds struct UWB_PlayButton_C_SetButtonSounds_Params { class USoundBase* OnClicked_Sound; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) class USoundBase* OnHovered_Sound; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.GetButton struct UWB_PlayButton_C_GetButton_Params { class UButton* Base_Button; // (Parm, OutParm, ZeroConstructor, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.SetFontInfo_OnClicked struct UWB_PlayButton_C_SetFontInfo_OnClicked_Params { }; // Function WB_PlayButton.WB_PlayButton_C.SetFontInfo_OnNormal struct UWB_PlayButton_C_SetFontInfo_OnNormal_Params { }; // Function WB_PlayButton.WB_PlayButton_C.SetFontInfo_OnHovered struct UWB_PlayButton_C_SetFontInfo_OnHovered_Params { }; // Function WB_PlayButton.WB_PlayButton_C.BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_5_OnClicked__DelegateSignature struct UWB_PlayButton_C_BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_5_OnClicked__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_6_OnHovered__DelegateSignature struct UWB_PlayButton_C_BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_6_OnHovered__DelegateSignature_Params { bool bNativeHovered; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor) }; // Function WB_PlayButton.WB_PlayButton_C.BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_7_OnUnhovered__DelegateSignature struct UWB_PlayButton_C_BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_7_OnUnhovered__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_8_OnPressed__DelegateSignature struct UWB_PlayButton_C_BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_8_OnPressed__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_9_OnReleased__DelegateSignature struct UWB_PlayButton_C_BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_9_OnReleased__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.Construct struct UWB_PlayButton_C_Construct_Params { }; // Function WB_PlayButton.WB_PlayButton_C.CheckHasFocus struct UWB_PlayButton_C_CheckHasFocus_Params { }; // Function WB_PlayButton.WB_PlayButton_C.OnInputSwitched struct UWB_PlayButton_C_OnInputSwitched_Params { TEnumAsByte<EInputType_EInputType> InputType; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_0_OnDisabled__DelegateSignature struct UWB_PlayButton_C_BndEvt__WB_BaseButton_K2Node_ComponentBoundEvent_0_OnDisabled__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.CheckScale struct UWB_PlayButton_C_CheckScale_Params { }; // Function WB_PlayButton.WB_PlayButton_C.BndEvt__WB_NativeButton_K2Node_ComponentBoundEvent_143_OnUnfocused__DelegateSignature struct UWB_PlayButton_C_BndEvt__WB_NativeButton_K2Node_ComponentBoundEvent_143_OnUnfocused__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.BndEvt__WB_NativeButton_K2Node_ComponentBoundEvent_142_OnFocused__DelegateSignature struct UWB_PlayButton_C_BndEvt__WB_NativeButton_K2Node_ComponentBoundEvent_142_OnFocused__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.Reconstruct struct UWB_PlayButton_C_Reconstruct_Params { }; // Function WB_PlayButton.WB_PlayButton_C.SetBaseColor struct UWB_PlayButton_C_SetBaseColor_Params { bool bUseBaseColor; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor) struct FLinearColor Grad0; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) struct FLinearColor Grad1; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) struct FLinearColor Grad2; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) struct FLinearColor Grad3; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.SetupButtonSounds struct UWB_PlayButton_C_SetupButtonSounds_Params { bool bUseButtonSounds; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor) class USoundBase* Clicked; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) class USoundBase* Hovered; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.PreConstruct struct UWB_PlayButton_C_PreConstruct_Params { bool IsDesignTime; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor) }; // Function WB_PlayButton.WB_PlayButton_C.Tick struct UWB_PlayButton_C_Tick_Params { struct FGeometry MyGeometry; // (BlueprintVisible, BlueprintReadOnly, Parm, IsPlainOldData, NoDestructor) float InDeltaTime; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.ExecuteUbergraph_WB_PlayButton struct UWB_PlayButton_C_ExecuteUbergraph_WB_PlayButton_Params { int EntryPoint; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; // Function WB_PlayButton.WB_PlayButton_C.OnUnfocused__DelegateSignature struct UWB_PlayButton_C_OnUnfocused__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.OnFocused__DelegateSignature struct UWB_PlayButton_C_OnFocused__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.OnDisabled__DelegateSignature struct UWB_PlayButton_C_OnDisabled__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.OnReleased__DelegateSignature struct UWB_PlayButton_C_OnReleased__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.OnPressed__DelegateSignature struct UWB_PlayButton_C_OnPressed__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.OnUnhovered__DelegateSignature struct UWB_PlayButton_C_OnUnhovered__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.OnHovered__DelegateSignature struct UWB_PlayButton_C_OnHovered__DelegateSignature_Params { }; // Function WB_PlayButton.WB_PlayButton_C.OnClicked__DelegateSignature struct UWB_PlayButton_C_OnClicked__DelegateSignature_Params { }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "64608145+Fischsalat@users.noreply.github.com" ]
64608145+Fischsalat@users.noreply.github.com
68965d55adbac2cf4ce22ccf5603460f5d651b18
7021c0fe34acca0d34573b1a15e787cde8e7232a
/9_11_practice_chapter/9_11_practice_chapter.cpp
73b1eb63165bccf74bd6cf5d3262891ab4e4fb80
[]
no_license
burdensome/CPP_TBC_CH9
98615448bb0d3c66679e8eb31735c93b078aa419
04e0572e9354fd95c14fdeb57598abe62082fc02
refs/heads/master
2023-04-10T01:04:18.526835
2021-04-12T10:04:34
2021-04-12T10:04:34
357,144,406
0
0
null
null
null
null
UHC
C++
false
false
2,647
cpp
#include <iostream> #include <cassert> using namespace std; class Mystring { //private: // 일반적인 구현에선 private가 맞는데 주소찍으려고 public으로 한 것 뿐. incapsulation에는 private이 좋겠따. public: char* m_data = nullptr; int m_length = 0; public: Mystring(const char* source = "") { cout << "Default constructor" << endl; assert(source); m_length = std::strlen(source) + 1; m_data = new char[m_length]; for (int i = 0; i < m_length; ++i) m_data[i] = source[i]; m_data[m_length - 1] = '\0'; } // 기본으로 생성된 copy constructor가 동적할당 시에는 복사생성자 사용시 위험 할 수 있기 떄문에 직접만든다. Mystring(const Mystring& source) { cout << "Copy constructor" << endl; m_length = source.m_length; if (source.m_data != nullptr) { m_data = new char[m_length]; for (int i = 0; i < m_length; ++i) m_data[i] = source.m_data[i]; } else { m_data = nullptr; // 0을 넣어도 되는데 요즘 문법인 nullptr } } Mystring& operator = (const Mystring& source) // { //shallow copy /*cout << "Default copy constructor " << endl; this->m_data = source.m_data; this->m_length = source.m_length;*/ cout << "Assignment operator " << endl; if (this == &source) // prevent self-assignment // (1) 여기 return *this; delete[] m_data; m_length = source.m_length; if (source.m_data != nullptr) { m_data = new char[m_length]; for (int i = 0; i < m_length; ++i) m_data[i] = source.m_data[i]; } else { m_data = nullptr; } } ~Mystring() { //cout << "소멸자" << endl; delete[] m_data; } char* getString() { return m_data; } int getLength() { return m_length; } }; int main() { Mystring hello("Hello"); // 자기 자신을 대입 할 떄 // hello = hello; // 사람 입장에선 시간낭비네? 라고 할 수 있는데 프로그램 입장에선 문제가 생김(1) cout << (int*)hello.m_data << endl; // hello.m_data를 실행하면 문자 값이 나오니 주소값을 보려고 강제로 int*로 typecasting을 함 cout << hello.getString() << endl; { Mystring copy = hello; cout << (int*)copy.m_data << endl; cout << copy.getString() << endl; } cout << hello.getString() << endl; return 0; }
[ "gudejrwkd@gmail.com" ]
gudejrwkd@gmail.com
86c2f8ad20b93c5e23f8bd4750effa821d941d64
a18a07d1b4ed6ceabdaaf2d732f167f8413dfba1
/travis/src/order_vector.cpp
a5de5d7379d59fcdc283576c9cb361ef4242270d
[]
no_license
craabreu/memory_respa_tests
9b221d46a80fc48425c05efdd1723c6201aa40d3
53a6bb3b79a5e3d9317a59cce6b7afdac802b3df
refs/heads/master
2020-04-29T10:20:54.988359
2019-05-02T04:27:15
2019-05-02T04:27:15
176,059,226
1
0
null
null
null
null
UTF-8
C++
false
false
12,219
cpp
/***************************************************************************** TRAVIS - Trajectory Analyzer and Visualizer http://www.travis-analyzer.de/ Copyright (c) 2009-2019 Martin Brehm 2012-2019 Martin Thomas 2016-2019 Sascha Gehrke This file was written by Martin Brehm. --------------------------------------------------------------------------- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. *****************************************************************************/ // This must always be the first include directive #include "config.h" #include "order.h" #include "order_vector.h" #include "globalvar.h" #include "maintools.h" const char *GetRevisionInfo_order_vector(unsigned int len) { static char buf[256]; GET_REVISION_INFO( buf, len ); return buf; } const char *GetSourceVersion_order_vector() { static char buf[256]; GET_SOURCE_VERSION( buf ); return buf; } bool COrderAnalysis_Vector::Parse(CTimeStep *ts) { COrderAnalysis_VectorObs *obs; CxString buf; CAtomGroup ag; CMolecule *m; bool chain, b; char *p, *q, cbuf[16]; int z, z2, z3, z4, ti, ia, it; std::vector<int> tia; std::vector<std::string> tsa; CSingleMolecule *sm; CMolBond *mb; COrderChain *oc; UNUSED(ts); mprintf(WHITE,"\n >>> Analysis %d: Vector-Based Order Parameters >>>\n\n",m_iNumber+1); m_vFixedVector[0] = AskFloat(" Enter X component of fixed vector: [0.0] ",0); m_vFixedVector[1] = AskFloat(" Enter Y component of fixed vector: [0.0] ",0); m_vFixedVector[2] = AskFloat(" Enter Z component of fixed vector: [1.0] ",1.0); mprintf("\n"); if (m_pParent->m_iChainsTotal != 0) { chain = AskYesNo(" Use C-H bonds along an alkyl chain as vectors (y/n)? [no] ",false); mprintf("\n"); } else chain = false; if (chain) { AskString(" Form vectors to which elements as carbon bond partners? [H,D,F] ",&buf,"H,D,F"); p = buf.GetWritePointer(); while (*p != 0) { while (*p == ' ') p++; q = p; while ((*q != 0) && (*q != ',') && (*q != ' ')) q++; memcpy(cbuf,p,q-p); cbuf[q-p] = 0; tsa.push_back((const char*)cbuf); while ((*q == ' ') || (*q == ',')) q++; if (*q == 0) break; p = q; } if (g_oaMolecules.GetSize() == 1) { mprintf(" Using molecule 1.\n"); ti = 0; } else ti = AskRangeInteger_ND(" Define vectors in which molecule (1-%d)? ",1,g_oaMolecules.GetSize(),g_oaMolecules.GetSize()) - 1; if (m_pParent->m_oaChains[ti].size() == 0) { eprintf("\n Error: No alkyl chains have been detected in molecule %d.\n",ti+1); abort(); } m = (CMolecule*)g_oaMolecules[ti]; _ilagain: tia.clear(); AskString_ND(" Which chain(s) to use in molecule %d (comma separated, see list above)? ",&buf,ti+1); if (!ParseIntList((const char*)buf,tia)) { eprintf("\n Invalid input.\n\n"); goto _ilagain; } for (z=0;z<(int)tia.size();z++) { if ((tia[z] < 1) || (tia[z] > (int)m_pParent->m_oaChains[ti].size())) { eprintf("\n Chain number %d outside of allowed range (%d .. %lu).\n\n",tia[z],1,m_pParent->m_oaChains[ti].size()); goto _ilagain; } tia[z]--; if (z > 0) { if (m_pParent->m_oaChains[ti][tia[0]]->m_iaAtoms.size() != m_pParent->m_oaChains[ti][tia[z]]->m_iaAtoms.size()) { eprintf("\n Chains have different lengths (%d: %lu vs. %d: %lu).\n\n",tia[0]+1,m_pParent->m_oaChains[ti][tia[0]]->m_iaAtoms.size(),tia[z]+1,m_pParent->m_oaChains[ti][tia[z]]->m_iaAtoms.size()); goto _ilagain; } } } mprintf("\n"); mprintf(" Using %lu chains of length %lu:\n\n",tia.size(),m_pParent->m_oaChains[ti][tia[0]]->m_iaAtoms.size()); sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[0]]; for (z=0;z<(int)m_pParent->m_oaChains[ti][tia[0]]->m_iaAtoms.size();z++) { mprintf(" Vector %2d: ",z+1); obs = new COrderAnalysis_VectorObs(); m_oaObservations.push_back(obs); obs->m_sName = m->m_sName; obs->m_iMolecule = ti; b = false; for (z2=0;z2<(int)tia.size();z2++) { oc = m_pParent->m_oaChains[ti][tia[z2]]; for (z3=0;z3<sm->m_oaBonds.GetSize();z3++) { mb = (CMolBond*)sm->m_oaBonds[z3]; if ((mb->m_iAtomType[0] == oc->m_iCarbonIndex) && (mb->m_iAtom[0] == oc->m_iaAtoms[z])) { ia = mb->m_iAtom[1]; it = mb->m_iAtomType[1]; } else if ((mb->m_iAtomType[1] == oc->m_iCarbonIndex) && (mb->m_iAtom[1] == oc->m_iaAtoms[z])) { ia = mb->m_iAtom[0]; it = mb->m_iAtomType[0]; } else continue; for (z4=0;z4<(int)tsa.size();z4++) if (mystricmp(tsa[z4].c_str(),((CAtom*)g_oaAtoms[m->m_baAtomIndex[it]])->m_sName) == 0) goto _elok; continue; _elok: obs->m_iaAtomTypes.push_back(oc->m_iCarbonIndex); obs->m_iaAtomTypes.push_back(it); obs->m_iaAtoms.push_back(oc->m_iaAtoms[z]); obs->m_iaAtoms.push_back(ia); buf.sprintf("_C%d-%s%d",oc->m_iaAtoms[z]+1,(const char*)((CAtom*)g_oaAtoms[m->m_baAtomIndex[it]])->m_sName,ia+1); obs->m_sName += buf; if (b) mprintf(", "); b = true; mprintf("C%d --> %s%d",oc->m_iaAtoms[z]+1,(const char*)((CAtom*)g_oaAtoms[m->m_baAtomIndex[it]])->m_sName,ia+1); } } mprintf("\n"); } mprintf("\n"); goto _defdone; } while (true) { mprintf(WHITE," *** Observation %lu ***\n\n",m_oaObservations.size()); obs = new COrderAnalysis_VectorObs(); m_oaObservations.push_back(obs); if (g_oaMolecules.GetSize() == 1) { mprintf(" Defining vector in molecule 1.\n"); obs->m_iMolecule = 0; } else obs->m_iMolecule = AskRangeInteger_ND(" Define vector in which molecule (1-%d)? ",1,g_oaMolecules.GetSize(),g_oaMolecules.GetSize()) - 1; mprintf("\n"); m = (CMolecule*)g_oaMolecules[obs->m_iMolecule]; obs->m_sName = m->m_sName; _again1: AskString_ND(" Which atom to use as vector base point (e.g. C3)? ",&buf); ag.Reset(); if (!ag.ParseAtoms(m,(const char*)buf)) { eprintf("\n Invalid input.\n\n"); goto _again1; } if (ag.m_iAtomGes != 1) { eprintf("\n Please enter only one atom at a time.\n\n"); goto _again1; } obs->m_iaAtomTypes.push_back(ag.m_baAtomType[0]); obs->m_iaAtoms.push_back(((CxIntArray*)ag.m_oaAtoms[0])->GetAt(0)); buf.sprintf("_%s%d-",(const char*)((CAtom*)g_oaAtoms[ag.m_baRealAtomType[0]])->m_sName,((CxIntArray*)ag.m_oaAtoms[0])->GetAt(0)+1); obs->m_sName += buf; _again2: AskString_ND(" Which atom to use as vector tip point (e.g. C3)? ",&buf); ag.Reset(); if (!ag.ParseAtoms(m,(const char*)buf)) { eprintf("\n Invalid input.\n\n"); goto _again2; } if (ag.m_iAtomGes != 1) { eprintf("\n Please enter only one atom at a time.\n\n"); goto _again2; } obs->m_iaAtomTypes.push_back(ag.m_baAtomType[0]); obs->m_iaAtoms.push_back(((CxIntArray*)ag.m_oaAtoms[0])->GetAt(0)); buf.sprintf("%s%d",(const char*)((CAtom*)g_oaAtoms[ag.m_baRealAtomType[0]])->m_sName,((CxIntArray*)ag.m_oaAtoms[0])->GetAt(0)+1); obs->m_sName += buf; mprintf("\n"); if (AskYesNo(" Add another vector to this observation (y/n)? [no] ",false)) goto _again1; if (!AskYesNo(" Add another observation (y/n)? [no] ",false)) break; mprintf("\n"); } mprintf("\n"); _defdone: m_bHistograms = AskYesNo(" Create histograms of each vector order parameter (y) or only average values (n)? [yes] ",true); if (m_bHistograms) { ti = AskUnsignedInteger(" Which resolution to use for the histograms? [100] ",100); for (z=0;z<(int)m_oaObservations.size();z++) { obs = m_oaObservations[z]; obs->m_pHistogram = new CDF(); obs->m_pHistogram->m_fMinVal = 0.0; obs->m_pHistogram->m_fMaxVal = 180.0; obs->m_pHistogram->m_iResolution = ti; obs->m_pHistogram->Create(); obs->m_pHistogram->SetLabelX("Angle"); obs->m_pHistogram->SetLabelY("Occurrence"); } mprintf("\n"); } for (z=0;z<(int)m_oaObservations.size();z++) { obs = m_oaObservations[z]; obs->m_fAverage = 0; obs->m_fAvgCounter = 0; } if (m_oaObservations.size() > 1) m_bCombined = AskYesNo(" Create an overview datafile with the average values of all order parameters (y/n)? [yes] ",true); else m_bCombined = false; mprintf(WHITE,"\n <<< Analysis %d: Vector-Based Order Parameters <<<\n\n",m_iNumber+1); return true; } void COrderAnalysis_Vector::ProcessStep(CTimeStep *ts) { int z, z2, z3; COrderAnalysis_VectorObs *obs; CxDVector3 vec; CMolecule *m; CSingleMolecule *sm; double tf, tf2; for (z=0;z<(int)m_oaObservations.size();z++) { obs = m_oaObservations[z]; m = (CMolecule*)g_oaMolecules[obs->m_iMolecule]; for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++) { sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]]; for (z3=0;z3<(int)obs->m_iaAtoms.size()/2;z3++) { vec = ts->m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[obs->m_iaAtomTypes[z3*2+1]])->GetAt(obs->m_iaAtoms[z3*2+1])] - ts->m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[obs->m_iaAtomTypes[z3*2]])->GetAt(obs->m_iaAtoms[z3*2])]; vec = FoldVector(vec); vec.Normalize(); tf = DotP(vec,m_vFixedVector); tf2 = 1.5*tf*tf - 0.5; obs->m_fAverage += tf2; obs->m_fAvgCounter++; if (m_bHistograms) obs->m_pHistogram->AddToBin(acos(tf)*180.0/Pi); } } } } void COrderAnalysis_Vector::Finish() { int z /*, z2*/; //double tf , tf2; //std::vector<double> tfa; COrderAnalysis_VectorObs *obs; FILE *a; CxString buf; mprintf(WHITE,"\n *** Vector Order Parameter Analysis %d ***\n\n",m_iNumber+1); for (z=0;z<(int)m_oaObservations.size();z++) { obs = m_oaObservations[z]; mprintf(" Observation %d:\n",z+1); obs->m_fAverage /= obs->m_fAvgCounter; mprintf(" Average value: %.6f\n",obs->m_fAverage); if (m_bHistograms) { buf.sprintf("order_vector%d_histogram%d_%s.csv",m_iNumber+1,z+1,(const char*)obs->m_sName); mprintf(" Writing histogram to %s ...\n",(const char*)buf); obs->m_pHistogram->AngleCorrect(); obs->m_pHistogram->NormBinSum(100.0); obs->m_pHistogram->Integrate(false,1.0); obs->m_pHistogram->Write((const char*)buf,"","",true); /* tfa.resize(obs->m_pHistogram->m_iResolution); for (z2=0;z2<obs->m_pHistogram->m_iResolution;z2++) { tf = -0.5 + 1.5*(z2+0.5)/obs->m_pHistogram->m_iResolution; tf2 = sin(acos(sqrt((tf+0.5)/1.5))); tfa[z2] = obs->m_pHistogram->m_pBin[z2] / tf2 / tf2; } tf = 0; for (z2=0;z2<obs->m_pHistogram->m_iResolution;z2++) tf += tfa[z2]; for (z2=0;z2<obs->m_pHistogram->m_iResolution;z2++) tfa[z2] *= 100.0 / tf; obs->m_pHistogram->NormBinSum(100.0); obs->m_pHistogram->Integrate(false,1.0); a = OpenFileWrite((const char*)buf,true); mfprintf(a,"# Order Parameter; Occurrence; Integral; Corrected Occurrence; Corrected Integral\n"); tf = 0; tf2 = 0; for (z2=0;z2<obs->m_pHistogram->m_iResolution;z2++) { tf += obs->m_pHistogram->m_pBin[z2]; tf2 += tfa[z2]; mfprintf(a,"%f; %f; %f; %f; %f\n", -0.5 + 1.5*(z2+0.5)/obs->m_pHistogram->m_iResolution, obs->m_pHistogram->m_pBin[z2], tf, tfa[z2], tf2); } fclose(a);*/ } mprintf("\n"); } if (m_bCombined) { buf.sprintf("order_vector%d_combined.csv",m_iNumber+1); mprintf(" Creating combined data file %s ...\n",(const char*)buf); a = OpenFileWrite((const char*)buf,true); mfprintf(a,"# Vector Set; Average Order Parameter\n"); for (z=0;z<(int)m_oaObservations.size();z++) mfprintf(a,"%d; %.6f\n",z+1,m_oaObservations[z]->m_fAverage); fclose(a); } }
[ "abreu@eq.ufrj.br" ]
abreu@eq.ufrj.br
30b83604dd1bd39235d6e1c8600a41d8cd333fe9
5aea11aa069a178a10e749906b549e3329eaf10a
/SurfaceClip/qSlicerSurfaceClipModule.cxx
b460937c5e987abd430bef99f880187649546c6e
[]
no_license
cy15196/SurfaceClip
d3dde5ca5ed9422a493d449b57770fc2eb8d9840
89d1e74c38656cb00bd807472250b7ab5a9532ed
refs/heads/master
2020-04-30T14:16:15.171220
2013-06-19T08:16:08
2013-06-19T08:16:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,812
cxx
/*============================================================================== Program: 3D Slicer Portions (c) Copyright Brigham and Women's Hospital (BWH) All Rights Reserved. See COPYRIGHT.txt or http://www.slicer.org/copyright/copyright.txt for details. 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. ==============================================================================*/ // Qt includes #include <QtPlugin> // SurfaceClip Logic includes #include <vtkSlicerSurfaceClipLogic.h> // SurfaceClip includes #include "qSlicerSurfaceClipModule.h" #include "qSlicerSurfaceClipModuleWidget.h" //----------------------------------------------------------------------------- Q_EXPORT_PLUGIN2(qSlicerSurfaceClipModule, qSlicerSurfaceClipModule); //----------------------------------------------------------------------------- /// \ingroup Slicer_QtModules_ExtensionTemplate class qSlicerSurfaceClipModulePrivate { public: qSlicerSurfaceClipModulePrivate(); }; //----------------------------------------------------------------------------- // qSlicerSurfaceClipModulePrivate methods //----------------------------------------------------------------------------- qSlicerSurfaceClipModulePrivate ::qSlicerSurfaceClipModulePrivate() { } //----------------------------------------------------------------------------- // qSlicerSurfaceClipModule methods //----------------------------------------------------------------------------- qSlicerSurfaceClipModule ::qSlicerSurfaceClipModule(QObject* _parent) : Superclass(_parent) , d_ptr(new qSlicerSurfaceClipModulePrivate) { } //----------------------------------------------------------------------------- qSlicerSurfaceClipModule::~qSlicerSurfaceClipModule() { } //----------------------------------------------------------------------------- QString qSlicerSurfaceClipModule::helpText()const { return "This is a loadable module designated to clip a model with a surface."; } //----------------------------------------------------------------------------- QString qSlicerSurfaceClipModule::acknowledgementText()const { return "This work was part of the dissertation of my bachelor degree from " "SJTU."; } //----------------------------------------------------------------------------- QStringList qSlicerSurfaceClipModule::contributors()const { QStringList moduleContributors; moduleContributors << QString("Jun LIN, Xiaojun CHEN"); return moduleContributors; } //----------------------------------------------------------------------------- QIcon qSlicerSurfaceClipModule::icon()const { return QIcon(":/Icons/SurfaceClip.png"); } //----------------------------------------------------------------------------- QStringList qSlicerSurfaceClipModule::categories() const { return QStringList() << "Examples"; } //----------------------------------------------------------------------------- QStringList qSlicerSurfaceClipModule::dependencies() const { return QStringList(); } //----------------------------------------------------------------------------- void qSlicerSurfaceClipModule::setup() { this->Superclass::setup(); } //----------------------------------------------------------------------------- qSlicerAbstractModuleRepresentation * qSlicerSurfaceClipModule ::createWidgetRepresentation() { return new qSlicerSurfaceClipModuleWidget; } //----------------------------------------------------------------------------- vtkMRMLAbstractLogic* qSlicerSurfaceClipModule::createLogic() { return vtkSlicerSurfaceClipLogic::New(); }
[ "xiaojunchen@163.com" ]
xiaojunchen@163.com
8c9dd1aab5efa11eef2f8a1b3723dffeab66f04e
22d4ec8baf3258edf318a7832a169a11e9fd12d1
/Flocking/Font.h
04fef82ddc0f17190057bf629e5534af15fed297
[]
no_license
Laurareilly/EventSystem
fee7f902266f8d9c6766ee8b3eb56517a4e322ef
e219f4499b88373c0d45d48f8f317d36449bfb4f
refs/heads/master
2021-07-22T20:48:47.566374
2017-10-31T00:25:11
2017-10-31T00:25:11
108,455,791
0
0
null
null
null
null
UTF-8
C++
false
false
368
h
#include <RakNet/WindowsIncludes.h> #include <Trackable.h> #include <allegro5/allegro.h> #include <allegro5/allegro_font.h> #include <allegro5/allegro_ttf.h> #include <string> class GraphicsSystem; class Font :public Trackable { public: Font(const std::string& filename, UINT size); ~Font(); private: ALLEGRO_FONT* mpAllegroFont; friend class GraphicsSystem; };
[ "laura.reilly@mymail.champlain.edu" ]
laura.reilly@mymail.champlain.edu
03319fd61996a7716fbfbff203d03db51dbda74a
8b3b851305e3371a0532e81b1bfc6c66866e5fd3
/TCP/client_windows.cpp
77c46e4a3d11000090765afddc6979962f559726
[]
no_license
kali-zhushui/cpp
e0b70de57260c0ff5fe9798b525578aea8206d3a
ed2434e91e05f8d03622d23cd8f203b682235644
refs/heads/master
2020-04-16T01:51:02.414444
2019-01-11T06:06:24
2019-01-11T06:06:24
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,036
cpp
#include <iostream> #include <stdlib.h> #include <string.h> #include "winsock2.h" #pragma comment(lib,"ws2_32.lib") #define PORTNUM 4600 #define SIZE 128 using namespace std; int main(int argc, char *argv[]) { //1¡¢³õʼ»¯Winsock WSADATA wsd; WSAStartup(MAKEWORD(2,2),&wsd); //2¡¢´´½¨socket char buf[SIZE]; SOCKET m_Sockfd; struct sockaddr_in serveraddr; //struct sockaddr_in serveraddrfrom; //SOCKET m_Server[20]; memset(&serveraddr,0,sizeof(struct sockaddr_in)); serveraddr.sin_family=AF_INET; serveraddr.sin_port=htons(PORTNUM); serveraddr.sin_addr.S_un.S_addr=inet_addr("127.0.0.1"); m_Sockfd=socket(AF_INET,SOCK_STREAM,0); while(1){ connect(m_Sockfd,(const struct sockaddr *)&serveraddr,sizeof(struct sockaddr)); cout<<"please input data: "; cin>>buf; send(m_Sockfd,buf,SIZE,0); closesocket(m_Sockfd); } cout << "continue ..."; cin.get(); return 0; }
[ "root@WIN-6F7DNCEHGVO.localdomain" ]
root@WIN-6F7DNCEHGVO.localdomain
a8fb20b4c843fcfb89752275e65e8714df7745b4
b28305dab0be0e03765c62b97bcd7f49a4f8073d
/components/autofill/core/browser/autofill_download_manager_unittest.cc
69e2bd6651638298c5ff59b3cea98dd0eecd24da
[ "BSD-3-Clause" ]
permissive
svarvel/browser-android-tabs
9e5e27e0a6e302a12fe784ca06123e5ce090ced5
bd198b4c7a1aca2f3e91f33005d881f42a8d0c3f
refs/heads/base-72.0.3626.105
2020-04-24T12:16:31.442851
2019-08-02T19:15:36
2019-08-02T19:15:36
171,950,555
1
2
NOASSERTION
2019-08-02T19:15:37
2019-02-21T21:47:44
null
UTF-8
C++
false
false
68,660
cc
// Copyright 2014 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 "components/autofill/core/browser/autofill_download_manager.h" #include <stddef.h> #include <list> #include <memory> #include <utility> #include <vector> #include "base/base64url.h" #include "base/bind.h" #include "base/format_macros.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/task/post_task.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_command_line.h" #include "base/test/scoped_feature_list.h" #include "base/test/scoped_task_environment.h" #include "base/test/test_timeouts.h" #include "base/threading/thread_task_runner_handle.h" #include "components/autofill/core/browser/autofill_field.h" #include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/browser/form_structure.h" #include "components/autofill/core/browser/randomized_encoder.h" #include "components/autofill/core/browser/test_autofill_clock.h" #include "components/autofill/core/browser/test_autofill_driver.h" #include "components/autofill/core/common/autofill_features.h" #include "components/autofill/core/common/autofill_switches.h" #include "components/autofill/core/common/form_data.h" #include "components/prefs/pref_service.h" #include "net/http/http_status_code.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_response.h" #include "net/url_request/url_request_status.h" #include "net/url_request/url_request_test_util.h" #include "services/network/public/cpp/data_element.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/test/test_shared_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h" #include "services/network/test/test_utils.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/third_party/mozilla/url_parse.h" using base::UTF8ToUTF16; using net::test_server::BasicHttpResponse; using net::test_server::EmbeddedTestServer; using net::test_server::HttpRequest; using net::test_server::HttpResponse; namespace autofill { namespace { const int METHOD_GET = 0; const int METHOD_POST = 1; const int CACHE_MISS = 0; const int CACHE_HIT = 1; std::vector<FormStructure*> ToRawPointerVector( const std::vector<std::unique_ptr<FormStructure>>& list) { std::vector<FormStructure*> result; for (const auto& item : list) result.push_back(item.get()); return result; } // Puts all data elements within the response body together in a single // DataElement and return the buffered content as a string. This ensure all // the response body data is utilized. std::string GetStringFromDataElements( const std::vector<network::DataElement>* data_elements) { network::DataElement unified_data_element; auto data_elements_it = data_elements->begin(); if (data_elements_it != data_elements->end()) { unified_data_element.SetToBytes(data_elements_it->bytes(), data_elements_it->length()); } ++data_elements_it; while (data_elements_it != data_elements->end()) { unified_data_element.AppendBytes(data_elements_it->bytes(), data_elements_it->length()); ++data_elements_it; } // Using the std::string constructor with length ensures that we don't rely // on having a termination character to delimit the string. This is the // safest approach. return std::string(unified_data_element.bytes(), unified_data_element.length()); } // Gets the AutofillUploadRequest proto from the HTTP loader request payload. // Will return false if failed to get the proto. bool GetUploadRequestProtoFromRequest( network::TestURLLoaderFactory::PendingRequest* loader_request, AutofillUploadRequest* upload_request) { if (loader_request->request.request_body == nullptr) { return false; } std::string request_body_content = GetStringFromDataElements( loader_request->request.request_body->elements()); if (!upload_request->ParseFromString(request_body_content)) { return false; } return true; } } // namespace // This tests AutofillDownloadManager. AutofillDownloadManagerTest implements // AutofillDownloadManager::Observer and creates an instance of // AutofillDownloadManager. Then it records responses to different initiated // requests, which are verified later. To mock network requests // TestURLLoaderFactory is used, which creates SimpleURLLoaders that do not // go over the wire, but allow calling back HTTP responses directly. // The responses in test are out of order and verify: successful query request, // successful upload request, failed upload request. class AutofillDownloadManagerTest : public AutofillDownloadManager::Observer, public testing::Test { public: AutofillDownloadManagerTest() : test_shared_loader_factory_( base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( &test_url_loader_factory_)), download_manager_(&driver_, this), pref_service_(test::PrefServiceForTesting()) { driver_.SetSharedURLLoaderFactory(test_shared_loader_factory_); } void LimitCache(size_t cache_size) { download_manager_.set_max_form_cache_size(cache_size); } // AutofillDownloadManager::Observer implementation. void OnLoadedServerPredictions( std::string response_xml, const std::vector<std::string>& form_signatures) override { ResponseData response; response.response = std::move(response_xml); response.type_of_response = QUERY_SUCCESSFULL; responses_.push_back(response); } void OnUploadedPossibleFieldTypes() override { ResponseData response; response.type_of_response = UPLOAD_SUCCESSFULL; responses_.push_back(response); } void OnServerRequestError(const std::string& form_signature, AutofillDownloadManager::RequestType request_type, int http_error) override { ResponseData response; response.signature = form_signature; response.error = http_error; response.type_of_response = request_type == AutofillDownloadManager::REQUEST_QUERY ? REQUEST_QUERY_FAILED : REQUEST_UPLOAD_FAILED; responses_.push_back(response); } enum ResponseType { QUERY_SUCCESSFULL, UPLOAD_SUCCESSFULL, REQUEST_QUERY_FAILED, REQUEST_UPLOAD_FAILED, }; struct ResponseData { ResponseType type_of_response; int error; std::string signature; std::string response; ResponseData() : type_of_response(REQUEST_QUERY_FAILED), error(0) {} }; base::MessageLoop message_loop_; std::list<ResponseData> responses_; scoped_refptr<network::SharedURLLoaderFactory> test_shared_loader_factory_; network::TestURLLoaderFactory test_url_loader_factory_; TestAutofillDriver driver_; AutofillDownloadManager download_manager_; std::unique_ptr<PrefService> pref_service_; }; TEST_F(AutofillDownloadManagerTest, QueryAndUploadTest) { base::test::ScopedFeatureList fl; fl.InitAndEnableFeature(features::kAutofillCacheQueryResponses); FormData form; FormFieldData field; field.label = UTF8ToUTF16("username"); field.name = UTF8ToUTF16("username"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("First Name"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Last Name"); field.name = UTF8ToUTF16("lastname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("email"); field.name = UTF8ToUTF16("email"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("email2"); field.name = UTF8ToUTF16("email2"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("password"); field.name = UTF8ToUTF16("password"); field.form_control_type = "password"; form.fields.push_back(field); field.label = base::string16(); field.name = UTF8ToUTF16("Submit"); field.form_control_type = "submit"; form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures; form_structures.push_back(std::make_unique<FormStructure>(form)); form.fields.clear(); field.label = UTF8ToUTF16("address"); field.name = UTF8ToUTF16("address"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("address2"); field.name = UTF8ToUTF16("address2"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("city"); field.name = UTF8ToUTF16("city"); field.form_control_type = "text"; form.fields.push_back(field); field.label = base::string16(); field.name = UTF8ToUTF16("Submit"); field.form_control_type = "submit"; form.fields.push_back(field); form_structures.push_back(std::make_unique<FormStructure>(form)); form.fields.clear(); field.label = UTF8ToUTF16("username"); field.name = UTF8ToUTF16("username"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("password"); field.name = UTF8ToUTF16("password"); field.form_control_type = "password"; form.fields.push_back(field); field.label = base::string16(); field.name = UTF8ToUTF16("Submit"); field.form_control_type = "submit"; form.fields.push_back(field); form_structures.push_back(std::make_unique<FormStructure>(form)); // Make download manager. AutofillDownloadManager download_manager(&driver_, this, "dummykey"); // Request with id 0. base::HistogramTester histogram; EXPECT_TRUE( download_manager.StartQueryRequest(ToRawPointerVector(form_structures))); histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 1); histogram.ExpectUniqueSample("Autofill.Query.Method", METHOD_GET, 1); // Validate if the API key is in the request headers. network::TestURLLoaderFactory::PendingRequest* request = test_url_loader_factory_.GetPendingRequest(0); std::string api_key_header_value; EXPECT_TRUE(request->request.headers.GetHeader("X-Goog-Api-Key", &api_key_header_value)); EXPECT_EQ(api_key_header_value, "dummykey"); // Request with id 1. EXPECT_TRUE(download_manager.StartUploadRequest( *(form_structures[0]), true, ServerFieldTypeSet(), std::string(), true, pref_service_.get())); // Request with id 2. EXPECT_TRUE(download_manager.StartUploadRequest( *(form_structures[1]), false, ServerFieldTypeSet(), std::string(), true, pref_service_.get())); // Request with id 3. Upload request with a non-empty additional password form // signature. EXPECT_TRUE(download_manager.StartUploadRequest(*(form_structures[2]), false, ServerFieldTypeSet(), "42", true, pref_service_.get())); const char* responses[] = { "<autofillqueryresponse>" "<field autofilltype=\"0\" />" "<field autofilltype=\"3\" />" "<field autofilltype=\"5\" />" "<field autofilltype=\"9\" />" "<field autofilltype=\"0\" />" "<field autofilltype=\"30\" />" "<field autofilltype=\"31\" />" "<field autofilltype=\"33\" />" "</autofillqueryresponse>", "", "<html></html>", }; // Return them out of sequence. // Request 1: Successful upload. request = test_url_loader_factory_.GetPendingRequest(1); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, responses[1]); histogram.ExpectBucketCount("Autofill.Upload.HttpResponseOrErrorCode", net::HTTP_OK, 1); // Request 2: Unsuccessful upload. request = test_url_loader_factory_.GetPendingRequest(2); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, network::CreateResourceResponseHead(net::HTTP_NOT_FOUND), responses[2], network::URLLoaderCompletionStatus(net::OK)); histogram.ExpectBucketCount("Autofill.Upload.HttpResponseOrErrorCode", net::HTTP_NOT_FOUND, 1); // Request 0: Successful query. request = test_url_loader_factory_.GetPendingRequest(0); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, responses[0]); EXPECT_EQ(3U, responses_.size()); histogram.ExpectBucketCount("Autofill.Query.WasInCache", CACHE_MISS, 1); histogram.ExpectBucketCount("Autofill.Query.HttpResponseOrErrorCode", net::HTTP_OK, 1); // Check Request 1. EXPECT_EQ(AutofillDownloadManagerTest::UPLOAD_SUCCESSFULL, responses_.front().type_of_response); EXPECT_EQ(0, responses_.front().error); EXPECT_EQ(std::string(), responses_.front().signature); // Expected response on non-query request is an empty string. EXPECT_EQ(std::string(), responses_.front().response); responses_.pop_front(); // Check Request 2. EXPECT_EQ(AutofillDownloadManagerTest::REQUEST_UPLOAD_FAILED, responses_.front().type_of_response); EXPECT_EQ(net::HTTP_NOT_FOUND, responses_.front().error); EXPECT_EQ(form_structures[1]->FormSignatureAsStr(), responses_.front().signature); // Expected response on non-query request is an empty string. EXPECT_EQ(std::string(), responses_.front().response); responses_.pop_front(); // Check Request 0. EXPECT_EQ(responses_.front().type_of_response, AutofillDownloadManagerTest::QUERY_SUCCESSFULL); EXPECT_EQ(0, responses_.front().error); EXPECT_EQ(std::string(), responses_.front().signature); EXPECT_EQ(responses[0], responses_.front().response); responses_.pop_front(); // Modify form structures to miss the cache. field.label = UTF8ToUTF16("Address line 2"); field.name = UTF8ToUTF16("address2"); field.form_control_type = "text"; form.fields.push_back(field); form_structures.push_back(std::make_unique<FormStructure>(form)); // Request with id 4, not successful. EXPECT_TRUE( download_manager.StartQueryRequest(ToRawPointerVector(form_structures))); request = test_url_loader_factory_.GetPendingRequest(4); histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 2); histogram.ExpectUniqueSample("Autofill.Query.Method", METHOD_GET, 2); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, network::CreateResourceResponseHead(net::HTTP_INTERNAL_SERVER_ERROR), responses[0], network::URLLoaderCompletionStatus(net::OK)); histogram.ExpectBucketCount("Autofill.Query.HttpResponseOrErrorCode", net::HTTP_INTERNAL_SERVER_ERROR, 1); // Check Request 4. EXPECT_EQ(AutofillDownloadManagerTest::REQUEST_QUERY_FAILED, responses_.front().type_of_response); EXPECT_EQ(net::HTTP_INTERNAL_SERVER_ERROR, responses_.front().error); // Expected response on non-query request is an empty string. EXPECT_EQ(std::string(), responses_.front().response); responses_.pop_front(); // Request with id 5. Let's pretend we hit the cache. EXPECT_TRUE( download_manager.StartQueryRequest(ToRawPointerVector(form_structures))); histogram.ExpectBucketCount("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 3); histogram.ExpectBucketCount("Autofill.Query.Method", METHOD_GET, 3); request = test_url_loader_factory_.GetPendingRequest(5); network::URLLoaderCompletionStatus status(net::OK); status.exists_in_cache = true; test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, network::CreateResourceResponseHead(net::HTTP_OK), responses[0], status); // Check Request 5. EXPECT_EQ(responses_.front().type_of_response, AutofillDownloadManagerTest::QUERY_SUCCESSFULL); responses_.pop_front(); histogram.ExpectBucketCount("Autofill.Query.WasInCache", CACHE_HIT, 1); // Test query with caching disabled. base::test::ScopedFeatureList fl2; fl2.InitAndDisableFeature(features::kAutofillCacheQueryResponses); // Don't hit the in-mem cache. field.label = UTF8ToUTF16("Address line 3"); field.name = UTF8ToUTF16("address3"); field.form_control_type = "text"; form.fields.push_back(field); form_structures.push_back(std::make_unique<FormStructure>(form)); // Request with id 6 EXPECT_TRUE( download_manager.StartQueryRequest(ToRawPointerVector(form_structures))); histogram.ExpectBucketCount("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 4); histogram.ExpectBucketCount("Autofill.Query.Method", METHOD_POST, 1); request = test_url_loader_factory_.GetPendingRequest(6); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, responses[0]); histogram.ExpectBucketCount("Autofill.Query.WasInCache", CACHE_MISS, 2); } TEST_F(AutofillDownloadManagerTest, QueryAPITest) { base::test::ScopedFeatureList feature_list; feature_list.InitWithFeatures( // Enabled // We want to query the API rather than the legacy server. {features::kAutofillUseApi}, // Disabled {}); // Build the form structures that we want to query. FormData form; FormFieldData field; field.label = UTF8ToUTF16("First Name"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Last Name"); field.name = UTF8ToUTF16("lastname"); field.form_control_type = "text"; form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures; form_structures.push_back(std::make_unique<FormStructure>(form)); AutofillDownloadManager download_manager(&driver_, this, "dummykey"); // Start the query request and look if it is successful. No response was // received yet. base::HistogramTester histogram; EXPECT_TRUE( download_manager.StartQueryRequest(ToRawPointerVector(form_structures))); // Verify if histograms are right. histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 1); histogram.ExpectUniqueSample("Autofill.Query.Method", METHOD_GET, 1); // Inspect the request that the test URL loader sent. network::TestURLLoaderFactory::PendingRequest* request = test_url_loader_factory_.GetPendingRequest(0); // This is the URL we expect to query the API. The sub-path right after // "/page" corresponds to the serialized AutofillPageQueryRequest proto (that // we filled forms in) encoded in base64. The Autofill // https://clients1.google.com/ domain URL corresponds to the default domain // used by the download manager. const std::string expected_url = { "https://clients1.google.com/v1/pages/" "Chc2LjEuMTcxNS4xNDQyL2VuIChHR0xMKRIlCU9O84MyjH9NEgsNeu" "FP4BIAGgAiABILDZxOStASABoAIgAaAA==?" "alt=proto"}; EXPECT_EQ(request->request.url, expected_url); std::string api_key_header_value; EXPECT_TRUE(request->request.headers.GetHeader("X-Goog-Api-Key", &api_key_header_value)); EXPECT_EQ(api_key_header_value, "dummykey"); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, "dummy response"); // Upon reception of a suggestions query, we expect OnLoadedServerPredictions // to be called back from the observer and some histograms be incremented. EXPECT_EQ(1U, responses_.size()); EXPECT_EQ(responses_.front().type_of_response, AutofillDownloadManagerTest::QUERY_SUCCESSFULL); histogram.ExpectBucketCount("Autofill.Query.WasInCache", CACHE_MISS, 1); histogram.ExpectBucketCount("Autofill.Query.HttpResponseOrErrorCode", net::HTTP_OK, 1); } // Test whether uploading vote content to the API is done right. We only do some // spot checks. No thorough testing is done here. Using the API does not add new // upload logic. // // We expect the download manager to do the following things: // * Use the right API canonical URL when uploading. // * Serialize the upload proto content using the API upload request proto. TEST_F(AutofillDownloadManagerTest, UploadToAPITest) { base::test::ScopedFeatureList feature_list; feature_list.InitWithFeatures( // Enabled // We want to query the API rather than the legacy server. {features::kAutofillUseApi}, // Disabled // We don't want upload throttling for testing purpose. {features::kAutofillUploadThrottling}); // Build the form structures that we want to query. FormData form; FormFieldData field; field.label = UTF8ToUTF16("First Name"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Last Name"); field.name = UTF8ToUTF16("lastname"); field.form_control_type = "text"; form.fields.push_back(field); FormStructure form_structure(form); form_structure.set_submission_source(SubmissionSource::FORM_SUBMISSION); std::unique_ptr<PrefService> pref_service = test::PrefServiceForTesting(); AutofillDownloadManager download_manager(&driver_, this, "dummykey"); EXPECT_TRUE(download_manager.StartUploadRequest(form_structure, true, ServerFieldTypeSet(), "", true, pref_service.get())); // Inspect the request that the test URL loader sent. network::TestURLLoaderFactory::PendingRequest* request = test_url_loader_factory_.GetPendingRequest(0); // This is the URL we expect to upload votes to the API. The Autofill // https://clients1.google.com/ domain URL corresponds to the // default one used by the download manager. Request upload data is in the // payload when uploading. const std::string expected_url = "https://clients1.google.com/v1/forms:vote?alt=proto"; EXPECT_EQ(request->request.url, expected_url); std::string api_key_header_value; EXPECT_TRUE(request->request.headers.GetHeader("X-Goog-Api-Key", &api_key_header_value)); EXPECT_EQ(api_key_header_value, "dummykey"); // Assert some of the fields within the uploaded proto to make sure it was // filled with something else than default data. base::HistogramTester histogram; AutofillUploadRequest upload_request; EXPECT_TRUE(GetUploadRequestProtoFromRequest(request, &upload_request)); EXPECT_GT(upload_request.upload().client_version().size(), 0U); EXPECT_EQ(upload_request.upload().form_signature(), form_structure.form_signature()); // Trigger an upload response from the API and assert upload response content. test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, ""); // Upon reception of a suggestions query, we expect // OnUploadedPossibleFieldTypes to be called back from the observer and some // histograms be incremented. EXPECT_EQ(1U, responses_.size()); // Request should be upload and successful. EXPECT_EQ(AutofillDownloadManagerTest::UPLOAD_SUCCESSFULL, responses_.front().type_of_response); // We expect the request to be OK and corresponding response code to be // counted. histogram.ExpectBucketCount("Autofill.Upload.HttpResponseOrErrorCode", net::HTTP_OK, 1); } TEST_F(AutofillDownloadManagerTest, BackoffLogic_Query) { FormData form; FormFieldData field; field.label = UTF8ToUTF16("address"); field.name = UTF8ToUTF16("address"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("address2"); field.name = UTF8ToUTF16("address2"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("city"); field.name = UTF8ToUTF16("city"); field.form_control_type = "text"; form.fields.push_back(field); field.label = base::string16(); field.name = UTF8ToUTF16("Submit"); field.form_control_type = "submit"; form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures; form_structures.push_back(std::make_unique<FormStructure>(form)); // Request with id 0. base::HistogramTester histogram; EXPECT_TRUE( download_manager_.StartQueryRequest(ToRawPointerVector(form_structures))); histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 1); auto* request = test_url_loader_factory_.GetPendingRequest(0); // Request error incurs a retry after 1 second. test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, network::CreateResourceResponseHead(net::HTTP_INTERNAL_SERVER_ERROR), "", network::URLLoaderCompletionStatus(net::OK)); EXPECT_EQ(1U, responses_.size()); EXPECT_LT(download_manager_.loader_backoff_.GetTimeUntilRelease(), base::TimeDelta::FromMilliseconds(1100)); base::RunLoop run_loop; base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(1100)); run_loop.Run(); // Get the retried request. request = test_url_loader_factory_.GetPendingRequest(1); // Next error incurs a retry after 2 seconds. test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, network::CreateResourceResponseHead(net::HTTP_REQUEST_ENTITY_TOO_LARGE), "<html></html>", network::URLLoaderCompletionStatus(net::OK)); EXPECT_EQ(2U, responses_.size()); EXPECT_LT(download_manager_.loader_backoff_.GetTimeUntilRelease(), base::TimeDelta::FromMilliseconds(2100)); // There should not be an additional retry. ASSERT_EQ(test_url_loader_factory_.NumPending(), 0); histogram.ExpectBucketCount("Autofill.Query.HttpResponseOrErrorCode", net::HTTP_REQUEST_ENTITY_TOO_LARGE, 1); auto buckets = histogram.GetAllSamples("Autofill.Query.FailingPayloadSize"); ASSERT_EQ(1U, buckets.size()); EXPECT_EQ(2, buckets[0].count); } TEST_F(AutofillDownloadManagerTest, BackoffLogic_Upload) { FormData form; FormFieldData field; field.label = UTF8ToUTF16("address"); field.name = UTF8ToUTF16("address"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("address2"); field.name = UTF8ToUTF16("address2"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("city"); field.name = UTF8ToUTF16("city"); field.form_control_type = "text"; form.fields.push_back(field); field.label = base::string16(); field.name = UTF8ToUTF16("Submit"); field.form_control_type = "submit"; form.fields.push_back(field); auto form_structure = std::make_unique<FormStructure>(form); form_structure->set_submission_source(SubmissionSource::FORM_SUBMISSION); // Request with id 0. EXPECT_TRUE(download_manager_.StartUploadRequest( *form_structure, true, ServerFieldTypeSet(), std::string(), true, pref_service_.get())); auto* request = test_url_loader_factory_.GetPendingRequest(0); // Error incurs a retry after 1 second. test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, network::CreateResourceResponseHead(net::HTTP_INTERNAL_SERVER_ERROR), "", network::URLLoaderCompletionStatus(net::OK)); EXPECT_EQ(1U, responses_.size()); EXPECT_LT(download_manager_.loader_backoff_.GetTimeUntilRelease(), base::TimeDelta::FromMilliseconds(1100)); base::RunLoop run_loop; base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(1100)); run_loop.Run(); // Check that it was a failure. EXPECT_EQ(AutofillDownloadManagerTest::REQUEST_UPLOAD_FAILED, responses_.front().type_of_response); EXPECT_EQ(net::HTTP_INTERNAL_SERVER_ERROR, responses_.front().error); EXPECT_EQ(form_structure->FormSignatureAsStr(), responses_.front().signature); // Expected response on non-query request is an empty string. EXPECT_EQ(std::string(), responses_.front().response); responses_.pop_front(); // Get the retried request, and make it successful. request = test_url_loader_factory_.GetPendingRequest(1); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, ""); // Check success of response. EXPECT_EQ(AutofillDownloadManagerTest::UPLOAD_SUCCESSFULL, responses_.front().type_of_response); EXPECT_EQ(0, responses_.front().error); EXPECT_EQ(std::string(), responses_.front().signature); // Expected response on non-query request is an empty string. EXPECT_EQ(std::string(), responses_.front().response); responses_.pop_front(); // Validate no retry on sending a bad request. form_structure->set_submission_source(SubmissionSource::XHR_SUCCEEDED); base::HistogramTester histogram; EXPECT_TRUE(download_manager_.StartUploadRequest( *form_structure, true, ServerFieldTypeSet(), std::string(), true, pref_service_.get())); request = test_url_loader_factory_.GetPendingRequest(2); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, network::CreateResourceResponseHead(net::HTTP_REQUEST_ENTITY_TOO_LARGE), "", network::URLLoaderCompletionStatus(net::OK)); ASSERT_EQ(test_url_loader_factory_.NumPending(), 0); histogram.ExpectBucketCount("Autofill.Upload.HttpResponseOrErrorCode", net::HTTP_REQUEST_ENTITY_TOO_LARGE, 1); auto buckets = histogram.GetAllSamples("Autofill.Upload.FailingPayloadSize"); ASSERT_EQ(1U, buckets.size()); EXPECT_EQ(1, buckets[0].count); } TEST_F(AutofillDownloadManagerTest, QueryTooManyFieldsTest) { // Create a query that contains too many fields for the server. std::vector<FormData> forms(21); std::vector<std::unique_ptr<FormStructure>> form_structures; for (auto& form : forms) { for (size_t i = 0; i < 5; ++i) { FormFieldData field; field.label = base::IntToString16(i); field.name = base::IntToString16(i); field.form_control_type = "text"; form.fields.push_back(field); } form_structures.push_back(std::make_unique<FormStructure>(form)); } // Check whether the query is aborted. EXPECT_FALSE( download_manager_.StartQueryRequest(ToRawPointerVector(form_structures))); } TEST_F(AutofillDownloadManagerTest, QueryNotTooManyFieldsTest) { // Create a query that contains a lot of fields, but not too many for the // server. std::vector<FormData> forms(25); std::vector<std::unique_ptr<FormStructure>> form_structures; for (auto& form : forms) { for (size_t i = 0; i < 4; ++i) { FormFieldData field; field.label = base::IntToString16(i); field.name = base::IntToString16(i); field.form_control_type = "text"; form.fields.push_back(field); } form_structures.push_back(std::make_unique<FormStructure>(form)); } // Check that the query is not aborted. EXPECT_TRUE( download_manager_.StartQueryRequest(ToRawPointerVector(form_structures))); } TEST_F(AutofillDownloadManagerTest, CacheQueryTest) { FormData form; FormFieldData field; field.form_control_type = "text"; field.label = UTF8ToUTF16("username"); field.name = UTF8ToUTF16("username"); form.fields.push_back(field); field.label = UTF8ToUTF16("First Name"); field.name = UTF8ToUTF16("firstname"); form.fields.push_back(field); field.label = UTF8ToUTF16("Last Name"); field.name = UTF8ToUTF16("lastname"); form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures0; form_structures0.push_back(std::make_unique<FormStructure>(form)); // Add a slightly different form, which should result in a different request. field.label = UTF8ToUTF16("email"); field.name = UTF8ToUTF16("email"); form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures1; form_structures1.push_back(std::make_unique<FormStructure>(form)); // Add another slightly different form, which should also result in a // different request. field.label = UTF8ToUTF16("email2"); field.name = UTF8ToUTF16("email2"); form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures2; form_structures2.push_back(std::make_unique<FormStructure>(form)); // Limit cache to two forms. LimitCache(2); const char *responses[] = { "<autofillqueryresponse>" "<field autofilltype=\"0\" />" "<field autofilltype=\"3\" />" "<field autofilltype=\"5\" />" "</autofillqueryresponse>", "<autofillqueryresponse>" "<field autofilltype=\"0\" />" "<field autofilltype=\"3\" />" "<field autofilltype=\"5\" />" "<field autofilltype=\"9\" />" "</autofillqueryresponse>", "<autofillqueryresponse>" "<field autofilltype=\"0\" />" "<field autofilltype=\"3\" />" "<field autofilltype=\"5\" />" "<field autofilltype=\"9\" />" "<field autofilltype=\"0\" />" "</autofillqueryresponse>", }; base::HistogramTester histogram; // Request with id 0. EXPECT_TRUE(download_manager_.StartQueryRequest( ToRawPointerVector(form_structures0))); histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 1); // No responses yet EXPECT_EQ(0U, responses_.size()); auto* request = test_url_loader_factory_.GetPendingRequest(0); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, responses[0]); ASSERT_EQ(1U, responses_.size()); EXPECT_EQ(responses[0], responses_.front().response); responses_.clear(); // No actual request - should be a cache hit. EXPECT_TRUE(download_manager_.StartQueryRequest( ToRawPointerVector(form_structures0))); histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 2); // Data is available immediately from cache - no over-the-wire trip. ASSERT_EQ(1U, responses_.size()); EXPECT_EQ(responses[0], responses_.front().response); responses_.clear(); // Request with id 1. EXPECT_TRUE(download_manager_.StartQueryRequest( ToRawPointerVector(form_structures1))); histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 3); // No responses yet EXPECT_EQ(0U, responses_.size()); request = test_url_loader_factory_.GetPendingRequest(1); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, responses[1]); ASSERT_EQ(1U, responses_.size()); EXPECT_EQ(responses[1], responses_.front().response); responses_.clear(); // Request with id 2. EXPECT_TRUE(download_manager_.StartQueryRequest( ToRawPointerVector(form_structures2))); histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 4); request = test_url_loader_factory_.GetPendingRequest(2); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, responses[2]); ASSERT_EQ(1U, responses_.size()); EXPECT_EQ(responses[2], responses_.front().response); responses_.clear(); // No actual requests - should be a cache hit. EXPECT_TRUE(download_manager_.StartQueryRequest( ToRawPointerVector(form_structures1))); histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 5); EXPECT_TRUE(download_manager_.StartQueryRequest( ToRawPointerVector(form_structures2))); histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 6); ASSERT_EQ(2U, responses_.size()); EXPECT_EQ(responses[1], responses_.front().response); EXPECT_EQ(responses[2], responses_.back().response); responses_.clear(); // The first structure should have expired. // Request with id 3. EXPECT_TRUE(download_manager_.StartQueryRequest( ToRawPointerVector(form_structures0))); histogram.ExpectUniqueSample("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 7); // No responses yet EXPECT_EQ(0U, responses_.size()); request = test_url_loader_factory_.GetPendingRequest(3); test_url_loader_factory_.SimulateResponseWithoutRemovingFromPendingList( request, responses[0]); ASSERT_EQ(1U, responses_.size()); EXPECT_EQ(responses[0], responses_.front().response); } namespace { enum ServerCommuncationMode { DISABLED, FINCHED_URL, COMMAND_LINE_URL, DEFAULT_URL }; class AutofillServerCommunicationTest : public AutofillDownloadManager::Observer, public testing::TestWithParam<ServerCommuncationMode> { protected: void SetUp() override { testing::TestWithParam<ServerCommuncationMode>::SetUp(); pref_service_ = test::PrefServiceForTesting(); scoped_feature_list_1_.InitWithFeatures( // Enabled {features::kAutofillCacheQueryResponses, features::kAutofillUploadThrottling}, // Disabled {}); // Setup the server. server_.RegisterRequestHandler( base::BindRepeating(&AutofillServerCommunicationTest::RequestHandler, base::Unretained(this))); ASSERT_TRUE(server_.Start()); GURL autofill_server_url(server_.base_url().Resolve("/tbproxy/af/")); ASSERT_TRUE(autofill_server_url.is_valid()); // Intialize the autofill driver. shared_url_loader_factory_ = base::MakeRefCounted<network::TestSharedURLLoaderFactory>(); driver_ = std::make_unique<TestAutofillDriver>(); driver_->SetSharedURLLoaderFactory(shared_url_loader_factory_); // Configure the autofill server communications channel. switch (GetParam()) { case DISABLED: scoped_feature_list_2_.InitAndDisableFeature( features::kAutofillServerCommunication); break; case FINCHED_URL: scoped_feature_list_2_.InitAndEnableFeatureWithParameters( features::kAutofillServerCommunication, {{switches::kAutofillServerURL, autofill_server_url.spec()}}); break; case COMMAND_LINE_URL: scoped_command_line_.GetProcessCommandLine()->AppendSwitchASCII( switches::kAutofillServerURL, autofill_server_url.spec()); FALLTHROUGH; case DEFAULT_URL: scoped_feature_list_2_.InitAndEnableFeature( features::kAutofillServerCommunication); break; default: ASSERT_TRUE(false); } } void TearDown() override { if (server_.Started()) ASSERT_TRUE(server_.ShutdownAndWaitUntilComplete()); } // AutofillDownloadManager::Observer implementation. void OnLoadedServerPredictions( std::string /* response_xml */, const std::vector<std::string>& /*form_signatures */) override { ASSERT_TRUE(run_loop_); run_loop_->QuitWhenIdle(); } void OnUploadedPossibleFieldTypes() override { ASSERT_TRUE(run_loop_); run_loop_->QuitWhenIdle(); } // Helper to extract the value of a query param. Returns "*** not found ***" // if the requested query param is not in the query string. std::string GetQueryParam(const std::string& query_str, const std::string& param_name) { url::Component query(0, query_str.length()); url::Component key, value; while (url::ExtractQueryKeyValue(query_str.c_str(), &query, &key, &value)) { base::StringPiece key_string(query_str.c_str() + key.begin, key.len); base::StringPiece param_text(query_str.c_str() + value.begin, value.len); std::string param_value; if (key_string == param_name && base::Base64UrlDecode(param_text, base::Base64UrlDecodePolicy::REQUIRE_PADDING, &param_value)) { return param_value; } } return "*** not found ***"; } std::unique_ptr<HttpResponse> RequestHandler(const HttpRequest& request) { GURL absolute_url = server_.GetURL(request.relative_url); ++call_count_; if (absolute_url.path() == "/tbproxy/af/query") { payloads_.push_back(!request.content.empty() ? request.content : GetQueryParam(absolute_url.query(), "q")); AutofillQueryResponseContents proto; proto.add_field()->set_overall_type_prediction(NAME_FIRST); auto response = std::make_unique<BasicHttpResponse>(); response->set_code(net::HTTP_OK); response->set_content(proto.SerializeAsString()); response->set_content_type("text/proto"); response->AddCustomHeader( "Cache-Control", base::StringPrintf("max-age=%" PRId64, base::TimeDelta::FromMilliseconds( cache_expiration_in_milliseconds_) .InSeconds())); return response; } if (absolute_url.path() == "/tbproxy/af/upload") { payloads_.push_back(request.content); auto response = std::make_unique<BasicHttpResponse>(); response->set_code(net::HTTP_OK); return response; } return nullptr; } bool SendQueryRequest( const std::vector<std::unique_ptr<FormStructure>>& form_structures) { EXPECT_EQ(run_loop_, nullptr); run_loop_ = std::make_unique<base::RunLoop>(); AutofillDownloadManager download_manager(driver_.get(), this); bool succeeded = download_manager.StartQueryRequest(ToRawPointerVector(form_structures)); if (succeeded) run_loop_->Run(); run_loop_.reset(); return succeeded; } bool SendUploadRequest(const FormStructure& form, bool form_was_autofilled, const ServerFieldTypeSet& available_field_types, const std::string& login_form_signature, bool observed_submission) { EXPECT_EQ(run_loop_, nullptr); run_loop_ = std::make_unique<base::RunLoop>(); AutofillDownloadManager download_manager(driver_.get(), this); bool succeeded = download_manager.StartUploadRequest( form, form_was_autofilled, available_field_types, login_form_signature, observed_submission, pref_service_.get()); if (succeeded) run_loop_->Run(); run_loop_.reset(); return succeeded; } base::test::ScopedTaskEnvironment scoped_task_environment_{ base::test::ScopedTaskEnvironment::MainThreadType::IO}; base::test::ScopedCommandLine scoped_command_line_; base::test::ScopedFeatureList scoped_feature_list_1_; base::test::ScopedFeatureList scoped_feature_list_2_; EmbeddedTestServer server_; int cache_expiration_in_milliseconds_ = 100000; std::unique_ptr<base::RunLoop> run_loop_; size_t call_count_ = 0; scoped_refptr<network::TestSharedURLLoaderFactory> shared_url_loader_factory_; std::unique_ptr<TestAutofillDriver> driver_; std::unique_ptr<PrefService> pref_service_; std::vector<std::string> payloads_; }; } // namespace TEST_P(AutofillServerCommunicationTest, IsEnabled) { AutofillDownloadManager download_manager(driver_.get(), this); EXPECT_EQ(download_manager.IsEnabled(), GetParam() != DISABLED); } TEST_P(AutofillServerCommunicationTest, Query) { FormData form; FormFieldData field; field.label = UTF8ToUTF16("First Name:"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures; form_structures.push_back(std::make_unique<FormStructure>(form)); EXPECT_EQ(GetParam() != DISABLED, SendQueryRequest(form_structures)); } TEST_P(AutofillServerCommunicationTest, Upload) { FormData form; FormFieldData field; field.label = UTF8ToUTF16("First Name:"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Last Name:"); field.name = UTF8ToUTF16("lastname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Email:"); field.name = UTF8ToUTF16("email"); field.form_control_type = "text"; form.fields.push_back(field); AutofillDownloadManager download_manager(driver_.get(), this); EXPECT_EQ(GetParam() != DISABLED, SendUploadRequest(FormStructure(form), true, {}, "", true)); } // Note that we omit DEFAULT_URL from the test params. We don't actually want // the tests to hit the production server. INSTANTIATE_TEST_CASE_P(All, AutofillServerCommunicationTest, ::testing::Values(DISABLED, FINCHED_URL, COMMAND_LINE_URL)); using AutofillQueryTest = AutofillServerCommunicationTest; TEST_P(AutofillQueryTest, CacheableResponse) { FormFieldData field; field.label = UTF8ToUTF16("First Name:"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; FormData form; form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures; form_structures.push_back(std::make_unique<FormStructure>(form)); // Query for the form. This should go to the embedded server. { SCOPED_TRACE("First Query"); base::HistogramTester histogram; call_count_ = 0; ASSERT_TRUE(SendQueryRequest(form_structures)); EXPECT_EQ(1u, call_count_); histogram.ExpectBucketCount("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 1); histogram.ExpectBucketCount("Autofill.Query.Method", METHOD_GET, 1); histogram.ExpectBucketCount("Autofill.Query.WasInCache", CACHE_MISS, 1); } // Query again the next day. This should go to the cache, since the max-age // for the cached response is 2 days. { SCOPED_TRACE("Second Query"); base::HistogramTester histogram; call_count_ = 0; ASSERT_TRUE(SendQueryRequest(form_structures)); EXPECT_EQ(0u, call_count_); histogram.ExpectBucketCount("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 1); histogram.ExpectBucketCount("Autofill.Query.Method", METHOD_GET, 1); histogram.ExpectBucketCount("Autofill.Query.WasInCache", CACHE_HIT, 1); } } TEST_P(AutofillQueryTest, ExpiredCacheInResponse) { FormFieldData field; field.label = UTF8ToUTF16("First Name:"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; FormData form; form.fields.push_back(field); std::vector<std::unique_ptr<FormStructure>> form_structures; form_structures.push_back(std::make_unique<FormStructure>(form)); // Set the cache expiration interval to 0. cache_expiration_in_milliseconds_ = 0; // Query for the form. This should go to the embedded server. { SCOPED_TRACE("First Query"); base::HistogramTester histogram; call_count_ = 0; ASSERT_TRUE(SendQueryRequest(form_structures)); EXPECT_EQ(1u, call_count_); histogram.ExpectBucketCount("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 1); histogram.ExpectBucketCount("Autofill.Query.Method", METHOD_GET, 1); histogram.ExpectBucketCount("Autofill.Query.WasInCache", CACHE_MISS, 1); } // The cache entry had a max age of 0 ms, so delaying only a few milliseconds // ensures the cache expires and no request are served by cached content // (ie this should go to the embedded server). base::RunLoop run_loop; base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(100)); run_loop.Run(); { SCOPED_TRACE("Second Query"); base::HistogramTester histogram; call_count_ = 0; ASSERT_TRUE(SendQueryRequest(form_structures)); EXPECT_EQ(1u, call_count_); histogram.ExpectBucketCount("Autofill.ServerQueryResponse", AutofillMetrics::QUERY_SENT, 1); histogram.ExpectBucketCount("Autofill.Query.Method", METHOD_GET, 1); histogram.ExpectBucketCount("Autofill.Query.WasInCache", CACHE_MISS, 1); } } TEST_P(AutofillQueryTest, RichMetadata_Enabled) { // Initialize a form. Note that this state is post-parse. FormData form; form.origin = GURL("https://origin.com"); form.action = GURL("https://origin.com/submit-me"); form.id_attribute = UTF8ToUTF16("form-id-attribute"); form.name_attribute = UTF8ToUTF16("form-name-attribute"); form.name = form.name_attribute; // Add field 0. FormFieldData field; field.id_attribute = UTF8ToUTF16("field-id-attribute-1"); field.name_attribute = UTF8ToUTF16("field-name-attribute-1"); field.name = field.name_attribute; field.label = UTF8ToUTF16("field-label"); field.aria_label = UTF8ToUTF16("field-aria-label"); field.aria_description = UTF8ToUTF16("field-aria-description"); field.form_control_type = "text"; field.css_classes = UTF8ToUTF16("field-css-classes"); field.placeholder = UTF8ToUTF16("field-placeholder"); form.fields.push_back(field); // Add field 1. field.id_attribute = UTF8ToUTF16("field-id-attribute-2"); field.name_attribute = UTF8ToUTF16("field-name-attribute-2"); field.name = field.name_attribute; field.label = UTF8ToUTF16("field-label"); field.aria_label = UTF8ToUTF16("field-aria-label"); field.aria_description = UTF8ToUTF16("field-aria-description"); field.form_control_type = "text"; field.css_classes = UTF8ToUTF16("field-css-classes"); field.placeholder = UTF8ToUTF16("field-placeholder"); form.fields.push_back(field); // Add field 2. field.id_attribute = UTF8ToUTF16("field-id-attribute-3"); field.name_attribute = UTF8ToUTF16("field-name-attribute-3"); field.name = field.name_attribute; field.label = UTF8ToUTF16("field-label"); field.aria_label = UTF8ToUTF16("field-aria-label"); field.aria_description = UTF8ToUTF16("field-aria-description"); field.form_control_type = "text"; field.css_classes = UTF8ToUTF16("field-css-classes"); field.placeholder = UTF8ToUTF16("field-placeholder"); form.fields.push_back(field); // Setup the form structures to query. AutofillDownloadManager download_manager(driver_.get(), this); std::vector<std::unique_ptr<FormStructure>> form_structures; form_structures.push_back(std::make_unique<FormStructure>(form)); // Turn on rich query encoding. form_structures.front()->set_is_rich_query_enabled(true); // Generate a query request. ASSERT_TRUE(SendQueryRequest(form_structures)); EXPECT_EQ(1u, call_count_); // We should have intercepted exactly on query request. Parse it. ASSERT_EQ(1u, payloads_.size()); AutofillQueryContents query; ASSERT_TRUE(query.ParseFromString(payloads_.front())); // Validate that we have one form in the query. ASSERT_EQ(query.form_size(), 1); const auto& query_form = query.form(0); // The form should have metadata, and the metadata value should be equal // those initialized above. ASSERT_TRUE(query_form.has_form_metadata()); EXPECT_EQ(UTF8ToUTF16(query_form.form_metadata().id().encoded_bits()), form.id_attribute); EXPECT_EQ(UTF8ToUTF16(query_form.form_metadata().name().encoded_bits()), form.name_attribute); // The form should have 3 fields, and their metadata value should be equal // those initialized above. ASSERT_EQ(3, query_form.field_size()); ASSERT_EQ(static_cast<int>(form.fields.size()), query_form.field_size()); for (int i = 0; i < query_form.field_size(); ++i) { const auto& query_field = query_form.field(i); const auto& form_field = form.fields[i]; ASSERT_TRUE(query_field.has_field_metadata()); const auto& meta = query_field.field_metadata(); EXPECT_EQ(UTF8ToUTF16(meta.id().encoded_bits()), form_field.id_attribute); EXPECT_EQ(UTF8ToUTF16(meta.name().encoded_bits()), form_field.name_attribute); EXPECT_EQ(meta.type().encoded_bits(), form_field.form_control_type); EXPECT_EQ(UTF8ToUTF16(meta.label().encoded_bits()), form_field.label); EXPECT_EQ(UTF8ToUTF16(meta.aria_label().encoded_bits()), form_field.aria_label); EXPECT_EQ(UTF8ToUTF16(meta.aria_description().encoded_bits()), form_field.aria_description); EXPECT_EQ(UTF8ToUTF16(meta.css_class().encoded_bits()), form_field.css_classes); EXPECT_EQ(UTF8ToUTF16(meta.placeholder().encoded_bits()), form_field.placeholder); } } TEST_P(AutofillQueryTest, RichMetadata_Disabled) { // Initialize a form. Note that this state is post-parse. FormData form; form.origin = GURL("https://origin.com"); form.action = GURL("https://origin.com/submit-me"); form.id_attribute = UTF8ToUTF16("form-id-attribute"); form.name_attribute = UTF8ToUTF16("form-name-attribute"); form.name = form.name_attribute; // Add field 0. FormFieldData field; field.id_attribute = UTF8ToUTF16("field-id-attribute-1"); field.name_attribute = UTF8ToUTF16("field-name-attribute-1"); field.name = field.name_attribute; field.label = UTF8ToUTF16("field-label"); field.aria_label = UTF8ToUTF16("field-aria-label"); field.aria_description = UTF8ToUTF16("field-aria-description"); field.form_control_type = "text"; field.css_classes = UTF8ToUTF16("field-css-classes"); field.placeholder = UTF8ToUTF16("field-placeholder"); form.fields.push_back(field); // Add field 1. field.id_attribute = UTF8ToUTF16("field-id-attribute-2"); field.name_attribute = UTF8ToUTF16("field-name-attribute-2"); field.name = field.name_attribute; field.label = UTF8ToUTF16("field-label"); field.aria_label = UTF8ToUTF16("field-aria-label"); field.aria_description = UTF8ToUTF16("field-aria-description"); field.form_control_type = "text"; field.css_classes = UTF8ToUTF16("field-css-classes"); field.placeholder = UTF8ToUTF16("field-placeholder"); form.fields.push_back(field); // Add field 2. field.id_attribute = UTF8ToUTF16("field-id-attribute-3"); field.name_attribute = UTF8ToUTF16("field-name-attribute-3"); field.name = field.name_attribute; field.label = UTF8ToUTF16("field-label"); field.aria_label = UTF8ToUTF16("field-aria-label"); field.aria_description = UTF8ToUTF16("field-aria-description"); field.form_control_type = "text"; field.css_classes = UTF8ToUTF16("field-css-classes"); field.placeholder = UTF8ToUTF16("field-placeholder"); form.fields.push_back(field); // Setup the form structures to query. AutofillDownloadManager download_manager(driver_.get(), this); std::vector<std::unique_ptr<FormStructure>> form_structures; form_structures.push_back(std::make_unique<FormStructure>(form)); // Turn off rich query encoding. form_structures.front()->set_is_rich_query_enabled(false); // Generate a query request. ASSERT_TRUE(SendQueryRequest(form_structures)); EXPECT_EQ(1u, call_count_); // We should have intercepted exactly on query request. Parse it. ASSERT_EQ(1u, payloads_.size()); AutofillQueryContents query; ASSERT_TRUE(query.ParseFromString(payloads_.front())); // Validate that we have one form in the query. ASSERT_EQ(query.form_size(), 1); const auto& query_form = query.form(0); // There should be no encoded metadata for the form. EXPECT_FALSE(query_form.has_form_metadata()); // There should be three fields, none of which have encoded metadata. ASSERT_EQ(3, query_form.field_size()); ASSERT_EQ(static_cast<int>(form.fields.size()), query_form.field_size()); for (int i = 0; i < query_form.field_size(); ++i) { const auto& query_field = query_form.field(i); EXPECT_FALSE(query_field.has_field_metadata()); } } // Note that we omit DEFAULT_URL from the test params. We don't actually want // the tests to hit the production server. We also excluded DISABLED, since // these tests exercise "enabled" functionality. INSTANTIATE_TEST_CASE_P(All, AutofillQueryTest, ::testing::Values(FINCHED_URL, COMMAND_LINE_URL)); using AutofillUploadTest = AutofillServerCommunicationTest; TEST_P(AutofillUploadTest, RichMetadata) { base::test::ScopedFeatureList local_feature; local_feature.InitAndEnableFeature(features::kAutofillMetadataUploads); FormData form; form.origin = GURL("https://origin.com"); form.action = GURL("https://origin.com/submit-me"); form.id_attribute = UTF8ToUTF16("form-id_attribute"); form.name_attribute = UTF8ToUTF16("form-id_attribute"); form.name = form.name_attribute; FormFieldData field; field.id_attribute = UTF8ToUTF16("field-id-attribute-1"); field.name_attribute = UTF8ToUTF16("field-name-attribute-1"); field.name = field.name_attribute; field.label = UTF8ToUTF16("field-label"); field.aria_label = UTF8ToUTF16("field-aria-label"); field.aria_description = UTF8ToUTF16("field-aria-descriptionm"); field.form_control_type = "text"; field.css_classes = UTF8ToUTF16("field-css-classes"); field.placeholder = UTF8ToUTF16("field-placeholder"); form.fields.push_back(field); field.id_attribute = UTF8ToUTF16("field-id-attribute-2"); field.name_attribute = UTF8ToUTF16("field-name-attribute-2"); field.name = field.name_attribute; field.label = UTF8ToUTF16("field-label"); field.aria_label = UTF8ToUTF16("field-aria-label"); field.aria_description = UTF8ToUTF16("field-aria-descriptionm"); field.form_control_type = "text"; field.css_classes = UTF8ToUTF16("field-css-classes"); field.placeholder = UTF8ToUTF16("field-placeholder"); form.fields.push_back(field); field.id_attribute = UTF8ToUTF16("field-id-attribute-3"); field.name_attribute = UTF8ToUTF16("field-name-attribute-3"); field.name = field.name_attribute; field.label = UTF8ToUTF16("field-label"); field.aria_label = UTF8ToUTF16("field-aria-label"); field.aria_description = UTF8ToUTF16("field-aria-descriptionm"); field.form_control_type = "text"; field.css_classes = UTF8ToUTF16("field-css-classes"); field.placeholder = UTF8ToUTF16("field-placeholder"); form.fields.push_back(field); AutofillDownloadManager download_manager(driver_.get(), this); FormStructure form_structure(form); form_structure.set_page_language("fr-ca"); for (int i = 0; i < 8; ++i) { SCOPED_TRACE(base::StringPrintf("submission source = %d", i)); base::HistogramTester histogram_tester; auto submission_source = static_cast<SubmissionSource>(i); form_structure.set_submission_source(submission_source); form_structure.set_randomized_encoder( RandomizedEncoder::Create(pref_service_.get())); payloads_.clear(); // The first attempt should succeed. EXPECT_TRUE(SendUploadRequest(form_structure, true, {}, "", true)); // The second attempt should always fail. EXPECT_FALSE(SendUploadRequest(form_structure, true, {}, "", true)); // One upload was sent. histogram_tester.ExpectBucketCount("Autofill.UploadEvent", 1, 1); histogram_tester.ExpectBucketCount( AutofillMetrics::SubmissionSourceToUploadEventMetric(submission_source), 1, 1); // Three encoding events should be sent. histogram_tester.ExpectUniqueSample("Autofill.Upload.MetadataConfigIsValid", true, 1); ASSERT_EQ(1u, payloads_.size()); AutofillUploadContents upload; ASSERT_TRUE(upload.ParseFromString(payloads_.front())); EXPECT_EQ(upload.language(), form_structure.page_language()); ASSERT_TRUE(upload.has_randomized_form_metadata()); EXPECT_TRUE(upload.randomized_form_metadata().has_id()); EXPECT_TRUE(upload.randomized_form_metadata().has_name()); EXPECT_EQ(3, upload.field_size()); for (const auto& f : upload.field()) { ASSERT_TRUE(f.has_randomized_field_metadata()); EXPECT_TRUE(f.randomized_field_metadata().has_id()); EXPECT_TRUE(f.randomized_field_metadata().has_name()); EXPECT_TRUE(f.randomized_field_metadata().has_type()); EXPECT_TRUE(f.randomized_field_metadata().has_label()); EXPECT_TRUE(f.randomized_field_metadata().has_aria_label()); EXPECT_TRUE(f.randomized_field_metadata().has_aria_description()); EXPECT_TRUE(f.randomized_field_metadata().has_css_class()); EXPECT_TRUE(f.randomized_field_metadata().has_placeholder()); } } } TEST_P(AutofillUploadTest, Throttling) { ASSERT_NE(DISABLED, GetParam()); FormData form; FormFieldData field; field.label = UTF8ToUTF16("First Name:"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Last Name:"); field.name = UTF8ToUTF16("lastname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Email:"); field.name = UTF8ToUTF16("email"); field.form_control_type = "text"; form.fields.push_back(field); AutofillDownloadManager download_manager(driver_.get(), this); FormStructure form_structure(form); for (int i = 0; i < 8; ++i) { SCOPED_TRACE(base::StringPrintf("submission source = %d", i)); base::HistogramTester histogram_tester; auto submission_source = static_cast<SubmissionSource>(i); form_structure.set_submission_source(submission_source); // The first attempt should succeed. EXPECT_TRUE(SendUploadRequest(form_structure, true, {}, "", true)); // The second attempt should always fail. EXPECT_FALSE(SendUploadRequest(form_structure, true, {}, "", true)); // One upload was not sent. histogram_tester.ExpectBucketCount("Autofill.UploadEvent", 0, 1); histogram_tester.ExpectBucketCount( AutofillMetrics::SubmissionSourceToUploadEventMetric(submission_source), 0, 1); // One upload was sent. histogram_tester.ExpectBucketCount("Autofill.UploadEvent", 1, 1); histogram_tester.ExpectBucketCount( AutofillMetrics::SubmissionSourceToUploadEventMetric(submission_source), 1, 1); } } TEST_P(AutofillUploadTest, ThrottlingDisabled) { ASSERT_NE(DISABLED, GetParam()); FormData form; FormFieldData field; field.label = UTF8ToUTF16("First Name:"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Last Name:"); field.name = UTF8ToUTF16("lastname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Email:"); field.name = UTF8ToUTF16("email"); field.form_control_type = "text"; form.fields.push_back(field); AutofillDownloadManager download_manager(driver_.get(), this); FormStructure form_structure(form); base::test::ScopedFeatureList local_feature; local_feature.InitAndDisableFeature(features::kAutofillUploadThrottling); for (int i = 0; i < 8; ++i) { SCOPED_TRACE(base::StringPrintf("submission source = %d", i)); base::HistogramTester histogram_tester; auto submission_source = static_cast<SubmissionSource>(i); form_structure.set_submission_source(submission_source); // The first attempt should succeed. EXPECT_TRUE(SendUploadRequest(form_structure, true, {}, "", true)); // The second attempt should also succeed EXPECT_TRUE(SendUploadRequest(form_structure, true, {}, "", true)); // The third attempt should also succeed EXPECT_TRUE(SendUploadRequest(form_structure, true, {}, "", true)); // No throttling metrics should be logged. EXPECT_TRUE(histogram_tester.GetAllSamples("Autofill.UploadEvent").empty()); EXPECT_TRUE( histogram_tester .GetAllSamples(AutofillMetrics::SubmissionSourceToUploadEventMetric( submission_source)) .empty()); } } TEST_P(AutofillUploadTest, PeriodicReset) { ASSERT_NE(DISABLED, GetParam()); FormData form; FormFieldData field; field.label = UTF8ToUTF16("First Name:"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Last Name:"); field.name = UTF8ToUTF16("lastname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Email:"); field.name = UTF8ToUTF16("email"); field.form_control_type = "text"; form.fields.push_back(field); AutofillDownloadManager download_manager(driver_.get(), this); SubmissionSource submission_source = SubmissionSource::FORM_SUBMISSION; FormStructure form_structure(form); form_structure.set_submission_source(submission_source); base::HistogramTester histogram_tester; TestAutofillClock test_clock; test_clock.SetNow(base::Time::Now()); // The first attempt should succeed. EXPECT_TRUE(SendUploadRequest(form_structure, true, {}, "", true)); // Advance the clock, but not past the reset period. The pref won't reset, // so the upload should never be sent. test_clock.Advance(base::TimeDelta::FromDays(27)); EXPECT_FALSE(SendUploadRequest(form_structure, true, {}, "", true)); // Advance the clock beyond the reset period. The pref should bfde reset and // the upload should succeed. test_clock.Advance(base::TimeDelta::FromDays(2)); // Total = 29 EXPECT_TRUE(SendUploadRequest(form_structure, true, {}, "", true)); // One upload was not sent. histogram_tester.ExpectBucketCount("Autofill.UploadEvent", 0, 1); histogram_tester.ExpectBucketCount( AutofillMetrics::SubmissionSourceToUploadEventMetric(submission_source), 0, 1); // Two uploads were sent. histogram_tester.ExpectBucketCount("Autofill.UploadEvent", 1, 2); histogram_tester.ExpectBucketCount( AutofillMetrics::SubmissionSourceToUploadEventMetric(submission_source), 1, 2); } TEST_P(AutofillUploadTest, ResetOnClearUploadHisotry) { ASSERT_NE(DISABLED, GetParam()); FormData form; FormFieldData field; field.label = UTF8ToUTF16("First Name:"); field.name = UTF8ToUTF16("firstname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Last Name:"); field.name = UTF8ToUTF16("lastname"); field.form_control_type = "text"; form.fields.push_back(field); field.label = UTF8ToUTF16("Email:"); field.name = UTF8ToUTF16("email"); field.form_control_type = "text"; form.fields.push_back(field); AutofillDownloadManager download_manager(driver_.get(), this); SubmissionSource submission_source = SubmissionSource::FORM_SUBMISSION; FormStructure form_structure(form); form_structure.set_submission_source(submission_source); base::HistogramTester histogram_tester; TestAutofillClock test_clock; test_clock.SetNow(base::Time::Now()); // The first attempt should succeed. EXPECT_TRUE(SendUploadRequest(form_structure, true, {}, "", true)); // Clear the upload throttling history. AutofillDownloadManager::ClearUploadHistory(pref_service_.get()); EXPECT_TRUE(SendUploadRequest(form_structure, true, {}, "", true)); // Two uploads were sent. histogram_tester.ExpectBucketCount("Autofill.UploadEvent", 1, 2); histogram_tester.ExpectBucketCount( AutofillMetrics::SubmissionSourceToUploadEventMetric(submission_source), 1, 2); } // Note that we omit DEFAULT_URL from the test params. We don't actually want // the tests to hit the production server. We also excluded DISABLED, since // these tests exercise "enabled" functionality. INSTANTIATE_TEST_CASE_P(All, AutofillUploadTest, ::testing::Values(FINCHED_URL, COMMAND_LINE_URL)); } // namespace autofill
[ "artem@brave.com" ]
artem@brave.com
db120dc58ae8662052c1f3dbf58a8056a3163c04
edb9157ed4d34ca0b5affc41ea2abce51d3c66fd
/src/optimization-seq.cpp
edfd0a38ec840c07a44da87c9339a9dd280f712f
[ "MIT" ]
permissive
Giraudux/turbo-multitask
62703d05bbd9a0f66c8ce87ebed3e0158eef33af
91635d12fcdd755b8e789d4224c9bdbc73030de9
refs/heads/master
2016-08-12T22:20:51.313615
2016-04-08T21:32:12
2016-04-08T21:32:12
53,426,345
0
0
null
null
null
null
UTF-8
C++
false
false
4,235
cpp
/** * Branch and bound algorithm to find the minimum of continuous binary functions * using interval arithmetic. * * Sequential version * * Authors: Frederic Goualard <Frederic.Goualard@univ-nantes.fr> * Alexis Giraudet <Alexis.Giraudet@etu.univ-nantes.fr> * Dennis Bordet <Dennis.Bordet@etu.univ-nantes.fr> * * v. 1.0, 2016-04-08 */ #include "interval.h" #include "functions.h" #include "minimizer.h" #include <chrono> #include <iostream> #include <iterator> #include <stdexcept> #include <string> using namespace std; // Split a 2D box into four subboxes by splitting each dimension // into two equal subparts void split_box(const interval &x, const interval &y, interval &xl, interval &xr, interval &yl, interval &yr) { double xm = x.mid(); double ym = y.mid(); xl = interval(x.left(), xm); xr = interval(xm, x.right()); yl = interval(y.left(), ym); yr = interval(ym, y.right()); } // Branch-and-bound minimization algorithm void minimize(itvfun f, // Function to minimize const interval &x, // Current bounds for 1st dimension const interval &y, // Current bounds for 2nd dimension double threshold, // Threshold at which we should stop splitting double &min_ub, // Current minimum upper bound minimizer_list &ml) // List of current minimizers { interval fxy = f(x, y); if (fxy.left() > min_ub) { // Current box cannot contain minimum? return; } if (fxy.right() < min_ub) { // Current box contains a new minimum? min_ub = fxy.right(); // Discarding all saved boxes whose minimum lower bound is // greater than the new minimum upper bound auto discard_begin = ml.lower_bound(minimizer{0, 0, min_ub, 0}); ml.erase(discard_begin, ml.end()); } // Checking whether the input box is small enough to stop searching. // We can consider the width of one dimension only since a box // is always split equally along both dimensions if (x.width() <= threshold) { // We have potentially a new minimizer ml.insert(minimizer{x, y, fxy.left(), fxy.right()}); return; } // The box is still large enough => we split it into 4 sub-boxes // and recursively explore them interval xl, xr, yl, yr; split_box(x, y, xl, xr, yl, yr); minimize(f, xl, yl, threshold, min_ub, ml); minimize(f, xl, yr, threshold, min_ub, ml); minimize(f, xr, yl, threshold, min_ub, ml); minimize(f, xr, yr, threshold, min_ub, ml); } int main(void) { cout.precision(16); // By default, the currently known upper bound for the minimizer is +oo double min_ub = numeric_limits<double>::infinity(); // List of potential minimizers. They may be removed from the list // if we later discover that their smallest minimum possible is // greater than the new current upper bound minimizer_list minimums; // Threshold at which we should stop splitting a box double precision; // Name of the function to optimize string choice_fun; // The information on the function chosen (pointer and initial box) opt_fun_t fun; bool good_choice; // Asking the user for the name of the function to optimize do { good_choice = true; cout << "Which function to optimize?\n"; cout << "Possible choices: "; for (auto fname : functions) { cout << fname.first << " "; } cout << endl; cin >> choice_fun; try { fun = functions.at(choice_fun); } catch (out_of_range) { cerr << "Bad choice" << endl; good_choice = false; } } while (!good_choice); // Asking for the threshold below which a box is not split further cout << "Precision? "; cin >> precision; auto start = chrono::high_resolution_clock::now(); minimize(fun.f, fun.x, fun.y, precision, min_ub, minimums); auto end = chrono::high_resolution_clock::now(); // Displaying all potential minimizers copy(minimums.begin(), minimums.end(), ostream_iterator<minimizer>(cout, "\n")); cout << "Number of minimizers: " << minimums.size() << endl; cout << "Upper bound for minimum: " << min_ub << endl; cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << " ms" << endl; }
[ "giraudux@gmail.com" ]
giraudux@gmail.com
6872344cb97b2ca417992f08dc9974d82fd526b6
091afb7001e86146209397ea362da70ffd63a916
/inst/include/nt2/exponential/functions/cbrt.hpp
7687bdc7f9e4e2f995d217cab208c7edfe9cde76
[]
no_license
RcppCore/RcppNT2
f156b58c08863243f259d1e609c9a7a8cf669990
cd7e548daa2d679b6ccebe19744b9a36f1e9139c
refs/heads/master
2021-01-10T16:15:16.861239
2016-02-02T22:18:25
2016-02-02T22:18:25
50,460,545
15
1
null
2019-11-15T22:08:50
2016-01-26T21:29:34
C++
UTF-8
C++
false
false
1,934
hpp
//============================================================================== // Copyright 2003 - 2012 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2012 LRI UMR 8623 CNRS/Univ Paris Sud XI // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #ifndef NT2_EXPONENTIAL_FUNCTIONS_CBRT_HPP_INCLUDED #define NT2_EXPONENTIAL_FUNCTIONS_CBRT_HPP_INCLUDED #include <nt2/include/functor.hpp> namespace nt2 { namespace tag { /*! @brief cbrt generic tag Represents the cbrt function in generic contexts. @par Models: Hierarchy **/ struct cbrt_ : ext::elementwise_<cbrt_> { /// @brief Parent hierarchy typedef ext::elementwise_<cbrt_> parent; template<class... Args> static BOOST_FORCEINLINE BOOST_AUTO_DECLTYPE dispatch(Args&&... args) BOOST_AUTO_DECLTYPE_BODY( dispatching_cbrt_( ext::adl_helper(), static_cast<Args&&>(args)... ) ) }; } namespace ext { template<class Site, class... Ts> BOOST_FORCEINLINE generic_dispatcher<tag::cbrt_, Site> dispatching_cbrt_(adl_helper, boost::dispatch::meta::unknown_<Site>, boost::dispatch::meta::unknown_<Ts>...) { return generic_dispatcher<tag::cbrt_, Site>(); } template<class... Args> struct impl_cbrt_; } /*! Compute the cubic root: \f$\sqrt[3]{x}\f$ @par Semantic: For every parameter of floating type T0 @code T0 r = cbrt(x); @endcode is similar to: @code T0 r = pow(x, T0(1/3.0)); @endcode @see @funcref{pow}, @funcref{boost::simd::sqrt} @param a0 @return a value of the same type as the parameter **/ NT2_FUNCTION_IMPLEMENTATION(tag::cbrt_, cbrt, 1) } #endif
[ "kevinushey@gmail.com" ]
kevinushey@gmail.com
942873ca6d873ffd53392bd714e8814ca8a4653f
565c6fc0714ef45619a77bf17dda9cc9453bd7a8
/src/path_finder.cpp
e025a7c3347a80e00a2f83a9a952b04c3c81c619
[]
no_license
rsilverhav/astar_example
b6da85e4274f2a9420b58539dc7c02d023323f2b
784ee9e5e87cc29456e925df6af497a1aae508da
refs/heads/master
2021-01-13T14:06:06.282059
2016-12-13T21:43:46
2016-12-13T21:43:46
76,189,928
0
0
null
null
null
null
UTF-8
C++
false
false
4,204
cpp
#include "path_finder.hpp" #include "path_node.hpp" #include <queue> #include <map> #include <vector> #include <math.h> #include <algorithm> #include <utility> #include <memory> using namespace std; PathFinder::PathFinder() { } int PathFinder::findPath(const Point start, const Point target, const World& world, const unsigned int worldWidth, const unsigned int worldHeight, std::vector<Point>& path, const unsigned int maxLength) { // using a priority_queue for searchQueue as this will be really fast for getting the next node with the smallest cost priority_queue<pair<int, shared_ptr<PathNode>>, vector<pair<int, shared_ptr<PathNode>>>, std::greater<pair<int, shared_ptr<PathNode>>>> searchQueue; map<int, shared_ptr<PathNode>> openSet; map<int, shared_ptr<PathNode>> closedSet; if(start == target){ return -1; } int xLimMin, xLimMax, checkPosX, checkPosY, index; // TODO: should be unique pointer, not shared pointer shared_ptr<PathNode> addNode = make_shared<PathNode>(nullptr, start.getX(), start.getY(), 0, calcHCost(start.getX(), start.getY(), target.getX(), target.getY())); searchQueue.emplace(addNode->getFCost(), addNode); openSet[start.getX() + start.getY()*worldWidth] = addNode; shared_ptr<PathNode> currentNodeShrPtr; PathNode* currentNode; while(!searchQueue.empty()){ // getting the node with the lowest f-cose from the open set currentNodeShrPtr = searchQueue.top().second; currentNode = currentNodeShrPtr.get(); searchQueue.pop(); // adding the node that is currently being explored to the closed set closedSet[currentNode->getPosX() + currentNode->getPosY()*worldWidth] = currentNodeShrPtr; // goal found, setting path and returning length if(currentNode->isEqual(target)){ int distance = currentNode->setBufferToPath(path); return distance; } // looping through neighbours for(int y = -1; y <= 1; y++){ if(y == 0){ xLimMin = -1; xLimMax = 1; }else{ xLimMin = 0; xLimMax = 1; } for( int x = xLimMin; x <= xLimMax; x+=2){ // calculates the position and the index of a neighbour checkPosX = currentNode->getPosX()+x; checkPosY = currentNode->getPosY()+y; index = checkPosX + checkPosY*worldWidth; // if the neighbours position is valid and is not in the closed set, continue evaluating if(isValidTile(checkPosX, checkPosY, worldWidth, worldHeight, world) && closedSet.find(checkPosX + checkPosY*worldWidth) == closedSet.end()){ int newGCost = currentNode->getGCost() + 1; // ignore this neighbour if the distance is longer than max path length if(newGCost > maxLength){ continue; } int newHCost = calcHCost(checkPosX, checkPosY, target.getX(), target.getY()); if(openSet.find(index) == openSet.end() || newGCost + newHCost < openSet[index]->getFCost()){ addNode = make_shared<PathNode>(currentNode, checkPosX, checkPosY, newGCost, calcHCost(checkPosX, checkPosY, target.getX(), target.getY())); searchQueue.emplace(addNode->getFCost(), addNode); openSet[index] = addNode; searchQueue.emplace(addNode->getFCost(), addNode); } } } } } return -1; } /** * Calculates the H-cost of a node using manhattan distance. * * Returns: the manhattan distance between grid positions */ int PathFinder::calcHCost(const int fromX, const int fromY, const int nTargetX, const int nTargetY){ return fabs((float)nTargetX - fromX) + fabs((float)nTargetY - fromY); } /** * Used to see if a path node can be created at a tile on the map * * Returns: true if posX and posY is inside the map and not on a wall */ bool PathFinder::isValidTile(const int posX, const int posY, const int worldWidth, const int worldHeight, const World& world){ if((posX < 0 || posX >= worldWidth) || (posY < 0 || posY >= worldHeight) || world.isWall(posX, posY)){ return false; } return true; }
[ "robinsilverhav@gmail.com" ]
robinsilverhav@gmail.com
29d2085edb0e0eb92ac329629c8d2fbec5ff34d6
d6d3e49cd07d64c6c59ad101a8a2a8585cb8874a
/MultiJets/MultiJetsCLs/bin/RunMultJetsCLs.cc
0100a6ffc1ab9a5aff8c06717f3472077456aa55
[]
no_license
dhidas/UserCode
2bb36c4eb5bd9daa4d71a739a042e4aee9200dea
04701c732d8acb3042e8967898a789d2b2845da4
refs/heads/master
2021-01-18T14:02:11.537626
2013-10-25T14:31:27
2013-10-25T14:31:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,999
cc
//////////////////////////////////////////////////////////////////// // // Dean Andrew Hidas <Dean.Andrew.Hidas@cern.ch> // // Created on: Sat Oct 1 06:02:06 EDT 2011 // //////////////////////////////////////////////////////////////////// #include <iostream> #include <fstream> #include <vector> #include "StandardHypoTestInvDemo.h" #include "TString.h" #include "TCanvas.h" #include "TF1.h" #include "TFile.h" #include "TTree.h" #include "RooDataHist.h" #include "RooWorkspace.h" #include "RooExponential.h" #include "RooGenericPdf.h" #include "RooPlot.h" #include "RooFitResult.h" // Min and max for observable float const MJJJMIN = 230; float const MJJJMAX = 1500; // Luminosity float const LUMINOSITY = 2177.0; float const LUMIERROR = 0.045; float GetAcceptanceForMjjj (float const Mjjj) { // Get the acceptance for a given mass //TF1* f = Accept->GetFunction("fit1"); //f->GetParameter(0) //f->GetParameter(1) //f->GetParameter(2) //2nd degree polynomial numbers: //p0 = -0.0173967 +/- 0.000576407 //p1 = 8.54121e-05 +/- 2.28888e-06 //p2 = -2.44194e-08 +/- 1.63146e-09 // //3rd degree polynomial numbers: //p0 = -0.01027 +/- 0.00171542 //p1 = 4.38331e-05 +/- 1.08208e-05 //p2 = 4.43791e-08 +/- 1.96505e-08 //p3 = -3.69426e-11 +/- 9.06989e-12 return -0.01027 + 4.38331e-05*Mjjj + 4.43791e-08*Mjjj*Mjjj - 3.69426e-11*Mjjj*Mjjj*Mjjj; //return -0.0173967 + 8.54121e-05 * Mjjj + -2.44194e-08 * Mjjj * Mjjj; } float GetAcceptanceError (float const m) { // 250 0.203786 // 300 0.175059 // 350 0.127826 // 400 0.136186 // 450 0.140467 // 500 0.171287 // 750 0.212378 //1250 0.335977 //1500 0.565487 // Fixed 250-500 to the 250 val and fit pol3. might undershoot around 1000, but ain't too bad //p0 = 0.140834 +/- 0.0160314 //p1 = 0.000392742 +/- 7.3481e-05 //p2 = -7.49412e-07 +/- 9.60659e-08 //p3 = 4.50564e-10 +/- 3.69923e-11 // acceptance error test remove later on //if (m >= 800) { // return 1.1653400; //} return (0.140834 + 0.000392742*m - -7.49412e-07*m*m + 4.50564e-10*m*m*m); } int RunMultJetsCLs (TString const InFileName, int const Section) { // Get the mass for this section float const SignalMass = 250 + (20 * Section); std::cout << "SignalMass = " << SignalMass << std::endl; float const MINXS = 0; float const MAXXS = 100; float const MINPOI = 0; float const MAXPOI = SignalMass < 300 ? 35 : SignalMass < 400 ? 13 : SignalMass < 500 ? 10 : SignalMass < 600 ? 6 : SignalMass < 650 ? 3 : SignalMass < 700 ? 2 : SignalMass < 780 ? 1.8 : SignalMass < 840 ? 1.3 : SignalMass < 860 ? 1.0 : SignalMass < 950 ? 0.7 : SignalMass < 1030 ? 0.5 : SignalMass < 1110 ? 0.4 : SignalMass < 1270 ? 0.3 : SignalMass < 1370 ? 0.18 : SignalMass < 1500 ? 0.16 : 0.16; // Open output file for limits std::ofstream OutFile(TString::Format("Limits_CLs_%i.dat", (int) SignalMass).Data()); if (!OutFile.is_open()) { std::cerr << "ERROR: cannot open output file Limits_CLs_*.dat for mass: " << SignalMass << std::endl; throw; } // Setup output root file based on mass TFile OutRootFile(TString::Format("MultiJetsCLs_%i.root", (int) SignalMass), "recreate"); if (!OutRootFile.IsOpen()) { std::cerr << "ERROR: cannot open output root file for mass: " << SignalMass << std::endl; throw; } OutRootFile.cd(); // Start a workspace RooWorkspace ws("ws"); // Obseravable ws.factory("mjjj[0]"); ws.var("mjjj")->setRange(MJJJMIN, MJJJMAX); // Get the data hist and import it to the workspace TFile InFile(InFileName, "read"); if (!InFile.IsOpen()) { std::cerr << "ERROR: cannot open input file: " << InFileName << std::endl; exit(1); } TH1* DataHist = (TH1*) InFile.Get("Mjjj_70_20_160_6jet"); if (DataHist == 0x0) { std::cerr << "ERROR: cannot get data histogram" << std::endl; throw; } std::cout << "Got data hist with number of entries: " << DataHist->GetEntries() << std::endl; RooDataHist Data("Data", "dataset with x", *ws.var("mjjj"), DataHist); ws.import(Data); // Get the fit function from the hist TF1* FitFunction = (TF1*) DataHist->GetFunction("g4"); if (FitFunction == 0x0) { std::cout << "ERROR: cannot get fitted function." << std::endl; throw; } std::cout << "Found fitted function: " << std::endl; FitFunction->Print(); // Compare number from fit and data float const NData = DataHist->Integral( DataHist->FindBin(MJJJMIN), DataHist->FindBin(MJJJMAX) ); float const NBackground = FitFunction->Integral(MJJJMIN, MJJJMAX) / DataHist->GetBinWidth(0); printf("Data vs fit: %12.1f %12.1f\n", NData, NBackground); // Define background and parameters ws.factory("p1[0]"); ws.var("p1")->setRange(FitFunction->GetParameter(1) - 5 * FitFunction->GetParError(1), FitFunction->GetParameter(1) + 5 * FitFunction->GetParError(1)); ws.var("p1")->setVal(FitFunction->GetParameter(1)); ws.var("p1")->setConstant(true); ws.var("p1")->Print(); ws.factory("p2[0]"); ws.var("p2")->setRange(FitFunction->GetParameter(2) - 5 * FitFunction->GetParError(2), FitFunction->GetParameter(2) + 5 * FitFunction->GetParError(2)); ws.var("p2")->setVal(-FitFunction->GetParameter(2)); ws.var("p2")->setConstant(true); ws.var("p2")->Print(); ws.factory("p3[0]"); ws.var("p3")->setRange(FitFunction->GetParameter(3) - 5 * FitFunction->GetParError(3), FitFunction->GetParameter(3) + 5 * FitFunction->GetParError(3)); ws.var("p3")->setVal(-FitFunction->GetParameter(3)); ws.var("p3")->setConstant(true); ws.var("p3")->Print(); // define priors (constraints) for these params ws.factory("RooLognormal::p1_prior(p1, p1M0[0], p1S0[1])"); ws.var("p1S0")->setVal(1.0 + FitFunction->GetParError(1) / FitFunction->GetParameter(1)); ws.var("p1S0")->setConstant(true); ws.var("p1M0")->setVal(FitFunction->GetParameter(1)); ws.var("p1M0")->setConstant(true); ws.factory("RooLognormal::p2_prior(p2, p2M0[0], p2S0[1])"); ws.var("p2S0")->setVal(1.0 + FitFunction->GetParError(2) / FitFunction->GetParameter(2)); ws.var("p2S0")->setConstant(true); ws.var("p2M0")->setVal(FitFunction->GetParameter(2)); ws.var("p2M0")->setConstant(true); ws.factory("RooLognormal::p3_prior(p3, p3M0[0], p3S0[1])"); ws.var("p3S0")->setVal(1.0 + FitFunction->GetParError(3) / FitFunction->GetParameter(3)); ws.var("p3S0")->setConstant(true); ws.var("p3M0")->setVal(FitFunction->GetParameter(3)); ws.var("p3M0")->setConstant(true); // Background function ws.factory("RooGenericPdf::background('(((1. - mjjj/7000.)^p1)/((mjjj/7000.)^(p2+ p3*log(mjjj/7000.))))', {mjjj, p1, p2, p3})"); // Define lumi and lumi prior ws.factory("RooLognormal::lumi_prior(lumi[0], lumiM0[0], lumiS0[0])"); ws.var("lumi")->setVal(LUMINOSITY); ws.var("lumi")->setRange(LUMINOSITY * (1. - 3. * LUMIERROR), LUMINOSITY * (1. + 3. * LUMIERROR)); ws.var("lumiM0")->setVal(LUMINOSITY); ws.var("lumiS0")->setVal(1.0 + LUMIERROR); // cross section prior and set the allowed range for the cross section ws.factory("xs[0]"); ws.var("xs")->setRange(MINXS, MAXXS); ws.var("xs")->setConstant(false); ws.factory("RooUniform::xs_prior(xs)"); // define number of signal as xs*lumi*acceptance ws.factory("prod::nsig(xs, lumi, acceptance[0,1])"); ws.factory("nsigX[0,500]"); ws.defineSet("POI","xs"); float const Acceptance = GetAcceptanceForMjjj(SignalMass); float const AcceptanceError = GetAcceptanceError(SignalMass); printf("Acceptance for mass %E is %E +/- %E\n", SignalMass, Acceptance, Acceptance * AcceptanceError); ws.factory("RooLognormal::acceptance_prior(acceptance, acceptanceM0[0], acceptanceS0[0])"); ws.var("acceptanceS0")->setVal(1.0 + AcceptanceError); ws.var("acceptanceS0")->setConstant(true); ws.var("acceptance")->setRange(0, Acceptance * (1. + 3. * AcceptanceError)); ws.var("acceptance")->setVal(Acceptance); ws.var("acceptance")->setConstant(true); ws.var("acceptanceM0")->setVal(Acceptance); ws.var("acceptanceM0")->setConstant(true); // Signal shape ws.factory("RooGaussian::signal(mjjj, sigMean[0], sigWidth[0,500])"); ws.var("sigWidth")->setVal(SignalMass * 0.065); ws.var("sigWidth")->setRange( (SignalMass * 0.065) * (1.0 - 0.10), (SignalMass * 0.065) * (1.0 + 0.10)); ws.var("sigWidth")->setConstant(true); ws.var("sigMean")->setVal(SignalMass); ws.var("sigMean")->setConstant(true); // prior on the signal width ws.factory("RooUniform::sigWidth_prior(sigWidth)"); // nbkg prior ws.factory("RooLognormal::nbkg_prior(nbkg[0,60000], nbkgM0[0], nbkgS0[0])"); ws.var("nbkgS0")->setVal(1. + 0.03); // 3% error ws.var("nbkgS0")->setConstant(true); ws.var("nbkgM0")->setVal(NBackground); ws.var("nbkgM0")->setConstant(true); ws.var("nbkg")->setVal(NBackground); ws.var("nbkg")->setRange(NBackground * (1 - 3*0.03), NBackground * (1 + 3*0.03)); ws.var("nbkg")->setConstant(true); // Define models (sig+bg, and bg only) ws.factory("SUM::sbmodel_noprior(nsig*signal, nbkg*background)"); ws.factory("SUM::bgmodel_noprior(nbkg*background)"); // Pick which constraints and nuisance params you want to use switch (4) { case 0: ws.factory("RooUniform::constraints(x)"); ws.defineSet("nuisance",""); break; case 1: ws.factory("PROD::constraints(nbkg_prior)"); ws.defineSet("nuisance", "nbkg"); ws.var("nbkg")->setConstant(false); break; case 2: ws.factory("PROD::constraints(nbkg_prior,p1_prior)"); ws.defineSet("nuisance", "nbkg,p1"); ws.var("nbkg")->setConstant(false); ws.var("p1")->setConstant(false); break; case 3: ws.factory("PROD::constraints(nbkg_prior,p1_prior,p2_prior)"); ws.defineSet("nuisance", "nbkg,p1,p2"); ws.var("nbkg")->setConstant(false); ws.var("p1")->setConstant(false); ws.var("p2")->setConstant(false); break; case 4: ws.factory("PROD::constraints(nbkg_prior,p1_prior,p2_prior,p3_prior)"); ws.defineSet("nuisance", "nbkg,p1,p2,p3"); ws.var("nbkg")->setConstant(false); ws.var("p1")->setConstant(false); ws.var("p2")->setConstant(false); ws.var("p3")->setConstant(false); break; case 5: ws.factory("PROD::constraints(nbkg_prior,p1_prior,p2_prior,p3_prior,lumi_prior)"); ws.defineSet("nuisance", "nbkg,p1,p2,p3,lumi"); ws.var("nbkg")->setConstant(false); ws.var("p1")->setConstant(false); ws.var("p2")->setConstant(false); ws.var("p3")->setConstant(false); ws.var("lumi")->setConstant(false); break; case 6: ws.factory("PROD::constraints(nbkg_prior,p1_prior,p2_prior,p3_prior,lumi_prior,acceptance_prior)"); ws.defineSet("nuisance", "nbkg,p1,p2,p3,lumi,acceptance"); ws.var("nbkg")->setConstant(false); ws.var("p1")->setConstant(false); ws.var("p2")->setConstant(false); ws.var("p3")->setConstant(false); ws.var("lumi")->setConstant(false); ws.var("acceptance")->setConstant(false); break; case 7: ws.factory("PROD::constraints(nbkg_prior,p1_prior,p2_prior,p3_prior,lumi_prior,acceptance_prior,sigWidth_prior)"); ws.defineSet("nuisance", "nbkg,p1,p2,p3,lumi,acceptance,sigWidth"); ws.var("nbkg")->setConstant(false); ws.var("p1")->setConstant(false); ws.var("p2")->setConstant(false); ws.var("p3")->setConstant(false); ws.var("lumi")->setConstant(false); ws.var("acceptance")->setConstant(false); ws.var("sigWidth")->setConstant(false); break; default: std::cerr << "pick something I have please" << std::endl; throw; } // Build modelconfig for bgmodel and set current workspace RooStats::ModelConfig ModelConfigBG("ModelConfigBG"); ModelConfigBG.SetWorkspace(ws); // Setup this model ModelConfigBG.SetPdf(*ws.pdf("bgmodel_noprior")); ModelConfigBG.SetParametersOfInterest(*ws.set("POI")); ModelConfigBG.SetObservables(*ws.var("mjjj")); ModelConfigBG.SetPriorPdf(*ws.pdf("constraints")); ModelConfigBG.SetNuisanceParameters(*ws.set("nuisance")); // Set the observable to zero and add POI snapsnot, import this modelconfig to the workspace ws.var("xs")->setVal(0); RooFitResult* FitResult = ws.pdf("bgmodel_noprior")->fitTo(*ws.data("Data"), RooFit::Range(MJJJMIN, MJJJMAX), RooFit::Extended(kTRUE)); FitResult->covarianceMatrix(); FitResult->correlationMatrix(); exit(0); RooArgSet POIAndNuisBG("POIAndNuisBG"); POIAndNuisBG.add(*ModelConfigBG.GetParametersOfInterest()); ModelConfigBG.SetSnapshot(POIAndNuisBG); ModelConfigBG.SetGlobalObservables( RooArgSet() ); ws.import(ModelConfigBG); // Build modelconfig for sbmodel and set current workspace RooStats::ModelConfig ModelConfigSB("ModelConfigSB"); ModelConfigSB.SetWorkspace(ws); // Setup this model ModelConfigSB.SetPdf(*ws.pdf("sbmodel_noprior")); ModelConfigSB.SetParametersOfInterest(*ws.set("POI")); ModelConfigSB.SetObservables(*ws.var("mjjj")); ModelConfigSB.SetPriorPdf(*ws.pdf("constraints")); ModelConfigSB.SetNuisanceParameters(*ws.set("nuisance")); // Fit model and add POI snapsnot, import this modelconfig to the workspace ws.pdf("sbmodel_noprior")->fitTo(*ws.data("Data"), RooFit::Range(MJJJMIN, MJJJMAX), RooFit::Extended(kTRUE)); TCanvas CanFit("Fit", "Fit"); CanFit.cd(); RooPlot* ThisDataFit = ws.var("mjjj")->frame(); ws.data("Data")->plotOn(ThisDataFit); ws.pdf("bgmodel_noprior")->plotOn(ThisDataFit); ThisDataFit->SetTitle(TString::Format("M_{jjj} = %i", (int) SignalMass)); ThisDataFit->Draw(); CanFit.SetLogy(1); OutRootFile.cd(); CanFit.Write(); CanFit.SaveAs(TString::Format("Fit_%i.eps", (int) SignalMass)); RooArgSet POIAndNuisSB("POIAndNuisSB"); POIAndNuisSB.add(*ModelConfigSB.GetParametersOfInterest()); ModelConfigSB.SetSnapshot(POIAndNuisSB); ModelConfigSB.SetGlobalObservables( RooArgSet() ); ws.import(ModelConfigSB); // For debugging, why not save the workspace ws.Print(); OutRootFile.cd(); ws.Write(); ws.var("acceptance")->Print(); ws.var("lumi")->Print(); ws.var("xs")->Print(); ws.var("nbkg")->Print(); // Parameters of the CLs method we'll call int const calculatorType = 1; int const testStatType = 3; bool const useCls = true; int const npoints = 20; float const poimin = MINPOI; // Set to bigger than max and npoints to zero for search (observed makes sense, expected do on own ) float const poimax = MAXPOI; //1;//60 / (LUMINOSITY * GetAcceptanceForMjjj(SignalMass)); int const ntoys = 600; bool const useNumberCounting = false; const char* nuisPriorName = ""; // Run the actual CLs RooStats::HypoTestInvTool HTIT; RooStats::HypoTestInverterResult* MyResult = HTIT.RunInverter(&ws, "ModelConfigSB", "ModelConfigBG", "Data", calculatorType, testStatType, npoints, poimin, poimax, ntoys, useCls, useNumberCounting, nuisPriorName); // Number of entries in result const int NEntries = MyResult->ArraySize(); // Just some names const char* TypeName = "Hybrid"; const char* ResultName = MyResult->GetName(); TString PlotTitle = TString::Format("%s CL Scan for workspace %s", TypeName, ResultName); // Grab the result plot RooStats::HypoTestInverterPlot *Plot = new RooStats::HypoTestInverterPlot("HTI_Result_Plot", PlotTitle, MyResult); TCanvas CanCLb("CLb_2CL", "CLb_2CL"); CanCLb.cd(); Plot->SetTitle(TString::Format("Hybrid CL Scan for M_{jjj} = %i", (int) SignalMass)); Plot->Draw("CLb 2CL"); // plot all and Clb CanCLb.SaveAs(TString::Format("CLb2L_%i.eps", (int) SignalMass)); OutRootFile.cd(); CanCLb.Write(); // Draw the sampling distributions TCanvas CanHTI("HTI_Result", "HTI_Result"); CanHTI.Divide(3, (int) TMath::Ceil(NEntries/3)); for (int i = 0; i < NEntries; ++i) { CanHTI.cd(i + 1); RooStats::SamplingDistPlot * SamplingPlot = Plot->MakeTestStatPlot(i); SamplingPlot->SetLogYaxis(true); delete SamplingPlot; } CanHTI.SaveAs(TString::Format("HTI_Result_%i.eps", (int) SignalMass)); OutRootFile.cd(); CanHTI.Write(); // Print the limits printf(" expected limit (-2 sig) %12.3E\n", MyResult->GetExpectedUpperLimit(-2)); printf(" expected limit (-1 sig) %12.3E\n", MyResult->GetExpectedUpperLimit(-1)); printf(" expected limit (median) %12.3E\n", MyResult->GetExpectedUpperLimit(0) ); printf(" expected limit (+1 sig) %12.3E\n", MyResult->GetExpectedUpperLimit(1) ); printf(" expected limit (+2 sig) %12.3E\n", MyResult->GetExpectedUpperLimit(2) ); printf(" observed limit %12.3E +/- %12.3E\n", MyResult->UpperLimit(), MyResult->UpperLimitEstimatedError()); // Write results and close file OutFile << SignalMass << std::endl; OutFile << MyResult->GetExpectedUpperLimit(-2) << std::endl; OutFile << MyResult->GetExpectedUpperLimit(-1) << std::endl; OutFile << MyResult->GetExpectedUpperLimit( 0) << std::endl; OutFile << MyResult->GetExpectedUpperLimit( 1) << std::endl; OutFile << MyResult->GetExpectedUpperLimit( 2) << std::endl; OutFile << MyResult->UpperLimit() << std::endl; OutFile.close(); // Close root file OutRootFile.Close(); return 0; } int main (int argc, char* argv[]) { if (argc != 3) { std::cerr << "Usage: " << argv[0] << " [InFile] [Section]" << std::endl; return 1; } TString const InFileName = argv[1]; int const Section = atoi(argv[2]); RunMultJetsCLs(InFileName, Section); return 0; }
[ "" ]
c21f332785ec797428135d2e57338b8c01b71cd6
21f55ef1427f19f40d40e6c0438cfe7c3573159b
/Semester 3/Data Structures/Recursion Solutions/InsertionSort.cpp
17f492dcb001b8d798ec4d38339979b9f8a4bed6
[]
no_license
SyedAsadAbrar/University-Assignments
fa80159d24eed85ae70e8aaf20041acd96b95861
e11b449fc2de2a07ea3b4a4aa3e3af29dee6447d
refs/heads/master
2022-11-15T12:49:02.257410
2022-11-12T23:06:41
2022-11-12T23:06:41
167,517,803
0
0
null
null
null
null
UTF-8
C++
false
false
542
cpp
# include <iostream> using namespace std; void insertionSort(int Array[], int size, int counter) { int temp; if (counter == size) { return; } for (int j = counter; j > 0; j--) { if (Array[j] < Array[j - 1]) { temp = Array[j]; Array[j] = Array[j - 1]; Array[j - 1] = temp; } } counter++; insertionSort(Array , size , counter); } int main() { int temp; int Array[] = {10,9,8,7,6,5,4,3,2,1}; insertionSort(Array , 10 , 0); for (int i = 0; i < 10; i++) { cout << Array[i] << endl << endl; } system("pause"); }
[ "asad.abrar97@gmail.com" ]
asad.abrar97@gmail.com
ecbaf1d4f622bf6236242771acd561449f9bdaab
99a8f78bfbd1e948c70437eacadd70d33fff76e1
/src/cpp/pss/astrotypes/multiarray/test/TestMultiArray.h
83fb9799229b22721d9f9cc24a4e6359831fb4d7
[ "MIT" ]
permissive
PulsarSearchSoft/astrotypes
c9ff8f2dee2f90051ec061db477faedf0fbd81a4
88395bccd2a15395fffac2b4dd1b7b1fd2c7a8a3
refs/heads/master
2022-10-14T22:11:40.072804
2022-10-13T08:39:14
2022-10-13T08:39:14
124,875,471
0
1
MIT
2022-10-13T08:39:16
2018-03-12T10:57:33
C++
UTF-8
C++
false
false
3,637
h
/* * MIT License * * Copyright (c) 2018 PulsarSearchSoft * * 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 PSS_ASTROTYPES_MULTIARRAY_TEST_TESTMULTIARRAY_H #define PSS_ASTROTYPES_MULTIARRAY_TEST_TESTMULTIARRAY_H #include "pss/astrotypes/multiarray/MultiArray.h" namespace pss { namespace astrotypes { namespace multiarray { namespace test { struct DimensionA {}; struct DimensionB {}; struct DimensionC {}; /** * @brief An instantiation of the MutliArray template for unit tests * @details */ template<typename T> class TestMultiArrayMixin : public T { public: TestMultiArrayMixin(T const& t) : T(t) {} using T::T; }; template<typename T, typename... Dimensions> class TestMultiArray : public MultiArray<std::allocator<T>, T, TestMultiArrayMixin, Dimensions...> { typedef MultiArray<std::allocator<T>, T, TestMultiArrayMixin, Dimensions...> BaseT; public: template<typename... Args> TestMultiArray(TestMultiArray<Args...> const& arg) : BaseT(arg) { } template<typename... Args> TestMultiArray(DimensionSize<Args>... args) : BaseT(args...) { unsigned n=0; // fill with a number sequence 1,2,3,4..... std::generate(this->begin(), this->end(), [&] () mutable { return n++; }); } }; } // namespace test } // namespace multiarray // this must be declared in the astrotypes namespace template<typename Dimension, typename T, typename... Dimensions> struct has_dimension<multiarray::test::TestMultiArray<T, Dimensions...>, Dimension> : public list_has_type<Dimension, Dimensions...>::type { }; typedef multiarray::test::DimensionA DimensionA; typedef multiarray::test::DimensionB DimensionB; typedef multiarray::test::DimensionC DimensionC; static_assert(has_dimension<multiarray::test::TestMultiArray<int, DimensionA>, DimensionA>::value, "oh oh"); static_assert(!has_dimension<multiarray::test::TestMultiArray<int, DimensionA>,DimensionB>::value, "oh oh"); static_assert(has_dimension<multiarray::test::TestMultiArray<int, DimensionA, DimensionB>, DimensionA>::value, "oh oh"); static_assert(has_dimension<multiarray::test::TestMultiArray<int, DimensionA, DimensionB>, DimensionB>::value, "oh oh"); static_assert(!has_dimension<multiarray::test::TestMultiArray<int, DimensionA, DimensionB>, DimensionC>::value, "oh oh"); } // namespace astrotypes } // namespace pss #endif // PSS_ASTROTYPES_MULTIARRAY_TEST_TESTMULTIARRAY_H
[ "christopher.williams@physics.ox.ac.uk" ]
christopher.williams@physics.ox.ac.uk
4c67bd370fd826a9bdf47fb9bdac7b810f9c6090
1f1d9b36f5d82167c8b3f829f47db5f5156f3d56
/cogs182.cpp
0852bb7a28ffbaceb363c9bdfd252a1af461bd1b
[]
no_license
qkxwxy123/LeetCodePractice
c2cbfeb5456fce56fc13fbf277445f9a6308b724
9394e6146d4bf042e141a3896d89be9763746135
refs/heads/master
2020-07-17T08:52:19.452568
2019-11-08T05:35:31
2019-11-08T05:35:31
205,988,386
1
0
null
null
null
null
UTF-8
C++
false
false
836
cpp
#include "iostream" #include "cstdio" #include "algorithm" #include "cmath" #define maxn 50010 using namespace std; int f[maxn][20], dp[maxn][20]; int n, q, height, r, l; int maxx = -1, minn = 0x7fffffff; int main() { freopen("lineup.in", "r", stdin); freopen("lineup.out", "w", stdout); cin >> n >> q; for (int i = 1; i <= n; i++) { cin >> height; f[i][0] = height; dp[i][0] = height; } for (int j = 1; (1 << j) <= n; j++) for (int i = 1; i + (1 << j) - 1 <= n; i++) { f[i][j] = max(f[i][j - 1], f[i + (1 << j - 1)][j - 1]); dp[i][j] = min(dp[i][j - 1], dp[i + (1 << j - 1)][j - 1]); } for (int i = 1; i <= q; i++) { cin >> l >> r; int k = log2(r - l + 1); maxx = max(f[l][k], f[r - (1 << k) + 1][k]); minn = min(dp[l][k], dp[r - (1 << k) + 1][k]); cout << maxx - minn << endl; } return 0; }
[ "948897764@qq.com" ]
948897764@qq.com
a20205569ab8001070f17f057b55bf021c595b0c
ee37b926d929f042031088f35a725416b1000de9
/include/bsl/is_bool.hpp
4644ffa6da3d7199236d4d905198031a0ea13b8a
[ "MIT" ]
permissive
connojd/bsl
6bee5c28b1a9106af312f5d5002b13bd8baa7089
9adebf89bf34ac14d92b26007cb19d5508de54ac
refs/heads/master
2022-12-18T14:20:22.117151
2020-06-22T20:53:55
2020-06-22T20:53:55
287,825,769
0
0
NOASSERTION
2020-08-15T21:19:40
2020-08-15T21:13:29
null
UTF-8
C++
false
false
2,075
hpp
/// @copyright /// Copyright (C) 2020 Assured Information Security, Inc. /// /// @copyright /// 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: /// /// @copyright /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// @copyright /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE /// SOFTWARE. /// /// @file is_bool.hpp /// #ifndef BSL_IS_BOOL_HPP #define BSL_IS_BOOL_HPP #include "true_type.hpp" #include "false_type.hpp" namespace bsl { /// @class bsl::is_bool /// /// <!-- description --> /// @brief If the provided type is a bool type (taking into account /// const qualifications), provides the member constant value /// equal to true. Otherwise the member constant value is false. /// @include example_is_bool_overview.hpp /// /// <!-- template parameters --> /// @tparam T the type to query /// template<typename T> class is_bool final : public false_type {}; /// @cond doxygen off template<> class is_bool<bool> final : public true_type {}; template<> class is_bool<bool const> final : public true_type {}; /// @endcond doxygen on } #endif
[ "rianquinn@gmail.com" ]
rianquinn@gmail.com
1436ef38a77a7186ddb766f21e65eaa14e141ee4
36183993b144b873d4d53e7b0f0dfebedcb77730
/GameDevelopment/Game Programming Gems 5/Section3-Artificial_Intelligence/3.08-AdvancedPathFinding-Tombesi/DstarViewer/ChildView.h
b6007aaecfdbbc9b8cfbaeaf399372defba07df9
[]
no_license
alecnunn/bookresources
b95bf62dda3eb9b0ba0fb4e56025c5c7b6d605c0
4562f6430af5afffde790c42d0f3a33176d8003b
refs/heads/master
2020-04-12T22:28:54.275703
2018-12-22T09:00:31
2018-12-22T09:00:31
162,790,540
20
14
null
null
null
null
UTF-8
C++
false
false
1,874
h
/********************************************************************** DEVELOPED BY: MARCO TOMBESI CONTACT: e-mail: baggior@libero.it web-page: digilander.iol.it/baggior *> Copyright (c) Marco Tombesi, 2003 **********************************************************************/ // ChildView.h : interface of the CChildView class // #pragma once #include <wchar.h> #include "Painter.h" #include "../DStar.h" #include "Resource.h" // CChildView window enum OperationState { OP_Obstacle, OP_Clear, OP_Start, OP_End, OP_Play, OP_Step, OP_Idle }; enum EdgeType { Edge_Clear = 1, Edge_Obstacle = 100000000 }; // SetBaseDim dialog class SetBaseDim : public CDialog { public: SetBaseDim(); // standard constructor //Overrides public: void OnOK(); // Dialog Data enum { IDD = IDD_SETBASE }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() }; class CChildView : public CWnd { // Construction public: CChildView(); // Attributes public: OperationState m_operation_state; Painter m_Painter; unsigned m_quad_cnt ; DStar * m_pDStar; UINT_PTR m_timer_play; // Operations public: // Overrides protected: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); // Implementation public: virtual ~CChildView(); // Generated message map functions protected: afx_msg void OnPaint(); DECLARE_MESSAGE_MAP() public: afx_msg void OnOperationsSetupmap(); afx_msg void OnOperationsClearmap(); afx_msg void OnOperationsSetobstacle(); afx_msg void OnOperationsSetclear(); afx_msg void OnOperationsPlay(); afx_msg void OnOperationsStep(); afx_msg void OnSetBase(); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnRButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnTimer(UINT nIDEvent); };
[ "alec.nunn@gmail.com" ]
alec.nunn@gmail.com
a9ec53455fb431520f5c1e5287ff9d7957502f8a
c300cac7ed1bbac6a3d80a310aa16b6d6a203b61
/src/engine/triangulate.cpp
fe66e1e0d15effc710ad9b8b6505faf6fcf998df
[]
no_license
nikita-yfh/hagen-engine
1548ea7498257f62aa591114104f7cd1f8ebac72
10edc9a74cfa89344de39be3cb4c6e57891b50f0
refs/heads/master
2023-08-14T08:42:43.726929
2021-09-22T13:38:15
2021-09-22T13:38:15
341,606,936
5
1
null
null
null
null
UTF-8
C++
false
false
2,954
cpp
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "triangulate.hpp" static const float EPSILON=0.0000000001f; namespace triangulate{ float Area(const Vector2dVector &contour) { int n = contour.size(); float A=0.0f; for(int p=n-1,q=0; q<n; p=q++) { A+= contour[p].x*contour[q].y - contour[q].x*contour[p].y; } return A*0.5f; } /* InsideTriangle decides if a point P is Inside of the triangle defined by A, B, C. */ bool InsideTriangle(float Ax, float Ay, float Bx, float By, float Cx, float Cy, float Px, float Py) { float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy; float cCROSSap, bCROSScp, aCROSSbp; ax = Cx - Bx; ay = Cy - By; bx = Ax - Cx; by = Ay - Cy; cx = Bx - Ax; cy = By - Ay; apx= Px - Ax; apy= Py - Ay; bpx= Px - Bx; bpy= Py - By; cpx= Px - Cx; cpy= Py - Cy; aCROSSbp = ax*bpy - ay*bpx; cCROSSap = cx*apy - cy*apx; bCROSScp = bx*cpy - by*cpx; return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f)); }; bool Snip(const Vector2dVector &contour,int u,int v,int w,int n,int *V) { int p; float Ax, Ay, Bx, By, Cx, Cy, Px, Py; Ax = contour[V[u]].x; Ay = contour[V[u]].y; Bx = contour[V[v]].x; By = contour[V[v]].y; Cx = contour[V[w]].x; Cy = contour[V[w]].y; if ( EPSILON > (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax))) ) return false; for (p=0; p<n; p++) { if( (p == u) || (p == v) || (p == w) ) continue; Px = contour[V[p]].x; Py = contour[V[p]].y; if (InsideTriangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py)) return false; } return true; } bool Process(const Vector2dVector &contour,Vector2dVector &result) { /* allocate and initialize list of Vertices in polygon */ int n = contour.size(); if ( n < 3 ) return false; int *V = new int[n]; /* we want a counter-clockwise polygon in V */ if ( 0.0f < Area(contour) ) for (int v=0; v<n; v++) V[v] = v; else for(int v=0; v<n; v++) V[v] = (n-1)-v; int nv = n; /* remove nv-2 Vertices, creating 1 triangle every time */ int count = 2*nv; /* error detection */ for(int m=0, v=nv-1; nv>2; ) { /* if we loop, it is probably a non-simple polygon */ if (0 >= (count--)) { //** Triangulate: ERROR - probable bad polygon! return false; } /* three consecutive vertices in current polygon, <u,v,w> */ int u = v ; if (nv <= u) u = 0; /* previous */ v = u+1; if (nv <= v) v = 0; /* new v */ int w = v+1; if (nv <= w) w = 0; /* next */ if ( Snip(contour,u,v,w,nv,V) ) { int a,b,c,s,t; /* true names of the vertices */ a = V[u]; b = V[v]; c = V[w]; /* output Triangle */ result.push_back( contour[a] ); result.push_back( contour[b] ); result.push_back( contour[c] ); m++; /* remove v from remaining polygon */ for(s=v,t=v+1; t<nv; s++,t++) V[s] = V[t]; nv--; /* resest error detection counter */ count = 2*nv; } } delete V; return true; } };
[ "nikita.yfh@gmail.com" ]
nikita.yfh@gmail.com
1b94d8612ebb5876fb3d1f0ab52cf4b8df85260a
e617edb453c160331f5dea9bc15da469f9a87662
/include/Ek/Gfx/Mouse.hpp
f44acb84c25b3a2aa8dde24cf048bbb9b57f327c
[ "MIT" ]
permissive
Ekkoz/Ektor
e0c70e31c28e7b5571170f6a9fab27ea6bb54a0f
065b63101f3a040f5fed0300677722682fb18c88
refs/heads/master
2021-03-30T22:13:53.292236
2018-03-20T13:58:40
2018-03-20T13:58:40
125,052,536
0
0
null
null
null
null
UTF-8
C++
false
false
1,387
hpp
// MIT License // // Copyright (c) 2018 EkkoZ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // #pragma once namespace ek { class Mouse { public: enum Button { Left, Right, Middle, XButton1, XButton2, ButtonCount }; enum Wheel { VerticalWheel, HorizontalWheel }; }; };
[ "ekkoz@protonmail.com" ]
ekkoz@protonmail.com
6ae3980d624b26c3a6d9979876497f121231052c
513383372a3e12ac5e625716cd4bc5a325644951
/Project/StarProject/Boss/Octopus.cpp
c5467bafbca716120908f1248c643e88a3b8595c
[]
no_license
Nosuriba/JapanGameAword
4bd80be7424af1ce5936d969dcafe7cfc7f1d975
55dae029f95e08ac8495bb6cbf0ceff819391029
refs/heads/master
2020-04-28T02:47:51.265884
2020-03-15T14:04:20
2020-03-15T14:04:20
174,912,062
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
18,899
cpp
#include "Octopus.h" #include "../ResourceManager.h" #include <DxLib.h> #define LEG(x) _oct.legs[x] constexpr int SPEED = 5; Octopus::Octopus(const std::shared_ptr<Camera>& camera, const std::shared_ptr<Player>& player,const Vector2& pos):Boss(camera,player) { ///変数初期化 _damageFlag = true; _returnFlag = false; _maxAngle = 30; _timer = 0; _idx = 0; ///音関係 SE.damage = ResourceManager::GetInstance().LoadSound("../Sound/damage.mp3"); SE.die = ResourceManager::GetInstance().LoadSound("../Sound/die2.mp3"); SE.shot = ResourceManager::GetInstance().LoadSound("../Sound/Octopus/shot.mp3"); SE.swing = ResourceManager::GetInstance().LoadSound("../Sound/Octopus/swing.mp3"); SE.pitch = ResourceManager::GetInstance().LoadSound("../Sound/Octopus/punch.mp3"); extend = ResourceManager::GetInstance().LoadSound("../Sound/Octopus/extend.mp3"); setup = ResourceManager::GetInstance().LoadSound("../Sound/Octopus/setup.mp3"); BGM = ResourceManager::GetInstance().LoadSound("../Sound/boss.mp3"); ///タコの初期化 _oct.center = pos; da.emplace_back(DamageInfo(_oct.center, 75)); _oct.r = 500; _oct.hedPos = _oct.center + Vector2(50, 0); da.emplace_back(DamageInfo(_oct.hedPos, 75)); for (int i = 0; i < _oct.eyePos.size(); ++i) { _oct.eyePos[i] = _oct.center + Vector2(-45, 37 - 75 * i); } auto c = cos(DX_PI_F / 180 * 180); auto s = sin(DX_PI_F / 180 * 0); auto p = Vector2(c, s); _oct.movePos = _oct.center + p * _oct.r; _oct.root.resize(8); _oct.legs.resize(8); auto radian = 2.0f * DX_PI_F / (float)_oct.legs.size(); for (int i = 0; i < _oct.legs.size(); ++i) { c = cos(radian / 2 * i - DX_PI_F / 180 * -90); s = sin(radian / 2 * i - DX_PI_F / 180 * -90); auto pos = Vector2(c, s); _oct.root[i] = _oct.center + pos * 50; LEG(i).tip = _oct.root[i] + pos * _oct.r; LEG(i).joint.clear(); auto width = 25; for (int j = 0; j < LEG(i).T; ++j) { LEG(i).joint.emplace_back(_oct.root[i] + Vector2(c, s)*(_oct.r / LEG(i).T*(j + 1))); at.emplace_back(AttackInfo(_oct.root[i] + Vector2(c, s)*(_oct.r / LEG(i).T*(j + 1)),width-=2)); } LEG(i).state = E_LEG_STATE::NORMAL; LEG(i).angle = (_maxAngle - _maxAngle / 2 - _maxAngle / 4) * SPEED*(i+1); LEG(i).cnt = 0; } ///パーティクル初期化 _particle.emplace_back(std::make_shared<Water>(_oct.center.x, _oct.center.y, 5000, _camera)); _updater = &Octopus::NeturalUpdate; } ///Inverse Kinematics(逆運動学)角度制限なし void Octopus::IkCcd(Vector2 pos, int idx, int numMaxItaration) { for (int it = 0; it < numMaxItaration; ++it) { for (int j = LEG(idx).T - 1; j > 0; --j) { auto t_vec = pos - LEG(idx).joint[j - 1]; //目標→関節 auto p_vec = LEG(idx).tip - LEG(idx).joint[j - 1]; //先端→関節 auto mat = MGetTranslate((-LEG(idx).joint[j - 1]).V_Cast()); //原点まで移動 mat = MMult(mat, MGetRotVec2(p_vec.V_Cast(), t_vec.V_Cast())); //回転 mat = MMult(mat, MGetTranslate(LEG(idx).joint[j - 1].V_Cast())); //元の位置に移動 for (int itr = j; itr < LEG(idx).T; ++itr) { LEG(idx).joint[itr] = VTransform(LEG(idx).joint[itr].V_Cast(), mat); } LEG(idx).tip = LEG(idx).joint[LEG(idx).T - 1]; } auto t_vec = pos - _oct.root[idx]; //目標→関節 auto p_vec = LEG(idx).tip - _oct.root[idx]; //先端→関節 auto mat = MGetTranslate((-_oct.root[idx]).V_Cast()); //原点まで移動 mat = MMult(mat, MGetRotVec2(p_vec.V_Cast(), t_vec.V_Cast())); //回転 mat = MMult(mat, MGetTranslate(_oct.root[idx].V_Cast())); //元の位置に移動 for (int j = 0; j < LEG(idx).T; ++j) { LEG(idx).joint[j] = VTransform(LEG(idx).joint[j].V_Cast(), mat); } LEG(idx).tip = LEG(idx).joint[LEG(idx).T - 1]; } } ///死亡処理 void Octopus::Die() { quake = Vector2(10.f, 10.f); da.clear(); at.clear(); shot.clear(); ChangeVolumeSoundMem((255 * 120) / 100, SE.die); PlaySoundMem(SE.die, DX_PLAYTYPE_BACK); _updater = &Octopus::DieUpdate; } ///通常時の足の動き void Octopus::Normal(int idx) { if (!CheckSoundMem(SE.swing)) { ChangeVolumeSoundMem((255 * 90) / 100, SE.swing); PlaySoundMem(SE.swing, DX_PLAYTYPE_BACK); } auto radian = 2.0f * DX_PI_F / (float)_oct.legs.size(); auto rad = radian / 2 * idx - DX_PI_F / 180 * -90; auto ang = abs((++LEG(idx).angle / SPEED) % _maxAngle - _maxAngle / 2) - _maxAngle / 4; rad = rad + DX_PI_F / 180 * ang; auto c = _oct.root[idx].x + cos(rad)*_oct.r; auto s = _oct.root[idx].y + sin(rad)*_oct.r; auto p_pos = Vector2(c, s); auto p = p_pos - _oct.root[idx]; auto v = LEG(idx).joint[0] - _oct.root[idx]; auto mat = MGetTranslate((-_oct.root[idx]).V_Cast()); mat = MMult(mat, MGetRotVec2(v.V_Cast(), p.V_Cast())); mat = MMult(mat, MGetTranslate(_oct.root[idx].V_Cast())); for (int j = 0; j < LEG(idx).T; ++j) { //第一関節から回転 LEG(idx).joint[j] = VTransform(LEG(idx).joint[j].V_Cast(), mat); } if (LEG(idx).cnt > 0) { //第二関節以降の回転 LegMove(LEG(idx), 1); } LEG(idx).mat = MGetRotVec2(v.V_Cast(), p.V_Cast()); //第一関節の回転行列保存 LEG(idx).tip = LEG(idx).joint[LEG(idx).T-1]; } ///足が遅れてついてくる void Octopus::LegMove(E_Leg & leg, int idx) { if (idx == leg.T) { return; } for (int j = idx; j < leg.T; ++j) { //第二関節から回転 auto mat = MGetTranslate((-leg.joint[idx]).V_Cast()); mat = MMult(mat, leg.mat); mat = MMult(mat, MGetTranslate(leg.joint[idx].V_Cast())); leg.joint[j] = VTransform(leg.joint[j].V_Cast(), mat); } leg.tip = leg.joint[leg.T - 1]; ++idx; LegMove(leg, idx); } ///パンチ攻撃 void Octopus::Punch(int idx) { auto p = LEG(idx).tip - _player->GetInfo().center; auto pos = LEG(idx).tip - p.Normalized() * 10; auto t_vec = pos - _oct.root[idx]; auto p_vec = LEG(idx).tip - _oct.root[idx]; if (++LEG(idx).cnt < _oct.r / LEG(idx).T * 6) { auto mat = MGetTranslate((-_oct.root[idx]).V_Cast()); mat = MMult(mat, MGetRotVec2(p_vec.V_Cast(), t_vec.V_Cast())); mat = MMult(mat, MGetTranslate(_oct.root[idx].V_Cast())); for (int j = 0; j < LEG(idx).T; ++j) { LEG(idx).joint[j] = VTransform(LEG(idx).joint[j].V_Cast(), mat); } LEG(idx).tip = LEG(idx).joint[LEG(idx).T - 1]; p_vec = LEG(idx).tip - _oct.root[idx]; if (p_vec.Magnitude() > _oct.r / 2) { for (int j = 2; j < LEG(idx).T; ++j) { LEG(idx).joint[j] = LEG(idx).joint[j - 1] + p_vec.Normalized()*((LEG(idx).joint[j] - LEG(idx).joint[j - 1]).Magnitude() - 0.3f); } LEG(idx).tip = LEG(idx).joint[LEG(idx).T - 1]; } } else if ((LEG(idx).cnt > _oct.r / LEG(idx).T * 6) && (LEG(idx).cnt < _oct.r / LEG(idx).T * 8) && (_oct.r*2 > p_vec.Magnitude())&&!_returnFlag) { if (!CheckSoundMem(extend)) { ChangeVolumeSoundMem((255 * 100) / 100, extend); PlaySoundMem(extend, DX_PLAYTYPE_BACK); } for (int j = 2; j < LEG(idx).T; ++j) { LEG(idx).joint[j] = LEG(idx).joint[j - 1] + p_vec.Normalized()*((LEG(idx).joint[j] - LEG(idx).joint[j - 1]).Magnitude() + j+0.5f); } LEG(idx).tip = LEG(idx).joint[LEG(idx).T - 1]; } else if (((LEG(idx).cnt > _oct.r / LEG(idx).T * 8)&&(p_vec.Magnitude()>_oct.r))||(_returnFlag && (p_vec.Magnitude() > _oct.r))) { for (int j = 2; j < LEG(idx).T; ++j) { LEG(idx).joint[j] = LEG(idx).joint[j - 1] + p_vec.Normalized()*((LEG(idx).joint[j] - LEG(idx).joint[j - 1]).Magnitude() - j); } LEG(idx).tip = LEG(idx).joint[LEG(idx).T - 1]; } else if(((LEG(idx).cnt > _oct.r / LEG(idx).T * 10) && (p_vec.Magnitude() < _oct.r))||(_returnFlag && (p_vec.Magnitude() < _oct.r))){ for (int j = 0; j < LEG(idx).T; ++j) { LEG(idx).joint[j] = _oct.root[idx] + p_vec.Normalized()*(_oct.r / LEG(idx).T*(j + 1)); } LEG(idx).tip = LEG(idx).joint[LEG(idx).T - 1]; LEG(idx).cnt = 0; LEG(idx).state = E_LEG_STATE::RE_MOVE; _returnFlag = false; } if ((LEG(idx).cnt == _oct.r / LEG(idx).T * 6)) { ChangeVolumeSoundMem((255 * 100) / 100, setup); PlaySoundMem(setup, DX_PLAYTYPE_BACK); } } ///タコ墨発射! void Octopus::OctInk() { if (!CheckSoundMem(SE.shot)){ PlaySoundMem(SE.shot, DX_PLAYTYPE_BACK); } auto c = cos( DX_PI_F / 180 * 180); auto s = sin(DX_PI_F / 180 * 0); auto p = Vector2(c, s); auto pos = _oct.center + p * _oct.r; auto p_vec = pos - _oct.center; auto t_vec = _player->GetInfo().center - _oct.center; auto dot = Dot(p_vec.Normalized(), t_vec.Normalized()); auto rad = acos(dot); if (_player->GetInfo().center.y > pos.y) { rad = -rad; } if (_timer % 5==0) { auto vel = Vector2(t_vec.Normalized().x * 2.0f, t_vec.Normalized().y * 2.0f); shot.emplace_back(ShotInfo(_oct.center, vel, 15)); } _particle[0]->SetPos(_oct.center.x, _oct.center.y); _particle[0]->SetVelocity(20); _particle[0]->SetRota(rad * 180 / DX_PI_F + 180); _particle[0]->Create(); } ///プレイヤーに一番近い足が追跡(IK) void Octopus::Chase(int idx) { auto p = LEG(idx).tip - _player->GetInfo().center; auto pos = LEG(idx).tip - p.Normalized() * 1; IkCcd(pos, idx, 12); } ///ダメージ処理 void Octopus::OnDamage() { if (_damageFlag) { PlaySoundMem(SE.damage, DX_PLAYTYPE_BACK); _oct.helth -= 10; _damageFlag = false; } } ///足を元の位置に戻す void Octopus::ReMove(int idx) { auto radian = 2.0f * DX_PI_F / (float)_oct.legs.size(); auto c = cos(radian / 2 * idx - DX_PI_F / 180 * -90); auto s = sin(radian / 2 * idx - DX_PI_F / 180 * -90); auto t = Vector2(c, s); auto target = _oct.root[idx] + t * (_oct.r+30); auto p = LEG(idx).tip - target; auto pos = LEG(idx).tip - p.Normalized() * 2; IkCcd(pos, idx, 100); if ((LEG(idx).tip - (_oct.root[idx] + t * _oct.r)).Magnitude() < 10) { for (int j = 0; j < LEG(idx).T; ++j) { LEG(idx).joint[j] = _oct.root[idx] + Vector2(c, s)*(_oct.r / LEG(idx).T*(j + 1)); } LEG(idx).angle = (_maxAngle - _maxAngle / 2 - _maxAngle / 4) * 5; LEG(idx).cnt = 0; LEG(idx).state = E_LEG_STATE::NORMAL; } } ///ブロック衝突時 void Octopus::HitBlock() { PlaySoundMem(SE.pitch, DX_PLAYTYPE_BACK); _returnFlag = true; } ///当たり判定更新 void Octopus::HitUpd() { auto attack = at.begin(); for (int i = 0; i < _oct.legs.size(); ++i) { auto width = 25; for (int j = 0; j < LEG(i).T; ++j) { *attack = AttackInfo(LEG(i).joint[j], width -= 2); ++attack; } } auto damage = da.begin(); *damage = DamageInfo(_oct.center, 75); damage++; *damage= DamageInfo(_oct.hedPos, 75); for (auto& sh:shot) { auto vel = sh._vel * 1.025f; auto p = sh._pos + vel; sh = ShotInfo(p, vel, 15); } if (!shot.empty()) { auto sh = shot.end(); auto pos = (--sh)->_pos; auto c = _camera->CameraCorrection(); auto p = pos - c; auto size = Stage::GetInstance().GetStageSize(); if (p.x < 0 || p.x > size.x || p.y < 0 || p.y > size.y) { shot.clear(); } } } //void Octopus::Move() //{ // auto t = _oct.movePos - _targetPos; // auto t_pos = _oct.movePos - t.Normalized()*3; // auto p_vec = _oct.movePos - _oct.center; // auto t_vec = t_pos - _oct.center; // // if ((_targetPos-t_pos).Magnitude()<1) { // return; // } // auto mat = MGetTranslate((-_oct.center).V_Cast()); // mat = MMult(mat, MGetRotVec2(p_vec.V_Cast(), t_vec.V_Cast())); // mat = MMult(mat, MGetTranslate(_oct.center.V_Cast())); // _oct.movePos = VTransform(_oct.movePos.V_Cast(), mat); // _oct.hedPos = VTransform(_oct.hedPos.V_Cast(), mat); // for (auto& eye : _oct.eyePos) { // eye = VTransform(eye.V_Cast(), mat); // } // for (int i = 0; i < _oct.legs.size(); ++i) { // _oct.root[i] = VTransform(_oct.root[i].V_Cast(), mat); // for (int j = 0; j < LEG(i).T; j++) { // LEG(i).joint[j] = VTransform(LEG(i).joint[j].V_Cast(), mat); // } // LEG(i).tip = LEG(i).joint[LEG(i).T - 1]; // } //} ///戦闘時の更新 void Octopus::NeturalUpdate() { int j = 0; HitUpd(); float distance = 9999; if ((++_timer)% 150==0) { int i = GetRand(_oct.legs.size() - 3)+1; if (LEG(i).state == E_LEG_STATE::NORMAL) { LEG(i).cnt = 0; LEG(i).state = E_LEG_STATE::PUNCH; } } if ((_timer/100) % 8 == 0) { OctInk(); } if (_oct.helth <= 0) { Die(); } for (auto& leg : _oct.legs) { if (((_player->GetInfo().center - leg.tip).Magnitude() < distance)) { distance = (_player->GetInfo().center - leg.tip).Magnitude(); _idx = j; } ++j; } for (int i = 0; i < _oct.legs.size(); ++i) { if (LEG(i).state == E_LEG_STATE::NORMAL) { Normal(i); ++LEG(i).cnt; } else { if ((_idx != i) && (LEG(i).state == E_LEG_STATE::CHASE)) { LEG(i).state = E_LEG_STATE::RE_MOVE; } } if (LEG(i).state == E_LEG_STATE::PUNCH) { Punch(i); } if (LEG(i).state == E_LEG_STATE::CHASE) { Chase(i); } if (LEG(i).state == E_LEG_STATE::RE_MOVE) { ReMove(i); } if ((_idx == i)&&(LEG(i).state==E_LEG_STATE::NORMAL)) { LEG(i).state = E_LEG_STATE::CHASE; } } //Move(); if (!_damageFlag) { if (++_oct.interval > 60) { _damageFlag = true; _oct.interval = 0; } } } ///死亡時の更新 void Octopus::DieUpdate() { blendCnt--; quake *= 0.9995; //quake = (quake.x <= 0.05 ? Vector2() : Vector2(quake.x * 0.9995, quake.y * 0.9995)); if (blendCnt <= 0) { _isDie = true; } } /////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////描画関係/////////////////////////////////////////////// ///デバッグ用 void Octopus::DebugDraw() { auto c = _camera->CameraCorrection(); for (auto attack : at) { DrawCircle(attack._pos.x - c.x, attack._pos.y - c.y, attack._r, 0x00ff00, true); } for (auto damage : da) { DrawCircle(damage._pos.x - c.x, damage._pos.y - c.y, damage._r, 0x0000ff, true); } for (auto sh : shot) { DrawCircle(sh._pos.x - c.x, sh._pos.y - c.y, sh._r, 0x00ffff, true); } } void Octopus::Draw() { for (auto& p : _particle) p->Draw(0x000000); auto c = _camera->CameraCorrection(); if (!_damageFlag && ((_oct.interval/5) % 2 == 0)) { SetDrawBlendMode(DX_BLENDMODE_ADD, 180); } if (_updater == &Octopus::DieUpdate) { SetDrawBlendMode(DX_BLENDMODE_ALPHA, blendCnt); quake.x = (GetRand(1) ? quake.x : -quake.x); quake.y = (GetRand(1) ? quake.y : -quake.y); c = c + quake; } //足の間の膜の描画 for (int i = 0; i < _oct.legs.size()-1; ++i) { int j = 1; auto p1 = _oct.root[i]; auto p2 = LEG(i).joint[j]; auto p3 = LEG((i + 1)).joint[j]; auto p4 = _oct.root[(i + 1) ]; DrawQuadrangle(p1.x - c.x, p1.y - c.y, p2.x - c.x, p2.y - c.y, p3.x - c.x, p3.y - c.y, p4.x - c.x, p4.y - c.y, 0xbb0000, true); } //足の描画 for (int i = 0; i < _oct.legs.size(); ++i) { int j = 0; auto width = 50; DrawLineAA(_oct.root[i].x - c.x, _oct.root[i].y - c.y, LEG(i).joint[j].x - c.x, LEG(i).joint[j].y - c.y, 0xcc0000, width); for (j = 0; j < LEG(i).T - 1; ++j) { DrawLineAA(LEG(i).joint[j].x - c.x, LEG(i).joint[j].y - c.y, LEG(i).joint[j + 1].x - c.x, LEG(i).joint[j + 1].y - c.y, 0xcc0000, width-=4); DrawCircle(LEG(i).joint[j].x - c.x, LEG(i).joint[j].y - c.y, width / 2, 0xcc0000, true); } } //頭の描画 DrawOval(_oct.hedPos.x - c.x, _oct.hedPos.y - c.y,125, 75, 0xee0000, true); for (int i = 0; i < 2; ++i) { DrawCircle(_oct.eyePos[i].x - c.x, _oct.eyePos[i].y - c.y, 8, 0xffa500, true); DrawCircle(_oct.eyePos[i].x - c.x, _oct.eyePos[i].y - c.y, 6,0x000000, true); } SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); #ifdef _DEBUG DebugDraw(); #endif // DEBUG } ///影 void Octopus::ShadowDraw() { auto c = _camera->CameraCorrection(); auto s = _camera->GetShadowPos(0.3f); if (_damageFlag) { //足の間の膜の描画 for (int i = 0; i < _oct.legs.size() - 1; ++i) { int j = 1; auto p1 = _oct.root[i]; auto p2 = LEG(i).joint[j]; auto p3 = LEG((i + 1)).joint[j]; auto p4 = _oct.root[(i + 1)]; DrawQuadrangle(p1.x - c.x + s.x, p1.y - c.y + s.y, p2.x - c.x + s.x, p2.y - c.y + s.y, p3.x - c.x + s.x, p3.y - c.y + s.y, p4.x - c.x + s.x, p4.y - c.y + s.y, 0xffffff, true); } //足の描画 for (int i = 0; i < _oct.legs.size(); ++i) { int j = 0; auto width = 50; DrawLineAA(_oct.root[i].x - c.x + s.x, _oct.root[i].y - c.y + s.y, LEG(i).joint[j].x - c.x + s.x, LEG(i).joint[j].y - c.y + s.y, 0xffffff, width); for (j = 0; j < LEG(i).T - 1; ++j) { DrawLineAA(LEG(i).joint[j].x - c.x + s.x, LEG(i).joint[j].y - c.y + s.y, LEG(i).joint[j + 1].x - c.x + s.x, LEG(i).joint[j + 1].y - c.y + s.y, 0xffffff, width -= 4); DrawCircle(LEG(i).joint[j].x - c.x + s.x, LEG(i).joint[j].y - c.y + s.y, width / 2, 0xffffff, true); } } //頭の描画 DrawOval(_oct.hedPos.x - c.x + s.x, _oct.hedPos.y - c.y + s.y, 125, 75, 0xffffff, true); for (int i = 0; i < 2; ++i) { DrawCircle(_oct.eyePos[i].x - c.x + s.x, _oct.eyePos[i].y - c.y + s.y, 8, 0xffffff, true); DrawCircle(_oct.eyePos[i].x - c.x + s.x, _oct.eyePos[i].y - c.y + s.y, 6, 0xffffff, true); } } } ///セレクトシーン用 void Octopus::SelectDraw(const Vector2 p, const float s) { _oct.center = p; auto range = _oct.r*s; _oct.hedPos = _oct.center + Vector2(50, 0)*s; for (int i = 0; i < _oct.eyePos.size(); ++i) { _oct.eyePos[i] = _oct.center + Vector2(-45, 37 - 75 * i)*s; } auto radian = 2.0f * DX_PI_F / (float)_oct.legs.size(); for (int i = 0; i < _oct.legs.size(); ++i) { auto co = cos(radian / 2 * i - DX_PI_F / 180 * -90); auto si = sin(radian / 2 * i - DX_PI_F / 180 * -90); auto pos = Vector2(co, si); _oct.root[i] = _oct.center + pos * 50 * s; LEG(i).tip = _oct.root[i] + pos * range; for (int j = 0; j < LEG(i).T; ++j) { LEG(i).joint[j]=_oct.root[i] + Vector2(co, si)*(range / LEG(i).T*(j + 1)); } } //足の間の膜の描画 for (int i = 0; i < _oct.legs.size() - 1; ++i) { int j = 1; auto p1 = _oct.root[i]; auto p2 = LEG(i).joint[j]; auto p3 = LEG((i + 1)).joint[j]; auto p4 = _oct.root[(i + 1)]; DrawQuadrangle(p1.x, p1.y, p2.x , p2.y, p3.x, p3.y, p4.x, p4.y, 0xbb0000, true); } //足の描画 for (int i = 0; i < _oct.legs.size(); ++i) { int j = 0; auto width = 50*s; DrawLineAA(_oct.root[i].x, _oct.root[i].y, LEG(i).joint[j].x, LEG(i).joint[j].y, 0xcc0000, width); for (j = 0; j < LEG(i).T - 1; ++j) { DrawLineAA(LEG(i).joint[j].x , LEG(i).joint[j].y , LEG(i).joint[j + 1].x , LEG(i).joint[j + 1].y , 0xcc0000, (width -= 1)); DrawCircle(LEG(i).joint[j].x , LEG(i).joint[j].y , (width-=1) / 2, 0xcc0000, true); } } //頭の描画 DrawOval(_oct.hedPos.x , _oct.hedPos.y ,125*s, 75*s, 0xee0000, true); for (int i = 0; i < 2; ++i) { DrawCircle(_oct.eyePos[i].x , _oct.eyePos[i].y , 8*s, 0xffa500, true); DrawCircle(_oct.eyePos[i].x, _oct.eyePos[i].y , 4*s, 0x000000, true); } } //////////////////////////////////////////////////////////////////////////////////////// ///更新 void Octopus::Update() { if (!CheckSoundMem(BGM)){ ChangeVolumeSoundMem(255 * 200 / 180, BGM); PlaySoundMem(BGM, DX_PLAYTYPE_LOOP); } (this->*_updater)(); } Octopus::~Octopus() { if (CheckSoundMem(BGM)){ StopSoundMem(BGM); } }
[ "1701377@PC65210" ]
1701377@PC65210
1090d250da6de7c0b594ab9d226eb246a5f9506b
a311dd75d9cbe0402c75a6e528630656d0b0bc40
/vendor/libraries/wabt/src/tools/wast2json.cc
d48dcb1ff4e78b2b48038e5c4237fab822a49356
[ "MIT", "Apache-2.0" ]
permissive
sighttviewliu/ultrain-core-production
e158d375cf83caf7a952688708b3be9bbdee5783
c2807d9310da8b5dc1408502866be59299a96c22
refs/heads/master
2020-09-26T09:03:22.816526
2019-10-16T09:01:33
2019-11-06T11:53:45
226,222,711
1
0
MIT
2019-12-06T01:42:31
2019-12-06T01:42:30
null
UTF-8
C++
false
false
4,840
cc
/* * Copyright 2016 WebAssembly Community Group participants * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <cassert> #include <cstdarg> #include <cstdint> #include <cstdlib> #include <cstdio> #include <string> #include "config.h" #include "src/binary-writer.h" #include "src/binary-writer-spec.h" #include "src/common.h" #include "src/error-formatter.h" #include "src/feature.h" #include "src/filenames.h" #include "src/ir.h" #include "src/option-parser.h" #include "src/resolve-names.h" #include "src/stream.h" #include "src/validator.h" #include "src/wast-parser.h" using namespace wabt; static const char* s_infile; static const char* s_outfile; static int s_verbose; static WriteBinaryOptions s_write_binary_options; static bool s_validate = true; static bool s_debug_parsing; static Features s_features; static std::unique_ptr<FileStream> s_log_stream; static const char s_description[] = R"( read a file in the wasm spec test format, check it for errors, and convert it to a JSON file and associated wasm binary files. examples: # parse spec-test.wast, and write files to spec-test.json. Modules are # written to spec-test.0.wasm, spec-test.1.wasm, etc. $ wast2json spec-test.wast -o spec-test.json )"; static void ParseOptions(int argc, char* argv[]) { OptionParser parser("wast2json", s_description); parser.AddOption('v', "verbose", "Use multiple times for more info", []() { s_verbose++; s_log_stream = FileStream::CreateStdout(); }); parser.AddHelpOption(); parser.AddOption("debug-parser", "Turn on debugging the parser of wast files", []() { s_debug_parsing = true; }); s_features.AddOptions(&parser); parser.AddOption('o', "output", "FILE", "output wasm binary file", [](const char* argument) { s_outfile = argument; }); parser.AddOption( 'r', "relocatable", "Create a relocatable wasm binary (suitable for linking with e.g. lld)", []() { s_write_binary_options.relocatable = true; }); parser.AddOption( "no-canonicalize-leb128s", "Write all LEB128 sizes as 5-bytes instead of their minimal size", []() { s_write_binary_options.canonicalize_lebs = false; }); parser.AddOption("debug-names", "Write debug names to the generated binary file", []() { s_write_binary_options.write_debug_names = true; }); parser.AddOption("no-check", "Don't check for invalid modules", []() { s_validate = false; }); parser.AddArgument("filename", OptionParser::ArgumentCount::One, [](const char* argument) { s_infile = argument; }); parser.Parse(argc, argv); } int ProgramMain(int argc, char** argv) { InitStdio(); ParseOptions(argc, argv); std::unique_ptr<WastLexer> lexer = WastLexer::CreateFileLexer(s_infile); if (!lexer) { WABT_FATAL("unable to read file: %s\n", s_infile); } Errors errors; std::unique_ptr<Script> script; WastParseOptions parse_wast_options(s_features); Result result = ParseWastScript(lexer.get(), &script, &errors, &parse_wast_options); if (Succeeded(result)) { result = ResolveNamesScript(script.get(), &errors); if (Succeeded(result) && s_validate) { ValidateOptions options(s_features); result = ValidateScript(script.get(), &errors, options); } if (Succeeded(result)) { std::vector<FilenameMemoryStreamPair> module_streams; MemoryStream json_stream; std::string module_filename_noext = StripExtension(s_outfile ? s_outfile : s_infile).to_string(); s_write_binary_options.features = s_features; result = WriteBinarySpecScript( &json_stream, script.get(), s_infile, module_filename_noext, s_write_binary_options, &module_streams, s_log_stream.get()); if (s_outfile) { json_stream.WriteToFile(s_outfile); } for (auto iter = module_streams.begin(); iter != module_streams.end(); ++iter) { iter->stream->WriteToFile(iter->filename); } } } auto line_finder = lexer->MakeLineFinder(); FormatErrorsToFile(errors, Location::Type::Text, line_finder.get()); return result != Result::Ok; } int main(int argc, char** argv) { WABT_TRY return ProgramMain(argc, argv); WABT_CATCH_BAD_ALLOC_AND_EXIT }
[ "fanliangqin@ultrain.io" ]
fanliangqin@ultrain.io
996bb966da8843fae2b00a89f223d871b9f67006
07df251f7fc5117f4759d286b87aa34f448c58e2
/chapter8/listing_8-51.cpp
15cf958b7fbb5d157de00fa6a70287dd60d04d4b
[ "BSD-3-Clause" ]
permissive
jackkolokasis/book
84b2647d51d1a57c49613f9ee25f59acb5bb759a
0514895682aa91c298088a7e713f4e39ba3eab31
refs/heads/master
2020-05-31T10:05:15.826010
2019-05-24T18:24:50
2019-05-24T18:24:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,089
cpp
/* * Copyright (c) 2019, Intel Corporation * * 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 Intel Corporation nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <emmintrin.h> #include <unistd.h> #include <stdio.h> #include <string.h> #include <stdint.h> #include <libpmemobj++/persistent_ptr.hpp> #include <libpmemobj++/make_persistent.hpp> #include <libpmemobj++/make_persistent_array.hpp> #include <libpmemobj++/transaction.hpp> #include <valgrind/pmemcheck.h> using namespace std; namespace pobj = pmem::obj; struct header_t { uint32_t counter; uint8_t reserved[60]; }; struct record_t { char name[63]; char valid; }; struct root { pobj::persistent_ptr<header_t> header; pobj::persistent_ptr<record_t[]> records; }; pobj::pool<root> pop; int main (int argc, char *argv[]) { VALGRIND_PMC_EMIT_LOG("PMREORDER_TAG.BEGIN"); pop = pobj::pool<root>::open ("/mnt/pmem/file", "RECORDS"); auto proot = pop.root (); pobj::transaction::run (pop, [&] { proot->header = pobj::make_persistent<header_t> (); proot->header->counter = 0; proot->records = pobj::make_persistent<record_t[]> (1); proot->records[0].valid = 0; }); pobj::persistent_ptr<header_t> header = proot->header; pobj::persistent_ptr<record_t[]> records = proot->records; VALGRIND_PMC_EMIT_LOG("PMREORDER_TAG.END"); header->counter = 0; for (uint8_t i = 0; i < 10; i++) { if (rand() % 2 == 0) { snprintf (records[i].name, 63, "record #%u", i + 1); pop.persist (records[i].name, 63); records[i].valid = 2; } else records[i].valid = 1; pop.persist (&(records[i].valid), 1); header->counter++; } pop.persist (&(header->counter), 4); pop.close (); return 0; }
[ "eduberrocal@gmail.com" ]
eduberrocal@gmail.com
04a634a99ef8db5060d9afb49053db6dfa83b737
4673455f303cdd96e73fb0bf5504fa0f17f52a80
/LearningUI/QToolTipperKnown.h
49239b29288e539df018c1724ef789a99f0e2f9c
[]
no_license
ComputerVisionWorks/ReconCam
547693a1e4fd956a36832cda063875a86ccad58f
cc00f524c36955c721007975aa2dc2ed14ed3bbe
refs/heads/master
2020-07-28T09:59:23.155649
2019-07-16T12:29:29
2019-07-16T12:29:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,549
h
#ifndef QTOOLTIPPERKNOWN_H #define QTOOLTIPPERKNOWN_H #include "global.h" #include <QAbstractItemView> #include <QDebug> #include <QEvent> #include <QFileSystemModel> #include <QHelpEvent> #include <QListView> #include <QObject> #include <QToolTip> class QToolTipperKnown : public QObject { Q_OBJECT public: QToolTipperKnown(QListView* listView, QListView* knownEvent, QFileSystemModel* model, QObject* parent = nullptr) : QObject(parent) , _view { listView } , _knownEvent { knownEvent } , _model { model } { } protected: bool eventFilter(QObject* watched, QEvent* event) override { // switch (event->type()) { // case QEvent::ToolTip: // case QEvent::MouseButtonPress: // break; // } if (event->type() == QEvent::ToolTip) { // QAbstractItemView* view = qobject_cast<QAbstractItemView*>(watched->parent()); // QAbstractItemView * view = static_cast<QAbstractItemView*>(parent()); // if (!view) { // return false; // } QHelpEvent* helpEvent = static_cast<QHelpEvent*>(event); QPoint pos = helpEvent->pos(); // qDebug() << "pos = " << pos; QModelIndex index = _view->indexAt(pos); // qDebug() << "index = " << index; QString itemText = _view->model()->data(index, Qt::DisplayRole).toString(); // qDebug() << itemText; QToolTip::showText(helpEvent->globalPos(), itemText, _view); } else if (event->type() == QEvent::MouseButtonPress) { QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); if (mouseEvent->button() == Qt::LeftButton) { qDebug() << "mouse button press"; QPoint pos = mouseEvent->pos(); QModelIndex index = _view->indexAt(pos); QString itemText = _view->model()->data(index, Qt::DisplayRole).toString(); qDebug() << itemText; // QFileSystemModel* model = static_cast<QFileSystemModel*>(_view->model()); _knownEvent->setRootIndex(_model->index(str_knownDir + "gauthier/")); // _knownEvent->reset(); } } else { return false; } return true; } private: QListView* _view; QListView* _knownEvent; QFileSystemModel* _model; }; #endif // QTOOLTIPPERKNOWN_H
[ "gauthierbouyjou@aol.com" ]
gauthierbouyjou@aol.com
af16abc8ad77a36cbf69cbfd51c60e6932f7e475
54fbe1a739a0d05031453f7947fa197406e2027f
/LServer/Window.cpp
1846954e1140f9c67c299dbb5acd93161d86dce6
[]
no_license
asmei1/SFML-IPS
ca3362c6d16664586949e7353a40c7d7de0b2db8
ce826e58fb5ba1c7ddf4a5ff19706f35bff67fdc
refs/heads/master
2021-10-19T14:55:56.855829
2019-02-21T20:43:13
2019-02-21T20:43:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,657
cpp
#include "Window.h" Window::Window() { Window("Window", sf::Vector2u(640, 480)); } Window::Window(const std::string &title, const sf::Vector2u &size) : windowTitle(title), windowSize(size), fullscreen(false), done(false) { create(); } void Window::create() { auto style = this->isFullscreen() ? sf::Style::Fullscreen : sf::Style::Default; sf::ContextSettings settings; settings.antialiasingLevel = 4; this->window.create({ this->windowSize.x, this->windowSize.y, 32 }, this->windowTitle, style, settings); this->window.setVerticalSyncEnabled(true); } void Window::destroy() { this->window.close(); } Window::~Window() { destroy(); } void Window::close() { this->done = true; } void Window::beginDraw() { this->window.clear(sf::Color::Black); } void Window::endDraw() { this->window.display(); } void Window::update() { sf::Event event; while (this->window.pollEvent(event)) { if (event.type == sf::Event::Closed) { this->done = true; } else if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::F5) { toggleFullscreen(); } } } bool Window::isDone() { return this->done; } bool Window::isFullscreen() { return this->fullscreen; } void Window::toggleFullscreen() { this->fullscreen != this->fullscreen; destroy(); create(); } sf::Vector2u Window::getWindowSize() { return sf::Vector2u(); } void Window::draw(sf::Drawable & drawable) { this->window.draw(drawable); } void Window::draw(sf::Vertex *verticles, size_t count, sf::PrimitiveType type) { this->window.draw(verticles, count, type); }
[ "kamsykula@gmail.com" ]
kamsykula@gmail.com
5b4000875ce52bb654cd68d936e971ff27598de9
65074e8e237be886278e6f5731298c65e082cf5e
/2018.03/25,03,2018/4-eleman silme(bas-orta-son)/İsimsiz1.cpp
3372d5822dc28e7bdb3baa64bd98b0bf501df6ec
[]
no_license
mustafaisikk/C-Programming
60b3d5d90f84b57b90d7d3333cfdaf56bcf01b00
f17987bcc3627a39104035ed03a5bf3d3d30ea37
refs/heads/master
2020-06-18T15:35:25.753047
2019-07-11T08:40:53
2019-07-11T08:40:53
196,349,210
0
0
null
null
null
null
UTF-8
C++
false
false
66
cpp
#include <stdio.h> int main(){ printf("hello world"); }
[ "mustafa@localhost.localdomain" ]
mustafa@localhost.localdomain
27145f105422114574c46cce854a934f215e8458
7d7301514d34006d19b2775ae4f967a299299ed6
/c++primer/Second_1.18_notes/13/13.5.strVec类.cpp
946ea48bb72be4f0ad467e82bfd8314ecb8b9083
[]
no_license
xmlb88/algorithm
ae83ff0e478ea01f37bc686de14f7d009d45731b
cf02d9099569e2638e60029b89fd7b384f3c1a68
refs/heads/master
2023-06-16T00:21:27.922428
2021-07-17T03:46:50
2021-07-17T03:46:50
293,984,271
1
0
null
2020-12-02T09:08:28
2020-09-09T02:44:20
C++
GB18030
C++
false
false
2,764
cpp
#include <iostream> #include <string> #include <vector> #include <memory> using namespace std; class StrVec { public: StrVec(): // allocator成员进行默认初始化 elements(nullptr), first_free(nullptr), cap(nullptr) {} StrVec(const StrVec&); StrVec &operator=(const StrVec&); StrVec(StrVec &&s) noexcept; ~StrVec(); void push_back(const std::string&); size_t size() const { return first_free - elements; } size_t capacity() const { return cap - elements; } std::string *begin() const { return elements; } std::string *end() const { return first_free; } private: static std::acclocator<std::string> alloc; // 分配元素 void chk_n_alloc() { if (size() == capacity()) reallocate(); } std::pair<std::string*, std::string*> alloc_n_copy (const std::string*, const std::string*); void free(); void reallocate(); std::string *elements; std::string *first_free; std::string *cap; } void StrVec::push_back(const string& s) { chk_n_alloc(); alloc.construct(first_free++, s); } pair<string*, string*> StrVec::alloc_n_copy(const string *b, const string *e) { auto data = alloc.allocate(e - b); return {data, uninitialized_copy(b, e, data)}; } void StrVec::free() { if (elements) { for (auto p = first_free; p != elements; ) alloc.destroy(--p); alloc.deallocate(elements, cap - elements); } } StrVec::StrVec(const StrVec &s) { auto newdata = alloc_n_copy(s.begin(), s.end()); elements = newdata.first; first_free = cap = newdata.second; } StrVec::~StrVec() { free(); } StrVec& StrVec::operator=(const StrVec &rhs) { auto data = alloc_n_copy(rhs.begin(), rhs.end()); free(); elements = data.first; first_free = cap = data.second; return *this; } #include <utility> // move void StrVec::reallocate() { auto newcapacity = size() ? 2 * size() : 1; auto newdata = alloc.allocate(newcapacity); auto dest = newdata; auto elem = elements; for (size_t i = 0; i != size(); ++i) alloc.construct(dest++, std::move(*elem++)); free(); elements = newdata; first_free = dest; cap = elements + newcapacity; } StrVec::StrVec(StrVec &&s) noexcept : // 成员初始化器接管s中的资源 elements(s.elements), first_free(s.first_free), cap(s.cap) { // 令s进入这样的状态-对其运行析构函数是安全的 s.elements = s.first_free = s.cap = nullptr; } StrVec &StrVec::operator=(StrVec &&rhs) noexcept { if (this != &rhs) { free(); elements = rhs.elements; first_free = rhs.first_free; cap = rhs.cap; rhs.elements = rhs.first_free = rhs.cap = nullptr; } return *this; }
[ "xmlb@gmail.com" ]
xmlb@gmail.com
87c04c4bc58cc8877fb3b71d9b7478852db8bd73
e888ed686e93e8f2d5562dd8ae8a72abd19c153e
/include/Discreture/detail_combinations_bf.hpp
7fb652786ef866b39afd941a52196e3ff92ca378
[ "Apache-2.0" ]
permissive
valabojub79/discreture
bd95b5568d3d472b62726a007b7d0bd5a71c079c
1943acd60cb77415a0d471e3a4c55d471b991ae4
refs/heads/master
2021-04-06T06:49:45.193167
2018-01-26T21:45:59
2018-01-26T21:45:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,432
hpp
#pragma once #include <vector> namespace dscr{ namespace detail { using std::vector; template<class combination, class Func, class IntType> void combination_helper0(Func f, IntType n) { combination x; f(x); } template<class combination, class Func, class IntType> void combination_helper1(Func f, IntType n) { combination x(1); for (x[0] = 0; x[0] < n; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper2(Func f, IntType n) { combination x(2); for (x[1] = 1; x[1] < n; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper3(Func f, IntType n) { combination x(3); for (x[2] = 2; x[2] < n ; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper4(Func f, IntType n) { combination x(4); for (x[3] = 3; x[3] < n ; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper5(Func f, IntType n) { combination x(5); for (x[4] = 4; x[4] < n; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper6(Func f, IntType n) { combination x(6); for (x[5] = 5; x[5] < n; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper7(Func f, IntType n) { combination x(7); for (x[6] = 6; x[6] < n; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper8(Func f, IntType n) { combination x(8); for (x[7] = 7; x[7] < n; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper9(Func f, IntType n) { combination x(9); for (x[8] = 8; x[8] < n; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper10(Func f, IntType n) { combination x(10); for (x[9] = 9; x[9] < n; ++x[9]) for (x[8] = 8; x[8] < x[9]; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper11(Func f, IntType n) { combination x(11); for (x[10] = 10; x[10] < n; ++x[10]) for (x[9] = 9; x[9] < x[10]; ++x[9]) for (x[8] = 8; x[8] < x[9]; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper12(Func f, IntType n) { combination x(12); for (x[11] = 11; x[11] < n; ++x[11]) for (x[10] = 10; x[10] < x[11]; ++x[10]) for (x[9] = 9; x[9] < x[10]; ++x[9]) for (x[8] = 8; x[8] < x[9]; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper13(Func f, IntType n) { combination x(13); for (x[12] = 12; x[12] < n; ++x[12]) for (x[11] = 11; x[11] < x[12]; ++x[11]) for (x[10] = 10; x[10] < x[11]; ++x[10]) for (x[9] = 9; x[9] < x[10]; ++x[9]) for (x[8] = 8; x[8] < x[9]; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper14(Func f, IntType n) { combination x(14); for (x[13] = 13; x[13] < n; ++x[13]) for (x[12] = 12; x[12] < x[13]; ++x[12]) for (x[11] = 11; x[11] < x[12]; ++x[11]) for (x[10] = 10; x[10] < x[11]; ++x[10]) for (x[9] = 9; x[9] < x[10]; ++x[9]) for (x[8] = 8; x[8] < x[9]; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper15(Func f, IntType n) { combination x(15); for (x[14] = 14; x[14] < n; ++x[14]) for (x[13] = 13; x[13] < x[14]; ++x[13]) for (x[12] = 12; x[12] < x[13]; ++x[12]) for (x[11] = 11; x[11] < x[12]; ++x[11]) for (x[10] = 10; x[10] < x[11]; ++x[10]) for (x[9] = 9; x[9] < x[10]; ++x[9]) for (x[8] = 8; x[8] < x[9]; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper16(Func f, IntType n) { combination x(16); for (x[15] = 15; x[15] < n; ++x[15]) for (x[14] = 14; x[14] < x[15]; ++x[14]) for (x[13] = 13; x[13] < x[14]; ++x[13]) for (x[12] = 12; x[12] < x[13]; ++x[12]) for (x[11] = 11; x[11] < x[12]; ++x[11]) for (x[10] = 10; x[10] < x[11]; ++x[10]) for (x[9] = 9; x[9] < x[10]; ++x[9]) for (x[8] = 8; x[8] < x[9]; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper17(Func f, IntType n) { combination x(17); for (x[16] = 16; x[16] < n; ++x[16]) for (x[15] = 15; x[15] < x[16]; ++x[15]) for (x[14] = 14; x[14] < x[15]; ++x[14]) for (x[13] = 13; x[13] < x[14]; ++x[13]) for (x[12] = 12; x[12] < x[13]; ++x[12]) for (x[11] = 11; x[11] < x[12]; ++x[11]) for (x[10] = 10; x[10] < x[11]; ++x[10]) for (x[9] = 9; x[9] < x[10]; ++x[9]) for (x[8] = 8; x[8] < x[9]; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper18(Func f, IntType n) { combination x(18); for (x[17] = 17; x[17] < n; ++x[17]) for (x[16] = 16; x[16] < x[17]; ++x[16]) for (x[15] = 15; x[15] < x[16]; ++x[15]) for (x[14] = 14; x[14] < x[15]; ++x[14]) for (x[13] = 13; x[13] < x[14]; ++x[13]) for (x[12] = 12; x[12] < x[13]; ++x[12]) for (x[11] = 11; x[11] < x[12]; ++x[11]) for (x[10] = 10; x[10] < x[11]; ++x[10]) for (x[9] = 9; x[9] < x[10]; ++x[9]) for (x[8] = 8; x[8] < x[9]; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } template<class combination, class Func, class IntType> void combination_helper19(Func f, IntType n) { combination x(19); for (x[18] = 18; x[18] < n; ++x[18]) for (x[17] = 17; x[17] < x[18]; ++x[17]) for (x[16] = 16; x[16] < x[17]; ++x[16]) for (x[15] = 15; x[15] < x[16]; ++x[15]) for (x[14] = 14; x[14] < x[15]; ++x[14]) for (x[13] = 13; x[13] < x[14]; ++x[13]) for (x[12] = 12; x[12] < x[13]; ++x[12]) for (x[11] = 11; x[11] < x[12]; ++x[11]) for (x[10] = 10; x[10] < x[11]; ++x[10]) for (x[9] = 9; x[9] < x[10]; ++x[9]) for (x[8] = 8; x[8] < x[9]; ++x[8]) for (x[7] = 7; x[7] < x[8]; ++x[7]) for (x[6] = 6; x[6] < x[7]; ++x[6]) for (x[5] = 5; x[5] < x[6]; ++x[5]) for (x[4] = 4; x[4] < x[5]; ++x[4]) for (x[3] = 3; x[3] < x[4]; ++x[3]) for (x[2] = 2; x[2] < x[3]; ++x[2]) for (x[1] = 1; x[1] < x[2]; ++x[1]) for (x[0] = 0; x[0] < x[1]; ++x[0]) { f(x); } } }} //namespace dscr::detail close
[ "mraggi@gmail.com" ]
mraggi@gmail.com
b2f89959e22be7ddb66c9d92e422e61f62551e42
8728ce574920a6727aa53468b8eb9d1e666e310b
/src/Chain/libraries/blockchain/GenesisJson.cpp
ca33cee5aa55c6c3e7fb4ea9cc0d1ee9b55e7f70
[ "MIT" ]
permissive
PinkDiamond1/TTCHAIN
f0ca5f63568f4a2c762229634190a48ef766efdd
028460c1693cfc3912ef17fcce0e09798087cff7
refs/heads/master
2023-03-15T19:31:46.767515
2018-12-12T00:43:53
2018-12-12T00:43:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
53,109
cpp
#ifndef ALP_TEST_NETWORK #include <blockchain/GenesisJson.hpp> #include <blockchain/GenesisState.hpp> #include <string> #include <fc/crypto/sha256.hpp> #include <fc/io/raw.hpp> namespace thinkyoung { namespace blockchain { static const unsigned char raw_genesis_config0[] = { 0x42, 0x4a, 0x30, 0x5b, 0x00, 0x63, 0x06, 0x6f, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x02, 0xf7, 0x1f, 0xed, 0x09, 0xc6, 0x0a, 0x0d, 0x20, 0xd8, 0x15, 0x31, 0x65, 0xbd, 0x94, 0x3e, 0xa3, 0x48, 0x55, 0x76, 0x24, 0x04, 0x87, 0xc4, 0xba, 0x8c, 0x51, 0xb9, 0xda, 0xec, 0xb5, 0x9d, 0x60, 0x06, 0x61, 0x73, 0x68, 0x74, 0x6f, 0x6e, 0x02, 0x50, 0x4b, 0x6a, 0x98, 0x0d, 0xfd, 0x72, 0xfe, 0xe2, 0x9a, 0x89, 0xc3, 0x7a, 0xa2, 0x5f, 0x52, 0xbc, 0xb2, 0xfc, 0x60, 0x9f, 0x71, 0x1e, 0x4c, 0xee, 0xcc, 0x37, 0x66, 0x2a, 0x44, 0x5e, 0x90, 0x07, 0x77, 0x69, 0x6c, 0x6c, 0x69, 0x61, 0x6d, 0x03, 0x8e, 0xd5, 0x24, 0x19, 0x74, 0x7b, 0x48, 0x88, 0x98, 0x25, 0x96, 0x02, 0xfd, 0x0e, 0x2f, 0xb2, 0x09, 0xda, 0x6c, 0xb6, 0x60, 0x43, 0xb8, 0x12, 0x1f, 0x91, 0xd2, 0xbb, 0x45, 0xfa, 0x91, 0xef, 0x03, 0x65, 0x6c, 0x69, 0x02, 0xa4, 0xcd, 0xcc, 0x0d, 0xb0, 0x57, 0x1f, 0x35, 0x2d, 0x6b, 0xc2, 0xc8, 0xd8, 0xdf, 0x5d, 0xa2, 0xd9, 0x75, 0x27, 0x01, 0x94, 0xf0, 0x86, 0x06, 0x21, 0xa5, 0xba, 0x4d, 0x59, 0x79, 0xa9, 0x75, 0x04, 0x6e, 0x6f, 0x61, 0x68, 0x02, 0x26, 0x1f, 0x4a, 0x70, 0x83, 0x09, 0x52, 0xfd, 0x93, 0xe4, 0x81, 0x87, 0x28, 0xec, 0xc7, 0x94, 0x52, 0xe7, 0xae, 0x00, 0xc5, 0x73, 0xf8, 0xc5, 0x84, 0xcb, 0x20, 0x06, 0x85, 0xa6, 0xf9, 0x26, 0x04, 0x6c, 0x75, 0x63, 0x61, 0x03, 0x06, 0x79, 0xef, 0xf8, 0x92, 0x72, 0x6e, 0x14, 0x37, 0xbf, 0xad, 0x03, 0xec, 0xcb, 0x23, 0x6b, 0x68, 0xa5, 0x7a, 0x19, 0x72, 0x5f, 0xc9, 0x14, 0x7f, 0x21, 0x47, 0xe1, 0xcb, 0x4c, 0xc9, 0xaa, 0x04, 0x6a, 0x61, 0x63, 0x6b, 0x03, 0xe6, 0x7d, 0x51, 0x5a, 0x24, 0x9f, 0x85, 0xa0, 0x60, 0xfe, 0xb3, 0xfe, 0xb3, 0xbf, 0x35, 0x86, 0xe7, 0xfa, 0x4c, 0xdb, 0x91, 0xa5, 0xb2, 0x5e, 0x43, 0x64, 0x43, 0x32, 0x96, 0x30, 0x23, 0x50, 0x07, 0x6d, 0x61, 0x74, 0x74, 0x68, 0x65, 0x77, 0x02, 0x91, 0xf2, 0x77, 0x97, 0x26, 0x6f, 0xc1, 0xef, 0x1b, 0x1b, 0x7a, 0xf1, 0xad, 0xb7, 0xbb, 0x97, 0x6f, 0xf2, 0xaf, 0xe1, 0xe9, 0x39, 0x24, 0x48, 0xb9, 0x32, 0x6e, 0xc3, 0x60, 0xbe, 0xc2, 0xf0, 0x05, 0x68, 0x65, 0x6e, 0x72, 0x79, 0x03, 0x14, 0x9d, 0x79, 0x32, 0x52, 0xcc, 0x6a, 0x11, 0x0b, 0xfb, 0x41, 0x9d, 0x48, 0xd7, 0x5d, 0x1c, 0x61, 0x2a, 0xd1, 0x99, 0x1e, 0x2c, 0xe8, 0x5a, 0x7e, 0x24, 0x7d, 0x72, 0x34, 0xe1, 0xf4, 0x90, 0x05, 0x6a, 0x61, 0x78, 0x6f, 0x6e, 0x03, 0x69, 0xc1, 0x38, 0xa7, 0xc1, 0x06, 0x23, 0x9e, 0x8b, 0x06, 0xb6, 0x56, 0xef, 0x6e, 0x6e, 0xe2, 0xca, 0x1e, 0x8b, 0x92, 0xd5, 0xfb, 0x2a, 0xae, 0x48, 0x0b, 0x7a, 0x97, 0x7f, 0xed, 0x6d, 0x14, 0x05, 0x6a, 0x61, 0x6d, 0x65, 0x73, 0x03, 0x66, 0x66, 0x8c, 0x21, 0xe4, 0x81, 0x3f, 0x88, 0x87, 0xeb, 0x92, 0xc7, 0x02, 0x62, 0xe8, 0x83, 0x94, 0x7f, 0x9e, 0x59, 0x61, 0x31, 0x56, 0xfd, 0x3d, 0xf7, 0xce, 0xfe, 0xe9, 0xd1, 0x86, 0xb2, 0x03, 0x6b, 0x61, 0x69, 0x03, 0xc6, 0x0c, 0xaa, 0x00, 0x14, 0xf2, 0x03, 0x79, 0xbc, 0xeb, 0xe9, 0xe4, 0x39, 0xc6, 0xbc, 0xb6, 0x40, 0x2c, 0xfc, 0x5d, 0xde, 0x46, 0x73, 0xc9, 0x3b, 0x35, 0x93, 0x10, 0x9e, 0xdc, 0xdb, 0xfd, 0x06, 0x74, 0x68, 0x6f, 0x6d, 0x61, 0x73, 0x03, 0x33, 0x1c, 0xaf, 0xfb, 0xeb, 0x68, 0x9d, 0x52, 0x27, 0xda, 0x1a, 0x59, 0xed, 0x5d, 0x54, 0x8a, 0x83, 0x14, 0x8a, 0x00, 0xe9, 0xad, 0xba, 0xb2, 0x0d, 0x16, 0xcc, 0xe8, 0x61, 0x03, 0x69, 0x54, 0x07, 0x7a, 0x61, 0x63, 0x68, 0x61, 0x72, 0x79, 0x02, 0x99, 0x27, 0xa0, 0xe1, 0x2a, 0x42, 0xec, 0x81, 0x61, 0x1e, 0x9c, 0x09, 0xa5, 0x4e, 0x61, 0xfd, 0xc1, 0xaf, 0xa5, 0x5b, 0x97, 0x98, 0x21, 0x0e, 0x71, 0x2a, 0xc8, 0xe5, 0xca, 0xb7, 0x49, 0x04, 0x05, 0x6c, 0x75, 0x63, 0x61, 0x73, 0x02, 0x7a, 0x30, 0x68, 0x4a, 0x6e, 0x35, 0x2c, 0x20, 0x84, 0xed, 0x9c, 0xa4, 0xa3, 0x87, 0x77, 0xab, 0xd5, 0x0a, 0x90, 0x0a, 0xc5, 0x82, 0x40, 0x62, 0x48, 0xcb, 0xa4, 0x9f, 0xc7, 0xdf, 0x7c, 0x1c, 0x07, 0x6d, 0x69, 0x63, 0x68, 0x61, 0x65, 0x6c, 0x03, 0xf7, 0x78, 0x96, 0xfb, 0x2b, 0x8e, 0x8b, 0x2b, 0x35, 0x6e, 0xde, 0xb0, 0xa4, 0x84, 0xd9, 0x24, 0x14, 0xc0, 0x6a, 0xb9, 0x4c, 0xd9, 0x99, 0x06, 0x98, 0x55, 0x3b, 0xab, 0x40, 0x2a, 0x6d, 0xc8, 0x05, 0x65, 0x74, 0x68, 0x61, 0x6e, 0x02, 0x94, 0xcd, 0x28, 0x0d, 0x35, 0x4b, 0x00, 0x7d, 0xf1, 0x6b, 0x38, 0x1a, 0xef, 0x01, 0x6a, 0x8f, 0x0c, 0x20, 0x4b, 0xd4, 0xdf, 0xb4, 0xef, 0x43, 0xc4, 0x08, 0xb1, 0x4f, 0xc4, 0xd2, 0xe8, 0x3a, 0x08, 0x6d, 0x75, 0x68, 0x61, 0x6d, 0x6d, 0x61, 0x64, 0x03, 0xdc, 0x87, 0xf3, 0x7f, 0xbd, 0x07, 0xdb, 0x51, 0x09, 0x56, 0xca, 0xa9, 0x4f, 0x7e, 0x6d, 0x0f, 0x59, 0xe3, 0x78, 0x78, 0xd6, 0x36, 0xd0, 0xc5, 0x6b, 0xb1, 0x77, 0xc1, 0xca, 0x9e, 0x1b, 0x17, 0x09, 0x61, 0x6c, 0x65, 0x78, 0x61, 0x6e, 0x64, 0x65, 0x72, 0x02, 0x54, 0x9f, 0x17, 0xa9, 0x47, 0x04, 0xd7, 0x3c, 0xd0, 0x30, 0x44, 0x48, 0x2c, 0xea, 0x21, 0x33, 0x5c, 0xdf, 0x53, 0xd4, 0xe3, 0x14, 0xd2, 0x17, 0x8f, 0x98, 0x0e, 0x40, 0x2f, 0x64, 0x83, 0x17, 0x05, 0x66, 0x6c, 0x79, 0x6e, 0x6e, 0x03, 0x01, 0x6f, 0x77, 0xbb, 0x94, 0x6d, 0xd7, 0xe8, 0x4d, 0xd8, 0x8a, 0xac, 0x23, 0xea, 0xae, 0x90, 0x9e, 0x9a, 0x69, 0x40, 0x9c, 0x34, 0x4e, 0x9f, 0x96, 0x15, 0xa4, 0x8d, 0x47, 0x67, 0x81, 0xb0, 0x04, 0x6c, 0x69, 0x61, 0x6d, 0x02, 0x45, 0xde, 0x92, 0x46, 0x29, 0xd4, 0x27, 0x82, 0x57, 0x4f, 0x0b, 0x8a, 0xec, 0xf3, 0x85, 0xb6, 0x58, 0xdc, 0x8d, 0x45, 0xc9, 0x5f, 0x0b, 0xfa, 0xba, 0x71, 0x40, 0xea, 0xae, 0xd7, 0x53, 0x34, 0x07, 0x67, 0x61, 0x62, 0x72, 0x69, 0x65, 0x6c, 0x02, 0xb0, 0x9e, 0xd7, 0xe6, 0x39, 0x25, 0x55, 0x9e, 0xef, 0x6e, 0x05, 0x55, 0x27, 0xf8, 0xa4, 0xc4, 0xbc, 0xe3, 0x68, 0x5f, 0xae, 0x85, 0x38, 0x49, 0xc1, 0xeb, 0xd1, 0x54, 0xca, 0x19, 0x95, 0xd2, 0x07, 0x6c, 0x61, 0x63, 0x68, 0x6c, 0x61, 0x6e, 0x03, 0x3e, 0x0f, 0x81, 0x2f, 0x58, 0x4e, 0x2e, 0x7b, 0x2b, 0xcd, 0x83, 0x14, 0x84, 0xf1, 0x97, 0xb9, 0xc1, 0x35, 0x7d, 0x52, 0x51, 0xdb, 0x32, 0x02, 0xa3, 0xdc, 0x2a, 0x36, 0x01, 0xb2, 0xde, 0x13, 0x05, 0x74, 0x79, 0x6c, 0x65, 0x72, 0x03, 0xcd, 0x05, 0x33, 0xfd, 0x2f, 0xc3, 0x47, 0x99, 0x45, 0x01, 0xf7, 0x9d, 0xd6, 0x16, 0x56, 0x8f, 0xb7, 0x0f, 0xe2, 0x9e, 0xe9, 0x16, 0x40, 0x87, 0xfa, 0x3f, 0x7f, 0xe8, 0x03, 0x26, 0xe4, 0x51, 0x03, 0x6c, 0x65, 0x6f, 0x02, 0x9c, 0x40, 0x2b, 0x27, 0x69, 0xd8, 0x3e, 0xaa, 0x81, 0x9a, 0x93, 0x3c, 0xce, 0x58, 0xb9, 0xd2, 0xa7, 0xd0, 0x16, 0x1b, 0x01, 0xc3, 0xec, 0x1f, 0xe3, 0xed, 0x43, 0xbc, 0x69, 0x59, 0x76, 0x09, 0x06, 0x63, 0x6f, 0x6e, 0x6e, 0x6f, 0x72, 0x02, 0x48, 0x27, 0xdd, 0x77, 0x5b, 0xdb, 0x94, 0x27, 0xd9, 0x49, 0x83, 0x09, 0xe1, 0x31, 0x05, 0xfc, 0x30, 0x88, 0x31, 0xab, 0x67, 0x74, 0xb7, 0xc5, 0xb6, 0x31, 0xdd, 0x8a, 0xa0, 0x94, 0x42, 0x4b, 0x08, 0x68, 0x61, 0x72, 0x72, 0x69, 0x73, 0x6f, 0x6e, 0x03, 0xd7, 0x4b, 0x4d, 0xfa, 0x5c, 0xf0, 0x2b, 0x35, 0xfc, 0x51, 0xdf, 0x43, 0x7f, 0xbe, 0xf0, 0xa7, 0x82, 0x2a, 0x85, 0x44, 0xc6, 0x43, 0x8d, 0xb8, 0x59, 0xea, 0x13, 0x82, 0xfd, 0x9b, 0x19, 0xb8, 0x05, 0x64, 0x79, 0x6c, 0x61, 0x6e, 0x02, 0x87, 0x13, 0x2b, 0x34, 0x93, 0xd1, 0x19, 0x60, 0x2b, 0x76, 0x80, 0x02, 0xbb, 0xa0, 0xf8, 0x9b, 0x9e, 0xb2, 0x51, 0x68, 0x73, 0xc6, 0xa0, 0x19, 0x24, 0x6a, 0xb6, 0x6d, 0x43, 0xb6, 0x5b, 0x2c, 0x06, 0x73, 0x61, 0x6d, 0x75, 0x65, 0x6c, 0x02, 0x57, 0xfc, 0xc5, 0xd8, 0xfa, 0xad, 0x3c, 0xbc, 0x5d, 0xc2, 0x49, 0xec, 0x40, 0x17, 0xdf, 0x20, 0xc5, 0x7a, 0x27, 0xf7, 0x65, 0x3a, 0xc2, 0x51, 0xb4, 0x0d, 0x0a, 0xf0, 0xbc, 0xf6, 0x59, 0xf8, 0x07, 0x70, 0x61, 0x74, 0x72, 0x69, 0x63, 0x6b, 0x03, 0x9a, 0xf9, 0xcb, 0x95, 0x4c, 0x47, 0xa1, 0x8d, 0xa5, 0xfa, 0x3f, 0x32, 0xa4, 0x16, 0xa4, 0xa7, 0x3a, 0x76, 0x5f, 0x4d, 0x74, 0xfb, 0xe9, 0x63, 0xc9, 0x2c, 0xc8, 0x05, 0xa2, 0xc9, 0x27, 0x4e, 0x05, 0x69, 0x73, 0x61, 0x61, 0x63, 0x03, 0xdf, 0x51, 0xdc, 0x21, 0x14, 0x2d, 0xad, 0x89, 0x7b, 0xfb, 0xbc, 0xb9, 0xca, 0xc2, 0xad, 0x7c, 0x69, 0x15, 0x52, 0x06, 0x53, 0x6c, 0xf5, 0x53, 0xad, 0x09, 0x39, 0x64, 0x62, 0xfe, 0xb2, 0x25, 0x03, 0x61, 0x6c, 0x69, 0x02, 0xf4, 0x63, 0xde, 0x5c, 0x48, 0x35, 0x61, 0x16, 0x0f, 0x0f, 0x34, 0x45, 0xfc, 0xe8, 0x1c, 0xc9, 0x33, 0x3d, 0xda, 0xf6, 0xf6, 0x2f, 0x98, 0xd1, 0x49, 0xb7, 0x49, 0x48, 0x34, 0x31, 0x6c, 0xb4, 0x05, 0x6a, 0x61, 0x63, 0x6f, 0x62, 0x02, 0x73, 0xb9, 0x82, 0x19, 0x57, 0xc2, 0x31, 0x5d, 0xad, 0x06, 0xcd, 0x9c, 0x18, 0xf9, 0x23, 0x64, 0xe2, 0x6c, 0x3c, 0xb5, 0x6e, 0xb8, 0x41, 0xb3, 0xd5, 0xba, 0x03, 0x4f, 0xe7, 0x19, 0xe3, 0x7a, 0x06, 0x61, 0x75, 0x73, 0x74, 0x69, 0x6e, 0x02, 0x79, 0xa9, 0x1d, 0x1c, 0xa3, 0xac, 0xbb, 0x54, 0x16, 0xe1, 0x40, 0x7c, 0xd1, 0x78, 0x9e, 0x8b, 0x9f, 0x05, 0xef, 0xc8, 0x81, 0xdb, 0xa0, 0xea, 0x07, 0x08, 0x46, 0xbc, 0xc7, 0x04, 0x95, 0x3c, 0x06, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x03, 0x20, 0x5e, 0xa0, 0x58, 0x54, 0x6e, 0x21, 0x33, 0xce, 0xc1, 0x63, 0x6b, 0xca, 0xad, 0x9b, 0x26, 0x19, 0xdb, 0xd7, 0x8e, 0x48, 0x9d, 0xb5, 0x9e, 0xdc, 0x19, 0x54, 0x2c, 0xbd, 0x76, 0x4b, 0x46, 0x09, 0x63, 0x68, 0x72, 0x69, 0x73, 0x74, 0x69, 0x61, 0x6e, 0x02, 0xc3, 0x34, 0x24, 0x3f, 0x5e, 0x84, 0x4f, 0xa7, 0x42, 0xfa, 0x07, 0x7c, 0x1c, 0x1b, 0x6d, 0x82, 0xf1, 0x34, 0x5c, 0x3d, 0xe1, 0x16, 0xe2, 0xf9, 0x1a, 0x80, 0xd7, 0x21, 0x94, 0x30, 0x4c, 0x89, 0x05, 0x6d, 0x61, 0x73, 0x6f, 0x6e, 0x02, 0x8e, 0x3a, 0x9e, 0x3d, 0xeb, 0x10, 0x63, 0x71, 0x43, 0x06, 0xe0, 0xfe, 0x8b, 0x8b, 0x51, 0xc0, 0xb0, 0xdf, 0x23, 0x96, 0x4e, 0xb5, 0x0a, 0x18, 0xa4, 0xea, 0x56, 0xf9, 0xe9, 0x92, 0x46, 0x80, 0x08, 0x6e, 0x69, 0x63, 0x68, 0x6f, 0x6c, 0x61, 0x73, 0x03, 0x7b, 0xd6, 0x3b, 0xbe, 0xbd, 0x53, 0xb3, 0xbc, 0x61, 0xf7, 0x3b, 0x35, 0xa9, 0x2d, 0x03, 0xa1, 0x8f, 0xaf, 0x6e, 0xf1, 0x54, 0x86, 0x3a, 0xbf, 0xc5, 0x3a, 0x13, 0xb9, 0x12, 0x85, 0x46, 0x52, 0x07, 0x63, 0x68, 0x61, 0x72, 0x6c, 0x69, 0x65, 0x03, 0x22, 0x4c, 0x51, 0xd1, 0x78, 0x44, 0xda, 0xa5, 0xb2, 0x0d, 0x1d, 0x19, 0xe8, 0x40, 0xc2, 0x8c, 0xe6, 0x85, 0x8f, 0x24, 0xa0, 0xdb, 0x18, 0xa8, 0x0c, 0x82, 0x49, 0xd3, 0x7b, 0x37, 0x3a, 0xa5, 0x06, 0x6a, 0x61, 0x73, 0x70, 0x65, 0x72, 0x02, 0x16, 0xe0, 0xaa, 0xcf, 0x6d, 0x32, 0x40, 0xa5, 0xa6, 0xc9, 0x6a, 0xeb, 0x1e, 0x72, 0x0c, 0x91, 0x1a, 0x9b, 0x9d, 0x52, 0xfd, 0x02, 0x57, 0xc2, 0xa2, 0xe5, 0x5f, 0x13, 0xec, 0x45, 0x61, 0x51, 0x05, 0x68, 0x61, 0x72, 0x72, 0x79, 0x02, 0x62, 0x8e, 0x2d, 0x5c, 0x20, 0x4e, 0x1b, 0x99, 0xda, 0x94, 0x07, 0xa3, 0x43, 0xa4, 0x80, 0x9c, 0x6f, 0x4f, 0x66, 0x63, 0xd8, 0x45, 0xd6, 0xc1, 0xc0, 0x3b, 0x8d, 0xea, 0xff, 0x7a, 0xa6, 0x11, 0x05, 0x6c, 0x6f, 0x75, 0x69, 0x73, 0x03, 0x6f, 0x2d, 0x1c, 0xea, 0xc5, 0xfd, 0x42, 0xb3, 0xc7, 0x95, 0xda, 0x81, 0x87, 0x5e, 0x97, 0x38, 0x07, 0x28, 0x0a, 0x6d, 0x21, 0x85, 0x96, 0xe2, 0x60, 0x6b, 0xa5, 0xcb, 0xd1, 0x27, 0x43, 0x63, 0x05, 0x6f, 0x73, 0x63, 0x61, 0x72, 0x03, 0x94, 0x8f, 0x29, 0x59, 0x4e, 0x5b, 0x45, 0x06, 0x40, 0x25, 0xa2, 0xa9, 0x73, 0x5b, 0xb0, 0xbf, 0x74, 0x1c, 0x02, 0xbe, 0xeb, 0x99, 0x3a, 0x00, 0x88, 0x0d, 0xd5, 0xef, 0x67, 0xba, 0x4e, 0x82, 0x04, 0x74, 0x6f, 0x62, 0x79, 0x03, 0x35, 0x7e, 0xd5, 0x18, 0xc9, 0xf0, 0x3a, 0xa6, 0x8d, 0x3e, 0x76, 0x57, 0x6f, 0x8e, 0x91, 0x46, 0x8a, 0x8e, 0x90, 0x98, 0x76, 0xa6, 0x7f, 0x9c, 0xf6, 0xd7, 0x9f, 0xbb, 0x68, 0x8c, 0xb1, 0xa4, 0x06, 0x6a, 0x6f, 0x73, 0x68, 0x75, 0x61, 0x03, 0x1c, 0x68, 0xc1, 0xb8, 0x67, 0xaa, 0x98, 0xf1, 0x31, 0xe8, 0xe2, 0x19, 0x99, 0x6b, 0xc4, 0x14, 0x4d, 0xac, 0x38, 0x95, 0xb3, 0x79, 0x31, 0x89, 0x31, 0xa6, 0xd4, 0x9b, 0x60, 0xfc, 0xa8, 0x6b, 0x06, 0x6a, 0x6f, 0x72, 0x64, 0x61, 0x6e, 0x02, 0x90, 0xc9, 0x00, 0x02, 0x5a, 0x02, 0x2d, 0xda, 0x53, 0xcd, 0x5a, 0x57, 0xeb, 0x62, 0x8c, 0x6d, 0xad, 0xb1, 0xe4, 0x56, 0x30, 0x95, 0x5d, 0x2b, 0x63, 0x14, 0xba, 0x02, 0x30, 0x12, 0x11, 0x45, 0x04, 0x72, 0x79, 0x61, 0x6e, 0x03, 0x0e, 0xb7, 0x97, 0xe2, 0xd2, 0x5b, 0xd2, 0x16, 0xe4, 0xb7, 0x5d, 0xe0, 0x20, 0xe8, 0x28, 0x40, 0xf3, 0x0f, 0x45, 0x5f, 0x5b, 0xb0, 0xfb, 0x83, 0x6d, 0xeb, 0xbe, 0xbe, 0x72, 0xb5, 0x4a, 0x47, 0x07, 0x63, 0x68, 0x61, 0x72, 0x6c, 0x65, 0x73, 0x02, 0xad, 0x9c, 0xf8, 0xdb, 0xa5, 0xe6, 0x7d, 0xbb, 0x52, 0x1a, 0xfb, 0xe4, 0xbc, 0x51, 0x1b, 0x0b, 0x90, 0x71, 0xc6, 0xbb, 0x44, 0xf5, 0xa8, 0xa8, 0x74, 0x53, 0xc3, 0xf4, 0x75, 0xab, 0xd1, 0x8c, 0x06, 0x65, 0x6c, 0x69, 0x6a, 0x61, 0x68, 0x03, 0x73, 0x40, 0x16, 0x14, 0x47, 0x47, 0x9d, 0x80, 0xb1, 0xc1, 0x43, 0x5d, 0x95, 0x7a, 0x73, 0x2f, 0x72, 0x3e, 0x48, 0xf9, 0x75, 0x41, 0x94, 0x90, 0x1c, 0xaa, 0x30, 0x70, 0xb1, 0xc1, 0x0a, 0x21, 0x06, 0x68, 0x61, 0x6d, 0x69, 0x73, 0x68, 0x02, 0xf1, 0xc3, 0x0a, 0xa7, 0xea, 0x92, 0xf6, 0x4a, 0x1a, 0xae, 0x63, 0x12, 0xf2, 0x48, 0x7f, 0xc1, 0xce, 0x9d, 0x0e, 0xd1, 0xff, 0x0e, 0xe2, 0xdc, 0xe3, 0xba, 0x04, 0x64, 0xba, 0x48, 0x64, 0xb4, 0x06, 0x68, 0x61, 0x72, 0x76, 0x65, 0x79, 0x02, 0x54, 0x03, 0x95, 0x71, 0x2b, 0xb7, 0xb6, 0x91, 0xae, 0x0e, 0xf0, 0x96, 0x08, 0xf3, 0x0f, 0x36, 0xc8, 0xc2, 0xdc, 0xd2, 0xad, 0xfe, 0xc2, 0x2d, 0x84, 0x29, 0xdc, 0x76, 0x1f, 0xc4, 0x28, 0x12, 0x06, 0x6d, 0x61, 0x72, 0x63, 0x75, 0x73, 0x03, 0x21, 0x2e, 0x28, 0xb9, 0xe9, 0x47, 0x14, 0x5e, 0x24, 0xbf, 0x71, 0xbb, 0x2d, 0xd0, 0x3e, 0xa6, 0xf4, 0xfb, 0xeb, 0xc6, 0xb4, 0x95, 0xbe, 0x4e, 0x52, 0x55, 0xf3, 0x6e, 0x8b, 0x18, 0x67, 0xdd, 0x06, 0x78, 0x61, 0x76, 0x69, 0x65, 0x72, 0x02, 0xff, 0x78, 0x0a, 0xc6, 0x4c, 0x10, 0x4e, 0x17, 0x6d, 0x88, 0x2c, 0xc8, 0xac, 0xe8, 0xe4, 0x88, 0x3c, 0x91, 0xb0, 0x61, 0x19, 0x80, 0x9c, 0x03, 0xff, 0xc9, 0xa6, 0x23, 0x05, 0xcd, 0x91, 0xa9, 0x05, 0x61, 0x61, 0x72, 0x6f, 0x6e, 0x02, 0x4d, 0x54, 0xf8, 0xbe, 0xe0, 0xd7, 0x75, 0x5d, 0xeb, 0xf1, 0x76, 0xa8, 0x64, 0x7d, 0x1c, 0x06, 0x04, 0xe3, 0x93, 0xb7, 0x3c, 0xe4, 0x33, 0x7c, 0x9b, 0xd7, 0x41, 0x53, 0x14, 0x21, 0xe7, 0xba, 0x04, 0x6c, 0x65, 0x76, 0x69, 0x03, 0x1a, 0x53, 0xf9, 0xd5, 0x83, 0x9e, 0xb4, 0xe0, 0x7c, 0x7e, 0x8d, 0x1e, 0x88, 0xee, 0x6c, 0x58, 0x09, 0x2e, 0x42, 0xdf, 0x2f, 0xb6, 0x20, 0xb6, 0xd4, 0x19, 0x0a, 0x19, 0xab, 0xa2, 0x5c, 0x5d, 0x04, 0x6f, 0x77, 0x65, 0x6e, 0x03, 0xa5, 0x75, 0x36, 0xaa, 0x2d, 0xb9, 0xc3, 0x49, 0xc7, 0xb1, 0x76, 0x3f, 0x41, 0x52, 0xd2, 0x18, 0xa6, 0x2c, 0xed, 0x41, 0x4e, 0xa0, 0x6a, 0xa4, 0xae, 0xd2, 0x17, 0x9c, 0x12, 0x12, 0xf5, 0x8c, 0x06, 0x67, 0x65, 0x6f, 0x72, 0x67, 0x65, 0x02, 0x8e, 0x7b, 0x57, 0xf2, 0x32, 0x09, 0xb6, 0xae, 0xfb, 0xfd, 0xd5, 0xa2, 0x70, 0xf9, 0x3c, 0x31, 0xe9, 0x45, 0x13, 0x06, 0xb7, 0x15, 0x4b, 0x1d, 0x6f, 0x54, 0x0f, 0x0c, 0x9c, 0x2c, 0x91, 0x4d, 0x04, 0x62, 0x65, 0x61, 0x75, 0x03, 0xc6, 0xd2, 0x3d, 0xe7, 0xc4, 0xab, 0xdc, 0x77, 0x9a, 0x8e, 0x6e, 0x93, 0x3d, 0xf8, 0x88, 0xea, 0xbd, 0x98, 0xef, 0xc0, 0xb3, 0x15, 0x55, 0xd1, 0x6e, 0x6d, 0x6e, 0x57, 0x47, 0xb2, 0x6b, 0xfd, 0x06, 0x61, 0x72, 0x63, 0x68, 0x69, 0x65, 0x02, 0xee, 0xdd, 0xb4, 0xe5, 0x07, 0xf4, 0xf7, 0xf7, 0x9f, 0xe7, 0xd4, 0x9d, 0x2a, 0x47, 0x7b, 0x18, 0x03, 0x72, 0x7b, 0xc5, 0x60, 0x22, 0x9c, 0xd9, 0x28, 0x9f, 0x34, 0x66, 0xd6, 0xae, 0x09, 0x34, 0x06, 0x63, 0x61, 0x72, 0x74, 0x65, 0x72, 0x03, 0x4c, 0xb8, 0x42, 0xa3, 0x59, 0xfb, 0x4a, 0x06, 0x24, 0xe3, 0xfb, 0xe7, 0xce, 0xc5, 0xa2, 0xd4, 0xaf, 0x5c, 0xaf, 0x83, 0x57, 0x93, 0x61, 0xb5, 0xe6, 0xfb, 0x9b, 0x57, 0xc8, 0x04, 0x83, 0x6f, 0x08, 0x62, 0x65, 0x6e, 0x6a, 0x61, 0x6d, 0x69, 0x6e, 0x03, 0x50, 0xa5, 0x0e, 0x8d, 0x6f, 0x3d, 0x2d, 0x0c, 0x95, 0x83, 0x25, 0xf1, 0x12, 0xf9, 0x15, 0x9e, 0x47, 0x87, 0x77, 0x34, 0x0e, 0x38, 0xac, 0x54, 0x4d, 0xc0, 0x82, 0x69, 0x2d, 0xa9, 0xd7, 0xc8, 0x04, 0x6a, 0x61, 0x6b, 0x65, 0x03, 0x98, 0xf2, 0xc4, 0x9e, 0x8b, 0x3c, 0xc0, 0x19, 0x14, 0x24, 0x3b, 0xe4, 0x9a, 0x54, 0x84, 0xae, 0xfa, 0x0d, 0x24, 0x26, 0xec, 0x23, 0xa6, 0x6e, 0x4a, 0x39, 0x10, 0x0f, 0x8d, 0xe3, 0x8a, 0xdc, 0x05, 0x6c, 0x6f, 0x67, 0x61, 0x6e, 0x03, 0xfa, 0xac, 0x4d, 0x50, 0x0c, 0xcc, 0x66, 0x05, 0x4d, 0xff, 0x80, 0xf1, 0x0d, 0x1a, 0x7b, 0x21, 0x49, 0xd4, 0x99, 0x54, 0x22, 0x9d, 0x20, 0xa9, 0x2b, 0x90, 0x48, 0xe5, 0x8d, 0x0b, 0x96, 0x20, 0x05, 0x64, 0x61, 0x72, 0x63, 0x79, 0x03, 0xc7, 0x1d, 0x37, 0x0b, 0x0f, 0xb3, 0x2e, 0x1d, 0x81, 0x95, 0x94, 0x2a, 0x3f, 0x5c, 0x28, 0x8c, 0xe3, 0xae, 0x4d, 0xa8, 0xa0, 0xcd, 0xb3, 0xa7, 0x94, 0xd2, 0xef, 0x03, 0xac, 0x6e, 0xaa, 0x98, 0x03, 0x6d, 0x61, 0x78, 0x02, 0xb4, 0xf3, 0x34, 0xc6, 0x52, 0x0c, 0x6e, 0xd1, 0x2b, 0x24, 0x9d, 0x51, 0x3f, 0x6c, 0x7a, 0xb4, 0x43, 0xb2, 0xd2, 0x07, 0x55, 0xda, 0x8c, 0x29, 0x33, 0x46, 0xf1, 0xe8, 0x26, 0x6c, 0x3b, 0x93, 0x05, 0x66, 0x65, 0x6c, 0x69, 0x78, 0x03, 0xd8, 0xe4, 0xfc, 0xd0, 0xe3, 0xd0, 0x24, 0x4d, 0x0e, 0x31, 0x3b, 0x50, 0xae, 0xbd, 0xe5, 0xda, 0x11, 0x90, 0xa8, 0xea, 0x4a, 0xfb, 0xe4, 0xbe, 0x56, 0xf0, 0x57, 0xf3, 0xa3, 0xa9, 0x4e, 0xf3, 0x09, 0x73, 0x65, 0x62, 0x61, 0x73, 0x74, 0x69, 0x61, 0x6e, 0x02, 0x47, 0x92, 0xb9, 0x9c, 0x8e, 0x41, 0xdd, 0x92, 0xcf, 0xc4, 0x1c, 0x36, 0x2a, 0x13, 0x60, 0x9d, 0x23, 0xd8, 0x47, 0x9a, 0x57, 0xc5, 0x79, 0x3c, 0xed, 0xdf, 0x8e, 0x4d, 0x75, 0x2c, 0x1e, 0xdc, 0x06, 0x61, 0x72, 0x74, 0x68, 0x75, 0x72, 0x02, 0xfc, 0x6d, 0x5c, 0xd0, 0x5c, 0x7f, 0x08, 0xf4, 0x61, 0x03, 0xa8, 0x9b, 0x10, 0x66, 0xdc, 0xc6, 0xbf, 0x93, 0x0f, 0x5c, 0xdb, 0xcc, 0xf5, 0xec, 0x9d, 0xa7, 0x2c, 0xb1, 0xb6, 0x7f, 0xe4, 0xe0, 0x06, 0x63, 0x6f, 0x6f, 0x70, 0x65, 0x72, 0x02, 0x55, 0x8f, 0xfb, 0xdc, 0x7b, 0xe4, 0x2b, 0xd2, 0x72, 0xdd, 0x6f, 0x6c, 0x64, 0x45, 0xc7, 0x13, 0xfe, 0x77, 0x87, 0x30, 0x7c, 0x16, 0x87, 0x61, 0xd5, 0xc4, 0x31, 0xd8, 0x80, 0x45, 0x63, 0x0f, 0x06, 0x69, 0x73, 0x61, 0x69, 0x61, 0x68, 0x03, 0x86, 0xe8, 0xe1, 0x8a, 0xd9, 0xd7, 0x45, 0x00, 0x89, 0x36, 0x30, 0xa4, 0x86, 0xf6, 0xc9, 0xc4, 0x52, 0x0d, 0xba, 0x17, 0x2b, 0x94, 0x21, 0xcc, 0x43, 0xbb, 0x99, 0x33, 0xd5, 0xa5, 0x64, 0x21, 0x06, 0x68, 0x75, 0x64, 0x73, 0x6f, 0x6e, 0x03, 0xff, 0x58, 0x34, 0xa2, 0xce, 0x08, 0xbc, 0x6b, 0xcd, 0xbd, 0x65, 0xc2, 0x3f, 0xe5, 0xbc, 0x78, 0x4d, 0x0d, 0x88, 0xf7, 0x48, 0x02, 0xba, 0x55, 0x0c, 0x0b, 0x8a, 0xbf, 0xb7, 0x35, 0xdb, 0xa2, 0x04, 0x6c, 0x75, 0x6b, 0x65, 0x02, 0xeb, 0x93, 0x3e, 0x28, 0x3c, 0xd7, 0x02, 0x24, 0x39, 0x08, 0x24, 0x1c, 0x59, 0x5c, 0x14, 0xeb, 0x7f, 0xe5, 0x7a, 0xfa, 0x90, 0xdf, 0xee, 0xbe, 0x77, 0x38, 0xc0, 0x96, 0x18, 0xcb, 0xff, 0xfc, 0x06, 0x6a, 0x61, 0x79, 0x64, 0x65, 0x6e, 0x03, 0x15, 0x5c, 0x65, 0x09, 0x6d, 0xa4, 0x7d, 0xbd, 0x1a, 0x27, 0xed, 0x55, 0xde, 0x6f, 0xab, 0x1a, 0x49, 0xa4, 0x21, 0xb6, 0x27, 0xb0, 0xf4, 0xc5, 0x15, 0x7c, 0x86, 0x17, 0x8f, 0x3c, 0x38, 0x82, 0x05, 0x63, 0x61, 0x6c, 0x65, 0x62, 0x03, 0xe2, 0x61, 0xce, 0x44, 0xab, 0x51, 0x3d, 0x42, 0x60, 0xb9, 0x5c, 0x3b, 0x9c, 0xaa, 0x6a, 0xd7, 0x91, 0x45, 0x59, 0xab, 0x39, 0x85, 0x9d, 0xf0, 0x8b, 0x49, 0x1b, 0x3e, 0x57, 0x9f, 0xa6, 0x31, 0x04, 0x68, 0x75, 0x67, 0x6f, 0x03, 0x36, 0x44, 0x5c, 0xc2, 0xad, 0xb6, 0x7b, 0xaa, 0x10, 0x38, 0x74, 0xd9, 0x72, 0xb5, 0xe5, 0x57, 0xfe, 0x53, 0x0a, 0x65, 0x2c, 0x52, 0x9d, 0x2c, 0xbe, 0xb3, 0x5a, 0x63, 0xd4, 0xdd, 0xbd, 0x18, 0x05, 0x61, 0x6e, 0x67, 0x75, 0x73, 0x03, 0x95, 0x5b, 0x95, 0x97, 0x23, 0xe4, 0x97, 0x72, 0x3f, 0x2e, 0x13, 0xba, 0x20, 0xcb, 0x99, 0x64, 0x27, 0x59, 0x3f, 0x2c, 0x2c, 0xd1, 0xa6, 0x6b, 0xf9, 0x84, 0x8a, 0x04, 0xe7, 0xda, 0xf1, 0x41, 0x06, 0x64, 0x61, 0x6e, 0x69, 0x65, 0x6c, 0x02, 0x2b, 0x0f, 0xa8, 0x9e, 0x08, 0x4a, 0x26, 0x52, 0x75, 0x45, 0x23, 0x78, 0x37, 0xec, 0x33, 0xfd, 0xdb, 0x7a, 0xcc, 0xeb, 0x4f, 0x26, 0x12, 0xd6, 0x13, 0x9f, 0x51, 0x47, 0x05, 0x11, 0x7a, 0xa1, 0x09, 0x6e, 0x61, 0x74, 0x68, 0x61, 0x6e, 0x69, 0x65, 0x6c, 0x03, 0xeb, 0x6d, 0x28, 0xcc, 0xca, 0x57, 0x3b, 0x52, 0xe2, 0x18, 0x45, 0x9d, 0x3b, 0x7b, 0xfe, 0xae, 0x5e, 0x4f, 0x97, 0xde, 0x31, 0xab, 0x59, 0x82, 0x63, 0x47, 0xb4, 0xdc, 0x03, 0x24, 0x10, 0x56, 0x04, 0x66, 0x69, 0x6e, 0x6e, 0x02, 0xa1, 0x35, 0x0f, 0x81, 0xe2, 0x8c, 0xc6, 0x81, 0x02, 0xc9, 0xeb, 0x27, 0x2c, 0xc8, 0xe5, 0xca, 0xf5, 0xc1, 0x7d, 0x0c, 0x9d, 0x70, 0xd0, 0x13, 0x94, 0x84, 0x7f, 0x7f, 0xc6, 0x0c, 0xac, 0x30, 0x04, 0x6a, 0x6f, 0x68, 0x6e, 0x03, 0xec, 0xe4, 0xe3, 0x24, 0x81, 0x04, 0xf8, 0x2e, 0xd5, 0xff, 0x5a, 0x6d, 0xf3, 0x9c, 0x32, 0x68, 0x7c, 0x55, 0xa2, 0xb4, 0x64, 0x0e, 0x84, 0xcb, 0x88, 0xc6, 0x53, 0x19, 0x96, 0xd6, 0x53, 0xee, 0x08, 0x74, 0x68, 0x65, 0x6f, 0x64, 0x6f, 0x72, 0x65, 0x02, 0xe6, 0xe3, 0x2c, 0xf4, 0xf8, 0x04, 0xee, 0xe2, 0x00, 0x13, 0x14, 0x0b, 0xb7, 0x35, 0x56, 0xd3, 0x0e, 0x94, 0x45, 0xe1, 0xd1, 0xf0, 0xe2, 0x87, 0x96, 0x5d, 0x59, 0x26, 0x5a, 0x53, 0xc4, 0xde, 0x07, 0x64, 0x6f, 0x6d, 0x69, 0x6e, 0x69, 0x63, 0x02, 0xeb, 0x4c, 0x1b, 0x2a, 0x71, 0xbf, 0x38, 0x6c, 0xc9, 0xa6, 0x25, 0xcf, 0x5e, 0x45, 0x05, 0x3c, 0x49, 0x10, 0x2f, 0x17, 0xa4, 0xfd, 0x57, 0xf5, 0xcf, 0x1d, 0xf3, 0xf3, 0x1e, 0x8a, 0xaa, 0xf9, 0x06, 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x03, 0x68, 0xca, 0x1d, 0xbb, 0xd8, 0x6d, 0x00, 0xf6, 0xdd, 0x97, 0xe4, 0x56, 0x3f, 0x9a, 0xd7, 0x63, 0x40, 0x64, 0x1f, 0x8e, 0x8e, 0x33, 0x92, 0xca, 0xb2, 0x65, 0x83, 0x01, 0xe3, 0x24, 0x21, 0x72, 0x04, 0x6e, 0x61, 0x74, 0x65, 0x03, 0xbe, 0xab, 0x5a, 0x7e, 0x84, 0x65, 0x7a, 0x4f, 0xc3, 0x02, 0xd4, 0xca, 0xfa, 0x0b, 0x27, 0x73, 0xeb, 0x65, 0x77, 0xe7, 0x1f, 0x72, 0xd9, 0xec, 0x56, 0x08, 0xd3, 0x88, 0x86, 0x36, 0x4c, 0x94, 0x05, 0x72, 0x69, 0x6c, 0x65, 0x79, 0x02, 0xb6, 0x0e, 0x8c, 0xd4, 0x86, 0x97, 0xb1, 0xd5, 0xa4, 0x82, 0x58, 0x7a, 0x34, 0x9e, 0xe0, 0x09, 0x10, 0x52, 0x3a, 0x80, 0xb9, 0x00, 0x4d, 0x77, 0x8b, 0xc1, 0x82, 0x5c, 0x49, 0xf1, 0x39, 0x96, 0x07, 0x61, 0x6e, 0x74, 0x68, 0x6f, 0x6e, 0x79, 0x03, 0x11, 0x70, 0x32, 0xe5, 0xe6, 0xd1, 0x77, 0xef, 0x61, 0x57, 0x74, 0xcd, 0x8a, 0xb8, 0x36, 0x3b, 0x61, 0xe9, 0xed, 0x4b, 0x0a, 0xe3, 0x78, 0x62, 0xb7, 0x4a, 0xe5, 0xb9, 0x97, 0xf7, 0xb3, 0x12, 0x04, 0x61, 0x64, 0x61, 0x6d, 0x02, 0x20, 0xd0, 0xf3, 0x98, 0xcc, 0x0c, 0x39, 0x94, 0x85, 0xf8, 0xb7, 0x3c, 0x59, 0x10, 0xba, 0xb2, 0xbb, 0xf5, 0x3a, 0x38, 0x03, 0x59, 0x61, 0x02, 0x6e, 0x0f, 0x65, 0x0b, 0x98, 0x0e, 0x6d, 0x4e, 0x05, 0x62, 0x6f, 0x64, 0x68, 0x69, 0x03, 0x59, 0x0b, 0x35, 0x97, 0xb9, 0x08, 0x11, 0x82, 0xc4, 0xfc, 0x89, 0xe8, 0x32, 0x6e, 0xfc, 0x09, 0x04, 0x24, 0x09, 0x10, 0x8e, 0x8f, 0x6b, 0x3c, 0x06, 0x31, 0xfb, 0x46, 0x6c, 0x72, 0xcb, 0x05, 0x04, 0x61, 0x72, 0x6c, 0x6f, 0x03, 0xae, 0x2a, 0x76, 0xbf, 0x70, 0xdf, 0xea, 0x8a, 0x3e, 0xab, 0x3d, 0x85, 0xfd, 0x8f, 0x47, 0x74, 0x8b, 0x7c, 0x88, 0x76, 0xc8, 0xbe, 0x41, 0x44, 0x7f, 0xcd, 0x42, 0xd7, 0x2a, 0xf5, 0x18, 0xdf, 0x04, 0x6a, 0x75, 0x64, 0x65, 0x03, 0xc1, 0x40, 0xd4, 0x7d, 0x51, 0x0d, 0x9d, 0x0f, 0x0c, 0x23, 0x6f, 0xe1, 0x22, 0x2f, 0x3a, 0x36, 0x71, 0xa7, 0x05, 0xe8, 0x21, 0xca, 0x17, 0xa4, 0xd2, 0x56, 0x44, 0xee, 0x97, 0x08, 0x67, 0x94, 0x07, 0x6a, 0x61, 0x63, 0x6b, 0x73, 0x6f, 0x6e, 0x03, 0x61, 0x36, 0x07, 0x9a, 0x4a, 0x27, 0xd0, 0xde, 0x13, 0x11, 0x64, 0xa2, 0x27, 0x2d, 0x18, 0xe1, 0xc6, 0x42, 0x5c, 0x17, 0x10, 0xeb, 0x63, 0x3c, 0xd2, 0xb9, 0x4f, 0xc8, 0xaa, 0xe9, 0xfc, 0x49, 0x04, 0x6c, 0x65, 0x6f, 0x6e, 0x02, 0x05, 0x75, 0x85, 0x4c, 0x7c, 0xf1, 0xa3, 0x06, 0xfa, 0x2d, 0x82, 0x6f, 0x5d, 0x4a, 0x14, 0x96, 0x97, 0x31, 0x7e, 0xd6, 0x4c, 0x47, 0x7c, 0xf6, 0xd8, 0x82, 0x56, 0xb3, 0x4b, 0x72, 0xf4, 0xe1, 0x06, 0x6a, 0x6f, 0x73, 0x65, 0x70, 0x68, 0x02, 0xde, 0xfe, 0x53, 0xf3, 0xf5, 0x09, 0x01, 0x4f, 0x37, 0xfc, 0x36, 0x41, 0xf6, 0xfd, 0xd7, 0x9c, 0x28, 0x39, 0x47, 0x60, 0xea, 0x60, 0x84, 0x5d, 0x85, 0x3d, 0x8a, 0x5d, 0xc8, 0x23, 0x82, 0xd0, 0x06, 0x68, 0x61, 0x72, 0x6c, 0x65, 0x79, 0x03, 0x9d, 0x3a, 0x4c, 0xd3, 0x2e, 0x35, 0x01, 0x25, 0x33, 0xe2, 0x0a, 0x42, 0x72, 0x1e, 0xbd, 0xe7, 0xb8, 0xb8, 0xf5, 0xd2, 0x66, 0x3e, 0x58, 0xca, 0x1a, 0x54, 0x0f, 0xf4, 0x9e, 0x72, 0x67, 0xdd, 0x06, 0x65, 0x64, 0x77, 0x61, 0x72, 0x64, 0x03, 0x1a, 0x3d, 0x96, 0x0d, 0xd6, 0x41, 0x81, 0x5f, 0xc1, 0x43, 0x45, 0xb7, 0x49, 0x8d, 0xab, 0x99, 0x26, 0x86, 0x75, 0x56, 0xda, 0x6b, 0xe2, 0x2b, 0xa2, 0xef, 0xf0, 0x61, 0x97, 0xce, 0x8e, 0x14, 0x07, 0x69, 0x62, 0x72, 0x61, 0x68, 0x69, 0x6d, 0x02, 0x6f, 0xfa, 0x5a, 0x31, 0xc7, 0x8c, 0xc5, 0x2e, 0x76, 0xf3, 0x83, 0x13, 0x6e, 0x7d, 0x3b, 0x8c, 0x56, 0xdd, 0x8a, 0x0a, 0x7b, 0x58, 0x95, 0x32, 0x25, 0xe3, 0xb5, 0x88, 0xaa, 0x3c, 0x54, 0x21, 0x07, 0x6c, 0x69, 0x6e, 0x63, 0x6f, 0x6c, 0x6e, 0x02, 0xa7, 0x49, 0x3f, 0xe2, 0xd1, 0xa1, 0xb2, 0x51, 0x91, 0x23, 0xc8, 0xec, 0x48, 0x8c, 0x9b, 0x52, 0x5f, 0x3b, 0x62, 0xec, 0xdd, 0x72, 0x10, 0x4f, 0x55, 0xf7, 0x8b, 0xef, 0xb5, 0xe7, 0x5d, 0x83, 0x05, 0x6e, 0x69, 0x78, 0x6f, 0x6e, 0x03, 0xbe, 0x11, 0x79, 0xd1, 0x9b, 0xd0, 0x0d, 0xd7, 0x68, 0xa6, 0xe7, 0x99, 0x19, 0x95, 0x35, 0x8d, 0xe6, 0xdb, 0x61, 0x01, 0x47, 0x2b, 0xef, 0x1a, 0x72, 0x2b, 0x5e, 0xed, 0xab, 0xcd, 0xe1, 0x34, 0x05, 0x61, 0x69, 0x64, 0x65, 0x6e, 0x03, 0x37, 0x1c, 0xa4, 0x82, 0x9d, 0xf6, 0x2c, 0x03, 0x44, 0xe5, 0x01, 0x67, 0x67, 0x68, 0x96, 0x70, 0x33, 0x83, 0x52, 0xba, 0x7f, 0xf2, 0xe9, 0xc0, 0xd7, 0xe5, 0xf1, 0xb8, 0x1d, 0xa1, 0x56, 0xde, 0x63, 0x24, 0x54, 0x54, 0x43, 0x4c, 0x79, 0x64, 0x72, 0x6f, 0x39, 0x79, 0x78, 0x46, 0x58, 0x79, 0x56, 0x6f, 0x70, 0x54, 0x35, 0x38, 0x72, 0x5a, 0x68, 0x71, 0x50, 0x31, 0x64, 0x4e, 0x68, 0x4c, 0x59, 0x67, 0x6a, 0x75, 0x56, 0x31, 0x00, 0x80, 0xc6, 0xa4, 0x7e, 0x8d, 0x03, 0x00, 0x24, 0x54, 0x54, 0x43, 0x48, 0x62, 0x69, 0x36, 0x36, 0x71, 0x76, 0x63, 0x74, 0x54, 0x74, 0x55, 0x57, 0x73, 0x31, 0x4a, 0x77, 0x61, 0x38, 0x46, 0x71, 0x44, 0x48, 0x37, 0x41, 0x6e, 0x74, 0x61, 0x68, 0x61, 0x50, 0x61, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4c, 0x57, 0x4c, 0x72, 0x4a, 0x56, 0x70, 0x74, 0x58, 0x4b, 0x48, 0x34, 0x77, 0x6b, 0x39, 0x51, 0x32, 0x47, 0x59, 0x36, 0x46, 0x42, 0x69, 0x35, 0x76, 0x44, 0x47, 0x66, 0x36, 0x59, 0x33, 0x36, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x47, 0x65, 0x76, 0x35, 0x6e, 0x55, 0x37, 0x61, 0x7a, 0x35, 0x6a, 0x4a, 0x50, 0x54, 0x37, 0x46, 0x36, 0x6a, 0x50, 0x6d, 0x4d, 0x68, 0x65, 0x74, 0x44, 0x58, 0x4a, 0x73, 0x71, 0x65, 0x4c, 0x46, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x34, 0x43, 0x4b, 0x52, 0x67, 0x45, 0x4c, 0x73, 0x38, 0x6d, 0x63, 0x56, 0x4c, 0x59, 0x48, 0x41, 0x74, 0x38, 0x66, 0x66, 0x6a, 0x67, 0x72, 0x68, 0x43, 0x46, 0x43, 0x70, 0x38, 0x73, 0x37, 0x7a, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4c, 0x34, 0x53, 0x4c, 0x50, 0x57, 0x73, 0x66, 0x41, 0x66, 0x34, 0x36, 0x36, 0x62, 0x6a, 0x72, 0x74, 0x58, 0x72, 0x6e, 0x46, 0x31, 0x4a, 0x37, 0x74, 0x7a, 0x4b, 0x79, 0x78, 0x52, 0x73, 0x57, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x38, 0x66, 0x35, 0x39, 0x79, 0x47, 0x69, 0x73, 0x47, 0x64, 0x61, 0x65, 0x65, 0x6f, 0x79, 0x76, 0x4e, 0x45, 0x41, 0x5a, 0x58, 0x68, 0x63, 0x71, 0x52, 0x50, 0x5a, 0x69, 0x54, 0x6d, 0x38, 0x52, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x32, 0x48, 0x4b, 0x6f, 0x70, 0x56, 0x35, 0x4a, 0x6b, 0x64, 0x65, 0x32, 0x74, 0x58, 0x67, 0x43, 0x6d, 0x5a, 0x63, 0x6a, 0x73, 0x45, 0x57, 0x52, 0x76, 0x6b, 0x64, 0x6e, 0x59, 0x37, 0x61, 0x37, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x32, 0x33, 0x57, 0x55, 0x7a, 0x4e, 0x67, 0x42, 0x65, 0x70, 0x39, 0x67, 0x54, 0x54, 0x32, 0x43, 0x61, 0x79, 0x6a, 0x7a, 0x32, 0x45, 0x61, 0x57, 0x6f, 0x32, 0x41, 0x37, 0x52, 0x63, 0x53, 0x44, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x45, 0x63, 0x56, 0x69, 0x48, 0x51, 0x4d, 0x44, 0x61, 0x6e, 0x46, 0x32, 0x50, 0x72, 0x69, 0x32, 0x66, 0x39, 0x35, 0x56, 0x46, 0x73, 0x6e, 0x53, 0x67, 0x41, 0x73, 0x65, 0x4e, 0x76, 0x71, 0x46, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x50, 0x41, 0x55, 0x78, 0x6a, 0x73, 0x58, 0x45, 0x45, 0x65, 0x59, 0x77, 0x66, 0x79, 0x6a, 0x77, 0x68, 0x34, 0x78, 0x4a, 0x63, 0x6a, 0x73, 0x63, 0x69, 0x32, 0x39, 0x6a, 0x54, 0x4d, 0x62, 0x74, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x48, 0x38, 0x63, 0x36, 0x50, 0x59, 0x52, 0x57, 0x6f, 0x6b, 0x43, 0x4a, 0x6a, 0x57, 0x50, 0x65, 0x76, 0x63, 0x43, 0x74, 0x43, 0x70, 0x55, 0x47, 0x4c, 0x62, 0x4b, 0x7a, 0x5a, 0x33, 0x46, 0x45, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x54, 0x54, 0x43, 0x50, 0x78, 0x41, 0x68, 0x5a, 0x63, 0x4e, 0x68, 0x74, 0x57, 0x4d, 0x31, 0x44, 0x52, 0x43, 0x50, 0x32, 0x6e, 0x31, 0x6b, 0x73, 0x33, 0x36, 0x4d, 0x70, 0x6d, 0x71, 0x42, 0x45, 0x52, 0x77, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4b, 0x48, 0x61, 0x34, 0x56, 0x74, 0x38, 0x6e, 0x61, 0x42, 0x62, 0x64, 0x4a, 0x46, 0x47, 0x6f, 0x43, 0x69, 0x69, 0x78, 0x79, 0x6e, 0x74, 0x72, 0x65, 0x6b, 0x69, 0x39, 0x6b, 0x6a, 0x45, 0x46, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x39, 0x44, 0x65, 0x68, 0x68, 0x72, 0x54, 0x4a, 0x32, 0x5a, 0x58, 0x46, 0x4d, 0x6d, 0x73, 0x74, 0x35, 0x36, 0x36, 0x70, 0x37, 0x6f, 0x43, 0x51, 0x4c, 0x6a, 0x65, 0x57, 0x6f, 0x63, 0x61, 0x78, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4a, 0x6b, 0x77, 0x61, 0x6a, 0x31, 0x38, 0x72, 0x78, 0x31, 0x6a, 0x77, 0x45, 0x71, 0x43, 0x42, 0x57, 0x52, 0x68, 0x61, 0x67, 0x46, 0x47, 0x66, 0x75, 0x51, 0x55, 0x78, 0x33, 0x76, 0x77, 0x73, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4d, 0x39, 0x57, 0x69, 0x55, 0x63, 0x6b, 0x79, 0x63, 0x37, 0x52, 0x4c, 0x44, 0x70, 0x4d, 0x41, 0x33, 0x6f, 0x4d, 0x6e, 0x46, 0x33, 0x5a, 0x44, 0x65, 0x4d, 0x72, 0x55, 0x63, 0x4c, 0x61, 0x42, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x43, 0x68, 0x32, 0x51, 0x71, 0x76, 0x72, 0x66, 0x4c, 0x41, 0x75, 0x55, 0x33, 0x41, 0x4b, 0x56, 0x57, 0x68, 0x6f, 0x48, 0x4e, 0x75, 0x4d, 0x5a, 0x48, 0x6d, 0x56, 0x67, 0x44, 0x46, 0x4c, 0x76, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x45, 0x78, 0x4d, 0x56, 0x33, 0x44, 0x59, 0x37, 0x72, 0x31, 0x41, 0x73, 0x4c, 0x50, 0x73, 0x75, 0x6f, 0x37, 0x75, 0x36, 0x6d, 0x65, 0x74, 0x62, 0x6f, 0x38, 0x64, 0x33, 0x64, 0x75, 0x61, 0x57, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x34, 0x53, 0x4c, 0x65, 0x6e, 0x47, 0x59, 0x44, 0x4b, 0x33, 0x46, 0x4a, 0x41, 0x54, 0x38, 0x68, 0x55, 0x42, 0x54, 0x46, 0x4a, 0x63, 0x35, 0x63, 0x4b, 0x42, 0x74, 0x59, 0x36, 0x57, 0x62, 0x55, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x32, 0x42, 0x79, 0x37, 0x73, 0x43, 0x73, 0x34, 0x4c, 0x35, 0x65, 0x41, 0x43, 0x48, 0x47, 0x7a, 0x6f, 0x31, 0x4b, 0x56, 0x62, 0x76, 0x54, 0x34, 0x57, 0x32, 0x53, 0x6a, 0x7a, 0x71, 0x7a, 0x4a, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4c, 0x46, 0x6f, 0x36, 0x52, 0x32, 0x4b, 0x65, 0x58, 0x68, 0x68, 0x7a, 0x75, 0x6a, 0x6b, 0x6a, 0x57, 0x67, 0x70, 0x52, 0x51, 0x6d, 0x6d, 0x48, 0x48, 0x64, 0x67, 0x6a, 0x34, 0x74, 0x41, 0x78, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x43, 0x33, 0x32, 0x71, 0x7a, 0x33, 0x35, 0x31, 0x39, 0x34, 0x74, 0x76, 0x66, 0x79, 0x52, 0x73, 0x4d, 0x4c, 0x46, 0x58, 0x4b, 0x77, 0x76, 0x57, 0x37, 0x74, 0x32, 0x69, 0x58, 0x6f, 0x55, 0x6a, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x34, 0x39, 0x56, 0x6a, 0x50, 0x48, 0x4e, 0x67, 0x45, 0x4a, 0x47, 0x43, 0x77, 0x36, 0x66, 0x70, 0x43, 0x74, 0x52, 0x4e, 0x39, 0x77, 0x35, 0x4e, 0x46, 0x76, 0x4c, 0x47, 0x35, 0x45, 0x39, 0x64, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4e, 0x57, 0x79, 0x31, 0x32, 0x61, 0x32, 0x69, 0x77, 0x50, 0x76, 0x65, 0x68, 0x50, 0x4a, 0x34, 0x62, 0x6e, 0x65, 0x6f, 0x41, 0x31, 0x56, 0x48, 0x57, 0x68, 0x39, 0x59, 0x79, 0x56, 0x51, 0x51, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x46, 0x6e, 0x52, 0x62, 0x48, 0x59, 0x4a, 0x69, 0x71, 0x58, 0x61, 0x53, 0x74, 0x4d, 0x35, 0x5a, 0x46, 0x62, 0x76, 0x36, 0x33, 0x65, 0x6d, 0x7a, 0x34, 0x64, 0x39, 0x54, 0x75, 0x79, 0x4c, 0x6e, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4a, 0x74, 0x54, 0x4e, 0x48, 0x50, 0x51, 0x46, 0x6f, 0x59, 0x74, 0x4c, 0x71, 0x62, 0x62, 0x54, 0x54, 0x31, 0x72, 0x41, 0x65, 0x6e, 0x6a, 0x6e, 0x62, 0x47, 0x4c, 0x75, 0x32, 0x6b, 0x4a, 0x47, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x50, 0x37, 0x6a, 0x52, 0x6b, 0x36, 0x68, 0x48, 0x74, 0x31, 0x70, 0x54, 0x38, 0x75, 0x4d, 0x58, 0x72, 0x33, 0x70, 0x76, 0x42, 0x62, 0x48, 0x56, 0x6d, 0x74, 0x34, 0x35, 0x56, 0x35, 0x55, 0x6b, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4b, 0x78, 0x73, 0x59, 0x6f, 0x6d, 0x65, 0x38, 0x74, 0x61, 0x46, 0x4e, 0x32, 0x53, 0x4d, 0x70, 0x5a, 0x59, 0x41, 0x73, 0x32, 0x74, 0x63, 0x4a, 0x41, 0x38, 0x48, 0x7a, 0x68, 0x54, 0x36, 0x71, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x41, 0x57, 0x46, 0x7a, 0x6d, 0x44, 0x69, 0x79, 0x34, 0x39, 0x78, 0x6a, 0x54, 0x57, 0x35, 0x36, 0x6b, 0x53, 0x4c, 0x78, 0x77, 0x74, 0x65, 0x31, 0x68, 0x6d, 0x59, 0x54, 0x6a, 0x4a, 0x63, 0x69, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4d, 0x77, 0x55, 0x54, 0x6a, 0x50, 0x79, 0x46, 0x45, 0x79, 0x45, 0x67, 0x68, 0x4e, 0x79, 0x55, 0x39, 0x56, 0x52, 0x38, 0x65, 0x72, 0x58, 0x32, 0x72, 0x47, 0x57, 0x70, 0x79, 0x46, 0x75, 0x64, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x43, 0x77, 0x65, 0x75, 0x64, 0x61, 0x78, 0x48, 0x77, 0x52, 0x74, 0x61, 0x48, 0x6e, 0x6e, 0x4e, 0x58, 0x61, 0x50, 0x59, 0x53, 0x42, 0x6d, 0x74, 0x44, 0x77, 0x6d, 0x78, 0x4b, 0x32, 0x6b, 0x41, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4a, 0x35, 0x78, 0x6b, 0x53, 0x39, 0x4d, 0x6d, 0x79, 0x4d, 0x4c, 0x74, 0x74, 0x39, 0x4e, 0x38, 0x68, 0x76, 0x46, 0x38, 0x48, 0x4c, 0x75, 0x36, 0x78, 0x71, 0x6b, 0x5a, 0x4b, 0x43, 0x35, 0x71, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x43, 0x53, 0x4e, 0x36, 0x6b, 0x32, 0x31, 0x64, 0x61, 0x78, 0x41, 0x6f, 0x46, 0x31, 0x39, 0x52, 0x63, 0x38, 0x31, 0x32, 0x69, 0x47, 0x76, 0x45, 0x71, 0x52, 0x6b, 0x36, 0x43, 0x69, 0x76, 0x6d, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x41, 0x70, 0x32, 0x70, 0x67, 0x4b, 0x78, 0x46, 0x65, 0x36, 0x66, 0x59, 0x36, 0x43, 0x34, 0x43, 0x63, 0x71, 0x76, 0x57, 0x6f, 0x73, 0x63, 0x6f, 0x4d, 0x4b, 0x41, 0x79, 0x6e, 0x77, 0x39, 0x64, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x43, 0x69, 0x72, 0x4d, 0x56, 0x67, 0x44, 0x39, 0x5a, 0x62, 0x52, 0x76, 0x63, 0x6f, 0x43, 0x54, 0x52, 0x71, 0x52, 0x33, 0x45, 0x41, 0x59, 0x48, 0x34, 0x44, 0x61, 0x51, 0x75, 0x42, 0x31, 0x77, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x48, 0x4a, 0x35, 0x73, 0x70, 0x68, 0x65, 0x42, 0x31, 0x7a, 0x45, 0x61, 0x32, 0x32, 0x33, 0x7a, 0x62, 0x56, 0x33, 0x32, 0x4b, 0x63, 0x41, 0x6e, 0x39, 0x6e, 0x74, 0x57, 0x61, 0x42, 0x58, 0x73, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4b, 0x57, 0x48, 0x42, 0x77, 0x31, 0x52, 0x75, 0x54, 0x7a, 0x68, 0x59, 0x51, 0x71, 0x58, 0x79, 0x50, 0x52, 0x37, 0x34, 0x68, 0x33, 0x39, 0x31, 0x4b, 0x43, 0x38, 0x57, 0x38, 0x73, 0x4d, 0x77, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x48, 0x55, 0x4d, 0x31, 0x6f, 0x72, 0x78, 0x4d, 0x78, 0x74, 0x42, 0x78, 0x58, 0x62, 0x78, 0x48, 0x77, 0x53, 0x6b, 0x44, 0x6d, 0x6f, 0x6f, 0x62, 0x6d, 0x54, 0x6d, 0x5a, 0x4d, 0x68, 0x43, 0x69, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4c, 0x34, 0x6b, 0x33, 0x74, 0x69, 0x51, 0x38, 0x6e, 0x5a, 0x73, 0x79, 0x33, 0x79, 0x39, 0x67, 0x73, 0x34, 0x4c, 0x47, 0x77, 0x41, 0x68, 0x52, 0x32, 0x75, 0x7a, 0x38, 0x43, 0x56, 0x50, 0x74, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x41, 0x47, 0x5a, 0x57, 0x47, 0x77, 0x6a, 0x4b, 0x45, 0x69, 0x58, 0x38, 0x6e, 0x70, 0x58, 0x31, 0x4c, 0x72, 0x55, 0x4a, 0x6f, 0x61, 0x46, 0x77, 0x72, 0x56, 0x42, 0x79, 0x75, 0x70, 0x36, 0x44, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x35, 0x66, 0x73, 0x4b, 0x38, 0x6e, 0x5a, 0x76, 0x41, 0x57, 0x47, 0x46, 0x71, 0x57, 0x58, 0x6f, 0x70, 0x57, 0x6e, 0x39, 0x46, 0x56, 0x39, 0x48, 0x4c, 0x74, 0x6b, 0x55, 0x41, 0x33, 0x4e, 0x48, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4a, 0x6a, 0x37, 0x46, 0x45, 0x33, 0x36, 0x43, 0x31, 0x70, 0x63, 0x68, 0x53, 0x32, 0x48, 0x53, 0x34, 0x6d, 0x7a, 0x72, 0x4c, 0x62, 0x50, 0x4a, 0x32, 0x73, 0x48, 0x58, 0x72, 0x52, 0x4c, 0x4a, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x50, 0x56, 0x77, 0x38, 0x46, 0x72, 0x5a, 0x73, 0x4c, 0x43, 0x65, 0x37, 0x42, 0x61, 0x5a, 0x4c, 0x65, 0x56, 0x53, 0x6a, 0x65, 0x66, 0x71, 0x55, 0x33, 0x5a, 0x42, 0x43, 0x45, 0x64, 0x45, 0x35, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x41, 0x68, 0x34, 0x69, 0x68, 0x79, 0x71, 0x38, 0x6e, 0x73, 0x42, 0x33, 0x35, 0x7a, 0x4d, 0x64, 0x73, 0x67, 0x43, 0x32, 0x61, 0x64, 0x72, 0x34, 0x6a, 0x56, 0x43, 0x46, 0x7a, 0x77, 0x5a, 0x6a, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x41, 0x41, 0x38, 0x44, 0x58, 0x53, 0x73, 0x6b, 0x59, 0x57, 0x4e, 0x34, 0x42, 0x63, 0x6e, 0x41, 0x4b, 0x39, 0x41, 0x74, 0x56, 0x48, 0x75, 0x71, 0x56, 0x67, 0x45, 0x54, 0x46, 0x51, 0x46, 0x54, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x32, 0x7a, 0x6a, 0x4e, 0x58, 0x72, 0x52, 0x4a, 0x4a, 0x72, 0x77, 0x76, 0x79, 0x67, 0x41, 0x47, 0x59, 0x44, 0x6e, 0x33, 0x4b, 0x65, 0x41, 0x42, 0x69, 0x58, 0x64, 0x6f, 0x43, 0x71, 0x62, 0x45, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x44, 0x39, 0x61, 0x6e, 0x31, 0x39, 0x57, 0x57, 0x56, 0x61, 0x32, 0x70, 0x34, 0x58, 0x76, 0x42, 0x38, 0x6d, 0x51, 0x77, 0x75, 0x47, 0x4b, 0x63, 0x72, 0x66, 0x4b, 0x59, 0x77, 0x78, 0x37, 0x71, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x46, 0x65, 0x69, 0x73, 0x6e, 0x36, 0x48, 0x50, 0x72, 0x48, 0x52, 0x43, 0x35, 0x74, 0x33, 0x7a, 0x51, 0x48, 0x51, 0x61, 0x32, 0x7a, 0x5a, 0x43, 0x44, 0x51, 0x6b, 0x7a, 0x48, 0x4d, 0x4e, 0x74, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x34, 0x31, 0x7a, 0x45, 0x53, 0x41, 0x73, 0x65, 0x47, 0x63, 0x58, 0x56, 0x50, 0x5a, 0x39, 0x43, 0x61, 0x7a, 0x58, 0x76, 0x55, 0x75, 0x64, 0x33, 0x68, 0x38, 0x37, 0x6f, 0x6d, 0x32, 0x73, 0x77, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x54, 0x54, 0x43, 0x62, 0x4d, 0x4c, 0x6b, 0x69, 0x42, 0x70, 0x72, 0x38, 0x54, 0x34, 0x33, 0x55, 0x32, 0x52, 0x51, 0x31, 0x37, 0x36, 0x4a, 0x73, 0x33, 0x4c, 0x5a, 0x56, 0x54, 0x74, 0x48, 0x78, 0x73, 0x74, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4a, 0x56, 0x4c, 0x34, 0x51, 0x48, 0x6a, 0x4a, 0x39, 0x37, 0x37, 0x65, 0x65, 0x75, 0x68, 0x50, 0x74, 0x74, 0x7a, 0x65, 0x45, 0x46, 0x54, 0x6b, 0x4b, 0x77, 0x4a, 0x61, 0x4a, 0x77, 0x4b, 0x53, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4c, 0x36, 0x6d, 0x47, 0x4a, 0x77, 0x5a, 0x4c, 0x35, 0x5a, 0x75, 0x5a, 0x6b, 0x59, 0x71, 0x75, 0x52, 0x75, 0x56, 0x4d, 0x37, 0x4b, 0x64, 0x71, 0x39, 0x32, 0x6d, 0x33, 0x31, 0x66, 0x59, 0x6f, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x46, 0x78, 0x41, 0x7a, 0x6e, 0x70, 0x39, 0x69, 0x32, 0x79, 0x34, 0x47, 0x55, 0x37, 0x78, 0x72, 0x79, 0x43, 0x64, 0x5a, 0x77, 0x59, 0x5a, 0x57, 0x6e, 0x76, 0x74, 0x69, 0x53, 0x70, 0x75, 0x79, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x33, 0x34, 0x75, 0x51, 0x58, 0x64, 0x47, 0x55, 0x4b, 0x79, 0x51, 0x5a, 0x69, 0x78, 0x50, 0x46, 0x58, 0x76, 0x6f, 0x67, 0x42, 0x62, 0x78, 0x36, 0x33, 0x73, 0x4e, 0x50, 0x51, 0x6e, 0x72, 0x33, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x38, 0x65, 0x66, 0x72, 0x56, 0x38, 0x70, 0x4b, 0x63, 0x4b, 0x48, 0x55, 0x76, 0x79, 0x77, 0x51, 0x32, 0x48, 0x4a, 0x4a, 0x56, 0x46, 0x51, 0x61, 0x46, 0x4a, 0x71, 0x6e, 0x4a, 0x56, 0x74, 0x38, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x32, 0x61, 0x7a, 0x53, 0x34, 0x42, 0x71, 0x41, 0x51, 0x67, 0x4e, 0x44, 0x41, 0x42, 0x33, 0x39, 0x77, 0x59, 0x38, 0x42, 0x47, 0x39, 0x54, 0x31, 0x44, 0x78, 0x77, 0x5a, 0x4a, 0x43, 0x75, 0x58, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x41, 0x76, 0x51, 0x71, 0x54, 0x34, 0x77, 0x63, 0x64, 0x4a, 0x51, 0x45, 0x47, 0x4e, 0x77, 0x56, 0x70, 0x66, 0x53, 0x68, 0x37, 0x44, 0x37, 0x6d, 0x64, 0x41, 0x39, 0x7a, 0x37, 0x48, 0x43, 0x7a, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x47, 0x34, 0x4e, 0x39, 0x34, 0x31, 0x72, 0x73, 0x65, 0x74, 0x77, 0x62, 0x43, 0x55, 0x76, 0x53, 0x6a, 0x32, 0x4c, 0x42, 0x57, 0x71, 0x50, 0x74, 0x65, 0x41, 0x6a, 0x35, 0x6b, 0x33, 0x75, 0x7a, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x50, 0x7a, 0x65, 0x36, 0x57, 0x70, 0x32, 0x44, 0x38, 0x54, 0x35, 0x64, 0x6f, 0x67, 0x39, 0x47, 0x62, 0x6a, 0x65, 0x73, 0x44, 0x6e, 0x6f, 0x69, 0x41, 0x62, 0x43, 0x69, 0x44, 0x66, 0x39, 0x38, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x33, 0x73, 0x54, 0x67, 0x6b, 0x50, 0x46, 0x6d, 0x45, 0x6d, 0x44, 0x4e, 0x78, 0x4d, 0x74, 0x34, 0x4c, 0x56, 0x48, 0x76, 0x44, 0x48, 0x44, 0x67, 0x33, 0x4a, 0x39, 0x63, 0x6d, 0x53, 0x75, 0x64, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x46, 0x4a, 0x46, 0x39, 0x78, 0x53, 0x61, 0x4a, 0x61, 0x78, 0x57, 0x43, 0x69, 0x4d, 0x75, 0x45, 0x56, 0x45, 0x48, 0x64, 0x54, 0x48, 0x32, 0x59, 0x74, 0x45, 0x69, 0x39, 0x43, 0x68, 0x5a, 0x45, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x36, 0x42, 0x4c, 0x6e, 0x7a, 0x6b, 0x32, 0x53, 0x4c, 0x50, 0x32, 0x6e, 0x59, 0x69, 0x50, 0x54, 0x51, 0x4e, 0x70, 0x50, 0x6e, 0x6e, 0x43, 0x74, 0x6d, 0x58, 0x55, 0x5a, 0x36, 0x48, 0x64, 0x68, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4e, 0x37, 0x38, 0x68, 0x41, 0x7a, 0x73, 0x45, 0x6b, 0x32, 0x61, 0x79, 0x6b, 0x59, 0x4b, 0x78, 0x68, 0x57, 0x4b, 0x58, 0x71, 0x7a, 0x79, 0x56, 0x39, 0x65, 0x66, 0x39, 0x6e, 0x42, 0x38, 0x4a, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4c, 0x52, 0x37, 0x41, 0x50, 0x31, 0x69, 0x41, 0x62, 0x39, 0x67, 0x76, 0x63, 0x6d, 0x51, 0x55, 0x6e, 0x68, 0x64, 0x44, 0x7a, 0x64, 0x73, 0x44, 0x35, 0x54, 0x53, 0x62, 0x45, 0x57, 0x6d, 0x48, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x33, 0x4e, 0x34, 0x6e, 0x6b, 0x6b, 0x59, 0x32, 0x75, 0x4b, 0x48, 0x70, 0x4d, 0x66, 0x50, 0x77, 0x6b, 0x42, 0x6a, 0x77, 0x37, 0x58, 0x69, 0x63, 0x38, 0x74, 0x6a, 0x5a, 0x63, 0x36, 0x6a, 0x73, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x41, 0x4e, 0x61, 0x48, 0x32, 0x59, 0x51, 0x51, 0x55, 0x75, 0x36, 0x47, 0x58, 0x58, 0x76, 0x66, 0x77, 0x5a, 0x79, 0x67, 0x72, 0x77, 0x42, 0x62, 0x57, 0x78, 0x34, 0x66, 0x4a, 0x4d, 0x33, 0x46, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x39, 0x4b, 0x64, 0x58, 0x6a, 0x43, 0x39, 0x34, 0x4e, 0x36, 0x50, 0x43, 0x70, 0x74, 0x61, 0x55, 0x61, 0x66, 0x31, 0x73, 0x6a, 0x55, 0x6a, 0x53, 0x4d, 0x4c, 0x43, 0x69, 0x36, 0x71, 0x6a, 0x52, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4e, 0x57, 0x79, 0x56, 0x36, 0x32, 0x5a, 0x35, 0x41, 0x6e, 0x41, 0x51, 0x6a, 0x4c, 0x67, 0x74, 0x61, 0x65, 0x62, 0x6d, 0x79, 0x37, 0x61, 0x5a, 0x51, 0x4e, 0x5a, 0x62, 0x73, 0x66, 0x4d, 0x37, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x47, 0x6b, 0x5a, 0x37, 0x6e, 0x4d, 0x68, 0x4d, 0x31, 0x53, 0x52, 0x7a, 0x4c, 0x4e, 0x34, 0x68, 0x56, 0x38, 0x65, 0x32, 0x53, 0x38, 0x56, 0x41, 0x52, 0x67, 0x6b, 0x7a, 0x56, 0x76, 0x50, 0x53, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x33, 0x36, 0x44, 0x52, 0x62, 0x54, 0x6b, 0x52, 0x71, 0x4b, 0x62, 0x34, 0x6a, 0x7a, 0x61, 0x39, 0x72, 0x56, 0x33, 0x54, 0x47, 0x4c, 0x67, 0x62, 0x33, 0x42, 0x67, 0x69, 0x4c, 0x69, 0x7a, 0x54, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4d, 0x74, 0x65, 0x4d, 0x4c, 0x58, 0x31, 0x4e, 0x66, 0x41, 0x61, 0x77, 0x4d, 0x71, 0x37, 0x7a, 0x78, 0x53, 0x48, 0x77, 0x63, 0x56, 0x53, 0x57, 0x63, 0x34, 0x54, 0x69, 0x74, 0x4b, 0x37, 0x78, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4e, 0x65, 0x39, 0x57, 0x76, 0x65, 0x36, 0x42, 0x62, 0x77, 0x7a, 0x72, 0x74, 0x53, 0x62, 0x74, 0x54, 0x50, 0x64, 0x47, 0x4b, 0x70, 0x37, 0x36, 0x58, 0x62, 0x56, 0x55, 0x7a, 0x69, 0x6f, 0x7a, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x33, 0x4c, 0x42, 0x72, 0x6e, 0x44, 0x76, 0x4a, 0x33, 0x6e, 0x47, 0x38, 0x35, 0x54, 0x4d, 0x58, 0x65, 0x62, 0x46, 0x54, 0x44, 0x54, 0x54, 0x54, 0x36, 0x41, 0x76, 0x48, 0x78, 0x32, 0x39, 0x58, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x44, 0x51, 0x50, 0x57, 0x5a, 0x6f, 0x5a, 0x54, 0x55, 0x64, 0x6b, 0x36, 0x77, 0x37, 0x58, 0x66, 0x33, 0x4c, 0x76, 0x41, 0x53, 0x48, 0x34, 0x57, 0x79, 0x37, 0x48, 0x4d, 0x32, 0x52, 0x6b, 0x63, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4a, 0x4b, 0x4c, 0x47, 0x53, 0x4c, 0x65, 0x79, 0x5a, 0x4e, 0x64, 0x58, 0x6d, 0x56, 0x44, 0x68, 0x64, 0x33, 0x35, 0x47, 0x33, 0x65, 0x75, 0x39, 0x64, 0x64, 0x61, 0x50, 0x65, 0x50, 0x37, 0x79, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4a, 0x66, 0x46, 0x55, 0x6b, 0x34, 0x58, 0x77, 0x61, 0x72, 0x5a, 0x70, 0x52, 0x76, 0x4d, 0x34, 0x74, 0x70, 0x6d, 0x55, 0x44, 0x42, 0x6e, 0x70, 0x63, 0x33, 0x79, 0x48, 0x79, 0x66, 0x66, 0x4d, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x34, 0x54, 0x72, 0x74, 0x6d, 0x41, 0x52, 0x76, 0x62, 0x36, 0x37, 0x54, 0x58, 0x34, 0x6a, 0x78, 0x7a, 0x78, 0x71, 0x62, 0x52, 0x65, 0x71, 0x6e, 0x34, 0x59, 0x68, 0x38, 0x6e, 0x50, 0x5a, 0x69, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x35, 0x6a, 0x53, 0x6a, 0x32, 0x47, 0x6a, 0x75, 0x54, 0x51, 0x52, 0x41, 0x76, 0x67, 0x37, 0x58, 0x54, 0x68, 0x55, 0x31, 0x41, 0x64, 0x6d, 0x64, 0x4a, 0x44, 0x74, 0x56, 0x7a, 0x55, 0x66, 0x56, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x54, 0x54, 0x43, 0x52, 0x6f, 0x78, 0x4e, 0x36, 0x75, 0x31, 0x6d, 0x79, 0x79, 0x36, 0x41, 0x6f, 0x6f, 0x6f, 0x62, 0x74, 0x72, 0x47, 0x65, 0x6e, 0x79, 0x36, 0x68, 0x77, 0x76, 0x41, 0x51, 0x50, 0x63, 0x56, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x37, 0x36, 0x6e, 0x59, 0x4a, 0x36, 0x74, 0x58, 0x31, 0x4d, 0x6d, 0x4b, 0x71, 0x73, 0x6f, 0x63, 0x6f, 0x66, 0x50, 0x48, 0x79, 0x68, 0x78, 0x39, 0x76, 0x4b, 0x55, 0x52, 0x31, 0x46, 0x38, 0x46, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4c, 0x76, 0x54, 0x43, 0x69, 0x57, 0x43, 0x4d, 0x59, 0x67, 0x5a, 0x55, 0x37, 0x4e, 0x33, 0x52, 0x42, 0x55, 0x36, 0x7a, 0x70, 0x61, 0x46, 0x6e, 0x35, 0x46, 0x69, 0x34, 0x48, 0x47, 0x4a, 0x68, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x36, 0x4e, 0x41, 0x77, 0x4a, 0x55, 0x51, 0x6e, 0x65, 0x7a, 0x73, 0x35, 0x79, 0x46, 0x36, 0x77, 0x71, 0x75, 0x73, 0x59, 0x6b, 0x67, 0x50, 0x6f, 0x77, 0x59, 0x70, 0x41, 0x75, 0x47, 0x56, 0x55, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x35, 0x36, 0x62, 0x47, 0x33, 0x63, 0x6f, 0x69, 0x53, 0x4b, 0x7a, 0x32, 0x79, 0x47, 0x64, 0x51, 0x72, 0x56, 0x5a, 0x64, 0x4c, 0x79, 0x73, 0x31, 0x73, 0x56, 0x51, 0x79, 0x75, 0x7a, 0x43, 0x64, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x51, 0x33, 0x64, 0x47, 0x62, 0x35, 0x4b, 0x51, 0x50, 0x62, 0x6d, 0x6b, 0x69, 0x36, 0x47, 0x77, 0x35, 0x7a, 0x68, 0x79, 0x56, 0x65, 0x31, 0x68, 0x47, 0x56, 0x79, 0x63, 0x36, 0x73, 0x54, 0x72, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x42, 0x35, 0x70, 0x47, 0x4b, 0x69, 0x61, 0x59, 0x47, 0x36, 0x33, 0x32, 0x4a, 0x75, 0x41, 0x33, 0x38, 0x4e, 0x5a, 0x37, 0x48, 0x44, 0x70, 0x35, 0x37, 0x75, 0x47, 0x70, 0x7a, 0x53, 0x33, 0x6d, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x54, 0x54, 0x43, 0x76, 0x77, 0x54, 0x74, 0x42, 0x52, 0x51, 0x4e, 0x56, 0x6a, 0x39, 0x73, 0x38, 0x46, 0x5a, 0x68, 0x62, 0x55, 0x34, 0x44, 0x7a, 0x74, 0x74, 0x58, 0x6e, 0x75, 0x45, 0x47, 0x73, 0x79, 0x6a, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x42, 0x4d, 0x67, 0x61, 0x64, 0x76, 0x52, 0x72, 0x78, 0x5a, 0x67, 0x5a, 0x44, 0x6f, 0x78, 0x33, 0x6a, 0x53, 0x7a, 0x78, 0x6e, 0x51, 0x55, 0x53, 0x43, 0x50, 0x70, 0x66, 0x7a, 0x6f, 0x70, 0x6f, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x48, 0x41, 0x41, 0x32, 0x58, 0x66, 0x70, 0x4e, 0x39, 0x4b, 0x67, 0x51, 0x55, 0x37, 0x4a, 0x58, 0x34, 0x64, 0x50, 0x52, 0x62, 0x75, 0x79, 0x48, 0x66, 0x41, 0x42, 0x64, 0x76, 0x67, 0x55, 0x77, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x37, 0x33, 0x71, 0x6d, 0x51, 0x47, 0x77, 0x59, 0x65, 0x71, 0x34, 0x76, 0x6d, 0x6f, 0x54, 0x4b, 0x64, 0x75, 0x4e, 0x5a, 0x75, 0x38, 0x5a, 0x48, 0x70, 0x59, 0x64, 0x64, 0x70, 0x79, 0x62, 0x4d, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x50, 0x35, 0x55, 0x43, 0x53, 0x70, 0x43, 0x55, 0x67, 0x36, 0x52, 0x33, 0x66, 0x41, 0x41, 0x43, 0x70, 0x6f, 0x59, 0x50, 0x53, 0x45, 0x58, 0x39, 0x4a, 0x54, 0x67, 0x67, 0x4c, 0x71, 0x75, 0x39, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x42, 0x4e, 0x59, 0x62, 0x35, 0x47, 0x51, 0x64, 0x4d, 0x61, 0x4d, 0x51, 0x78, 0x4b, 0x55, 0x61, 0x54, 0x4b, 0x74, 0x57, 0x71, 0x67, 0x43, 0x73, 0x62, 0x46, 0x66, 0x78, 0x68, 0x4b, 0x4a, 0x59, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x31, 0x34, 0x52, 0x65, 0x69, 0x64, 0x66, 0x44, 0x4e, 0x38, 0x6d, 0x79, 0x7a, 0x4c, 0x58, 0x70, 0x67, 0x59, 0x79, 0x47, 0x59, 0x6d, 0x44, 0x4a, 0x48, 0x66, 0x6f, 0x70, 0x58, 0x45, 0x36, 0x34, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x37, 0x47, 0x63, 0x75, 0x35, 0x76, 0x46, 0x42, 0x54, 0x54, 0x6d, 0x55, 0x6e, 0x31, 0x46, 0x39, 0x4b, 0x45, 0x74, 0x54, 0x6b, 0x76, 0x76, 0x51, 0x4b, 0x6d, 0x45, 0x42, 0x39, 0x54, 0x71, 0x69, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x33, 0x66, 0x62, 0x56, 0x6d, 0x67, 0x79, 0x68, 0x4e, 0x64, 0x51, 0x6d, 0x31, 0x70, 0x36, 0x37, 0x76, 0x59, 0x68, 0x68, 0x42, 0x68, 0x54, 0x6f, 0x4d, 0x63, 0x77, 0x74, 0x4e, 0x4d, 0x32, 0x74, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x38, 0x54, 0x62, 0x32, 0x4b, 0x41, 0x6a, 0x33, 0x69, 0x39, 0x31, 0x38, 0x56, 0x6f, 0x55, 0x76, 0x44, 0x63, 0x71, 0x32, 0x75, 0x78, 0x6d, 0x70, 0x32, 0x72, 0x58, 0x41, 0x38, 0x75, 0x73, 0x71, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x4c, 0x78, 0x33, 0x56, 0x36, 0x39, 0x4b, 0x6d, 0x33, 0x65, 0x79, 0x50, 0x61, 0x65, 0x4d, 0x7a, 0x34, 0x54, 0x48, 0x59, 0x4c, 0x65, 0x64, 0x67, 0x48, 0x37, 0x4c, 0x73, 0x41, 0x4e, 0x7a, 0x75, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x38, 0x75, 0x62, 0x66, 0x59, 0x4c, 0x63, 0x73, 0x33, 0x72, 0x37, 0x34, 0x4b, 0x4b, 0x63, 0x38, 0x36, 0x4c, 0x4a, 0x5a, 0x35, 0x53, 0x71, 0x7a, 0x46, 0x59, 0x39, 0x6e, 0x42, 0x38, 0x78, 0x31, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x54, 0x54, 0x43, 0x47, 0x56, 0x37, 0x73, 0x4b, 0x35, 0x41, 0x47, 0x37, 0x7a, 0x62, 0x31, 0x5a, 0x45, 0x4b, 0x39, 0x50, 0x76, 0x70, 0x56, 0x51, 0x71, 0x64, 0x44, 0x52, 0x5a, 0x42, 0x45, 0x72, 0x32, 0x56, 0x53, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; GenesisState get_builtin_genesis_block_config() { unsigned total_size = sizeof(raw_genesis_config0); std::unique_ptr<char[]> buffer(new char[total_size]); char *ptr = buffer.get(); memcpy(ptr, (const char*)raw_genesis_config0, sizeof(raw_genesis_config0)); ptr += sizeof(raw_genesis_config0); return fc::raw::unpack<GenesisState>(buffer.get(), total_size); } fc::sha256 get_builtin_genesis_block_state_hash() { fc::sha256::encoder encoder; encoder.write((const char*)raw_genesis_config0, sizeof(raw_genesis_config0)); return encoder.result(); } } } #endif
[ "saifullah.rao@etomato.com" ]
saifullah.rao@etomato.com
f27422dc654b597fe4323ebb37e594fe7f752fe3
b4f9ac8b39c07c2cd4b4516aa26655b82fdd0943
/src/qt/blockbrowser.cpp
c6be226fab83b19808e1aae806c3be41bafe2a4a
[ "MIT" ]
permissive
PentaNodeNetwork/Pentanode-wallet
f396d412490c00e0e603103a7dd42d2afbd2faaf
c1dca1d52422550d8133687d3b642c862792f257
refs/heads/master
2020-03-24T15:34:24.309500
2018-06-16T18:44:16
2018-06-16T18:44:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,177
cpp
#include "blockbrowser.h" #include "ui_blockbrowser.h" #include "main.h" #include "wallet.h" #include "base58.h" #include "clientmodel.h" #include "walletmodel.h" #include "rpcconsole.h" #include "transactionrecord.h" #include <sstream> #include <string> double getBlockHardness(int height) { const CBlockIndex* blockindex = getBlockIndex(height); int nShift = (blockindex->nBits >> 24) & 0xff; double dDiff = (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff); while (nShift < 29) { dDiff *= 256.0; nShift++; } while (nShift > 29) { dDiff /= 256.0; nShift--; } return dDiff; } int getBlockHashrate(int height) { int lookup = height; double timeDiff = getBlockTime(height) - getBlockTime(1); double timePerBlock = timeDiff / lookup; return (boost::int64_t)(((double)getBlockHardness(height) * pow(2.0, 32)) / timePerBlock); } const CBlockIndex* getBlockIndex(int height) { std::string hex = getBlockHash(height); uint256 hash(hex); return mapBlockIndex[hash]; } std::string getBlockHash(int Height) { if(Height > pindexBest->nHeight) { return "351c6703813172725c6d660aa539ee6a3d7a9fe784c87fae7f36582e3b797058"; } if(Height < 0) { return "351c6703813172725c6d660aa539ee6a3d7a9fe784c87fae7f36582e3b797058"; } int desiredheight; desiredheight = Height; if (desiredheight < 0 || desiredheight > nBestHeight) return 0; CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hashBestChain]; while (pblockindex->nHeight > desiredheight) pblockindex = pblockindex->pprev; return pblockindex->phashBlock->GetHex(); } int getBlockTime(int Height) { std::string strHash = getBlockHash(Height); uint256 hash(strHash); if (mapBlockIndex.count(hash) == 0) return 0; CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; return pblockindex->nTime; } std::string getBlockMerkle(int Height) { std::string strHash = getBlockHash(Height); uint256 hash(strHash); if (mapBlockIndex.count(hash) == 0) return 0; CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; return pblockindex->hashMerkleRoot.ToString().substr(0,10).c_str(); } int getBlocknBits(int Height) { std::string strHash = getBlockHash(Height); uint256 hash(strHash); if (mapBlockIndex.count(hash) == 0) return 0; CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; return pblockindex->nBits; } int getBlockNonce(int Height) { std::string strHash = getBlockHash(Height); uint256 hash(strHash); if (mapBlockIndex.count(hash) == 0) return 0; CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; return pblockindex->nNonce; } std::string getBlockDebug(int Height) { std::string strHash = getBlockHash(Height); uint256 hash(strHash); if (mapBlockIndex.count(hash) == 0) return 0; CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; return pblockindex->ToString(); } int blocksInPastHours(int hours) { int wayback = hours * 3600; bool check = true; int height = pindexBest->nHeight; int heightHour = pindexBest->nHeight; int utime = (int)time(NULL); int target = utime - wayback; while(check) { if(getBlockTime(heightHour) < target) { check = false; return height - heightHour; } else { heightHour = heightHour - 1; } } return 0; } double getTxTotalValue(std::string txid) { uint256 hash; hash.SetHex(txid); CTransaction tx; uint256 hashBlock = 0; if (!GetTransaction(hash, tx, hashBlock)) return 1000; CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << tx; double value = 0; double buffer = 0; for (unsigned int i = 0; i < tx.vout.size(); i++) { const CTxOut& txout = tx.vout[i]; buffer = value + convertCoins(txout.nValue); value = buffer; } return value; } double convertCoins(int64_t amount) { return (double)amount / (double)COIN; } std::string getOutputs(std::string txid) { uint256 hash; hash.SetHex(txid); CTransaction tx; uint256 hashBlock = 0; if (!GetTransaction(hash, tx, hashBlock)) return "fail"; CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << tx; std::string str = ""; for (unsigned int i = 0; i < tx.vout.size(); i++) { const CTxOut& txout = tx.vout[i]; CTxDestination source; ExtractDestination(txout.scriptPubKey, source); CPentanodeAddress addressSource(source); std::string lol7 = addressSource.ToString(); double buffer = convertCoins(txout.nValue); std::ostringstream ss; ss << std::fixed << std::setprecision(4) << buffer; std::string amount = ss.str(); str.append(lol7); str.append(": "); str.append(amount); str.append(" PTN"); str.append("\n"); } return str; } std::string getInputs(std::string txid) { uint256 hash; hash.SetHex(txid); CTransaction tx; uint256 hashBlock = 0; if (!GetTransaction(hash, tx, hashBlock)) return "fail"; CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << tx; std::string str = ""; for (unsigned int i = 0; i < tx.vin.size(); i++) { uint256 hash; const CTxIn& vin = tx.vin[i]; hash.SetHex(vin.prevout.hash.ToString()); CTransaction wtxPrev; uint256 hashBlock = 0; if (!GetTransaction(hash, wtxPrev, hashBlock)) return "fail"; CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << wtxPrev; CTxDestination source; ExtractDestination(wtxPrev.vout[vin.prevout.n].scriptPubKey, source); CPentanodeAddress addressSource(source); std::string lol6 = addressSource.ToString(); const CScript target = wtxPrev.vout[vin.prevout.n].scriptPubKey; double buffer = convertCoins(getInputValue(wtxPrev, target)); std::ostringstream ss; ss << std::fixed << std::setprecision(4) << buffer; std::string amount = ss.str(); str.append(lol6); str.append(": "); str.append(amount); str.append(" PTN"); str.append("\n"); } return str; } int64_t getInputValue(CTransaction tx, CScript target) { for (unsigned int i = 0; i < tx.vin.size(); i++) { const CTxOut& txout = tx.vout[i]; if(txout.scriptPubKey == target) { return txout.nValue; } } return 0; } double getTxFees(std::string txid) { uint256 hash; hash.SetHex(txid); CTransaction tx; uint256 hashBlock = 0; if (!GetTransaction(hash, tx, hashBlock)) return 51; CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << tx; double value = 0; double buffer = 0; for (unsigned int i = 0; i < tx.vout.size(); i++) { const CTxOut& txout = tx.vout[i]; buffer = value + convertCoins(txout.nValue); value = buffer; } double value0 = 0; double buffer0 = 0; for (unsigned int i = 0; i < tx.vin.size(); i++) { uint256 hash0; const CTxIn& vin = tx.vin[i]; hash0.SetHex(vin.prevout.hash.ToString()); CTransaction wtxPrev; uint256 hashBlock0 = 0; if (!GetTransaction(hash0, wtxPrev, hashBlock0)) return 0; CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << wtxPrev; const CScript target = wtxPrev.vout[vin.prevout.n].scriptPubKey; buffer0 = value0 + convertCoins(getInputValue(wtxPrev, target)); value0 = buffer0; } return value0 - value; } BlockBrowser::BlockBrowser(QWidget *parent) : QWidget(parent), ui(new Ui::BlockBrowser) { ui->setupUi(this); setFixedSize(400, 420); connect(ui->blockButton, SIGNAL(pressed()), this, SLOT(blockClicked())); connect(ui->txButton, SIGNAL(pressed()), this, SLOT(txClicked())); } void BlockBrowser::updateExplorer(bool block) { if(block) { ui->heightLabel->show(); ui->heightLabel_2->show(); ui->hashLabel->show(); ui->hashBox->show(); ui->merkleLabel->show(); ui->merkleBox->show(); ui->nonceLabel->show(); ui->nonceBox->show(); ui->bitsLabel->show(); ui->bitsBox->show(); ui->timeLabel->show(); ui->timeBox->show(); ui->hardLabel->show(); ui->hardBox->show();; int height = ui->heightBox->value(); if (height > pindexBest->nHeight) { ui->heightBox->setValue(pindexBest->nHeight); height = pindexBest->nHeight; } std::string hash = getBlockHash(height); std::string merkle = getBlockMerkle(height); int nBits = getBlocknBits(height); int nNonce = getBlockNonce(height); int atime = getBlockTime(height); double hardness = getBlockHardness(height); QString QHeight = QString::number(height); QString QHash = QString::fromUtf8(hash.c_str()); QString QMerkle = QString::fromUtf8(merkle.c_str()); QString QBits = QString::number(nBits); QString QNonce = QString::number(nNonce); QString QTime = QString::number(atime); QString QHardness = QString::number(hardness, 'f', 6); ui->heightLabel->setText(QHeight); ui->hashBox->setText(QHash); ui->merkleBox->setText(QMerkle); ui->bitsBox->setText(QBits); ui->nonceBox->setText(QNonce); ui->timeBox->setText(QTime); ui->hardBox->setText(QHardness); } if(block == false) { ui->txID->show(); ui->txLabel->show(); ui->valueLabel->show(); ui->valueBox->show(); ui->inputLabel->show(); ui->inputBox->show(); ui->outputLabel->show(); ui->outputBox->show(); ui->feesLabel->show(); ui->feesBox->show(); std::string txid = ui->txBox->text().toUtf8().constData(); double value = getTxTotalValue(txid); double fees = getTxFees(txid); std::string outputs = getOutputs(txid); std::string inputs = getInputs(txid); QString QValue = QString::number(value, 'f', 6); QString QID = QString::fromUtf8(txid.c_str()); QString QOutputs = QString::fromUtf8(outputs.c_str()); QString QInputs = QString::fromUtf8(inputs.c_str()); QString QFees = QString::number(fees, 'f', 6); ui->valueBox->setText(QValue + " PTN"); ui->txID->setText(QID); ui->outputBox->setText(QOutputs); ui->inputBox->setText(QInputs); ui->feesBox->setText(QFees + " PTN"); } } void BlockBrowser::txClicked() { updateExplorer(false); } void BlockBrowser::blockClicked() { updateExplorer(true); } void BlockBrowser::setModel(WalletModel *model) { this->model = model; } BlockBrowser::~BlockBrowser() { delete ui; }
[ "pentanodecrypto@gmail.com" ]
pentanodecrypto@gmail.com
fbfc3aa47f0b158ca6f91184a6c830a6975c8a49
388cc3b1b431072bcdb66d1bd6235c8d868715f6
/VEngine/Graphics.cpp
31e3be11f36cdb6480652a8b9598d3d3532dc8c4
[]
no_license
PalaceDCXVI/VEngine
0053eb23530764ecbccfaf08225840c69f7c614b
26601b3c3f90e7168e9f328599d7f735a4a8ec0f
refs/heads/master
2023-01-27T11:02:51.342746
2023-01-15T20:23:19
2023-01-15T20:23:19
94,813,371
2
0
null
null
null
null
UTF-8
C++
false
false
1,395
cpp
#include "Graphics.h" GraphicsSystem* GraphicsSystem::singleton = NULL; GraphicsSystem::GraphicsSystem() { instance = new GraphicsInstance(); physicalDevice = new GraphicsPhysicalDevice(*instance); logicalDevice = new GraphicsLogicalDevice(*physicalDevice); const VkDevice vkDevice = logicalDevice->GetVKLogicalDevice(); GraphicsPhysicalDevice::QueueFamilyIndices indices = physicalDevice->GetQueueFamilyIndices(); vkGetDeviceQueue(vkDevice, indices.graphicsQueueIndex, 0, &graphicsQueue); vkGetDeviceQueue(vkDevice, indices.computeQueueIndex, 0, &computeQueue); vkGetDeviceQueue(vkDevice, indices.transferQueueIndex, 0, &transferQueue); vkGetDeviceQueue(vkDevice, indices.sparseQueueIndex, 0, &sparseQueue); graphicsCmdPool = new CommandPool(*logicalDevice, indices.graphicsQueueIndex); computeCmdPool = new CommandPool(*logicalDevice, indices.computeQueueIndex); transferCmdPool = new CommandPool(*logicalDevice, indices.transferQueueIndex); sparseCmdPool = new CommandPool(*logicalDevice, indices.sparseQueueIndex); assert(singleton == NULL); singleton = this; } GraphicsSystem::~GraphicsSystem() { delete graphicsCmdPool; delete computeCmdPool; delete transferCmdPool; delete sparseCmdPool; delete logicalDevice; delete physicalDevice; delete instance; } void GraphicsSystem::WaitForDeviceIdle() { vkDeviceWaitIdle(logicalDevice->GetVKLogicalDevice()); }
[ "Jordan6372927@gmail.com" ]
Jordan6372927@gmail.com
036e0cac18781f26a43bbc2cda79007ec6e662a7
4368f3b127b9330885c7a1789446c8af56189cdb
/_v8pp/v8pp/module.hpp
6b7ab9d61aa60eea9f553a9fc72853aaaae04dec
[ "BSL-1.0", "MIT" ]
permissive
Yangff/mvuccu
4cb57a8fb855a60c44e40f30b9c23bc66e175781
d0dc7c84fdeea4ee3b70ba758942a3499bd7a53a
refs/heads/master
2021-01-17T06:52:24.207080
2017-11-24T17:08:24
2017-11-24T17:08:24
52,864,715
5
5
null
2017-11-24T17:08:24
2016-03-01T09:30:02
C++
UTF-8
C++
false
false
4,950
hpp
// // Copyright (c) 2013-2016 Pavel Medvedev. All rights reserved. // // This file is part of v8pp (https://github.com/pmed/v8pp) project. // // Distributed under 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) // #ifndef V8PP_MODULE_HPP_INCLUDED #define V8PP_MODULE_HPP_INCLUDED #include <v8.h> #include "v8pp/config.hpp" #include "v8pp/function.hpp" #include "v8pp/property.hpp" namespace v8pp { template<typename T> class class_; /// Module (similar to v8::ObjectTemplate) class module { public: explicit module(v8::Isolate* isolate) : isolate_(isolate) , obj_(v8::ObjectTemplate::New(isolate)) { } explicit module(v8::Isolate* isolate, v8::Handle<v8::ObjectTemplate> obj) : isolate_(isolate) , obj_(obj) { } /// v8::Isolate where the module belongs v8::Isolate* isolate() { return isolate_; } /// Set a V8 value in the module with specified name template<typename Data> module& set(char const* name, v8::Handle<Data> value) { obj_->Set(v8pp::to_v8(isolate_, name), value); return *this; } /// Set another module in the module with specified name module& set(char const* name, module& m) { return set(name, m.obj_); } /// Set wrapped C++ class in the module with specified name template<typename T> module& set(char const* name, class_<T>& cl) { v8::HandleScope scope(isolate_); cl.class_function_template()->SetClassName(v8pp::to_v8(isolate_, name)); return set(name, cl.js_function_template()); } /// Set a C++ function in the module with specified name template<typename Function, typename Fun = typename std::decay<Function>::type> typename std::enable_if<detail::is_callable<Fun>::value, module&>::type set(char const* name, Function&& func) { return set(name, wrap_function_template(isolate_, std::forward<Fun>(func))); } /// Set a C++ variable in the module with specified name template<typename Variable> typename std::enable_if<!detail::is_callable<Variable>::value, module&>::type set(char const *name, Variable& var, bool readonly = false) { v8::HandleScope scope(isolate_); v8::AccessorGetterCallback getter = &var_get<Variable>; v8::AccessorSetterCallback setter = &var_set<Variable>; if (readonly) { setter = nullptr; } obj_->SetAccessor(v8pp::to_v8(isolate_, name), getter, setter, detail::set_external_data(isolate_, &var), v8::DEFAULT, v8::PropertyAttribute(v8::DontDelete | (setter ? 0 : v8::ReadOnly))); return *this; } /// Set v8pp::property in the module with specified name template<typename GetFunction, typename SetFunction> module& set(char const *name, property_<GetFunction, SetFunction>&& prop) { using prop_type = property_<GetFunction, SetFunction>; v8::HandleScope scope(isolate_); v8::AccessorGetterCallback getter = prop_type::get; v8::AccessorSetterCallback setter = prop_type::set; if (prop_type::is_readonly) { setter = nullptr; } obj_->SetAccessor(v8pp::to_v8(isolate_, name), getter, setter, detail::set_external_data(isolate_, std::forward<prop_type>(prop)), v8::DEFAULT, v8::PropertyAttribute(v8::DontDelete | (setter ? 0 : v8::ReadOnly))); return *this; } /// Set another module as a read-only property module& set_const(char const* name, module& m) { v8::HandleScope scope(isolate_); obj_->Set(v8pp::to_v8(isolate_, name), m.obj_, v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete)); return *this; } /// Set another module as a read-only property module& set_const(char const* name, v8::Handle<v8::ObjectTemplate> m) { v8::HandleScope scope(isolate_); obj_->Set(v8pp::to_v8(isolate_, name), m, v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete)); return *this; } /// Set a value convertible to JavaScript as a read-only property template<typename Value> module& set_const(char const* name, Value const& value) { v8::HandleScope scope(isolate_); obj_->Set(v8pp::to_v8(isolate_, name), to_v8(isolate_, value), v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete)); return *this; } /// Create a new module instance in V8 v8::Local<v8::Object> new_instance() { return obj_->NewInstance(); } private: template<typename Variable> static void var_get(v8::Local<v8::String>, v8::PropertyCallbackInfo<v8::Value> const& info) { v8::Isolate* isolate = info.GetIsolate(); Variable* var = detail::get_external_data<Variable*>(info.Data()); info.GetReturnValue().Set(to_v8(isolate, *var)); } template<typename Variable> static void var_set(v8::Local<v8::String>, v8::Local<v8::Value> value, v8::PropertyCallbackInfo<void> const& info) { v8::Isolate* isolate = info.GetIsolate(); Variable* var = detail::get_external_data<Variable*>(info.Data()); *var = v8pp::from_v8<Variable>(isolate, value); } v8::Isolate* isolate_; v8::Handle<v8::ObjectTemplate> obj_; }; } // namespace v8pp #endif // V8PP_MODULE_HPP_INCLUDED
[ "yangff1@gmail.com" ]
yangff1@gmail.com
8904007f9237700d7a9e2a6e0ad089b6d8820079
68e7c610733ea66eb9c1571822d6804ea171a97d
/2839/main.cpp
479de8894b612309be4d3a146d055a3988f98bc8
[]
no_license
qahirakim/backjun
e918e4cd35c447e97de43d2bf9fa1c2bfc0c4f7f
0cf406138c2f7e6911de41227ec643c80558c272
refs/heads/master
2020-04-22T15:50:20.720268
2019-07-14T16:29:11
2019-07-14T16:29:11
170,489,234
0
0
null
null
null
null
UTF-8
C++
false
false
619
cpp
//#include <iostream> //#include <climits> // //using namespace std; // //int sugar(int n); //int main(int argc, char *argv[]) //{ // int N; // cin>>N; // // cout<<sugar(N)<<endl; // // return 0; //} // //int sugar(int n) //{ // if(!(n%5)) return n/5; // int X = 0; // int Y = 0; // int min = INT_MAX; // while(5*X <= n) // { // int t = (n - 5*X); // // if(!(t % 3)) // { // Y = t/3; // min = min > X+Y ? X+Y : min; // } // // X++; // } // if(min == INT_MAX) // return -1; // return min; //}
[ "qahirakim@gmail.com" ]
qahirakim@gmail.com
2b158a44ad44585e83047ac3f7dfa897dde74317
4d5e9c1db95e5551ea03854295c9f5771fb26a25
/Tiny2DGameEngine/src/Components/ColliderComponent.cpp
382819d62aa8fcf6672af4b111ac6b8464e5202e
[]
no_license
zrcoy/Tiny2DGameEngine
1f28f17e10ad5647aff95dd39476fb7f7439d8ac
07ed7dbd3a656cbfeb8484a53e52a04140885e8e
refs/heads/master
2021-03-01T00:20:17.542241
2020-10-13T16:31:39
2020-10-13T16:31:39
245,742,037
0
1
null
2020-10-13T16:31:41
2020-03-08T02:56:29
C++
UTF-8
C++
false
false
1,294
cpp
#include "ColliderComponent.h" #include "../TextureManager.h" #include "../AssetManager.h" ColliderComponent::ColliderComponent(std::string colliderTag, int x, int y, int width, int height, bool turnOnCollidingBox) { this->colliderTag = colliderTag; this->colliderRect = { x,y,width,height }; this->turnOnCollidingBox = turnOnCollidingBox; } void ColliderComponent::Initialize() { if (owner->HasComponent<TransformComponent>()) { transform = owner->GetComponent<TransformComponent>(); sourceRect = { 0,0,transform->width,transform->height }; destinationRect = { colliderRect.x,colliderRect.y,colliderRect.w,colliderRect.h }; } } void ColliderComponent::Update(float deltaTime) { colliderRect.x = static_cast<int>(transform->position.x); colliderRect.y = static_cast<int>(transform->position.y); colliderRect.w = transform->width * transform->scale; colliderRect.h = transform->height * transform->scale; destinationRect.x = colliderRect.x - Game::camera.x; destinationRect.y = colliderRect.y - Game::camera.y; } void ColliderComponent::Render() { if (turnOnCollidingBox) { TextureManager::Draw(Game::assetManager->GetTexture("BoundingBox-Texture"), sourceRect, destinationRect, SDL_FLIP_NONE); } }
[ "zhangruichaotyler@gmail.com" ]
zhangruichaotyler@gmail.com
906b061f82675cf2f1117a06c45feaba1ed4f17c
6b952bc2b4c19f9ea358759d503faa730f57c5e4
/project/embedded_linux/semaphore/semctl.cpp
804778961a4579a40777f99889c6956315b0ab03
[]
no_license
wd-cell/Lproject
789fe7d211193ad60545a40c55c89e648f86d8f7
6cebdcbf7bf9d76527a8fd96d0f11450c9ab12fe
refs/heads/master
2022-12-04T01:37:11.847622
2020-08-17T03:46:59
2020-08-17T03:46:59
287,671,843
0
0
null
null
null
null
UTF-8
C++
false
false
1,591
cpp
//cpp未成功 #include<iostream> #include<linux/sem.h> #include<sys/sem.h> #include<unistd.h> #define NUMS 10; using namespace std; int get_sem_val(int sid, int semnum){ //取得当前信号量 return semctl(sid, semnum, GETVAL, 0); } int main(){ int i; int semid; int pid,ret; struct sembuf sem_op; //信号集结构 union semun sem_val; //信号量数值 semid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600); //建立有一个信号的信号量集 if(semid < 0){ cout << "creat sem error" << endl; exit(1); } cout << "creat " << semid << " sem success" << endl ; sem_val.val = 1; //信号量初始化 ret = semctl(semid, 0, SETVAL, sem_val); //设置信号量,0为第一个信号量,1为第二个... if(ret < 0){ perror("initialize sem error"); exit(1); } pid = fork(); if(pid < 0){ perror("fork error"); exit(1); } else if(pid == 0){ //子进程,使用者 for(i=0; i< 10; ++i){ sem_op.sem_num = 0; sem_op.sem_op = -1; sem_op.sem_flg = 0; semop(semid, &sem_op, 1); //操作信号量,每次-1 cout << i << " 使用者: " << get_sem_val(semid, 0) << endl; } }else{ //父进程,制造者 for(i=0; i< 10; ++i){ sem_op.sem_num = 0; sem_op.sem_op = 1; sem_op.sem_flg = 0; semop(semid, &sem_op, 1); //操作信号量,每次+1 cout << i << " 制造者: " << get_sem_val(semid, 0) << endl; } } exit(0); }
[ "954876425@qq.com" ]
954876425@qq.com
795feaf226851f18cd052cdcb5f1ba9976301609
0a348be3e756ab37ff3a7fceaa78c5b616d8c5f8
/point.cpp
c29c92a0e0f673332c69c7e929b51039e455fd2b
[]
no_license
ILISI2/repo
7ee464c757d978f23dda6d3222590762a23240e0
bb86d072b419994ddfc8898c9be065270b31a05a
refs/heads/master
2021-01-12T06:31:16.451314
2016-12-26T09:36:32
2016-12-26T09:36:32
77,373,294
0
0
null
2016-12-26T09:36:32
2016-12-26T09:27:09
C++
UTF-8
C++
false
false
624
cpp
#include "stdafx.h" #include "point.h" point::point(int xx, int yy):x(xx),y(yy) { cout << "hi" << endl; cout << "ilisi2" << endl out << "ilisi2" << endl; } point::~point() { } bool point::operator<(const point &) const { return (x<y); } bool point::operator>(const point & p) const { return x > p.x; } bool point::operator!=(const point & p) const { bool r = (x != p.x || y != p.y); return r; } bool point::operator==(const point & p) const { return !((*this)!=p); } ostream & operator<<(ostream & s, const point & p) { // TODO: insert return statement here s << p.x << " " << p.y << " "; return s; }
[ "ilisi2.github@gmail.com" ]
ilisi2.github@gmail.com
5431f97f040add62ad9826c44452f923d7f5323a
4270f3faf3f9ce84bc2bde86e24afabe5c02c808
/src/main.cpp
adea6be9d77ba3c1b11fb9bd529e7be5a61a7d37
[]
no_license
motobep/NSC
0f5b96a075343a603fd892a34d38e25fdf676e7f
cdecfbe6cb30d53518f7c22ad85767ebb9ae21e5
refs/heads/master
2023-02-03T11:21:16.177960
2020-12-20T16:41:08
2020-12-20T16:41:08
284,314,975
3
0
null
null
null
null
UTF-8
C++
false
false
1,852
cpp
/** * NSC. No Semicolon C. * Converts files without semicolons to .c or .cpp files. * * nsc - bin file. * * Example: * $ nsc main.nsc * * Outputs main.cpp * * @author motobep: <motobep@yandex.ru> * @date 2020.08.02 * @version: 0.1.1 */ #include <iostream> #include <cstdlib> #include <filesystem> #include "nsc.h" using std::cout; using std::endl; using std::ifstream; using std::ofstream; using std::string; namespace fs = std::filesystem; int main(int argc, char *argv[]) { if (argc <= 1) { cout << "Must be at least 1 arg.\n"; return 0; } const string OUTPUT_EXTENSION = ".cpp"; // Put ".c" for c-files. const string OUTPUT_DIR = "./"; // Specify your output directory. for (int i = 1; i < argc; i++) { const string INPUT(argv[i]); // input filename const string OUTPUT = OUTPUT_DIR + nsc::get_output(INPUT) + OUTPUT_EXTENSION; if (!fs::exists(INPUT)) { cout << INPUT << " doesn't exist.\n"; return 0; } fs::create_directory(OUTPUT_DIR); string line; ifstream fin(INPUT); ofstream fout(OUTPUT); while (getline(fin, line)) { nsc::rtrim(line); fout << line; const string last_word = nsc::get_last_word(line); const char last_char = line.back(); if (last_char && !nsc::is_preprocessor_dirictive(line) && !nsc::is_comment_line(line) && last_word != "else") { switch (last_char) { case ';': case '{': case '}': case ',': case ':': case '<': case '>': case '\\': break; case ')': if (!nsc::is_next('{', fin) && !nsc::is_next('.', fin)) { fout << ';'; } break; default: fout << ';'; } } fout << endl; } } return 0; }
[ "motobep@yandex.ru" ]
motobep@yandex.ru
08e0935cd6b0f8ab61cecb40071adf4b1f91b9b3
5c356c576398e667cb73c3df8c6eac1baf0aedbd
/src/modules/boots/tempfile.cpp
51e9e1135fca449c0eab9ca8e8162180e0be1ca3
[ "MIT" ]
permissive
Fall-man/AS_x86_emulator
baaef0db4052a3f907c0b61b67fa4d86c50a7f86
0a83129a0e421fdb2fd9f31952d8f67619ea7ed9
refs/heads/master
2022-04-20T09:15:33.440379
2020-04-19T09:46:25
2020-04-19T09:46:25
256,825,662
0
0
null
null
null
null
UTF-8
C++
false
false
289
cpp
#include "tempfile.hpp" using namespace boost; TemporaryFile::TemporaryFile() : path_(filesystem::unique_path()) {} TemporaryFile::~TemporaryFile() { filesystem::remove(path_); } const boost::filesystem::path& TemporaryFile::path() const { return path_; }
[ "take.tennis2008@icloud.com" ]
take.tennis2008@icloud.com
c0672edb235dcc196e1616334df5ef849cf0b46f
9f53efd271528e61615299b951e267da54090a7f
/src/loss/Quadratic.hpp
a1ad3f8631f6e24c74ffdca85e5d9ca0beeb3985
[ "Apache-2.0" ]
permissive
kenk42292/mochi
b2b65cfe40998faac384353c39be93e9372d5298
79e65bc669812b37b5a38975fcada23b95206ac5
refs/heads/master
2020-12-24T06:37:43.760509
2017-01-18T11:10:08
2017-01-18T11:10:08
63,491,157
0
0
null
null
null
null
UTF-8
C++
false
false
426
hpp
/* * Quadratic.h * * Created on: Dec 11, 2016 * Author: ken */ #ifndef LOSS_QUADRATIC_HPP_ #define LOSS_QUADRATIC_HPP_ #include "Loss.hpp" class Quadratic: public Loss { public: Quadratic(); virtual ~Quadratic(); double loss(arma::Cube<double> output, arma::Cube<double> y); arma::Cube<double> loss_prime(const arma::Cube<double>& output, const arma::Cube<double>& y); }; #endif /* LOSS_QUADRATIC_HPP_ */
[ "kenk42292@gmail.com" ]
kenk42292@gmail.com
e0627d677d660f3f40ff90129c34054c24d8e9d0
23e8d9970daa0f3747e64ee4a53eef7f75d0ca90
/src/qt/intro.cpp
698203c43e66938553bc8f478eb344d77418608d
[ "MIT" ]
permissive
defense-org/defense-core
c8f5815a7324893584f434eeb6bdb6eb3204a0c7
9d296c1e174c1160dfe12cda02e52143f6964ad2
refs/heads/master
2020-08-30T15:52:44.047856
2019-11-11T21:33:34
2019-11-11T21:33:34
182,461,541
0
0
null
null
null
null
UTF-8
C++
false
false
8,937
cpp
// Copyright (c) 2011-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "intro.h" #include "ui_intro.h" #include "guiutil.h" #include "util.h" #include <boost/filesystem.hpp> #include <QFileDialog> #include <QMessageBox> #include <QSettings> /* Minimum free space (in bytes) needed for data directory */ static const uint64_t GB_BYTES = 1000000000LL; static const uint64_t BLOCK_CHAIN_SIZE = 1LL * GB_BYTES; /* Check free space asynchronously to prevent hanging the UI thread. Up to one request to check a path is in flight to this thread; when the check() function runs, the current path is requested from the associated Intro object. The reply is sent back through a signal. This ensures that no queue of checking requests is built up while the user is still entering the path, and that always the most recently entered path is checked as soon as the thread becomes available. */ class FreespaceChecker : public QObject { Q_OBJECT public: FreespaceChecker(Intro* intro); enum Status { ST_OK, ST_ERROR }; public slots: void check(); signals: void reply(int status, const QString& message, quint64 available); private: Intro* intro; }; #include "intro.moc" FreespaceChecker::FreespaceChecker(Intro* intro) { this->intro = intro; } void FreespaceChecker::check() { namespace fs = boost::filesystem; QString dataDirStr = intro->getPathToCheck(); fs::path dataDir = GUIUtil::qstringToBoostPath(dataDirStr); uint64_t freeBytesAvailable = 0; int replyStatus = ST_OK; QString replyMessage = tr("A new data directory will be created."); /* Find first parent that exists, so that fs::space does not fail */ fs::path parentDir = dataDir; fs::path parentDirOld = fs::path(); while (parentDir.has_parent_path() && !fs::exists(parentDir)) { parentDir = parentDir.parent_path(); /* Check if we make any progress, break if not to prevent an infinite loop here */ if (parentDirOld == parentDir) break; parentDirOld = parentDir; } try { freeBytesAvailable = fs::space(parentDir).available; if (fs::exists(dataDir)) { if (fs::is_directory(dataDir)) { QString separator = "<code>" + QDir::toNativeSeparators("/") + tr("name") + "</code>"; replyStatus = ST_OK; replyMessage = tr("Directory already exists. Add %1 if you intend to create a new directory here.").arg(separator); } else { replyStatus = ST_ERROR; replyMessage = tr("Path already exists, and is not a directory."); } } } catch (fs::filesystem_error& e) { /* Parent directory does not exist or is not accessible */ replyStatus = ST_ERROR; replyMessage = tr("Cannot create data directory here."); } emit reply(replyStatus, replyMessage, freeBytesAvailable); } Intro::Intro(QWidget* parent) : QDialog(parent), ui(new Ui::Intro), thread(0), signalled(false) { ui->setupUi(this); ui->sizeWarningLabel->setText(ui->sizeWarningLabel->text().arg(BLOCK_CHAIN_SIZE / GB_BYTES)); startThread(); } Intro::~Intro() { delete ui; /* Ensure thread is finished before it is deleted */ emit stopThread(); thread->wait(); } QString Intro::getDataDirectory() { return ui->dataDirectory->text(); } void Intro::setDataDirectory(const QString& dataDir) { ui->dataDirectory->setText(dataDir); if (dataDir == getDefaultDataDirectory()) { ui->dataDirDefault->setChecked(true); ui->dataDirectory->setEnabled(false); ui->ellipsisButton->setEnabled(false); } else { ui->dataDirCustom->setChecked(true); ui->dataDirectory->setEnabled(true); ui->ellipsisButton->setEnabled(true); } } QString Intro::getDefaultDataDirectory() { return GUIUtil::boostPathToQString(GetDefaultDataDir()); } bool Intro::pickDataDirectory() { namespace fs = boost::filesystem; QSettings settings; /* If data directory provided on command line, no need to look at settings or show a picking dialog */ if (!GetArg("-datadir", "").empty()) return true; /* 1) Default data directory for operating system */ QString dataDir = getDefaultDataDirectory(); /* 2) Allow QSettings to override default dir */ dataDir = settings.value("strDataDir", dataDir).toString(); if (!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || GetBoolArg("-choosedatadir", false)) { /* If current default data directory does not exist, let the user choose one */ Intro intro; intro.setDataDirectory(dataDir); intro.setWindowIcon(QIcon(":icons/defense")); while (true) { if (!intro.exec()) { /* Cancel clicked */ return false; } dataDir = intro.getDataDirectory(); try { TryCreateDirectory(GUIUtil::qstringToBoostPath(dataDir)); break; } catch (fs::filesystem_error& e) { QMessageBox::critical(0, tr("Defense Core"), tr("Error: Specified data directory \"%1\" cannot be created.").arg(dataDir)); /* fall through, back to choosing screen */ } } settings.setValue("strDataDir", dataDir); } /* Only override -datadir if different from the default, to make it possible to * override -datadir in the defense.conf file in the default data directory * (to be consistent with defensed behavior) */ if (dataDir != getDefaultDataDirectory()) SoftSetArg("-datadir", GUIUtil::qstringToBoostPath(dataDir).string()); // use OS locale for path setting return true; } void Intro::setStatus(int status, const QString& message, quint64 bytesAvailable) { switch (status) { case FreespaceChecker::ST_OK: ui->errorMessage->setText(message); ui->errorMessage->setStyleSheet(""); break; case FreespaceChecker::ST_ERROR: ui->errorMessage->setText(tr("Error") + ": " + message); ui->errorMessage->setStyleSheet("QLabel { color: #800000 }"); break; } /* Indicate number of bytes available */ if (status == FreespaceChecker::ST_ERROR) { ui->freeSpace->setText(""); } else { QString freeString = tr("%1 GB of free space available").arg(bytesAvailable / GB_BYTES); if (bytesAvailable < BLOCK_CHAIN_SIZE) { freeString += " " + tr("(of %1 GB needed)").arg(BLOCK_CHAIN_SIZE / GB_BYTES); ui->freeSpace->setStyleSheet("QLabel { color: #800000 }"); } else { ui->freeSpace->setStyleSheet(""); } ui->freeSpace->setText(freeString + "."); } /* Don't allow confirm in ERROR state */ ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status != FreespaceChecker::ST_ERROR); } void Intro::on_dataDirectory_textChanged(const QString& dataDirStr) { /* Disable OK button until check result comes in */ ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); checkPath(dataDirStr); } void Intro::on_ellipsisButton_clicked() { QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(0, "Choose data directory", ui->dataDirectory->text())); if (!dir.isEmpty()) ui->dataDirectory->setText(dir); } void Intro::on_dataDirDefault_clicked() { setDataDirectory(getDefaultDataDirectory()); } void Intro::on_dataDirCustom_clicked() { ui->dataDirectory->setEnabled(true); ui->ellipsisButton->setEnabled(true); } void Intro::startThread() { thread = new QThread(this); FreespaceChecker* executor = new FreespaceChecker(this); executor->moveToThread(thread); connect(executor, SIGNAL(reply(int, QString, quint64)), this, SLOT(setStatus(int, QString, quint64))); connect(this, SIGNAL(requestCheck()), executor, SLOT(check())); /* make sure executor object is deleted in its own thread */ connect(this, SIGNAL(stopThread()), executor, SLOT(deleteLater())); connect(this, SIGNAL(stopThread()), thread, SLOT(quit())); thread->start(); } void Intro::checkPath(const QString& dataDir) { mutex.lock(); pathToCheck = dataDir; if (!signalled) { signalled = true; emit requestCheck(); } mutex.unlock(); } QString Intro::getPathToCheck() { QString retval; mutex.lock(); retval = pathToCheck; signalled = false; /* new request can be queued now */ mutex.unlock(); return retval; }
[ "defense-org@protonmail.com" ]
defense-org@protonmail.com
6d20bba2a37166b3757895749187ac0b70e0e775
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function14699/function14699_schedule_14/function14699_schedule_14.cpp
9ae7fa7098e27a608ecbd756bcf0d1f52360e1dd
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
1,002
cpp
#include <tiramisu/tiramisu.h> using namespace tiramisu; int main(int argc, char **argv){ tiramisu::init("function14699_schedule_14"); constant c0("c0", 512), c1("c1", 256), c2("c2", 256); var i0("i0", 0, c0), i1("i1", 0, c1), i2("i2", 0, c2), i100("i100", 1, c0 - 1), i101("i101", 1, c1 - 1), i102("i102", 1, c2 - 1), i01("i01"), i02("i02"), i03("i03"), i04("i04"); input input0("input0", {i0, i1, i2}, p_int32); computation comp0("comp0", {i100, i101, i102}, (input0(i100, i101, i102) + input0(i100 + 1, i101, i102) - input0(i100 - 1, i101, i102))); comp0.tile(i100, i101, 128, 64, i01, i02, i03, i04); comp0.parallelize(i01); buffer buf00("buf00", {512, 256, 256}, p_int32, a_input); buffer buf0("buf0", {512, 256, 256}, p_int32, a_output); input0.store_in(&buf00); comp0.store_in(&buf0); tiramisu::codegen({&buf00, &buf0}, "../data/programs/function14699/function14699_schedule_14/function14699_schedule_14.o"); return 0; }
[ "ei_mekki@esi.dz" ]
ei_mekki@esi.dz
76d20207f09593e43e5d0785886ae24c179bbdb2
a7cb82dde437c45310328b1ea561e49fbdc342fb
/mine.h
82efbff80ff27b176a24b2e389bf3002af99c270
[]
no_license
dave18/Fuzed
f2848da527f272ad6e2cdd707b38edc65abae16f
ad2e715eb56ea3a57c8a1e240a4d805b500d0825
refs/heads/master
2021-01-25T12:13:56.471271
2012-11-11T13:38:34
2012-11-11T13:38:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,197
h
#ifndef MINE_H #define MINE_H //mine class class Tmine { private: char PeekByte(char* mem,int addr); int PeekInt(char* mem,int addr); int create(void); int remove(int id); void drawSprite(SDL_Surface* imageSurface, SDL_Surface* screenSurface, int srcX, int srcY, int dstX, int dstY, int width, int height,int id); int loadgfx(SDL_Surface** s, char* n); int channel; public: Tmine(); struct class_struct { int id; int startframe,endframe,currframe,framecount,framecounttotal; int belongsto,time; int x,y; SDL_Surface* image; float zx,zy; }; private: class_struct * item_store; int item_count; SDL_Surface* mine_floor; void Update2(class_struct* is); void SetScale(float xscale,float yscale,int id); public: void init(void); int spawn(int mx,int my,int sframe,int eframe,int acount,int bel); //Create new mine); void Update(); void Draw(); int GetPlayerID(int b); int GetTime(int b); int GetX(int b); int GetY(int b); void Destroy(int id); void ClearList(void); }; #endif
[ "david@david-openpandora-2.localdomain" ]
david@david-openpandora-2.localdomain
14f9a652883c519c895949fc7ef9cbbc405ea6cd
90c95fd7a5687b1095bf499892b8c9ba40f59533
/sprout/type_traits/has_logical_operator.hpp
61931344f8ddf1d47c88e1f4b83f571f79df0abf
[ "BSL-1.0" ]
permissive
CreativeLabs0X3CF/Sprout
af60a938fd12e8439a831d4d538c4c48011ca54f
f08464943fbe2ac2030060e6ff20e4bb9782cd8e
refs/heads/master
2021-01-20T17:03:24.630813
2016-08-15T04:44:46
2016-08-15T04:44:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
760
hpp
/*============================================================================= Copyright (c) 2011-2016 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under 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) =============================================================================*/ #ifndef SPROUT_TYPE_TRAITS_HAS_LOGICAL_OPERATOR_HPP #define SPROUT_TYPE_TRAITS_HAS_LOGICAL_OPERATOR_HPP #include <sprout/config.hpp> #include <sprout/type_traits/has_logical_and.hpp> #include <sprout/type_traits/has_logical_or.hpp> #include <sprout/type_traits/has_logical_not.hpp> #endif // #ifndef SPROUT_TYPE_TRAITS_HAS_LOGICAL_OPERATOR_HPP
[ "bolero.murakami@gmail.com" ]
bolero.murakami@gmail.com
42010598b420d2a5710cbf42810e1627ba7bc64a
43e9981a76019ab4a1b61768ef340f8cb6ebb87a
/src/plugins/applications/extension.h
c5b7c903f0aad3d2e3a3e972c4b58d2076c319d5
[]
no_license
anibalardid/albert
f9a39c983c06e40e33302c7da5843f2f82da9ef6
964b35ba0348a5848a7c2dda2fb6a7fb797437ca
refs/heads/master
2020-12-25T22:19:33.177428
2016-04-05T10:15:28
2016-04-05T10:15:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,279
h
// albert - a simple application launcher for linux // Copyright (C) 2014-2015 Manuel Schneider // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. #pragma once #include <QFileSystemWatcher> #include <QPointer> #include <QObject> #include <QString> #include <QMutex> #include <QTimer> #include <QList> #include <vector> #include "iextension.h" #include "offlineindex.h" namespace Applications { class DesktopEntry; class ConfigWidget; class Extension final : public QObject, public IExtension { Q_OBJECT Q_PLUGIN_METADATA(IID ALBERT_EXTENSION_IID FILE "metadata.json") Q_INTERFACES(IExtension) class Indexer; public: Extension(); ~Extension(); /* * Implementation of extension interface */ QWidget *widget(QWidget *parent = nullptr) override; void handleQuery(shared_ptr<Query> query) override; /* * Extension specific members */ void addDir(const QString &dirPath); void removeDir(const QString &dirPath); void restorePaths(); bool fuzzy(); void setFuzzy(bool b = true); void updateIndex(); private: QPointer<ConfigWidget> widget_; std::vector<shared_ptr<DesktopEntry>> index_; OfflineIndex offlineIndex_; QMutex indexAccess_; QPointer<Indexer> indexer_; QFileSystemWatcher watcher_; QTimer updateDelayTimer_; QStringList rootDirs_; /* const */ static const char* CFG_PATHS; static const char* CFG_FUZZY; static const bool DEF_FUZZY; static const char* CFG_TERM; static const char* DEF_TERM; static const bool UPDATE_DELAY; signals: void rootDirsChanged(const QStringList&); void statusInfo(const QString&); }; }
[ "manuelschneid3r@gmail.com" ]
manuelschneid3r@gmail.com
45fe4f856363c978396bc1b700f331df3561b0d6
7e06cfaf78a2ed860b0a2a7551c4670573fe47b8
/src/C45.cc
364237ee4cee265b4770b7e3f18ecbe9dbbeea82
[ "Apache-2.0" ]
permissive
DeepAINet/boostexp
f66b7df23047741584ef3162d4cc9d60472168df
df409046065d9827f21bba5049108389caed0e63
refs/heads/master
2020-06-05T15:09:50.771474
2019-06-21T04:06:13
2019-06-21T04:06:13
192,468,821
0
0
null
null
null
null
UTF-8
C++
false
false
16
cc
class C45{ };
[ "mengqy@mengqydeMacBook-Pro.local" ]
mengqy@mengqydeMacBook-Pro.local
e1fd4a667e2457a6f229d83d998ba1ff079f3ac7
dbc5fd6f0b741d07aca08cff31fe88d2f62e8483
/lib/Transforms/Coroutines/CoroElide.cpp
42fd6d7461459cce3fcd5bbb940b2359266bb029
[ "LicenseRef-scancode-unknown-license-reference", "NCSA" ]
permissive
yrnkrn/zapcc
647246a2ed860f73adb49fa1bd21333d972ff76b
c6a8aa30006d997eff0d60fd37b0e62b8aa0ea50
refs/heads/master
2023-03-08T22:55:12.842122
2020-07-21T10:21:59
2020-07-21T10:21:59
137,340,494
1,255
88
NOASSERTION
2020-07-21T10:22:01
2018-06-14T10:00:31
C++
UTF-8
C++
false
false
11,467
cpp
//===- CoroElide.cpp - Coroutine Frame Allocation Elision Pass ------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // This pass replaces dynamic allocation of coroutine frame with alloca and // replaces calls to llvm.coro.resume and llvm.coro.destroy with direct calls // to coroutine sub-functions. //===----------------------------------------------------------------------===// #include "CoroInternal.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/IR/InstIterator.h" #include "llvm/Pass.h" #include "llvm/Support/ErrorHandling.h" using namespace llvm; #define DEBUG_TYPE "coro-elide" namespace { // Created on demand if CoroElide pass has work to do. struct Lowerer : coro::LowererBase { SmallVector<CoroIdInst *, 4> CoroIds; SmallVector<CoroBeginInst *, 1> CoroBegins; SmallVector<CoroAllocInst *, 1> CoroAllocs; SmallVector<CoroSubFnInst *, 4> ResumeAddr; SmallVector<CoroSubFnInst *, 4> DestroyAddr; SmallVector<CoroFreeInst *, 1> CoroFrees; Lowerer(Module &M) : LowererBase(M) {} void elideHeapAllocations(Function *F, Type *FrameTy, AAResults &AA); bool shouldElide() const; bool processCoroId(CoroIdInst *, AAResults &AA); }; } // end anonymous namespace // Go through the list of coro.subfn.addr intrinsics and replace them with the // provided constant. static void replaceWithConstant(Constant *Value, SmallVectorImpl<CoroSubFnInst *> &Users) { if (Users.empty()) return; // See if we need to bitcast the constant to match the type of the intrinsic // being replaced. Note: All coro.subfn.addr intrinsics return the same type, // so we only need to examine the type of the first one in the list. Type *IntrTy = Users.front()->getType(); Type *ValueTy = Value->getType(); if (ValueTy != IntrTy) { // May need to tweak the function type to match the type expected at the // use site. assert(ValueTy->isPointerTy() && IntrTy->isPointerTy()); Value = ConstantExpr::getBitCast(Value, IntrTy); } // Now the value type matches the type of the intrinsic. Replace them all! for (CoroSubFnInst *I : Users) replaceAndRecursivelySimplify(I, Value); } // See if any operand of the call instruction references the coroutine frame. static bool operandReferences(CallInst *CI, AllocaInst *Frame, AAResults &AA) { for (Value *Op : CI->operand_values()) if (AA.alias(Op, Frame) != NoAlias) return true; return false; } // Look for any tail calls referencing the coroutine frame and remove tail // attribute from them, since now coroutine frame resides on the stack and tail // call implies that the function does not references anything on the stack. static void removeTailCallAttribute(AllocaInst *Frame, AAResults &AA) { Function &F = *Frame->getFunction(); MemoryLocation Mem(Frame); for (Instruction &I : instructions(F)) if (auto *Call = dyn_cast<CallInst>(&I)) if (Call->isTailCall() && operandReferences(Call, Frame, AA)) { // FIXME: If we ever hit this check. Evaluate whether it is more // appropriate to retain musttail and allow the code to compile. if (Call->isMustTailCall()) report_fatal_error("Call referring to the coroutine frame cannot be " "marked as musttail"); Call->setTailCall(false); } } // Given a resume function @f.resume(%f.frame* %frame), returns %f.frame type. static Type *getFrameType(Function *Resume) { auto *ArgType = Resume->arg_begin()->getType(); return cast<PointerType>(ArgType)->getElementType(); } // Finds first non alloca instruction in the entry block of a function. static Instruction *getFirstNonAllocaInTheEntryBlock(Function *F) { for (Instruction &I : F->getEntryBlock()) if (!isa<AllocaInst>(&I)) return &I; llvm_unreachable("no terminator in the entry block"); } // To elide heap allocations we need to suppress code blocks guarded by // llvm.coro.alloc and llvm.coro.free instructions. void Lowerer::elideHeapAllocations(Function *F, Type *FrameTy, AAResults &AA) { LLVMContext &C = FrameTy->getContext(); auto *InsertPt = getFirstNonAllocaInTheEntryBlock(CoroIds.front()->getFunction()); // Replacing llvm.coro.alloc with false will suppress dynamic // allocation as it is expected for the frontend to generate the code that // looks like: // id = coro.id(...) // mem = coro.alloc(id) ? malloc(coro.size()) : 0; // coro.begin(id, mem) auto *False = ConstantInt::getFalse(C); for (auto *CA : CoroAllocs) { CA->replaceAllUsesWith(False); CA->eraseFromParent(); } // FIXME: Design how to transmit alignment information for every alloca that // is spilled into the coroutine frame and recreate the alignment information // here. Possibly we will need to do a mini SROA here and break the coroutine // frame into individual AllocaInst recreating the original alignment. const DataLayout &DL = F->getParent()->getDataLayout(); auto *Frame = new AllocaInst(FrameTy, DL.getAllocaAddrSpace(), "", InsertPt); auto *FrameVoidPtr = new BitCastInst(Frame, Type::getInt8PtrTy(C), "vFrame", InsertPt); for (auto *CB : CoroBegins) { CB->replaceAllUsesWith(FrameVoidPtr); CB->eraseFromParent(); } // Since now coroutine frame lives on the stack we need to make sure that // any tail call referencing it, must be made non-tail call. removeTailCallAttribute(Frame, AA); } bool Lowerer::shouldElide() const { // If no CoroAllocs, we cannot suppress allocation, so elision is not // possible. if (CoroAllocs.empty()) return false; // Check that for every coro.begin there is a coro.destroy directly // referencing the SSA value of that coro.begin. If the value escaped, then // coro.destroy would have been referencing a memory location storing that // value and not the virtual register. SmallPtrSet<CoroBeginInst *, 8> ReferencedCoroBegins; for (CoroSubFnInst *DA : DestroyAddr) { if (auto *CB = dyn_cast<CoroBeginInst>(DA->getFrame())) ReferencedCoroBegins.insert(CB); else return false; } // If size of the set is the same as total number of CoroBegins, means we // found a coro.free or coro.destroy mentioning a coro.begin and we can // perform heap elision. return ReferencedCoroBegins.size() == CoroBegins.size(); } bool Lowerer::processCoroId(CoroIdInst *CoroId, AAResults &AA) { CoroBegins.clear(); CoroAllocs.clear(); CoroFrees.clear(); ResumeAddr.clear(); DestroyAddr.clear(); // Collect all coro.begin and coro.allocs associated with this coro.id. for (User *U : CoroId->users()) { if (auto *CB = dyn_cast<CoroBeginInst>(U)) CoroBegins.push_back(CB); else if (auto *CA = dyn_cast<CoroAllocInst>(U)) CoroAllocs.push_back(CA); else if (auto *CF = dyn_cast<CoroFreeInst>(U)) CoroFrees.push_back(CF); } // Collect all coro.subfn.addrs associated with coro.begin. // Note, we only devirtualize the calls if their coro.subfn.addr refers to // coro.begin directly. If we run into cases where this check is too // conservative, we can consider relaxing the check. for (CoroBeginInst *CB : CoroBegins) { for (User *U : CB->users()) if (auto *II = dyn_cast<CoroSubFnInst>(U)) switch (II->getIndex()) { case CoroSubFnInst::ResumeIndex: ResumeAddr.push_back(II); break; case CoroSubFnInst::DestroyIndex: DestroyAddr.push_back(II); break; default: llvm_unreachable("unexpected coro.subfn.addr constant"); } } // PostSplit coro.id refers to an array of subfunctions in its Info // argument. ConstantArray *Resumers = CoroId->getInfo().Resumers; assert(Resumers && "PostSplit coro.id Info argument must refer to an array" "of coroutine subfunctions"); auto *ResumeAddrConstant = ConstantExpr::getExtractValue(Resumers, CoroSubFnInst::ResumeIndex); replaceWithConstant(ResumeAddrConstant, ResumeAddr); bool ShouldElide = shouldElide(); auto *DestroyAddrConstant = ConstantExpr::getExtractValue( Resumers, ShouldElide ? CoroSubFnInst::CleanupIndex : CoroSubFnInst::DestroyIndex); replaceWithConstant(DestroyAddrConstant, DestroyAddr); if (ShouldElide) { auto *FrameTy = getFrameType(cast<Function>(ResumeAddrConstant)); elideHeapAllocations(CoroId->getFunction(), FrameTy, AA); coro::replaceCoroFree(CoroId, /*Elide=*/true); } return true; } // See if there are any coro.subfn.addr instructions referring to coro.devirt // trigger, if so, replace them with a direct call to devirt trigger function. static bool replaceDevirtTrigger(Function &F) { SmallVector<CoroSubFnInst *, 1> DevirtAddr; for (auto &I : instructions(F)) if (auto *SubFn = dyn_cast<CoroSubFnInst>(&I)) if (SubFn->getIndex() == CoroSubFnInst::RestartTrigger) DevirtAddr.push_back(SubFn); if (DevirtAddr.empty()) return false; Module &M = *F.getParent(); Function *DevirtFn = M.getFunction(CORO_DEVIRT_TRIGGER_FN); assert(DevirtFn && "coro.devirt.fn not found"); replaceWithConstant(DevirtFn, DevirtAddr); return true; } //===----------------------------------------------------------------------===// // Top Level Driver //===----------------------------------------------------------------------===// namespace { struct CoroElide : FunctionPass { static char ID; CoroElide() : FunctionPass(ID) { initializeCoroElidePass(*PassRegistry::getPassRegistry()); } std::unique_ptr<Lowerer> L; bool doInitialization(Module &M) override { if (coro::declaresIntrinsics(M, {"llvm.coro.id"})) L = llvm::make_unique<Lowerer>(M); return false; } bool runOnFunction(Function &F) override { if (!L) return false; bool Changed = false; if (F.hasFnAttribute(CORO_PRESPLIT_ATTR)) Changed = replaceDevirtTrigger(F); L->CoroIds.clear(); // Collect all PostSplit coro.ids. for (auto &I : instructions(F)) if (auto *CII = dyn_cast<CoroIdInst>(&I)) if (CII->getInfo().isPostSplit()) // If it is the coroutine itself, don't touch it. if (CII->getCoroutine() != CII->getFunction()) L->CoroIds.push_back(CII); // If we did not find any coro.id, there is nothing to do. if (L->CoroIds.empty()) return Changed; AAResults &AA = getAnalysis<AAResultsWrapperPass>().getAAResults(); for (auto *CII : L->CoroIds) Changed |= L->processCoroId(CII, AA); return Changed; } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<AAResultsWrapperPass>(); } StringRef getPassName() const override { return "Coroutine Elision"; } }; } char CoroElide::ID = 0; INITIALIZE_PASS_BEGIN( CoroElide, "coro-elide", "Coroutine frame allocation elision and indirect calls replacement", false, false) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) INITIALIZE_PASS_END( CoroElide, "coro-elide", "Coroutine frame allocation elision and indirect calls replacement", false, false) Pass *llvm::createCoroElidePass() { return new CoroElide(); }
[ "yaron.keren@gmail.com" ]
yaron.keren@gmail.com
c9ae5e3ca3dd6e69c84b2b5b9a556d94242e339b
09a5be4ce5eddc4b3af8e023fc1a09d40099c669
/src/network/src/network_address.cpp
27ef7797faad2f3c31b8715a35c09ded60341987
[]
no_license
rongwl/btclite
a48e5076dd8bfad80eb2b4de8fc024830529fa5b
5f7eb6fc2a51320a4dac9ea898c6fb3d62892fd3
refs/heads/master
2021-07-04T02:01:08.688741
2020-08-31T09:59:10
2020-08-31T09:59:10
158,512,773
1
0
null
null
null
null
UTF-8
C++
false
false
20,869
cpp
#include "network_address.h" #include <arpa/inet.h> #include <botan/base32.h> #include <sstream> #include "constants.h" namespace btclite { namespace network { NetAddr::NetAddr() : proto_addr_() { proto_addr_.mutable_ip()->Resize(ip_uint32_size, 0); } NetAddr::NetAddr(const struct sockaddr_in& addr) : proto_addr_() { proto_addr_.mutable_ip()->Resize(ip_uint32_size, 0); SetIpv4(addr.sin_addr.s_addr); proto_addr_.set_port(ntohs(addr.sin_port)); } NetAddr::NetAddr(const struct sockaddr_in6& addr6) : proto_addr_() { proto_addr_.mutable_ip()->Resize(ip_uint32_size, 0); SetIpv6(addr6.sin6_addr.s6_addr); proto_addr_.set_port(ntohs(addr6.sin6_port)); proto_addr_.set_scope_id(addr6.sin6_scope_id); } NetAddr::NetAddr(const struct sockaddr_storage& addr) : proto_addr_() { proto_addr_.mutable_ip()->Resize(ip_uint32_size, 0); if (addr.ss_family == AF_INET) { const struct sockaddr_in *addr4 = reinterpret_cast<const struct sockaddr_in*>(&addr); SetIpv4(addr4->sin_addr.s_addr); proto_addr_.set_port(ntohs(addr4->sin_port)); } else { const struct sockaddr_in6 *addr6 = reinterpret_cast<const struct sockaddr_in6*>(&addr); SetIpv6(addr6->sin6_addr.s6_addr); proto_addr_.set_port(ntohs(addr6->sin6_port)); proto_addr_.set_scope_id(addr6->sin6_scope_id); } } NetAddr::NetAddr(const proto_netaddr::NetAddr& proto_addr) : proto_addr_(proto_addr) { } NetAddr::NetAddr(proto_netaddr::NetAddr&& proto_addr) noexcept : proto_addr_(std::move(proto_addr)) { } NetAddr::NetAddr(uint32_t timestamp, uint64_t services, IpAddr& ip, uint16_t port) : proto_addr_() { proto_addr_.mutable_ip()->Resize(ip_uint32_size, 0); std::memcpy(proto_addr_.mutable_ip()->begin(), ip.begin(), kIpByteSize); proto_addr_.set_port(port); proto_addr_.set_services(services); proto_addr_.set_timestamp(timestamp); } NetAddr::NetAddr(uint32_t timestamp, uint64_t services, IpAddr&& ip, uint16_t port) noexcept : proto_addr_() { proto_addr_.mutable_ip()->Resize(ip_uint32_size, 0); std::memmove(proto_addr_.mutable_ip()->begin(), ip.begin(), kIpByteSize); proto_addr_.set_port(port); proto_addr_.set_services(services); proto_addr_.set_timestamp(timestamp); } bool NetAddr::IsIpv4() const { ASSERT_SIZE(); return (std::memcmp(proto_addr_.ip().begin(), kPchIpv4, sizeof(kPchIpv4)) == 0); } bool NetAddr::IsIpv6() const { ASSERT_SIZE(); return (!IsIpv4() && !IsTor() && !IsInternal()); } bool NetAddr::IsTor() const { ASSERT_SIZE(); return (std::memcmp(proto_addr_.ip().begin(), kPchOnionCat, sizeof(kPchOnionCat)) == 0); } bool NetAddr::IsRFC1918() const { return IsIpv4() && ( GetByte(12) == 10 || (GetByte(12) == 192 && GetByte(13) == 168) || (GetByte(12) == 172 && (GetByte(13) >= 16 && GetByte(13) <= 31))); return true; } bool NetAddr::IsRFC2544() const { return IsIpv4() && GetByte(12) == 198 && (GetByte(13) == 18 || GetByte(13) == 19); } bool NetAddr::IsRFC6598() const { return IsIpv4() && GetByte(12) == 100 && GetByte(13) >= 64 && GetByte(13) <= 127; } bool NetAddr::IsRFC5737() const { return IsIpv4() && ((GetByte(12) == 192 && GetByte(13) == 0 && GetByte(14) == 2) || (GetByte(12) == 198 && GetByte(13) == 51 && GetByte(14) == 100) || (GetByte(12) == 203 && GetByte(13) == 0 && GetByte(14) == 113)); } bool NetAddr::IsRFC3849() const { return IsIpv6() && GetByte(0) == 0x20 && GetByte(1) == 0x01 && GetByte(2) == 0x0D && GetByte(3) == 0xB8; } bool NetAddr::IsRFC3927() const { return IsIpv4() && (GetByte(12) == 169 && GetByte(13) == 254); } bool NetAddr::IsRFC3964() const { return IsIpv6() && (GetByte(0) == 0x20 && GetByte(1) == 0x02); } bool NetAddr::IsRFC4193() const { return IsIpv6() && ((GetByte(0) & 0xFE) == 0xFC); } bool NetAddr::IsRFC4380() const { return IsIpv6() && (GetByte(0) == 0x20 && GetByte(1) == 0x01 && GetByte(2) == 0 && GetByte(3) == 0); } bool NetAddr::IsRFC4843() const { return IsIpv6() && (GetByte(0) == 0x20 && GetByte(1) == 0x01 && GetByte(2) == 0x00 && (GetByte(3) & 0xF0) == 0x10); } bool NetAddr::IsRFC4862() const { return IsIpv6() && (proto_addr_.ip(0) == 0x80FE && proto_addr_.ip(1) == 0); } bool NetAddr::IsRFC6052() const { return IsIpv6() && (proto_addr_.ip(0) == 0x9BFF6400 && proto_addr_.ip(1) == 0); } bool NetAddr::IsRFC6145() const { return IsIpv6() && (proto_addr_.ip(0) == 0 && proto_addr_.ip(1) == 0 && proto_addr_.ip(2) == 0xFFFF); } bool NetAddr::IsLocal() const { // IPv4 loopback if (IsIpv4() && (GetByte(12) == 127 || GetByte(12) == 0)) return true; // IPv6 loopback (::1/128) if (IsIpv6() && (proto_addr_.ip(0) == 0 && proto_addr_.ip(1) == 0 && proto_addr_.ip(2) == 0 && proto_addr_.ip(3) == 0x1000000)) return true; return false; } bool NetAddr::IsRoutable() const { return IsValid() && !(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || IsRFC6598() || IsRFC5737() || IsRFC4193() || IsRFC4843() || (IsRFC4193() && !IsTor()) || IsLocal() || IsInternal()); } bool NetAddr::IsInternal() const { ASSERT_SIZE(); return (std::memcmp(proto_addr_.ip().data(), kBtcIpPrefix, sizeof(kBtcIpPrefix)) == 0); } bool NetAddr::IsValid() const { // Cleanup 3-byte shifted addresses caused by garbage in size field // of addr messages from versions before 0.2.9 checksum. // Two consecutive addr messages look like this: // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26... // so if the first length field is garbled, it reads the second batch // of addr misaligned by 3 bytes. if (std::memcmp(proto_addr_.ip().data(), kPchIpv4+3, sizeof(kPchIpv4)-3) == 0) return false; // unspecified IPv6 address (::/128) unsigned char ip6_none[kIpByteSize] = {}; if (std::memcmp(proto_addr_.ip().data(), ip6_none, kIpByteSize) == 0) return false; // documentation IPv6 address if (IsRFC3849()) return false; if (IsInternal()) return false; if (IsIpv4()) { // INADDR_NONE if (proto_addr_.ip(3) == INADDR_NONE) return false; // 0 if (proto_addr_.ip(3) == 0) return false; } return true; } std::string NetAddr::ToString() const { std::stringstream ss; if (IsTor()) return Botan::base32_encode(reinterpret_cast<const uint8_t*>(proto_addr_.ip().begin()) + sizeof(kPchOnionCat), kIpByteSize - sizeof(kPchOnionCat)) + ".onion"; if (IsInternal()) return Botan::base32_encode(reinterpret_cast<const uint8_t*>(proto_addr_.ip().begin()) + sizeof(kBtcIpPrefix), kIpByteSize - sizeof(kBtcIpPrefix)) + ".internal"; if (IsIpv4()) ss << +GetByte(12) << "." << +GetByte(13) << "." << +GetByte(14) << "." << +GetByte(15); else ss << std::hex << ((GetByte(0) << 8) | GetByte(1)) << ":" << ((GetByte(2) << 8) | GetByte(3)) << ":" << ((GetByte(4) << 8) | GetByte(5)) << ":" << ((GetByte(6) << 8) | GetByte(7)) << ":" << ((GetByte(8) << 8) | GetByte(9)) << ":" << ((GetByte(10) << 8) | GetByte(11)) << ":" << ((GetByte(12) << 8) | GetByte(13)) << ":" << ((GetByte(14) << 8) | GetByte(15)); return ss.str(); } bool NetAddr::ToSockAddr(struct sockaddr* out) const { if (IsIpv4()) { struct sockaddr_in *addr = reinterpret_cast<struct sockaddr_in*>(out); std::memset(addr, 0, sizeof(*addr)); addr->sin_family = AF_INET; addr->sin_addr.s_addr = GetIpv4(); addr->sin_port = htons(proto_addr_.port()); return true; } if (IsIpv6()) { struct sockaddr_in6 *addr6 = reinterpret_cast<struct sockaddr_in6*>(out); std::memset(addr6, 0, sizeof(*addr6)); addr6->sin6_family = AF_INET6; GetIpv6(addr6->sin6_addr.s6_addr); addr6->sin6_port = htons(proto_addr_.port()); addr6->sin6_scope_id = proto_addr_.scope_id(); return true; } return false; } bool NetAddr::FromSockAddr(const struct sockaddr *in) { if (in->sa_family == AF_INET) { *this = NetAddr(*reinterpret_cast<const struct sockaddr_in*>(in)); return true; } else if (in->sa_family == AF_INET6) { *this = NetAddr(*reinterpret_cast<const sockaddr_in6*>(in)); return true; } return false; } size_t NetAddr::SerializedSize() const { return sizeof(proto_addr_.timestamp()) + sizeof(proto_addr_.services()) + kIpByteSize + sizeof(uint16_t); } void NetAddr::Clear() { proto_addr_.clear_timestamp(); proto_addr_.clear_services(); for (int i = 0; i < proto_addr_.ip_size(); i++) proto_addr_.set_ip(i, 0); proto_addr_.clear_port(); } uint8_t NetAddr::GetByte(int n) const { ASSERT_VALID_BYTE(n); const uint8_t *byte = reinterpret_cast<const uint8_t*>(proto_addr_.ip().data()); return byte[n]; } void NetAddr::SetByte(int n, uint8_t value) { ASSERT_VALID_BYTE(n); uint8_t *byte = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(proto_addr_.ip().data())); byte[n] = value; } void NetAddr::SetNByte(const uint8_t *src, size_t n) { ASSERT_VALID_BYTE(n); for (int i = 0; i < n; i++) SetByte(i, src[i]); } // return ip in network byte order uint32_t NetAddr::GetIpv4() const { ASSERT_SIZE(); if (!IsIpv4()) return INADDR_NONE; return proto_addr_.ip(3); } void NetAddr::SetIpv4(uint32_t net_byte_order_ip) { ASSERT_SIZE(); if (!IsIpv4()) SetNByte(kPchIpv4, sizeof(kPchIpv4)); proto_addr_.set_ip(3, net_byte_order_ip); } bool NetAddr::GetIpv6(uint8_t *out) const { ASSERT_SIZE(); if (!IsIpv6()) return false; std::memcpy(out, proto_addr_.ip().begin(), kIpByteSize); return true; } void NetAddr::SetIpv6(const uint8_t *src) { ASSERT_SIZE(); for (int i = 0; i < kIpByteSize; i++) SetByte(i, src[i]); } void NetAddr::GetGroup(std::vector<uint8_t> *out) const { ASSERT_SIZE(); int af = kAfIpv6; int start_byte = 0; int bits = 16; if (!out) return; out->clear(); // all local addresses belong to the same group if (IsLocal()) { af = 255; bits = 0; } // all internal-usage addresses get their own group if (IsInternal()) { af = kAfInternal; start_byte = sizeof(kBtcIpPrefix); bits = (kIpByteSize - sizeof(kBtcIpPrefix)) * 8; } // all other unroutable addresses belong to the same group else if (!IsRoutable()) { af = kAfUnroutable; bits = 0; } // for IPv4 addresses, '1' + the 16 higher-order bits of the IP // includes mapped IPv4, SIIT translated IPv4, and the well-known prefix else if (IsIpv4() || IsRFC6145() || IsRFC6052()) { af = kAfIpv4; start_byte = 12; } // for 6to4 tunnelled addresses, use the encapsulated IPv4 address else if (IsRFC3964()) { af = kAfIpv4; start_byte = 2; } // for Teredo-tunnelled IPv6 addresses, use the encapsulated IPv4 address else if (IsRFC4380()) { out->push_back(kAfIpv4); out->push_back(GetByte(12) ^ 0xFF); out->push_back(GetByte(13) ^ 0xFF); return; } else if (IsTor()) { af = kAfTor; start_byte = 6; bits = 4; } // for he.net, use /36 groups else if (GetByte(0) == 0x20 && GetByte(1) == 0x01 && GetByte(2) == 0x04 && GetByte(3) == 0x70) bits = 36; // for the rest of the IPv6 network, use /32 groups else bits = 32; out->push_back(af); while (bits >= 8) { out->push_back(GetByte(start_byte)); start_byte++; bits -= 8; } if (bits > 0) out->push_back(GetByte(start_byte) | ((1 << (8 - bits)) - 1)); } bool NetAddr::SetInternal(const std::string& name) { if (name.empty()) { return false; } uint8_t hash[32] = {}; std::unique_ptr<Botan::HashFunction> hash_func(Botan::HashFunction::create("SHA-256")); hash_func->update(reinterpret_cast<const uint8_t*>(name.data()), name.size()); hash_func->final(hash); uint8_t *data = reinterpret_cast<uint8_t*>(proto_addr_.mutable_ip()->mutable_data()); std::memcpy(data, kBtcIpPrefix, sizeof(kBtcIpPrefix)); std::memcpy(data + sizeof(kBtcIpPrefix), hash, kIpByteSize - sizeof(kBtcIpPrefix)); return true; } AddrFamily NetAddr::GetFamily() const { if (IsInternal()) return kAfInternal; if (!IsRoutable()) return kAfUnroutable; if (IsIpv4()) return kAfIpv4; if (IsTor()) return kAfTor; return kAfIpv6; } int NetAddr::GetReachability(const NetAddr& addr_partner) const { enum Reachability { kReachUnreachable, kReachDefault, kReachTeredo, kReachIpv6Weak, kReachIpv4, kReachIpv6Strong, kReachPrivate }; if (!IsRoutable() || IsInternal()) return kReachUnreachable; int our_net = GetExtFamily(); int their_net = addr_partner.GetExtFamily(); bool is_tunnel = IsRFC3964() || IsRFC6052() || IsRFC6145(); switch(their_net) { case kAfIpv4: switch(our_net) { case kAfIpv4: return kReachIpv4; default: return kReachDefault; } case kAfIpv6: switch(our_net) { case kAfTeredo: return kReachTeredo; case kAfIpv4: return kReachIpv4; case kAfIpv6: // only prefer giving our IPv6 address if it's not tunnelled return is_tunnel ? kReachIpv6Weak : kReachIpv6Strong; default: return kReachDefault; } case kAfTor: switch(our_net) { case kAfIpv4: return kReachIpv4; // Tor users can connect to IPv4 as well case kAfTor: return kReachPrivate; default: return kReachDefault; } case kAfTeredo: switch(our_net) { case kAfTeredo: return kReachTeredo; case kAfIpv6: return kReachIpv6Weak; case kAfIpv4: return kReachIpv4; default: return kReachDefault; } case kAfUnroutable: default: switch(our_net) { case kAfTeredo: return kReachTeredo; case kAfIpv6: return kReachIpv6Weak; case kAfIpv4: return kReachIpv4; case kAfTor: return kReachPrivate; // either from Tor, or don't care about our address default: return kReachDefault; } } } AddrFamily NetAddr::GetExtFamily() const { if (IsRFC4380()) return kAfTeredo; return GetFamily(); } util::Hash256 NetAddr::GetHash() const { crypto::HashOStream hs; for (const auto& raw : proto_addr_.ip()) hs << raw; hs << proto_addr_.port(); return hs.Sha256(); } uint16_t NetAddr::port() const { return static_cast<uint16_t>(proto_addr_.port()); } void NetAddr::set_port(uint16_t port) { proto_addr_.set_port(port); } uint32_t NetAddr::scope_id() const { return proto_addr_.scope_id(); } void NetAddr::set_scope_id(uint32_t id) { proto_addr_.set_scope_id(id); } uint64_t NetAddr::services() const { return proto_addr_.services(); } void NetAddr::set_services(uint64_t services) { proto_addr_.set_services(services); } uint32_t NetAddr::timestamp() const { return proto_addr_.timestamp(); } void NetAddr::set_timestamp(uint32_t timestamp) { proto_addr_.set_timestamp(timestamp); } const proto_netaddr::NetAddr& NetAddr::proto_addr() const { return proto_addr_; } SubNet::SubNet() : net_addr_(), valid_(false) { std::memset(netmask_, 0, sizeof(netmask_)); } SubNet::SubNet(const NetAddr& addr) : net_addr_(addr), valid_(addr.IsValid()) { std::memset(netmask_, 0xff, sizeof(netmask_)); } SubNet::SubNet(NetAddr&& addr) noexcept : net_addr_(std::move(addr)), valid_(addr.IsValid()) { std::memset(netmask_, 0xff, sizeof(netmask_)); } SubNet::SubNet(const NetAddr& addr, int32_t mask) : net_addr_(addr), valid_(true) { // Default to /32 (IPv4) or /128 (IPv6), i.e. match single address memset(netmask_, 0xff, sizeof(netmask_)); // IPv4 addresses start at offset 12, and first 12 bytes must match, so just offset n const int astartofs = net_addr_.IsIpv4() ? 12 : 0; int32_t n = mask; if(n >= 0 && n <= (128 - astartofs*8)) // Only valid if in range of bits of address { n += astartofs*8; // Clear bits [n..127] for (; n < 128; ++n) netmask_[n>>3] &= ~(1<<(7-(n&7))); } else valid_ = false; // Normalize network according to netmask for(int x = 0; x < netmask_byte_size; ++x) net_addr_.SetByte(x, (net_addr_.GetByte(x) & netmask_[x])); } SubNet::SubNet(const NetAddr &addr, const NetAddr &mask) : net_addr_(addr), valid_(true) { // Default to /32 (IPv4) or /128 (IPv6), i.e. match single address memset(netmask_, 255, sizeof(netmask_)); // IPv4 addresses start at offset 12, and first 12 bytes must match, so just offset n const int astartofs = net_addr_.IsIpv4() ? 12 : 0; for(int x=astartofs; x<16; ++x) netmask_[x] = mask.GetByte(x); // Normalize network according to netmask for(int x = 0; x < netmask_byte_size; ++x) net_addr_.SetByte(x, (net_addr_.GetByte(x) & netmask_[x])); } bool SubNet::IsValid() const { return valid_; } void SubNet::Clear() { net_addr_.Clear(); std::memset(netmask_, 0, sizeof(netmask_)); valid_ = false; } bool SubNet::Match(const NetAddr& addr) const { if (!valid_ || !addr.IsValid()) return false; for (int i = 0; i < netmask_byte_size; ++i) if ((addr.GetByte(i) & netmask_[i]) != net_addr_.GetByte(i)) return false; return true; } std::string SubNet::ToString() const { /* Parse binary 1{n}0{N-n} to see if mask can be represented as /n */ int cidr = 0; bool valid_cidr = true; int n = net_addr_.IsIpv4() ? 12 : 0; for (; n < 16 && netmask_[n] == 0xff; ++n) cidr += 8; if (n < 16) { int bits = NetmaskBits(netmask_[n]); if (bits < 0) valid_cidr = false; else cidr += bits; ++n; } for (; n < 16 && valid_cidr; ++n) if (netmask_[n] != 0x00) valid_cidr = false; /* Format output */ std::stringstream os; if (valid_cidr) { os << cidr; } else { if (net_addr_.IsIpv4()) os << +netmask_[12] << "." << +netmask_[13] << "." << +netmask_[14] << "." << +netmask_[15]; else os << std::hex << (netmask_[0] << 8 | netmask_[1]) << ":" << (netmask_[2] << 8 | netmask_[3]) << ":" << (netmask_[4] << 8 | netmask_[5]) << ":" << (netmask_[6] << 8 | netmask_[7]) << ":" << (netmask_[8] << 8 | netmask_[9]) << ":" << (netmask_[10] << 8 | netmask_[11]) << ":" << (netmask_[12] << 8 | netmask_[13]) << ":" << (netmask_[14] << 8 | netmask_[15]); } return net_addr_.ToString() + "/" + os.str(); } const NetAddr& SubNet::net_addr() const { return net_addr_; } const uint8_t* const SubNet::netmask() const { return netmask_; } int SubNet::NetmaskBits(uint8_t x) const { switch(x) { case 0x00: return 0; case 0x80: return 1; case 0xc0: return 2; case 0xe0: return 3; case 0xf0: return 4; case 0xf8: return 5; case 0xfc: return 6; case 0xfe: return 7; case 0xff: return 8; default: break; } return -1; } } // namespace network } // namespace btclite
[ "michael_air_rong@163.com" ]
michael_air_rong@163.com
4ab5aa57f35f28e447abfa54151eb86b602c4545
64b71454a4823806e62ac617829b8923be375c3a
/IRScan/IRScanDlg.h
b30a6edd398b223b2ac52053abe44179b1fa2388
[]
no_license
seafrog1984/IRScan-Server
3b131b0c9d1eecdc2c2fa59a562d149a641e9d8c
7ccfa140b29ef619f59556f4c98cf20c78272e0c
refs/heads/master
2021-09-11T04:35:15.423198
2018-01-15T15:33:36
2018-01-15T15:33:36
103,039,508
0
0
null
null
null
null
UTF-8
C++
false
false
777
h
// IRScanDlg.h : header file // #pragma once #include "afxcmn.h" #include "CaptureDlg.h" #include "SettingDlg.h" // CIRScanDlg dialog class CIRScanDlg : public CDialogEx { // Construction public: CIRScanDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data enum { IDD = IDD_IRSCAN_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: HICON m_hIcon; // Generated message map functions virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() public: CTabCtrl m_tab; CCaptureDlg capDlg; CSettingDlg setDlg; afx_msg void OnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult); };
[ "seafrog1984@hotmail.com" ]
seafrog1984@hotmail.com
3abe0eb5fc67bc28cdb152b2197bc7333ee4b121
b8fb6c802cf4767f582b64aca4e05ab8df9b7cbe
/src/Lua/LuaHelper.cpp
62dfb3f4efb5dca569982a3eb890a3414268c1b9
[ "MIT" ]
permissive
castly6/rainbow
8bc82bbb6d2b1bae3b095a05c12b10f599267ae8
96d90b5a81e1fda09f5b570f6c972026d1b29f32
refs/heads/master
2020-05-30T11:27:39.773049
2015-12-22T16:21:24
2015-12-22T20:10:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,264
cpp
// Copyright (c) 2010-14 Bifrost Entertainment AS and Tommy Nguyen // Distributed under the MIT License. // (See accompanying file LICENSE or copy at http://opensource.org/licenses/MIT) #include "Lua/LuaHelper.h" #include <cstring> #include <memory> #include "Common/Data.h" #include "FileSystem/File.h" #include "FileSystem/Path.h" #include "Lua/LuaDebugging.h" #include "Lua/LuaSyntax.h" namespace { const char kLuaErrorErrorHandling[] = "error handling"; const char kLuaErrorGeneral[] = "general"; const char kLuaErrorMemory[] = "memory allocation"; const char kLuaErrorRuntime[] = "runtime"; const char kLuaErrorSyntax[] = "syntax"; const char kLuaErrorType[] = "Object is not of type '%s'"; int load_module(lua_State *L, char *const path, const char *const module, const char *const suffix) { strcpy(path, module); strcat(path, suffix); const Path asset(path); #ifndef RAINBOW_OS_ANDROID if (!asset.is_file()) return 0; #endif // RAINBOW_OS_ANDROID const File &file = File::open(asset); if (!file) return 0; const int result = rainbow::lua::load(L, Data(file), module, false); if (result == 0) return luaL_error(L, "Failed to load '%s'", module); return result; } } NS_RAINBOW_LUA_BEGIN { ScopedRef::ScopedRef(lua_State *L) : state_(L), ref_(luaL_ref(L, LUA_REGISTRYINDEX)) {} ScopedRef::~ScopedRef() { if (ref_ == LUA_REFNIL || lua_rawlen(state_, LUA_REGISTRYINDEX) < static_cast<size_t>(ref_)) return; luaL_unref(state_, LUA_REGISTRYINDEX, ref_); } void ScopedRef::reset(lua_State *L) { if (ref_ != LUA_REFNIL) luaL_unref(state_, LUA_REGISTRYINDEX, ref_); state_ = L; ref_ = (!L ? LUA_REFNIL : luaL_ref(L, LUA_REGISTRYINDEX)); } void error(lua_State *L, const int result) { R_ASSERT(result != LUA_OK, "No error to report"); const char *desc = kLuaErrorGeneral; switch (result) { case LUA_ERRRUN: desc = kLuaErrorRuntime; break; case LUA_ERRSYNTAX: desc = kLuaErrorSyntax; break; case LUA_ERRMEM: desc = kLuaErrorMemory; break; case LUA_ERRERR: desc = kLuaErrorErrorHandling; break; default: break; } LOGE("Lua %s error: %s", desc, lua_tostring(L, -1)); lua_pop(L, 1); dump_stack(L); } int load(lua_State *L) { const char *module = lua_tostring(L, -1); std::unique_ptr<char[]> path(new char[strlen(module) + 10]); const int result = load_module(L, path.get(), module, ".lua"); return (!result ? load_module(L, path.get(), module, "/init.lua") : result); } int load(lua_State *L, const Data &chunk, const char *name, const bool exec) { int e = luaL_loadbuffer(L, chunk, chunk.size(), name); if (e == LUA_OK && exec) e = lua_pcall(L, 0, LUA_MULTRET, 0); if (e != LUA_OK) { error(L, e); return 0; } return 1; } template<> void push<bool>(lua_State *L, const bool b) { lua_pushboolean(L, b); } template<> void push<const char*>(lua_State *L, const char *const str) { lua_pushstring(L, str); } template<> void push<lua_CFunction>(lua_State *L, const lua_CFunction c) { lua_pushcfunction(L, c); } template<> void push<lua_Integer>(lua_State *L, const lua_Integer i) { lua_pushinteger(L, i); } template<> void push<lua_Number>(lua_State *L, const lua_Number n) { lua_pushnumber(L, n); } void pushpointer(lua_State *L, void *ptr, const char *name) { lua_createtable(L, 1, 1); lua_pushlightuserdata(L, ptr); lua_rawseti(L, -2, 0); luaR_rawsetstring(L, "__type", name); } int reload(lua_State *L, const Data &chunk, const char *name) { lua_getglobal(L, "package"); lua_pushliteral(L, "loaded"); lua_rawget(L, -2); R_ASSERT(lua_istable(L, -1), "Missing control table 'package.loaded'"); lua_pushstring(L, name); lua_pushnil(L); lua_rawset(L, -3); lua_pop(L, 2); return load(L, chunk, name, true); } void replacetable(lua_State *L, const int n) { if (!lua_istable(L, n)) return; lua_pushliteral(L, "__userdata"); lua_rawget(L, n); if (!lua_isuserdata(L, -1)) { lua_pop(L, 1); return; } lua_replace(L, n); } void sethook(lua_State *L, const int mask) { if (g_level >= 0) return; int depth = -1; lua_Debug ar; while (lua_getstack(L, ++depth, &ar)); --depth; while (lua_getstack(L, ++g_level, &ar)) { lua_getinfo(L, "Sl", &ar); g_callstack[depth - g_level].currentline = ar.currentline; g_callstack[depth - g_level].nparams = ar.nparams; g_callstack[depth - g_level].source = ar.source; } lua_sethook(L, lua_Hook, mask, 0); } void* topointer(lua_State *L, const char *name) { LUA_ASSERT(L, !lua_isnil(L, -1), "Unexpected nil value"); LUA_ASSERT(L, lua_istable(L, -1), kLuaErrorType, name); lua_pushliteral(L, "__type"); lua_rawget(L, -2); const char *type = lua_tostring(L, -1); if (!type) { LUA_ASSERT(L, type, kLuaErrorType, name); lua_pop(L, 1); return nullptr; } LUA_ASSERT(L, strcmp(type, name) == 0, kLuaErrorType, name); lua_rawgeti(L, -2, 0); void *ptr = lua_touserdata(L, -1); lua_pop(L, 2); return ptr; static_cast<void>(name); static_cast<void>(kLuaErrorType); } } NS_RAINBOW_LUA_END
[ "tn0502@gmail.com" ]
tn0502@gmail.com
5e5eca87a7aa561cb9b5d6a8bf905e675e0e12b8
7d981c361b07dc4771835a57713efd7c9767c5e1
/CardsPlayer.cpp
bc37c46dad8d60dabc88998a89fb38bec079adfe
[]
no_license
monkeyking88/CardDeck
f3c811dcd037a4fb38ed46da4f084f4686bbfcbc
b329ff709ef7b1c0277589fa4203bd2d16ca2fe0
refs/heads/master
2020-03-25T05:35:18.482581
2018-08-03T17:25:17
2018-08-03T17:25:17
143,453,999
0
0
null
null
null
null
UTF-8
C++
false
false
4,519
cpp
// // CardsPlayer.cpp // CS247 // // Created by Mengqi Liu on 2013-07-18. // Copyright (c) 2013 Matthew Yang. All rights reserved. // #include "CardsPlayer.h" #include <vector> #include "Card.h" #include "View.h" using namespace std; CardsPlayer::CardsPlayer(View* v) : hbox( true, 10 ), v(v){ const Glib::RefPtr<Gdk::Pixbuf> nullCardPixbuf = deck.getNullCardImage(); set_border_width( 10 ); frame.set_label( " Your Cards:" ); frame.set_label_align( Gtk::ALIGN_TOP ); frame.set_shadow_type( Gtk::SHADOW_ETCHED_OUT ); add( frame ); frame.add( hbox ); // Initialize 13 empty cards with buttons and place them in the box. for (int i = 0; i < 13; i++ ) { card[i] = new Gtk::Image( nullCardPixbuf ); hbox.add( *card[i] ); button[i].set_image( *card[i] ); hbox.add( button[i] ); } //add different event handler to different button //one the specific button is clicked, the event function call will be fired button[0].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex0 ) ); button[1].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex1 ) ); button[2].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex2 ) ); button[3].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex3 ) ); button[4].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex4 ) ); button[5].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex5 ) ); button[6].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex6 ) ); button[7].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex7 ) ); button[8].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex8 ) ); button[9].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex9 ) ); button[10].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex10 ) ); button[11].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex11 ) ); button[12].signal_clicked().connect( sigc::mem_fun( *this, &CardsPlayer::handCardIndex12 ) ); }//end of CardsPlayer constructor void CardsPlayer::setNUllPic(){ const Glib::RefPtr<Gdk::Pixbuf> nullCardPixbuf = deck.getNullCardImage(); for (int i = 0; i < 13; i++ ) { card[i]->set( nullCardPixbuf ); } } void CardsPlayer::displayCards(vector<Card> onhand){ setNUllPic(); for (int i = 0; i<onhand.size(); ++i){ Rank rank= onhand[i].getRank(); Suit suit = onhand[i].getSuit(); cout<<suit << " "<< rank <<endl; card[i]->set(deck.getCardImage(rank,suit)); } } //whold banch of event handler, basically just return the index of card to view and Game //for futhure logic and view update void CardsPlayer::handCardIndex0(){ this->button_index = 0; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex1(){ this->button_index = 1; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex2(){ this->button_index = 2; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex3(){ this->button_index = 3; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex4(){ this->button_index = 4; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex5(){ this->button_index = 5; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex6(){ this->button_index = 6; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex7(){ this->button_index = 7; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex8(){ this->button_index = 8; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex9(){ this->button_index = 9; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex10(){ this->button_index = 10; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex11(){ this->button_index = 11; v->handCardBtnClicked(this->button_index); } void CardsPlayer::handCardIndex12(){ this->button_index = 12; v->handCardBtnClicked(this->button_index); } int CardsPlayer::getCardIndex() const{ return button_index; } CardsPlayer::~CardsPlayer(){ for (int i = 0; i < 13; i++ ){ delete card[i]; } }
[ "monkeyking9288@gmail.com" ]
monkeyking9288@gmail.com
2fae0711b7a3e1639421adda5ae8fae1dd745016
a38ccdbbc6ae26c287dd1f7d795e6bf78f7a22ae
/GKOM_Projekt/Cylinder.cpp
6474adb062f293d0ddce8f324bf6a18eb14f3c9b
[]
no_license
ASobolewski/OpenGL-project
7f39519e87c31918daf70a044d87edf60e481e88
c3efbca7aec7ecd467feb68cb75481c0359a4e35
refs/heads/master
2021-01-12T02:04:20.131547
2017-06-09T21:32:04
2017-06-09T21:32:04
78,462,570
0
0
null
null
null
null
UTF-8
C++
false
false
4,448
cpp
#include "Cylinder.h" void calc_circle_coords(std::vector<GLfloat> &coords, GLfloat x, GLfloat y, GLfloat z, GLfloat radius, GLuint segments) { GLfloat alfa = 2.0f * glm::pi<GLfloat>() / segments; coords.push_back(x); coords.push_back(y); coords.push_back(z); for (GLuint i = 0; i < segments; i++) { GLfloat xi = radius *glm::cos(alfa*i); GLfloat yi = radius *glm::sin(alfa*i); coords.push_back(x + xi); coords.push_back(y + yi); coords.push_back(z); } } std::vector<GLuint> calc_circle_indices(GLuint segments) { std::vector<GLuint> indices; for (GLuint i = 1; i < segments; i++) { indices.push_back(0); indices.push_back(i); indices.push_back(i + 1); } indices.push_back(0); indices.push_back(1); indices.push_back(segments); for (GLuint i = segments + 2; i < segments * 2 + 1; i++) { indices.push_back(segments + 1); indices.push_back(i); indices.push_back(i + 1); } indices.push_back(segments + 1); indices.push_back(segments * 2 + 1); indices.push_back(segments + 2); return indices; } std::vector<GLuint> calc_cylinder_side_indices(GLuint segments) { std::vector<GLuint> indices; for (GLuint i = 1; i < segments; i++) { indices.push_back(i); indices.push_back(i + 1); indices.push_back(segments + 1 + i); } indices.push_back(segments); indices.push_back(1); indices.push_back(segments * 2 + 1); for (GLuint i = segments + 2; i < segments * 2 + 1; i++) { indices.push_back(i); indices.push_back(i + 1); indices.push_back(i - segments); } indices.push_back(1); indices.push_back(segments + 2); indices.push_back(segments * 2 + 1); return indices; } std::vector<GLuint> calc_cylinder_indices(GLuint segments) { std::vector<GLuint> circleIndices = calc_circle_indices(segments); std::vector<GLuint> sideIndices = calc_cylinder_side_indices(segments); std::vector<GLuint> cylinderIndices; cylinderIndices.reserve(circleIndices.size() + sideIndices.size()); cylinderIndices.insert(cylinderIndices.end(), circleIndices.begin(), circleIndices.end()); cylinderIndices.insert(cylinderIndices.end(), sideIndices.begin(), sideIndices.end()); return cylinderIndices; } std::vector<GLfloat> calc_cylinder_normals(std::vector<GLfloat> cylinderCoords, std::vector<GLuint> indices) { std::vector<GLfloat> normals; glm::vec3 A; glm::vec3 B; for (GLuint i = 0; i < indices.size(); i += 3) { A = glm::vec3(cylinderCoords[3 * indices[i + 1]] - cylinderCoords[3 * indices[i]], cylinderCoords[3 * indices[i + 1] + 1] - cylinderCoords[3 * indices[i] + 1], cylinderCoords[3 * indices[i + 1] + 2] - cylinderCoords[3 * indices[i] + 2]); B = glm::vec3(cylinderCoords[3 * indices[i + 2]] - cylinderCoords[3 * indices[i]], cylinderCoords[3 * indices[i + 2] + 1] - cylinderCoords[3 * indices[i] + 1], cylinderCoords[3 * indices[i + 2] + 2] - cylinderCoords[3 * indices[i] + 2]); glm::vec3 iloczyn; if (i < indices.size() / 4 - 3) iloczyn = glm::normalize(glm::cross(B, A)); else if (i < indices.size() / 2 - 3) iloczyn = glm::normalize(glm::cross(A, B)); else if (i< indices.size() * 3 / 4) iloczyn = glm::normalize(glm::cross(A, B)); else if (i< indices.size() - 3) iloczyn = glm::normalize(glm::cross(B, A)); else iloczyn = glm::normalize(glm::cross(A, B)); normals.push_back(iloczyn.x); normals.push_back(iloczyn.y); normals.push_back(iloczyn.z); } return normals; } std::vector<GLfloat> calc_cylinder_final(std::vector<GLfloat> coords, std::vector<GLfloat> normals, std::vector<GLuint> indices, int segments) { std::vector<GLfloat> result; int j = 0; int k = 0; for (GLuint i = 0; i < indices.size(); i++) { result.push_back(coords[3 * indices[i]]); result.push_back(coords[3 * indices[i] + 1]); result.push_back(coords[3 * indices[i] + 2]); result.push_back(normals[j]); result.push_back(normals[j + 1]); result.push_back(normals[j + 2]); k++; if (k % 3 == 0) { j += 3; } } return result; } std::vector<GLfloat> calc_cylinder_coords(GLfloat x, GLfloat y, GLfloat z, GLfloat height, GLfloat radius, GLuint segments) { std::vector<GLfloat> coords; calc_circle_coords(coords, x, y, z, radius, segments); calc_circle_coords(coords, x, y, z + height, radius, segments); std::vector<GLuint> indices = calc_cylinder_indices(segments); std::vector<GLfloat>cylinderCoords = calc_cylinder_final(coords, calc_cylinder_normals(coords, indices), indices, segments); return cylinderCoords; }
[ "adrian.sobolew@gmail.com" ]
adrian.sobolew@gmail.com
9fcee7a6ee8a62c343c4f79cddfc26b896685908
127e6a0c6abb58da2aa10485703afd95536e1ed3
/AtCoder/arc075_a.cpp
fa2ecf986e6e22e795049185e8b96e48ea1ebadf
[]
no_license
NKH123/Competitive-Programming
d5fdf16831677c96b0d7171b61d05b47e33ea840
b905780d0af2c61af0e87924f3525879c4febed0
refs/heads/master
2021-06-28T09:58:37.938421
2020-09-12T20:52:15
2020-09-12T20:52:15
145,118,633
5
1
null
null
null
null
UTF-8
C++
false
false
2,024
cpp
#include<bits/stdc++.h> using namespace std; #define F first #define S second #define PB push_back #define MP make_pair #define REP(i,a,b) for (int i = a; i <b; i++) typedef long long ll; #define int ll typedef vector<int> vi; typedef vector<long long> vl; typedef pair<int,int> pi; #define trace(x) cout<<#x<<"="<<x<<"\n"; #define llp 1000000007 #define mod 1000000007 template < typename F, typename S > ostream& operator << ( ostream& os, const pair< F, S > & p ) { return os << "(" << p.first << ", " << p.second << ")"; } template < typename T > ostream &operator << ( ostream & os, const vector< T > &v ) { os << "{"; typename vector< T > :: const_iterator it; for( it = v.begin(); it != v.end(); it++ ) { if( it != v.begin() ) os << ", "; os << *it; } return os << "}"; } template < typename T > ostream &operator << ( ostream & os, const set< T > &v ) { os << "["; typename set< T > :: const_iterator it; for ( it = v.begin(); it != v.end(); it++ ) { if( it != v.begin() ) os << ", "; os << *it; } return os << "]"; } template < typename F, typename S > ostream &operator << ( ostream & os, const map< F, S > &v ) { os << "["; typename map< F , S >::const_iterator it; for( it = v.begin(); it != v.end(); it++ ) { if( it != v.begin() ) os << ", "; os << it -> first << " = " << it -> second ; } return os << "]"; } #define deb(x) cerr << #x << " = " << x << endl; int dp[10005]; int32_t main(){ ios::sync_with_stdio(false); int n; cin>>n; vi a(n); REP(i,0,n)cin>>a[i]; memset(dp,0,sizeof(dp)); dp[0]=1; for(int i=0;i<n;i++){ // deb(i); // deb(a[i]); for(int j=10005;j>=a[i];j--){ if(dp[j-a[i]]){ // deb(j); dp[j]=1; } } } int ans=0; for(int i=0;i<10005;i++){ if(dp[i] && i%10!=0){ ans=max(i,ans); } } cout<<ans<<"\n"; return 0; }
[ "neeraj.171it226@nitk.edu.in" ]
neeraj.171it226@nitk.edu.in
5704ec334c598088f8f41d34cbee68f0a7dc8ef0
f869cb0cb89ade3231b7f2781ead1f08ec621b7d
/p/PermutationSequence.cpp
1be5750dc37a1bc7ca33d4a9e8439263390775ac
[]
no_license
amnesia4bygone/codeleet
06ea3e446e281d4237eb12fd470a8515346a57d6
d2a4d962084891a89454a5ffd198e23882fe4dc6
refs/heads/master
2016-09-16T06:34:05.280273
2013-02-23T02:56:37
2013-02-23T02:56:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,125
cpp
#include <string> #include <vector> using namespace std; class Solution { public: int return_offset(int loop_len, int & k) { int offset = (k-1)/loop_len; k = k - offset*loop_len; return offset; } string getPermutation(int n, int k) { // Start typing your C/C++ solution below // DO NOT write int main() function vector<int> stack; string result; int sum = 1; for(int i=1; i<=n; i++) { stack.push_back(i); sum *= i; } for(int i=n; i>= 1; i--) { sum /=i; int offset = return_offset(sum, k); char buf[8]; memset(buf, 0, 8); sprintf(buf, "%d", stack[offset]); string one(buf); result += one; stack.erase(stack.begin() + offset); } return result; } }; int main(void) { Solution s; s.getPermutation(2,1); return 1; }
[ "amnesia.bygone@gmail.com" ]
amnesia.bygone@gmail.com
566ff56353fea3ec97a708c5d5a864022a644580
d5d03792a869747a07ae75bef1a00ef07cb46e08
/distribute/src/caffe/layers/divide_layer.cpp
fa342281c7cad9b0846ab1b58154d53030f9d5ff
[]
no_license
klqulei/Face_Parsing_2016
ddd5f338795a345c8642bd4dc9a85053879c154b
89e2c485f770badd3461a1828956c330a4100017
refs/heads/master
2020-04-08T19:41:32.890426
2018-05-25T04:00:35
2018-05-25T04:00:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,356
cpp
#include <algorithm> #include <vector> #include "caffe/layers/divide_layer.hpp" //#include "caffe/layer.hpp" //#include "caffe/layers/neuron_layer.hpp" namespace caffe { template <typename Dtype> void DivideLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { Dtype* bottom_data = bottom[0]->mutable_cpu_data(); Dtype* top_data = top[0]->mutable_cpu_data(); const int count = bottom[0]->count(); for (int i = 0; i < count; ++i) { if (bottom_data[i]==0) { bottom_data[i] = Dtype(0.0001); } top_data[i] = Dtype(1) / bottom_data[i]; } } template <typename Dtype> void DivideLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { const Dtype* top_diff = top[0]->cpu_diff(); Dtype* bottom_data = bottom[0]->mutable_cpu_data(); Dtype* bottom_diff = bottom[0]->mutable_cpu_diff(); const int count = bottom[0]->count(); for (int i = 0; i < count; ++i) { if (bottom_data[i]==0) { bottom_data[i] = Dtype(0.0001); } bottom_diff[i] = (Dtype(-1) / (bottom_data[i] * bottom_data[i])) * top_diff[i]; } } #ifdef CPU_ONLY STUB_GPU(DivideLayer); #endif INSTANTIATE_CLASS(DivideLayer); REGISTER_LAYER_CLASS(Divide); }// namespace caffe
[ "zwrq0star@gmail.com" ]
zwrq0star@gmail.com
0b2d0d8771bd4d3353178713e252f895618feba8
8d19ab53401030209dd7e5e655bdb0e2952bfa7e
/toonz/sources/include/tfxattributes.h
7a4c0d738d9407613a5e0722e69be89ad27b90a0
[ "BSD-3-Clause" ]
permissive
deruji/opentoonz
825a74af1dbc89c62991458a352650c4ef766fde
ad5f6141388f796c5146876916c812bf1b1f0ff9
refs/heads/master
2021-05-03T09:41:12.454051
2016-04-22T21:08:08
2016-04-22T21:08:08
54,891,799
0
0
null
2016-04-22T21:08:08
2016-03-28T12:49:04
C++
UTF-8
C++
false
false
2,196
h
#ifndef TFX_ATTRIBUTES_INCLUDED #define TFX_ATTRIBUTES_INCLUDED #include "tgeometry.h" #include <QStack> #undef DVAPI #undef DVVAR #ifdef TFX_EXPORTS #define DVAPI DV_EXPORT_API #define DVVAR DV_EXPORT_VAR #else #define DVAPI DV_IMPORT_API #define DVVAR DV_IMPORT_VAR #endif class DVAPI TFxAttributes { int m_id; TPointD m_dagNodePos; bool m_enabled; bool m_speedAware; bool m_isOpened; TPointD m_speed; //A stack is used to manage subgroups. QStack<int> m_groupId; QStack<wstring> m_groupName; int m_passiveCacheDataIdx; int m_groupSelector; /*-- MotionBlurなどのFxのために、オブジェクトの軌跡のデータを取得する --*/ QList<TPointD> m_motionPoints; public: TFxAttributes(); ~TFxAttributes(); void setId(int id) { m_id = id; } int getId() { return m_id; } void setDagNodePos(const TPointD &pos); TPointD getDagNodePos() const { return m_dagNodePos; } bool isEnabled() const { return m_enabled; } void enable(bool on) { m_enabled = on; } void setIsSpeedAware(bool yes) { m_speedAware = yes; } bool isSpeedAware() const { return m_speedAware; } void setSpeed(TPointD &speed) { m_speed = speed; } TPointD getSpeed() const { return m_speed; } void setIsOpened(bool value) { m_isOpened = value; } bool isOpened() { return m_isOpened; } int &passiveCacheDataIdx() { return m_passiveCacheDataIdx; } void setMotionPoints(QList<TPointD> motionPoints) { m_motionPoints = motionPoints; } QList<TPointD> getMotionPoints() { return m_motionPoints; } //Group management int setGroupId(int value); void setGroupId(int value, int position); int getGroupId(); QStack<int> getGroupIdStack(); void removeGroupId(int position); int removeGroupId(); void removeFromAllGroup(); bool isGrouped(); bool isContainedInGroup(int groupId); void setGroupName(const wstring &name, int position = -1); wstring getGroupName(bool fromEditor); QStack<wstring> getGroupNameStack(); int removeGroupName(bool fromEditor); void removeGroupName(int position = -1); bool editGroup(); bool isGroupEditing(); void closeEditingGroup(int groupId); int getEditingGroupId(); wstring getEditingGroupName(); void closeAllGroups(); }; #endif
[ "shimizu.toshihiro@gmail.com" ]
shimizu.toshihiro@gmail.com
4942bee353d8313252d4a3031138510551f99dda
a679dba6ef0364962b94ed65d0caad1a88da6c43
/ServerProject/KittyPureServer/sceneserver/SceneServer.h
2e4d363d9aa64356037666a960966c3e9ac2c7e7
[]
no_license
w5762847/Learn
7f84933fe664e6cf52089a9f4b9140fca8b9a783
a5494181ea791fd712283fa8e78ca0287bf05318
refs/heads/master
2020-08-27T05:43:35.496579
2016-12-02T12:16:12
2016-12-02T12:16:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,955
h
/** * \file * \version $Id: SceneServer.h 67 2013-04-23 09:44:20Z $ * \author , * \date 2013年04月07日 15时55分53秒 CST * \brief Fir场景服务器 * */ #ifndef _SCENESERVER_H_ #define _SCENESERVER_H_ #include "zSubNetService.h" #include "Fir.h" #include "zMisc.h" #include "zMemDBPool.h" #include "zCmdHandle.h" #include "MessageQueue.h" #include "zDBConnPool.h" class SceneUser; //SUPER指令缓冲 class SuperCmdQueue : public MessageBuffer<100> { private: //处理全区来的c++消息 bool allZoneMsgParseStruct(SceneUser *user,const CMD::t_NullCmd *ptNullCmd,const DWORD cmdLen); //处理全区来的proto消息 bool allZoneMsgParseProto(SceneUser *user,const BYTE *data,const DWORD cmdLen); //处理superCmd消息 bool msgParseSuperCmd(const CMD::SUPER::SuperServerNull *superNull,const DWORD nCmdLen); public: //处理全区来的所有消息(必须是c++消息头,服务器内部消息) bool cmdMsgParse(const CMD::t_NullCmd *ptNullCmd, const DWORD nCmdLen); //分发消息c++和proto消息 bool allzoneMsgParse(SceneUser *user,const BYTE *data, const DWORD cmdLen); }; /** * \brief 定义计费服务类 * * 这个类使用了Singleton设计模式,保证了一个进程中只有一个类的实例 * */ class SceneService : public zSubNetService, public Singleton<SceneService> { friend class Singleton<SceneService>; public: WORD getZoneID () const { return zoneID.zone; } ~SceneService() { instance = NULL; //关闭线程池 if (taskPool) { taskPool->final(); SAFE_DELETE(taskPool); } } const int getPoolSize() const { if(taskPool) { return taskPool->getSize(); } else { return 0; } } bool isSequeueTerminate() { return taskPool == NULL; } bool msgParse_SuperService(const CMD::t_NullCmd *ptNullCmd, const unsigned int nCmdLen); //重新加载配置文件 void reloadconfig(); bool initConfig(); virtual void getnewServerEntry(const CMD::SUPER::ServerEntry &entry); public: //MD5存档验证 bool md5Verify; int writeBackGroup; GameZone_t zoneID; SuperCmdQueue superCmd; static DWORD cmd_record[4]; static char cmd_recordNew[zSocket::MAX_DATASIZE]; static DWORD cmd_len; zCmdHandleManager cmd_handle_manager; static zDBConnPool *dbConnPool; static MetaData* metaData; private: /** * \brief 构造函数 * */ SceneService() : zSubNetService("场景服务器", SCENESSERVER) { taskPool = NULL; md5Verify = false; writeBackGroup = 10; } bool init(); void newTCPTask(const int sock, const struct sockaddr_in *addr); void final(); private: /** * \brief 类的唯一实例指针 * */ static SceneService *instance; zTCPTaskPool *taskPool; /**< TCP连接池的指针 */ }; #endif
[ "flyer_son@126.com" ]
flyer_son@126.com
3def068f1168b6fb5d587185dce999a23ee5b508
6c77cf237697f252d48b287ae60ccf61b3220044
/aws-cpp-sdk-elasticbeanstalk/source/model/ActionHistoryStatus.cpp
ccd6e93f4249989652ac22d2eee3e8b15efa9bd2
[ "MIT", "Apache-2.0", "JSON" ]
permissive
Gohan/aws-sdk-cpp
9a9672de05a96b89d82180a217ccb280537b9e8e
51aa785289d9a76ac27f026d169ddf71ec2d0686
refs/heads/master
2020-03-26T18:48:43.043121
2018-11-09T08:44:41
2018-11-09T08:44:41
145,232,234
1
0
Apache-2.0
2018-08-30T13:42:27
2018-08-18T15:42:39
C++
UTF-8
C++
false
false
2,785
cpp
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 <aws/elasticbeanstalk/model/ActionHistoryStatus.h> #include <aws/core/utils/HashingUtils.h> #include <aws/core/Globals.h> #include <aws/core/utils/EnumParseOverflowContainer.h> using namespace Aws::Utils; namespace Aws { namespace ElasticBeanstalk { namespace Model { namespace ActionHistoryStatusMapper { static const int Completed_HASH = HashingUtils::HashString("Completed"); static const int Failed_HASH = HashingUtils::HashString("Failed"); static const int Unknown_HASH = HashingUtils::HashString("Unknown"); ActionHistoryStatus GetActionHistoryStatusForName(const Aws::String& name) { int hashCode = HashingUtils::HashString(name.c_str()); if (hashCode == Completed_HASH) { return ActionHistoryStatus::Completed; } else if (hashCode == Failed_HASH) { return ActionHistoryStatus::Failed; } else if (hashCode == Unknown_HASH) { return ActionHistoryStatus::Unknown; } EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); if(overflowContainer) { overflowContainer->StoreOverflow(hashCode, name); return static_cast<ActionHistoryStatus>(hashCode); } return ActionHistoryStatus::NOT_SET; } Aws::String GetNameForActionHistoryStatus(ActionHistoryStatus enumValue) { switch(enumValue) { case ActionHistoryStatus::Completed: return "Completed"; case ActionHistoryStatus::Failed: return "Failed"; case ActionHistoryStatus::Unknown: return "Unknown"; default: EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); if(overflowContainer) { return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); } return ""; } } } // namespace ActionHistoryStatusMapper } // namespace Model } // namespace ElasticBeanstalk } // namespace Aws
[ "henso@amazon.com" ]
henso@amazon.com
0978038625f8815eb03db9678b659d8ed3ba3f1f
305652c7bbdda46a7f4767a06c7e3573d8ab4b84
/codeforces/682/A.cpp
e3ff721187976f8ca1c0b44144e7cbae5ba2616e
[]
no_license
ImperishableMe/codeforces-submissions
cde2ac379aa0580937d935f1ece7d3681e45471a
9cd18f567c477f7392f2994c22168b4c6801d02c
refs/heads/master
2023-06-15T03:46:05.243797
2021-06-18T13:34:00
2021-07-11T07:20:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
734
cpp
#include <stdio.h> int main() { long long int a1[11],a2[11]; int m,n; scanf("%d %d",&n,&m); for(int i=0;i<=10;i++) a1[i]=0; for(int i=0;i<=10;i++) a1[i]=a1[i]+n/10; for(int k=1;k<=(n%10);k++) a1[k]++; for(int i=0;i<=10;i++) a2[i]=0; for(int i=0;i<=10;i++) a2[i]=a2[i]+m/10; for(int k=1;k<=(m%10);k++) a2[k]++; long long int sum=a1[0]*a2[0]+a1[0]*a2[5]+a1[1]*a2[4]+a1[1]*a2[9]+a1[2]*a2[3]+a1[2]*a2[8]+a1[3]*a2[2]+ a1[3]*a2[7]+a1[4]*a2[1]+a1[4]*a2[6]+a1[5]*a2[5]+a1[5]*a2[0]+ a1[6]*a2[4]+a1[6]*a2[9]+a1[7]*a2[8]+a1[7]*a2[3]+a1[8]*a2[2]+ a1[8]*a2[7]+a1[9]*a2[1]+a1[9]*a2[6]; printf("%I64d\n",sum); return 0; }
[ "bishwajit0020@gmail.com" ]
bishwajit0020@gmail.com
c967210dfec860be41493832ea0a15a9602df7b6
bdb86768bfd78420848f28c8e17f0044676890d3
/cpp_optimise.cpp
9185885bab7318dd3d31dd655a64bfbbad91068a
[]
no_license
bodhisatwa-mandal/DS-Algo
29565ffc0e7adc2225f540e30489fdece20613f4
0d50b86f16c27eb8e5a0e65300c82924010bb048
refs/heads/master
2021-08-19T14:06:33.476503
2017-11-26T15:02:14
2017-11-26T15:02:14
112,082,042
0
0
null
null
null
null
UTF-8
C++
false
false
158
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); return 0; }
[ "bodhisatwam@gmail.com" ]
bodhisatwam@gmail.com
82b71a9fa1e7654970f2b34ad396d2bdd191e4b4
3c358ed09b70d5185786ab3bed65c610fa9de974
/playground/playground.cpp
f1e952d8082a46c37380638f7d6d35559f6ed91c
[]
no_license
zsdvvb/LearnOPENGL
14818a18ff6f0d01a34eb2d8e88cd749fb2528f7
2737e171eb94fb3b68f2ecf1107656de4c7f37a8
refs/heads/master
2020-07-15T12:34:15.819427
2016-09-11T08:19:17
2016-09-11T08:19:17
67,911,807
0
0
null
null
null
null
UTF-8
C++
false
false
2,308
cpp
#include <iostream> // GLEW #define GLEW_STATIC #include "..\external\include\glew.h" // GLFW #include "../external/include/glfw3.h" // Function prototypes void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode); // Window dimensions const GLuint WIDTH = 800, HEIGHT = 600; // The MAIN function, from here we start the application and run the game loop int main() { std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl; // Init GLFW glfwInit(); // Set all the required options for GLFW glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); // Create a GLFWwindow object that we can use for GLFW's functions GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr); if (window == nullptr) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); // Set the required callback functions glfwSetKeyCallback(window, key_callback); // Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions glewExperimental = GL_TRUE; // Initialize GLEW to setup the OpenGL Function pointers if (glewInit() != GLEW_OK) { std::cout << "Failed to initialize GLEW" << std::endl; return -1; } // Define the viewport dimensions int width, height; glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); // Game loop while (!glfwWindowShouldClose(window)) { // Check if any events have been activiated (key pressed, mouse moved etc.) and call corresponding response functions glfwPollEvents(); // Render // Clear the colorbuffer glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // Swap the screen buffers glfwSwapBuffers(window); } // Terminate GLFW, clearing any resources allocated by GLFW. glfwTerminate(); return 0; } // Is called whenever a key is pressed/released via GLFW void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode) { std::cout << key << std::endl; if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, GL_TRUE); }
[ "15521188045@163.com" ]
15521188045@163.com
8d83013db04bcc7ed1ad95ef1218c054a4998014
04b1803adb6653ecb7cb827c4f4aa616afacf629
/chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_impl_win.cc
dcc144500b06b08116384d4e2de7e86ff0fef1b5
[ "BSD-3-Clause" ]
permissive
Samsung/Castanets
240d9338e097b75b3f669604315b06f7cf129d64
4896f732fc747dfdcfcbac3d442f2d2d42df264a
refs/heads/castanets_76_dev
2023-08-31T09:01:04.744346
2021-07-30T04:56:25
2021-08-11T05:45:21
125,484,161
58
49
BSD-3-Clause
2022-10-16T19:31:26
2018-03-16T08:07:37
null
UTF-8
C++
false
false
28,839
cc
// Copyright 2017 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 "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_impl_win.h" #include <windows.h> #include <set> #include <string> #include <utility> #include <vector> #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" #include "base/files/file_util.h" #include "base/location.h" #include "base/logging.h" #include "base/metrics/histogram_macros.h" #include "base/task/post_task.h" #include "base/task/task_traits.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/component_updater/sw_reporter_installer_win.h" #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" #include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_fetcher_win.h" #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_navigation_util_win.h" #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_reboot_dialog_controller_impl_win.h" #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_runner_win.h" #include "chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h" #include "chrome/browser/safe_browsing/chrome_cleaner/settings_resetter_win.h" #include "chrome/browser/safe_browsing/chrome_cleaner/srt_client_info_win.h" #include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h" #include "chrome/browser/ui/browser.h" #include "chrome/installer/util/scoped_token_privilege.h" #include "components/chrome_cleaner/public/constants/constants.h" #include "components/component_updater/component_updater_service.h" #include "components/component_updater/pref_names.h" #include "components/prefs/pref_service.h" #include "components/safe_browsing/common/safe_browsing_prefs.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "net/http/http_status_code.h" #include "ui/base/window_open_disposition.h" namespace safe_browsing { namespace { using ::chrome_cleaner::mojom::ChromePrompt; using ::chrome_cleaner::mojom::PromptAcceptance; using ::content::BrowserThread; // The global singleton instance. Exposed outside of GetInstance() so that it // can be reset by tests. ChromeCleanerControllerImpl* g_controller = nullptr; // TODO(alito): Move these shared exit codes to the chrome_cleaner component. // https://crbug.com/727956 constexpr int kRebootRequiredExitCode = 15; constexpr int kRebootNotRequiredExitCode = 0; // These values are used to send UMA information and are replicated in the // enums.xml file, so the order MUST NOT CHANGE. enum CleanupResultHistogramValue { CLEANUP_RESULT_SUCCEEDED = 0, CLEANUP_RESULT_REBOOT_REQUIRED = 1, CLEANUP_RESULT_FAILED = 2, CLEANUP_RESULT_MAX, }; // These values are used to send UMA information and are replicated in the // enums.xml file, so the order MUST NOT CHANGE. enum IPCDisconnectedHistogramValue { IPC_DISCONNECTED_SUCCESS = 0, IPC_DISCONNECTED_LOST_WHILE_SCANNING = 1, IPC_DISCONNECTED_LOST_USER_PROMPTED = 2, IPC_DISCONNECTED_MAX, }; // Attempts to change the Chrome Cleaner binary's suffix to ".exe". Will return // an empty FilePath on failure. Should be called on a sequence with traits // appropriate for IO operations. base::FilePath VerifyAndRenameDownloadedCleaner( base::FilePath downloaded_path, ChromeCleanerFetchStatus fetch_status) { if (downloaded_path.empty() || !base::PathExists(downloaded_path)) return base::FilePath(); if (fetch_status != ChromeCleanerFetchStatus::kSuccess) { base::DeleteFile(downloaded_path, /*recursive=*/false); return base::FilePath(); } base::FilePath executable_path( downloaded_path.ReplaceExtension(FILE_PATH_LITERAL("exe"))); if (!base::ReplaceFile(downloaded_path, executable_path, nullptr)) { base::DeleteFile(downloaded_path, /*recursive=*/false); return base::FilePath(); } return executable_path; } void OnChromeCleanerFetched( ChromeCleanerControllerDelegate::FetchedCallback fetched_callback, base::FilePath downloaded_path, ChromeCleanerFetchStatus fetch_status) { base::PostTaskWithTraitsAndReplyWithResult( FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT, base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, base::BindOnce(VerifyAndRenameDownloadedCleaner, downloaded_path, fetch_status), std::move(fetched_callback)); } ChromeCleanerController::IdleReason IdleReasonWhenConnectionClosedTooSoon( ChromeCleanerController::State current_state) { DCHECK(current_state == ChromeCleanerController::State::kScanning || current_state == ChromeCleanerController::State::kInfected); return current_state == ChromeCleanerController::State::kScanning ? ChromeCleanerController::IdleReason::kScanningFailed : ChromeCleanerController::IdleReason::kConnectionLost; } void RecordScannerLogsAcceptanceHistogram(bool logs_accepted) { UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.ScannerLogsAcceptance", logs_accepted); } void RecordCleanerLogsAcceptanceHistogram(bool logs_accepted) { UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.CleanerLogsAcceptance", logs_accepted); } void RecordCleanupResultHistogram(CleanupResultHistogramValue result) { UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.Cleaner.CleanupResult", result, CLEANUP_RESULT_MAX); } void RecordIPCDisconnectedHistogram(IPCDisconnectedHistogramValue error) { UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.IPCDisconnected", error, IPC_DISCONNECTED_MAX); } void RecordReporterSequenceTypeHistogram( SwReporterInvocationType invocation_type) { UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.ReporterSequenceType", static_cast<int>(invocation_type), static_cast<int>(SwReporterInvocationType::kMax)); } void RecordReporterSequenceResultHistogram( SwReporterInvocationType invocation_type, SwReporterInvocationResult result) { if (invocation_type == SwReporterInvocationType::kPeriodicRun) { UMA_HISTOGRAM_ENUMERATION( "SoftwareReporter.ReporterSequenceResult_Periodic", static_cast<int>(result), static_cast<int>(SwReporterInvocationResult::kMax)); } else { UMA_HISTOGRAM_ENUMERATION( "SoftwareReporter.ReporterSequenceResult_UserInitiated", static_cast<int>(result), static_cast<int>(SwReporterInvocationResult::kMax)); } } void RecordOnDemandUpdateRequiredHistogram(bool value) { UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.OnDemandUpdateRequired", value); } } // namespace ChromeCleanerControllerDelegate::ChromeCleanerControllerDelegate() = default; ChromeCleanerControllerDelegate::~ChromeCleanerControllerDelegate() = default; void ChromeCleanerControllerDelegate::FetchAndVerifyChromeCleaner( FetchedCallback fetched_callback) { FetchChromeCleaner( base::BindOnce(&OnChromeCleanerFetched, base::Passed(&fetched_callback)), g_browser_process->system_network_context_manager() ->GetURLLoaderFactory()); } bool ChromeCleanerControllerDelegate::IsMetricsAndCrashReportingEnabled() { return ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); } void ChromeCleanerControllerDelegate::TagForResetting(Profile* profile) { if (PostCleanupSettingsResetter::IsEnabled()) PostCleanupSettingsResetter().TagForResetting(profile); } void ChromeCleanerControllerDelegate::ResetTaggedProfiles( std::vector<Profile*> profiles, base::OnceClosure continuation) { if (PostCleanupSettingsResetter::IsEnabled()) { PostCleanupSettingsResetter().ResetTaggedProfiles( std::move(profiles), std::move(continuation), std::make_unique<PostCleanupSettingsResetter::Delegate>()); } } void ChromeCleanerControllerDelegate::StartRebootPromptFlow( ChromeCleanerController* controller) { // The controller object decides if and when a prompt should be shown. ChromeCleanerRebootDialogControllerImpl::Create(controller); } // static ChromeCleanerControllerImpl* ChromeCleanerControllerImpl::GetInstance() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (!g_controller) { g_controller = new ChromeCleanerControllerImpl(); } return g_controller; } // static ChromeCleanerController* ChromeCleanerController::GetInstance() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); return ChromeCleanerControllerImpl::GetInstance(); } ChromeCleanerController::State ChromeCleanerControllerImpl::state() const { return state_; } ChromeCleanerController::IdleReason ChromeCleanerControllerImpl::idle_reason() const { return idle_reason_; } void ChromeCleanerControllerImpl::SetLogsEnabled(Profile* profile, bool logs_enabled) { PrefService* profile_prefs = profile->GetPrefs(); profile_prefs->SetBoolean(prefs::kSwReporterReportingEnabled, logs_enabled); } bool ChromeCleanerControllerImpl::logs_enabled(Profile* profile) const { PrefService* profile_prefs = profile->GetPrefs(); return profile_prefs->GetBoolean(prefs::kSwReporterReportingEnabled); } void ChromeCleanerControllerImpl::ResetIdleState() { if (state() != State::kIdle || idle_reason() == IdleReason::kInitial) return; idle_reason_ = IdleReason::kInitial; // SetStateAndNotifyObservers doesn't allow transitions to the same state. // Notify observers directly instead. for (auto& observer : observer_list_) NotifyObserver(&observer); } void ChromeCleanerControllerImpl::SetDelegateForTesting( ChromeCleanerControllerDelegate* delegate) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); delegate_ = delegate ? delegate : real_delegate_.get(); DCHECK(delegate_); } void ChromeCleanerControllerImpl::SetStateForTesting(State state) { state_ = state; if (state_ == State::kIdle) idle_reason_ = IdleReason::kInitial; } // static void ChromeCleanerControllerImpl::ResetInstanceForTesting() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (g_controller) { delete g_controller; g_controller = nullptr; } } void ChromeCleanerControllerImpl::AddObserver(Observer* observer) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); observer_list_.AddObserver(observer); NotifyObserver(observer); } void ChromeCleanerControllerImpl::RemoveObserver(Observer* observer) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); observer_list_.RemoveObserver(observer); } void ChromeCleanerControllerImpl::OnReporterSequenceStarted() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); RecordReporterSequenceTypeHistogram(pending_invocation_type_); if (state() == State::kIdle) SetStateAndNotifyObservers(State::kReporterRunning); } void ChromeCleanerControllerImpl::OnReporterSequenceDone( SwReporterInvocationResult result) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_NE(SwReporterInvocationResult::kUnspecified, result); RecordReporterSequenceResultHistogram(pending_invocation_type_, result); // Ignore if any interaction with cleaner runs is ongoing. This can happen // in two situations: // - The controller is currently handling the cleanup flow (states: infected, // cleaning, reboot required); // - The controller was handling the cleanup flow when the reporter sequence // started, and we didn't transition to the reporter running state. // // That situation can happen, for example, if a new version of the reporter // component becomes available while the controller is handling the cleanup // flow. The UI should block any attempt of starting a new user-initiated scan // if the controller is not on an idle state, which includes when a reporter // sequence is currently running. if (state() != State::kReporterRunning) return; switch (result) { case SwReporterInvocationResult::kNotScheduled: // This can happen if a new periodic reporter run tried to start (for // example, because a new reporter component version became available) and // there is another reporter sequence currently running. // Ignore and wait until the other sequence completes to update state. return; case SwReporterInvocationResult::kTimedOut: case SwReporterInvocationResult::kComponentNotAvailable: case SwReporterInvocationResult::kProcessFailedToLaunch: case SwReporterInvocationResult::kGeneralFailure: idle_reason_ = IdleReason::kReporterFailed; break; case SwReporterInvocationResult::kNothingFound: idle_reason_ = IdleReason::kReporterFoundNothing; break; case SwReporterInvocationResult::kCleanupNotOffered: idle_reason_ = IdleReason::kReporterFoundNothing; break; case SwReporterInvocationResult::kCleanupToBeOffered: // A request to scan will immediately follow this message, so no state // transition will be needed. return; default: NOTREACHED(); } SetStateAndNotifyObservers(State::kIdle); } void ChromeCleanerControllerImpl::OnSwReporterReady( SwReporterInvocationSequence&& invocations) { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!invocations.container().empty()); SwReporterInvocationType invocation_type = SwReporterInvocationType::kPeriodicRun; { base::AutoLock autolock(lock_); // Cache a copy of the invocations. cached_reporter_invocations_ = std::make_unique<SwReporterInvocationSequence>(invocations); std::swap(pending_invocation_type_, invocation_type); } safe_browsing::MaybeStartSwReporter(invocation_type, std::move(invocations)); } void ChromeCleanerControllerImpl::RequestUserInitiatedScan(Profile* profile) { base::AutoLock autolock(lock_); DCHECK(IsAllowedByPolicy()); DCHECK(pending_invocation_type_ != SwReporterInvocationType::kUserInitiatedWithLogsAllowed && pending_invocation_type_ != SwReporterInvocationType::kUserInitiatedWithLogsDisallowed); const bool logs_enabled = this->logs_enabled(profile); RecordScannerLogsAcceptanceHistogram(logs_enabled); SwReporterInvocationType invocation_type = logs_enabled ? SwReporterInvocationType::kUserInitiatedWithLogsAllowed : SwReporterInvocationType::kUserInitiatedWithLogsDisallowed; if (cached_reporter_invocations_) { SwReporterInvocationSequence copied_sequence(*cached_reporter_invocations_); base::PostTaskWithTraits( FROM_HERE, {content::BrowserThread::UI}, base::BindOnce( &safe_browsing::MaybeStartSwReporter, invocation_type, // The invocations will be modified by the |ReporterRunner|. // Give it a copy to keep the cached invocations pristine. base::Passed(&copied_sequence))); RecordOnDemandUpdateRequiredHistogram(false); } else { pending_invocation_type_ = invocation_type; OnReporterSequenceStarted(); // Creation of the |SwReporterOnDemandFetcher| automatically starts fetching // the SwReporter component. |OnSwReporterReady| will be called if the // component is successfully installed. Otherwise, |OnReporterSequenceDone| // will be called. on_demand_sw_reporter_fetcher_ = std::make_unique<component_updater::SwReporterOnDemandFetcher>( g_browser_process->component_updater(), base::BindOnce(&ChromeCleanerController::OnReporterSequenceDone, base::Unretained(this), SwReporterInvocationResult::kComponentNotAvailable)); RecordOnDemandUpdateRequiredHistogram(true); } } void ChromeCleanerControllerImpl::Scan( const SwReporterInvocation& reporter_invocation) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK(IsAllowedByPolicy()); DCHECK(reporter_invocation.BehaviourIsSupported( SwReporterInvocation::BEHAVIOUR_TRIGGER_PROMPT)); if (state() != State::kIdle && state() != State::kReporterRunning) return; DCHECK(!reporter_invocation_); reporter_invocation_ = std::make_unique<SwReporterInvocation>(reporter_invocation); const std::string& reporter_engine = reporter_invocation_->command_line().GetSwitchValueASCII( chrome_cleaner::kEngineSwitch); // Currently, only engine=2 corresponds to a partner-powered engine. This // condition should be updated if other partner-powered engines are added. powered_by_partner_ = !reporter_engine.empty() && reporter_engine == "2"; SetStateAndNotifyObservers(State::kScanning); // base::Unretained is safe because the ChromeCleanerController instance is // guaranteed to outlive the UI thread. delegate_->FetchAndVerifyChromeCleaner(base::BindOnce( &ChromeCleanerControllerImpl::OnChromeCleanerFetchedAndVerified, base::Unretained(this))); } void ChromeCleanerControllerImpl::ReplyWithUserResponse( Profile* profile, extensions::ExtensionService* extension_service, UserResponse user_response) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); if (state() != State::kInfected) return; DCHECK(prompt_user_callback_); PromptAcceptance acceptance = PromptAcceptance::DENIED; State new_state = State::kIdle; switch (user_response) { case UserResponse::kAcceptedWithLogs: acceptance = PromptAcceptance::ACCEPTED_WITH_LOGS; SetLogsEnabled(profile, true); RecordCleanerLogsAcceptanceHistogram(true); new_state = State::kCleaning; delegate_->TagForResetting(profile); extension_service_ = extension_service; break; case UserResponse::kAcceptedWithoutLogs: acceptance = PromptAcceptance::ACCEPTED_WITHOUT_LOGS; SetLogsEnabled(profile, false); RecordCleanerLogsAcceptanceHistogram(false); new_state = State::kCleaning; delegate_->TagForResetting(profile); extension_service_ = extension_service; break; case UserResponse::kDenied: // Fallthrough case UserResponse::kDismissed: acceptance = PromptAcceptance::DENIED; idle_reason_ = IdleReason::kUserDeclinedCleanup; new_state = State::kIdle; break; } base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}) ->PostTask(FROM_HERE, base::BindOnce(std::move(prompt_user_callback_), acceptance)); if (new_state == State::kCleaning) time_cleanup_started_ = base::Time::Now(); // The transition to a new state should happen only after the response has // been posted on the UI thread so that if we transition to the kIdle state, // the response callback is not cleared before it has been posted. SetStateAndNotifyObservers(new_state); } void ChromeCleanerControllerImpl::Reboot() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); if (state() != State::kRebootRequired) return; UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.Cleaner.RebootResponse", true); InitiateReboot(); } bool ChromeCleanerControllerImpl::IsAllowedByPolicy() { return safe_browsing::SwReporterIsAllowedByPolicy(); } bool ChromeCleanerControllerImpl::IsReportingManagedByPolicy(Profile* profile) { // Logs are considered managed if the logs themselves are managed or if the // entire cleanup feature is disabled by policy. PrefService* profile_prefs = profile->GetPrefs(); return !IsAllowedByPolicy() || (profile_prefs && profile_prefs->IsManagedPreference( prefs::kSwReporterReportingEnabled)); } ChromeCleanerControllerImpl::ChromeCleanerControllerImpl() : real_delegate_(std::make_unique<ChromeCleanerControllerDelegate>()), delegate_(real_delegate_.get()), weak_factory_(this) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); } ChromeCleanerControllerImpl::~ChromeCleanerControllerImpl() = default; void ChromeCleanerControllerImpl::NotifyObserver(Observer* observer) const { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); switch (state_) { case State::kIdle: observer->OnIdle(idle_reason_); break; case State::kReporterRunning: observer->OnReporterRunning(); break; case State::kScanning: observer->OnScanning(); break; case State::kInfected: observer->OnInfected(powered_by_partner_, scanner_results_); break; case State::kCleaning: observer->OnCleaning(powered_by_partner_, scanner_results_); break; case State::kRebootRequired: observer->OnRebootRequired(); break; } } void ChromeCleanerControllerImpl::SetStateAndNotifyObservers(State state) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_NE(state_, state); state_ = state; if (state_ == State::kIdle || state_ == State::kRebootRequired) ResetCleanerDataAndInvalidateWeakPtrs(); for (auto& observer : observer_list_) NotifyObserver(&observer); } void ChromeCleanerControllerImpl::ResetCleanerDataAndInvalidateWeakPtrs() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); weak_factory_.InvalidateWeakPtrs(); reporter_invocation_.reset(); prompt_user_callback_.Reset(); } void ChromeCleanerControllerImpl::OnChromeCleanerFetchedAndVerified( base::FilePath executable_path) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_EQ(State::kScanning, state()); DCHECK(reporter_invocation_); if (executable_path.empty()) { idle_reason_ = IdleReason::kCleanerDownloadFailed; SetStateAndNotifyObservers(State::kIdle); RecordPromptNotShownWithReasonHistogram( NO_PROMPT_REASON_CLEANER_DOWNLOAD_FAILED); return; } DCHECK(executable_path.MatchesExtension(FILE_PATH_LITERAL(".exe"))); ChromeCleanerRunner::ChromeMetricsStatus metrics_status = delegate_->IsMetricsAndCrashReportingEnabled() ? ChromeCleanerRunner::ChromeMetricsStatus::kEnabled : ChromeCleanerRunner::ChromeMetricsStatus::kDisabled; ChromeCleanerRunner::RunChromeCleanerAndReplyWithExitCode( extension_service_, executable_path, *reporter_invocation_, metrics_status, base::Bind(&ChromeCleanerControllerImpl::WeakOnPromptUser, weak_factory_.GetWeakPtr()), base::Bind(&ChromeCleanerControllerImpl::OnConnectionClosed, weak_factory_.GetWeakPtr()), base::Bind(&ChromeCleanerControllerImpl::OnCleanerProcessDone, weak_factory_.GetWeakPtr()), // Our callbacks should be dispatched to the UI thread only. base::ThreadTaskRunnerHandle::Get()); time_scanning_started_ = base::Time::Now(); } // static void ChromeCleanerControllerImpl::WeakOnPromptUser( const base::WeakPtr<ChromeCleanerControllerImpl>& controller, ChromeCleanerScannerResults&& scanner_results, ChromePrompt::PromptUserCallback prompt_user_callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // If the weak pointer has been invalidated, the controller is no longer able // to receive callbacks, so respond with PromptAcceptance::Denied immediately. if (!controller) { base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}) ->PostTask(FROM_HERE, base::BindOnce(std::move(prompt_user_callback), PromptAcceptance::DENIED)); } controller->OnPromptUser(std::move(scanner_results), std::move(prompt_user_callback)); } void ChromeCleanerControllerImpl::OnPromptUser( ChromeCleanerScannerResults&& scanner_results, ChromePrompt::PromptUserCallback prompt_user_callback) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_EQ(State::kScanning, state()); DCHECK(scanner_results_.files_to_delete().empty()); DCHECK(scanner_results_.registry_keys().empty()); DCHECK(scanner_results_.extension_ids().empty()); DCHECK(!prompt_user_callback_); DCHECK(!time_scanning_started_.is_null()); UMA_HISTOGRAM_LONG_TIMES_100("SoftwareReporter.Cleaner.ScanningTime", base::Time::Now() - time_scanning_started_); if (scanner_results.files_to_delete().empty()) { base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}) ->PostTask(FROM_HERE, base::BindOnce(std::move(prompt_user_callback), PromptAcceptance::DENIED)); idle_reason_ = IdleReason::kScanningFoundNothing; SetStateAndNotifyObservers(State::kIdle); RecordPromptNotShownWithReasonHistogram(NO_PROMPT_REASON_NOTHING_FOUND); return; } UMA_HISTOGRAM_COUNTS_1000("SoftwareReporter.NumberOfFilesToDelete", scanner_results.files_to_delete().size()); scanner_results_ = std::move(scanner_results); prompt_user_callback_ = std::move(prompt_user_callback); SetStateAndNotifyObservers(State::kInfected); } void ChromeCleanerControllerImpl::OnConnectionClosed() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_NE(State::kIdle, state()); DCHECK_NE(State::kRebootRequired, state()); if (state() == State::kScanning || state() == State::kInfected) { if (state() == State::kScanning) { RecordPromptNotShownWithReasonHistogram( NO_PROMPT_REASON_IPC_CONNECTION_BROKEN); RecordIPCDisconnectedHistogram(IPC_DISCONNECTED_LOST_WHILE_SCANNING); } else { RecordIPCDisconnectedHistogram(IPC_DISCONNECTED_LOST_USER_PROMPTED); } idle_reason_ = IdleReasonWhenConnectionClosedTooSoon(state()); SetStateAndNotifyObservers(State::kIdle); return; } // Nothing to do if OnConnectionClosed() is called in other states: // - This function will not be called in the kIdle and kRebootRequired // states since we invalidate all weak pointers when we enter those states. // - In the kCleaning state, we don't care about the connection to the Chrome // Cleaner process since communication via Mojo is complete and only the // exit code of the process is of any use to us (for deciding whether we // need to reboot). RecordIPCDisconnectedHistogram(IPC_DISCONNECTED_SUCCESS); } void ChromeCleanerControllerImpl::OnCleanerProcessDone( ChromeCleanerRunner::ProcessStatus process_status) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); if (state() == State::kScanning || state() == State::kInfected) { idle_reason_ = IdleReasonWhenConnectionClosedTooSoon(state()); SetStateAndNotifyObservers(State::kIdle); return; } DCHECK_EQ(State::kCleaning, state()); DCHECK_NE(ChromeCleanerRunner::LaunchStatus::kLaunchFailed, process_status.launch_status); if (process_status.launch_status == ChromeCleanerRunner::LaunchStatus::kSuccess) { if (process_status.exit_code == kRebootRequiredExitCode || process_status.exit_code == kRebootNotRequiredExitCode) { DCHECK(!time_cleanup_started_.is_null()); UMA_HISTOGRAM_CUSTOM_TIMES("SoftwareReporter.Cleaner.CleaningTime", base::Time::Now() - time_cleanup_started_, base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(5), 100); } if (process_status.exit_code == kRebootRequiredExitCode) { RecordCleanupResultHistogram(CLEANUP_RESULT_REBOOT_REQUIRED); SetStateAndNotifyObservers(State::kRebootRequired); // Start the reboot prompt flow. delegate_->StartRebootPromptFlow(this); return; } if (process_status.exit_code == kRebootNotRequiredExitCode) { RecordCleanupResultHistogram(CLEANUP_RESULT_SUCCEEDED); delegate_->ResetTaggedProfiles( g_browser_process->profile_manager()->GetLoadedProfiles(), base::DoNothing()); idle_reason_ = IdleReason::kCleaningSucceeded; SetStateAndNotifyObservers(State::kIdle); return; } } RecordCleanupResultHistogram(CLEANUP_RESULT_FAILED); idle_reason_ = IdleReason::kCleaningFailed; SetStateAndNotifyObservers(State::kIdle); } void ChromeCleanerControllerImpl::InitiateReboot() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); installer::ScopedTokenPrivilege scoped_se_shutdown_privilege( SE_SHUTDOWN_NAME); if (!scoped_se_shutdown_privilege.is_enabled() || !::ExitWindowsEx(EWX_REBOOT, SHTDN_REASON_MAJOR_SOFTWARE | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED)) { for (auto& observer : observer_list_) observer.OnRebootFailed(); } } } // namespace safe_browsing
[ "sunny.nam@samsung.com" ]
sunny.nam@samsung.com
811d85a4930d1e4aef25b03a4fc7ed6d27df44b0
3c364f1e3d0af0b650b96b1ac80aedd74940d3fb
/branches/unlabeled-1.1.2/plugins/logger/logconfig.cpp
8ef7a818d2cd1c1733e414711ae1f658824e9f1f
[]
no_license
dhyannataraj/sim-im
aa8e938766f6304d9f71be883f0ef4e10a7c8c65
6b0d058cd5ab06ba72a34f09d44b3f0598960572
refs/heads/master
2021-04-03T04:26:23.903185
2011-10-10T15:58:45
2011-10-10T15:58:45
124,702,761
1
0
null
null
null
null
UTF-8
C++
false
false
2,647
cpp
/*************************************************************************** logconfig.cpp - description ------------------- begin : Sun Mar 17 2002 copyright : (C) 2002 by Vladimir Shutoff email : vovan@shutoff.ru ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "logconfig.h" #include "logger.h" #include <qcheckbox.h> #include <qlayout.h> LogConfig::LogConfig(QWidget *parent, LoggerPlugin *plugin) : LogConfigBase(parent) { m_plugin = plugin; unsigned log_level = plugin->getLogLevel(); chkError->setChecked((log_level & L_ERROR) != 0); chkWarn->setChecked((log_level & L_WARN) != 0); chkDebug->setChecked((log_level & L_DEBUG) != 0); fill(); } void LogConfig::apply() { unsigned log_level = 0; if (chkError->isChecked()) log_level |= L_ERROR; if (chkWarn->isChecked()) log_level |= L_WARN; if (chkDebug->isChecked()) log_level |= L_DEBUG; m_plugin->setLogLevel(log_level); for (BOX_MAP::iterator it = m_boxes.begin(); it != m_boxes.end(); ++it){ m_plugin->setLogType((*it).first, (*it).second->isChecked()); } } void LogConfig::fill() { for (BOX_MAP::iterator it = m_boxes.begin(); it != m_boxes.end(); ++it) delete (*it).second; m_boxes.clear(); QVBoxLayout *lay = static_cast<QVBoxLayout*>(layout()); PacketType *packet; ContactList::PacketIterator it_packet; unsigned pos = 4; while ((packet = ++it_packet) != NULL){ QCheckBox *box = new QCheckBox(i18n(packet->name()), this); lay->insertWidget(pos++, box); box->setChecked(m_plugin->isLogType(packet->id())); m_boxes.insert(BOX_MAP::value_type(packet->id(), box)); } } void *LogConfig::processEvent(Event *e) { if ((e->type() == EventPluginChanged) || (e->type() == EventLanguageChanged)) fill(); return NULL; } #ifndef WIN32 #include "logconfig.moc" #endif
[ "shutoff@f7a67266-ba00-4dfb-90a2-3eec4ba07b7d" ]
shutoff@f7a67266-ba00-4dfb-90a2-3eec4ba07b7d