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
64977b6e8341872e0a727e448679603bfbc81e6e
948f4e13af6b3014582909cc6d762606f2a43365
/testcases/juliet_test_suite/testcases/CWE121_Stack_Based_Buffer_Overflow/s04/CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memmove_33.cpp
9f2fa634d079769d90b228e36b8f269425bf87cb
[]
no_license
junxzm1990/ASAN--
0056a341b8537142e10373c8417f27d7825ad89b
ca96e46422407a55bed4aa551a6ad28ec1eeef4e
refs/heads/master
2022-08-02T15:38:56.286555
2022-06-16T22:19:54
2022-06-16T22:19:54
408,238,453
74
13
null
2022-06-16T22:19:55
2021-09-19T21:14:59
null
UTF-8
C++
false
false
3,120
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memmove_33.cpp Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE805.label.xml Template File: sources-sink-33.tmpl.cpp */ /* * @description * CWE: 121 Stack Based Buffer Overflow * BadSource: Set data pointer to the bad buffer * GoodSource: Set data pointer to the good buffer * Sinks: memmove * BadSink : Copy int64_t array to data using memmove * Flow Variant: 33 Data flow: use of a C++ reference to data within the same function * * */ #include "std_testcase.h" namespace CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memmove_33 { #ifndef OMITBAD void bad() { int64_t * data; int64_t * &dataRef = data; int64_t * dataBadBuffer = (int64_t *)ALLOCA(50*sizeof(int64_t)); int64_t * dataGoodBuffer = (int64_t *)ALLOCA(100*sizeof(int64_t)); /* FLAW: Set a pointer to a "small" buffer. This buffer will be used in the sinks as a destination * buffer in various memory copying functions using a "large" source buffer. */ data = dataBadBuffer; { int64_t * data = dataRef; { int64_t source[100] = {0}; /* fill with 0's */ /* POTENTIAL FLAW: Possible buffer overflow if data < 100 */ memmove(data, source, 100*sizeof(int64_t)); printLongLongLine(data[0]); } } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ static void goodG2B() { int64_t * data; int64_t * &dataRef = data; int64_t * dataBadBuffer = (int64_t *)ALLOCA(50*sizeof(int64_t)); int64_t * dataGoodBuffer = (int64_t *)ALLOCA(100*sizeof(int64_t)); /* FIX: Set a pointer to a "large" buffer, thus avoiding buffer overflows in the sinks. */ data = dataGoodBuffer; { int64_t * data = dataRef; { int64_t source[100] = {0}; /* fill with 0's */ /* POTENTIAL FLAW: Possible buffer overflow if data < 100 */ memmove(data, source, 100*sizeof(int64_t)); printLongLongLine(data[0]); } } } void good() { goodG2B(); } #endif /* OMITGOOD */ } /* close namespace */ /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memmove_33; /* so that we can use good and bad easily */ int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
[ "yzhang0701@gmail.com" ]
yzhang0701@gmail.com
cb4848875cbf2117831b3be63921c8f02a813570
1cba40be0095359b6ea74c8bb4c9562371bc0316
/Baekjoon/16120. PPAP.cpp
e70bed3b5793a56a8c36e13b84d0c6d07b36761f
[]
no_license
dgandrewc/leetcode
4934b7700c4e8b6bce5be2ae2232794a03d0e00b
00c834222e16dd4e57e5ac11bb438a2ecec99375
refs/heads/main
2023-06-09T17:05:03.329571
2021-07-05T03:45:02
2021-07-05T03:45:02
357,297,233
0
0
null
null
null
null
UTF-8
C++
false
false
398
cpp
#include<iostream> using namespace std; int main(void) { string str; cin >> str; int cnt=0; for(int i=0; i<str.size(); i++) { if(str[i]=='P') cnt++; else if(str[i]=='A') { if(cnt>=2 && str[i+1]=='P') { cnt--; i++; } else { cout << "NP" << endl; return 0; } } } if(cnt==1) cout << "PPAP" << endl; else cout << "NP" << endl; return 0; }
[ "dgandrewc@gmail.com" ]
dgandrewc@gmail.com
466f0f32cd90174ac493eb638b6c4f961861c225
8f11b828a75180161963f082a772e410ad1d95c6
/packages/vehicle/include/device/ICurrentProvider.h
82f2861e26b79d8d4273c4b983be86febec315d8
[]
no_license
venkatarajasekhar/tortuga
c0d61703d90a6f4e84d57f6750c01786ad21d214
f6336fb4d58b11ddfda62ce114097703340e9abd
refs/heads/master
2020-12-25T23:57:25.036347
2017-02-17T05:01:47
2017-02-17T05:01:47
43,284,285
0
0
null
2017-02-17T05:01:48
2015-09-28T06:39:21
C++
UTF-8
C++
false
false
905
h
/* * Copyright (C) 2008 Robotics at Maryland * Copyright (C) 2008 Joseph Lisee <jlisee@umd.edu> * All rights reserved. * * Author: Joseph Lisee <jlisee@umd.edu> * File: packages/vision/include/device/ICurrentProvider.h */ #ifndef RAM_VEHICLE_DEVICE_ICURRENTPROVIDER_06_15_2008 #define RAM_VEHICLE_DEVICE_ICURRENTPROVIDER_06_15_2008 // STD Includesb #include <string> // Project Includes #include "vehicle/include/device/IDevice.h" // Must Be Included last #include "vehicle/include/Export.h" namespace ram { namespace vehicle { namespace device { class RAM_EXPORT ICurrentProvider { public: /** Fired when the voltage updates */ static const core::Event::EventType UPDATE; virtual ~ICurrentProvider(); virtual double getCurrent() = 0; }; } // namespace device } // namespace vehicle } // namespace ram #endif // RAM_VEHICLE_DEVICE_ICURRENTPROVIDER_06_15_2008
[ "jlisee@gmail.com" ]
jlisee@gmail.com
85a6b41dfb9c2b2328bb79cb593adef77db5dace
1864d6be0f28eea17d097aa94fb0a8f955fa21f3
/Screen/Math/src/screen/math/Radian.cpp
f3dba22033d2df1787dd7192a26f05e3623e0610
[]
no_license
sivarajankumar/screen3d
a1fd17011248da213fc53be5544fe4e7bcda2906
7c7fb5469f80ec8bbcd7202fc1913bb66bd21e49
refs/heads/master
2021-01-10T03:19:13.368011
2012-11-04T12:44:29
2012-11-04T12:44:29
49,218,449
0
0
null
null
null
null
UTF-8
C++
false
false
3,250
cpp
/***************************************************************************** * This source file is part of SCREEN (SCalable REndering ENgine) * * * * Copyright (c) 2008-2012 Ratouit Thomas * * * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 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 Lesser * * General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program; if not, write to the Free Software Foundation, * * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to * * http://www.gnu.org/copyleft/lesser.txt. * *****************************************************************************/ /** * \file Radian.cpp * \brief The class used to represent the Radian unit * \author pjdemaret * * This class is used to represent the radian unit used for angles representation. */ // Math includes #include <screen/math/Radian.h> #include <screen/math/Degree.h> // Utils include #include <screen/utils/Constants.h> namespace screen { using namespace utils; namespace math { Radian::Radian ( const Degree& iDegree ) : _value(iDegree.getRadianValue()){ SCREEN_DECL_CONSTRUCTOR(Radian); } inline Radian& Radian::operator = ( const Degree& iDegree ){ SCREEN_DECL_METHOD(operator =); _value = iDegree.getRadianValue(); return *this; } float Radian::getDegreeValue() const{ SCREEN_DECL_METHOD(getDegreeValue); return Radian::ToDegree(_value); } inline Radian Radian::operator + ( const Degree& iDegree ) const{ SCREEN_DECL_METHOD(operator +); return Radian( _value + iDegree.getRadianValue()); } inline Radian& Radian::operator += ( const Degree& iDegree ){ SCREEN_DECL_METHOD(operator +=); _value += iDegree.getRadianValue(); return *this; } inline Radian Radian::operator - ( const Degree& iDegree ) const{ SCREEN_DECL_METHOD(operator -); return Radian( _value + iDegree.getRadianValue()); } inline Radian& Radian::operator -= ( const Degree& iDegree ){ SCREEN_DECL_METHOD(operator -=); _value -= iDegree.getRadianValue(); return *this; } inline float Radian::ToDegree(const float iRadian) { SCREEN_DECL_METHOD(ToDegree); return iRadian / Pi * 180; } } }
[ "pjdemaret@df6f4744-0210-11df-9fb0-db4daf2f83fa" ]
pjdemaret@df6f4744-0210-11df-9fb0-db4daf2f83fa
dbf63e82da9b071b46608600d3b1a1f7bf7f26a8
e61a6e786c840ffea6bd0ad43b3f4907b050e001
/src/help/TextEdit.cpp
22df6af9bec05e11416d7f87ab60bd9c5f2805c8
[ "LicenseRef-scancode-public-domain" ]
permissive
kaiyuzhao/XmdvTool
7888919d30e6b3b52eb4a6759b254d60ff64bb22
d0be8511e1577995220a18e0bdbae601cd95727a
refs/heads/master
2021-09-28T10:27:58.532772
2021-09-24T03:30:35
2021-09-24T03:30:35
43,215,167
11
5
null
2021-09-24T03:30:36
2015-09-26T17:22:40
C++
UTF-8
C++
false
false
2,925
cpp
/* * textedit.cpp * * Created on: Feb 1, 2010 * Author: mukherab */ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <QtCore/QFileInfo> #include <QtCore/QFile> #include "help/TextEdit.h" TextEdit::TextEdit(QWidget *parent) : QTextEdit(parent) { setReadOnly(true); } void TextEdit::setContents(const QString &fileName) { QFileInfo fi(fileName); srcUrl = QUrl::fromLocalFile(fi.absoluteFilePath()); QFile file(fileName); if (file.open(QIODevice::ReadOnly)) { QString data(file.readAll()); if (fileName.endsWith(".html")) setHtml(data); else setPlainText(data); } } QVariant TextEdit::loadResource(int type, const QUrl &name) { if (type == QTextDocument::ImageResource) { QFile file(srcUrl.resolved(name).toLocalFile()); if (file.open(QIODevice::ReadOnly)) return file.readAll(); } return QTextEdit::loadResource(type, name); }
[ "kaiyu@dato.com" ]
kaiyu@dato.com
132871645892e9c4c23a5b1dde91338fcc95cd4b
eda023fde0fb2a48a66a6290875cc98179322c81
/Engine/Graphics/Texture.cpp
310b0faf1afec26e7a2e740b5803d08da5fa6b5e
[ "X11" ]
permissive
i0r/huisclos
58ca628b59c776abc406214e90a882064c05b759
930c641ab64f1deff4c15a6e1617fc596cf8118f
refs/heads/master
2020-05-02T06:32:26.090264
2019-03-26T13:50:32
2019-03-26T13:50:32
79,543,414
0
0
null
null
null
null
UTF-8
C++
false
false
1,201
cpp
#include "Shared.h" #include "RenderContext.h" #include "Texture.h" #include <d3d11.h> #include <Engine/ThirdParty/DirectXTK/Inc/DDSTextureLoader.h> texture_t* TextureManager::GetTexture( const renderContext_t* context, const char* texPath ) { const uint64_t texHashcode = MurmurHash64A( texPath, static_cast<int>( strlen( texPath ) ), 0xB ); auto it = content.find( texHashcode ); if ( it != content.end() ) { return it->second.get(); } content[texHashcode] = std::make_unique<texture_t>(); static wchar_t widePath[MAX_PATH]{ '\0' }; // because Microsoft std::size_t wideConvertedLength = 0; mbstowcs_s( &wideConvertedLength, widePath, texPath, MAX_PATH ); const HRESULT texLoadResult = DirectX::CreateDDSTextureFromFile( context->device, widePath, &content[texHashcode]->ressource, &content[texHashcode]->view ); if ( texLoadResult != S_OK ) { content.erase( texHashcode ); // TODO: log stuff return nullptr; } return content[texHashcode].get(); } void Render_ClearTargetColor( ID3D11DeviceContext* context, const renderTarget_t* rt ) { static constexpr FLOAT CLEAR_COLOR[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; context->ClearRenderTargetView( rt->view, CLEAR_COLOR ); }
[ "baptiste.prevost@protonmail.com" ]
baptiste.prevost@protonmail.com
9947f81547eecf2b31b56ac37e698bc9f42d7a9a
bd8d279e9c97d5dbc978fa8345235a33c006fc97
/samples/DateTime/src/DialogApp.h
fd5cfeeb87c84d9e216dc01f2c57848637fdde0b
[]
no_license
the-reverend/Win32xx
d2b3ec040df4ed594fe0ec648b394f49b2258b2e
3a6bd55fc7f0f8f0d24133cbeb9ce9226efe554f
refs/heads/master
2016-09-12T13:49:48.392542
2016-04-17T03:22:30
2016-04-17T03:22:30
56,416,919
0
0
null
null
null
null
UTF-8
C++
false
false
518
h
/////////////////////////////////////// // DialogApp.h #ifndef DIALOGAPP_H #define DIALOGAPP_H #include "MyDialog.h" // Declaration of the CDialogApp class class CDialogApp : public CWinApp { public: CDialogApp(); virtual ~CDialogApp(); virtual BOOL InitInstance(); CMyDialog& GetDialog() {return m_MyDialog;} private: CMyDialog m_MyDialog; }; // returns a reference to the CDialogApp object inline CDialogApp& GetDialogApp() { return static_cast<CDialogApp&>(GetApp()); } #endif // define DIALOGAPP_H
[ "ronaldpwilson@gmail.com" ]
ronaldpwilson@gmail.com
68277284bbfdbb2289a5b78bbc5189577e4a34e5
9d0e1d990e309d6e3a2c7e38d2898e146bc756d3
/tree/check_identical.cpp
9b221ddce9c1a67e45125ec89e3fdf1b019fa91f
[]
no_license
Cyatrosi/DSAlgo
be981b56692d0fe99af1b6bc7e86bc0ee426760a
5c02780c5236e036e769809b3c8e68db2ef35a1f
refs/heads/master
2020-03-12T08:55:25.297949
2018-04-25T18:30:24
2018-04-25T18:30:24
130,502,551
1
0
null
null
null
null
UTF-8
C++
false
false
1,567
cpp
#include<bits/stdc++.h> using namespace std; struct node { int key; struct node *left,*right; }; struct node *newnode(int key) { struct node *temp = new node; temp->key = key; temp->left = temp->right = NULL; return temp; } node *addnode(node *root,int key) { if(root == NULL) return newnode(key); if(key<root->key) root->left = addnode(root->left,key); else root->right = addnode(root->right,key); return root; } void display(node* root ,int style) { if(root == NULL) return; if(style<0) cout<<root->key<<" "; display(root->left,style); if(style==0) cout<<root->key<<" "; display(root->right,style); if(style>0) cout<<root->key<<" "; } bool identical(node *root_a,node *root_b) { if(root_a == NULL && root_b == NULL) return true; if(root_a == NULL || root_b == NULL) return false; if(root_a->key != root_b->key) return false; return identical(root_a->left,root_b->left) && identical(root_a->right,root_b->right); } int main() { node *root = NULL; root = addnode(root,4); root = addnode(root,2); root = addnode(root,1); root = addnode(root,3); root = addnode(root,6); root = addnode(root,5); root = addnode(root,7); node *root_n = NULL; root_n = addnode(root_n,4); root_n = addnode(root_n,2); root_n = addnode(root_n,1); root_n = addnode(root_n,3); root_n = addnode(root_n,6); root_n = addnode(root_n,5); root_n = addnode(root_n,7); display(root,1); cout<<endl; display(root_n,0); cout<<endl; cout<<identical(root,root_n); return 0; }
[ "nileshsaxena23@gmail.com" ]
nileshsaxena23@gmail.com
90c36e33b07345cab3f3819edfbf1c4970963e87
812067c42686dffa054e1e8bd54e5d48aa4bb161
/116.populating-next-right-pointers-in-each-node/populating-next-right-pointers-in-each-node.cpp
620640841d980677a5c552c817e27d101a00b534
[]
no_license
spacefan/Leetcode
35873bef37fad4ce8d7611482879706f9e9cd54c
344e181544a7347f3b208dd98712cce0b73f9f94
refs/heads/master
2020-03-22T04:04:44.278754
2017-05-14T06:10:33
2017-05-14T06:10:33
139,471,573
0
1
null
2018-07-02T17:08:14
2018-07-02T17:08:14
null
UTF-8
C++
false
false
596
cpp
/** * Definition for binary tree with next pointer. * struct TreeLinkNode { * int val; * TreeLinkNode *left, *right, *next; * TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {} * }; */ class Solution { public: void connect(TreeLinkNode *root) { if(!root) return ; if(root->left) { root->left->next=root->right; connect(root->left); } if(root->right) { if(root->next) root->right->next=root->next->left; connect(root->right); } } };
[ "huangjipengnju@gmail.com" ]
huangjipengnju@gmail.com
cfe7893df2547f11728660daf4edf13563d35e4d
a4f888f4af89da2bb3777c06163cd19ffa6988c1
/test/Src/Utility/Collision.cpp
aae196028b504e844d6d3681edbaf7a8032e048b
[]
no_license
siryuu0725/peapro
f27c6b53ec3bb4a4176620094797b07f7f120eee
ad42fe58b7cd33fab4bc012784a87b9a0ac8967d
refs/heads/master
2022-10-12T04:05:18.529069
2020-06-08T09:43:58
2020-06-08T09:43:58
270,561,220
0
0
null
null
null
null
UTF-8
C++
false
false
1,166
cpp
#include "Collision.h" bool Collision::CircleHit(D3DXVECTOR2 posA_, D3DXVECTOR2 posB_, float radiusA, float radiusB) { float a = posA_.x - posB_.x; float b = posA_.y - posB_.y; float c = sqrt(a * a + b + b); if (c <= radiusA + radiusB) { return true; } else return false; } bool Collision::OugiHit(D3DXVECTOR2 posA_, D3DXVECTOR2 posB_, float ougi_radius, float radian, float cosradian) { posB_.x = posB_.x + 25.0f; posB_.y = posB_.y + 25.0f; D3DXVECTOR2 vec = posA_ - posB_; float lenght = sqrtf((vec.x * vec.x) + (vec.y * vec.y)); D3DXVECTOR2 nor_vec; nor_vec.x = vec.x / lenght; nor_vec.y = vec.y / lenght; D3DXVECTOR2 ougivec1 = D3DXVECTOR2(1.0f, 0.0f); D3DXVECTOR2 ougivec2; ougivec2.x = ougivec1.x * cosf(D3DXToRadian(radian)) - ougivec1.y * sinf(D3DXToRadian(radian)); ougivec2.y = ougivec1.x * sinf(D3DXToRadian(radian)) + ougivec1.y * cosf(D3DXToRadian(radian)); float dot = (ougivec2.x * nor_vec.x) + (ougivec2.y * nor_vec.y); float ougi_cos = cosf(D3DXToRadian(cosradian) / 2); if (lenght <= ougi_radius) { if (ougi_cos > dot) { return true; } else { return false; } } else { return false; } }
[ "siryu725@gmail.com" ]
siryu725@gmail.com
9bc6ed1934bfc443303bae8a34087fb61d0558dc
1942a0d16bd48962e72aa21fad8d034fa9521a6c
/aws-cpp-sdk-organizations/source/model/ActionType.cpp
6dfbe217a3cd5f14ab69215540f44eccd24d10d5
[ "Apache-2.0", "JSON", "MIT" ]
permissive
yecol/aws-sdk-cpp
1aff09a21cfe618e272c2c06d358cfa0fb07cecf
0b1ea31e593d23b5db49ee39d0a11e5b98ab991e
refs/heads/master
2021-01-20T02:53:53.557861
2018-02-11T11:14:58
2018-02-11T11:14:58
83,822,910
0
1
null
2017-03-03T17:17:00
2017-03-03T17:17:00
null
UTF-8
C++
false
false
2,778
cpp
/* * Copyright 2010-2016 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/organizations/model/ActionType.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 Organizations { namespace Model { namespace ActionTypeMapper { static const int INVITE_HASH = HashingUtils::HashString("INVITE"); static const int ENABLE_ALL_FEATURES_HASH = HashingUtils::HashString("ENABLE_ALL_FEATURES"); static const int APPROVE_ALL_FEATURES_HASH = HashingUtils::HashString("APPROVE_ALL_FEATURES"); ActionType GetActionTypeForName(const Aws::String& name) { int hashCode = HashingUtils::HashString(name.c_str()); if (hashCode == INVITE_HASH) { return ActionType::INVITE; } else if (hashCode == ENABLE_ALL_FEATURES_HASH) { return ActionType::ENABLE_ALL_FEATURES; } else if (hashCode == APPROVE_ALL_FEATURES_HASH) { return ActionType::APPROVE_ALL_FEATURES; } EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); if(overflowContainer) { overflowContainer->StoreOverflow(hashCode, name); return static_cast<ActionType>(hashCode); } return ActionType::NOT_SET; } Aws::String GetNameForActionType(ActionType enumValue) { switch(enumValue) { case ActionType::INVITE: return "INVITE"; case ActionType::ENABLE_ALL_FEATURES: return "ENABLE_ALL_FEATURES"; case ActionType::APPROVE_ALL_FEATURES: return "APPROVE_ALL_FEATURES"; default: EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); if(overflowContainer) { return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); } return ""; } } } // namespace ActionTypeMapper } // namespace Model } // namespace Organizations } // namespace Aws
[ "henso@amazon.com" ]
henso@amazon.com
824e64518c59520b8a50d5de5a9746967377cde0
84e8de770bbb9955c809a2b3a327484c9bd9c023
/class_obj.cpp
9c4bcf1a66cd5ab9b662703deb1d38ed8e0d1d5f
[]
no_license
ShohrabRustam/CPP-Object-Oriented-
432d6648255decc19d333bf6ad18e635b6b13306
13d77aa0be2dce17525d88f6c6656dabb6b56ea6
refs/heads/master
2023-08-16T22:28:53.429382
2021-10-09T08:21:10
2021-10-09T08:21:10
415,247,538
0
0
null
null
null
null
UTF-8
C++
false
false
821
cpp
#include <iostream> using namespace std; class Room { private: double length; double breadth; double height; public: // function to initialize private variables void getData(double len, double brth, double hgt) { length = len; breadth = brth; height = hgt; } double calculateArea() { return length * breadth; } double calculateVolume() { return length * breadth * height; } }; int main() { // create object of Room class Room room1; // pass the values of private variables as arguments room1.getData(42.5, 30.8, 19.2); cout << "Area of Room = " << room1.calculateArea() << endl; cout << "Volume of Room = " << room1.calculateVolume() << endl; return 0; }
[ "mohdrustam001@gmail.com" ]
mohdrustam001@gmail.com
45c2b80de6ba3657ac258032db89449fae5b1e50
2d45c865218d8e37f329fe3105212fb7045e8e19
/src/Graphics/Rectangle.h
809da8476a5fdcebbc10f65b56a1a14438f2209d
[]
no_license
stereotype13/VREngine
18120a392fd705fc514aac408d169dfbb6f4e8d1
29ec43c977da10177ddad6153a11104dc0c0f872
refs/heads/master
2021-05-16T01:56:45.445874
2016-12-09T23:42:30
2016-12-09T23:42:30
75,885,018
0
0
null
null
null
null
UTF-8
C++
false
false
254
h
#pragma once #include "Renderable.h" #include "..\Math\vec4.h" namespace VR { namespace core { class Rectangle : public Renderable { public: Rectangle(GLfloat x, GLfloat y, GLfloat width, GLfloat height, const VR::math::vec4& color); }; } }
[ "stereotype13@hotmail.com" ]
stereotype13@hotmail.com
4ccaf57f1ce13908637e274a61dc0328af9222ea
fd7208dff242a8d2506b9929d7000c87c618fb1d
/Programmers/Programmers_12902.cpp
74114943184ffe62ec158c6bcd52c9fc0bac2e7f
[]
no_license
Jungdahee/Problem_Solving
2d2b9cef3b3125279da32135c2d285424481a51c
b1b39b578b8198e9ac07bf9daca5e8c186747736
refs/heads/master
2020-08-30T03:22:51.773237
2019-12-14T14:50:54
2019-12-14T14:50:54
218,247,453
0
0
null
null
null
null
UTF-8
C++
false
false
549
cpp
#include <string> #include <vector> #include <iostream> using namespace std; int solution(int n) { // 3 * n 타일링 - success vector<long long> number(n + 1, 0); number[0] = 1; number[2] = 3; for(int i = 4; i <= n; i += 2){ //이전 값에 *3 수행 시 이전 타일을 그대로 사용했을 시 경우의 수 계산 가능 number[i] += (number[i - 2] * 3) % 1000000007; for(int j = 0; j <= i - 4; j += 2) number[i] += (number[j] * 2) % 1000000007; } return number[n] % 1000000007; }
[ "jungdahee010@naver.com" ]
jungdahee010@naver.com
fb068d3f3249480fdcb5faac1558e3babb78324b
7fa6aa899c62125789da0368c3cbd514cd7def10
/PagedLOD/Tests/UnitTests/TestCase_2003/test.cpp
75ba4a2fde404a2d97cb87d16fa5326b4ec21e87
[]
no_license
xiaoqiye/RFPagedLOD
f78e72d537319101063980a98b675eec13f37b32
aa0eefe17955cef5144874612d0d37f34b2f21fc
refs/heads/master
2022-11-21T20:18:59.908851
2020-07-26T12:21:31
2020-07-26T12:21:31
255,565,532
0
0
null
null
null
null
UTF-8
C++
false
false
2,513
cpp
#include "pch.h" #include "MockData.h" const std::string LODTREE_FOLDER_PATH = "H:\\PagedLOD_Resource\\Chengdu\\SerializedData\\"; const std::string BIN_FOLDER_PATH = "H:\\PagedLOD_Resource\\Chengdu\\BinData\\"; TEST(TestRenderingTileNodeGeneratorKernal, TestWork) { auto pPipelineP2R = std::make_shared<hivePagedLOD::CPipelinePreferred2RenderingTileNodeGenerator>(); pPipelineP2R->initInputBuffer(); pPipelineP2R->initOutputBuffer(); auto pPipelineM2R = std::make_shared<hivePagedLOD::CPipelineMemoryBufferManager2RenderingTileNodeGenerator>(); pPipelineM2R->initInputBuffer(); pPipelineM2R->initOutputBuffer(); auto pPipelineR2M = std::make_shared<hivePagedLOD::CPipelineRenderingTileNodeGenerator2MemoryBufferManager>(); pPipelineR2M->initInputBuffer(); pPipelineR2M->initOutputBuffer(); hivePagedLOD::RenderingTileNodeGenerator Kernal(pPipelineP2R, pPipelineM2R, pPipelineR2M); auto PreferredTileNodeSet = MockData::getPreferredTileNodeSet(); pPipelineP2R->tryPush(PreferredTileNodeSet); std::vector<std::vector<std::shared_ptr<CTileNode>>> OutputBufferResult0; pPipelineP2R->tryPop(OutputBufferResult0); std::vector<std::vector<std::shared_ptr<CTileNode>>> RenderingTileNodeSet; auto LoadCostMap = MockData::getTileNodeLoadCostMap(); LoadCostMap["1.bin"].GeoInMemory = true; LoadCostMap["1.bin"].TexInMemory = true; LoadCostMap["1.bin"].LoadCost = 0; LoadCostMap["3.bin"].GeoInMemory = true; LoadCostMap["3.bin"].TexInMemory = true; LoadCostMap["3.bin"].LoadCost = 0; LoadCostMap["5.bin"].GeoInMemory = true; LoadCostMap["5.bin"].TexInMemory = true; LoadCostMap["5.bin"].LoadCost = 0; LoadCostMap["6.bin"].GeoInMemory = true; LoadCostMap["6.bin"].TexInMemory = true; LoadCostMap["6.bin"].LoadCost = 0; Kernal.setLoadCostMap(LoadCostMap); Kernal.setMaxLoadPerFrame(1000); Kernal.generateRenderingTileNodeByStrategy(hivePagedLOD::EStrategy::xxx, OutputBufferResult0, RenderingTileNodeSet); EXPECT_EQ(RenderingTileNodeSet.size(), 1); EXPECT_EQ(RenderingTileNodeSet[0].size(), 3); EXPECT_EQ(RenderingTileNodeSet[0][0]->getGeometryFileName(), "4.bin"); pPipelineR2M->tryPush(RenderingTileNodeSet); auto UpdateDataSet = MockData::getUpdateDataSet(); Kernal.updateTileNodeLoadCostTable(UpdateDataSet); auto NewMap = Kernal.getLoadCostMap(); EXPECT_FALSE(["1.bin"].GeoInMemory); EXPECT_FALSE(["1.bin"].TexInMemory); EXPECT_EQ(["1.bin"].LoadCost, 200); EXPECT_TRUE(["4.bin"].GeoInMemory); EXPECT_TRUE(["4.bin"].TexInMemory); EXPECT_EQ(["4.bin"].LoadCost, 0); }
[ "806707499@qq.com" ]
806707499@qq.com
98ecd3d05c6a6c275d24c3c648880b2878551703
31475b58b676a174d89b3130f869656366dc3078
/fm_physics_bullet/bullet/bullet_collision/collision_dispatch/bt_sphere_sphere_collision_algorithm.h
8c7adfbe5b246b1c086354531747acd89e82113a
[]
no_license
cooper-zhzhang/engine
ed694d15b5d065d990828e43e499de9fa141fc47
b19b45316220fae2a1d00052297957268c415045
refs/heads/master
2021-06-21T07:09:37.355174
2017-07-18T14:51:45
2017-07-18T14:51:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,054
h
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H #define BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H #include "bt_activating_collision_algorithm.h" #include "bullet_collision/broadphase_collision/bt_broadphase_proxy.h" #include "bullet_collision/collision_dispatch/bt_collision_create_func.h" #include "bt_collision_dispatcher.h" class btPersistentManifold; /// btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection. /// Other features are frame-coherency (persistent data) and collision response. /// Also provides the most basic sample for custom/user btCollisionAlgorithm class btSphereSphereCollisionAlgorithm : public btActivatingCollisionAlgorithm { bool m_ownManifold; btPersistentManifold* m_manifoldPtr; public: btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* col0Wrap,const btCollisionObjectWrapper* col1Wrap); btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) : btActivatingCollisionAlgorithm(ci) {} virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); virtual void getAllContactManifolds(btManifoldArray& manifoldArray) { if (m_manifoldPtr && m_ownManifold) { manifoldArray.push_back(m_manifoldPtr); } } virtual ~btSphereSphereCollisionAlgorithm(); struct CreateFunc :public btCollisionAlgorithmCreateFunc { virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* col0Wrap,const btCollisionObjectWrapper* col1Wrap) { void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereSphereCollisionAlgorithm)); return new(mem) btSphereSphereCollisionAlgorithm(0,ci,col0Wrap,col1Wrap); } }; }; #endif //BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H
[ "1542971595@qq.com" ]
1542971595@qq.com
001d5cb309ff34c7eb7cda1ef53073ae7b5656d5
588af4de7d99da2312a97e0c48b8332c366eeb31
/src/MakerMatty_Button.h
367a1195b0f02c0b304d0df88c7688fae7ef27b2
[ "MIT" ]
permissive
immakermatty/MakerMatty_Button
1a894b3a365777ae4c8edb2bca69c9c61c9775e1
d5a228d86518f8d1df8361518ba4b08a1474caad
refs/heads/master
2022-12-20T07:27:34.123667
2020-10-05T15:12:08
2020-10-05T15:12:08
272,677,234
0
0
null
null
null
null
UTF-8
C++
false
false
891
h
/** * Author : @makermatty (www.maker.matejsuchanek.cz) * Date : 16-6-2020 */ #ifndef _MM_BUTTON_h #define _MM_BUTTON_h #include <Arduino.h> #include <Bounce2.h> /* Use this defines before including the library for changin the wiring of the buttons */ // #define BUTTONS_INTERNAL_PULLUP_WIRED // #define BUTTONS_PULLDOWN_WIRED #if !defined(BUTTONS_INTERNAL_PULLUP_WIRED) && !defined(BUTTONS_PULLDOWN_WIRED) #define BUTTONS_INTERNAL_PULLUP_WIRED #elif defined(BUTTONS_INTERNAL_PULLUP_WIRED) && defined(BUTTONS_PULLDOWN_WIRED) #error Buttons must be wired all the same. #endif #define DEFAULT_BUTTON_DEBOUNCE_MS 10 class Button { public: Button(int pinNum, int debaunceInterval = DEFAULT_BUTTON_DEBOUNCE_MS); void update(); bool read(); bool pressed(); bool released(); private: const int interval; Bounce debouncer; int pin; }; typedef Button MakerMatty_Button; #endif
[ "kkartk322@gmail.com" ]
kkartk322@gmail.com
b187997f2d544611e150c97e72fa3be25c6604f4
8e8aa2932ec737f2ec55edacaa944ff2be4b02d3
/Algorithms/DuplicatesInVector.cpp
58627a14d0812eb48f4b3d6a06c0902d63a3579a
[ "MIT" ]
permissive
Nemanja92/Algorithms
76e0c631673188ebf9526d5dec9c2a852a790674
9f5e3913b8c343732f6fceabf14aea02e9094c6c
refs/heads/master
2021-06-28T01:19:23.277194
2021-04-06T02:24:15
2021-04-06T02:24:15
216,981,590
1
0
null
null
null
null
UTF-8
C++
false
false
658
cpp
// // DuplicatesInVector.cpp // Algorithms // // Created by Nemanja Ignjatovic on 11/27/19. // Copyright © 2019 Nemanja Ignjatovic. All rights reserved. // #include "Algorithms.hpp" /* Time Complexity: O(n) Auxiliary Space: O(1) */ void findDuplicatesInVectorHashing(vector<int> arr) { map<int, int> hashMap; for (int i = 0; i<arr.size(); i++) { hashMap[arr[i]]++; } for ( const auto &p : hashMap ) { // print only if p.second (value) is gretaer then 1, meaning it is a duplicate if (p.second > 1) { printf("%d is appearing %d times\n",p.first,p.second); } } }
[ "nemanja92@icloud.com" ]
nemanja92@icloud.com
ebf9f336b4560087b97dd186f9d0866032f4775e
0c4bd1b977cc714a8a6b2839f51c4247ecfd32b1
/C++/nnForge/nnforge/reshape_data_transformer.cpp
1663f875fabd64c21074912efa06062a37feb53e
[ "Apache-2.0" ]
permissive
ishine/neuralLOGIC
281d498b40159308815cee6327e6cf79c9426b16
3eb3b9980e7f7a7d87a77ef40b1794fb5137c459
refs/heads/master
2020-08-14T14:11:54.487922
2019-10-14T05:32:53
2019-10-14T05:32:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,900
cpp
/* * Copyright 2011-2016 Maxim Milakov * * 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 "reshape_data_transformer.h" #include "neural_network_exception.h" #include <boost/format.hpp> #include <cstring> namespace nnforge { reshape_data_transformer::reshape_data_transformer(const layer_configuration_specific& config) : config(config) { } void reshape_data_transformer::transform( const float * data, float * data_transformed, const layer_configuration_specific& original_config, unsigned int sample_id) { if (original_config.get_neuron_count() != config.get_neuron_count()) throw neural_network_exception((boost::format("Neuron counts for reshape_data_transformer don't match: %1% and %2%") % original_config.get_neuron_count() % config.get_neuron_count()).str()); memcpy(data_transformed, data, original_config.get_neuron_count() * sizeof(float)); } layer_configuration_specific reshape_data_transformer::get_transformed_configuration(const layer_configuration_specific& original_config) const { if (original_config.get_neuron_count() != config.get_neuron_count()) throw neural_network_exception((boost::format("Neuron counts for reshape_data_transformer don't match: %1% and %2%") % original_config.get_neuron_count() % config.get_neuron_count()).str()); return config; } }
[ "the.new.horizon@outlook.com" ]
the.new.horizon@outlook.com
2f5281692050428e7b4bec81955b0c1ea9573cd7
09cbd3eb63b290115682c72d529087ae0a56fc71
/runtime/mem/frame_allocator.h
17ae23e8d06d1ecda22ec63833de2393cb797697
[ "Apache-2.0" ]
permissive
openharmony-gitee-mirror/ark_runtime_core
ac3c512a58fd6b52315da0c6f099edf827cd88e6
2e6f195caf482dc9607efda7cfb5cc5f98da5598
refs/heads/master
2022-07-28T07:38:29.271322
2021-11-25T11:45:47
2021-11-25T11:45:47
410,627,949
0
0
null
null
null
null
UTF-8
C++
false
false
5,332
h
/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef PANDA_RUNTIME_MEM_FRAME_ALLOCATOR_H_ #define PANDA_RUNTIME_MEM_FRAME_ALLOCATOR_H_ #include <securec.h> #include <array> #include "libpandabase/mem/arena.h" #include "libpandabase/mem/mem.h" #include "libpandabase/mem/mmap_mem_pool-inl.h" namespace panda::mem { // Allocation flow looks like that: // // Allocate arenas for frames Frames free Return arenas Second allocated arena // (stage 1) (stage 2) (stage 3) will be bigger than the // second at stage 1 // |-----| |-----| |-----| // | | | | | | // |-----| | | |-----| | | | | // |xxxxx| | | | | | | | | // |-----| |xxxxx| |xxxxx| |-----| | | | | |-----| |-----| | | // |xxxxx| |xxxxx| |xxxxx| ----> | | | | | | ----> | | ----> |xxxxx| |xxxxx| // |xxxxx| |xxxxx| |xxxxx| | | | | | | | | |xxxxx| |xxxxx| // |xxxxx| |xxxxx| |xxxxx| | | | | | | | | |xxxxx| |xxxxx| // |xxxxx| |xxxxx| |xxxxx| | | | | | | | | |xxxxx| |xxxxx| // |xxxxx| |xxxxx| |xxxxx| |xxxxx| | | | | |xxxxx| |xxxxx| |xxxxx| // |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| // Frame allocator uses arenas and works like a stack - // it will give memory from the top and can delete only last allocated memory. template <Alignment AlignmenT = DEFAULT_FRAME_ALIGNMENT, bool UseMemsetT = true> class FrameAllocator { public: FrameAllocator(); ~FrameAllocator(); FrameAllocator(const FrameAllocator &) noexcept = delete; FrameAllocator(FrameAllocator &&) noexcept = default; FrameAllocator &operator=(const FrameAllocator &) noexcept = delete; FrameAllocator &operator=(FrameAllocator &&) noexcept = default; [[nodiscard]] void *Alloc(size_t size); // We must free objects allocated by this allocator strictly in reverse order void Free(void *mem); /** * \brief Returns true if address inside current allocator. */ bool Contains(void *mem); static constexpr AllocatorType GetAllocatorType() { return AllocatorType::FRAME_ALLOCATOR; } private: using FramesArena = DoubleLinkedAlignedArena<AlignmenT>; static constexpr size_t FIRST_ARENA_SIZE = 256_KB; static_assert(FIRST_ARENA_SIZE % PANDA_POOL_ALIGNMENT_IN_BYTES == 0); static constexpr size_t ARENA_SIZE_GREW_LEVEL = FIRST_ARENA_SIZE; static constexpr size_t FRAME_ALLOC_MIN_FREE_MEMORY_THRESHOLD = FIRST_ARENA_SIZE / 2; static constexpr size_t FRAME_ALLOC_MAX_FREE_ARENAS_THRESHOLD = 1; /** * \brief Heuristic for arena size increase. * @return new size */ size_t GetNextArenaSize(size_t size); /** * \brief Try to allocate an arena from the memory. * @return true on success, or false on fail */ bool TryAllocateNewArena(size_t size = ARENA_SIZE_GREW_LEVEL); /** * \brief Try to allocate memory for a frame in the current arena or in the next one if it exists. * @param size - size of the allocated memory * @return pointer to the allocated memory on success, or nullptr on fail */ void *TryToAllocate(size_t size); /** * \brief Free last_allocated_arena_, i.e., free last arena in the list. */ void FreeLastArena(); // A pointer to the current arena with the last allocated frame FramesArena *cur_arena_ {nullptr}; // A pointer to the last allocated arena (so it is equal to the top arena in the list) FramesArena *last_alloc_arena_ {nullptr}; // The biggest arena size during FrameAllocator workflow. Needed for computing a new arena size. size_t biggest_arena_size_ {0}; // A marker which tells us if we need to increase the size of a new arena or not. bool arena_size_need_to_grow_ {true}; size_t empty_arenas_count_ {0}; MmapMemPool *mem_pool_alloc_ {nullptr}; friend class FrameAllocatorTest; }; } // namespace panda::mem #endif // PANDA_RUNTIME_MEM_FRAME_ALLOCATOR_H_
[ "wanyanglan1@huawei.com" ]
wanyanglan1@huawei.com
b8e4842b8c20ac6f0bdfde7dc42b387d2efdeada
ae52a789938dcda0e77dee94c76b7ee2f5a42e13
/obs_text_directwrite/obs_text_directwrite.cpp
932b0fe7e586c1b4596d974f7cb1d8c4167eb283
[]
no_license
molandtoxx/obs-text-directwrite
40feba6d0d006dd20c8a235c5317534d96fdb67c
1db80b6092f49c356012fc7af79a555446ab0cb0
refs/heads/master
2020-12-27T12:55:16.031618
2017-06-18T04:46:29
2017-06-18T04:46:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
29,535
cpp
#include <util/platform.h> #include <util/util.hpp> #include <obs-module.h> #include <sys/stat.h> #include <windows.h> #include <algorithm> #include <string> #include <memory> #include <math.h> #include "CustomTextRenderer.h" using namespace std; #ifndef clamp #define clamp(val, min_val, max_val) \ if (val < min_val) val = min_val; \ else if (val > max_val) val = max_val; #endif #define MIN_SIZE_CX 2.0 #define MIN_SIZE_CY 2.0 #define MAX_SIZE_CX 4096.0 #define MAX_SIZE_CY 4096.0 /* ------------------------------------------------------------------------- */ #define S_FONT "font" #define S_USE_FILE "read_from_file" #define S_FILE "file" #define S_TEXT "text" #define S_COLOR "color" #define S_GRADIENT "gradient" #define S_GRADIENT_NONE "none" #define S_GRADIENT_TWO "two_colors" #define S_GRADIENT_THREE "three_colors" #define S_GRADIENT_FOUR "four_colors" #define S_GRADIENT_COLOR "gradient_color" #define S_GRADIENT_COLOR2 "gradient_color2" #define S_GRADIENT_COLOR3 "gradient_color3" #define S_GRADIENT_DIR "gradient_dir" #define S_GRADIENT_OPACITY "gradient_opacity" #define S_ALIGN "align" #define S_VALIGN "valign" #define S_OPACITY "opacity" #define S_BKCOLOR "bk_color" #define S_BKOPACITY "bk_opacity" //#define S_VERTICAL "vertical" #define S_OUTLINE "outline" #define S_OUTLINE_SIZE "outline_size" #define S_OUTLINE_COLOR "outline_color" #define S_OUTLINE_OPACITY "outline_opacity" #define S_CHATLOG_MODE "chatlog" #define S_CHATLOG_LINES "chatlog_lines" #define S_EXTENTS "extents" #define S_EXTENTS_CX "extents_cx" #define S_EXTENTS_CY "extents_cy" #define S_ALIGN_LEFT "left" #define S_ALIGN_CENTER "center" #define S_ALIGN_RIGHT "right" #define S_VALIGN_TOP "top" #define S_VALIGN_CENTER S_ALIGN_CENTER #define S_VALIGN_BOTTOM "bottom" #define T_(v) obs_module_text(v) #define T_FONT T_("Font") #define T_USE_FILE T_("ReadFromFile") #define T_FILE T_("TextFile") #define T_TEXT T_("Text") #define T_COLOR T_("Color") #define T_GRADIENT T_("Gradient") #define T_GRADIENT_NONE T_("Gradient.None") #define T_GRADIENT_TWO T_("Gradient.TwoColors") #define T_GRADIENT_THREE T_("Gradient.ThreeColors") #define T_GRADIENT_FOUR T_("Gradient.FourColors") #define T_GRADIENT_COLOR T_("Gradient.Color") #define T_GRADIENT_COLOR2 T_("Gradient.Color2") #define T_GRADIENT_COLOR3 T_("Gradient.Color3") #define T_GRADIENT_DIR T_("Gradient.Direction") #define T_GRADIENT_OPACITY T_("Gradient.Opacity") #define T_ALIGN T_("Alignment") #define T_VALIGN T_("VerticalAlignment") #define T_OPACITY T_("Opacity") #define T_BKCOLOR T_("BkColor") #define T_BKOPACITY T_("BkOpacity") //#define T_VERTICAL T_("Vertical") #define T_OUTLINE T_("Outline") #define T_OUTLINE_SIZE T_("Outline.Size") #define T_OUTLINE_COLOR T_("Outline.Color") #define T_OUTLINE_OPACITY T_("Outline.Opacity") #define T_CHATLOG_MODE T_("ChatlogMode") #define T_CHATLOG_LINES T_("ChatlogMode.Lines") #define T_EXTENTS T_("UseCustomExtents") #define T_EXTENTS_CX T_("Width") #define T_EXTENTS_CY T_("Height") #define T_FILTER_TEXT_FILES T_("Filter.TextFiles") #define T_FILTER_ALL_FILES T_("Filter.AllFiles") #define T_ALIGN_LEFT T_("Alignment.Left") #define T_ALIGN_CENTER T_("Alignment.Center") #define T_ALIGN_RIGHT T_("Alignment.Right") #define T_VALIGN_TOP T_("VerticalAlignment.Top") #define T_VALIGN_CENTER T_ALIGN_CENTER #define T_VALIGN_BOTTOM T_("VerticalAlignment.Bottom") /* ------------------------------------------------------------------------- */ static inline DWORD get_alpha_val(uint32_t opacity) { return ((opacity * 255 / 100) & 0xFF) << 24; } static inline DWORD calc_color(uint32_t color, uint32_t opacity) { return color & 0xFFFFFF | get_alpha_val(opacity); } static inline wstring to_wide(const char *utf8) { wstring text; size_t len = os_utf8_to_wcs(utf8, 0, nullptr, 0); text.resize(len); if (len) os_utf8_to_wcs(utf8, 0, &text[0], len + 1); return text; } static inline uint32_t rgb_to_bgr(uint32_t rgb) { return ((rgb & 0xFF) << 16) | (rgb & 0xFF00) | ((rgb & 0xFF0000) >> 16); } enum Gradient_mode { Gradient_none = 0, Gradient_two_color = 2, Gradient_three_color = 3, Gradient_four_color = 4 }; struct TargetDC{ void *bits; HDC memDC; HBITMAP hBmp; TargetDC(long width, long height) { BITMAPINFO info; info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); info.bmiHeader.biWidth = width; info.bmiHeader.biHeight = -height; info.bmiHeader.biBitCount = 32; info.bmiHeader.biPlanes = 1; info.bmiHeader.biXPelsPerMeter = 0; info.bmiHeader.biYPelsPerMeter = 0; info.bmiHeader.biClrUsed = 0; info.bmiHeader.biClrImportant = 0; info.bmiHeader.biCompression = BI_RGB; info.bmiHeader.biSizeImage = width * height; info.bmiColors[0].rgbGreen = 0; info.bmiColors[0].rgbBlue = 0; info.bmiColors[0].rgbRed = 0; info.bmiColors[0].rgbReserved = 0; hBmp = CreateDIBSection(0, &info, DIB_RGB_COLORS, &bits, 0, 0); HDC hdc = GetDC(0); memDC = CreateCompatibleDC(hdc); SelectObject(memDC, hBmp); ReleaseDC(0, hdc); } ~TargetDC() { DeleteObject(hBmp); DeleteDC(memDC); } }; struct TextSource { obs_source_t *source = nullptr; gs_texture_t *tex = nullptr; uint32_t cx = 0; uint32_t cy = 0; IDWriteFactory* pDWriteFactory = nullptr; IDWriteTextFormat* pTextFormat = nullptr; ID2D1Factory* pD2DFactory = nullptr; ID2D1Brush* pFillBrush = nullptr; ID2D1Brush* pOutlineBrush = nullptr; ID2D1DCRenderTarget* pRT = nullptr; IDWriteTextLayout* pTextLayout = nullptr; CustomTextRenderer* pTextRenderer = nullptr; D2D1_RENDER_TARGET_PROPERTIES props = {}; bool read_from_file = false; string file; time_t file_timestamp = 0; float update_time_elapsed = 0.0f; wstring text; wstring face; int face_size = 0; uint32_t color = 0xFFFFFF; uint32_t color2 = 0xFFFFFF; uint32_t color3 = 0xFFFFFF; uint32_t color4 = 0xFFFFFF; Gradient_mode gradient_count = Gradient_none; float gradient_dir = 0; float gradient_x = 0; float gradient_y = 0; float gradient2_x = 0; float gradient2_y = 0; uint32_t opacity = 100; uint32_t opacity2 = 100; uint32_t bk_color = 0; uint32_t bk_opacity = 0; DWRITE_FONT_WEIGHT weight = DWRITE_FONT_WEIGHT_REGULAR; DWRITE_FONT_STYLE style = DWRITE_FONT_STYLE_NORMAL; DWRITE_FONT_STRETCH stretch = DWRITE_FONT_STRETCH_NORMAL; DWRITE_TEXT_ALIGNMENT align = DWRITE_TEXT_ALIGNMENT_LEADING; DWRITE_PARAGRAPH_ALIGNMENT valign = DWRITE_PARAGRAPH_ALIGNMENT_NEAR; bool bold = false; bool italic = false; bool underline = false; bool strikeout = false; //bool vertical = false; bool use_outline = false; float outline_size = 0.0f; uint32_t outline_color = 0; uint32_t outline_opacity = 100; bool use_extents = false; uint32_t extents_cx = 0; uint32_t extents_cy = 0; bool chatlog_mode = false; int chatlog_lines = 6; /* --------------------------- */ inline TextSource(obs_source_t *source_, obs_data_t *settings) : source(source_) { InitializeDirectWrite(); obs_source_update(source, settings); } inline ~TextSource() { if (tex) { obs_enter_graphics(); gs_texture_destroy(tex); obs_leave_graphics(); } ReleaseResource(); } void UpdateFont(); void CalculateGradientAxis(float width, float height); void InitializeDirectWrite(); void ReleaseResource(); void UpdateBrush(ID2D1RenderTarget* pRT, ID2D1Brush** ppOutlineBrush, ID2D1Brush** ppFillBrush, float width, float height); void RenderText(); void LoadFileText(); const char *GetMainString(const char *str); inline void Update(obs_data_t *settings); inline void Tick(float seconds); inline void Render(gs_effect_t *effect); }; static time_t get_modified_timestamp(const char *filename) { struct stat stats; if (os_stat(filename, &stats) != 0) return -1; return stats.st_mtime; } void TextSource::UpdateFont() { if (bold) weight = DWRITE_FONT_WEIGHT::DWRITE_FONT_WEIGHT_BOLD; else weight = DWRITE_FONT_WEIGHT::DWRITE_FONT_WEIGHT_REGULAR; if (italic) style = DWRITE_FONT_STYLE::DWRITE_FONT_STYLE_ITALIC; else style = DWRITE_FONT_STYLE::DWRITE_FONT_STYLE_NORMAL; } void TextSource::CalculateGradientAxis(float width, float height) { if (width <= 0.0 || height <= 0.0) return; float angle = atan(height / width)*180.0 / M_PI; if (gradient_dir <= angle || gradient_dir > 360.0 - angle) { float y = width / 2 * tan(gradient_dir*M_PI / 180.0); gradient_x = width; gradient_y = height / 2 - y; gradient2_x = 0; gradient2_y = height / 2 + y; } else if (gradient_dir <= 180.0 - angle && gradient_dir> angle) { float x = height / 2 * tan((90.0 - gradient_dir)*M_PI / 180.0); gradient_x = width / 2 + x; gradient_y = 0; gradient2_x = width / 2 - x; gradient2_y = height; } else if (gradient_dir <= 180.0 + angle && gradient_dir > 180.0 - angle) { float y = width / 2 * tan(gradient_dir*M_PI / 180.0); gradient_x = 0; gradient_y = height / 2 + y; gradient2_x = width; gradient2_y = height / 2 - y; } else { float x = height / 2 * tan((270.0 - gradient_dir)*M_PI / 180.0); gradient_x = width / 2 - x; gradient_y = height; gradient2_x = width / 2 + x; gradient2_y = 0; } } void TextSource::InitializeDirectWrite() { HRESULT hr = S_OK; hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &pD2DFactory); if (SUCCEEDED(hr)) { hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&pDWriteFactory) ); } props = D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED), 0, 0, D2D1_RENDER_TARGET_USAGE_NONE, D2D1_FEATURE_LEVEL_DEFAULT ); } void TextSource::ReleaseResource() { SafeRelease(&pTextRenderer); SafeRelease(&pRT); SafeRelease(&pFillBrush); SafeRelease(&pOutlineBrush); SafeRelease(&pTextLayout); SafeRelease(&pTextFormat); SafeRelease(&pDWriteFactory); SafeRelease(&pD2DFactory); } void TextSource::UpdateBrush(ID2D1RenderTarget* pRT, ID2D1Brush** ppOutlineBrush, ID2D1Brush** ppFillBrush , float width, float height) { HRESULT hr; if (gradient_count > 0) { CalculateGradientAxis(width, height); ID2D1GradientStopCollection *pGradientStops = NULL; float level = 1.0 / (gradient_count - 1); D2D1_GRADIENT_STOP gradientStops[4]; gradientStops[0].color = D2D1::ColorF(color, opacity / 100.0); gradientStops[0].position = 0.0f; gradientStops[1].color = D2D1::ColorF(color2, opacity2 / 100.0); gradientStops[1].position = gradientStops[0].position + level; gradientStops[2].color = D2D1::ColorF(color3, opacity2 / 100.0); gradientStops[2].position = gradientStops[1].position + level; gradientStops[3].color = D2D1::ColorF(color4, opacity2 / 100.0); gradientStops[3].position = 1.0f; hr = pRT->CreateGradientStopCollection(gradientStops, gradient_count, D2D1_GAMMA_2_2, D2D1_EXTEND_MODE_MIRROR, &pGradientStops); hr = pRT->CreateLinearGradientBrush( D2D1::LinearGradientBrushProperties( D2D1::Point2F(gradient_x, gradient_y), D2D1::Point2F(gradient2_x, gradient2_y)), pGradientStops, (ID2D1LinearGradientBrush**)ppFillBrush ); } else { hr = pRT->CreateSolidColorBrush(D2D1::ColorF(color, opacity / 100.0), (ID2D1SolidColorBrush**)ppFillBrush ); } if (use_outline) { hr = pRT->CreateSolidColorBrush( D2D1::ColorF(outline_color, outline_opacity / 100.0), (ID2D1SolidColorBrush**)ppOutlineBrush ); } } void TextSource::RenderText() { UINT32 TextLength = (UINT32)wcslen(text.c_str()); HRESULT hr = S_OK; float layout_cx = (use_extents) ? extents_cx : 1920.0; float layout_cy = (use_extents) ? extents_cy : 1080.0; float text_cx = 0.0; float text_cy = 0.0; SIZE size; UINT32 lines = 1; if (pDWriteFactory) { hr = pDWriteFactory->CreateTextFormat(face.c_str(), NULL, weight, style, stretch, (float)face_size, L"en-us", &pTextFormat); } if (SUCCEEDED(hr)) { pTextFormat->SetTextAlignment(align); pTextFormat->SetParagraphAlignment(valign); pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); /*if (vertical) { pTextFormat->SetReadingDirection(DWRITE_READING_DIRECTION_TOP_TO_BOTTOM); pTextFormat->SetFlowDirection(DWRITE_FLOW_DIRECTION_RIGHT_TO_LEFT); }*/ hr = pDWriteFactory->CreateTextLayout(text.c_str(), TextLength, pTextFormat, layout_cx, layout_cy, &pTextLayout); } if (SUCCEEDED(hr)) { DWRITE_TEXT_METRICS textMetrics; hr = pTextLayout->GetMetrics(&textMetrics); text_cx = ceil(textMetrics.widthIncludingTrailingWhitespace); text_cy = ceil(textMetrics.height); lines = textMetrics.lineCount; if (!use_extents) { layout_cx = text_cx; layout_cy = text_cy; } clamp(layout_cx, MIN_SIZE_CX, MAX_SIZE_CX); clamp(layout_cy, MIN_SIZE_CY, MAX_SIZE_CY); size.cx = layout_cx; size.cy = layout_cy; } if (SUCCEEDED(hr)) { DWRITE_TEXT_RANGE text_range = { 0, TextLength }; pTextLayout->SetUnderline(underline, text_range); pTextLayout->SetStrikethrough(strikeout, text_range); pTextLayout->SetMaxWidth(layout_cx); pTextLayout->SetMaxHeight(layout_cy); hr = pD2DFactory->CreateDCRenderTarget(&props, &pRT); } TargetDC target(size.cx, size.cy); if (SUCCEEDED(hr)) { RECT rc; SetRect(&rc, 0, 0, size.cx, size.cy); pRT->BindDC(target.memDC, &rc); UpdateBrush(pRT, &pOutlineBrush, &pFillBrush, text_cx, text_cy / lines); pTextRenderer = new (std::nothrow)CustomTextRenderer( pD2DFactory, (ID2D1RenderTarget*)pRT, (ID2D1Brush*)pOutlineBrush, (ID2D1Brush*)pFillBrush, outline_size ); pRT->BeginDraw(); pRT->SetTransform(D2D1::IdentityMatrix()); pRT->Clear(D2D1::ColorF(bk_color, bk_opacity / 100.0)); pTextLayout->Draw(NULL, pTextRenderer, 0, 0); hr = pRT->EndDraw(); } if (!tex || (LONG)cx != size.cx || (LONG)cy != size.cy) { obs_enter_graphics(); if (tex) gs_texture_destroy(tex); const uint8_t *data = (uint8_t*)target.bits; tex = gs_texture_create(size.cx, size.cy, GS_BGRA, 1, &data, GS_DYNAMIC); obs_leave_graphics(); cx = (uint32_t)size.cx; cy = (uint32_t)size.cy; } else if (tex) { obs_enter_graphics(); const uint8_t *data = (uint8_t*)target.bits; gs_texture_set_image(tex, data, size.cx * 4, false); obs_leave_graphics(); } SafeRelease(&pTextFormat); SafeRelease(&pFillBrush); SafeRelease(&pOutlineBrush); SafeRelease(&pTextLayout); SafeRelease(&pTextRenderer); SafeRelease(&pRT); } const char *TextSource::GetMainString(const char *str) { if (!str) return ""; if (!chatlog_mode || !chatlog_lines) return str; int lines = chatlog_lines; size_t len = strlen(str); if (!len) return str; const char *temp = str + len; while (temp != str) { temp--; if (temp[0] == '\n' && temp[1] != 0) { if (!--lines) break; } } return *temp == '\n' ? temp + 1 : temp; } void TextSource::LoadFileText() { BPtr<char> file_text = os_quick_read_utf8_file(file.c_str()); text = to_wide(GetMainString(file_text)); } #define obs_data_get_uint32 (uint32_t)obs_data_get_int inline void TextSource::Update(obs_data_t *s) { const char *new_text = obs_data_get_string(s, S_TEXT); obs_data_t *font_obj = obs_data_get_obj(s, S_FONT); const char *align_str = obs_data_get_string(s, S_ALIGN); const char *valign_str = obs_data_get_string(s, S_VALIGN); uint32_t new_color = obs_data_get_uint32(s, S_COLOR); uint32_t new_opacity = obs_data_get_uint32(s, S_OPACITY); const char *gradient_str = obs_data_get_string(s, S_GRADIENT); uint32_t new_color2 = obs_data_get_uint32(s, S_GRADIENT_COLOR); uint32_t new_color3 = obs_data_get_uint32(s, S_GRADIENT_COLOR2); uint32_t new_color4 = obs_data_get_uint32(s, S_GRADIENT_COLOR3); uint32_t new_opacity2 = obs_data_get_uint32(s, S_GRADIENT_OPACITY); float new_grad_dir = (float)obs_data_get_double(s, S_GRADIENT_DIR); //bool new_vertical = obs_data_get_bool(s, S_VERTICAL); bool new_outline = obs_data_get_bool(s, S_OUTLINE); uint32_t new_o_color = obs_data_get_uint32(s, S_OUTLINE_COLOR); uint32_t new_o_opacity = obs_data_get_uint32(s, S_OUTLINE_OPACITY); uint32_t new_o_size = obs_data_get_uint32(s, S_OUTLINE_SIZE); bool new_use_file = obs_data_get_bool(s, S_USE_FILE); const char *new_file = obs_data_get_string(s, S_FILE); bool new_chat_mode = obs_data_get_bool(s, S_CHATLOG_MODE); int new_chat_lines = (int)obs_data_get_int(s, S_CHATLOG_LINES); bool new_extents = obs_data_get_bool(s, S_EXTENTS); uint32_t n_extents_cx = obs_data_get_uint32(s, S_EXTENTS_CX); uint32_t n_extents_cy = obs_data_get_uint32(s, S_EXTENTS_CY); const char *font_face = obs_data_get_string(font_obj, "face"); int font_size = (int)obs_data_get_int(font_obj, "size"); int64_t font_flags = obs_data_get_int(font_obj, "flags"); bool new_bold = (font_flags & OBS_FONT_BOLD) != 0; bool new_italic = (font_flags & OBS_FONT_ITALIC) != 0; bool new_underline = (font_flags & OBS_FONT_UNDERLINE) != 0; bool new_strikeout = (font_flags & OBS_FONT_STRIKEOUT) != 0; uint32_t new_bk_color = obs_data_get_uint32(s, S_BKCOLOR); uint32_t new_bk_opacity = obs_data_get_uint32(s, S_BKOPACITY); /* ----------------------------- */ wstring new_face = to_wide(font_face); if (new_face != face || face_size != font_size || new_bold != bold || new_italic != italic || new_underline != underline || new_strikeout != strikeout) { face = new_face; face_size = font_size; bold = new_bold; italic = new_italic; underline = new_underline; strikeout = new_strikeout; UpdateFont(); } /* ----------------------------- */ new_color = rgb_to_bgr(new_color); new_color2 = rgb_to_bgr(new_color2); new_color3 = rgb_to_bgr(new_color3); new_color4 = rgb_to_bgr(new_color4); new_o_color = rgb_to_bgr(new_o_color); new_bk_color = rgb_to_bgr(new_bk_color); color = new_color; opacity = new_opacity; color2 = new_color2; color3 = new_color3; color4 = new_color4; opacity2 = new_opacity2; gradient_dir = new_grad_dir; //vertical = new_vertical; Gradient_mode new_count = Gradient_none; if (strcmp(gradient_str, S_GRADIENT_NONE) == 0) new_count = Gradient_none; else if (strcmp(gradient_str, S_GRADIENT_TWO) == 0) new_count = Gradient_two_color; else if (strcmp(gradient_str, S_GRADIENT_THREE) == 0) new_count = Gradient_three_color; else new_count = Gradient_four_color; gradient_count = new_count; bk_color = new_bk_color; bk_opacity = new_bk_opacity; use_extents = new_extents; extents_cx = n_extents_cx; extents_cy = n_extents_cy; read_from_file = new_use_file; chatlog_mode = new_chat_mode; chatlog_lines = new_chat_lines; if (read_from_file) { file = new_file; file_timestamp = get_modified_timestamp(new_file); LoadFileText(); } else { text = to_wide(GetMainString(new_text)); } use_outline = new_outline; outline_color = new_o_color; outline_opacity = new_o_opacity; outline_size = roundf(float(new_o_size)); if (strcmp(align_str, S_ALIGN_CENTER) == 0) align = DWRITE_TEXT_ALIGNMENT_CENTER; else if (strcmp(align_str, S_ALIGN_RIGHT) == 0) align = DWRITE_TEXT_ALIGNMENT_TRAILING; else align = DWRITE_TEXT_ALIGNMENT_LEADING; if (strcmp(valign_str, S_VALIGN_CENTER) == 0) valign = DWRITE_PARAGRAPH_ALIGNMENT_CENTER; else if (strcmp(valign_str, S_VALIGN_BOTTOM) == 0) valign = DWRITE_PARAGRAPH_ALIGNMENT_FAR; else valign = DWRITE_PARAGRAPH_ALIGNMENT_NEAR; RenderText(); update_time_elapsed = 0.0f; /* ----------------------------- */ obs_data_release(font_obj); } inline void TextSource::Tick(float seconds) { if (!read_from_file) return; update_time_elapsed += seconds; if (update_time_elapsed >= 1.0f) { time_t t = get_modified_timestamp(file.c_str()); update_time_elapsed = 0.0f; if (file_timestamp != t) { LoadFileText(); RenderText(); file_timestamp = t; } } } inline void TextSource::Render(gs_effect_t *effect) { if (!tex) return; gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"), tex); gs_draw_sprite(tex, 0, cx, cy); } /* ------------------------------------------------------------------------- */ OBS_DECLARE_MODULE() OBS_MODULE_USE_DEFAULT_LOCALE("obs-text", "en-US") #define set_vis(var, val, show) \ do { \ p = obs_properties_get(props, val); \ obs_property_set_visible(p, var == show); \ } while (false) static bool use_file_changed(obs_properties_t *props, obs_property_t *p, obs_data_t *s) { bool use_file = obs_data_get_bool(s, S_USE_FILE); set_vis(use_file, S_TEXT, false); set_vis(use_file, S_FILE, true); return true; } static bool outline_changed(obs_properties_t *props, obs_property_t *p, obs_data_t *s) { bool outline = obs_data_get_bool(s, S_OUTLINE); set_vis(outline, S_OUTLINE_SIZE, true); set_vis(outline, S_OUTLINE_COLOR, true); set_vis(outline, S_OUTLINE_OPACITY, true); return true; } static bool chatlog_mode_changed(obs_properties_t *props, obs_property_t *p, obs_data_t *s) { bool chatlog_mode = obs_data_get_bool(s, S_CHATLOG_MODE); set_vis(chatlog_mode, S_CHATLOG_LINES, true); return true; } static bool gradient_changed(obs_properties_t *props, obs_property_t *p, obs_data_t *s) { const char *gradient_str = obs_data_get_string(s, S_GRADIENT); Gradient_mode mode = Gradient_none; if (strcmp(gradient_str, S_GRADIENT_NONE) == 0) mode = Gradient_none; else if (strcmp(gradient_str, S_GRADIENT_TWO) == 0) mode = Gradient_two_color; else if (strcmp(gradient_str, S_GRADIENT_THREE) == 0) mode = Gradient_three_color; else mode = Gradient_four_color; bool gradient_color = (mode > Gradient_none); bool gradient_color2 = (mode > Gradient_two_color); bool gradient_color3 = (mode > Gradient_three_color); set_vis(gradient_color, S_GRADIENT_COLOR, true); set_vis(gradient_color2, S_GRADIENT_COLOR2, true); set_vis(gradient_color3, S_GRADIENT_COLOR3, true); set_vis(gradient_color, S_GRADIENT_OPACITY, true); set_vis(gradient_color, S_GRADIENT_DIR, true); return true; } static bool extents_modified(obs_properties_t *props, obs_property_t *p, obs_data_t *s) { bool use_extents = obs_data_get_bool(s, S_EXTENTS); set_vis(use_extents, S_EXTENTS_CX, true); set_vis(use_extents, S_EXTENTS_CY, true); return true; } #undef set_vis static obs_properties_t *get_properties(void *data) { TextSource *s = reinterpret_cast<TextSource*>(data); string path; obs_properties_t *props = obs_properties_create(); obs_property_t *p; obs_properties_add_font(props, S_FONT, T_FONT); p = obs_properties_add_bool(props, S_USE_FILE, T_USE_FILE); obs_property_set_modified_callback(p, use_file_changed); string filter; filter += T_FILTER_TEXT_FILES; filter += " (*.txt);;"; filter += T_FILTER_ALL_FILES; filter += " (*.*)"; if (s && !s->file.empty()) { const char *slash; path = s->file; replace(path.begin(), path.end(), '\\', '/'); slash = strrchr(path.c_str(), '/'); if (slash) path.resize(slash - path.c_str() + 1); } obs_properties_add_text(props, S_TEXT, T_TEXT, OBS_TEXT_MULTILINE); obs_properties_add_path(props, S_FILE, T_FILE, OBS_PATH_FILE, filter.c_str(), path.c_str()); //obs_properties_add_bool(props, S_VERTICAL, T_VERTICAL); obs_properties_add_color(props, S_COLOR, T_COLOR); obs_properties_add_int_slider(props, S_OPACITY, T_OPACITY, 0, 100, 1); /*p = obs_properties_add_bool(props, S_GRADIENT, T_GRADIENT); obs_property_set_modified_callback(p, gradient_changed);*/ p = obs_properties_add_list(props, S_GRADIENT, T_GRADIENT, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, T_GRADIENT_NONE, S_GRADIENT_NONE); obs_property_list_add_string(p, T_GRADIENT_TWO, S_GRADIENT_TWO); obs_property_list_add_string(p, T_GRADIENT_THREE, S_GRADIENT_THREE); obs_property_list_add_string(p, T_GRADIENT_FOUR, S_GRADIENT_FOUR); obs_property_set_modified_callback(p, gradient_changed); obs_properties_add_color(props, S_GRADIENT_COLOR, T_GRADIENT_COLOR); obs_properties_add_color(props, S_GRADIENT_COLOR2, T_GRADIENT_COLOR2); obs_properties_add_color(props, S_GRADIENT_COLOR3, T_GRADIENT_COLOR3); obs_properties_add_int_slider(props, S_GRADIENT_OPACITY, T_GRADIENT_OPACITY, 0, 100, 1); obs_properties_add_float_slider(props, S_GRADIENT_DIR, T_GRADIENT_DIR, 0, 360, 0.1); obs_properties_add_color(props, S_BKCOLOR, T_BKCOLOR); obs_properties_add_int_slider(props, S_BKOPACITY, T_BKOPACITY, 0, 100, 1); p = obs_properties_add_list(props, S_ALIGN, T_ALIGN, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, T_ALIGN_LEFT, S_ALIGN_LEFT); obs_property_list_add_string(p, T_ALIGN_CENTER, S_ALIGN_CENTER); obs_property_list_add_string(p, T_ALIGN_RIGHT, S_ALIGN_RIGHT); p = obs_properties_add_list(props, S_VALIGN, T_VALIGN, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, T_VALIGN_TOP, S_VALIGN_TOP); obs_property_list_add_string(p, T_VALIGN_CENTER, S_VALIGN_CENTER); obs_property_list_add_string(p, T_VALIGN_BOTTOM, S_VALIGN_BOTTOM); p = obs_properties_add_bool(props, S_OUTLINE, T_OUTLINE); obs_property_set_modified_callback(p, outline_changed); obs_properties_add_int(props, S_OUTLINE_SIZE, T_OUTLINE_SIZE, 1, 20, 1); obs_properties_add_color(props, S_OUTLINE_COLOR, T_OUTLINE_COLOR); obs_properties_add_int_slider(props, S_OUTLINE_OPACITY, T_OUTLINE_OPACITY, 0, 100, 1); p = obs_properties_add_bool(props, S_CHATLOG_MODE, T_CHATLOG_MODE); obs_property_set_modified_callback(p, chatlog_mode_changed); obs_properties_add_int(props, S_CHATLOG_LINES, T_CHATLOG_LINES, 1, 1000, 1); p = obs_properties_add_bool(props, S_EXTENTS, T_EXTENTS); obs_property_set_modified_callback(p, extents_modified); obs_properties_add_int(props, S_EXTENTS_CX, T_EXTENTS_CX, 32, 8000, 1); obs_properties_add_int(props, S_EXTENTS_CY, T_EXTENTS_CY, 32, 8000, 1); return props; } bool obs_module_load(void) { obs_source_info si = {}; si.id = "text_directwrite"; si.type = OBS_SOURCE_TYPE_INPUT; si.output_flags = OBS_SOURCE_VIDEO; si.get_properties = get_properties; si.get_name = [](void*) { return obs_module_text("TextDirectWrite"); }; si.create = [](obs_data_t *settings, obs_source_t *source) { return (void*)new TextSource(source, settings); }; si.destroy = [](void *data) { delete reinterpret_cast<TextSource*>(data); }; si.get_width = [](void *data) { return reinterpret_cast<TextSource*>(data)->cx; }; si.get_height = [](void *data) { return reinterpret_cast<TextSource*>(data)->cy; }; si.get_defaults = [](obs_data_t *settings) { obs_data_t *font_obj = obs_data_create(); obs_data_set_default_string(font_obj, "face", "Arial"); obs_data_set_default_int(font_obj, "size", 36); obs_data_set_default_obj(settings, S_FONT, font_obj); obs_data_set_default_string(settings, S_ALIGN, S_ALIGN_LEFT); obs_data_set_default_string(settings, S_VALIGN, S_VALIGN_TOP); obs_data_set_default_int(settings, S_COLOR, 0xFFFFFF); obs_data_set_default_int(settings, S_OPACITY, 100); obs_data_set_default_int(settings, S_GRADIENT_COLOR, 0xFFFFFF); obs_data_set_default_int(settings, S_GRADIENT_COLOR2, 0xFFFFFF); obs_data_set_default_int(settings, S_GRADIENT_COLOR3, 0xFFFFFF); obs_data_set_default_int(settings, S_GRADIENT_OPACITY, 100); obs_data_set_default_double(settings, S_GRADIENT_DIR, 90.0); obs_data_set_default_int(settings, S_BKCOLOR, 0x000000); obs_data_set_default_int(settings, S_BKOPACITY, 0); obs_data_set_default_int(settings, S_OUTLINE_SIZE, 2); obs_data_set_default_int(settings, S_OUTLINE_COLOR, 0xFFFFFF); obs_data_set_default_int(settings, S_OUTLINE_OPACITY, 100); obs_data_set_default_int(settings, S_CHATLOG_LINES, 6); obs_data_set_default_int(settings, S_EXTENTS_CX, 100); obs_data_set_default_int(settings, S_EXTENTS_CY, 100); obs_data_release(font_obj); }; si.update = [](void *data, obs_data_t *settings) { reinterpret_cast<TextSource*>(data)->Update(settings); }; si.video_tick = [](void *data, float seconds) { reinterpret_cast<TextSource*>(data)->Tick(seconds); }; si.video_render = [](void *data, gs_effect_t *effect) { reinterpret_cast<TextSource*>(data)->Render(effect); }; obs_register_source(&si); return true; } void obs_module_unload(void) { }
[ "lazycat.fish0215@gmail.com" ]
lazycat.fish0215@gmail.com
525064389e30111ea3965b9f697dde40ae4dd5bc
0412573aa478f60cd9123e6a9715f503a1dd6bd7
/DLL/GoldManager.cpp
e548c16e941f2c8e81da7472540fdf8f052e5d68
[]
no_license
Abin-Liu/Pindlebot_Sig
7d28f4d4a5cdeeed69f9676f4b1349d2664a3775
ff5269c5148c80662283ca1b646b191484b30592
refs/heads/master
2020-03-20T19:29:17.621445
2018-06-10T09:12:54
2018-06-10T09:12:54
137,639,835
0
0
null
null
null
null
UTF-8
C++
false
false
3,271
cpp
// GoldManager.cpp: implementation of the CGoldManager class. // ////////////////////////////////////////////////////////////////////// //#include "StdAfx.h" #include "GoldManager.h" // Stuff for picking gold #define MAXGOLD(char_level)((char_level) * (DWORD)10000) #define GOLDSPACE(char_level, inventory_gold)(MAXGOLD(char_level) > (inventory_gold) ? MAXGOLD(char_level) - (inventory_gold) : 0) #define GUESSLEVEL(inventory_gold)(((inventory_gold) % 10000) ? (inventory_gold) / 10000 + 1 : (inventory_gold) / 10000) ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CGoldManager::CGoldManager() { InitAttributes(); } CGoldManager::~CGoldManager() { } void CGoldManager::OnGameJoin(DWORD dwPlayerID) { InitAttributes(); m_dwPlayerID = dwPlayerID; } void CGoldManager::OnGameLeave() { InitAttributes(); } void CGoldManager::OnGamePacketBeforeReceived(const BYTE *aPacket, DWORD aLen) { if (!aPacket || !aLen) return; // inventory gold updates if (aPacket[0] == 0x19 && aLen == 2) { // less than 255 gold update m_dwInventoryGold += aPacket[1]; return; } if (aPacket[0] == 0x1d && aPacket[1] == 0x0e && aLen >= 3) { // inventory gold BYTE update BYTE gTmp = 0; ::memcpy(&gTmp, &aPacket[2], sizeof(BYTE)); m_dwInventoryGold = (DWORD)gTmp; m_iCharLevel = max(m_iCharLevel, (BYTE)GUESSLEVEL(m_dwInventoryGold)); return; } if (aPacket[0] == 0x1e && aPacket[1] == 0x0e && aLen >= 4) { // inventory gold WORD update WORD gTmp = 0; memcpy(&gTmp, &aPacket[2], sizeof(WORD)); m_dwInventoryGold = (DWORD)gTmp; m_iCharLevel = max(m_iCharLevel, (BYTE)GUESSLEVEL(m_dwInventoryGold)); return; } if (aPacket[0] == 0x1f && aPacket[1] == 0x0e && aLen >= 6) { // inventory gold DWORD update DWORD gTmp = 0; memcpy(&gTmp, &aPacket[2], sizeof(DWORD)); m_dwInventoryGold = (DWORD)gTmp; m_iCharLevel = max(m_iCharLevel, (BYTE)GUESSLEVEL(m_dwInventoryGold)); return; } // stash gold update if (aPacket[0] == 0x1d && aPacket[1] == 0x0f) { // stash gold BYTE update BYTE gTmp; memcpy(&gTmp, &aPacket[2], sizeof(BYTE)); m_dwStashGold = (DWORD)gTmp; return; } if (aPacket[0] == 0x1e && aPacket[1] == 0x0f) { // stash gold WORD update WORD gTmp; memcpy(&gTmp, &aPacket[2], sizeof(WORD)); m_dwStashGold = (DWORD)gTmp; return; } if (aPacket[0] == 0x1f && aPacket[1] == 0x0f) { // stash gold DWORD update DWORD gTmp; memcpy(&gTmp, &aPacket[2], sizeof(DWORD)); m_dwStashGold = (DWORD)gTmp; return; } // Char level, used for determining gold capacity if (aLen > 24 && aPacket[0] == 0x5b && !::memcmp(aPacket + 3, &m_dwPlayerID, 4)) { m_iCharLevel = aPacket[24]; return; } } DWORD CGoldManager::GetInventoryGold() const { return m_dwInventoryGold; } DWORD CGoldManager::GetStashGold() const { return m_dwStashGold; } BYTE CGoldManager::GetCharLevel() const { return m_iCharLevel; } DWORD CGoldManager::GetInventoryGoldSpace() const { return GOLDSPACE(m_iCharLevel, m_dwInventoryGold); } void CGoldManager::InitAttributes() { CD2Abstract::InitAttributes(); m_dwPlayerID = 0; m_iCharLevel = 1; m_dwInventoryGold = 0; m_dwStashGold = 0; }
[ "abinn32@163.com" ]
abinn32@163.com
7450434ce1a6287b290119d043a375b375582262
583149883e4e6a8c27eb4a5314c26ea92f485fec
/Source/PansMooMoo/Buildings/Building.h
12e67ca322410aa9f920dea6028f74d2f0722963
[]
no_license
janbroz/PansMooMoo
ab47885baa07aa4b437314fe9d08967b8abdf82d
bdc1508a514c6a5f271949ff203030096b4c45f8
refs/heads/master
2020-04-19T13:19:32.338770
2019-02-07T03:52:27
2019-02-07T03:52:27
168,214,167
0
0
null
null
null
null
UTF-8
C++
false
false
924
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "UMG.h" #include "Building.generated.h" UCLASS() class PANSMOOMOO_API ABuilding : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties ABuilding(); protected: // Called when the game starts or when spawned virtual void BeginPlay() override; public: // Called every frame virtual void Tick(float DeltaTime) override; UFUNCTION() bool IsPlayerCloseEnough(AActor* Hero); public: UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Building data") UStaticMeshComponent* Mesh; UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Building data") class USphereComponent* Collider; UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Building data") uint32 bCanBeAttacked : 1; };
[ "f870421@gmail.com" ]
f870421@gmail.com
837aacb0b55d82d1639bb570aeb60ab4a1451689
d7db098f4b1d1cd7d32952ebde8106e1f297252e
/AtCoder/ABC/036/d.cpp
c8dd7234ca80df5abb05a82e99ffb6c38e885486
[]
no_license
monman53/online_judge
d1d3ce50f5a8a3364a259a78bb89980ce05b9419
dec972d2b2b3922227d9eecaad607f1d9cc94434
refs/heads/master
2021-01-16T18:36:27.455888
2019-05-26T14:03:14
2019-05-26T14:03:14
25,679,069
0
0
null
null
null
null
UTF-8
C++
false
false
1,223
cpp
// header {{{ #include <bits/stdc++.h> using namespace std; // {U}{INT,LONG,LLONG}_{MAX,MIN} #define INF INT_MAX/3 #define MOD (1000000007LL) #define MODA(a, b) a=((a)+(b))%MOD #define MODP(a, b) a=((a)*(b))%MOD #define inc(i, l, r) for(long long i=(l);i<(r);i++) #define dec(i, l, r) for(long long i=(r)-1;i>=(l);i--) #define pb push_back #define se second #define fi first using LL = long long; using G = vector<vector<int>>; int di[] = {0, -1, 0, 1}; int dj[] = {1, 0, -1, 0}; // }}} G g; LL dp[100000][2]; void dfs(int from, int to) { dp[to][0] = dp[to][1] = 1; int cnt = 0; for(auto next : g[to]){ if(next == from) continue; dfs(to, next); cnt++; } if(cnt == 0) return; for(auto next : g[to]){ if(next == from) continue; MODP(dp[to][0], dp[next][1]); MODP(dp[to][1], dp[next][0]+dp[next][1]); } return; } int main() { std::ios::sync_with_stdio(false); int n;cin >> n; g.resize(n); inc(i, 0, n-1){ int a, b;cin >> a >> b;a--;b--; g[a].pb(b); g[b].pb(a); } dfs(-1, 0); cout << (dp[0][0]+dp[0][1])%MOD << endl; return 0; }
[ "monman.cs@gmail.com" ]
monman.cs@gmail.com
869a322b686a0ebcdc60f0ae0d2c361123f114cd
6350f5536d4c4939c539c29dad984a2cfa0bf77d
/verhojenhallinta.cpp
d1cf44539d79f1fc6331e5dda9e08bc80ef85db1
[]
no_license
sadxtester/KotiTeatter
3d3cbf6957cdf2266c8ca47b30f2a9ff29ee140f
a35c0e83d34ca5725f6e7159eec3876cf1bac065
refs/heads/master
2016-09-06T19:29:10.230554
2012-03-13T20:57:14
2012-03-13T20:57:14
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
717
cpp
#include "verhojenhallinta.h" #include <QDebug> VerhojenHallinta::VerhojenHallinta(QObject *parent) : QObject(parent) { m_onkoVerhotAuki = false; } void VerhojenHallinta::avaaSuljeVerhot(bool suljetaankoVerhot){ qDebug() << "signaali verhojen avaamisesta/sulkemisesta vastaan otettu"; if(suljetaankoVerhot){ m_onkoVerhotAuki = false; }else{ m_onkoVerhotAuki = true; } if(m_onkoVerhotAuki){ qDebug() << "Verhojen tila: auki"; }else{ qDebug() << "Verhojen tila: kiinni"; } qDebug() << "signaali verhojen tilasta lähetetty"; qDebug() << "HUOM! Signaalilla ei vastaanottajaa"; emit verhojenTila(m_onkoVerhotAuki); }
[ "ma@tester.test" ]
ma@tester.test
54e89595e17809e8303953daa842d1595cde56e8
21553f6afd6b81ae8403549467230cdc378f32c9
/arm/cortex/Freescale/MK64F12/include/arch/reg/rfvbat.hpp
c8b04b656c94d6ba415c8390925868ee38870cc2
[]
no_license
digint/openmptl-reg-arm-cortex
3246b68dcb60d4f7c95a46423563cab68cb02b5e
88e105766edc9299348ccc8d2ff7a9c34cddacd3
refs/heads/master
2021-07-18T19:56:42.569685
2017-10-26T11:11:35
2017-10-26T11:11:35
108,407,162
3
1
null
null
null
null
UTF-8
C++
false
false
1,869
hpp
/* * OpenMPTL - C++ Microprocessor Template Library * * This program is a derivative representation of a CMSIS System View * Description (SVD) file, and is subject to the corresponding license * (see "Freescale CMSIS-SVD License Agreement.pdf" in the parent directory). * * 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. */ //////////////////////////////////////////////////////////////////////// // // Import from CMSIS-SVD: "Freescale/MK64F12.svd" // // vendor: Freescale Semiconductor, Inc. // vendorID: Freescale // name: MK64F12 // series: Kinetis_K // version: 1.6 // description: MK64F12 Freescale Microcontroller // -------------------------------------------------------------------- // // C++ Header file, containing architecture specific register // declarations for use in OpenMPTL. It has been converted directly // from a CMSIS-SVD file. // // https://digint.ch/openmptl // https://github.com/posborne/cmsis-svd // #ifndef ARCH_REG_RFVBAT_HPP_INCLUDED #define ARCH_REG_RFVBAT_HPP_INCLUDED #warning "using untested register declarations" #include <register.hpp> namespace mptl { /** * VBAT register file */ struct RFVBAT { static constexpr reg_addr_t base_addr = 0x4003e000; /** * VBAT register file register */ struct REG%s : public reg< uint32_t, base_addr + 0, rw, 0 > { using type = reg< uint32_t, base_addr + 0, rw, 0 >; using LL = regbits< type, 0, 8 >; /**< Low lower byte */ using LH = regbits< type, 8, 8 >; /**< Low higher byte */ using HL = regbits< type, 16, 8 >; /**< High lower byte */ using HH = regbits< type, 24, 8 >; /**< High higher byte */ }; }; } // namespace mptl #endif // ARCH_REG_RFVBAT_HPP_INCLUDED
[ "axel@tty0.ch" ]
axel@tty0.ch
1ff1f57642c2c8ce9157e511a577f124c56a5bc6
a55b87a1e0b9ef1b49b81799a1eadef24779fe16
/Chapter 02 Linked lists/Question 06/C++/stdafx.cpp
16ac57c3c069997e18f7830483a3ae6ab018cca6
[]
no_license
anesin/ctci
385b5e42dcdb85eaff7387ca0252b7295d9c12b3
bac9b8c352dd13b9b2dfa42e318954887d93681a
refs/heads/master
2021-01-22T17:57:30.800645
2017-03-16T01:44:45
2017-03-16T01:44:45
85,046,421
0
0
null
null
null
null
UTF-8
C++
false
false
286
cpp
// stdafx.cpp : source file that includes just the standard includes // Q-02-06.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ "anesiner@gmail.com" ]
anesiner@gmail.com
55b4245189befab2d5fac383f4010bea90bfc884
2729d7cc7089c27ecf9c177a4917dfe59d1311ba
/src/example.cpp
1273a6791e6cc43ed0f1af1aab5c6fa8499b74bd
[]
no_license
COLAB2/baxter_pcl
1513a991c6f5d7ddfa5a0851ac97aebd0544efef
f5dce389ae602085882a98abf5270ff73038c94f
refs/heads/master
2021-03-22T05:19:51.746721
2018-08-06T19:39:28
2018-08-06T19:39:28
112,775,454
1
1
null
null
null
null
UTF-8
C++
false
false
863
cpp
#include <ros/ros.h> // PCL specific includes #include <sensor_msgs/PointCloud2.h> #include <pcl_conversions/pcl_conversions.h> #include <pcl/point_cloud.h> #include <pcl/point_types.h> ros::Publisher pub; void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input) { // Create a container for the data. sensor_msgs::PointCloud2 output; // Do data processing here... output = *input; // Publish the data. pub.publish (output); } int main (int argc, char** argv) { // Initialize ROS ros::init (argc, argv, "my_pcl_tutorial"); ros::NodeHandle nh; // Create a ROS subscriber for the input point cloud ros::Subscriber sub = nh.subscribe ("/camera/depth_registered/points", 1, cloud_cb); // Create a ROS publisher for the output point cloud pub = nh.advertise<sensor_msgs::PointCloud2> ("/output", 1); // Spin ros::spin (); }
[ "gogineni.14@wright.edu" ]
gogineni.14@wright.edu
00b072559ca2f88bc16ce1d0d10c9791b99f9dd9
6f998bc0963dc3dfc140475a756b45d18a712a1e
/Source/AnimationLib/DoorOpenIdleState.h
93fdae5bf9ad7d3da3191fc3d4c1be89606c5fbc
[]
no_license
iomeone/PudgeNSludge
d4062529053c4c6d31430e74be20e86f9d04e126
55160d94f9ef406395d26a60245df1ca3166b08d
refs/heads/master
2021-06-11T09:45:04.035247
2016-05-25T05:57:08
2016-05-25T05:57:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
537
h
#ifndef DOOROPENIDLESTATE_H_ #define DOOROPENIDLESTATE_H_ #include "State.h" __declspec(align(32)) class DoorOpenIdleState : public State { private: DoorOpenIdleState(void){} DoorOpenIdleState( const DoorOpenIdleState& ) {} const DoorOpenIdleState& operator = (const DoorOpenIdleState& ) {} public: ~DoorOpenIdleState(void); static DoorOpenIdleState* GetState(); void Enter(CComponent_Animation* pComponent); void Execute(CComponent_Animation* pComponent, float fTime); void Exit(CComponent_Animation* pComponent); }; #endif
[ "ethanthecrazy@gmail.com" ]
ethanthecrazy@gmail.com
2ac839a80c75cd23ba9069c14b8ca62d3393392a
ce36a853f193e8a3d16570c3ebd86ea84696bc78
/core/os/winmain.cpp
ccce836aa14bb85a02adbdd78cfe87340643ea72
[ "Unlicense" ]
permissive
seanlim/ponyo
d93faf1150602ef86344250471414d80d928dfef
ebb44b92c9e49803bda5ed355b98d6f6fda13f23
refs/heads/master
2020-04-01T14:55:41.129001
2019-10-07T03:23:07
2019-10-07T03:23:07
153,313,917
0
0
null
null
null
null
UTF-8
C++
false
false
3,401
cpp
#define _CRTDBG_MAP_ALLOC #define WIN32_LEAN_AND_MEAN #include <crtdbg.h> #include <stdlib.h> #include <windows.h> #include "common.h" #include "graphics.h" #include "main.h" #include "random.h" bool AnotherInstance() { HANDLE ourMutex = CreateMutex(NULL, true, "process0"); return GetLastError() == ERROR_ALREADY_EXISTS; } int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int); bool CreateMainWindow(HWND&, HINSTANCE, int); LRESULT WINAPI WinProc(HWND, UINT, WPARAM, LPARAM); Game* game; HWND hwnd = NULL; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { #if defined(DEBUG) | defined(DEBUG) _crtDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif MSG msg; game = new Main(); if (AnotherInstance()) return false; if (!CreateMainWindow(hwnd, hInstance, nCmdShow)) return false; try { game->initialise(hwnd); int done = 0; while (!done) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // Look for quit message if (msg.message == WM_QUIT) done = 1; // Decode and pass messages on to WinProc TranslateMessage(&msg); DispatchMessage(&msg); } else { game->run(hwnd); } } safeDelete(game); return msg.wParam; } catch (const GameError& err) { game->deleteAll(); DestroyWindow(hwnd); MessageBox(NULL, err.getMessage(), "Error", MB_OK); } catch (...) { game->deleteAll(); DestroyWindow(hwnd); MessageBox(NULL, "Something is not quite right...", "Error", MB_OK); } safeDelete(game); return 0; } LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { short nVirtKey; const short PRESSED = (short)0x8000; TEXTMETRIC tm; DWORD chWidth = 40; DWORD chHeight = 40; switch (msg) { case WM_CREATE: return 0; case WM_DESTROY: PostQuitMessage(0); return 0; default: // Send message to game game->handleInput(wParam, lParam, msg); DefWindowProc(hWnd, msg, wParam, lParam); } } bool CreateMainWindow(HWND& hwnd, HINSTANCE hInstance, int nCmdShow) { WNDCLASSEX wcx; wcx.cbSize = sizeof(wcx); wcx.style = CS_HREDRAW | CS_VREDRAW; wcx.lpfnWndProc = WinProc; wcx.cbClsExtra = 0; wcx.cbWndExtra = 0; wcx.hInstance = hInstance; wcx.hIcon = NULL; wcx.hCursor = LoadCursor(NULL, IDC_ARROW); wcx.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wcx.lpszMenuName = NULL; wcx.lpszClassName = CLASS_NAME; wcx.hIconSm = NULL; // Register the window class. // RegisterClassEx returns 0 on error. if (RegisterClassEx(&wcx) == 0) // if error return false; DWORD windowStyle; if (FULLSCREEN) windowStyle = WS_EX_TOPMOST | WS_VISIBLE | WS_POPUP; else windowStyle = WS_OVERLAPPEDWINDOW; // Create window hwnd = CreateWindow(CLASS_NAME, GAME_TITLE, windowStyle, CW_USEDEFAULT, CW_USEDEFAULT, GAME_WIDTH, GAME_HEIGHT, (HWND)NULL, (HMENU)NULL, hInstance, (LPVOID)NULL); if (!hwnd) return false; if (!FULLSCREEN) { RECT clientRect; GetClientRect(hwnd, &clientRect); MoveWindow(hwnd, clientRect.left + (GAME_WIDTH / 2), clientRect.top / 2, GAME_WIDTH + (GAME_WIDTH - clientRect.right), GAME_HEIGHT + (GAME_HEIGHT - clientRect.bottom), true); } ShowWindow(hwnd, nCmdShow); return true; }
[ "lim_kai_xiang_sean@s2013.sst.edu.sg" ]
lim_kai_xiang_sean@s2013.sst.edu.sg
a81c889f508a80b7d3b44d9aefab9d3d414305ad
60bcabba9e16d91165a6b1f7368aae813231cc07
/src/treelike/action/fade_out.cpp
7f79b376d8c97692e17a2943bb5313e83e20ddc1
[]
no_license
yumayo/treelike
b5bd0d42737fc2486860266a8e8c34ad8ffb7d93
12463256b5b4da10a8a1bcd5a9dc52a8974d23b8
refs/heads/master
2021-06-20T08:31:49.495890
2017-07-30T17:40:56
2017-07-30T17:40:56
88,397,093
0
0
null
null
null
null
UTF-8
C++
false
false
618
cpp
#include <treelike/action/fade_out.h> #include <treelike/node.h> using namespace cinder; namespace treelike { namespace action { CREATE_CPP( fade_out, float duration ) { CREATE( fade_out, duration ); } bool fade_out::init( float duration ) { finite_time_action::init( duration ); return true; } void fade_out::setup( ) { _opacity = _target->get_opacity( ); } void fade_out::step( float t ) { t = clamp( t, 0.0F, 1.0F ); auto const to = 0.0F; auto const from = _opacity; auto const temp = ease_liner( t, from, to ); _target->set_opacity( temp ); } } }
[ "scha-taz0@outlook.jp" ]
scha-taz0@outlook.jp
a1419c636b8a14fdc17fabc283268321529f7c9d
40546e4371261bfd7a0643dd9da4d751161baa3e
/CS Lab practice/Lab9/cs163_graph.h
45bc6598d869fbae63ffa2855423dd301902de57
[]
no_license
tochiton/Data-Structures
f7c9111e55c38a0b886f03a75233d80b9e8d4403
fbe4c9e20881c501e0c221260c9c0c6e94182546
refs/heads/master
2020-12-24T08:42:47.228659
2016-11-09T22:37:40
2016-11-09T22:37:40
73,325,007
0
0
null
null
null
null
UTF-8
C++
false
false
1,122
h
#include "cs163_entry.h" //Compare these structs to the ones in your answers on Page #1 struct vertex { journal_entry * entry; //NULL, if the vertex isn't set struct node * head; //edge list }; struct node { vertex * adjacent; //Additional data would be needed //for a weighted graph node * next; }; class table { public: /* Implement these three functions for this lab */ table(int size=5); //Step 1 int insert_vertex(const journal_entry & to_add); //Step 2 int find_location(char * key_value); //Step 3 int insert_edge(char * current_vertex, char * to_attach); //Step 4 int display_adjacent(char * key_value); //Challenge /* These functions are ALREADY implemented for you */ ~table(void); // Already implemented in methods.o int display_all(void) const; /*This is already implemented */ private: vertex * adjacency_list; int list_size; };
[ "tochi.caraballo@gmail.com" ]
tochi.caraballo@gmail.com
f1cbf178edac5e1432034c1eaf7a8afb626663ea
4264133677f7525f9a51054d6ccbf51f6599eccc
/AVFileParse/FLV_Parse/TagScript.h
9bd9f73b1f8bca4d7b5c8c17c4f7de5eb89ee4ab
[]
no_license
peichangliang123/ToolBank
6d6c4e31bddb233d94df6f4d145d836e7306832d
599beaf80a7f384a82a540c6e4e184b488e4c236
refs/heads/master
2023-05-27T18:54:10.794257
2019-10-19T03:18:49
2019-10-19T03:18:49
null
0
0
null
null
null
null
ISO-8859-7
C++
false
false
201
h
#pragma once #include "TagType.h" #include "amf.h" #include <vector> class CTagScript : public CTagType { public: CTagScript(); ~CTagScript(); // ΟΤΚΎ; virtual void Display(); };
[ "yuanda_yu@sina.com" ]
yuanda_yu@sina.com
cb2037fae9af0fa44a905b25173e29e431365787
8cf763c4c29db100d15f2560953c6e6cbe7a5fd4
/src/qt/qtbase/src/gui/text/qtextimagehandler.cpp
37c18e3624c5db67e7ab8880ceb2798952f333ea
[ "BSD-3-Clause", "LGPL-2.0-or-later", "LGPL-2.1-only", "GFDL-1.3-only", "Qt-LGPL-exception-1.1", "LicenseRef-scancode-digia-qt-commercial", "LGPL-3.0-only", "GPL-3.0-only", "LicenseRef-scancode-digia-qt-preview", "LGPL-2.1-or-later", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-refe...
permissive
chihlee/phantomjs
69d6bbbf1c9199a78e82ae44af072aca19c139c3
644e0b3a6c9c16bcc6f7ce2c24274bf7d764f53c
refs/heads/master
2021-01-19T13:49:41.265514
2018-06-15T22:48:11
2018-06-15T22:48:11
82,420,380
0
0
BSD-3-Clause
2018-06-15T22:48:12
2017-02-18T22:34:48
C++
UTF-8
C++
false
false
8,866
cpp
/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qtextimagehandler_p.h" #include <qguiapplication.h> #include <qtextformat.h> #include <qpainter.h> #include <qdebug.h> #include <private/qtextengine_p.h> #include <qpalette.h> #include <qthread.h> QT_BEGIN_NAMESPACE static QString resolveFileName(QString fileName, QUrl *url, qreal targetDevicePixelRatio) { // We might use the fileName for loading if url loading fails // try to make sure it is a valid file path. // Also, QFile{Info}::exists works only on filepaths (not urls) if (url->isValid()) { if (url->scheme() == QLatin1Literal("qrc")) { fileName = fileName.right(fileName.length() - 3); } else if (url->scheme() == QLatin1Literal("file")) { fileName = url->toLocalFile(); } } if (targetDevicePixelRatio <= 1.0) return fileName; // try to find a 2x version const int dotIndex = fileName.lastIndexOf(QLatin1Char('.')); if (dotIndex != -1) { QString at2xfileName = fileName; at2xfileName.insert(dotIndex, QStringLiteral("@2x")); if (QFile::exists(at2xfileName)) { fileName = at2xfileName; *url = QUrl(fileName); } } return fileName; } static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, const qreal devicePixelRatio = 1.0) { QPixmap pm; QString name = format.name(); if (name.startsWith(QLatin1String(":/"))) // auto-detect resources and convert them to url name.prepend(QLatin1String("qrc")); QUrl url = QUrl(name); name = resolveFileName(name, &url, devicePixelRatio); const QVariant data = doc->resource(QTextDocument::ImageResource, url); if (data.type() == QVariant::Pixmap || data.type() == QVariant::Image) { pm = qvariant_cast<QPixmap>(data); } else if (data.type() == QVariant::ByteArray) { pm.loadFromData(data.toByteArray()); } if (pm.isNull()) { #if 0 QString context; // ### Qt5 QTextBrowser *browser = qobject_cast<QTextBrowser *>(doc->parent()); if (browser) context = browser->source().toString(); #endif // try direct loading QImage img; if (name.isEmpty() || !img.load(name)) return QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/file-16.png")); pm = QPixmap::fromImage(img); doc->addResource(QTextDocument::ImageResource, url, pm); } if (name.contains(QStringLiteral("@2x"))) pm.setDevicePixelRatio(2.0); return pm; } static QSize getPixmapSize(QTextDocument *doc, const QTextImageFormat &format) { QPixmap pm; const bool hasWidth = format.hasProperty(QTextFormat::ImageWidth); const int width = qRound(format.width()); const bool hasHeight = format.hasProperty(QTextFormat::ImageHeight); const int height = qRound(format.height()); QSize size(width, height); if (!hasWidth || !hasHeight) { pm = getPixmap(doc, format); const int pmWidth = pm.width() / pm.devicePixelRatio(); const int pmHeight = pm.height() / pm.devicePixelRatio(); if (!hasWidth) { if (!hasHeight) size.setWidth(pmWidth); else size.setWidth(qRound(height * (pmWidth / (qreal) pmHeight))); } if (!hasHeight) { if (!hasWidth) size.setHeight(pmHeight); else size.setHeight(qRound(width * (pmHeight / (qreal) pmWidth))); } } qreal scale = 1.0; QPaintDevice *pdev = doc->documentLayout()->paintDevice(); if (pdev) { if (pm.isNull()) pm = getPixmap(doc, format); if (!pm.isNull()) scale = qreal(pdev->logicalDpiY()) / qreal(qt_defaultDpi()); } size *= scale; return size; } static QImage getImage(QTextDocument *doc, const QTextImageFormat &format, const qreal devicePixelRatio = 1.0) { QImage image; QString name = format.name(); if (name.startsWith(QLatin1String(":/"))) // auto-detect resources name.prepend(QLatin1String("qrc")); QUrl url = QUrl(name); name = resolveFileName(name, &url, devicePixelRatio); const QVariant data = doc->resource(QTextDocument::ImageResource, url); if (data.type() == QVariant::Image) { image = qvariant_cast<QImage>(data); } else if (data.type() == QVariant::ByteArray) { image.loadFromData(data.toByteArray()); } if (image.isNull()) { #if 0 QString context; // ### Qt5 QTextBrowser *browser = qobject_cast<QTextBrowser *>(doc->parent()); if (browser) context = browser->source().toString(); #endif // try direct loading if (name.isEmpty() || !image.load(name)) return QImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/file-16.png")); doc->addResource(QTextDocument::ImageResource, url, image); } if (name.contains(QStringLiteral("@2x"))) image.setDevicePixelRatio(2.0); return image; } static QSize getImageSize(QTextDocument *doc, const QTextImageFormat &format) { QImage image; const bool hasWidth = format.hasProperty(QTextFormat::ImageWidth); const int width = qRound(format.width()); const bool hasHeight = format.hasProperty(QTextFormat::ImageHeight); const int height = qRound(format.height()); QSize size(width, height); if (!hasWidth || !hasHeight) { image = getImage(doc, format); if (!hasWidth) size.setWidth(image.width() / image.devicePixelRatio()); if (!hasHeight) size.setHeight(image.height() / image.devicePixelRatio()); } qreal scale = 1.0; QPaintDevice *pdev = doc->documentLayout()->paintDevice(); if (pdev) { if (image.isNull()) image = getImage(doc, format); if (!image.isNull()) scale = qreal(pdev->logicalDpiY()) / qreal(qt_defaultDpi()); } size *= scale; return size; } QTextImageHandler::QTextImageHandler(QObject *parent) : QObject(parent) { } QSizeF QTextImageHandler::intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) { Q_UNUSED(posInDocument) const QTextImageFormat imageFormat = format.toImageFormat(); if (QCoreApplication::instance()->thread() != QThread::currentThread()) return getImageSize(doc, imageFormat); return getPixmapSize(doc, imageFormat); } QImage QTextImageHandler::image(QTextDocument *doc, const QTextImageFormat &imageFormat) { Q_ASSERT(doc != 0); return getImage(doc, imageFormat); } void QTextImageHandler::drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) { Q_UNUSED(posInDocument) const QTextImageFormat imageFormat = format.toImageFormat(); if (QCoreApplication::instance()->thread() != QThread::currentThread()) { const QImage image = getImage(doc, imageFormat, p->device()->devicePixelRatio()); p->drawImage(rect, image, image.rect()); } else { const QPixmap pixmap = getPixmap(doc, imageFormat, p->device()->devicePixelRatio()); p->drawPixmap(rect, pixmap, pixmap.rect()); } } QT_END_NAMESPACE
[ "ariya.hidayat@gmail.com" ]
ariya.hidayat@gmail.com
c8118d3cc753ddfe8e52550037f3b660bbd6fc30
e0281740c6d5ed8046410ea220d18ba18ac6869f
/third_party/fmt/include/fmt/color.h
4dbb37d339d08894141576f9d9db0f9e1973cbbb
[ "MIT", "BSD-2-Clause", "Python-2.0", "BSD-3-Clause", "LicenseRef-scancode-free-unknown" ]
permissive
killvxk/icebox
fe34e88a97f674671965f6d4bee8e8a84ddcbbda
463dd01236aea40ff6312af1881bf9b915765794
refs/heads/master
2020-06-03T07:50:23.511752
2019-07-13T09:40:22
2019-07-13T09:40:22
191,500,707
0
2
MIT
2019-07-13T09:40:23
2019-06-12T05:01:18
C++
UTF-8
C++
false
false
18,557
h
// Formatting library for C++ - color support // // Copyright (c) 2018 - present, Victor Zverovich and fmt contributors // All rights reserved. // // For the license information refer to format.h. #ifndef FMT_COLOR_H_ #define FMT_COLOR_H_ #include "format.h" FMT_BEGIN_NAMESPACE #ifdef FMT_DEPRECATED_COLORS // color and (v)print_colored are deprecated. enum color { black, red, green, yellow, blue, magenta, cyan, white }; FMT_API void vprint_colored(color c, string_view format, format_args args); FMT_API void vprint_colored(color c, wstring_view format, wformat_args args); template <typename... Args> inline void print_colored(color c, string_view format_str, const Args & ... args) { vprint_colored(c, format_str, make_format_args(args...)); } template <typename... Args> inline void print_colored(color c, wstring_view format_str, const Args & ... args) { vprint_colored(c, format_str, make_format_args<wformat_context>(args...)); } inline void vprint_colored(color c, string_view format, format_args args) { char escape[] = "\x1b[30m"; escape[3] = static_cast<char>('0' + c); std::fputs(escape, stdout); vprint(format, args); std::fputs(internal::data::RESET_COLOR, stdout); } inline void vprint_colored(color c, wstring_view format, wformat_args args) { wchar_t escape[] = L"\x1b[30m"; escape[3] = static_cast<wchar_t>('0' + c); std::fputws(escape, stdout); vprint(format, args); std::fputws(internal::data::WRESET_COLOR, stdout); } #else enum class color : uint32_t { alice_blue = 0xF0F8FF, // rgb(240,248,255) antique_white = 0xFAEBD7, // rgb(250,235,215) aqua = 0x00FFFF, // rgb(0,255,255) aquamarine = 0x7FFFD4, // rgb(127,255,212) azure = 0xF0FFFF, // rgb(240,255,255) beige = 0xF5F5DC, // rgb(245,245,220) bisque = 0xFFE4C4, // rgb(255,228,196) black = 0x000000, // rgb(0,0,0) blanched_almond = 0xFFEBCD, // rgb(255,235,205) blue = 0x0000FF, // rgb(0,0,255) blue_violet = 0x8A2BE2, // rgb(138,43,226) brown = 0xA52A2A, // rgb(165,42,42) burly_wood = 0xDEB887, // rgb(222,184,135) cadet_blue = 0x5F9EA0, // rgb(95,158,160) chartreuse = 0x7FFF00, // rgb(127,255,0) chocolate = 0xD2691E, // rgb(210,105,30) coral = 0xFF7F50, // rgb(255,127,80) cornflower_blue = 0x6495ED, // rgb(100,149,237) cornsilk = 0xFFF8DC, // rgb(255,248,220) crimson = 0xDC143C, // rgb(220,20,60) cyan = 0x00FFFF, // rgb(0,255,255) dark_blue = 0x00008B, // rgb(0,0,139) dark_cyan = 0x008B8B, // rgb(0,139,139) dark_golden_rod = 0xB8860B, // rgb(184,134,11) dark_gray = 0xA9A9A9, // rgb(169,169,169) dark_green = 0x006400, // rgb(0,100,0) dark_khaki = 0xBDB76B, // rgb(189,183,107) dark_magenta = 0x8B008B, // rgb(139,0,139) dark_olive_green = 0x556B2F, // rgb(85,107,47) dark_orange = 0xFF8C00, // rgb(255,140,0) dark_orchid = 0x9932CC, // rgb(153,50,204) dark_red = 0x8B0000, // rgb(139,0,0) dark_salmon = 0xE9967A, // rgb(233,150,122) dark_sea_green = 0x8FBC8F, // rgb(143,188,143) dark_slate_blue = 0x483D8B, // rgb(72,61,139) dark_slate_gray = 0x2F4F4F, // rgb(47,79,79) dark_turquoise = 0x00CED1, // rgb(0,206,209) dark_violet = 0x9400D3, // rgb(148,0,211) deep_pink = 0xFF1493, // rgb(255,20,147) deep_sky_blue = 0x00BFFF, // rgb(0,191,255) dim_gray = 0x696969, // rgb(105,105,105) dodger_blue = 0x1E90FF, // rgb(30,144,255) fire_brick = 0xB22222, // rgb(178,34,34) floral_white = 0xFFFAF0, // rgb(255,250,240) forest_green = 0x228B22, // rgb(34,139,34) fuchsia = 0xFF00FF, // rgb(255,0,255) gainsboro = 0xDCDCDC, // rgb(220,220,220) ghost_white = 0xF8F8FF, // rgb(248,248,255) gold = 0xFFD700, // rgb(255,215,0) golden_rod = 0xDAA520, // rgb(218,165,32) gray = 0x808080, // rgb(128,128,128) green = 0x008000, // rgb(0,128,0) green_yellow = 0xADFF2F, // rgb(173,255,47) honey_dew = 0xF0FFF0, // rgb(240,255,240) hot_pink = 0xFF69B4, // rgb(255,105,180) indian_red = 0xCD5C5C, // rgb(205,92,92) indigo = 0x4B0082, // rgb(75,0,130) ivory = 0xFFFFF0, // rgb(255,255,240) khaki = 0xF0E68C, // rgb(240,230,140) lavender = 0xE6E6FA, // rgb(230,230,250) lavender_blush = 0xFFF0F5, // rgb(255,240,245) lawn_green = 0x7CFC00, // rgb(124,252,0) lemon_chiffon = 0xFFFACD, // rgb(255,250,205) light_blue = 0xADD8E6, // rgb(173,216,230) light_coral = 0xF08080, // rgb(240,128,128) light_cyan = 0xE0FFFF, // rgb(224,255,255) light_golden_rod_yellow = 0xFAFAD2, // rgb(250,250,210) light_gray = 0xD3D3D3, // rgb(211,211,211) light_green = 0x90EE90, // rgb(144,238,144) light_pink = 0xFFB6C1, // rgb(255,182,193) light_salmon = 0xFFA07A, // rgb(255,160,122) light_sea_green = 0x20B2AA, // rgb(32,178,170) light_sky_blue = 0x87CEFA, // rgb(135,206,250) light_slate_gray = 0x778899, // rgb(119,136,153) light_steel_blue = 0xB0C4DE, // rgb(176,196,222) light_yellow = 0xFFFFE0, // rgb(255,255,224) lime = 0x00FF00, // rgb(0,255,0) lime_green = 0x32CD32, // rgb(50,205,50) linen = 0xFAF0E6, // rgb(250,240,230) magenta = 0xFF00FF, // rgb(255,0,255) maroon = 0x800000, // rgb(128,0,0) medium_aquamarine = 0x66CDAA, // rgb(102,205,170) medium_blue = 0x0000CD, // rgb(0,0,205) medium_orchid = 0xBA55D3, // rgb(186,85,211) medium_purple = 0x9370DB, // rgb(147,112,219) medium_sea_green = 0x3CB371, // rgb(60,179,113) medium_slate_blue = 0x7B68EE, // rgb(123,104,238) medium_spring_green = 0x00FA9A, // rgb(0,250,154) medium_turquoise = 0x48D1CC, // rgb(72,209,204) medium_violet_red = 0xC71585, // rgb(199,21,133) midnight_blue = 0x191970, // rgb(25,25,112) mint_cream = 0xF5FFFA, // rgb(245,255,250) misty_rose = 0xFFE4E1, // rgb(255,228,225) moccasin = 0xFFE4B5, // rgb(255,228,181) navajo_white = 0xFFDEAD, // rgb(255,222,173) navy = 0x000080, // rgb(0,0,128) old_lace = 0xFDF5E6, // rgb(253,245,230) olive = 0x808000, // rgb(128,128,0) olive_drab = 0x6B8E23, // rgb(107,142,35) orange = 0xFFA500, // rgb(255,165,0) orange_red = 0xFF4500, // rgb(255,69,0) orchid = 0xDA70D6, // rgb(218,112,214) pale_golden_rod = 0xEEE8AA, // rgb(238,232,170) pale_green = 0x98FB98, // rgb(152,251,152) pale_turquoise = 0xAFEEEE, // rgb(175,238,238) pale_violet_red = 0xDB7093, // rgb(219,112,147) papaya_whip = 0xFFEFD5, // rgb(255,239,213) peach_puff = 0xFFDAB9, // rgb(255,218,185) peru = 0xCD853F, // rgb(205,133,63) pink = 0xFFC0CB, // rgb(255,192,203) plum = 0xDDA0DD, // rgb(221,160,221) powder_blue = 0xB0E0E6, // rgb(176,224,230) purple = 0x800080, // rgb(128,0,128) rebecca_purple = 0x663399, // rgb(102,51,153) red = 0xFF0000, // rgb(255,0,0) rosy_brown = 0xBC8F8F, // rgb(188,143,143) royal_blue = 0x4169E1, // rgb(65,105,225) saddle_brown = 0x8B4513, // rgb(139,69,19) salmon = 0xFA8072, // rgb(250,128,114) sandy_brown = 0xF4A460, // rgb(244,164,96) sea_green = 0x2E8B57, // rgb(46,139,87) sea_shell = 0xFFF5EE, // rgb(255,245,238) sienna = 0xA0522D, // rgb(160,82,45) silver = 0xC0C0C0, // rgb(192,192,192) sky_blue = 0x87CEEB, // rgb(135,206,235) slate_blue = 0x6A5ACD, // rgb(106,90,205) slate_gray = 0x708090, // rgb(112,128,144) snow = 0xFFFAFA, // rgb(255,250,250) spring_green = 0x00FF7F, // rgb(0,255,127) steel_blue = 0x4682B4, // rgb(70,130,180) tan = 0xD2B48C, // rgb(210,180,140) teal = 0x008080, // rgb(0,128,128) thistle = 0xD8BFD8, // rgb(216,191,216) tomato = 0xFF6347, // rgb(255,99,71) turquoise = 0x40E0D0, // rgb(64,224,208) violet = 0xEE82EE, // rgb(238,130,238) wheat = 0xF5DEB3, // rgb(245,222,179) white = 0xFFFFFF, // rgb(255,255,255) white_smoke = 0xF5F5F5, // rgb(245,245,245) yellow = 0xFFFF00, // rgb(255,255,0) yellow_green = 0x9ACD32 // rgb(154,205,50) }; // enum class color enum class emphasis : uint8_t { bold = 1, italic = 1 << 1, underline = 1 << 2, strikethrough = 1 << 3 }; // enum class emphasis // rgb is a struct for red, green and blue colors. // We use rgb as name because some editors will show it as color direct in the // editor. struct rgb { FMT_CONSTEXPR_DECL rgb() : r(0), g(0), b(0) {} FMT_CONSTEXPR_DECL rgb(uint8_t r_, uint8_t g_, uint8_t b_) : r(r_), g(g_), b(b_) {} FMT_CONSTEXPR_DECL rgb(uint32_t hex) : r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b((hex) & 0xFF) {} FMT_CONSTEXPR_DECL rgb(color hex) : r((uint32_t(hex) >> 16) & 0xFF), g((uint32_t(hex) >> 8) & 0xFF), b(uint32_t(hex) & 0xFF) {} uint8_t r; uint8_t g; uint8_t b; }; // Experimental text formatting support. class text_style { public: FMT_CONSTEXPR_DECL text_style(emphasis em) FMT_NOEXCEPT : set_foreground_color(), set_background_color(), ems(em) {} FMT_CONSTEXPR_DECL text_style &operator|=(const text_style &rhs) FMT_NOEXCEPT { if (!set_foreground_color) { set_foreground_color = rhs.set_foreground_color; foreground_color = rhs.foreground_color; } else if (rhs.set_foreground_color) { foreground_color.r |= rhs.foreground_color.r; foreground_color.g |= rhs.foreground_color.g; foreground_color.b |= rhs.foreground_color.b; } if (!set_background_color) { set_background_color = rhs.set_background_color; background_color = rhs.background_color; } else if (rhs.set_background_color) { background_color.r |= rhs.background_color.r; background_color.g |= rhs.background_color.g; background_color.b |= rhs.background_color.b; } ems = static_cast<emphasis>(static_cast<uint8_t>(ems) | static_cast<uint8_t>(rhs.ems)); return *this; } friend FMT_CONSTEXPR_DECL text_style operator|(text_style lhs, const text_style &rhs) FMT_NOEXCEPT { return lhs |= rhs; } FMT_CONSTEXPR_DECL text_style &operator&=(const text_style &rhs) FMT_NOEXCEPT { if (!set_foreground_color) { set_foreground_color = rhs.set_foreground_color; foreground_color = rhs.foreground_color; } else if (rhs.set_foreground_color) { foreground_color.r &= rhs.foreground_color.r; foreground_color.g &= rhs.foreground_color.g; foreground_color.b &= rhs.foreground_color.b; } if (!set_background_color) { set_background_color = rhs.set_background_color; background_color = rhs.background_color; } else if (rhs.set_background_color) { background_color.r &= rhs.background_color.r; background_color.g &= rhs.background_color.g; background_color.b &= rhs.background_color.b; } ems = static_cast<emphasis>(static_cast<uint8_t>(ems) & static_cast<uint8_t>(rhs.ems)); return *this; } friend FMT_CONSTEXPR_DECL text_style operator&(text_style lhs, const text_style &rhs) FMT_NOEXCEPT { return lhs &= rhs; } FMT_CONSTEXPR_DECL bool has_foreground() const FMT_NOEXCEPT { return set_foreground_color; } FMT_CONSTEXPR_DECL bool has_background() const FMT_NOEXCEPT { return set_background_color; } FMT_CONSTEXPR_DECL bool has_emphasis() const FMT_NOEXCEPT { return static_cast<uint8_t>(ems) != 0; } FMT_CONSTEXPR_DECL rgb get_foreground() const FMT_NOEXCEPT { assert(has_foreground() && "no foreground specified for this style"); return foreground_color; } FMT_CONSTEXPR_DECL rgb get_background() const FMT_NOEXCEPT { assert(has_background() && "no background specified for this style"); return background_color; } FMT_CONSTEXPR emphasis get_emphasis() const FMT_NOEXCEPT { assert(has_emphasis() && "no emphasis specified for this style"); return ems; } private: FMT_CONSTEXPR_DECL text_style(bool is_foreground, rgb text_color) FMT_NOEXCEPT : set_foreground_color(), set_background_color(), ems() { if (is_foreground) { foreground_color = text_color; set_foreground_color = true; } else { background_color = text_color; set_background_color = true; } } friend FMT_CONSTEXPR_DECL text_style fg(rgb foreground) FMT_NOEXCEPT; friend FMT_CONSTEXPR_DECL text_style bg(rgb background) FMT_NOEXCEPT; rgb foreground_color; rgb background_color; bool set_foreground_color; bool set_background_color; emphasis ems; }; FMT_CONSTEXPR_DECL text_style fg(rgb foreground) FMT_NOEXCEPT { return text_style(/*is_foreground=*/true, foreground); } FMT_CONSTEXPR_DECL text_style bg(rgb background) FMT_NOEXCEPT { return text_style(/*is_foreground=*/false, background); } FMT_CONSTEXPR_DECL text_style operator|(emphasis lhs, emphasis rhs) FMT_NOEXCEPT { return text_style(lhs) | rhs; } namespace internal { template <typename Char> struct ansi_color_escape { FMT_CONSTEXPR ansi_color_escape(rgb color, const char * esc) FMT_NOEXCEPT { for (int i = 0; i < 7; i++) { buffer[i] = static_cast<Char>(esc[i]); } to_esc(color.r, buffer + 7, ';'); to_esc(color.g, buffer + 11, ';'); to_esc(color.b, buffer + 15, 'm'); buffer[19] = static_cast<Char>(0); } FMT_CONSTEXPR ansi_color_escape(emphasis em) FMT_NOEXCEPT { uint8_t em_codes[4] = {}; uint8_t em_bits = static_cast<uint8_t>(em); if (em_bits & static_cast<uint8_t>(emphasis::bold)) em_codes[0] = 1; if (em_bits & static_cast<uint8_t>(emphasis::italic)) em_codes[1] = 3; if (em_bits & static_cast<uint8_t>(emphasis::underline)) em_codes[2] = 4; if (em_bits & static_cast<uint8_t>(emphasis::strikethrough)) em_codes[3] = 9; std::size_t index = 0; for (int i = 0; i < 4; ++i) { if (!em_codes[i]) continue; buffer[index++] = static_cast<Char>('\x1b'); buffer[index++] = static_cast<Char>('['); buffer[index++] = static_cast<Char>('0' + em_codes[i]); buffer[index++] = static_cast<Char>('m'); } buffer[index++] = static_cast<Char>(0); } FMT_CONSTEXPR operator const Char *() const FMT_NOEXCEPT { return buffer; } private: Char buffer[7 + 3 * 4 + 1]; static FMT_CONSTEXPR void to_esc(uint8_t c, Char *out, char delimiter) FMT_NOEXCEPT { out[0] = static_cast<Char>('0' + c / 100); out[1] = static_cast<Char>('0' + c / 10 % 10); out[2] = static_cast<Char>('0' + c % 10); out[3] = static_cast<Char>(delimiter); } }; template <typename Char> FMT_CONSTEXPR ansi_color_escape<Char> make_foreground_color(rgb color) FMT_NOEXCEPT { return ansi_color_escape<Char>(color, internal::data::FOREGROUND_COLOR); } template <typename Char> FMT_CONSTEXPR ansi_color_escape<Char> make_background_color(rgb color) FMT_NOEXCEPT { return ansi_color_escape<Char>(color, internal::data::BACKGROUND_COLOR); } template <typename Char> FMT_CONSTEXPR ansi_color_escape<Char> make_emphasis(emphasis em) FMT_NOEXCEPT { return ansi_color_escape<Char>(em); } template <typename Char> inline void fputs(const Char *chars, FILE *stream) FMT_NOEXCEPT { std::fputs(chars, stream); } template <> inline void fputs<wchar_t>(const wchar_t *chars, FILE *stream) FMT_NOEXCEPT { std::fputws(chars, stream); } template <typename Char> inline void reset_color(FILE *stream) FMT_NOEXCEPT { fputs(internal::data::RESET_COLOR, stream); } template <> inline void reset_color<wchar_t>(FILE *stream) FMT_NOEXCEPT { fputs(internal::data::WRESET_COLOR, stream); } } // namespace internal template < typename S, typename Char = typename internal::char_t<S>::type> void vprint(const text_style &tf, const S &format, basic_format_args<typename buffer_context<Char>::type> args) { if (tf.has_emphasis()) internal::fputs<Char>(internal::make_emphasis<Char>(tf.get_emphasis()), stdout); if (tf.has_foreground()) internal::fputs<Char>( internal::make_foreground_color<Char>(tf.get_foreground()), stdout); if (tf.has_background()) internal::fputs<Char>( internal::make_background_color<Char>(tf.get_background()), stdout); vprint(format, args); internal::reset_color<Char>(stdout); } /** Formats a string and prints it to stdout using ANSI escape sequences to specify text formatting. Example: fmt::print(fmt::emphasis::bold | fg(fmt::color::red), "Elapsed time: {0:.2f} seconds", 1.23); */ template <typename String, typename... Args> typename std::enable_if<internal::is_string<String>::value>::type print(const text_style &tf, const String &format_str, const Args & ... args) { internal::check_format_string<Args...>(format_str); typedef typename internal::char_t<String>::type char_t; typedef typename buffer_context<char_t>::type context_t; format_arg_store<context_t, Args...> as{args...}; vprint(tf, format_str, basic_format_args<context_t>(as)); } #endif FMT_END_NAMESPACE #endif // FMT_COLOR_H_
[ "benoit.amiaux@gmail.com" ]
benoit.amiaux@gmail.com
1181524692ab514e994aac883767dbcc5ab29e22
7bf78a184381771d4ca77c35ce603aab36331edd
/main.cpp
46ca79bdcd67ed3683cbec293c325c325a642a5f
[]
no_license
sidit77/InputShareBT
53bbd86bb17f2bb3277e51b1c2f723e13b615281
704fc123a68289eab372eb2c772c9b18fdca3e44
refs/heads/master
2023-04-19T19:30:55.956959
2021-05-16T12:52:23
2021-05-16T12:52:23
358,184,917
1
0
null
null
null
null
UTF-8
C++
false
false
3,578
cpp
#include <QtWidgets/QApplication> #include <QPushButton> #include <QSystemTrayIcon> #include <QMenu> #include <iostream> #include <bitset> #include "inputhook.h" #include "bluetooth.h" #include "hid.h" int main(int argc, char *argv[]){ Q_INIT_RESOURCE(resources); QApplication app(argc, argv); QCoreApplication::setOrganizationName("QtProject"); QCoreApplication::setApplicationName("Application Example"); QCoreApplication::setApplicationVersion(QT_VERSION_STR); //Window window; //window.show(); QMenu trayMenu; auto* inputOption = trayMenu.addAction("Input Enabled"); inputOption->setCheckable(true); inputOption->setChecked(false); trayMenu.addAction("Quit", QApplication::instance(), &QApplication::quit); QSystemTrayIcon trayIcon; trayIcon.setIcon(QIcon(":/resources/icon.png")); trayIcon.setToolTip("Snip Snap Program"); trayIcon.setContextMenu(&trayMenu); trayIcon.show(); inputOption->setChecked(false); bt_init(); //uint8_t modifiers = 0; auto modifiers = HIDModifierKeys::None; bool canSwap = true; std::vector<HIDKeyCode> pressedKeys; InputHook::Initialize([&](auto args){ bool fresh = true; auto mod = getModifiers(args.key); if(mod != HIDModifierKeys::None){ auto old = modifiers; if(args.state == KeyState::Pressed) modifiers += mod; if(args.state == KeyState::Released) modifiers -= mod; if(modifiers == old) fresh = false; } else { auto key = getHidKeycode(args.scanCode); if(key != 0x0){ auto sv = std::find(pressedKeys.begin(), pressedKeys.end(), key); if(args.state == KeyState::Pressed){ if(sv == pressedKeys.end()) pressedKeys.push_back(key); else fresh = false; } if(args.state == KeyState::Released) pressedKeys.erase(sv); } } if(modifiers & (HIDModifierKeys::LCtrl | HIDModifierKeys::RCtrl)){ if(canSwap){ std::cout << "Swaping" << std::endl; inputOption->setChecked(!inputOption->isChecked()); canSwap = false; } } else { canSwap = true; } //TODO handle key press -> switch -> key release //std::cout << std::bitset<8>(static_cast<uint8_t>(modifiers)) << std::endl; if(!inputOption->isChecked()){ HIDKeys keys{}; for(int i = 0; i < std::min(pressedKeys.size(), {6}); i++){ keys[i] = pressedKeys[pressedKeys.size() - std::min(pressedKeys.size(), {6}) + i]; } if(fresh){ std::cout << std::bitset<8>(static_cast<uint8_t>(modifiers)); for(auto k : keys){ std::cout << " " << std::hex << +k; } std::cout <<std::endl; bt_send_char(modifiers, keys); } //if(args.state == KeyState::Pressed){ // printf("Keycode: 0x%x Scancode: Ox%x Translate: 0x%x\n", (uint32_t)args.key, args.scanCode, getHidKeycode(args.scanCode)); // //bt_send_char(static_cast<uint8_t>(modifiers), getHidKeycode(args.scanCode)); //} return false; } return true; }); auto r = QApplication::exec(); bt_destroy(); return r; }
[ "sidit77@gmail.com" ]
sidit77@gmail.com
b379d11030a4338999deeef8c8db3d740be6de53
3cf9e141cc8fee9d490224741297d3eca3f5feff
/C++ Benchmark Programs/Benchmark Files 1/classtester/autogen-sources/source-2884.cpp
84518434dcea3e8547c30bc57bd33713e6ab861d
[]
no_license
TeamVault/tauCFI
e0ac60b8106fc1bb9874adc515fc01672b775123
e677d8cc7acd0b1dd0ac0212ff8362fcd4178c10
refs/heads/master
2023-05-30T20:57:13.450360
2021-06-14T09:10:24
2021-06-14T09:10:24
154,563,655
0
1
null
null
null
null
UTF-8
C++
false
false
2,503
cpp
struct c0; void __attribute__ ((noinline)) tester0(c0* p); struct c0 { bool active0; c0() : active0(true) {} virtual ~c0() { tester0(this); active0 = false; } virtual void f0(){} }; void __attribute__ ((noinline)) tester0(c0* p) { p->f0(); } struct c1; void __attribute__ ((noinline)) tester1(c1* p); struct c1 { bool active1; c1() : active1(true) {} virtual ~c1() { tester1(this); active1 = false; } virtual void f1(){} }; void __attribute__ ((noinline)) tester1(c1* p) { p->f1(); } struct c2; void __attribute__ ((noinline)) tester2(c2* p); struct c2 { bool active2; c2() : active2(true) {} virtual ~c2() { tester2(this); active2 = false; } virtual void f2(){} }; void __attribute__ ((noinline)) tester2(c2* p) { p->f2(); } struct c3; void __attribute__ ((noinline)) tester3(c3* p); struct c3 : virtual c1, c2, c0 { bool active3; c3() : active3(true) {} virtual ~c3() { tester3(this); c0 *p0_0 = (c0*)(c3*)(this); tester0(p0_0); c1 *p1_0 = (c1*)(c3*)(this); tester1(p1_0); c2 *p2_0 = (c2*)(c3*)(this); tester2(p2_0); active3 = false; } virtual void f3(){} }; void __attribute__ ((noinline)) tester3(c3* p) { p->f3(); if (p->active0) p->f0(); if (p->active2) p->f2(); if (p->active1) p->f1(); } struct c4; void __attribute__ ((noinline)) tester4(c4* p); struct c4 : virtual c1, c2, virtual c0 { bool active4; c4() : active4(true) {} virtual ~c4() { tester4(this); c0 *p0_0 = (c0*)(c4*)(this); tester0(p0_0); c1 *p1_0 = (c1*)(c4*)(this); tester1(p1_0); c2 *p2_0 = (c2*)(c4*)(this); tester2(p2_0); active4 = false; } virtual void f4(){} }; void __attribute__ ((noinline)) tester4(c4* p) { p->f4(); if (p->active2) p->f2(); if (p->active0) p->f0(); if (p->active1) p->f1(); } int __attribute__ ((noinline)) inc(int v) {return ++v;} int main() { c0* ptrs0[25]; ptrs0[0] = (c0*)(new c0()); ptrs0[1] = (c0*)(c3*)(new c3()); ptrs0[2] = (c0*)(c4*)(new c4()); for (int i=0;i<3;i=inc(i)) { tester0(ptrs0[i]); delete ptrs0[i]; } c1* ptrs1[25]; ptrs1[0] = (c1*)(new c1()); ptrs1[1] = (c1*)(c3*)(new c3()); ptrs1[2] = (c1*)(c4*)(new c4()); for (int i=0;i<3;i=inc(i)) { tester1(ptrs1[i]); delete ptrs1[i]; } c2* ptrs2[25]; ptrs2[0] = (c2*)(new c2()); ptrs2[1] = (c2*)(c3*)(new c3()); ptrs2[2] = (c2*)(c4*)(new c4()); for (int i=0;i<3;i=inc(i)) { tester2(ptrs2[i]); delete ptrs2[i]; } c3* ptrs3[25]; ptrs3[0] = (c3*)(new c3()); for (int i=0;i<1;i=inc(i)) { tester3(ptrs3[i]); delete ptrs3[i]; } c4* ptrs4[25]; ptrs4[0] = (c4*)(new c4()); for (int i=0;i<1;i=inc(i)) { tester4(ptrs4[i]); delete ptrs4[i]; } return 0; }
[ "ga72foq@mytum.de" ]
ga72foq@mytum.de
873febaf329c6055ca74e4a6277baf1ac6e32256
26ad4cc35496d364b31396e43a863aee08ef2636
/SDK/SoT_BP_Lantern_functions.cpp
5f40cab446c261884b8857cbe6482abd2e04e0a1
[]
no_license
cw100/SoT-SDK
ddb9b19ce6ae623299b2b02dee51c29581537ba1
3e6f12384c8e21ed83ef56f00030ca0506d297fb
refs/heads/master
2020-05-05T12:09:55.938323
2019-03-20T14:11:57
2019-03-20T14:11:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,532
cpp
// Sea of Thieves (1.4) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "SoT_BP_Lantern_classes.hpp" namespace SDK { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function BP_Lantern.BP_Lantern_C.CreateLanternDynamicMaterial // (Public, BlueprintCallable, BlueprintEvent) void ABP_Lantern_C::CreateLanternDynamicMaterial() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.CreateLanternDynamicMaterial")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.OnAttachThirdPerson // (Public, BlueprintCallable, BlueprintEvent) void ABP_Lantern_C::OnAttachThirdPerson() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.OnAttachThirdPerson")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.OnAttachFirstPerson // (Public, BlueprintCallable, BlueprintEvent) void ABP_Lantern_C::OnAttachFirstPerson() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.OnAttachFirstPerson")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.TurnOff // (Public, BlueprintCallable, BlueprintEvent) void ABP_Lantern_C::TurnOff() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.TurnOff")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.TurnOn // (Public, BlueprintCallable, BlueprintEvent) void ABP_Lantern_C::TurnOn() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.TurnOn")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.UserConstructionScript // (Event, Public, BlueprintCallable, BlueprintEvent) void ABP_Lantern_C::UserConstructionScript() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.UserConstructionScript")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.ReceiveWieldFirstPerson // (Event, Protected, BlueprintEvent) void ABP_Lantern_C::ReceiveWieldFirstPerson() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.ReceiveWieldFirstPerson")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.ReceiveWieldThirdPerson // (Event, Protected, BlueprintEvent) void ABP_Lantern_C::ReceiveWieldThirdPerson() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.ReceiveWieldThirdPerson")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.ReceiveBeginPlay // (Event, Public, BlueprintEvent) void ABP_Lantern_C::ReceiveBeginPlay() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.ReceiveBeginPlay")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.ReceiveLightChange // (Event, Protected, BlueprintEvent) void ABP_Lantern_C::ReceiveLightChange() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.ReceiveLightChange")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.TriggerGlow // (Event, Protected, BlueprintEvent) void ABP_Lantern_C::TriggerGlow() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.TriggerGlow")); struct { } params; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.PostMeshChangedBPEvent // (Event, Protected, BlueprintEvent) // Parameters: // bool SkipFlameColourTransition (Parm, ZeroConstructor, IsPlainOldData) void ABP_Lantern_C::PostMeshChangedBPEvent(bool SkipFlameColourTransition) { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.PostMeshChangedBPEvent")); struct { bool SkipFlameColourTransition; } params; params.SkipFlameColourTransition = SkipFlameColourTransition; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.ReceiveFlameData // (Event, Protected, BlueprintEvent) // Parameters: // bool WantChangeAnimation (Parm, ZeroConstructor, IsPlainOldData) void ABP_Lantern_C::ReceiveFlameData(bool WantChangeAnimation) { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.ReceiveFlameData")); struct { bool WantChangeAnimation; } params; params.WantChangeAnimation = WantChangeAnimation; UObject::ProcessEvent(fn, &params); } // Function BP_Lantern.BP_Lantern_C.ExecuteUbergraph_BP_Lantern // () // Parameters: // int EntryPoint (Parm, ZeroConstructor, IsPlainOldData) void ABP_Lantern_C::ExecuteUbergraph_BP_Lantern(int EntryPoint) { static auto fn = UObject::FindObject<UFunction>(_xor_("Function BP_Lantern.BP_Lantern_C.ExecuteUbergraph_BP_Lantern")); struct { int EntryPoint; } params; params.EntryPoint = EntryPoint; UObject::ProcessEvent(fn, &params); } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "igromanru@yahoo.de" ]
igromanru@yahoo.de
5f7f8cce6aa1e491d284b5f1c206b5dcd0498f4f
f16ca93a097425dd80012deb14fa5840b87eb650
/ContentTools/Common/Filters/FilterTexture/RemoveTexturePaths/hctRemoveTexturePathsOptions.h
0b9294c7cffa8349923638e772dc0147814f013d
[]
no_license
Veryzon/havok-2013
868a4873f5254709b77a2ed8393355b89d2398af
45812e33f4bd92c428866e5e7c1b4d71a4762fb5
refs/heads/master
2021-06-25T23:48:11.919356
2021-04-17T02:12:06
2021-04-17T02:12:06
226,624,337
4
1
null
2019-12-08T06:21:56
2019-12-08T06:21:56
null
UTF-8
C++
false
false
1,912
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2013 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HKFILTERTEXTURES_HKFILTERTEXTURESREMOVEPATHSOPTIONS_HKCLASS_H #define HKFILTERTEXTURES_HKFILTERTEXTURESREMOVEPATHSOPTIONS_HKCLASS_H /// hctRemoveTexturePathsOptions meta information extern const class hkClass hctRemoveTexturePathsOptionsClass; /// Contains a list of the texture paths to remove. class hctRemoveTexturePathsOptions { public: HK_DECLARE_REFLECTION(); // Struct holding default values struct DefaultStruct; /// Default constructor hctRemoveTexturePathsOptions() { } // // Members // public: /// A list of the texture paths to remove, separated by semicolons. char* m_texturePaths; }; #endif // HKFILTERTEXTURES_HKFILTERTEXTURESREMOVEPATHSOPTIONS_HKCLASS_H /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20130718) * * Confidential Information of Havok. (C) Copyright 1999-2013 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at www.havok.com/tryhavok. * */
[ "veryzon@outlook.com.br" ]
veryzon@outlook.com.br
e47fe2d5f9353d754574bbcd43f87440be5c1e49
711e5c8b643dd2a93fbcbada982d7ad489fb0169
/XPSP1/NT/multimedia/directx/dplay/dvoice/dxvtlib/priority.cpp
93c33288ea6a0fab59c8975cb1c4570e2cc7fc41
[]
no_license
aurantst/windows-XP-SP1
629a7763c082fd04d3b881e0d32a1cfbd523b5ce
d521b6360fcff4294ae6c5651c539f1b9a6cbb49
refs/heads/master
2023-03-21T01:08:39.870106
2020-09-28T08:10:11
2020-09-28T08:10:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,313
cpp
/*==========================================================================; * * Copyright (C) 1999 Microsoft Corporation. All Rights Reserved. * * File: priority.cpp * Content: Implements a process that uses DirectSound in prioirty * mode to simulate an aggressive external playback only * application (such as a game) that may be running while * the full duplex application is in use. Note that WinMain * is in fdtest.cpp, but the guts are here. * History: * Date By Reason * ============ * 08/19/99 pnewson created * 10/28/99 pnewson Bug #113937 audible clicking during full duplex test * 11/02/99 pnewson Fix: Bug #116365 - using wrong DSBUFFERDESC * 01/21/2000 pnewson Workaround for broken SetNotificationPositions call. * undef DSOUND_BROKEN once the SetNotificationPositions * no longer broken. * 02/15/2000 pnewson Removed the workaround for bug 116365 * 04/04/2000 pnewson Changed a SendMessage to PostMessage to fix deadlock * 04/19/2000 pnewson Error handling cleanup * 07/12/2000 rodtoll Bug #31468 - Add diagnostic spew to logfile to show what is failing the HW Wizard * 08/25/2000 rodtoll Bug #43363 - CommandPriorityStart does not init return param and uses stack trash. * ***************************************************************************/ #include "dxvtlibpch.h" #undef DPF_SUBCOMP #define DPF_SUBCOMP DN_SUBCOMP_VOICE static HRESULT CommandLoop(CPriorityIPC* lpipcPriority); static HRESULT DispatchCommand(CPriorityIPC* lpipcPriority, SFDTestCommand* pfdtc); static HRESULT CommandPriorityStart(SFDTestCommandPriorityStart* pfdtcPriorityStart, HRESULT* phrIPC); static HRESULT CommandPriorityStop(SFDTestCommandPriorityStop* pfdtcPriorityStop, HRESULT* phrIPC); #undef DPF_MODNAME #define DPF_MODNAME "PriorityProcess" HRESULT PriorityProcess(HINSTANCE hResDLLInstance, HINSTANCE hPrevInstance, TCHAR *szCmdLine, int iCmdShow) { //DEBUG_ONLY(_asm int 3;) DPF_ENTER(); HRESULT hr; CPriorityIPC ipcPriority; BOOL fIPCInit = FALSE; BOOL fGuardInit = FALSE; if (!InitGlobGuard()) { return DVERR_OUTOFMEMORY; } fGuardInit = TRUE; // Init the common control library. Use the old style // call, so we're compatibile right back to 95. InitCommonControls(); // get the mutex, events and shared memory stuff hr = ipcPriority.Init(); if (FAILED(hr)) { goto error_cleanup; } fIPCInit = TRUE; // start up the testing loop hr = CommandLoop(&ipcPriority); if (FAILED(hr)) { goto error_cleanup; } // close the mutex, events and shared memory stuff hr = ipcPriority.Deinit(); fIPCInit = FALSE; if (FAILED(hr)) { goto error_cleanup; } DeinitGlobGuard(); DPF_EXIT(); return S_OK; error_cleanup: if (fIPCInit == TRUE) { ipcPriority.Deinit(); fIPCInit = FALSE; } if (fGuardInit == TRUE) { DeinitGlobGuard(); fGuardInit = FALSE; } DPF_EXIT(); return hr; } #undef DPF_MODNAME #define DPF_MODNAME "CommandLoop" static HRESULT CommandLoop(CPriorityIPC* lpipcPriority) { DPF_ENTER(); BOOL fRet; LONG lRet; HRESULT hr; DWORD dwRet; SFDTestCommand fdtc; // Kick the supervisor process to let it know // we're ready to go. hr = lpipcPriority->SignalParentReady(); if (FAILED(hr)) { DPF_EXIT(); return hr; } // enter the main command loop while (1) { // wait for a command from the supervisor process fdtc.dwSize = sizeof(fdtc); hr = lpipcPriority->Receive(&fdtc); if (FAILED(hr)) { Diagnostics_Write(DVF_ERRORLEVEL, "CPriorityIPC::Receive() failed, hr: 0x%x", hr); break; } // dispatch the command hr = DispatchCommand(lpipcPriority, &fdtc); if (FAILED(hr)) { Diagnostics_Write(DVF_ERRORLEVEL, "DispatchCommand() failed, hr: 0x%x", hr); break; } if (hr == DV_EXIT) { DPFX(DPFPREP, DVF_INFOLEVEL, "Exiting Priority process command loop"); break; } } DPF_EXIT(); return hr; } #undef DPF_MODNAME #define DPF_MODNAME "DispatchCommand" static HRESULT DispatchCommand(CPriorityIPC* lpipcPriority, SFDTestCommand* pfdtc) { DPF_ENTER(); HRESULT hr; HRESULT hrIPC; switch (pfdtc->fdtcc) { case fdtccExit: // ok - reply to the calling process to let them // know we are getting out. DPFX(DPFPREP, DVF_INFOLEVEL, "Priority received Exit command"); lpipcPriority->Reply(DV_EXIT); // returning this code will break us out of // the command processing loop DPF_EXIT(); return DV_EXIT; case fdtccPriorityStart: hr = CommandPriorityStart(&(pfdtc->fdtu.fdtcPriorityStart), &hrIPC); if (FAILED(hr)) { lpipcPriority->Reply(hrIPC); DPF_EXIT(); return hr; } hr = lpipcPriority->Reply(hrIPC); DPF_EXIT(); return hr; case fdtccPriorityStop: hr = CommandPriorityStop(&(pfdtc->fdtu.fdtcPriorityStop), &hrIPC); if (FAILED(hr)) { lpipcPriority->Reply(hrIPC); DPF_EXIT(); return hr; } hr = lpipcPriority->Reply(hrIPC); DPF_EXIT(); return hr; default: // Don't know this command. Reply with the appropriate // code. DPFX(DPFPREP, DVF_INFOLEVEL, "Priority received Unknown command"); hr = lpipcPriority->Reply(DVERR_UNKNOWN); if (FAILED(hr)) { DPF_EXIT(); return hr; } // While this is an error, it is one that the calling // process needs to figure out. In the meantime, this // process will happily continue on. DPF_EXIT(); return S_OK; } } #undef DPF_MODNAME #define DPF_MODNAME "CommandPriorityStart" HRESULT CommandPriorityStart(SFDTestCommandPriorityStart* pfdtcPriorityStart, HRESULT* phrIPC) { DPF_ENTER(); *phrIPC = DV_OK; HRESULT hr = S_OK; DSBUFFERDESC dsbd; WAVEFORMATEX wfx; DWORD dwSizeWritten; DSBCAPS dsbc; LPVOID lpvAudio1 = NULL; DWORD dwAudio1Size = NULL; LPVOID lpvAudio2 = NULL; DWORD dwAudio2Size = NULL; DSBPOSITIONNOTIFY dsbPositionNotify; DWORD dwRet; LONG lRet; BOOL fRet; HWND hwnd; BYTE bSilence; BOOL bBufferPlaying = FALSE; GUID guidTmp; memset( &guidTmp, 0x00, sizeof( GUID ) ); // initalize the global vars GlobGuardIn(); g_lpdsPriorityRender = NULL; g_lpdsbPriorityPrimary = NULL; g_lpdsbPrioritySecondary = NULL; GlobGuardOut(); Diagnostics_Write( DVF_INFOLEVEL, "-----------------------------------------------------------" ); hr = Diagnostics_DeviceInfo( &pfdtcPriorityStart->guidRenderDevice, &guidTmp ); if( FAILED( hr ) ) { Diagnostics_Write( 0, "Error getting device information hr=0x%x", hr ); } Diagnostics_Write( DVF_INFOLEVEL, "-----------------------------------------------------------" ); Diagnostics_Write( DVF_INFOLEVEL, "Primary Format: " ); Diagnositcs_WriteWAVEFORMATEX( DVF_INFOLEVEL, &pfdtcPriorityStart->wfxRenderFormat ); // make sure the priority dialog is in the foreground DPFX(DPFPREP, DVF_INFOLEVEL, "Bringing Wizard to the foreground"); fRet = SetForegroundWindow(pfdtcPriorityStart->hwndWizard); if (!fRet) { DPFX(DPFPREP, DVF_WARNINGLEVEL, "Unable to bring wizard to foreground, continuing anyway..."); } // kick the progress bar forward one tick DPFX(DPFPREP, DVF_INFOLEVEL, "Incrementing progress bar in dialog"); PostMessage(pfdtcPriorityStart->hwndProgress, PBM_STEPIT, 0, 0); // create the DirectSound interface DPFX(DPFPREP, DVF_INFOLEVEL, "Creating DirectSound"); GlobGuardIn(); hr = DirectSoundCreate(&pfdtcPriorityStart->guidRenderDevice, &g_lpdsPriorityRender, NULL); if (FAILED(hr)) { g_lpdsPriorityRender = NULL; GlobGuardOut(); Diagnostics_Write(DVF_ERRORLEVEL, "DirectSoundCreate failed, code: 0x%x", hr); *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } GlobGuardOut(); // set to priority mode DPFX(DPFPREP, DVF_INFOLEVEL, "Setting Cooperative Level"); GlobGuardIn(); hr = g_lpdsPriorityRender->SetCooperativeLevel(pfdtcPriorityStart->hwndWizard, DSSCL_PRIORITY); GlobGuardOut(); if (FAILED(hr)) { Diagnostics_Write(DVF_ERRORLEVEL, "SetCooperativeLevel failed, code: 0x%x", hr); *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } // Create a primary buffer object with 3d controls. // We're not actually going to use the controls, but a game probably would, // and we are really trying to emulate a game in this process. DPFX(DPFPREP, DVF_INFOLEVEL, "Creating Primary Sound Buffer"); ZeroMemory(&dsbd, sizeof(dsbd)); dsbd.dwSize = sizeof(dsbd); dsbd.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER; dsbd.dwBufferBytes = 0; dsbd.dwReserved = 0; dsbd.lpwfxFormat = NULL; dsbd.guid3DAlgorithm = DS3DALG_DEFAULT; GlobGuardIn(); hr = g_lpdsPriorityRender->CreateSoundBuffer((LPDSBUFFERDESC)&dsbd, &g_lpdsbPriorityPrimary, NULL); if (FAILED(hr)) { g_lpdsbPriorityPrimary = NULL; GlobGuardOut(); Diagnostics_Write(DVF_ERRORLEVEL, "CreateSoundBuffer failed, code: 0x%x", hr); *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } GlobGuardOut(); // Set the format of the primary buffer to the requested format. DPFX(DPFPREP, DVF_INFOLEVEL, "Setting Primary Buffer Format"); GlobGuardIn(); hr = g_lpdsbPriorityPrimary->SetFormat(&pfdtcPriorityStart->wfxRenderFormat); GlobGuardOut(); if (FAILED(hr)) { Diagnostics_Write(DVF_ERRORLEVEL, "SetFormat failed, code: 0x%x ", hr); *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } // check to make sure the SetFormat actually worked DPFX(DPFPREP, DVF_INFOLEVEL, "Verifying Primary Buffer Format"); GlobGuardIn(); hr = g_lpdsbPriorityPrimary->GetFormat(&wfx, sizeof(wfx), &dwSizeWritten); GlobGuardOut(); if (FAILED(hr)) { Diagnostics_Write(DVF_ERRORLEVEL, "GetFormat failed, code: 0x%x ", hr); *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } if (dwSizeWritten != sizeof(wfx)) { *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } if (memcmp(&wfx, &pfdtcPriorityStart->wfxRenderFormat, sizeof(wfx)) != 0) { // This is an interesting case. Is it really a full duplex error that // we are unable to initialize a primary buffer in this format? // Perhaps not. Perhaps it is sufficient that we can get full duplex // sound even if the forground priority mode app attempts to play // using this format. So just dump a debug note, and move along... DPFX(DPFPREP, DVF_WARNINGLEVEL, "Warning: SetFormat on primary buffer did not actually set the format"); } // Create a secondary buffer object with 3d controls. // We're not actually going to use the controls, but a game probably would, // and we are really trying to emulate a game in this process. DPFX(DPFPREP, DVF_INFOLEVEL, "Creating Secondary Buffer"); dsbd.dwSize = sizeof(dsbd); dsbd.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; dsbd.dwBufferBytes = (pfdtcPriorityStart->wfxSecondaryFormat.nSamplesPerSec * pfdtcPriorityStart->wfxSecondaryFormat.nBlockAlign) / (1000 / gc_dwFrameSize); dsbd.dwReserved = 0; dsbd.guid3DAlgorithm = DS3DALG_DEFAULT; dsbd.lpwfxFormat = &(pfdtcPriorityStart->wfxSecondaryFormat); GlobGuardIn(); hr = g_lpdsPriorityRender->CreateSoundBuffer((LPDSBUFFERDESC)&dsbd, &g_lpdsbPrioritySecondary, NULL); if (FAILED(hr)) { g_lpdsbPrioritySecondary = NULL; GlobGuardOut(); Diagnostics_Write(DVF_ERRORLEVEL, "CreateSoundBuffer failed, code: 0x%x Primary ", hr); *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } GlobGuardOut(); // clear out the secondary buffer DPFX(DPFPREP, DVF_INFOLEVEL, "Clearing Secondary Buffer"); GlobGuardIn(); hr = g_lpdsbPrioritySecondary->Lock( 0, 0, &lpvAudio1, &dwAudio1Size, &lpvAudio2, &dwAudio2Size, DSBLOCK_ENTIREBUFFER); GlobGuardOut(); if (FAILED(hr)) { Diagnostics_Write(DVF_ERRORLEVEL, "Lock failed, code: 0x%x ", hr); *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } if (lpvAudio1 == NULL) { *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } if (pfdtcPriorityStart->wfxSecondaryFormat.wBitsPerSample == 8) { bSilence = 0x80; } else { bSilence = 0x00; } memset(lpvAudio1, bSilence, dwAudio1Size); if (lpvAudio2 != NULL) { memset(lpvAudio2, bSilence, dwAudio2Size); } GlobGuardIn(); hr = g_lpdsbPrioritySecondary->Unlock( lpvAudio1, dwAudio1Size, lpvAudio2, dwAudio2Size); GlobGuardOut(); if (FAILED(hr)) { Diagnostics_Write(DVF_ERRORLEVEL, "Unlock failed, code: 0x%x ", hr); *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } // start playing the secondary buffer DPFX(DPFPREP, DVF_INFOLEVEL, "Playing Secondary Buffer"); GlobGuardIn(); hr = g_lpdsbPrioritySecondary->Play(0, 0, DSBPLAY_LOOPING); GlobGuardOut(); if (FAILED(hr)) { Diagnostics_Write(DVF_ERRORLEVEL, "Play failed, code: 0x%x ", hr); *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; goto error_cleanup; } bBufferPlaying = TRUE; DPF_EXIT(); Diagnostics_Write(DVF_INFOLEVEL, "Priority Result = DV_OK" ); return DV_OK; error_cleanup: GlobGuardIn(); if (bBufferPlaying == TRUE) { if (g_lpdsbPrioritySecondary != NULL) { g_lpdsbPrioritySecondary->Stop(); } bBufferPlaying = FALSE; } if (g_lpdsbPrioritySecondary != NULL) { g_lpdsbPrioritySecondary->Release(); g_lpdsbPrioritySecondary = NULL; } if (g_lpdsbPriorityPrimary != NULL) { g_lpdsbPriorityPrimary->Release(); g_lpdsbPriorityPrimary = NULL; } if (g_lpdsPriorityRender != NULL) { g_lpdsPriorityRender->Release(); g_lpdsPriorityRender = NULL; } GlobGuardOut(); DPF_EXIT(); Diagnostics_Write(DVF_INFOLEVEL, "Priority Result = 0x%x", hr ); return hr; } #undef DPF_MODNAME #define DPF_MODNAME "CommandPriorityStop" HRESULT CommandPriorityStop(SFDTestCommandPriorityStop* pfdtcPriorityStop, HRESULT* phrIPC) { DPF_ENTER(); HRESULT hr; LONG lRet; DWORD dwRet; *phrIPC = S_OK; hr = S_OK; GlobGuardIn(); if (g_lpdsbPrioritySecondary != NULL) { DPFX(DPFPREP, DVF_INFOLEVEL, "Stopping Secondary Buffer"); hr = g_lpdsbPrioritySecondary->Stop(); } GlobGuardOut(); if (FAILED(hr)) { Diagnostics_Write(DVF_ERRORLEVEL, "Stop failed, code: 0x%x", hr); *phrIPC = DVERR_SOUNDINITFAILURE; hr = DV_OK; } GlobGuardIn(); if (g_lpdsbPrioritySecondary != NULL) { DPFX(DPFPREP, DVF_INFOLEVEL, "Releasing Secondary Buffer"); g_lpdsbPrioritySecondary->Release(); g_lpdsbPrioritySecondary = NULL; } if (g_lpdsbPriorityPrimary != NULL) { DPFX(DPFPREP, DVF_INFOLEVEL, "Releasing Primary Buffer"); g_lpdsbPriorityPrimary->Release(); g_lpdsbPriorityPrimary = NULL; } if (g_lpdsPriorityRender != NULL) { DPFX(DPFPREP, DVF_INFOLEVEL, "Releasing DirectSound"); g_lpdsPriorityRender->Release(); g_lpdsPriorityRender = NULL; } GlobGuardOut(); DPF_EXIT(); return hr; }
[ "112426112@qq.com" ]
112426112@qq.com
0dae844c75354d7c8f78008934057bd8af6a3858
8f11b576b6fd648b67e4cbebeb525c97d1b9e6dd
/ImageTool/HistogramDlg.cpp
aee82127504a6e60eb1e401603dcd49dfab1d53b
[]
no_license
josoooooooooojang/ImageProcessingMFC
b220a980a9a3f2fb3d45a5536517aa8c953d8d8d
25ac359012fd2986e0974020982e4158a04e56cb
refs/heads/master
2023-02-08T16:03:20.183210
2021-01-05T16:48:16
2021-01-05T16:48:16
317,869,588
0
0
null
null
null
null
UTF-8
C++
false
false
1,978
cpp
// HistogramDlg.cpp: 구현 파일 // #include "pch.h" #include "ImageTool.h" #include "HistogramDlg.h" #include "afxdialogex.h" #include "IppImage\IppDib.h" #include "IppImage\IppImage.h" #include "IppImage\IppConvert.h" #include "IppImage\IppEnhance.h" // CHistogramDlg 대화 상자 IMPLEMENT_DYNAMIC(CHistogramDlg, CDialogEx) CHistogramDlg::CHistogramDlg(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_HISTOGRAM, pParent) { memset(m_Histogram, 0, sizeof(int) * 256); } CHistogramDlg::~CHistogramDlg() { } void CHistogramDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CHistogramDlg, CDialogEx) ON_WM_PAINT() END_MESSAGE_MAP() // CHistogramDlg 메시지 처리기 void CHistogramDlg::SetImage(IppDib* pDib) { // 넘어온 이미지가 유효한 그레이스케일 이미지일 때 if (pDib != NULL && pDib->GetBitCount() == 8) { IppByteImage img; IppDibToImage(*pDib, img); float histo[256] = { 0.f, }; IppHistogram(img, histo); float max_histo = histo[0]; for (int i = 0; i < 256; i++) max_histo = histo[i] > max_histo ? histo[i] : max_histo; for (int i = 0; i < 256; i++) m_Histogram[i] = static_cast<int>(histo[i] * 100 / max_histo); } else { memset(m_Histogram, 0, sizeof(int) * 256); } } void CHistogramDlg::OnPaint() { CPaintDC dc(this); // device context for painting CGdiObject* pOldPen = dc.SelectStockObject(DC_PEN); // 히스토그램 박스 dc.SetDCPenColor(RGB(128, 128, 128)); dc.MoveTo(20, 20); dc.LineTo(20, 120); dc.LineTo(275, 120); dc.LineTo(275, 20); // 각 그레이스케일에 해당하는 히스토그램 출력 dc.SetDCPenColor(RGB(0, 0, 0)); for (int i = 0; i < 256; i++) { dc.MoveTo(20 + i, 120); dc.LineTo(20 + i, 120 - m_Histogram[i]); } // 그레이스케일 레벨 출력 for (int i = 0; i < 256; i++) { dc.SetDCPenColor(RGB(i, i, i)); dc.MoveTo(20 + i, 130); dc.LineTo(20 + i, 145); } dc.SelectObject(pOldPen); }
[ "46040847+josoooooooooojang@users.noreply.github.com" ]
46040847+josoooooooooojang@users.noreply.github.com
de092d353c6cb49961cf2811d0c92e5dbd2aa075
38c10c01007624cd2056884f25e0d6ab85442194
/content/public/test/mock_render_thread.cc
687d7b8951d21a1c7c4f3ad9202bb36d3ae35013
[ "BSD-3-Clause" ]
permissive
zenoalbisser/chromium
6ecf37b6c030c84f1b26282bc4ef95769c62a9b2
e71f21b9b4b9b839f5093301974a45545dad2691
refs/heads/master
2022-12-25T14:23:18.568575
2016-07-14T21:49:52
2016-07-23T08:02:51
63,980,627
0
2
BSD-3-Clause
2022-12-12T12:43:41
2016-07-22T20:14:04
null
UTF-8
C++
false
false
8,037
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/public/test/mock_render_thread.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "content/common/frame_messages.h" #include "content/common/view_messages.h" #include "content/public/renderer/render_process_observer.h" #include "content/renderer/render_view_impl.h" #include "ipc/ipc_message_utils.h" #include "ipc/ipc_sync_message.h" #include "ipc/message_filter.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/public/web/WebScriptController.h" namespace content { MockRenderThread::MockRenderThread() : routing_id_(0), opener_id_(0), new_window_routing_id_(0), new_window_main_frame_routing_id_(0), new_window_main_frame_widget_routing_id_(0), new_frame_routing_id_(0) {} MockRenderThread::~MockRenderThread() { while (!filters_.empty()) { scoped_refptr<IPC::MessageFilter> filter = filters_.back(); filters_.pop_back(); filter->OnFilterRemoved(); } } // Called by the Widget. Used to send messages to the browser. // We short-circuit the mechanism and handle the messages right here on this // class. bool MockRenderThread::Send(IPC::Message* msg) { // We need to simulate a synchronous channel, thus we are going to receive // through this function messages, messages with reply and reply messages. // We can only handle one synchronous message at a time. if (msg->is_reply()) { if (reply_deserializer_) { reply_deserializer_->SerializeOutputParameters(*msg); reply_deserializer_.reset(); } } else { if (msg->is_sync()) { // We actually need to handle deleting the reply deserializer for sync // messages. reply_deserializer_.reset( static_cast<IPC::SyncMessage*>(msg)->GetReplyDeserializer()); } if (msg->routing_id() == MSG_ROUTING_CONTROL) OnControlMessageReceived(*msg); else OnMessageReceived(*msg); } delete msg; return true; } IPC::SyncChannel* MockRenderThread::GetChannel() { return NULL; } std::string MockRenderThread::GetLocale() { return "en-US"; } IPC::SyncMessageFilter* MockRenderThread::GetSyncMessageFilter() { return NULL; } scoped_refptr<base::SingleThreadTaskRunner> MockRenderThread::GetIOMessageLoopProxy() { return scoped_refptr<base::SingleThreadTaskRunner>(); } void MockRenderThread::AddRoute(int32 routing_id, IPC::Listener* listener) { } void MockRenderThread::RemoveRoute(int32 routing_id) { } int MockRenderThread::GenerateRoutingID() { NOTREACHED(); return MSG_ROUTING_NONE; } void MockRenderThread::AddFilter(IPC::MessageFilter* filter) { filter->OnFilterAdded(&sink()); // Add this filter to a vector so the MockRenderThread::RemoveFilter function // can check if this filter is added. filters_.push_back(make_scoped_refptr(filter)); } void MockRenderThread::RemoveFilter(IPC::MessageFilter* filter) { // Emulate the IPC::ChannelProxy::OnRemoveFilter function. for (size_t i = 0; i < filters_.size(); ++i) { if (filters_[i].get() == filter) { filter->OnFilterRemoved(); filters_.erase(filters_.begin() + i); return; } } NOTREACHED() << "filter to be removed not found"; } void MockRenderThread::AddObserver(RenderProcessObserver* observer) { observers_.AddObserver(observer); } void MockRenderThread::RemoveObserver(RenderProcessObserver* observer) { observers_.RemoveObserver(observer); } void MockRenderThread::SetResourceDispatcherDelegate( ResourceDispatcherDelegate* delegate) { } void MockRenderThread::EnsureWebKitInitialized() { } void MockRenderThread::RecordAction(const base::UserMetricsAction& action) { } void MockRenderThread::RecordComputedAction(const std::string& action) { } scoped_ptr<base::SharedMemory> MockRenderThread::HostAllocateSharedMemoryBuffer( size_t buffer_size) { scoped_ptr<base::SharedMemory> shared_buf(new base::SharedMemory); if (!shared_buf->CreateAnonymous(buffer_size)) { NOTREACHED() << "Cannot map shared memory buffer"; return scoped_ptr<base::SharedMemory>(); } return scoped_ptr<base::SharedMemory>(shared_buf.release()); } cc::SharedBitmapManager* MockRenderThread::GetSharedBitmapManager() { return &shared_bitmap_manager_; } void MockRenderThread::RegisterExtension(v8::Extension* extension) { blink::WebScriptController::registerExtension(extension); } void MockRenderThread::ScheduleIdleHandler(int64 initial_delay_ms) { } void MockRenderThread::IdleHandler() { } int64 MockRenderThread::GetIdleNotificationDelayInMs() const { return 0; } void MockRenderThread::SetIdleNotificationDelayInMs( int64 idle_notification_delay_in_ms) { } void MockRenderThread::UpdateHistograms(int sequence_number) { } int MockRenderThread::PostTaskToAllWebWorkers(const base::Closure& closure) { return 0; } bool MockRenderThread::ResolveProxy(const GURL& url, std::string* proxy_list) { return false; } base::WaitableEvent* MockRenderThread::GetShutdownEvent() { return NULL; } #if defined(OS_WIN) void MockRenderThread::PreCacheFont(const LOGFONT& log_font) { } void MockRenderThread::ReleaseCachedFonts() { } #endif // OS_WIN ServiceRegistry* MockRenderThread::GetServiceRegistry() { return NULL; } void MockRenderThread::SendCloseMessage() { ViewMsg_Close msg(routing_id_); RenderViewImpl::FromRoutingID(routing_id_)->OnMessageReceived(msg); } // The Widget expects to be returned valid route_id. void MockRenderThread::OnCreateWidget(int opener_id, blink::WebPopupType popup_type, int* route_id) { opener_id_ = opener_id; *route_id = routing_id_; } // The View expects to be returned a valid route_id different from its own. void MockRenderThread::OnCreateWindow( const ViewHostMsg_CreateWindow_Params& params, ViewHostMsg_CreateWindow_Reply* reply) { reply->route_id = new_window_routing_id_; reply->main_frame_route_id = new_window_main_frame_routing_id_; reply->main_frame_widget_route_id = new_window_main_frame_widget_routing_id_; reply->cloned_session_storage_namespace_id = 0; } // The Frame expects to be returned a valid route_id different from its own. void MockRenderThread::OnCreateChildFrame(int new_frame_routing_id, blink::WebTreeScopeType scope, const std::string& frame_name, blink::WebSandboxFlags sandbox_flags, int* new_render_frame_id) { *new_render_frame_id = new_frame_routing_id_++; } bool MockRenderThread::OnControlMessageReceived(const IPC::Message& msg) { base::ObserverListBase<RenderProcessObserver>::Iterator it(&observers_); RenderProcessObserver* observer; while ((observer = it.GetNext()) != NULL) { if (observer->OnControlMessageReceived(msg)) return true; } return OnMessageReceived(msg); } bool MockRenderThread::OnMessageReceived(const IPC::Message& msg) { // Save the message in the sink. sink_.OnMessageReceived(msg); bool handled = true; IPC_BEGIN_MESSAGE_MAP(MockRenderThread, msg) IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnCreateWidget) IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnCreateWindow) IPC_MESSAGE_HANDLER(FrameHostMsg_CreateChildFrame, OnCreateChildFrame) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } #if defined(OS_WIN) void MockRenderThread::OnDuplicateSection( base::SharedMemoryHandle renderer_handle, base::SharedMemoryHandle* browser_handle) { // We don't have to duplicate the input handles since RenderViewTest does not // separate a browser process from a renderer process. *browser_handle = renderer_handle; } #endif // defined(OS_WIN) } // namespace content
[ "zeno.albisser@hemispherian.com" ]
zeno.albisser@hemispherian.com
2cb51204b503d3fbcd3b76fa81df77155261aae2
3f78ac9921f1d12340210045af9659f8485fb521
/BookSelection/s3.cpp
7719e5165689515248110c3805daf50a0974de54
[]
no_license
cfyuen/Topcoder-Marathon
d2d1d42540081255432bdd2e34b9f255c83bf84d
0b617f323212ea08a48c1a7748696ddef669178b
refs/heads/master
2020-03-19T06:01:34.617770
2018-06-04T08:16:26
2018-06-04T08:16:26
135,984,163
0
0
null
null
null
null
UTF-8
C++
false
false
15,128
cpp
/***************** v5.1 various height(hill climb, minor adjust),approx binpack change findheight, estimate average - Bug fixed Bugs fixed in valley... optimization of approxbinpack, back to original changed binpack to near binpack fixed height, binpack optimally for each shelf from low height to high height (O(n^2*v)) seed 6,58 *****************/ #include<iostream> #include<vector> #include<string> #include<cstdio> #include<algorithm> #include<ctime> #include<cstdlib> #include<fstream> #include<cmath> #include<queue> using namespace std; struct Book { int h,w,v,ind; }; struct Shelf { vector<int> bok; int w,h; }; vector<Book> b,orib,tb; int H,W; vector<int> ret; int bdp[1400][6005],hcho[250]; int maxpershelf=1800,factor=1; int done[1<<27],hisco=0,use[1400],tots[30],totcnt[30]; double aver[30]; vector<int> bestret,besth,indsco[30]; int used[1400],hlimit; timeval sttime; double tlim1_1=0.7,tlim1_2=1.4,tlim2=1.86,tout=1.95; void start() { gettimeofday(&sttime,NULL); } double runtime() { timeval tt, nowt; gettimeofday(&tt,NULL); timersub(&tt,&sttime,&nowt); return (nowt.tv_sec*1000+nowt.tv_usec/1000)/1000.0; } bool cmpv (Book x,Book y) { if (x.v==y.v) { if (orib[x.ind].v==orib[y.ind].v) return x.ind<y.ind; return orib[x.ind].v>orib[y.ind].v; } return x.v>y.v; } bool cmph (Book x,Book y) { return x.h>y.h; } bool qcmpr (Book x,Book y) { if (x.h>hlimit || y.h>hlimit) return x.h<y.h; double xs,ys; xs=x.w*1.0/x.v; ys=y.w*1.0/y.v; if (abs(xs-ys)<1e-9) return x.ind<y.ind; return xs<ys; } bool cmpr (Book x,Book y) { double xs,ys; xs=x.w*(50+x.h)*1.0/x.v; ys=y.w*(50+y.h)*1.0/y.v; if (abs(xs-ys)<1e-9) return x.ind<y.ind; return xs<ys; } bool cmprev (int a,int b) { return a>b; } class BookSelection { public: int score (vector<int> res) { int sco=0; for (int i=0; i<b.size(); i++) if (res[i]!=-1) { sco+=orib[i].v; } return sco; } vector<int> approxbinpack (vector<int> shh) { sort(shh.begin(),shh.end()); sort(b.begin(),b.end(),cmpr); vector<int> bret,wid; vector<Book> tb=b; for (int i=0; i<b.size(); i++) for (int j=0; j<shh.size(); j++) if (tb[i].h<=shh[j]) { tb[i].h=shh[j]; break; } sort(tb.begin(),tb.end(),cmpr); wid.resize(shh.size()); for (int i=0; i<b.size(); i++) bret.push_back(-1); for (int i=0; i<b.size(); i++) { for (int j=0; j<shh.size(); j++) if (tb[i].h<=shh[j] && wid[j]+tb[i].w<=W) { wid[j]+=tb[i].w; bret[tb[i].ind]=j; break; } } return bret; } vector<int> nearbinpack (vector<int> shh) { sort(shh.begin(),shh.end()); maxpershelf=700; memset(used,0,sizeof(used)); vector<int> bret,wid; for (int i=0; i<b.size(); i++) bret.push_back(-1); tb=b; wid.resize(shh.size()); int tvv=0,curind=0; for (int i=0; i<shh.size(); i++) { hlimit=shh[i]; sort(tb.begin(),tb.end(),qcmpr); tvv=0; for (int j=0; j<b.size(); j++) { if (tb[j].h>shh[i] || (wid[i]>W/2 && runtime()<=tout)) break; if (wid[i]+tb[j].w<=W && used[tb[j].ind]==0) { wid[i]+=tb[j].w; bret[tb[j].ind]=i; tvv+=tb[j].v; curind=j; used[tb[j].ind]=1; } } if (runtime()>tout) continue; int curmx=0,lastind=tb.size()-1; for (int j=curind; j<=tb.size(); j++) { int ind=j-1; if (tb[ind].h>shh[i]) { lastind=j-1; break; } for (int k=0; k<maxpershelf; k++) { if (k==0) { bdp[j][k]=0; continue; } if (j==curind) { bdp[j][k]=2000000; continue; } if (tb[ind].v>k) { bdp[j][k]=bdp[j-1][k]; continue; } if (tb[ind].w+bdp[j-1][k-tb[ind].v]<bdp[j-1][k] && used[tb[ind].ind]==0 && tb[ind].h<=shh[i]) { bdp[j][k]=tb[ind].w+bdp[j-1][k-tb[ind].v]; curmx=max(k,curmx); } else { bdp[j][k]=bdp[j-1][k]; } } } int bval=0,vnow; for (int j=0; j<maxpershelf; j++) if (bdp[lastind][j]<=W-wid[i]) { bval=j; } vnow=bval; for (int j=lastind-1; j>=curind; j--) if (bdp[j][vnow]!=bdp[j+1][vnow]) { bret[tb[j].ind]=i; used[tb[j].ind]=1; vnow-=tb[j].v; } } return bret; } vector<int> findheight () { sort(b.begin(),b.end(),cmpr); int asum=0; memset(use,-1,sizeof(use)); for (int i=0; i<b.size(); i++) if (asum+b[i].h*b[i].w<H*W) { asum+=b[i].h*b[i].w; use[b[i].ind]=H*W/asum; } sort(b.begin(),b.end(),cmph); vector<int> tryh; int noww=100000,sumv=0,last=-1; for (int i=0; i<b.size(); i++) { if (use[b[i].ind]!=-1) { if (noww>W || ((last==-1 || b[last].h-b[i].h>3) && use[b[i].ind]>0 && b[i].h>50)) { tryh.push_back(b[i].h); if (noww>W) noww=0; } noww+=b[i].w; sumv+=b[i].v; last=i; } } sort(tryh.begin(),tryh.end(),cmprev); int getsz=tryh.size(); for (int i=1; i<getsz; i++) for (int j=0; j<b.size(); j++) if (abs((tryh[i]+tryh[i-1])/2-b[j].h)<=1 && use[b[j].ind]!=-1) { tryh.push_back(b[j].h); break; } if (tryh.size()>27) tryh.resize(27); sort(tryh.begin(),tryh.end(),cmprev); for (int i=1; i<tryh.size(); i++) if (tryh[i-1]-tryh[i]<2) { tryh.erase(tryh.begin()+i); i--; } return tryh; } void minoradjust () { vector<int> nowh,orih=besth,tret; priority_queue<pair<int,int> > mpq; mpq.push(make_pair(0,0)); int del,ndel,base,mulb[50]; if (besth.size()>8) base=5; else if (besth.size()>6) base=7; else if (besth.size()>4) base=9; else base=13; mulb[0]=1; for (int i=1; mulb[i-1]*base<(1<<30); i++) mulb[i]=mulb[i-1]*base; int opr=0; while (!mpq.empty() && runtime()<tlim2) { nowh=orih; del=mpq.top().second; ndel=del; mpq.pop(); for (int i=0; i<nowh.size(); i++) { if (del<0) { nowh[i]-=abs(del-base/2)%base-base/2; del=(del-base/2)/base; } else { nowh[i]+=(del+base/2)%base-base/2; del=(del+base/2)/base; } } opr++; int scor; tret=approxbinpack(nowh); scor=score(tret); if (scor>hisco) { bestret=tret; besth=nowh; hisco=scor; } del=ndel; for (int i=0; i<nowh.size(); i++) for (int j=0; j<nowh.size(); j++) if (i!=j && nowh[i]>=orih[i] && nowh[i]-orih[i]<=base/2-1 && nowh[j]<=orih[j] && orih[j]-nowh[j]<=base/2-1) { ndel=del; if (i>j) { ndel+=mulb[i]; ndel-=mulb[j]; } else { ndel+=mulb[i]; ndel-=mulb[j]; } mpq.push(make_pair(scor,ndel)); } } } vector<int> majorheight (vector<int> geth,double timelim) { int curleast=100000; sort(geth.begin(),geth.end(),cmprev); vector<int> selh=geth,tret; for (int i=0; i<geth.size(); i++) { indsco[i].clear(); } int at=0,th=0,sumh=0,scor,least,cntopr=0; int opr=0,fr; at+=1<<0; least=0; memset(totcnt,0,sizeof(totcnt)); memset(tots,0,sizeof(tots)); memset(done,-1,sizeof(done)); priority_queue<pair<int,int> > pq; pq.push(make_pair(0,at)); done[at-(1<<least)]=1; while (!pq.empty() && runtime()<timelim) { at=pq.top().second; fr=pq.top().first; pq.pop(); selh.clear(); sumh=0; opr++; cntopr++; for (int i=0; i<geth.size(); i++) if (at & (1<<i)) { sumh+=geth[i]+10; selh.push_back(geth[i]); least=i; } selh[selh.size()-1]+=H-sumh; tret=approxbinpack(selh); scor=score(tret); if (scor>hisco) { bestret=tret; besth=selh; hisco=scor; } int nsum,nat,nleast; for (int i=0; i<geth.size(); i++) if (at & (1<<i)) for (int j=0; j<geth.size(); j++) if (at & (1<<j)) {} else { nsum=sumh-geth[i]+geth[j]; nat=at; nleast=least; nat-=(1<<i); nat+=(1<<j); if (i==nleast) { for (int k=i-1; k>=0; k--) { nleast--; if (at & (1<<k)) break; } } nleast=max(j,nleast); if (nsum<=H && (done[nat-(1<<nleast)]==-1 || scor-done[nat-(1<<nleast)]>300)) { done[nat-(1<<nleast)]=scor; pq.push(make_pair(scor,nat)); } } for (int i=0; i<geth.size(); i++) if (at & (1<<i)) { indsco[i].push_back(scor); } else { nsum=sumh+geth[i]+10; nat=at; nat+=(1<<i); if (nsum<=H && (done[nat-(1<<max(i,least))]==-1 || scor-done[nat-(1<<max(i,least))]>100)) { done[nat-(1<<max(i,least))]=scor; pq.push(make_pair(scor,nat)); } } } double aversco=0; int not0=0; for (int i=0; i<geth.size(); i++) { sort(indsco[i].begin(),indsco[i].end(),cmprev); for (int j=0; j<30 && j<indsco[i].size()/2; j++) { tots[i]+=indsco[i][j]; totcnt[i]++; } if (totcnt[i]>0) { aver[i]=tots[i]*1.0/totcnt[i]; aversco+=aver[i]; not0++; } else aver[i]=1e9; } sort(aver,aver+geth.size()); aversco/=not0; if (cntopr>200) { if (geth.size()/2<10) aversco=min(aversco,aver[max(0,(int)geth.size()-10)]-1e-5); } else aversco=aver[0]-1; vector<int> newh; for (int i=0; i<geth.size(); i++) if (totcnt[i]==0 || tots[i]*1.0/totcnt[i]>aversco-10) { newh.push_back(geth[i]); } return newh; } void select () { memset(hcho,0,sizeof(hcho)); vector<int> candh=findheight(); for (int i=0; i<candh.size(); i++) { hcho[candh[i]]=1; hcho[candh[i]+1]=1; hcho[candh[i]-1]=1; } int times=1; while (runtime()<tlim1_2 && candh.size()>0) { candh=majorheight(candh,min(runtime()+tlim1_1,tlim1_2)); times++; fprintf(stderr,"Time 1_1: %0.4lf\n",runtime()); fflush(stderr); int getsz=candh.size(); for (int i=1; i<=getsz; i++) { int ncand; if (i==getsz) ncand=candh[getsz-1]-4; else { if (candh[i-1]-candh[i]>4 || getsz<=10) ncand=(candh[i]+candh[i-1])/2; else continue; } for (int j=0; j<b.size(); j++) if (abs(ncand-b[j].h)<=1 && use[b[j].ind]!=-1 && hcho[b[j].h]==0) { candh.push_back(b[j].h); hcho[b[j].h]=1; hcho[b[j].h+1]=1; hcho[b[j].h-1]=1; break; } } if (candh.size()>27) candh.resize(27); } fprintf(stderr,"Time 1_2: %0.4lf\n",runtime()); fflush(stderr); minoradjust(); fprintf(stderr,"Time 2: %0.4lf\n",runtime()); fflush(stderr); factor=1; sort(b.begin(),b.end(),cmpr); bestret=nearbinpack(besth); for (int i=0; i<besth.size(); i++) fprintf(stderr,"%d ",besth[i]); fprintf(stderr,"\n"); ret=bestret; } vector <int> arrange(int H1, int W1, vector <int> bookH, vector <int> bookW, vector <int> bookV) { H=H1; W=W1; start(); b.resize(bookH.size()); for (int i=0; i<bookH.size(); i++) { b[i].h=bookH[i]; b[i].w=bookW[i]; b[i].v=bookV[i]; b[i].ind=i; } orib=b; sort(b.begin(),b.end(),cmpv); ret.resize(b.size()); for (int i=0; i<b.size(); i++) { ret[i]=-1; } select(); fprintf(stderr,"Time: %0.4lf\n",runtime()); int rev=0; for (int i=0; i<b.size(); i++) { rev=max(rev,ret[i]); } b=orib; for (int i=0; i<b.size(); i++) { if (ret[i]!=-1) ret[i]=rev-ret[i]; } return ret; } };
[ "cfyuen.trevor@gmail.com" ]
cfyuen.trevor@gmail.com
c771e9d9cd047031801120b703cee9b6dc6b854a
7a74c9a3dcbd98e5ddf4c69e923920aa099fb665
/src/sqlite/cursor.cpp
c488498dbaef7dae371904c1bc351e173fafc8d6
[ "MIT" ]
permissive
cp3fantasy/mx3
ec90f5971ca0ec52cac6f66727c4f8ac3c9173a9
954bdeb14319427dba386fdf64ae6e7499646925
refs/heads/master
2021-01-18T07:25:47.969570
2015-02-25T08:43:50
2015-02-25T08:46:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,727
cpp
#include "cursor.hpp" #include "stmt.hpp" #include <sqlite3/sqlite3.h> using mx3::sqlite::Stmt; using mx3::sqlite::Cursor; using mx3::sqlite::Value; Value Cursor::value_at(int pos) const { sqlite3_stmt * stmt = m_raw_stmt.get(); sqlite3_value * value = sqlite3_column_value(stmt, pos); const auto type = sqlite3_value_type(value); switch (type) { case SQLITE_NULL: { return Value {nullptr}; } case SQLITE_TEXT: { auto data = sqlite3_value_text(value); return Value { string { reinterpret_cast<const char *>(data) } }; } case SQLITE_INTEGER: { return Value { static_cast<int64_t>( sqlite3_value_int64(value) ) }; } case SQLITE_FLOAT: { return Value { sqlite3_value_double(value) }; } case SQLITE_BLOB: { const auto len = sqlite3_value_bytes(value); const uint8_t * data = static_cast<const uint8_t*>( sqlite3_value_blob(value) ); return Value { vector<uint8_t> {data, data + len} }; } } return Value {nullptr}; } vector<Value> Cursor::values() const { vector<Value> values; const int col_count = this->column_count(); values.reserve(col_count); for (int i=0; i < col_count; i++) { values.push_back( this->value_at(i) ); } return values; } vector<vector<Value>> Cursor::all_rows() { vector<vector<Value>> rows; while (this->is_valid()) { rows.push_back(this->values()); this->next(); } return rows; } std::map<string, Value> Cursor::value_map() const { std::map<string, Value> all_values; const int col_count = this->column_count(); for (int i=0; i < col_count; i++) { all_values.emplace( this->column_name(i), this->value_at(i) ); } return all_values; } void Cursor::Resetter::operator() (sqlite3_stmt * stmt) { auto error_code = sqlite3_reset(stmt); if (error_code != SQLITE_OK) { // this is in the dtor, so don't throw } } Cursor::Cursor(const shared_ptr<Stmt>& stmt, bool is_valid) : m_stmt {stmt} , m_raw_stmt {m_stmt->borrow_stmt()} , m_is_valid {is_valid} {} sqlite3_stmt * Cursor::borrow_stmt() const { return m_raw_stmt.get(); } sqlite3 * Cursor::borrow_db() const { return m_stmt->borrow_db(); } string Cursor::column_name(int pos) const { const char * name = sqlite3_column_name(m_raw_stmt.get(), pos); return string {name}; } vector<string> Cursor::column_names() const { vector<string> names; const int col_count = this->column_count(); names.reserve(col_count); for (int i=0; i < col_count; i++) { names.push_back( this->column_name(i) ); } return names; } int Cursor::column_count() const { return sqlite3_column_count(m_raw_stmt.get()); } void Cursor::next() { auto result = sqlite3_step(m_raw_stmt.get()); switch (result) { case SQLITE_ROW: break; case SQLITE_DONE: m_is_valid = false; break; default: { throw std::runtime_error { "invalid query" }; break; } } } bool Cursor::is_null(int pos) const { return this->value_at(pos).is_null(); } string Cursor::string_value(int pos) const { return this->value_at(pos).string_value(); } int32_t Cursor::int_value(int pos) const { return this->value_at(pos).int_value(); } int64_t Cursor::int64_value(int pos) const { return this->value_at(pos).int64_value(); } double Cursor::double_value(int pos) const { return this->value_at(pos).double_value(); } vector<uint8_t> Cursor::blob_value(int pos) const { return this->value_at(pos).blob_value(); }
[ "stevenkabbes@gmail.com" ]
stevenkabbes@gmail.com
c05610bfc4c07994046f8c99b5df1acd7e53002f
42719c16705542a9d20b8852a153ef627e484fef
/cpp/Set_Functions.h
5d34b4e86261754fde3b95ba91e2fd46fa5bec44
[]
no_license
luiarthur/Boggle
bf0e0ea518607df14608fda2066ba6ee524f821f
6e50dcc080bea2bd13e0c453a769ffcedb3d988b
refs/heads/master
2021-01-21T04:37:38.832585
2020-01-14T03:49:43
2020-01-14T03:49:43
26,022,276
0
0
null
null
null
null
UTF-8
C++
false
false
318
h
#include <set> template<typename Key_Type, typename Compare> std::set<Key_Type, Compare> operator+( const std::set<Key_Type, Compare>& left, const std::set<Key_Type, Compare>& right){ typename std::set<Key_Type, Compare> result(left); result.insert(right.begin(), right.end()); return result; }
[ "luiarthur@gmail.com" ]
luiarthur@gmail.com
0f7e13b7f66e791bedfebd0aaf5f4c87c3c6153a
0a9306173a78ed7f3ab20c2db2fd21c3ae01b19a
/ddlus/cute/update.cpp
581e066982642601f52411b82fc37e38f2dd334f
[]
no_license
jaysi/prj
ee811ba838b2fc40c13e9ffb5c986e3241798ff6
4bd599ea8e8681806e5a8e34f78f13613838716c
refs/heads/master
2020-12-03T00:43:01.263991
2017-10-21T14:06:44
2017-10-21T14:06:44
96,068,073
0
0
null
null
null
null
UTF-8
C++
false
false
2,177
cpp
#include "update.h" #include "mainwindow.h" //int plotxy(struct session *sess){ // Update* up; // struct tok_s* x, *y; // x = poptok(sess); // if(!x){ // printe(MSG_MOREARGS); // return false_; // } // y = poptok(sess); // if(!y){ // printe(MSG_MOREARGS); // return false_; // } // up = (Update*)(sess->cursess->ui); // up->upPlot(x->val, y->val); // return true_; //} int outtext_(struct session* sess, char* buf){ Update* up; up = (Update*)(sess->cursess->wr); if(!memcmp(buf, ERR_ICON, ICON_SIZE)){ up->upOut(QString::fromUtf8(buf+ICON_SIZE), 255, 0, 0, false, false); } else if(!memcmp(buf, WARN_ICON, ICON_SIZE)) { up->upOut(QString::fromUtf8(buf+ICON_SIZE), 255, 0, 255, false, false); } else if(!memcmp(buf, INFO_ICON, ICON_SIZE)) { up->upOut(QString::fromUtf8(buf+ICON_SIZE), 0, 0, 255, false, false); } else if(!memcmp(buf, HELPBLOCK_ICON, ICON_SIZE)) { up->upOut(QString::fromUtf8(buf+ICON_SIZE), 32, 32, 32, true, false); } else if(!memcmp(buf, HELPINFO_ICON, ICON_SIZE)) { up->upOut(QString::fromUtf8(buf+ICON_SIZE), 32, 32, 32, true, false); } else if(!memcmp(buf, ANS_ICON, ICON_SIZE)) { up->upOut(QString::fromUtf8(buf+ICON_SIZE), 0, 0, 0, true, false); } else if(!memcmp(buf, RESULT_ICON, ICON_SIZE)) { up->upOut(QString::fromUtf8(buf+ICON_SIZE), 32, 32, 32, false, true); } else if(!memcmp(buf, INFOBLOCK_ICON, ICON_SIZE)) { up->upOut(QString::fromUtf8(buf+ICON_SIZE), 32, 32, 32, true, true); } else if(!memcmp(buf, NOP_ICON, ICON_SIZE)) { up->upOut(QString::fromUtf8(buf+ICON_SIZE), 32, 32, 32, false, false); } else { up->upOut(QString::fromUtf8(buf), 32, 32, 32, false, false); } return true_; } Update::Update(QObject *parent) : QThread(parent) { } void Update::upOut(QString str, int r, int g, int b, bool bold, bool italic){ emit updateOut(str, r, g, b, bold, italic); this->usleep(100); } void Update::upPlot(fnum_t x, fnum_t y){ emit updatePlot(x, y); } void Update::upConf(QString text) { emit updateConf(text); }
[ "b.akhondi@B-Akhondi.Chillco.local" ]
b.akhondi@B-Akhondi.Chillco.local
791f8a614e386a6a504801627134c2247986e27b
043226adf84531a160bb816f0926382f3e3f4a5c
/PizzaAbstractFactory/marinara_sauce.cc
f9604215f73bf875067333371ff17647f015f5b2
[]
no_license
Akhil-Dalwadi/CPP
14ddba738bc39e771523a5d498be712d034db592
1f8030a39b6e7d9ed3038aee91d16be33c1af971
refs/heads/master
2022-02-16T10:56:40.302269
2018-10-19T16:40:23
2018-10-19T16:40:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
91
cc
#include "marinara_sauce.h" MarinaraSauce::MarinaraSauce() { name_ = "Marinara sauce"; }
[ "nguyen_bn@hotmail.com" ]
nguyen_bn@hotmail.com
0efbd171121f51805c737eb22e1cefc826935b63
a08f16f650e6158ac719527d15c804988818cbb5
/TrainingCamo/dia4m.cpp
1257380fdcdd810ea1eadc396f5be7f2583add31
[]
no_license
emae18/pc-Key
d2651dad02ce268ea24ab845b8634eeb334515bb
3b79a3bb16afebcbbda3f27a872e619a82f1ce0a
refs/heads/master
2020-04-16T09:01:19.009218
2020-03-30T04:34:19
2020-03-30T04:34:19
165,447,519
0
0
null
2020-02-28T05:34:05
2019-01-12T23:43:31
C++
UTF-8
C++
false
false
1,067
cpp
#include<bits/stdc++.h> //template Emae #define forin(i,n) for(int i=0;i<n;i++) #define forisn(i,s,n) for(int i=s;i<n;i++) #define fortin(i,n) for(int i=0;i<=n;i++) #define nforin(i,n) for(int i=n;i>-1;i--) #define mostrar(x,s) for(auto x : s)cout<<x<<" "; #define desc greater<int>() #define asc less<int>() #define all(v) v.begin(),v.end() //loops and more using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef set<int> si; typedef map<string,int> msi; typedef pair<int,int> pii; typedef set<int>::iterator itsi; typedef map<string,int>::iterator itmsi; //solve vector<pair<ll,ll> > v(200001); map<int,int > x; map<int,int > y; map<int,int > xy; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin>>n; int a,b; forin(i,n) { cin>>xa>>ya; x[xa]++; x[ya]++; } // sort(all(v)); int c=0; forin(i,n) forisn(j,i+1,n) if(v[i].first== v[j].first || v[i].second== v[j].second) c++; cout<<c<<"\n"; return 0; }
[ "eliasvilte1@gmail.com" ]
eliasvilte1@gmail.com
1adacfe586f37037ede578d80ea8301f867bfd8c
e1c6bed59e725e9e7f28f17e88357c3424dba491
/est/speech_tools/base_class/EST_svec_aux.cc
a88eceaf175816257fb918d7c31d3bc1e420997c
[ "MIT", "LicenseRef-scancode-proprietary-license", "BSD-3-Clause", "GPL-1.0-or-later", "LicenseRef-scancode-other-permissive", "MIT-Festival" ]
permissive
shashankrnr32/WaveCLI
87a398809263a97da4c072617b3ed3e0aa396287
b2addcfb90b9dbef8ce6035e01dbf639285ec20f
refs/heads/master
2020-05-07T09:17:19.010465
2019-05-21T07:59:04
2019-05-21T07:59:04
180,370,062
1
2
MIT
2019-04-20T08:48:39
2019-04-09T13:13:02
Python
UTF-8
C++
false
false
4,091
cc
/*************************************************************************/ /* */ /* Centre for Speech Technology Research */ /* University of Edinburgh, UK */ /* Copyright (c) 1994,1995,1996 */ /* All Rights Reserved. */ /* */ /* Permission is hereby granted, free of charge, to use and distribute */ /* this software and its documentation without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of this work, and to */ /* permit persons to whom this work is furnished to do so, subject to */ /* the following conditions: */ /* 1. The code must retain the above copyright notice, this list of */ /* conditions and the following disclaimer. */ /* 2. Any modifications must be clearly marked as such. */ /* 3. Original authors' names are not deleted. */ /* 4. The authors' names are not used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ /* THIS SOFTWARE. */ /* */ /*************************************************************************/ /* Author : Paul Taylor */ /* Date : May 1994 */ /*-----------------------------------------------------------------------*/ /* StrVector i/o utility functions */ /* */ /*=======================================================================*/ #include <cstdio> #include <cctype> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include "EST_types.h" #include "EST_String.h" #include "EST_Pathname.h" #include "EST_string_aux.h" #include "EST_cutils.h" #include "EST_Token.h" EST_read_status load_TList_of_StrVector(EST_TList<EST_StrVector> &w, const EST_String &filename, const int vec_len) { EST_TokenStream ts; EST_String s; EST_StrVector v; int c; if(ts.open(filename) != 0){ cerr << "Can't open EST_TList<EST_StrVector> file " << filename << endl; return misc_read_error; } v.resize(vec_len); // ts.set_SingleCharSymbols(""); // ts.set_PunctuationSymbols(""); c=0; while (!ts.eof()) { s = ts.get().string(); if(s != "") { if(c == vec_len) { cerr << "Too many points in line - expected " << vec_len << endl; return wrong_format; } else v[c++] = s; } if(ts.eoln()) { if(c != vec_len) { cerr << "Too few points in line - got " << c << ", expected " << vec_len << endl; return wrong_format; } else { w.append(v); c=0; } } } ts.close(); return format_ok; }
[ "shashankrnr32@gmail.com" ]
shashankrnr32@gmail.com
eff63aa27b4fcc14940152d20b30e748fb47e344
e91828f8e87a17b942cc26da4bf061f65e3a04c8
/searchcorespi/src/vespa/searchcorespi/index/activediskindexes.h
dff2590655913c2a06509feba932e4dc95f98aa5
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
NolanJos/vespa
69dbe95b1a9e8cba2879d7b39d882501dc92bebc
fdc4350398029fbffbed3c0498380589a73571d7
refs/heads/master
2022-08-02T10:29:40.065863
2020-06-02T12:47:31
2020-06-02T12:47:31
268,804,702
1
0
Apache-2.0
2020-06-02T13:12:47
2020-06-02T13:12:46
null
UTF-8
C++
false
false
796
h
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/sync.h> #include <set> namespace searchcorespi { namespace index { /** * Class used to keep track of the set of active disk indexes in an index maintainer. * The index directories are used as identifiers. */ class ActiveDiskIndexes { std::multiset<vespalib::string> _active; vespalib::Lock _lock; public: typedef std::shared_ptr<ActiveDiskIndexes> SP; void setActive(const vespalib::string & index); void notActive(const vespalib::string & index); bool isActive(const vespalib::string & index) const; }; } // namespace index } // namespace searchcorespi
[ "bratseth@yahoo-inc.com" ]
bratseth@yahoo-inc.com
891521d4113000eb28785d26d05fe48f66258464
ec238b46f55c73f8be22315d45df590ae252dc79
/Amethyst/Source/Core/Context.h
7b813dd3b628d8d578735a82f09d00153ad06df8
[]
no_license
xRiveria/Amethyst
9c2ca3b8b142d1cb8e826cf216ea1c3c86888401
ac9acb726e9d4361b5cf4e2976448fd8d98bf7f6
refs/heads/master
2023-06-03T10:29:25.689304
2021-06-13T15:15:17
2021-06-13T15:15:17
339,117,861
0
0
null
null
null
null
UTF-8
C++
false
false
2,874
h
#pragma once #include "ISubsystem.h" #include "../Runtime/Log/Log.h" #include "AmethystDefinitions.h" namespace Amethyst { class Engine; enum class TickType { Variable, Smoothed }; struct _Subsystem { _Subsystem(const std::shared_ptr<ISubsystem> subsystem, TickType tickType) { m_SubsystemPointer = subsystem; m_TickType = tickType; } std::shared_ptr<ISubsystem> m_SubsystemPointer; TickType m_TickType; }; class Context { public: Context() = default; ~Context() { //Loop in reverse registration order to avoid dependency conflicts. for (size_t i = m_Subsystems.size() - 1; i > 0; i--) { m_Subsystems[i].m_SubsystemPointer.reset(); } m_Subsystems.clear(); } //Register a subsystem. template<typename T> void RegisterSubsystem(TickType tickType = TickType::Variable) { ValidateSubsystemType<T>(); m_Subsystems.emplace_back(std::make_shared<T>(this), tickType); } //Initialize Subsystems. void OnInitialize() { std::vector<uint32_t> failedSubsystems; // Initialize Subsystems for (uint32_t i = 0; i < static_cast<uint32_t>(m_Subsystems.size()); i++) { if (!m_Subsystems[i].m_SubsystemPointer->OnInitialize()) { failedSubsystems.emplace_back(i); AMETHYST_ERROR("Failed to initialize %s", typeid(*m_Subsystems[i].m_SubsystemPointer).name()); // Note: Calling * on a shared pointer returns the result of dereferencing the stored (raw) pointer. } } // Remove the ones that failed. for (const uint32_t failedSubsystemIndex : failedSubsystems) { m_Subsystems.erase(m_Subsystems.begin() + failedSubsystemIndex); } } // Pre-Tick void OnPreUpdate() { for (const _Subsystem& subsystem : m_Subsystems) { subsystem.m_SubsystemPointer->OnPreUpdate(); } } // Tick void OnUpdate(TickType tickType, float deltaTime = 0.0f) { for (const _Subsystem& subsystem : m_Subsystems) { if (subsystem.m_TickType != tickType) { continue; } subsystem.m_SubsystemPointer->OnUpdate(deltaTime); } } // Post-Tick void OnPostUpdate() { for (const _Subsystem& subsystem : m_Subsystems) { subsystem.m_SubsystemPointer->OnPostUpdate(); } } // Shutdown void OnShutdown() { for (const _Subsystem& subsystem : m_Subsystems) { subsystem.m_SubsystemPointer->OnShutdown(); } } //Retrieve a subsystem. template<typename T> T* RetrieveSubsystem() const { ValidateSubsystemType<T>(); for (const _Subsystem& subsystem : m_Subsystems) { if (subsystem.m_SubsystemPointer) { if (typeid(T) == typeid(*subsystem.m_SubsystemPointer)) { return static_cast<T*>(subsystem.m_SubsystemPointer.get()); } } } return nullptr; } public: Engine* m_Engine = nullptr; private: std::vector<_Subsystem> m_Subsystems; }; }
[ "ryan-wende@outlook.com" ]
ryan-wende@outlook.com
da27a855dcfd91adbb27cb7271607c1845c92cb3
faa1deda6f40791c71410db9c497a94ef922dc0c
/tests/id/id_api.cpp
cd2673860660199ac4c25b78f507b33a9eebb051
[ "Apache-2.0" ]
permissive
bader/SYCL-CTS
df2f58f1ab10d2a2900cec7c28b6279443c91d06
1a79b76f831ac756bb5c369e8d157228dcb15d3e
refs/heads/SYCL-1.2.1/master
2023-09-06T01:38:01.495070
2021-02-03T07:56:30
2021-02-03T07:56:30
196,969,522
0
0
Apache-2.0
2023-06-16T04:20:22
2019-07-15T09:38:41
C++
UTF-8
C++
false
false
7,981
cpp
/******************************************************************************* // // SYCL 1.2.1 Conformance Test Suite // // Copyright: (c) 2017 by Codeplay Software LTD. All Rights Reserved. // *******************************************************************************/ #include "../common/common.h" #define TEST_NAME id_api namespace id_api__ { using namespace sycl_cts; template <int dims> class test_kernel {}; template <int dims> void test_id_kernels( cl::sycl::id<dims> id, cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer> error_ptr, int m_iteration) { cl::sycl::id<dims> id_two(id * 2); cl::sycl::id<dims> id_three(id); size_t integer = 16; for (int j = 0; j < dims; j++) { if (id_two.get(j) == 0) { id_two[j] = 1; } } const cl::sycl::id<dims> id_two_const(id_two); const cl::sycl::id<dims> id_const(id); // operators // += INDEX_ASSIGNMENT_TESTS(+=, +, id, id_two, id_three); // -= INDEX_ASSIGNMENT_TESTS(-=, -, id, id_two, id_three); // *= INDEX_ASSIGNMENT_TESTS(*=, *, id, id_two, id_three); // /= INDEX_ASSIGNMENT_TESTS(/=, /, id, id_two, id_three); // %= INDEX_ASSIGNMENT_TESTS(%=, %, id, id_two, id_three); // >>= INDEX_ASSIGNMENT_TESTS(>>=, >>, id, id_two, id_three); // <<= INDEX_ASSIGNMENT_TESTS(<<=, <<, id, id_two, id_three); // &= INDEX_ASSIGNMENT_TESTS(&=, &, id, id_two, id_three); // |= INDEX_ASSIGNMENT_TESTS(|=, |, id, id_two, id_three); // ^= INDEX_ASSIGNMENT_TESTS(^=, ^, id, id_two, id_three); // check id<dimensions> operatorOP(const id<dimensions> &rhs) // * INDEX_KERNEL_TEST(*, id, id_two_const, id_three); // / INDEX_KERNEL_TEST(/, id, id_two_const, id_three); //+ INDEX_KERNEL_TEST(+, id, id_two_const, id_three); //- INDEX_KERNEL_TEST(-, id, id_two_const, id_three); //% INDEX_KERNEL_TEST(%, id, id_two_const, id_three); //<< INDEX_KERNEL_TEST(<<, id, id_two_const, id_three); //>> INDEX_KERNEL_TEST(>>, id, id_two_const, id_three); //& INDEX_KERNEL_TEST(&, id, id_two_const, id_three); //| INDEX_KERNEL_TEST(|, id, id_two_const, id_three); //^ INDEX_KERNEL_TEST (^, id, id_two_const, id_three); // && INDEX_KERNEL_TEST(&&, id, id_two_const, id_three); // || INDEX_KERNEL_TEST(||, id, id_two_const, id_three); // > INDEX_KERNEL_TEST(>, id, id_two_const, id_three); // < INDEX_KERNEL_TEST(<, id, id_two_const, id_three); // >= INDEX_KERNEL_TEST(>=, id, id_two_const, id_three); // <= INDEX_KERNEL_TEST(<=, id, id_two_const, id_three); // check == and != // == INDEX_EQ_KERNEL_TEST(==, id, id_two); // != INDEX_EQ_KERNEL_TEST(!=, id, id_two); // check id<dimensions> operatorOP(const size_t &rhs) // * DUAL_SIZE_INDEX_KERNEL_TEST(*, id, integer, id_three); // + DUAL_SIZE_INDEX_KERNEL_TEST(+, id, integer, id_three); // - DUAL_SIZE_INDEX_KERNEL_TEST(-, id, integer, id_three); // / DUAL_SIZE_INDEX_KERNEL_TEST(/, id, integer, id_three); // % DUAL_SIZE_INDEX_KERNEL_TEST(%, id, integer, id_three); // << DUAL_SIZE_INDEX_KERNEL_TEST(<<, id, integer, id_three); // >> DUAL_SIZE_INDEX_KERNEL_TEST(>>, id, integer, id_three); // | DUAL_SIZE_INDEX_KERNEL_TEST(|, id, integer, id_three); // ^ DUAL_SIZE_INDEX_KERNEL_TEST (^, id, integer, id_three); // && id can only be lhs INDEX_SIZE_T_KERNEL_TEST(&&, id, integer, id_three); // || id can only be lhs INDEX_SIZE_T_KERNEL_TEST(||, id, integer, id_three); // < DUAL_SIZE_INDEX_KERNEL_TEST(<, id, integer, id_three); // > DUAL_SIZE_INDEX_KERNEL_TEST(>, id, integer, id_three); // <= DUAL_SIZE_INDEX_KERNEL_TEST(<=, id, integer, id_three); // >= DUAL_SIZE_INDEX_KERNEL_TEST(>=, id, integer, id_three); // check id<dimensions> &operatorOP(const size_t &rhs) // += INDEX_ASSIGNMENT_INTEGER_TESTS(+=, +, id, integer, id_three); // -= INDEX_ASSIGNMENT_INTEGER_TESTS(-=, -, id, integer, id_three); // *= INDEX_ASSIGNMENT_INTEGER_TESTS(*=, *, id, integer, id_three); // /= INDEX_ASSIGNMENT_INTEGER_TESTS(/=, /, id, integer, id_three); // %= INDEX_ASSIGNMENT_INTEGER_TESTS(%=, %, id, integer, id_three); // >>= INDEX_ASSIGNMENT_INTEGER_TESTS(>>=, >>, id, integer, id_three); // <<= INDEX_ASSIGNMENT_INTEGER_TESTS(<<=, <<, id, integer, id_three); // &= INDEX_ASSIGNMENT_INTEGER_TESTS(&=, &, id, integer, id_three); // |= INDEX_ASSIGNMENT_INTEGER_TESTS(|=, |, id, integer, id_three); // ^= INDEX_ASSIGNMENT_INTEGER_TESTS(^=, ^, id, integer, id_three); } template <int dims> class test_id { public: // golden values static const int m_x = 16; static const int m_y = 32; static const int m_z = 64; static const int m_local = 2; static const int error_size = 200; // up to 200 possible errors int m_error[error_size]; void operator()(util::logger &log, cl::sycl::range<dims> global, cl::sycl::range<dims> local, cl::sycl::queue q) { // for testing get() for (int i = 0; i < error_size; i++) { m_error[i] = 0; // no error } { cl::sycl::buffer<int, 1> error_buffer(m_error, cl::sycl::range<1>(error_size)); q.submit([&](cl::sycl::handler &cgh) { auto my_range = cl::sycl::nd_range<dims>(global, local); auto error_ptr = error_buffer.get_access<cl::sycl::access::mode::read_write>(cgh); auto my_kernel = ([=](cl::sycl::nd_item<dims> item) { int m_iteration = 0; // create check table cl::sycl::id<dims> id = item.get_nd_range().get_global_range(); size_t check[] = {m_x, m_y, m_z}; for (int i = 0; i < dims; i++) { if (id.get(i) > check[i] || id[i] > check[i]) { // report an error error_ptr[m_iteration] = __LINE__; m_iteration++; } } test_id_kernels<dims>(id, error_ptr, m_iteration); // test all in the kernel }); cgh.parallel_for<class test_kernel<dims>>(my_range, my_kernel); }); q.wait_and_throw(); } for (int i = 0; i < error_size; i++) { CHECK_VALUE(log, m_error[i], 0, i); } } }; /** test cl::sycl::range::get(int index) return size_t */ class TEST_NAME : public util::test_base { public: /** return information about this test */ void get_info(test_base::info &out) const override { set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); } /** execute the test */ void run(util::logger &log) override { try { // use across all the dimensions auto my_queue = util::get_cts_object::queue(); // templated approach { cl::sycl::range<1> range_1d_g(test_id<1>::m_x); cl::sycl::range<2> range_2d_g(test_id<2>::m_x, test_id<2>::m_y); cl::sycl::range<3> range_3d_g(test_id<3>::m_x, test_id<3>::m_y, test_id<3>::m_z); cl::sycl::range<1> range_1d_l(test_id<1>::m_local); cl::sycl::range<2> range_2d_l(test_id<2>::m_local, test_id<2>::m_local); cl::sycl::range<3> range_3d_l(test_id<3>::m_local, test_id<3>::m_local, test_id<3>::m_local); test_id<1> test1d; test1d(log, range_1d_g, range_1d_l, my_queue); test_id<2> test2d; test2d(log, range_2d_g, range_2d_l, my_queue); test_id<3> test3d; test3d(log, range_3d_g, range_3d_l, my_queue); } } catch (const cl::sycl::exception &e) { log_exception(log, e); cl::sycl::string_class errorMsg = "a SYCL exception was caught: " + cl::sycl::string_class(e.what()); FAIL(log, errorMsg.c_str()); } } }; // construction of this proxy will register the above test util::test_proxy<TEST_NAME> proxy; } // namespace id_api__
[ "ronan.keryell@xilinx.com" ]
ronan.keryell@xilinx.com
9a7f9c0a7edfe72a3cf66d21b398fea062018c98
d7d040481472d1e1e8c2e304cd4ac4f87e248b77
/002_YouTube/Aditya Verma/Stacks/008_Trapping_Rain_Water.cpp
005846fbd70abbbff67f3059047ae8095d6d5a57
[]
no_license
Sahil1515/Competitive-Coding
9f24dec518f565074cb14ce65e1c2ebd162a49db
2bd2a2257c8cac5a5c00b37e79bbb68a24e186d4
refs/heads/master
2023-06-12T20:48:19.342064
2021-06-30T02:20:16
2021-06-30T02:20:16
290,392,677
0
0
null
null
null
null
UTF-8
C++
false
false
1,371
cpp
#include<bits/stdc++.h> using namespace std; // } Driver Code Ends class Solution{ // Function to find the trapped water between the blocks. public: int trappingWater(int arr[], int n){ // Code here int arrL[n]; int arrR[n]; int water[n]; for(int i=0;i<n;i++) { arrL[i]=arrR[i]=water[i]=0; } arrL[0]=arr[0]; for(int i=1;i<n;i++) { arrL[i]=max(arr[i],arrL[i-1]); } arrR[n-1]=arr[n-1]; for(int i=n-2;i>=0;i--) { arrR[i]=max(arr[i],arrR[i+1]); } int sum=0; for(int i=0;i<n;i++) { water[i]=min(arrL[i],arrR[i])-arr[i]; sum=sum+water[i]; } return sum; } }; // { Driver Code Starts. int main(){ int t; //testcases cin >> t; while(t--){ int n; //size of array cin >> n; int a[n]; //adding elements to the array for(int i =0;i<n;i++){ cin >> a[i]; } Solution obj; //calling trappingWater() function cout << obj.trappingWater(a, n) << endl; } return 0; } // } Driver Code Ends
[ "sahilsainisalaria@gmail.com" ]
sahilsainisalaria@gmail.com
3b2391120e2279d606d5a5e5f101454fda06eaa7
4f53831ead94da9bd133c4c2d18acba200e40039
/EngineCore/Components/PositionComponent.cpp
cbae8ff9b7aee2e6a037d2fbf0299887cc840743
[]
no_license
SolidCake98/GameEngine
d13fd733b015da1c00d88c47c372affa59d21af5
1a0de503792d9892aefaa78f979b4ab5410c9fb5
refs/heads/master
2022-09-20T22:11:38.984441
2020-06-05T16:17:21
2020-06-05T16:17:21
251,269,131
0
0
null
null
null
null
UTF-8
C++
false
false
605
cpp
// // Created by gleb on 13.05.2020. // #include "PositionComponent.h" PositionComponent::PositionComponent(float x, float y, float angle) { _x = x; _y = y; _angle = angle; } std::string PositionComponent::GetName() const { return "PositionComponent"; } float PositionComponent::GetX() const { return _x; } void PositionComponent::SetX(float x) { _x = x; } float PositionComponent::GetY() const { return _y; } void PositionComponent::SetY(float y) { _y = y; } float PositionComponent::GetAngle() const { return _angle; } void PositionComponent::SetAngle(float angle) { _angle = angle; }
[ "whnpir@gmail.com" ]
whnpir@gmail.com
c487054227236017d1944fd1371d331c3e07c0fe
0819df2c2812de2332a8ac7137aff4ca101b96df
/KT_new_1D/staggeredcell.h
940b2f170d869d291a4c15c3ac23074d5877ab90
[]
no_license
Yukee/finite-volume
48052abfd989591d6e9bdc2afa5b0eb671a2c1f6
bd81926f9dee29491d0a6f72aef744a1c4676421
refs/heads/master
2021-01-25T08:54:39.320145
2013-07-16T17:27:51
2013-07-16T17:27:51
10,644,004
0
1
null
null
null
null
UTF-8
C++
false
false
395
h
#ifndef STAGGEREDCELL_H #define STAGGEREDCELL_H #include "cell.h" #include "nt.h" /* Used with NT scheme (see nt.h for details) */ class SpatialSolver; class StaggeredCell : public Cell { public: StaggeredCell(); StaggeredCell(const double dx, const double dt); virtual void evolve(); virtual std::ostream & operator<<(std::ostream & output); }; #endif // STAGGEREDCELL_H
[ "nicolas91mace@gmail.com" ]
nicolas91mace@gmail.com
30613ef57b7c750b671110aed89638cb1803d299
21100eaf94ceb5b886fdbb6e14088bb3dfd32e8e
/BattleTank/Source/BattleTank/TankBarrel.cpp
f7b69a7b46b84af16fc20e111a18a5f05ed45344
[]
no_license
timberwang0810/Battle_Tank
1214f7fde7c6fcbef11662a8551a2eccf683d207
d2f7417ed94bb64ae5cc15336742f0cb3ddd27f1
refs/heads/master
2022-10-17T00:21:45.471339
2020-06-17T00:27:37
2020-06-17T00:27:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
481
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "TankBarrel.h" void UTankBarrel::Elevate(float RelativeSpeed){ RelativeSpeed = FMath::Clamp<float>(RelativeSpeed,-1,1); auto ElevationChange = RelativeSpeed * MaxDegreesPerSecond * GetWorld()->DeltaTimeSeconds; auto NewElevation = RelativeRotation.Pitch + ElevationChange; SetRelativeRotation(FRotator(FMath::Clamp<float>(NewElevation,MinElevation,MaxElevation),0,0)); }
[ "annie@Zilins-MBP.fios-router.home" ]
annie@Zilins-MBP.fios-router.home
c15022e62b484b292b9fe0e6357f4cda6bebf779
a0e97414e0baaf6f5dd3dfb2872349466519150d
/devices/include/factory.hpp
7c60a7f469c4996c1be3386b9b71dc5ed39ad81c
[ "MIT" ]
permissive
ellin3288/ve
1fca9d2bdf04479acf35a3ce0aa6e71e00486384
9f080319b542126f08064294efd323ac328a0b67
refs/heads/master
2020-12-11T09:15:42.032885
2014-12-09T15:04:49
2014-12-09T15:04:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
31,373
hpp
//------------------------------------------------------------------------------ // File: factory.hpp // // Desc: Device factory - Manage IP Camera. // // Copyright (c) 2014-2018 INTINT. All rights reserved. //------------------------------------------------------------------------------ #ifndef __VSC_FACTORY_H_ #define __VSC_FACTORY_H_ #include "confdb.hpp" #include "device.hpp" #include "vdb.hpp" #include "vplay.hpp" #include "sysdb.hpp" #include "hdddevice.hpp" #include <QThread> #include <qdebug.h> typedef enum { FACTORY_DEVICE_ADD = 1, FACTORY_DEVICE_DEL, FACTORY_DEVICE_ONLINE, FACTORY_DEVICE_OFFLINE, FACTORY_DEVICE_RECORDING_ON, FACTORY_DEVICE_RECORDING_OFF, /* The Camera group has been change */ FACTORY_DEVICE_GROUP_CHANGE, FACTORY_VMS_ADD, FACTORY_VMS_DEL, FACTORY_VIPC_ADD, FACTORY_VIPC_DEL, /* Camera view add and del */ FACTORY_VIEW_ADD, FACTORY_VIEW_DEL, /* Camera group add and del */ FACTORY_VGROUP_ADD, FACTORY_VGROUP_DEL, FACTORY_DEVICE_LAST } FactoryDeviceChangeType; class FactoryDeviceChangeData { public: FactoryDeviceChangeType type; int id; }; typedef BOOL (*FactoryDeviceChangeNotify)(void* pParam, FactoryDeviceChangeData data); typedef std::list<LPDevice> DeviceList; typedef std::list<DeviceParam> DeviceParamList; typedef std::map<int, LPDevice> DeviceMap; typedef std::map<int, DeviceParam> DeviceParamMap; typedef std::map<int, VIPCDeviceParam> VIPCDeviceParamMap; typedef std::map<void *, FactoryDeviceChangeNotify> DeviceChangeNofityMap; #define FACTORY_DEVICE_ID_MAX 4096 class Factory; class FactoryHddTask:public QThread { Q_OBJECT public: FactoryHddTask(Factory &pFactory); ~FactoryHddTask(); public: void run(); private: Factory &m_Factory; }; /* Fatory is Qthread for callback in Qt GUI */ class Factory: public QThread { Q_OBJECT public: Factory(); ~Factory(); public: /* Init function */ BOOL Init(); s32 InitAddDevice(DeviceParam & pParam, u32 nIndex); public: BOOL RegDeviceChangeNotify(void * pData, FactoryDeviceChangeNotify callback); BOOL CallDeviceChange(FactoryDeviceChangeData data); public: BOOL GetLicense(astring &strLicense, astring &strHostId, int &ch, int &type); BOOL SetLicense(astring &strLicense); BOOL InitLicense(); public: /* UI can use this for display device tree */ BOOL GetDeviceParamMap(DeviceParamMap &pMap); BOOL GetVIPCDeviceParamMap(VIPCDeviceParamMap &pMap); /* Device function */ s32 AddDevice(DeviceParam & pParam); s32 GetDeviceParamById(DeviceParam & pParam, s32 nIndex); BOOL GetDeviceRtspUrl(astring & strUrl, s32 nIndex); s32 GetDeviceParamByIdTryLock(DeviceParam & pParam, s32 nIndex); BOOL DelDevice(s32 nIndex); BOOL UpdateDeviceGroup(s32 nIndex, s32 nGroup); /* VIPC function */ s32 AddVIPC(VIPCDeviceParam & pParam); s32 GetVIPCParamById(VIPCDeviceParam & pParam, s32 nIndex); BOOL DelVIPC(s32 nIndex); /* Video play function */ BOOL AttachPlayer(s32 nIndex, HWND hWnd, int w, int h); BOOL UpdateWidget(s32 nIndex, HWND hWnd, int w, int h); BOOL DetachPlayer(s32 nIndex, HWND hWnd); BOOL EnablePtz(s32 nIndex, HWND hWnd, bool enable); BOOL DrawPtzDirection(s32 nIndex, HWND hWnd, int x1, int y1, int x2, int y2); BOOL ClearPtzDirection(s32 nIndex, HWND hWnd); BOOL PtzAction(s32 nIndex, FPtzAction action, float speed); BOOL ShowAlarm(s32 nIndex, HWND hWnd); public: /* VMS */ BOOL GetVms(VSCVmsData &pData); s32 AddVms(VSCVmsDataItem &pParam); BOOL DelVms(s32 Id); BOOL GetVmsById(VSCVmsDataItem &pParam, int nId); /* View */ BOOL GetView(VSCViewData &pData); s32 AddView(VSCViewDataItem &pParam); BOOL DelView(s32 Id); BOOL GetViewById(VSCViewDataItem &pParam, int nId); /* Camera group */ BOOL GetVGroup(VSCVGroupData &pData); s32 AddVGroup(VSCVGroupDataItem &pParam); BOOL DelVGroup(s32 Id); BOOL GetVGroupById(VSCVGroupDataItem &pParam, int nId); public: BOOL StartDevice(s32 nIndex); BOOL StopDevice(s32 nIndex); BOOL StartRecord(s32 nIndex); BOOL StopRecord(s32 nIndex); public: BOOL GetRecordStatus(s32 nIndex, BOOL &bStatus); public: NotificationQueue * GetRawDataQueue(s32 nIndex); BOOL ReleaseRawDataQueue(s32 nIndex, NotificationQueue * pQueue); NotificationQueue * GetDataQueue(s32 nIndex); BOOL GetDataQueue(s32 nIndex, NotificationQueue * pQueue); BOOL RegDataCallback(s32 nIndex, DeviceDataCallbackFunctionPtr pCallback, void * pParam); BOOL UnRegDataCallback(s32 nIndex, void * pParam); BOOL GetDeviceOnline(s32 nIndex, BOOL &bStatus); BOOL GetUrl(s32 nIndex, std::string &url); BOOL SetSystemPath(astring &strPath); /* Disk function */ BOOL AddHdd(astring &strHdd, astring & strPath, s64 nSize); BOOL DelHdd(astring & strHdd); BOOL HddUpdateSize(astring &strHdd, s64 nSize); BOOL GetDiskMap(VDBDiskMap &pMap); BOOL GetDiskStatus(VDBDiskStatus &pStatus); BOOL UpdateDiskStatusMap(VDBDiskStatus &pStatus); /* Search function */ BOOL SearchItems(s32 deviceId, u32 startTime, u32 endTime, u32 recordType, RecordItemMap &map); BOOL SearchAItem(s32 deviceId, u32 Time, VdbRecordItem &pItem); BOOL SearchNextItem(s32 deviceId, s64 LastId, VdbRecordItem &pItem); BOOL RequestAMFRead(VdbRecordItem &pItem, astring & strPath); BOOL FinishedAMFRead(VdbRecordItem &pItem, astring & strPath); public: void Lock(){m_Lock.lock();} bool TryLock(){return m_Lock.try_lock();} void UnLock(){m_Lock.unlock();} public: /* Device */ s32 GetDeviceID(void); BOOL ReleaseDeviceID(s32 nID); BOOL LockDeviceID(s32 nID); /* VIPC */ s32 GetVIPCID(void); BOOL ReleaseVIPCID(s32 nID); BOOL LockVIPCID(s32 nID); public: static void Run(void * pParam); void run(); private: DeviceMap m_DeviceMap; DeviceParamMap m_DeviceParamMap; /* Second stream */ DeviceMap m_DeviceMap2; DeviceParamMap m_DeviceParamMap2; /* Virtual IP camera param */ VIPCDeviceParamMap m_VIPCDeviceParamMap; fast_mutex m_Lock; tthread::thread *m_pThread; private: DeviceChangeNofityMap m_DeviceChange; private: VDB *m_pVdb; FactoryHddTask *m_HddTask; private: s8 m_strDeviceMap[FACTORY_DEVICE_ID_MAX]; s8 m_strVIPCMap[FACTORY_DEVICE_ID_MAX]; ConfDB m_Conf; SysDB m_SysPath; }; typedef Factory* LPFactory; inline FactoryHddTask::FactoryHddTask(Factory &pFactory) :m_Factory(pFactory) { } inline FactoryHddTask::~FactoryHddTask() { } inline void FactoryHddTask::run() { VDBDiskMap mapDisk; VDBDiskStatus mapStatus; while(1) { mapDisk.clear(); mapStatus.clear(); /* Get Diskmap */ m_Factory.GetDiskMap(mapDisk); /* loop to find a good disk */ for (VDBDiskMap::iterator it = mapDisk.begin(); it != mapDisk.end(); it++) { QString path((*it).second.path.c_str()); QStorageInfo info(path); VdbDiskStatus status; status.status = HDD_DISK_ERROR; status.hdd = (*it).second.hdd; status.path = (*it).second.path; if (info.isValid() == true && info.isReady() == true) { status.status = HDD_DISK_OK; } if (info.isReadOnly() == true) { status.status = HDD_DISK_READ_ONLY; } status.freeSize = info.bytesAvailable()/1024; status.totalSize = info.bytesTotal()/1024; mapStatus[(*it).second.hdd] = status; VDC_DEBUG("HDD %s path %s freeSize %lld\n", ((*it).first).c_str(), (*it).second.path.c_str(), status.freeSize); } m_Factory.UpdateDiskStatusMap(mapStatus); #ifdef WIN32 Sleep(1000 * 2); #else sleep(2); #endif } } inline void OnvifLog(char * str) { VDC_DEBUG( "%s\n", str); return; } inline Factory::Factory() { #ifdef WIN32 astring strSysPath = "C:\\videodb\\system"; #else astring strSysPath = "ve/videodb/system/"; #endif m_SysPath.Open(strSysPath); } inline Factory::~Factory() { } inline BOOL Factory::SetSystemPath(astring &strPath) { return m_SysPath.SetSystemPath(strPath); } inline BOOL Factory::Init() { s32 i = 0; for (i = 0; i < FACTORY_DEVICE_ID_MAX; i ++) { m_strDeviceMap[i] = 'n'; } for (i = 0; i < FACTORY_DEVICE_ID_MAX; i ++) { m_strVIPCMap[i] = 'n'; } astring strPath; if (m_SysPath.GetSystemPath(strPath) == FALSE) { return FALSE; //strPath = "C:\\video";//TODO get the path from user } printf("Sys path %s\n", strPath.c_str()); #ifdef WIN32 astring strPathConf = strPath + "videodb\\config"; #else astring strPathConf = strPath + "videodb/config"; #endif m_Conf.Open(strPathConf); astring strPathDb = strPath + "videodb"; m_pVdb = new VDB(strPathDb); VSCConfData sysData; m_Conf.GetSysData(sysData); for (s32 i = 1; i < CONF_MAP_MAX; i ++) { if (sysData.data.conf.DeviceMap[i] != CONF_MAP_INVALID_MIN && sysData.data.conf.DeviceMap[i] != 0) { VDC_DEBUG( "%s Init Device %d\n",__FUNCTION__, i); VSCDeviceData Data; m_Conf.GetDeviceData(i, Data); DeviceParam mParam(Data); LockDeviceID(Data.data.conf.nId); InitAddDevice(mParam, Data.data.conf.nId); VDC_DEBUG( "%s Id %d\n",__FUNCTION__, Data.data.conf.nId); } } for (s32 i = 1; i < CONF_MAP_MAX; i ++) { if (sysData.data.conf.VIPCMap[i] != CONF_MAP_INVALID_MIN && sysData.data.conf.VIPCMap[i] != 0) { VDC_DEBUG( "%s Init VIPC %d\n",__FUNCTION__, i); VSCVIPCData Data; m_Conf.GetVIPCData(i, Data); VIPCDeviceParam mParam(Data); LockVIPCID(Data.data.conf.nId); m_VIPCDeviceParamMap[i] = mParam; VDC_DEBUG( "%s Id %d\n",__FUNCTION__, Data.data.conf.nId); } } #if 0 /* Init the Virtual Camera */ VIPCDeviceParam vipc; //add two fake one strcpy(vipc.m_Conf.data.conf.IP, "192.168.1.4"); strcpy(vipc.m_Conf.data.conf.Name, "VIPC 1"); strcpy(vipc.m_Conf.data.conf.Port, "8000"); m_VIPCDeviceParamMap[1] = vipc; strcpy(vipc.m_Conf.data.conf.IP, "192.168.22.15"); strcpy(vipc.m_Conf.data.conf.Name, "VIPC 2"); strcpy(vipc.m_Conf.data.conf.Port, "8000"); m_VIPCDeviceParamMap[2] = vipc; strcpy(vipc.m_Conf.data.conf.IP, "192.168.22.15"); strcpy(vipc.m_Conf.data.conf.Name, "VIPC 3"); strcpy(vipc.m_Conf.data.conf.Port, "8001"); m_VIPCDeviceParamMap[3] = vipc; #endif InitLicense(); //m_pThread = new thread(Factory::Run, (void *)this); //start(); m_HddTask = new FactoryHddTask(*this); m_HddTask->start(); return TRUE; } inline BOOL Factory::RegDeviceChangeNotify(void * pData, FactoryDeviceChangeNotify callback) { Lock(); m_DeviceChange[pData] = callback; UnLock(); return TRUE; } inline BOOL Factory::CallDeviceChange(FactoryDeviceChangeData data) { DeviceChangeNofityMap::iterator it = m_DeviceChange.begin(); for(; it!=m_DeviceChange.end(); ++it) { if ((*it).second) { (*it).second((*it).first, data); } } return TRUE; } inline BOOL Factory::GetLicense(astring &strLicense, astring &strHostId, int &ch, int &type) { VPlay::GetLicenseInfo(strHostId, ch, type); return m_Conf.GetLicense(strLicense); } inline BOOL Factory::SetLicense(astring &strLicense) { VPlay::SetLicense(strLicense); return m_Conf.SetLicense(strLicense); } inline BOOL Factory::InitLicense() { astring strLicense; m_Conf.GetLicense(strLicense); VPlay::SetLicense(strLicense); return TRUE; } inline BOOL Factory::AddHdd(astring &strHdd, astring & strPath, s64 nSize) { //astring strPathHdd = strPath + "videodb"; return m_pVdb->AddHdd(strHdd, strPath, nSize); } inline BOOL Factory::DelHdd(astring & strHdd) { return m_pVdb->DelHdd(strHdd); } inline BOOL Factory::HddUpdateSize(astring &strHdd, s64 nSize) { return m_pVdb->HddUpdateSize(strHdd, nSize); } inline BOOL Factory::GetDiskMap(VDBDiskMap &pMap) { return m_pVdb->GetDiskMap(pMap); } inline BOOL Factory::GetDiskStatus(VDBDiskStatus &pStatus) { return m_pVdb->GetDiskStatus(pStatus); } inline BOOL Factory::UpdateDiskStatusMap(VDBDiskStatus &pStatus) { return m_pVdb->UpdateDiskStatusMap(pStatus); } inline BOOL Factory::SearchItems(s32 deviceId, u32 startTime, u32 endTime, u32 recordType, RecordItemMap &map) { return m_pVdb->SearchItems(deviceId, startTime, endTime, recordType, map); } inline BOOL Factory::SearchAItem(s32 deviceId, u32 Time, VdbRecordItem &pItem) { return m_pVdb->SearchAItem(deviceId, Time, pItem); } inline BOOL Factory::SearchNextItem(s32 deviceId, s64 LastId, VdbRecordItem &pItem) { return m_pVdb->SearchNextItem(deviceId, LastId, pItem); } inline BOOL Factory::RequestAMFRead(VdbRecordItem &pItem, astring & strPath) { return m_pVdb->RequestAMFRead(pItem, strPath); } inline BOOL Factory::FinishedAMFRead(VdbRecordItem &pItem, astring & strPath) { return m_pVdb->FinishedAMFRead(pItem, strPath); } inline BOOL Factory::GetDeviceParamMap(DeviceParamMap &pMap) { pMap = m_DeviceParamMap; return TRUE; } inline BOOL Factory::GetVIPCDeviceParamMap(VIPCDeviceParamMap &pMap) { pMap = m_VIPCDeviceParamMap; return TRUE; } inline s32 Factory::InitAddDevice(DeviceParam & pParam, u32 nIndex) { if (pParam.m_Conf.data.conf.nType == VSC_DEVICE_CAM) { m_DeviceMap[nIndex] = new Device(*m_pVdb, pParam); }else { m_DeviceMap[nIndex] = NULL; } m_DeviceParamMap[nIndex] = pParam; return TRUE; } inline NotificationQueue * Factory::GetRawDataQueue(s32 nIndex) { NotificationQueue * pQueue = NULL; Lock(); if (m_DeviceMap[nIndex] != NULL) { pQueue = m_DeviceMap[nIndex]->GetRawDataQueue(); } UnLock(); return pQueue; } inline BOOL Factory::ReleaseRawDataQueue(s32 nIndex, NotificationQueue * pQueue) { Lock(); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->ReleaseRawDataQueue(pQueue); } UnLock(); return TRUE; } inline NotificationQueue * Factory::GetDataQueue(s32 nIndex) { return NULL; } inline BOOL Factory::GetDataQueue(s32 nIndex, NotificationQueue * pQueue) { return TRUE; } inline BOOL Factory::RegDataCallback(s32 nIndex, DeviceDataCallbackFunctionPtr pCallback, void * pParam) { Lock(); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->RegDataCallback(pCallback, pParam); } UnLock(); return TRUE; } inline BOOL Factory::GetDeviceOnline(s32 nIndex, BOOL &bStatus) { if (TryLock() == false) { return FALSE; } if (m_DeviceMap[nIndex] != NULL) { bStatus = m_DeviceMap[nIndex]->GetDeviceOnline(); } UnLock(); return TRUE; } inline BOOL Factory::GetUrl(s32 nIndex, std::string &url) { BOOL ret = FALSE; if (m_DeviceMap[nIndex] != NULL) { ret = m_DeviceMap[nIndex]->GetUrl(url); } UnLock(); return ret; } inline BOOL Factory::UnRegDataCallback(s32 nIndex, void * pParam) { Lock(); if (m_DeviceMap[nIndex] != NULL) { UnLock(); return m_DeviceMap[nIndex]->UnRegDataCallback(pParam); } UnLock(); return TRUE; } inline BOOL Factory::StartDevice(s32 nIndex) { Lock(); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->Start(); } UnLock(); return TRUE; } inline BOOL Factory::AttachPlayer(s32 nIndex, HWND hWnd, int w, int h) { //Lock();//For VIPC testing if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->AttachPlayer(hWnd, w, h); } //UnLock(); return TRUE; } inline BOOL Factory::UpdateWidget(s32 nIndex, HWND hWnd, int w, int h) { Lock(); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->UpdateWidget(hWnd, w, h); } UnLock(); return TRUE; } inline BOOL Factory::DetachPlayer(s32 nIndex, HWND hWnd) { Lock(); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->DetachPlayer(hWnd); } UnLock(); return TRUE; } inline BOOL Factory::EnablePtz(s32 nIndex, HWND hWnd, bool enable) { Lock(); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->EnablePtz(hWnd, enable); } UnLock(); return TRUE; } inline BOOL Factory::DrawPtzDirection(s32 nIndex, HWND hWnd, int x1, int y1, int x2, int y2) { Lock(); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->DrawPtzDirection(hWnd, x1, y1, x2, y2); } UnLock(); return TRUE; } inline BOOL Factory::ShowAlarm(s32 nIndex, HWND hWnd) { Lock(); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->ShowAlarm(hWnd); } UnLock(); return TRUE; } inline BOOL Factory::ClearPtzDirection(s32 nIndex, HWND hWnd) { Lock(); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->ClearPtzDirection(hWnd); } UnLock(); return TRUE; } inline BOOL Factory::PtzAction(s32 nIndex, FPtzAction action, float speed) { Lock(); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->PtzAction(action, speed); } UnLock(); return TRUE; } inline BOOL Factory::StopDevice(s32 nIndex) { Lock(); UnLock(); return TRUE; } inline BOOL Factory::GetRecordStatus(s32 nIndex,BOOL &nStatus) { DeviceParam pParam; if (nIndex <=0 || nIndex >= FACTORY_DEVICE_ID_MAX) { return FALSE; } if (GetDeviceParamByIdTryLock(pParam, nIndex) == FALSE) { return FALSE; } if (pParam.m_Conf.data.conf.Recording == 1) { nStatus = TRUE; }else { nStatus = FALSE; } return TRUE; } inline BOOL Factory::StartRecord(s32 nIndex) { DeviceParam pParam; FactoryDeviceChangeData change; if (nIndex <=0 || nIndex >= FACTORY_DEVICE_ID_MAX) { return FALSE; } GetDeviceParamById(pParam, nIndex); if (pParam.m_Conf.data.conf.Recording == 1) { return TRUE; } Lock(); pParam.m_Conf.data.conf.Recording = 1; m_Conf.UpdateDeviceData(nIndex, pParam.m_Conf); m_DeviceParamMap[nIndex] = pParam; if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->SetRecord(TRUE); m_DeviceMap[nIndex]->StartRecord(); } UnLock(); change.id = nIndex; change.type = FACTORY_DEVICE_RECORDING_ON; CallDeviceChange(change); return TRUE; } inline BOOL Factory::StopRecord(s32 nIndex) { DeviceParam pParam; FactoryDeviceChangeData change; if (nIndex <=0 || nIndex >= FACTORY_DEVICE_ID_MAX) { return FALSE; } GetDeviceParamById(pParam, nIndex); if (pParam.m_Conf.data.conf.Recording == 0) { return TRUE; } Lock(); pParam.m_Conf.data.conf.Recording = 0; m_DeviceParamMap[nIndex] = pParam; m_Conf.UpdateDeviceData(nIndex, pParam.m_Conf); if (m_DeviceMap[nIndex] != NULL) { m_DeviceMap[nIndex]->SetRecord(FALSE); m_DeviceMap[nIndex]->StopRecord(); } UnLock(); change.id = nIndex; change.type = FACTORY_DEVICE_RECORDING_OFF; CallDeviceChange(change); return TRUE; } inline BOOL Factory::UpdateDeviceGroup(s32 nIndex, s32 nGroup) { DeviceParam pParam; FactoryDeviceChangeData change; if (nIndex <=0 || nIndex >= FACTORY_DEVICE_ID_MAX) { return FALSE; } GetDeviceParamById(pParam, nIndex); if (pParam.m_Conf.data.conf.GroupId == nGroup) { return TRUE; } Lock(); pParam.m_Conf.data.conf.GroupId = nGroup; m_DeviceParamMap[nIndex] = pParam; m_Conf.UpdateDeviceData(nIndex, pParam.m_Conf); UnLock(); change.id = nIndex; change.type = FACTORY_DEVICE_GROUP_CHANGE; CallDeviceChange(change); return TRUE; } inline s32 Factory::AddDevice(DeviceParam & pParam) { s32 nId = GetDeviceID(); FactoryDeviceChangeData change; VDC_DEBUG( "%s GetDeviceID %d\n",__FUNCTION__, nId); Lock(); pParam.m_Conf.data.conf.nId = nId; m_DeviceParamMap[nId] = pParam; m_Conf.AddDevice(pParam.m_Conf, nId); if (pParam.m_Conf.data.conf.nType == VSC_DEVICE_CAM) { m_DeviceMap[nId] = new Device(*m_pVdb, pParam); }else { m_DeviceMap[nId] = NULL; } VDC_DEBUG( "%s Line %d\n",__FUNCTION__, __LINE__); UnLock(); VDC_DEBUG( "%s Line %d\n",__FUNCTION__, __LINE__); change.id = nId; change.type = FACTORY_DEVICE_ADD; CallDeviceChange(change); VDC_DEBUG( "%s Line %d\n",__FUNCTION__, __LINE__); return nId; } inline BOOL Factory::DelDevice(s32 nIndex) { FactoryDeviceChangeData change; VDC_DEBUG( "%s DelDevice %d\n",__FUNCTION__, nIndex); if (nIndex <=0 || nIndex >= FACTORY_DEVICE_ID_MAX) { return FALSE; } //TODO check is this device can be delete or not Lock(); VDC_DEBUG( "%s Cleanup Begin\n",__FUNCTION__); m_DeviceMap[nIndex]->Cleanup(); VDC_DEBUG( "%s Cleanup End\n",__FUNCTION__); delete m_DeviceMap[nIndex]; m_DeviceMap[nIndex] = NULL; m_DeviceParamMap.erase(nIndex); m_DeviceMap.erase(nIndex); m_Conf.DelDevice(nIndex); UnLock(); ReleaseDeviceID(nIndex); change.id = nIndex; change.type = FACTORY_DEVICE_DEL; CallDeviceChange(change); return TRUE; } inline s32 Factory::AddVIPC(VIPCDeviceParam & pParam) { s32 nId = GetVIPCID(); FactoryDeviceChangeData change; VDC_DEBUG( "%s GetDeviceID %d\n",__FUNCTION__, nId); Lock(); pParam.m_Conf.data.conf.nId = nId; m_VIPCDeviceParamMap[nId] = pParam; m_Conf.AddVIPC(pParam.m_Conf, nId); VDC_DEBUG( "%s Line %d\n",__FUNCTION__, __LINE__); UnLock(); VDC_DEBUG( "%s Line %d\n",__FUNCTION__, __LINE__); change.id = nId; change.type = FACTORY_VIPC_ADD; CallDeviceChange(change); VDC_DEBUG( "%s Line %d\n",__FUNCTION__, __LINE__); return nId; } inline s32 Factory::GetVIPCParamById(VIPCDeviceParam & pParam, s32 nIndex) { //VDC_DEBUG( "%s GetDeviceParamById %d\n",__FUNCTION__, nIndex); if (nIndex <=0 || nIndex >= FACTORY_DEVICE_ID_MAX) { return FALSE; } Lock(); pParam = m_VIPCDeviceParamMap[nIndex]; UnLock(); return TRUE; } inline BOOL Factory::DelVIPC(s32 nIndex) { FactoryDeviceChangeData change; VDC_DEBUG( "%s DelDevice %d\n",__FUNCTION__, nIndex); if (nIndex <=0 || nIndex >= FACTORY_DEVICE_ID_MAX) { return FALSE; } change.id = nIndex; change.type = FACTORY_VIPC_DEL; CallDeviceChange(change); Lock(); m_VIPCDeviceParamMap.erase(nIndex); m_Conf.DelVIPC(nIndex); ReleaseVIPCID(nIndex); UnLock(); return TRUE; } inline BOOL Factory::GetVms(VSCVmsData &pData) { Lock(); m_Conf.GetVmsData(pData); UnLock(); return TRUE; } inline BOOL Factory::GetVmsById(VSCVmsDataItem &pParam, int nId) { VSCVmsData VmsData; int id = -1; Lock(); m_Conf.GetVmsData(VmsData); if (nId < CONF_VMS_NUM_MAX && nId > 0) { if (VmsData.data.conf.vms[nId].Used == 1) { memcpy(&pParam, &(VmsData.data.conf.vms[nId]), sizeof(VSCVmsDataItem)); } }else { UnLock(); return FALSE; } return TRUE; } inline s32 Factory::AddVms(VSCVmsDataItem &pParam) { VSCVmsData VmsData; FactoryDeviceChangeData change; int id = -1; Lock(); m_Conf.GetVmsData(VmsData); /* Just use 1 to CONF_VMS_NUM_MAX */ for (s32 i = 1; i < CONF_VMS_NUM_MAX; i ++) { if (VmsData.data.conf.vms[i].Used == 1) { continue; }else { memcpy(&(VmsData.data.conf.vms[i]), &pParam, sizeof(VSCVmsDataItem)); VmsData.data.conf.vms[i].Used = 1; VmsData.data.conf.vms[i].nId = i; id = i; break; } } m_Conf.UpdateVmsData(VmsData); UnLock(); change.id = id; change.type = FACTORY_VMS_ADD; CallDeviceChange(change); return id; } inline BOOL Factory::DelVms(s32 Id) { VSCVmsData VmsData; FactoryDeviceChangeData change; Lock(); m_Conf.GetVmsData(VmsData); if (Id < CONF_VMS_NUM_MAX && Id > 0) { VmsData.data.conf.vms[Id].Used = 0; }else { UnLock(); return FALSE; } m_Conf.UpdateVmsData(VmsData); UnLock(); change.id = Id; change.type = FACTORY_VMS_DEL; CallDeviceChange(change); return TRUE; } inline BOOL Factory::GetView(VSCViewData &pData) { Lock(); m_Conf.GetViewData(pData); UnLock(); return TRUE; } inline BOOL Factory::GetViewById(VSCViewDataItem &pParam, int nId) { VSCViewData ViewData; int id = -1; Lock(); m_Conf.GetViewData(ViewData); if (nId < CONF_VMS_NUM_MAX && nId > 0) { if (ViewData.data.conf.view[nId].Used == 1) { memcpy(&pParam, &(ViewData.data.conf.view[nId]), sizeof(VSCViewDataItem)); } }else { UnLock(); return FALSE; } UnLock(); return TRUE; } inline s32 Factory::AddView(VSCViewDataItem &pParam) { VSCViewData ViewData; FactoryDeviceChangeData change; int id = -1; Lock(); m_Conf.GetViewData(ViewData); /* Just use 1 to CONF_VIEW_NUM_MAX */ for (s32 i = 1; i < CONF_VIEW_NUM_MAX; i ++) { if (ViewData.data.conf.view[i].Used == 1) { continue; }else { memcpy(&(ViewData.data.conf.view[i]), &pParam, sizeof(VSCViewDataItem)); ViewData.data.conf.view[i].Used = 1; ViewData.data.conf.view[i].nId = i; id = i; break; } } m_Conf.UpdateViewData(ViewData); UnLock(); change.id = id; change.type = FACTORY_VIEW_ADD; CallDeviceChange(change); return id; } inline BOOL Factory::DelView(s32 Id) { VSCViewData ViewData; FactoryDeviceChangeData change; Lock(); m_Conf.GetViewData(ViewData); if (Id < CONF_VMS_NUM_MAX && Id > 0) { ViewData.data.conf.view[Id].Used = 0; }else { UnLock(); return FALSE; } m_Conf.UpdateViewData(ViewData); UnLock(); change.id = Id; change.type = FACTORY_VIEW_DEL; CallDeviceChange(change); return TRUE; } inline BOOL Factory::GetVGroup(VSCVGroupData &pData) { Lock(); m_Conf.GetVGroupData(pData); UnLock(); return TRUE; } inline BOOL Factory::GetVGroupById(VSCVGroupDataItem &pParam, int nId) { VSCVGroupData VGroupData; int id = -1; Lock(); m_Conf.GetVGroupData(VGroupData); if (nId < CONF_VGROUP_NUM_MAX && nId > 0) { if (VGroupData.data.conf.group[nId].Used == 1) { memcpy(&pParam, &(VGroupData.data.conf.group[nId]), sizeof(VSCVGroupDataItem)); } }else { UnLock(); return FALSE; } UnLock(); return TRUE; } inline s32 Factory::AddVGroup(VSCVGroupDataItem &pParam) { VSCVGroupData VGroupData; FactoryDeviceChangeData change; int id = -1; Lock(); m_Conf.GetVGroupData(VGroupData); /* Just use 1 to CONF_VGROUP_NUM_MAX */ for (s32 i = 1; i < CONF_VGROUP_NUM_MAX; i ++) { if (VGroupData.data.conf.group[i].Used == 1) { continue; }else { memcpy(&(VGroupData.data.conf.group[i]), &pParam, sizeof(VSCVGroupDataItem)); VGroupData.data.conf.group[i].Used = 1; VGroupData.data.conf.group[i].nId = i; id = i; break; } } m_Conf.UpdateVGroupData(VGroupData); UnLock(); change.id = id; change.type = FACTORY_VGROUP_ADD; CallDeviceChange(change); return id; } inline BOOL Factory::DelVGroup(s32 Id) { VSCVGroupData VGroupData; FactoryDeviceChangeData change; Lock(); m_Conf.GetVGroupData(VGroupData); if (Id < CONF_VGROUP_NUM_MAX && Id > 0) { VGroupData.data.conf.group[Id].Used = 0; }else { UnLock(); return FALSE; } m_Conf.UpdateVGroupData(VGroupData); UnLock(); change.id = Id; change.type = FACTORY_VGROUP_DEL; CallDeviceChange(change); return TRUE; } inline BOOL Factory::GetDeviceRtspUrl(astring & strUrl, s32 nIndex) { BOOL ret = FALSE; Lock(); if (m_DeviceMap[nIndex] != NULL) { ret = m_DeviceMap[nIndex]->GetDeviceRtspUrl(strUrl); } UnLock(); return ret; } inline s32 Factory::GetDeviceParamById(DeviceParam & pParam, s32 nIndex) { //VDC_DEBUG( "%s GetDeviceParamById %d\n",__FUNCTION__, nIndex); if (nIndex <=0 || nIndex >= FACTORY_DEVICE_ID_MAX) { return FALSE; } Lock(); pParam = m_DeviceParamMap[nIndex]; UnLock(); return TRUE; } inline s32 Factory::GetDeviceParamByIdTryLock(DeviceParam & pParam, s32 nIndex) { //VDC_DEBUG( "%s GetDeviceParamById %d\n",__FUNCTION__, nIndex); if (nIndex <=0 || nIndex >= FACTORY_DEVICE_ID_MAX) { return FALSE; } #if 1 if (TryLock() == false) { return FALSE; } #else Lock(); #endif pParam = m_DeviceParamMap[nIndex]; UnLock(); return TRUE; } inline s32 Factory::GetDeviceID(void) { s32 id = -1; s32 i = -1; Lock(); for (i = 1; i < FACTORY_DEVICE_ID_MAX; i ++) { if (m_strDeviceMap[i] == 'n') { id = i; m_strDeviceMap[i] = 'y'; UnLock(); return id; } } UnLock(); return id; } inline BOOL Factory::ReleaseDeviceID(s32 nID) { if (nID <=0 || nID >= FACTORY_DEVICE_ID_MAX) { return FALSE; } Lock(); m_strDeviceMap[nID] = 'n'; UnLock(); return TRUE; } inline BOOL Factory::LockDeviceID(s32 nID) { if (nID <=0 || nID >= FACTORY_DEVICE_ID_MAX) { return FALSE; } Lock(); m_strDeviceMap[nID] = 'y'; UnLock(); return TRUE; } inline s32 Factory::GetVIPCID(void) { s32 id = -1; s32 i = -1; Lock(); for (i = 1; i < FACTORY_DEVICE_ID_MAX; i ++) { if (m_strVIPCMap[i] == 'n') { id = i; m_strVIPCMap[i] = 'y'; UnLock(); return id; } } UnLock(); return id; } inline BOOL Factory::ReleaseVIPCID(s32 nID) { if (nID <=0 || nID >= FACTORY_DEVICE_ID_MAX) { return FALSE; } Lock(); m_strVIPCMap[nID] = 'n'; UnLock(); return TRUE; } inline BOOL Factory::LockVIPCID(s32 nID) { if (nID <=0 || nID >= FACTORY_DEVICE_ID_MAX) { return FALSE; } Lock(); m_strVIPCMap[nID] = 'y'; UnLock(); return TRUE; } inline void Factory::Run(void * pParam) { int dummy = errno; LPFactory pThread = (LPFactory)pParam; if (pThread) { //pThread->Run1(); } } inline void Factory::run() { int lastIdx = 0; /* Create the thread to update the Disk status */ //First updateDisk Status and then start the thread to update the disk status while (1) { Lock(); DeviceMap::iterator it = m_DeviceMap.begin(); for(; it!=m_DeviceMap.end(); ++it) { s32 nIndex = (*it).first; DeviceMap::iterator next = it; next ++; //VDC_DEBUG( "%s run CheckDevice %d 1\n",__FUNCTION__, nIndex); if (lastIdx +1 > nIndex && next != m_DeviceMap.end()) { continue; } if (next == m_DeviceMap.end()) { lastIdx = 0; }else { lastIdx = nIndex; } //VDC_DEBUG( "%s run CheckDevice %d 2\n",__FUNCTION__, nIndex); if (m_DeviceMap[nIndex]) { FactoryDeviceChangeData change; change.id = nIndex; switch (m_DeviceMap[nIndex]->CheckDevice()) { case DEV_OFF2ON: { change.type = FACTORY_DEVICE_ONLINE; UnLock(); CallDeviceChange(change); Lock(); break; } case DEV_ON2OFF: { change.type = FACTORY_DEVICE_OFFLINE; UnLock(); CallDeviceChange(change); Lock(); break; } default: { break; } } } break; } UnLock(); #ifdef WIN32 Sleep(1000 * 2); #else sleep(2); #endif } } #endif // __VSC_FACTORY_H_
[ "xsmart@163.com" ]
xsmart@163.com
f5262edc4705f6e5e228cd2650fcf361600b5b42
5a60d60fca2c2b8b44d602aca7016afb625bc628
/aws-cpp-sdk-athena/include/aws/athena/model/UpdateNamedQueryResult.h
090c08097cb92bfe1994dab4944b771a8dd65df2
[ "Apache-2.0", "MIT", "JSON" ]
permissive
yuatpocketgems/aws-sdk-cpp
afaa0bb91b75082b63236cfc0126225c12771ed0
a0dcbc69c6000577ff0e8171de998ccdc2159c88
refs/heads/master
2023-01-23T10:03:50.077672
2023-01-04T22:42:53
2023-01-04T22:42:53
134,497,260
0
1
null
2018-05-23T01:47:14
2018-05-23T01:47:14
null
UTF-8
C++
false
false
785
h
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/athena/Athena_EXPORTS.h> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace Athena { namespace Model { class UpdateNamedQueryResult { public: AWS_ATHENA_API UpdateNamedQueryResult(); AWS_ATHENA_API UpdateNamedQueryResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); AWS_ATHENA_API UpdateNamedQueryResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); }; } // namespace Model } // namespace Athena } // namespace Aws
[ "aws-sdk-cpp-automation@github.com" ]
aws-sdk-cpp-automation@github.com
6aa49bc44680a4ed2fc21bd64a431cf918f6fd67
1ed34e46bbd9d77d1e74a133fc2f1ffab49a2397
/src/wireguard/wireguard.cpp
577b4336bd41769691e56aa86d672217b4941d6c
[ "MIT" ]
permissive
raydwaipayan/wg-gui
f43639d00410fd97159ba736ed05fc506edb6ed3
26bcee64f94d493f6a51108dc748f74e5312c04b
refs/heads/master
2022-12-06T03:22:32.304584
2020-08-20T15:24:48
2020-08-20T15:24:48
284,971,812
2
0
null
null
null
null
UTF-8
C++
false
false
2,740
cpp
// Copyright 2020 Banbreach // Written by Dwaipayan Ray // 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 "wireguard.h" #include <QDebug> wg::WireGuard::WireGuard() { // The process is run every second to fetch the current wireguard active // configuration. process = new QProcess(); timer = new QTimer(); connect(process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(emitReadComplete(int,QProcess::ExitStatus))); connect(timer, SIGNAL(timeout()), this, SLOT(processWgActive())); processWgActive(); timer->start(1000); } void wg::WireGuard::emitReadComplete(int, QProcess::ExitStatus) // Once process is finished, emit a signal containing the stdout which shall be // catched by the slot in the // mainwindow component { QString out = process->readAllStandardOutput(); emit this->readComplete(out); } void wg::WireGuard::processWgActive() // Starts the wg process { process->start("wg", QStringList() << "show"); } bool wg::WireGuard::connectTunnel(const QString& tunnel_name) // Connect to the given wireguard tunnel. Creates a qprocess and calls wg-quick // to bring up the tunnel { QProcess p; p.start("wg-quick", QStringList() << "up" << tunnel_name); p.waitForFinished(); if (p.exitCode()) { return false; } return true; } bool wg::WireGuard::disconnectTunnel(const QString& tunnel_name) // Disonnect the given wireguard tunnel. Creates a qprocess and calls wg-quick // to bring down the tunnel { QProcess p; p.start("wg-quick", QStringList() << "down" << tunnel_name); p.waitForFinished(); if (p.exitCode()) { return false; } return true; }
[ "dwaipayanray1@gmail.com" ]
dwaipayanray1@gmail.com
8ab60637de4e96af2e6241e9a21807648d5c9b58
e42e01a33985d2ac4e8c85407243d968f0bc845e
/solution/372-Delete-Node-in-a-Linked-List/372-Delete-Node-in-a-Linked-List.cpp
ac694a981b21599f0d9a107f954fe6117f533dd5
[]
no_license
Snow-Crash/lintcode-practice
dd6646814aa8f18917b64fbb4561bfe71e6511b9
11950eec472777d39a7034c2986c80b6fb76ef7a
refs/heads/master
2023-01-22T00:58:49.779520
2020-11-13T05:52:14
2020-11-13T05:52:14
268,988,706
0
0
null
null
null
null
UTF-8
C++
false
false
997
cpp
// 372-Delete-Node-in-a-Linked-List.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> class ListNode { public: int val; ListNode* next; ListNode(int val) { this->val = val; this->next = NULL; } }; class Solution { public: /* * @param node: the node in the list should be deleted * @return: nothing */ void deleteNode(ListNode* node) { // write your code here ListNode* slow = node; ListNode* fast = node; ListNode* prev = node; while (fast != NULL && fast->next != NULL) { prev = slow; slow = slow->next; fast = fast->next->next; } prev->next = slow->next; } }; int main() { ListNode n1(1); ListNode n2(2); ListNode n3(3); ListNode n4(4); n1.next = &n2; n2.next = &n3; n3.next = &n4; Solution solution; solution.deleteNode(&n1); }
[ "hfang02@syr.edu" ]
hfang02@syr.edu
f829612f9240feb0639d0ecbf6523fe55c595472
5f8482008795504e17db32c814586567d8ad8483
/MCValidation/two_particle_plots.h
ab057b278fa9bf6924c4bedb4dd504557fab53a6
[]
no_license
AtlasWHHV/ATLASMCValidation
4694cf096f39be3f393ec6f41656aca9e110fd1d
3b33e86eadb577f00ff9d5201d4d7288b0499820
refs/heads/master
2020-12-31T07:11:49.959589
2017-02-01T01:53:58
2017-02-01T01:53:58
80,581,202
0
0
null
null
null
null
UTF-8
C++
false
false
3,724
h
#ifndef __two_particle_plots__ #define __two_particle_plots__ #include "xAODTruth/TruthParticle.h" #include "TH1.h" #include <string> class two_particle_plots { public: two_particle_plots(const std::string &name, const std::string &title) { _deltaR = new TH1F ((name + "DR" ).c_str(), (title + "\\Delta R; \\Delta R").c_str(), 100, 0.0, 5.0); _deltaPhi = new TH1F ((name + "Dphi").c_str(), (title + "|\\Delta \\phi|; |\\Delta \\phi|").c_str(), 100, 0, 3.5); _deltaEta = new TH1F ((name + "Deta").c_str(), (title + "|\\Delta \\eta|; |\\Delta \\eta|").c_str(), 100, 0, 3.0 ); _deltaR_e = new TH1F ((name + "DR_e" ).c_str(), (title + "\\Delta R electrons; \\Delta R electrons").c_str(), 100, 0.0, 5.0); _deltaPhi_e = new TH1F ((name + "Dphi_e").c_str(), (title + "|\\Delta \\phi| electrons; |\\Delta \\phi| electrons").c_str(), 100, 0, 3.5); _deltaEta_e = new TH1F ((name + "Deta_e").c_str(), (title + "|\\Delta \\eta| electrons; |\\Delta \\eta| electrons").c_str(), 100, 0, 3.0 ); _deltaR_mu = new TH1F ((name + "DR_mu" ).c_str(), (title + "\\Delta R muons; \\Delta R muons").c_str(), 100, 0.0, 5.0); _deltaPhi_mu = new TH1F ((name + "Dphi_mu").c_str(), (title + "|\\Delta \\phi| muons; |\\Delta \\phi| muons").c_str(), 100, 0, 3.5); _deltaEta_mu = new TH1F ((name + "Deta_mu").c_str(), (title + "|\\Delta \\eta| muons; |\\Delta \\eta| muons").c_str(), 100, 0, 3.0 ); _deltaR_tau = new TH1F ((name + "DR_tau" ).c_str(), (title + "\\Delta R taus; \\Delta R taus").c_str(), 100, 0.0, 5.0); _deltaPhi_tau = new TH1F ((name + "Dphi_tau").c_str(), (title + "|\\Delta \\phi| taus; |\\Delta \\phi| taus").c_str(), 100, 0, 3.5); _deltaEta_tau = new TH1F ((name + "Deta_tau").c_str(), (title + "|\\Delta \\eta| taus; |\\Delta \\eta| taus").c_str(), 100, 0, 3.0 ); } void addParticle (const xAOD::TruthParticle *p) { _stash.push_back(p); } // This is where the work happens void EndOfEvent() { if (_stash.size() < 2) { cout << "At end of event, not enough particles" << endl; } bool electrons=false; if ( (_stash[0]->pdgId()==13 && _stash[1]->pdgId()==-13) || (_stash[0]->pdgId()==-13 && _stash[1]->pdgId()==13) ) electrons=true; bool muons=false; if ( (_stash[0]->pdgId()==11 && _stash[1]->pdgId()==-11) || (_stash[0]->pdgId()==-11 && _stash[1]->pdgId()==11) ) muons=true; bool taus=false; if ( (_stash[0]->pdgId()==15 && _stash[1]->pdgId()==-15) || (_stash[0]->pdgId()==-15 && _stash[1]->pdgId()==15) ) taus=true; // Calc the Delta R auto h1 = _stash[0]->p4(); auto h2 = _stash[1]->p4(); _deltaR ->Fill(h1.DeltaR(h2)); _deltaPhi ->Fill(h1.DeltaPhi(h2)); _deltaEta ->Fill(fabs(h1.Eta()-h2.Eta())); if ( electrons ) _deltaR_e ->Fill(h1.DeltaR(h2)); if ( electrons ) _deltaPhi_e ->Fill(h1.DeltaPhi(h2)); if ( electrons ) _deltaEta_e ->Fill(fabs(h1.Eta()-h2.Eta())); if ( muons ) _deltaR_mu ->Fill(h1.DeltaR(h2)); if ( muons ) _deltaPhi_mu ->Fill(h1.DeltaPhi(h2)); if ( muons ) _deltaEta_mu ->Fill(fabs(h1.Eta()-h2.Eta())); if ( taus ) _deltaR_tau ->Fill(h1.DeltaR(h2)); if ( taus ) _deltaPhi_tau->Fill(h1.DeltaPhi(h2)); if ( taus ) _deltaEta_tau->Fill(fabs(h1.Eta()-h2.Eta())); _stash.clear(); } private: vector<const xAOD::TruthParticle *> _stash; TH1F *_deltaR; TH1F *_deltaPhi; TH1F *_deltaEta; TH1F *_deltaR_e; TH1F *_deltaPhi_e; TH1F *_deltaEta_e; TH1F *_deltaR_mu; TH1F *_deltaPhi_mu; TH1F *_deltaEta_mu; TH1F *_deltaR_tau; TH1F *_deltaPhi_tau; TH1F *_deltaEta_tau; }; #endif
[ "gordon@gordonandpaula.net" ]
gordon@gordonandpaula.net
922b5571311ddb7607132b9dff1c576f5e0095b9
55196303f36aa20da255031a8f115b6af83e7d11
/private/external/gameswf/gameswf/gameswf_avm2.h
4975c5cae9eaba359c3cba1f6342ac014677479d
[]
no_license
Heartbroken/bikini
3f5447647d39587ffe15a7ae5badab3300d2a2ff
fe74f51a3a5d281c671d303632ff38be84d23dd7
refs/heads/master
2021-01-10T19:48:40.851837
2010-05-25T19:58:52
2010-05-25T19:58:52
37,190,932
0
0
null
null
null
null
UTF-8
C++
false
false
2,879
h
// gameswf_avm2.h -- Vitaly Alexeev <tishka92@yahoo.com> 2008 // This source code has been donated to the Public Domain. Do // whatever you want with it. // AVM2 implementation #ifndef GAMESWF_AVM2_H #define GAMESWF_AVM2_H #include "gameswf/gameswf_function.h" #include "gameswf/gameswf_jit.h" namespace gameswf { struct abc_def; struct option_detail { int m_value; Uint8 m_kind; }; struct traits_info : public ref_counted { enum kind { Trait_Slot = 0, Trait_Method = 1, Trait_Getter = 2, Trait_Setter = 3, Trait_Class = 4, Trait_Function = 5, Trait_Const = 6 }; enum attr { ATTR_Final = 0x1, ATTR_Override = 0x2, ATTR_Metadata = 0x4 }; int m_name; Uint8 m_kind; Uint8 m_attr; // data union { struct { int m_slot_id; int m_type_name; int m_vindex; Uint8 m_vkind; } trait_slot; struct { int m_slot_id; int m_classi; } trait_class; struct { int m_slot_id; int m_function; } trait_function; struct { int m_disp_id; int m_method; } trait_method; }; array<int> m_metadata; void read(stream* in, abc_def* abc); }; struct except_info : public ref_counted { int m_from; int m_to; int m_target; int m_exc_type; int m_var_name; void read(stream* in, abc_def* abc); }; struct as_3_function : public as_function { // Unique id of a gameswf resource enum { m_class_id = AS_3_FUNCTION }; virtual bool is(int class_id) const { if (m_class_id == class_id) return true; else return as_function::is(class_id); } enum flags { NEED_ARGUMENTS = 0x01, NEED_ACTIVATION = 0x02, NEED_REST = 0x04, HAS_OPTIONAL = 0x08, SET_DXNS = 0x40, HAS_PARAM_NAMES = 0x80 }; weak_ptr<as_object> m_target; smart_ptr<abc_def> m_abc; // method_info int m_return_type; array<int> m_param_type; int m_name; Uint8 m_flags; array<option_detail> m_options; int m_method; // index in method_info // body_info int m_max_stack; // this is the index of the highest-numbered local register plus one. int m_local_count; int m_init_scope_depth; int m_max_scope_depth; membuf m_code; array< smart_ptr<except_info> > m_exception; array< smart_ptr<traits_info> > m_trait; jit_function m_compiled_code; as_3_function(abc_def* abc, int method, player* player); ~as_3_function(); // Dispatch. virtual void operator()(const fn_call& fn); void execute(array<as_value>& lregister, array<as_value>& stack, array<as_value>& scope, as_value* result); void compile(); void compile_stack_resize( int count ); void read(stream* in); void read_body(stream* in); }; } #endif
[ "viktor.reutskyy@68c2588f-494f-0410-aecb-65da31d84587" ]
viktor.reutskyy@68c2588f-494f-0410-aecb-65da31d84587
31f10d54c704086085ceff701611725184b6a87b
1f682e669dbf8370d63285135238ea1846e490c8
/src/StopsTableGeneratorHttps.hpp
5441444f5cedb677b7cca6193ff4c0adc5d7455c
[ "Apache-2.0" ]
permissive
kononowicz24/public-transport-live-display
494b9519e1487d7b8f5bc6763c4b5c6ff4950b1b
445bc2a0120542ffb36e65408c61d54748a7d5f4
refs/heads/master
2022-02-01T14:28:00.408063
2022-01-17T19:04:26
2022-01-17T19:04:26
178,856,560
0
0
null
null
null
null
UTF-8
C++
false
false
3,191
hpp
#ifndef _STOPSTABLEGENERATOR_H_ #define _STOPSTABLEGENERATOR_H_ #include <ESP8266WiFi.h> #include <WiFiClientSecure.h> #include <ESP8266HTTPClient.h> #include <ArduinoJson.h> #include "VFDInterface.hpp" #include "passwords.h" #include "debugInterface.hpp" boolean showStopDelayList(const char *host, int httpsPort, String stopId) { boolean printedLines[] = {false, false, false}; WiFiClientSecure httpsClient; //Declare object of class WiFiClient Serial.println(debug("STOPS")+host); Serial.println(String(debug("STOPS"))+"Using fingerprint '"+FINGERPRINT_CKAN); httpsClient.setFingerprint(FINGERPRINT_CKAN); httpsClient.setTimeout(15000); // 15 Seconds //delay(1000); Serial.println(debug("STOPS")+"HTTPS Connecting"); int r = 0; //retry counter while ((!httpsClient.connect(host, httpsPort)) && (r < 30)) { delay(100); Serial.print("."); r++; } if (r == 30) { Serial.println(debug("STOPS")+"Connection failed"); return false; } else { Serial.println(debug("STOPS")+"Connected to web"); } // We now create a URI for the request String url = "/delays"; url += "?stopId="; url += stopId; Serial.print(debug("STOPS")+"requesting URL: "); Serial.println(host + url); httpsClient.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); Serial.println(debug("STOPS")+"request sent"); unsigned long timeout = millis(); while (httpsClient.available() == 0) { if (millis() - timeout > 5000) { Serial.println(debug("STOPS")+">>> Client Timeout !"); httpsClient.stop(); return false; } } const size_t bufferSize = JSON_ARRAY_SIZE(5) + JSON_OBJECT_SIZE(3) + 5*JSON_OBJECT_SIZE(12) + 1120; DynamicJsonBuffer jsonBuffer(bufferSize); while(httpsClient.available()){ JsonObject& root = jsonBuffer.parseObject(httpsClient); for (int i=0; i<2; i++) { JsonObject& delay0 = root["delay"][i]; int routeId = delay0["routeId"]; int delayInSeconds = delay0["delayInSeconds"]; String estimatedTime = delay0["estimatedTime"]; String theoreticalTime = delay0["theoreticalTime"]; String relation = delay0["headsign"]; String delStr = ""; if (routeId!=0) { clearLine(i); setCursor(0,i); Serial.print(debug("STOPS")+(String)routeId); Serial1.print((String)routeId); delStr = (String)delayInSeconds; setCursor(4,i); String relation1= toCP852(relation); Serial.print(relation1); Serial1.print(relation1); setCursor(13-delStr.length(),i); Serial.print((String)" "+ delStr+" "); Serial1.print((String)" "+ delStr+" "); setCursor(15,i); Serial.println((String)estimatedTime); Serial1.print((String)estimatedTime); printedLines[i] = true; } } } for (int i=0; i<2; i++) { if (!printedLines[i]) clearLine(i); } httpsClient.stop(); return true; } #endif
[ "kononowicz24@gmail.com" ]
kononowicz24@gmail.com
aa042b59ff963a8a6cc70d7dd6859b148db98993
984246e5ef86b94a47ffab8e6be1c3bb20fcc23e
/deck.h
34d706e3b94a85d702cfae5a39b11eea65f867e9
[]
no_license
tonningp/cis201-game
7cf7710a35a76211e9322add84d5632b52a2ad9d
e8af7facf1068db3d92832789b64a2bee2f22528
refs/heads/master
2020-04-06T19:10:56.023505
2018-11-15T16:50:21
2018-11-15T16:50:21
157,728,823
0
0
null
null
null
null
UTF-8
C++
false
false
163
h
#ifndef DECK_H #define DECK_H #include <string> #include <vector> #include "card.h" class Deck { std::vector<Card> m_deck; public: Deck(){}; }; #endif
[ "paul.tonning@student.vvc.edu" ]
paul.tonning@student.vvc.edu
aa919afdf81264a18eff51fd8f28848b8e71bead
77ac717c860c2d7e214bc4d911f0d220ad612f24
/AnimationFSM/Walking.h
c751f596c52d1c56539758d9ff26692d58573160
[]
no_license
KrystianSarowski/Animation-Sprites-FSM
659bbf2177ff3745ce35e41bda710d5f8c422d7a
2b4d3f9ff08ee4e8b157c6f448d2f7866f2821f2
refs/heads/master
2020-04-01T20:34:44.452224
2018-11-11T20:37:16
2018-11-11T20:37:16
153,610,678
0
0
null
null
null
null
UTF-8
C++
false
false
391
h
#ifndef WALKING_H #define WALKING_H #include <State.h> // @Author Krystian Sarowski class Walking : public State { public: Walking(); ~Walking(); void idle(Animation* a); void jumping(Animation* a); void climbing(Animation* a); void walking(Animation * a); void hammering(Animation * a); void shoveling(Animation * a); void swordsmanship(Animation * a); }; #endif // !WALKING_H
[ "C00225629@itcarlow.ie" ]
C00225629@itcarlow.ie
737f445bef04488811d254d1184a2d28f3962785
048a60046d36e605e6a330944d557228fd860ae9
/GMCJamPlayer/extensions/execute_shell_simple/execute_shell_simple.cpp
84e93649315071ef7ddc59b5d67003c16d134ee0
[]
no_license
gamedevdan/gmc-jam-player
c1bb3e26a9c7059c7e87ddf309800721ea94b2fe
638966e74d0cb1e78f0c6bee8ae105e49145dd2d
refs/heads/main
2023-06-25T14:51:11.576505
2021-07-29T08:16:54
2021-07-29T08:16:54
343,727,254
1
1
null
2021-05-12T10:41:03
2021-03-02T10:03:09
Yacc
UTF-8
C++
false
false
720
cpp
/// @author YellowAfterlife #include "stdafx.h" #include <shellapi.h> #include <memory> #if defined(WIN32) #define dllx extern "C" __declspec(dllexport) #elif defined(GNUC) #define dllx extern "C" __attribute__ ((visibility("default"))) #else #define dllx extern "C" #endif dllx double execute_shell_simple_raw(const char* path, const char* args, const char* action, double showCmd) { wchar_t wpath[1024] = {}; mbstowcs(wpath, path, 1024); wchar_t wargs[1024] = {}; mbstowcs(wargs, args, 1024); wchar_t waction[1024] = {}; mbstowcs(waction, action, 1024); wchar_t wdir[1024] = {}; GetCurrentDirectoryW(1024, wdir); return (int)ShellExecute(nullptr, waction, wpath, wargs, wdir, (int)showCmd) > 32; }
[ "dan@chequered.ink" ]
dan@chequered.ink
802d3ae0dffbfe56a9a8dd5c78edf1392755d2fe
0d0e78c6262417fb1dff53901c6087b29fe260a0
/ocr/include/tencentcloud/ocr/v20181119/model/VinOCRResponse.h
9d007a92f5c0819ab19fe6a0c3f65e4ad63063f5
[ "Apache-2.0" ]
permissive
li5ch/tencentcloud-sdk-cpp
ae35ffb0c36773fd28e1b1a58d11755682ade2ee
12ebfd75a399ee2791f6ac1220a79ce8a9faf7c4
refs/heads/master
2022-12-04T15:33:08.729850
2020-07-20T00:52:24
2020-07-20T00:52:24
281,135,686
1
0
Apache-2.0
2020-07-20T14:14:47
2020-07-20T14:14:46
null
UTF-8
C++
false
false
2,100
h
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TENCENTCLOUD_OCR_V20181119_MODEL_VINOCRRESPONSE_H_ #define TENCENTCLOUD_OCR_V20181119_MODEL_VINOCRRESPONSE_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/AbstractModel.h> namespace TencentCloud { namespace Ocr { namespace V20181119 { namespace Model { /** * VinOCR返回参数结构体 */ class VinOCRResponse : public AbstractModel { public: VinOCRResponse(); ~VinOCRResponse() = default; CoreInternalOutcome Deserialize(const std::string &payload); /** * 获取检测到的车辆 VIN 码。 * @return Vin 检测到的车辆 VIN 码。 */ std::string GetVin() const; /** * 判断参数 Vin 是否已赋值 * @return Vin 是否已赋值 */ bool VinHasBeenSet() const; private: /** * 检测到的车辆 VIN 码。 */ std::string m_vin; bool m_vinHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_OCR_V20181119_MODEL_VINOCRRESPONSE_H_
[ "jimmyzhuang@tencent.com" ]
jimmyzhuang@tencent.com
fd7c9df169e3c2edcd424a5a0a3bf919d30de62d
be4f246d03631a0370d7aa487dfe683ad9e11173
/include/data/extern/thrift/client_constants.h
e683ab493ae8e2ab55dbd85fc8e60e32986486d2
[ "Apache-2.0" ]
permissive
phrocker/sharkbite
f03abb8173ef3b5525d81d0184859e49c2e067f3
7f2625f74331b0cd4a75dc0484949c40f1409686
refs/heads/main
2023-09-01T11:53:00.189396
2022-07-23T00:15:11
2022-07-23T00:15:11
79,762,882
30
5
Apache-2.0
2023-08-17T22:34:50
2017-01-23T02:32:18
C++
UTF-8
C++
false
true
487
h
/** * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ #ifndef client_CONSTANTS_H #define client_CONSTANTS_H #include "client_types.h" namespace org { namespace apache { namespace accumulo { namespace core { namespace client { namespace impl { namespace thrift { class clientConstants { public: clientConstants(); }; extern const clientConstants g_client_constants; }}}}}}} // namespace #endif
[ "marc.parisi@gmail.com" ]
marc.parisi@gmail.com
96a863905bf0de0416af1e57c899342ffe36764a
346e7f4aa65d89e3ca1e4b6210e1a68eb99bab5d
/Graphics/GraphicsEngineMetal/interface/EngineFactoryMtl.h
6787953603926d98b051f701731e4081259ede0e
[ "Apache-2.0" ]
permissive
raptoravis/DiligentCore
cd74be889968cfebab635fcc07d382c22f9065a5
a2ee49069659eb650b912463a8e380c1c49a0605
refs/heads/master
2020-08-12T19:30:35.599793
2019-11-02T04:04:54
2019-11-02T04:04:54
214,829,391
0
0
Apache-2.0
2019-10-13T13:55:22
2019-10-13T13:55:22
null
UTF-8
C++
false
false
2,962
h
/* Copyright 2015-2019 Egor Yusov * * 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 * * 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 OF ANY PROPRIETARY RIGHTS. * * In no event and under no legal theory, whether in tort (including negligence), * contract, or otherwise, unless required by applicable law (such as deliberate * and grossly negligent acts) or agreed to in writing, shall any Contributor be * liable for any damages, including any direct, indirect, special, incidental, * or consequential damages of any character arising as a result of this License or * out of the use or inability to use the software (including but not limited to damages * for loss of goodwill, work stoppage, computer failure or malfunction, or any and * all other commercial damages or losses), even if such Contributor has been advised * of the possibility of such damages. */ #pragma once /// \file /// Declaration of functions that initialize Vulkan-based engine implementation #include <sstream> #include "../../GraphicsEngine/interface/EngineFactory.h" #include "../../GraphicsEngine/interface/RenderDevice.h" #include "../../GraphicsEngine/interface/DeviceContext.h" #include "../../GraphicsEngine/interface/SwapChain.h" // https://gcc.gnu.org/wiki/Visibility #define API_QUALIFIER __attribute__((visibility("default"))) namespace Diligent { // {CF4A590D-2E40-4F48-9579-0D25991F963B} static const INTERFACE_ID IID_EngineFactoryMtl = { 0xcf4a590d, 0x2e40, 0x4f48, { 0x95, 0x79, 0xd, 0x25, 0x99, 0x1f, 0x96, 0x3b } }; class IEngineFactoryMtl : public IEngineFactory { public: virtual void CreateDeviceAndContextsMtl(const EngineMtlCreateInfo& Attribs, IRenderDevice** ppDevice, IDeviceContext** ppContexts) = 0; virtual void CreateSwapChainMtl( IRenderDevice* pDevice, IDeviceContext* pImmediateContext, const SwapChainDesc& SCDesc, void* pView, ISwapChain** ppSwapChain ) = 0; virtual void AttachToMtlDevice(void* pMtlNativeDevice, const EngineMtlCreateInfo& EngineAttribs, IRenderDevice** ppDevice, IDeviceContext** ppContexts) = 0; }; API_QUALIFIER IEngineFactoryMtl* GetEngineFactoryMtl(); }
[ "egor.yusov@gmail.com" ]
egor.yusov@gmail.com
968756a2685ef28cb3ee9416e1a7b63eb5693332
33ad44ec1150b5dfea704f7f483ac33c938bd259
/Cifrados/EuclidesBinario/main.cpp
09160cec3b5f167a5fa85763cea997999758294d
[]
no_license
AlonsoCerpa/ED3
231ae517403abd68d3b78cf8b464cda8b6f6019a
775cc01975793ab87148b63aff536153652638a7
refs/heads/master
2020-04-24T04:01:10.864672
2017-11-11T21:01:31
2017-11-11T21:01:31
66,728,146
0
0
null
null
null
null
UTF-8
C++
false
false
1,952
cpp
#include "funciones.h" #include <NTL/ZZ.h> #include <chrono> #include <iostream> #include <fstream> using namespace NTL; using namespace std; using namespace std::chrono; int main() { string auxStr, num1Str, num2Str; ifstream num1Txt, num2Txt; ZZ num1; ZZ num2; long nBits = 20000; high_resolution_clock::time_point iniTime1, iniTime2, endTime1, endTime2; num1Txt.open("num1Txt.txt"); while (getline(num1Txt, auxStr)) { num1Str += auxStr; } num2Txt.open("num2Txt.txt"); while (getline(num2Txt, auxStr)) { num2Str += auxStr; } num1 = ZZ(INIT_VAL, num1Str.c_str()); num2 = ZZ(INIT_VAL, num2Str.c_str()); num1Txt.close(); num2Txt.close(); //77 segundos +-, mcd = 2 cout << "MCD binario: " << endl; iniTime2 = high_resolution_clock::now(); cout << mcdBinario(num1, num2) << endl; endTime2 = high_resolution_clock::now(); duration<double> time2 = duration_cast<duration<double>>(endTime2 - iniTime2); cout << "Tiempo: " << time2.count() << " segundos" << endl; /* RandomBits(num1, nBits); cout << "Random num1: " << num1 << endl << endl; RandomBits(num2, nBits); cout << "Random num2: " << num2 << endl; //cout << "GCD NTL: " << endl; //cout << GCD(num1, num2) << endl << endl; cout << "MCD Euclides: " << endl; iniTime1 = high_resolution_clock::now(); cout << mcdEuclides(num1, num2) << endl; endTime1 = high_resolution_clock::now(); duration<double> time1 = duration_cast<duration<double>>(endTime1 - iniTime1); cout << "Tiempo: " << time1.count() << " segundos" << endl << endl; cout << "MCD binario: " << endl; iniTime2 = high_resolution_clock::now(); cout << mcdBinario(num1, num2) << endl; endTime2 = high_resolution_clock::now(); duration<double> time2 = duration_cast<duration<double>>(endTime2 - iniTime2); cout << "Tiempo: " << time2.count() << " segundos" << endl; */ return 0; }
[ "alonso.cerpa@ucsp.edu.pe" ]
alonso.cerpa@ucsp.edu.pe
81648ec407ecdb36e957695e17526b70d64e70e1
bd5775ff6aaf09b9ab4719990473a04227ea897a
/amici/src/hdf5.cpp
0643fd5724e4b6e4a1b58f74d1e51a934ec51591
[ "BSD-3-Clause" ]
permissive
ICB-DCM/Study-DFO
89e23441fa0b41ac3d230e5c72e4d990c3db69b6
e0612427c8c3d8e3fe0c7d5a795ecb01a586309f
refs/heads/master
2022-04-07T00:27:46.379781
2020-01-08T11:27:33
2020-01-08T11:27:33
119,100,031
2
4
null
2020-01-08T11:27:35
2018-01-26T20:30:50
C
UTF-8
C++
false
false
23,108
cpp
#include "amici/hdf5.h" #include "amici/amici.h" #include <hdf5_hl.h> #include <cassert> #include <cstring> #include <algorithm> #ifdef AMI_HDF5_H_DEBUG #ifndef __APPLE__ #include <cexecinfo> #else #include <execinfo.h> #endif #endif #include <unistd.h> #include <cmath> namespace amici { namespace hdf5 { /** * @brief assertMeasurementDimensionsCompatible * @param m * @param n * @param model */ void checkMeasurementDimensionsCompatible(hsize_t m, hsize_t n, Model const& model) { bool compatible = true; // if this is rank 1, n and m can be swapped if (n == 1) { compatible &= (n == (unsigned)model.nt() || n == (unsigned)model.nytrue); compatible &= (m == (unsigned)model.nytrue || m == (unsigned)model.nt()); compatible &= (m * n == (unsigned)model.nytrue * model.nt()); } else { compatible &= (n == (unsigned)model.nytrue); compatible &= (m == (unsigned)model.nt()); } if(!compatible) throw(AmiException("HDF5 measurement data does not match model. Incompatible dimensions.")); } /** * @brief assertEventDimensionsCompatible * @param m * @param n * @param model */ void checkEventDimensionsCompatible(hsize_t m, hsize_t n, Model const& model) { bool compatible = true; // if this is rank 1, n and m can be swapped if (n == 1) { compatible &= (n == (unsigned)model.nMaxEvent() || n == (unsigned)model.nztrue); compatible &= (m == (unsigned)model.nztrue || m == (unsigned)model.nMaxEvent()); compatible &= (m * n == (unsigned)model.nytrue * model.nMaxEvent()); } else { compatible &= (n == (unsigned)model.nztrue); compatible &= (m == (unsigned)model.nMaxEvent()); } if(!compatible) throw(AmiException("HDF5 event data does not match model. Incompatible dimensions.")); } void createGroup(H5::H5File &file, std::string const& groupPath, bool recursively) { hid_t groupCreationPropertyList = H5P_DEFAULT; if (recursively) { groupCreationPropertyList = H5Pcreate(H5P_LINK_CREATE); H5Pset_create_intermediate_group(groupCreationPropertyList, 1); } hid_t group = H5Gcreate(file.getId(), groupPath.c_str(), groupCreationPropertyList, H5P_DEFAULT, H5P_DEFAULT); H5Pclose(groupCreationPropertyList); if (group < 0) throw(AmiException("Failed to create group in hdf5CreateGroup: %s", groupPath.c_str())); H5Gclose(group); } std::unique_ptr<ExpData> readSimulationExpData(std::string const& hdf5Filename, std::string const& hdf5Root, Model const& model) { H5::H5File file(hdf5Filename, H5F_ACC_RDONLY); hsize_t m, n; auto edata = std::unique_ptr<ExpData>(new ExpData(model)); auto my = getDoubleDataset2D(file, hdf5Root + "/Y", m, n); if(m * n > 0) { checkMeasurementDimensionsCompatible(m, n, model); edata->my = my; } auto sigmay = getDoubleDataset2D(file, hdf5Root + "/Sigma_Y", m, n); if(m * n > 0) { checkMeasurementDimensionsCompatible(m, n, model); edata->sigmay = sigmay; } if (model.nz) { edata->mz = getDoubleDataset2D(file, hdf5Root + "/Z", m, n); checkEventDimensionsCompatible(m, n, model); edata->sigmaz = getDoubleDataset2D(file, hdf5Root + "/Sigma_Z", m, n); checkEventDimensionsCompatible(m, n, model); } return edata; } void writeReturnData(const ReturnData &rdata, H5::H5File &file, const std::string &hdf5Location) { if(!locationExists(file, hdf5Location)) createGroup(file, hdf5Location); if (rdata.ts.size()) createAndWriteDouble1DDataset(file, hdf5Location + "/t", rdata.ts.data(), rdata.nt); H5LTset_attribute_double(file.getId(), hdf5Location.c_str(), "llh", &rdata.llh, 1); H5LTset_attribute_double(file.getId(), hdf5Location.c_str(), "chi2", &rdata.chi2, 1); H5LTset_attribute_int(file.getId(), hdf5Location.c_str(), "status", &rdata.status, 1); if (rdata.sllh.size()) createAndWriteDouble1DDataset(file, hdf5Location + "/sllh", rdata.sllh.data(), rdata.nplist); if (rdata.x0.size()) createAndWriteDouble1DDataset(file, hdf5Location + "/x0", rdata.x0.data(), rdata.nx); if (rdata.x.size()) createAndWriteDouble2DDataset(file, hdf5Location + "/x", rdata.x.data(), rdata.nt, rdata.nx); if (rdata.y.size()) createAndWriteDouble2DDataset(file, hdf5Location + "/y", rdata.y.data(), rdata.nt, rdata.ny); if (rdata.z.size()) createAndWriteDouble2DDataset(file, hdf5Location + "/z", rdata.z.data(), rdata.nmaxevent, rdata.nz); if (rdata.rz.size()) createAndWriteDouble2DDataset(file, hdf5Location + "/rz", rdata.rz.data(), rdata.nmaxevent, rdata.nz); if (rdata.sigmay.size()) createAndWriteDouble2DDataset(file, hdf5Location + "/sigmay", rdata.sigmay.data(), rdata.nt, rdata.ny); if (rdata.sigmaz.size()) createAndWriteDouble2DDataset(file, hdf5Location + "/sigmaz", rdata.sigmaz.data(), rdata.nmaxevent, rdata.nz); if (rdata.s2llh.size()) createAndWriteDouble2DDataset(file, hdf5Location + "/s2llh", rdata.s2llh.data(), rdata.nJ - 1, rdata.nplist); if (rdata.sx0.size()) createAndWriteDouble2DDataset(file, hdf5Location + "/sx0", rdata.sx0.data(), rdata.nx, rdata.nplist); if (rdata.sx.size()) createAndWriteDouble3DDataset(file, hdf5Location + "/sx", rdata.sx.data(), rdata.nt, rdata.nplist, rdata.nx); if (rdata.sy.size()) createAndWriteDouble3DDataset(file, hdf5Location + "/sy", rdata.sy.data(), rdata.nt, rdata.nplist, rdata.ny); if (rdata.ssigmay.size()) createAndWriteDouble3DDataset(file, hdf5Location + "/ssigmay", rdata.ssigmay.data(), rdata.nt, rdata.nplist, rdata.ny); if (rdata.sz.size()) createAndWriteDouble3DDataset(file, hdf5Location + "/sz", rdata.sz.data(), rdata.nmaxevent, rdata.nplist, rdata.nz); if (rdata.srz.size()) createAndWriteDouble3DDataset(file, hdf5Location + "/srz", rdata.srz.data(), rdata.nmaxevent, rdata.nplist, rdata.nz); if (rdata.ssigmaz.size()) createAndWriteDouble3DDataset(file, hdf5Location + "/ssigmaz", rdata.ssigmaz.data(), rdata.nmaxevent, rdata.nplist, rdata.nz); writeReturnDataDiagnosis(rdata, file, hdf5Location + "/diagnosis"); } void writeReturnDataDiagnosis(const ReturnData &rdata, H5::H5File& file, const std::string& hdf5Location) { if(!locationExists(file, hdf5Location)) createGroup(file, hdf5Location); if (rdata.xdot.size()) createAndWriteDouble1DDataset(file, hdf5Location + "/xdot", rdata.xdot.data(), rdata.nx); if (rdata.numsteps.size()) createAndWriteInt1DDataset(file, hdf5Location + "/numsteps", rdata.numsteps); if (rdata.numrhsevals.size()) createAndWriteInt1DDataset(file, hdf5Location + "/numrhsevals", rdata.numrhsevals); if (rdata.numerrtestfails.size()) createAndWriteInt1DDataset(file, hdf5Location + "/numerrtestfails", rdata.numerrtestfails); if (rdata.numnonlinsolvconvfails.size()) createAndWriteInt1DDataset(file, hdf5Location + "/numnonlinsolvconvfails", rdata.numnonlinsolvconvfails); if (rdata.order.size()) createAndWriteInt1DDataset(file, hdf5Location + "/order", rdata.order); if (rdata.numstepsB.size()) createAndWriteInt1DDataset(file, hdf5Location + "/numstepsB", rdata.numstepsB); if (rdata.numrhsevalsB.size()) createAndWriteInt1DDataset(file, hdf5Location + "/numrhsevalsB", rdata.numrhsevalsB); if (rdata.numerrtestfailsB.size()) createAndWriteInt1DDataset(file, hdf5Location + "/numerrtestfailsB", rdata.numerrtestfailsB); if (rdata.numnonlinsolvconvfailsB.size()) createAndWriteInt1DDataset(file, hdf5Location + "/numnonlinsolvconvfailsB", rdata.numnonlinsolvconvfailsB); H5LTset_attribute_int(file.getId(), (hdf5Location + "").c_str(), "newton_status", &rdata.newton_status, 1); if (rdata.newton_numsteps.size()) createAndWriteInt1DDataset(file, hdf5Location + "/newton_numsteps", rdata.newton_numsteps); if (rdata.newton_numlinsteps.size()) createAndWriteInt2DDataset(file, hdf5Location + "/newton_numlinsteps", rdata.newton_numlinsteps.data(), rdata.newton_maxsteps, 2); H5LTset_attribute_double(file.getId(), hdf5Location.c_str(), "newton_time", &rdata.newton_time, 1); if (rdata.J.size()) createAndWriteDouble2DDataset(file, hdf5Location + "/J", rdata.J.data(), rdata.nx, rdata.nx); } void writeReturnData(ReturnData const& rdata, std::string const& hdf5Filename, std::string const& hdf5Location) { auto file = createOrOpenForWriting(hdf5Filename); writeReturnData(rdata, file, hdf5Location); } double getDoubleScalarAttribute(H5::H5File const& file, std::string const& optionsObject, std::string const& attributeName) { double data = NAN; herr_t status = H5LTget_attribute_double(file.getId(), optionsObject.c_str(), attributeName.c_str(), &data); #ifdef AMI_HDF5_H_DEBUG printf("%s: %e\n", attributeName, data); #endif if(status < 0) throw AmiException("Attribute %s not found for object %s.", attributeName.c_str(), optionsObject.c_str()); return data; } int getIntScalarAttribute(H5::H5File const& file, std::string const& optionsObject, std::string const& attributeName) { int data = 0; herr_t status = H5LTget_attribute_int(file.getId(), optionsObject.c_str(), attributeName.c_str(), &data); #ifdef AMI_HDF5_H_DEBUG printf("%s: %d\n", attributeName.c_str(), data); #endif if(status < 0) throw AmiException("Attribute %s not found for object %s.", attributeName.c_str(), optionsObject.c_str()); return data; } void createAndWriteInt1DDataset(H5::H5File& file, std::string const& datasetName, const int *buffer, hsize_t m) { H5::DataSpace dataspace(1, &m); auto dataset = file.createDataSet(datasetName, H5::PredType::NATIVE_INT, dataspace); dataset.write(buffer, H5::PredType::NATIVE_INT); } void createAndWriteInt1DDataset(H5::H5File& file, std::string const& datasetName, std::vector<int> const& buffer) { createAndWriteInt1DDataset(file, datasetName, buffer.data(), buffer.size()); } void createAndWriteDouble1DDataset(H5::H5File& file, std::string const& datasetName, const double *buffer, hsize_t m) { H5::DataSpace dataspace(1, &m); auto dataset = file.createDataSet(datasetName, H5::PredType::NATIVE_DOUBLE, dataspace); dataset.write(buffer, H5::PredType::NATIVE_DOUBLE); } void createAndWriteDouble2DDataset(H5::H5File& file, std::string const& datasetName, const double *buffer, hsize_t m, hsize_t n) { const hsize_t adims[] {m, n}; H5::DataSpace dataspace(2, adims); auto dataset = file.createDataSet(datasetName, H5::PredType::NATIVE_DOUBLE, dataspace); dataset.write(buffer, H5::PredType::NATIVE_DOUBLE); } void createAndWriteInt2DDataset(H5::H5File& file, std::string const& datasetName, const int *buffer, hsize_t m, hsize_t n) { const hsize_t adims[] {m, n}; H5::DataSpace dataspace(2, adims); auto dataset = file.createDataSet(datasetName, H5::PredType::NATIVE_INT, dataspace); dataset.write(buffer, H5::PredType::NATIVE_INT); } void createAndWriteDouble3DDataset(H5::H5File& file, std::string const& datasetName, const double *buffer, hsize_t m, hsize_t n, hsize_t o) { const hsize_t adims[] {m, n, o}; H5::DataSpace dataspace(3, adims); auto dataset = file.createDataSet(datasetName, H5::PredType::NATIVE_DOUBLE, dataspace); dataset.write(buffer, H5::PredType::NATIVE_DOUBLE); } bool attributeExists(H5::H5File const& file, const std::string &optionsObject, const std::string &attributeName) { AMICI_H5_SAVE_ERROR_HANDLER; int result = H5Aexists_by_name(file.getId(), optionsObject.c_str(), attributeName.c_str(), H5P_DEFAULT); AMICI_H5_RESTORE_ERROR_HANDLER; return result > 0; } bool attributeExists(H5::H5Object const& object, const std::string &attributeName) { AMICI_H5_SAVE_ERROR_HANDLER; int result = H5Aexists(object.getId(), attributeName.c_str()); AMICI_H5_RESTORE_ERROR_HANDLER; return result > 0; } void readSolverSettingsFromHDF5(H5::H5File const& file, Solver &solver, const std::string &datasetPath) { if(attributeExists(file, datasetPath, "atol")) { solver.setAbsoluteTolerance(getDoubleScalarAttribute(file, datasetPath, "atol")); } if(attributeExists(file, datasetPath, "rtol")) { solver.setRelativeTolerance(getDoubleScalarAttribute(file, datasetPath, "rtol")); } if(attributeExists(file, datasetPath, "maxsteps")) { solver.setMaxSteps(getIntScalarAttribute(file, datasetPath, "maxsteps")); } if(attributeExists(file, datasetPath, "lmm")) { solver.setLinearMultistepMethod( static_cast<LinearMultistepMethod>(getIntScalarAttribute(file, datasetPath, "lmm"))); } if(attributeExists(file, datasetPath, "iter")) { solver.setNonlinearSolverIteration( static_cast<NonlinearSolverIteration>(getIntScalarAttribute(file, datasetPath, "iter"))); } if(attributeExists(file, datasetPath, "stldet")) { solver.setStabilityLimitFlag(getIntScalarAttribute(file, datasetPath, "stldet")); } if(attributeExists(file, datasetPath, "ordering")) { solver.setStateOrdering(static_cast<StateOrdering>( getIntScalarAttribute(file, datasetPath, "ordering"))); } if(attributeExists(file, datasetPath, "interpType")) { solver.setInterpolationType(static_cast<InterpolationType>(getIntScalarAttribute(file, datasetPath, "interpType"))); } if(attributeExists(file, datasetPath, "sensi_meth")) { solver.setSensitivityMethod(static_cast<AMICI_sensi_meth>(getIntScalarAttribute(file, datasetPath, "sensi_meth"))); } if(attributeExists(file, datasetPath, "sensi")) { solver.setSensitivityOrder(static_cast<AMICI_sensi_order>(getIntScalarAttribute(file, datasetPath, "sensi"))); } if(attributeExists(file, datasetPath, "newton_maxsteps")) { solver.setNewtonMaxSteps(getIntScalarAttribute(file, datasetPath, "newton_maxsteps")); } if(attributeExists(file, datasetPath, "newton_preeq")) { solver.setNewtonPreequilibration(getIntScalarAttribute(file, datasetPath, "newton_preeq")); } if(attributeExists(file, datasetPath, "newton_precon")) { solver.setNewtonPreconditioner(getIntScalarAttribute(file, datasetPath, "newton_precon")); } if(attributeExists(file, datasetPath, "newton_maxlinsteps")) { solver.setNewtonMaxLinearSteps(getIntScalarAttribute(file, datasetPath, "newton_maxlinsteps")); } if(attributeExists(file, datasetPath, "linsol")) { solver.setLinearSolver(static_cast<LinearSolver>(getIntScalarAttribute(file, datasetPath, "linsol"))); } if(attributeExists(file, datasetPath, "ism")) { solver.setInternalSensitivityMethod(static_cast<InternalSensitivityMethod>(getIntScalarAttribute(file, datasetPath, "ism"))); } } void readSolverSettingsFromHDF5(const std::string &hdffile, Solver &solver, const std::string &datasetPath) { H5::H5File file(hdffile, H5F_ACC_RDONLY, H5P_DEFAULT); readSolverSettingsFromHDF5(file, solver, datasetPath); } void readModelDataFromHDF5(const std::string &hdffile, Model &model, const std::string &datasetPath) { H5::H5File file(hdffile, H5F_ACC_RDONLY, H5P_DEFAULT); readModelDataFromHDF5(file, model, datasetPath); } void readModelDataFromHDF5(const H5::H5File &file, Model &model, const std::string &datasetPath) { if(attributeExists(file, datasetPath, "tstart")) { model.setT0(getDoubleScalarAttribute(file, datasetPath, "tstart")); } if(locationExists(file, datasetPath + "/pscale")) { auto pscaleInt = getIntDataset1D(file, datasetPath + "/pscale"); std::vector<AMICI_parameter_scaling> pscale(pscaleInt.size()); for(int i = 0; (unsigned)i < pscaleInt.size(); ++i) pscale[i] = static_cast<AMICI_parameter_scaling>(pscaleInt[i]); model.setParameterScale(pscale); } else if (attributeExists(file, datasetPath, "pscale")) { // if pscale is the same for all parameters, // it can be set as scalar attribute for convenience model.setParameterScale(static_cast<AMICI_parameter_scaling>(getDoubleScalarAttribute(file, datasetPath, "pscale"))); } if(attributeExists(file, datasetPath, "nmaxevent")) { model.setNMaxEvent(getIntScalarAttribute(file, datasetPath, "nmaxevent")); } if(locationExists(file, datasetPath + "/qpositivex")) { auto qPosX = getIntDataset1D(file, datasetPath + "/qpositivex"); model.setPositivityFlag(qPosX); } if(locationExists(file, datasetPath + "/theta")) { model.setParameters(getDoubleDataset1D(file, datasetPath + "/theta")); } if(locationExists(file, datasetPath + "/kappa")) { model.setFixedParameters(getDoubleDataset1D(file, datasetPath + "/kappa")); } if(locationExists(file, datasetPath + "/ts")) { model.setTimepoints(getDoubleDataset1D(file, datasetPath + "/ts")); } if(locationExists(file, datasetPath + "/sens_ind")) { auto sensInd = getIntDataset1D(file, datasetPath + "/sens_ind"); model.setParameterList(sensInd); } if(locationExists(file, datasetPath + "/x0")) { auto x0 = getDoubleDataset1D(file, datasetPath + "/x0"); if(x0.size()) model.setInitialStates(x0); } if(locationExists(file, datasetPath + "/sx0")) { hsize_t length0 = 0; hsize_t length1 = 0; auto sx0 = getDoubleDataset2D(file, datasetPath + "/sx0", length0, length1); if(sx0.size()) { if (length0 != (unsigned) model.nx && length1 != (unsigned) model.nplist()) throw(AmiException("Dimension mismatch when reading sx0. Expected %dx%d, got %llu, %llu.", model.nx, model.nplist(), length0, length1)); model.setInitialStateSensitivities(sx0); } } } H5::H5File createOrOpenForWriting(const std::string &hdf5filename) { H5::H5File file; AMICI_H5_SAVE_ERROR_HANDLER; try { file = H5::H5File(hdf5filename, H5F_ACC_RDWR); AMICI_H5_RESTORE_ERROR_HANDLER; } catch(...) { AMICI_H5_RESTORE_ERROR_HANDLER; file = H5::H5File(hdf5filename, H5F_ACC_EXCL); } return file; } bool locationExists(const H5::H5File &file, const std::string &location) { AMICI_H5_SAVE_ERROR_HANDLER; auto result = H5Lexists(file.getId(), location.c_str(), H5P_DEFAULT) > 0; AMICI_H5_RESTORE_ERROR_HANDLER; return result; } bool locationExists(const std::string &filename, const std::string &location) { H5::H5File file(filename, H5F_ACC_RDONLY); return locationExists(file, location); } std::vector<int> getIntDataset1D(const H5::H5File &file, std::string const& name) { auto dataset = file.openDataSet(name); auto dataspace = dataset.getSpace(); int rank = dataspace.getSimpleExtentNdims(); if(rank != 1) throw(AmiException("Expected array of rank 1 in %s", name.c_str())); hsize_t dim; dataspace.getSimpleExtentDims(&dim); std::vector<int> result(dim); if(result.size()) dataset.read(result.data(), H5::PredType::NATIVE_INT); return result; } std::vector<double> getDoubleDataset1D(const H5::H5File &file, const std::string &name) { auto dataset = file.openDataSet(name); auto dataspace = dataset.getSpace(); int rank = dataspace.getSimpleExtentNdims(); if(rank != 1) throw(AmiException("Expected array of rank 1 in %s", name.c_str())); hsize_t dim; dataspace.getSimpleExtentDims(&dim); std::vector<double> result(dim); if(result.size()) dataset.read(result.data(), H5::PredType::NATIVE_DOUBLE); return result; } std::vector<double> getDoubleDataset2D(const H5::H5File &file, const std::string &name, hsize_t &m, hsize_t &n) { m = n = 0; auto dataset = file.openDataSet(name); auto dataspace = dataset.getSpace(); int rank = dataspace.getSimpleExtentNdims(); if(rank != 2) throw(AmiException("Expected array of rank 2 in %s", name.c_str())); hsize_t dims[2]; dataspace.getSimpleExtentDims(dims); m = dims[0]; n = dims[1]; std::vector<double> result(m * n); if(result.size()) dataset.read(result.data(), H5::PredType::NATIVE_DOUBLE); return result; } std::vector<double> getDoubleDataset3D(const H5::H5File &file, const std::string &name, hsize_t &m, hsize_t &n, hsize_t &o) { m = n = o = 0; auto dataset = file.openDataSet(name); auto dataspace = dataset.getSpace(); int rank = dataspace.getSimpleExtentNdims(); if(rank != 3) throw(AmiException("Expected array of rank 3 in %s", name.c_str())); hsize_t dims[3]; dataspace.getSimpleExtentDims(dims); m = dims[0]; n = dims[1]; o = dims[2]; std::vector<double> result(m * n * o); if(result.size()) dataset.read(result.data(), H5::PredType::NATIVE_DOUBLE); return result; } } // namespace hdf5 } // namespace amici
[ "yannik.schaelte@gmail.com" ]
yannik.schaelte@gmail.com
5c511add1e32bf5c6e12f2ecd0805ae20fb7850b
3501288a559c3996eedda7d91609d2afc74af351
/codeforces/palindromes-building.cpp
0545537deae7c691c64071ddae12ae4100a6f5ef
[]
no_license
josecleiton/contest
9b76035025943067bf7b1eedc40e9aa03b209d12
6e35bbda0f739782536fb6837194a86e7f52e89f
refs/heads/master
2023-06-22T20:10:06.980694
2023-06-18T13:50:07
2023-06-18T13:50:07
137,649,792
23
9
null
null
null
null
UTF-8
C++
false
false
1,907
cpp
//TEMPLATE COM MACROS PARA OS CONTESTS //compile usando: g++ -std=c++11 -lm -O3 arquivo.cpp #include <bits/stdc++.h> #define FOR(x) for(int i=0;i<x;i++) #define ROF(x) for(int i=x-1;i>=0;i--) #define ROFJ(x) for(int j=x-1;j>=0;j--) #define FORJ(x) for(int j=0;j<x;j++) #define FORQ(Q) for(int i=0;Q;i++) #define FORM(x,y) for(int i=0;i<x;i++) for(int j=0;j<y;j++) #define FORT(x,y) for(int i=x;i<y;i++) #define ROFT(x,y) for(int i=x-1;i>=y;i--) #define WHILE(n,x) while((n--)&&cin>>x) #define SORT(v) sort(v.begin(), v.end()) #define SORTC(v, comp) sort(v.begin(), v.end(), comp) #define FORIT(v) for(auto& it: v) #define c(x) cout<<x<<endl #define C(x) cin>>x #define set(a,b) cout.precision(a); cout<<fixed<<b<<endl #define pcs(a) cout.precision(a) #define fx(a) fixed<<a #define gl(s) getline(cin,s) #define pb(a) push_back(a) #define matrixM(n,m) vector<vector<int>> M (n, vector<int> (m)) #define matrixN(n,m) vector<vector<int>> N (n, vector<int> (m)) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<string> vstr; typedef vector<double> vd; typedef vector<long> vl; typedef vector<ll> vll; typedef map<int, int> mii; typedef map<int, bool> mib; typedef map<char, int> mci; typedef map<string, int> msi; typedef pair<int, int> pii; int main(){ int m,ct,res,impar; string str; bool pal; cin>>ct; for(int t=0, k; t<ct; t++){ impar=0; string str; vi freq(26); cin>>m>>str; FOR(m) freq[str[i]-'a']++; for(auto f: freq) if(f&1) impar++; if(impar>1){ cout<<0<<endl; } else{ string z = ""; FOR(26) z += string(freq[i] >> 1, char(i + 'a')); res=0; do{ res++; } while(next_permutation(z.begin(), z.end())); cout<<res<<endl; } } return 0; }
[ "jcleitonbc@gmail.com" ]
jcleitonbc@gmail.com
56d21998c3de18dd567b86481924519b20bc75c1
a6832dffec7f93e8d48efd27403918633b0a94c8
/grpc_backend/Indexer.h
5b8216279e877f58e73216bbc21ab0281d703ac8
[]
no_license
shrekshao/TinyCloud
497b13b97ef8cf1fa59967ad644ff4ba1d45fe86
5c9cc1361331a153b8598929b06a9f4bfd29ca7d
refs/heads/master
2020-12-24T10:52:20.114445
2016-12-19T05:13:23
2016-12-19T05:13:23
73,127,947
2
1
null
2016-12-05T19:10:31
2016-11-07T22:47:30
C++
UTF-8
C++
false
false
1,188
h
// // Created by tianli on 12/5/16. // #ifndef TINYCLOUD_STORAGE_SERVICE_H #define TINYCLOUD_STORAGE_SERVICE_H #include <iostream> #include <vector> #include <string> #include <sys/stat.h> #include <map> #include <boost/thread.hpp> #include <boost/filesystem.hpp> using namespace std; /* * Node object to store directories and files for Indexer when requiring user's file hierarchy */ class Node { public: string node_name; string full_name; bool is_file; map<string, Node> children; Node(string node_name, string full_name, bool is_file = false) { this->node_name = node_name; this->full_name = full_name; this->is_file = is_file; // Default to be directory } }; class Indexer { Node root; Node* node_finder(string target_name, Node* node); public: Indexer(); int display(string cur_dir, map<string, Node> &res); int insert(string new_dir, bool is_file = false); int delet(string del_dir); pair<int, bool> checkIsFile(string cur_dir); int findAllChildren(string dir, vector<string>& res); int findAllChildrenHelper(Node* cur_node, vector<string>& res); }; #endif //TINYCLOUD_STORAGE_SERVICE_H
[ "tianlihan9@gmail.com" ]
tianlihan9@gmail.com
779fc9273ef9306dcef3c7038c5f8c492fce259f
9e52f9ebd890948abee5a56594dd70038ed3072d
/matlab_tools/CloudsGPUPro6-master/Terrain/EarthHemisphere.cpp
c557891f4831a2fb5fafc25c8e9acda5587f00b1
[ "BSD-3-Clause", "MIT" ]
permissive
CS1371/textbook
9b9585ba3b04a46dcf7f2c44346eb12dabff39e3
57bc0fd7cd69bc60f556b231c79679cac3455e4b
refs/heads/master
2020-09-11T17:09:38.080789
2020-07-15T20:05:06
2020-07-15T20:05:06
222,132,166
0
0
MIT
2020-04-13T15:47:11
2019-11-16T17:05:37
C++
UTF-8
C++
false
false
45,502
cpp
// Copyright 2013 Intel Corporation // All Rights Reserved // // Permission is granted to use, copy, distribute and prepare derivative works of this // software for any purpose and without fee, provided, that the above copyright notice // and this statement appear in all copies. Intel makes no representations about the // suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS." // INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, AND ALL LIABILITY, // INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE, // INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not // assume any responsibility for any errors which may appear in this software nor any // responsibility to update it. #include "stdafx.h" #include "EarthHemisphere.h" #include "Structures.fxh" #include "ElevationDataSource.h" #include "ShaderMacroHelper.h" struct SHemisphereVertex { D3DXVECTOR3 f3WorldPos; D3DXVECTOR2 f2MaskUV0; SHemisphereVertex() : f3WorldPos(0,0,0), f2MaskUV0(0,0){} }; enum QUAD_TRIANGULATION_TYPE { QUAD_TRIANG_TYPE_UNDEFINED = 0, // 01 11 // *------* // | .' | // | .' | // * -----* // 00 10 QUAD_TRIANG_TYPE_00_TO_11, // 01 11 // *------* // | '. | // | '. | // * -----* // 00 10 QUAD_TRIANG_TYPE_01_TO_10 }; template<typename IndexType, class CIndexGenerator> class CTriStrip { public: CTriStrip(std::vector<IndexType> &Indices, CIndexGenerator IndexGenerator): m_Indices(Indices), m_IndexGenerator(IndexGenerator), m_QuadTriangType(QUAD_TRIANG_TYPE_UNDEFINED) { } void AddStrip(int iBaseIndex, int iStartCol, int iStartRow, int iNumCols, int iNumRows, QUAD_TRIANGULATION_TYPE QuadTriangType) { assert( QuadTriangType == QUAD_TRIANG_TYPE_00_TO_11 || QuadTriangType == QUAD_TRIANG_TYPE_01_TO_10 ); int iFirstVertex = iBaseIndex + m_IndexGenerator(iStartCol, iStartRow + (QuadTriangType==QUAD_TRIANG_TYPE_00_TO_11 ? 1:0)); if(m_QuadTriangType != QUAD_TRIANG_TYPE_UNDEFINED) { // To move from one strip to another, we have to generate two degenerate triangles // by duplicating the last vertex in previous strip and the first vertex in new strip m_Indices.push_back( m_Indices.back() ); m_Indices.push_back( iFirstVertex ); } if(m_QuadTriangType != QUAD_TRIANG_TYPE_UNDEFINED && m_QuadTriangType != QuadTriangType || m_QuadTriangType == QUAD_TRIANG_TYPE_UNDEFINED && QuadTriangType == QUAD_TRIANG_TYPE_01_TO_10) { // If triangulation orientation changes, or if start strip orientation is 01 to 10, // we also have to add one additional vertex to preserve winding order m_Indices.push_back( iFirstVertex ); } m_QuadTriangType = QuadTriangType; for(int iRow = 0; iRow < iNumRows-1; ++iRow) { for(int iCol = 0; iCol < iNumCols; ++iCol) { int iV00 = iBaseIndex + m_IndexGenerator(iStartCol+iCol, iStartRow+iRow); int iV01 = iBaseIndex + m_IndexGenerator(iStartCol+iCol, iStartRow+iRow+1); if( m_QuadTriangType == QUAD_TRIANG_TYPE_01_TO_10 ) { if( iCol == 0 && iRow == 0) assert(iFirstVertex == iV00); // 01 11 // *------* // | '. | // | '. | // * -----* // 00 10 m_Indices.push_back(iV00); m_Indices.push_back(iV01); } else if( m_QuadTriangType == QUAD_TRIANG_TYPE_00_TO_11 ) { if( iCol == 0 && iRow == 0) assert(iFirstVertex == iV01); // 01 11 // *------* // | .' | // | .' | // * -----* // 00 10 m_Indices.push_back(iV01); m_Indices.push_back(iV00); } else { assert(false); } } if(iRow < iNumRows-2) { m_Indices.push_back( m_Indices.back() ); m_Indices.push_back( iBaseIndex + m_IndexGenerator(iStartCol, iStartRow+iRow+1 + (QuadTriangType==QUAD_TRIANG_TYPE_00_TO_11 ? 1:0)) ); } } } private: QUAD_TRIANGULATION_TYPE m_QuadTriangType; std::vector<IndexType> &m_Indices; CIndexGenerator m_IndexGenerator; }; class CStdIndexGenerator { public: CStdIndexGenerator(int iPitch):m_iPitch(iPitch){} UINT operator ()(int iCol, int iRow){return iCol + iRow*m_iPitch;} private: int m_iPitch; }; typedef CTriStrip<UINT, CStdIndexGenerator> StdTriStrip32; void ComputeVertexHeight(SHemisphereVertex &Vertex, class CElevationDataSource *pDataSource, float fSamplingStep, float fSampleScale) { D3DXVECTOR3 &f3PosWS = Vertex.f3WorldPos; float fCol = f3PosWS.x / fSamplingStep; float fRow = f3PosWS.z / fSamplingStep; float fDispl = pDataSource->GetInterpolatedHeight(fCol, fRow); int iColOffset, iRowOffset; pDataSource->GetOffsets(iColOffset, iRowOffset); Vertex.f2MaskUV0.x = (fCol + (float)iColOffset + 0.5f)/(float)pDataSource->GetNumCols(); Vertex.f2MaskUV0.y = (fRow + (float)iRowOffset + 0.5f)/(float)pDataSource->GetNumRows(); D3DXVECTOR3 f3SphereNormal; D3DXVec3Normalize(&f3SphereNormal, &f3PosWS); f3PosWS += f3SphereNormal * fDispl * fSampleScale; } class CRingMeshBuilder { public: CRingMeshBuilder(ID3D11Device *pDevice, const std::vector<SHemisphereVertex> &VB, int iGridDimenion, std::vector<SRingSectorMesh> &RingMeshes) : m_pDevice(pDevice), m_VB(VB), m_iGridDimenion(iGridDimenion), m_RingMeshes(RingMeshes){} void CreateMesh(int iBaseIndex, int iStartCol, int iStartRow, int iNumCols, int iNumRows, enum QUAD_TRIANGULATION_TYPE QuadTriangType) { m_RingMeshes.push_back( SRingSectorMesh() ); auto& CurrMesh = m_RingMeshes.back(); std::vector<UINT> IB; StdTriStrip32 TriStrip( IB, CStdIndexGenerator(m_iGridDimenion) ); TriStrip.AddStrip(iBaseIndex, iStartCol, iStartRow, iNumCols, iNumRows, QuadTriangType); CurrMesh.uiNumIndices = (UINT)IB.size(); // Prepare buffer description D3D11_BUFFER_DESC IndexBufferDesc= { (UINT)(IB.size() * sizeof(IB[0])), D3D11_USAGE_IMMUTABLE, D3D11_BIND_INDEX_BUFFER, 0, //UINT CPUAccessFlags 0, //UINT MiscFlags; 0, //UINT StructureByteStride; }; D3D11_SUBRESOURCE_DATA IBInitData = {&IB[0], 0, 0}; // Create the buffer HRESULT hr; V( m_pDevice->CreateBuffer( &IndexBufferDesc, &IBInitData, &CurrMesh.pIndBuff) ); // Compute bounding box auto &BB = CurrMesh.BoundBox; BB.fMaxX =BB.fMaxY = BB.fMaxZ = -FLT_MAX; BB.fMinX =BB.fMinY = BB.fMinZ = +FLT_MAX; for(auto Ind = IB.begin(); Ind != IB.end(); ++Ind) { const auto &CurrVert = m_VB[*Ind].f3WorldPos; BB.fMinX = min(BB.fMinX, CurrVert.x); BB.fMinY = min(BB.fMinY, CurrVert.y); BB.fMinZ = min(BB.fMinZ, CurrVert.z); BB.fMaxX = max(BB.fMaxX, CurrVert.x); BB.fMaxY = max(BB.fMaxY, CurrVert.y); BB.fMaxZ = max(BB.fMaxZ, CurrVert.z); } } private: CComPtr<ID3D11Device> m_pDevice; std::vector<SRingSectorMesh> &m_RingMeshes; const std::vector<SHemisphereVertex> &m_VB; const int m_iGridDimenion; }; void GenerateSphereGeometry(ID3D11Device *pDevice, const float fEarthRadius, int iGridDimension, const int iNumRings, class CElevationDataSource *pDataSource, float fSamplingStep, float fSampleScale, std::vector<SHemisphereVertex> &VB, std::vector<UINT> &StitchIB, std::vector<SRingSectorMesh> &SphereMeshes) { if( (iGridDimension - 1) % 4 != 0 ) { assert(false); iGridDimension = SRenderingParams().m_iRingDimension; } const int iGridMidst = (iGridDimension-1)/2; const int iGridQuart = (iGridDimension-1)/4; const int iLargestGridScale = iGridDimension << (iNumRings-1); CRingMeshBuilder RingMeshBuilder(pDevice, VB, iGridDimension, SphereMeshes); int iStartRing = 0; VB.reserve( (iNumRings-iStartRing) * iGridDimension * iGridDimension ); for(int iRing = iStartRing; iRing < iNumRings; ++iRing) { int iCurrGridStart = (int)VB.size(); VB.resize(VB.size() + iGridDimension * iGridDimension); float fGridScale = 1.f / (float)(1<<(iNumRings-1 - iRing)); // Fill vertex buffer for(int iRow = 0; iRow < iGridDimension; ++iRow) for(int iCol = 0; iCol < iGridDimension; ++iCol) { auto &CurrVert = VB[iCurrGridStart + iCol + iRow*iGridDimension]; auto &f3Pos = CurrVert.f3WorldPos; f3Pos.x = static_cast<float>(iCol) / static_cast<float>(iGridDimension-1); f3Pos.z = static_cast<float>(iRow) / static_cast<float>(iGridDimension-1); f3Pos.x = f3Pos.x*2 - 1; f3Pos.z = f3Pos.z*2 - 1; f3Pos.y = 0; float fDirectionScale = 1; if( f3Pos.x != 0 || f3Pos.z != 0 ) { float fDX = abs(f3Pos.x); float fDZ = abs(f3Pos.z); float fMaxD = max(fDX, fDZ); float fMinD = min(fDX, fDZ); float fTan = fMinD/fMaxD; fDirectionScale = 1 / sqrt(1 + fTan*fTan); } f3Pos.x *= fDirectionScale*fGridScale; f3Pos.z *= fDirectionScale*fGridScale; f3Pos.y = sqrt( max(0, 1 - (f3Pos.x*f3Pos.x + f3Pos.z*f3Pos.z)) ); f3Pos.x *= fEarthRadius; f3Pos.z *= fEarthRadius; f3Pos.y *= fEarthRadius; ComputeVertexHeight(CurrVert, pDataSource, fSamplingStep, fSampleScale); f3Pos.y -= fEarthRadius; } // Align vertices on the outer boundary if( iRing < iNumRings-1 ) { for(int i=1; i < iGridDimension-1; i+=2) { // Top & bottom boundaries for(int iRow=0; iRow < iGridDimension; iRow += iGridDimension-1) { const auto &V0 = VB[iCurrGridStart + i - 1 + iRow*iGridDimension].f3WorldPos; auto &V1 = VB[iCurrGridStart + i + 0 + iRow*iGridDimension].f3WorldPos; const auto &V2 = VB[iCurrGridStart + i + 1 + iRow*iGridDimension].f3WorldPos; V1 = (V0+V2)/2.f; } // Left & right boundaries for(int iCol=0; iCol < iGridDimension; iCol += iGridDimension-1) { const auto &V0 = VB[iCurrGridStart + iCol + (i - 1)*iGridDimension].f3WorldPos; auto &V1 = VB[iCurrGridStart + iCol + (i + 0)*iGridDimension].f3WorldPos; const auto &V2 = VB[iCurrGridStart + iCol + (i + 1)*iGridDimension].f3WorldPos; V1 = (V0+V2)/2.f; } } // Add triangles stitching this ring with the next one int iNextGridStart = (int)VB.size(); assert( iNextGridStart == iCurrGridStart + iGridDimension*iGridDimension); // Bottom boundary for(int iCol=0; iCol < iGridDimension-1; iCol += 2) { StitchIB.push_back(iNextGridStart + (iGridQuart + iCol/2) + iGridQuart * iGridDimension); StitchIB.push_back(iCurrGridStart + (iCol+1) + 0 * iGridDimension); StitchIB.push_back(iCurrGridStart + (iCol+0) + 0 * iGridDimension); StitchIB.push_back(iNextGridStart + (iGridQuart + iCol/2) + iGridQuart * iGridDimension); StitchIB.push_back(iCurrGridStart + (iCol+2) + 0 * iGridDimension); StitchIB.push_back(iCurrGridStart + (iCol+1) + 0 * iGridDimension); StitchIB.push_back(iNextGridStart + (iGridQuart + iCol/2) + iGridQuart * iGridDimension); StitchIB.push_back(iNextGridStart + (iGridQuart + iCol/2+1) + iGridQuart * iGridDimension); StitchIB.push_back(iCurrGridStart + (iCol+2) + 0 * iGridDimension); } // Top boundary for(int iCol=0; iCol < iGridDimension-1; iCol += 2) { StitchIB.push_back(iCurrGridStart + (iCol+0) + (iGridDimension-1) * iGridDimension); StitchIB.push_back(iCurrGridStart + (iCol+1) + (iGridDimension-1) * iGridDimension); StitchIB.push_back(iNextGridStart + (iGridQuart + iCol/2) + iGridQuart* 3 * iGridDimension); StitchIB.push_back(iCurrGridStart + (iCol+1) + (iGridDimension-1) * iGridDimension); StitchIB.push_back(iCurrGridStart + (iCol+2) + (iGridDimension-1) * iGridDimension); StitchIB.push_back(iNextGridStart + (iGridQuart + iCol/2) + iGridQuart* 3 * iGridDimension); StitchIB.push_back(iCurrGridStart + (iCol+2) + (iGridDimension-1) * iGridDimension); StitchIB.push_back(iNextGridStart + (iGridQuart + iCol/2 + 1) + iGridQuart* 3 * iGridDimension); StitchIB.push_back(iNextGridStart + (iGridQuart + iCol/2) + iGridQuart* 3 * iGridDimension); } // Left boundary for(int iRow=0; iRow < iGridDimension-1; iRow += 2) { StitchIB.push_back(iNextGridStart + iGridQuart + (iGridQuart+ iRow/2) * iGridDimension); StitchIB.push_back(iCurrGridStart + 0 + (iRow+0) * iGridDimension); StitchIB.push_back(iCurrGridStart + 0 + (iRow+1) * iGridDimension); StitchIB.push_back(iNextGridStart + iGridQuart + (iGridQuart+ iRow/2) * iGridDimension); StitchIB.push_back(iCurrGridStart + 0 + (iRow+1) * iGridDimension); StitchIB.push_back(iCurrGridStart + 0 + (iRow+2) * iGridDimension); StitchIB.push_back(iNextGridStart + iGridQuart + (iGridQuart + iRow/2 + 1) * iGridDimension); StitchIB.push_back(iNextGridStart + iGridQuart + (iGridQuart + iRow/2) * iGridDimension); StitchIB.push_back(iCurrGridStart + 0 + (iRow+2) * iGridDimension); } // Right boundary for(int iRow=0; iRow < iGridDimension-1; iRow += 2) { StitchIB.push_back(iCurrGridStart + (iGridDimension-1) + (iRow+1) * iGridDimension); StitchIB.push_back(iCurrGridStart + (iGridDimension-1) + (iRow+0) * iGridDimension); StitchIB.push_back(iNextGridStart + iGridQuart*3 + (iGridQuart+ iRow/2) * iGridDimension); StitchIB.push_back(iCurrGridStart + (iGridDimension-1) + (iRow+2) * iGridDimension); StitchIB.push_back(iCurrGridStart + (iGridDimension-1) + (iRow+1) * iGridDimension); StitchIB.push_back(iNextGridStart + iGridQuart*3 + (iGridQuart+ iRow/2) * iGridDimension); StitchIB.push_back(iCurrGridStart + (iGridDimension-1) + (iRow+2) * iGridDimension); StitchIB.push_back(iNextGridStart + iGridQuart*3 + (iGridQuart+ iRow/2) * iGridDimension); StitchIB.push_back(iNextGridStart + iGridQuart*3 + (iGridQuart+ iRow/2 + 1) * iGridDimension); } } // Generate indices for the current ring if( iRing == 0 ) { RingMeshBuilder.CreateMesh( iCurrGridStart, 0, 0, iGridMidst+1, iGridMidst+1, QUAD_TRIANG_TYPE_00_TO_11); RingMeshBuilder.CreateMesh( iCurrGridStart, iGridMidst, 0, iGridMidst+1, iGridMidst+1, QUAD_TRIANG_TYPE_01_TO_10); RingMeshBuilder.CreateMesh( iCurrGridStart, 0, iGridMidst, iGridMidst+1, iGridMidst+1, QUAD_TRIANG_TYPE_01_TO_10); RingMeshBuilder.CreateMesh( iCurrGridStart, iGridMidst, iGridMidst, iGridMidst+1, iGridMidst+1, QUAD_TRIANG_TYPE_00_TO_11); } else { RingMeshBuilder.CreateMesh( iCurrGridStart, 0, 0, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_00_TO_11); RingMeshBuilder.CreateMesh( iCurrGridStart, iGridQuart, 0, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_00_TO_11); RingMeshBuilder.CreateMesh( iCurrGridStart, iGridMidst, 0, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_01_TO_10); RingMeshBuilder.CreateMesh( iCurrGridStart, iGridQuart*3, 0, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_01_TO_10); RingMeshBuilder.CreateMesh( iCurrGridStart, 0, iGridQuart, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_00_TO_11); RingMeshBuilder.CreateMesh( iCurrGridStart, 0, iGridMidst, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_01_TO_10); RingMeshBuilder.CreateMesh( iCurrGridStart, iGridQuart*3, iGridQuart, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_01_TO_10); RingMeshBuilder.CreateMesh( iCurrGridStart, iGridQuart*3, iGridMidst, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_00_TO_11); RingMeshBuilder.CreateMesh( iCurrGridStart, 0, iGridQuart*3, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_01_TO_10); RingMeshBuilder.CreateMesh( iCurrGridStart, iGridQuart, iGridQuart*3, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_01_TO_10); RingMeshBuilder.CreateMesh( iCurrGridStart, iGridMidst, iGridQuart*3, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_00_TO_11); RingMeshBuilder.CreateMesh( iCurrGridStart, iGridQuart*3, iGridQuart*3, iGridQuart+1, iGridQuart+1, QUAD_TRIANG_TYPE_00_TO_11); } } // We do not need per-vertex normals as we use normal map to shade terrain // Sphere tangent vertex are computed in the shader #if 0 // Compute normals const D3DXVECTOR3 *pV0 = nullptr; const D3DXVECTOR3 *pV1 = &VB[ IB[0] ].f3WorldPos; const D3DXVECTOR3 *pV2 = &VB[ IB[1] ].f3WorldPos; float fSign = +1; for(UINT Ind=2; Ind < m_uiIndicesInIndBuff; ++Ind) { fSign = -fSign; pV0 = pV1; pV1 = pV2; pV2 = &VB[ IB[Ind] ].f3WorldPos; D3DXVECTOR3 Rib0 = *pV0 - *pV1; D3DXVECTOR3 Rib1 = *pV1 - *pV2; D3DXVECTOR3 TriN; D3DXVec3Cross(&TriN, &Rib0, &Rib1); float fLength = D3DXVec3Length(&TriN); if( fLength > 0.1 ) { TriN /= fLength*fSign; for(int i=-2; i <= 0; ++i) VB[ IB[Ind+i] ].f3Normal += TriN; } } for(auto VBIt=VB.begin(); VBIt != VB.end(); ++VBIt) { float fLength = D3DXVec3Length(&VBIt->f3Normal); if( fLength > 1 ) VBIt->f3Normal /= fLength; } // Adjust normals on boundaries for(int iRing = iStartRing; iRing < iNumRings-1; ++iRing) { int iCurrGridStart = (iRing-iStartRing) * iGridDimension*iGridDimension; int iNextGridStart = (iRing-iStartRing+1) * iGridDimension*iGridDimension; for(int i=0; i < iGridDimension; i+=2) { for(int Bnd=0; Bnd < 2; ++Bnd) { const int CurrGridOffsets[] = {0, iGridDimension-1}; const int NextGridPffsets[] = {iGridQuart, iGridQuart*3}; // Left and right boundaries { auto &CurrGridN = VB[iCurrGridStart + CurrGridOffsets[Bnd] + i*iGridDimension].f3Normal; auto &NextGridN = VB[iNextGridStart + NextGridPffsets[Bnd] + (iGridQuart+i/2)*iGridDimension].f3Normal; auto NewN = CurrGridN + NextGridN; D3DXVec3Normalize(&NewN, &NewN); CurrGridN = NextGridN = NewN; if( i > 1 ) { auto &PrevCurrGridN = VB[iCurrGridStart + CurrGridOffsets[Bnd] + (i-2)*iGridDimension].f3Normal; auto MiddleN = PrevCurrGridN + NewN; D3DXVec3Normalize( &VB[iCurrGridStart + CurrGridOffsets[Bnd] + (i-1)*iGridDimension].f3Normal, &MiddleN); } } // Bottom and top boundaries { auto &CurrGridN = VB[iCurrGridStart + i + CurrGridOffsets[Bnd]*iGridDimension].f3Normal; auto &NextGridN = VB[iNextGridStart + (iGridQuart+i/2) + NextGridPffsets[Bnd]*iGridDimension].f3Normal; auto NewN = CurrGridN + NextGridN; D3DXVec3Normalize(&NewN, &NewN); CurrGridN = NextGridN = NewN; if( i > 1 ) { auto &PrevCurrGridN = VB[iCurrGridStart + (i-2) + CurrGridOffsets[Bnd]*iGridDimension].f3Normal; auto MiddleN = PrevCurrGridN + NewN; D3DXVec3Normalize( &VB[iCurrGridStart + (i-1) + CurrGridOffsets[Bnd]*iGridDimension].f3Normal, &MiddleN); } } } } } #endif } HRESULT CEarthHemsiphere::CreateRenderStates(ID3D11Device* pd3dDevice) { HRESULT hr; // Create depth stencil state D3D11_DEPTH_STENCIL_DESC DisableDepthTestDSDesc; ZeroMemory(&DisableDepthTestDSDesc, sizeof(DisableDepthTestDSDesc)); DisableDepthTestDSDesc.DepthEnable = FALSE; DisableDepthTestDSDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; V( pd3dDevice->CreateDepthStencilState( &DisableDepthTestDSDesc, &m_pDisableDepthTestDS) ); D3D11_DEPTH_STENCIL_DESC EnableDepthTestDSDesc; ZeroMemory(&EnableDepthTestDSDesc, sizeof(EnableDepthTestDSDesc)); EnableDepthTestDSDesc.DepthEnable = TRUE; EnableDepthTestDSDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; EnableDepthTestDSDesc.DepthFunc = D3D11_COMPARISON_GREATER; V( pd3dDevice->CreateDepthStencilState( &EnableDepthTestDSDesc, &m_pEnableDepthTestDS) ); // Create default blend state D3D11_BLEND_DESC DefaultBlendStateDesc; ZeroMemory(&DefaultBlendStateDesc, sizeof(DefaultBlendStateDesc)); DefaultBlendStateDesc.IndependentBlendEnable = FALSE; for(int i=0; i< _countof(DefaultBlendStateDesc.RenderTarget); i++) DefaultBlendStateDesc.RenderTarget[i].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; V( pd3dDevice->CreateBlendState( &DefaultBlendStateDesc, &m_pDefaultBS) ); // Create rasterizer state for solid fill mode D3D11_RASTERIZER_DESC RSSolidFill = { D3D11_FILL_SOLID, D3D11_CULL_BACK, TRUE, //BOOL FrontCounterClockwise; 0,// INT DepthBias; 0,// FLOAT DepthBiasClamp; 0,// FLOAT SlopeScaledDepthBias; TRUE,//BOOL DepthClipEnable; FALSE,//BOOL ScissorEnable; FALSE,//BOOL MultisampleEnable; FALSE,//BOOL AntialiasedLineEnable; }; hr = pd3dDevice->CreateRasterizerState( &RSSolidFill, &m_pRSSolidFill ); D3D11_RASTERIZER_DESC RSWireframeFill = RSSolidFill; RSWireframeFill.FillMode = D3D11_FILL_WIREFRAME; hr = pd3dDevice->CreateRasterizerState( &RSWireframeFill, &m_pRSWireframeFill ); D3D11_RASTERIZER_DESC SolidFillCullBackRSDesc; ZeroMemory(&SolidFillCullBackRSDesc, sizeof(SolidFillCullBackRSDesc)); SolidFillCullBackRSDesc.FillMode = D3D11_FILL_SOLID; SolidFillCullBackRSDesc.CullMode = D3D11_CULL_NONE; V( pd3dDevice->CreateRasterizerState( &SolidFillCullBackRSDesc, &m_pRSSolidFillNoCull) ); D3D11_RASTERIZER_DESC ZOnlyPassRSDesc = RSSolidFill; // Disable depth clipping ZOnlyPassRSDesc.DepthClipEnable = FALSE; // Do not use slope-scaled depth bias because this results in light leaking // through terrain! //ZOnlyPassRSDesc.DepthBias = -1; //ZOnlyPassRSDesc.SlopeScaledDepthBias = -4; //ZOnlyPassRSDesc.DepthBiasClamp = -1e-6; ZOnlyPassRSDesc.FrontCounterClockwise = FALSE; V( pd3dDevice->CreateRasterizerState( &ZOnlyPassRSDesc, &m_pRSZOnlyPass) ); D3D11_SAMPLER_DESC SamLinearMirrorDesc = { D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_MIRROR, D3D11_TEXTURE_ADDRESS_MIRROR, D3D11_TEXTURE_ADDRESS_MIRROR, 0, //FLOAT MipLODBias; 0, //UINT MaxAnisotropy; D3D11_COMPARISON_NEVER, // D3D11_COMPARISON_FUNC ComparisonFunc; {0.f, 0.f, 0.f, 0.f}, //FLOAT BorderColor[ 4 ]; -FLT_MAX, //FLOAT MinLOD; +FLT_MAX //FLOAT MaxLOD; }; V( pd3dDevice->CreateSamplerState( &SamLinearMirrorDesc, &m_psamLinearMirror) ); D3D11_SAMPLER_DESC SamPointClamp = { D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_CLAMP, 0, //FLOAT MipLODBias; 0, //UINT MaxAnisotropy; D3D11_COMPARISON_NEVER, // D3D11_COMPARISON_FUNC ComparisonFunc; {0.f, 0.f, 0.f, 0.f}, //FLOAT BorderColor[ 4 ]; -FLT_MAX, //FLOAT MinLOD; +FLT_MAX //FLOAT MaxLOD; }; V( pd3dDevice->CreateSamplerState( &SamPointClamp, &m_psamPointClamp) ); D3D11_SAMPLER_DESC SamLinearClamp = { D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_CLAMP, 0, //FLOAT MipLODBias; 0, //UINT MaxAnisotropy; D3D11_COMPARISON_NEVER, // D3D11_COMPARISON_FUNC ComparisonFunc; {0.f, 0.f, 0.f, 0.f}, //FLOAT BorderColor[ 4 ]; -FLT_MAX, //FLOAT MinLOD; +FLT_MAX //FLOAT MaxLOD; }; V( pd3dDevice->CreateSamplerState( &SamLinearClamp, &m_psamLinearClamp) ); D3D11_SAMPLER_DESC SamComparison = { D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_CLAMP, 0, //FLOAT MipLODBias; 0, //UINT MaxAnisotropy; D3D11_COMPARISON_GREATER, // D3D11_COMPARISON_FUNC ComparisonFunc; {0.f, 0.f, 0.f, 0.f}, //FLOAT BorderColor[ 4 ]; -FLT_MAX, //FLOAT MinLOD; +FLT_MAX //FLOAT MaxLOD; }; V( pd3dDevice->CreateSamplerState( &SamComparison, &m_psamComaprison) ); D3D11_SAMPLER_DESC SamLinearWrapDesc = { D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_WRAP, 0, //FLOAT MipLODBias; 0, //UINT MaxAnisotropy; D3D11_COMPARISON_NEVER, // D3D11_COMPARISON_FUNC ComparisonFunc; {0.f, 0.f, 0.f, 0.f}, //FLOAT BorderColor[ 4 ]; -FLT_MAX, //FLOAT MinLOD; +FLT_MAX //FLOAT MaxLOD; }; V( pd3dDevice->CreateSamplerState( &SamLinearWrapDesc, &m_psamLinearWrap) ); return S_OK; } void CEarthHemsiphere::RenderNormalMap(ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, const UINT16 *pHeightMap, size_t HeightMapPitch, int iHeightMapDim) { HRESULT hr; D3D11_TEXTURE2D_DESC HeightMapDesc = { iHeightMapDim, iHeightMapDim, 1, 1, DXGI_FORMAT_R16_UNORM, {1,0}, D3D11_USAGE_IMMUTABLE, D3D11_BIND_SHADER_RESOURCE, 0, 0 }; while( (iHeightMapDim >> HeightMapDesc.MipLevels) > 1 ) ++HeightMapDesc.MipLevels; std::vector<UINT16> CoarseMipLevels; CoarseMipLevels.resize( iHeightMapDim/2 * iHeightMapDim ); std::vector<D3D11_SUBRESOURCE_DATA> InitData(HeightMapDesc.MipLevels); InitData[0].pSysMem = pHeightMap; InitData[0].SysMemPitch = (UINT)HeightMapPitch*sizeof(pHeightMap[0]); const UINT16 *pFinerMipLevel = pHeightMap; UINT16 *pCurrMipLevel = &CoarseMipLevels[0]; size_t FinerMipPitch = HeightMapPitch; size_t CurrMipPitch = iHeightMapDim/2; for(UINT uiMipLevel = 1; uiMipLevel < HeightMapDesc.MipLevels; ++uiMipLevel) { auto MipWidth = HeightMapDesc.Width >> uiMipLevel; auto MipHeight = HeightMapDesc.Height >> uiMipLevel; for(UINT uiRow=0; uiRow < MipHeight; ++uiRow) for(UINT uiCol=0; uiCol < MipWidth; ++uiCol) { int iAverageHeight = 0; for(int i=0; i<2; ++i) for(int j=0; j<2; ++j) iAverageHeight += pFinerMipLevel[ (uiCol*2+i) + (uiRow*2+j)*FinerMipPitch]; pCurrMipLevel[uiCol + uiRow*CurrMipPitch] = (UINT16)(iAverageHeight>>2); } InitData[uiMipLevel].pSysMem = pCurrMipLevel; InitData[uiMipLevel].SysMemPitch = (UINT)CurrMipPitch*sizeof(*pCurrMipLevel); pFinerMipLevel = pCurrMipLevel; FinerMipPitch = CurrMipPitch; pCurrMipLevel += MipHeight*CurrMipPitch; CurrMipPitch = iHeightMapDim/2; } CComPtr<ID3D11Texture2D> ptex2DHeightMap; pd3dDevice->CreateTexture2D(&HeightMapDesc, &InitData[0], &ptex2DHeightMap); CComPtr<ID3D11ShaderResourceView> ptex2DHeightMapSRV; pd3dDevice->CreateShaderResourceView(ptex2DHeightMap, nullptr, &ptex2DHeightMapSRV); D3D11_TEXTURE2D_DESC NormalMapDesc = HeightMapDesc; NormalMapDesc.Format = DXGI_FORMAT_R8G8_SNORM; NormalMapDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; NormalMapDesc.Usage = D3D11_USAGE_DEFAULT; CComPtr<ID3D11Texture2D> ptex2DNormalMap; pd3dDevice->CreateTexture2D(&NormalMapDesc, &InitData[0], &ptex2DNormalMap); pd3dDevice->CreateShaderResourceView(ptex2DNormalMap, nullptr, &m_ptex2DNormalMapSRV); CComPtr<ID3D11RenderTargetView> pOrigRTV; CComPtr<ID3D11DepthStencilView> pOrigDSV; pd3dImmediateContext->OMGetRenderTargets( 1, &pOrigRTV, &pOrigDSV ); D3D11_VIEWPORT OrigViewPort; UINT iNumOldViewports = 1; pd3dImmediateContext->RSGetViewports(&iNumOldViewports, &OrigViewPort); CRenderTechnique RenderNormalMapTech; RenderNormalMapTech.SetDeviceAndContext(pd3dDevice, pd3dImmediateContext); V( RenderNormalMapTech.CreateVGPShadersFromFile( L"fx\\Terrain.fx", "GenerateScreenSizeQuadVS", NULL, "GenerateNormalMapPS", NULL ) ); RenderNormalMapTech.SetDS( m_pDisableDepthTestDS ); RenderNormalMapTech.SetRS( m_pRSSolidFillNoCull ); RenderNormalMapTech.SetBS( m_pDefaultBS ); D3D11_VIEWPORT NewViewPort; NewViewPort.TopLeftX = 0; NewViewPort.TopLeftY = 0; NewViewPort.MinDepth = 0; NewViewPort.MaxDepth = 1; D3D11_BUFFER_DESC CBDesc = { sizeof(SNMGenerationAttribs), D3D11_USAGE_DYNAMIC, D3D11_BIND_CONSTANT_BUFFER, D3D11_CPU_ACCESS_WRITE, //UINT CPUAccessFlags 0, //UINT MiscFlags; 0, //UINT StructureByteStride; }; CComPtr<ID3D11Buffer> pcbNMGenerationAttribs; V( pd3dDevice->CreateBuffer( &CBDesc, NULL, &pcbNMGenerationAttribs) ); pd3dImmediateContext->PSSetConstantBuffers(0, 1, &pcbNMGenerationAttribs.p); pd3dImmediateContext->PSSetShaderResources(0, 1, &ptex2DHeightMapSRV.p); pd3dImmediateContext->PSSetSamplers(0, 1, &m_psamPointClamp.p); for(UINT uiMipLevel = 0; uiMipLevel < NormalMapDesc.MipLevels; ++uiMipLevel) { D3D11_RENDER_TARGET_VIEW_DESC RTVDesc; RTVDesc.Format = NormalMapDesc.Format; RTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; RTVDesc.Texture2D.MipSlice = uiMipLevel; CComPtr<ID3D11RenderTargetView> ptex2DNormalMapRTV; pd3dDevice->CreateRenderTargetView(ptex2DNormalMap, &RTVDesc, &ptex2DNormalMapRTV); NewViewPort.Width = (float)(NormalMapDesc.Width >> uiMipLevel); NewViewPort.Height = (float)(NormalMapDesc.Height >> uiMipLevel); pd3dImmediateContext->RSSetViewports(1, &NewViewPort); pd3dImmediateContext->OMSetRenderTargets(1, &ptex2DNormalMapRTV.p, NULL); SNMGenerationAttribs NMGenerationAttribs; NMGenerationAttribs.m_fElevationScale = m_Params.m_TerrainAttribs.m_fElevationScale; NMGenerationAttribs.m_fSampleSpacingInterval = m_Params.m_TerrainAttribs.m_fElevationSamplingInterval; NMGenerationAttribs.m_fMIPLevel = (float)uiMipLevel; UpdateConstantBuffer(pd3dImmediateContext, pcbNMGenerationAttribs, &NMGenerationAttribs, sizeof(NMGenerationAttribs)); RenderNormalMapTech.Apply(); pd3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); pd3dImmediateContext->Draw(4,0); } pd3dImmediateContext->RSSetViewports(iNumOldViewports, &OrigViewPort); pd3dImmediateContext->OMSetRenderTargets( 1, &pOrigRTV.p, pOrigDSV ); } HRESULT CEarthHemsiphere::OnD3D11CreateDevice( class CElevationDataSource *pDataSource, const SRenderingParams &Params, ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, LPCTSTR HeightMapPath, LPCTSTR MaterialMaskPath, LPCTSTR *TileTexturePath, LPCTSTR *TileNormalMapPath) { HRESULT hr; m_Params = Params; const UINT16 *pHeightMap; size_t HeightMapPitch; pDataSource->GetDataPtr(pHeightMap, HeightMapPitch); int iHeightMapDim = pDataSource->GetNumCols(); assert(iHeightMapDim == pDataSource->GetNumRows() ); std::vector<SHemisphereVertex> VB; std::vector<UINT> StitchIB; GenerateSphereGeometry(pd3dDevice, SAirScatteringAttribs().fEarthRadius, m_Params.m_iRingDimension, m_Params.m_iNumRings, pDataSource, m_Params.m_TerrainAttribs.m_fElevationSamplingInterval, m_Params.m_TerrainAttribs.m_fElevationScale, VB, StitchIB, m_SphereMeshes); D3D11_BUFFER_DESC VBDesc = { (UINT)(VB.size() * sizeof(VB[0])), D3D11_USAGE_IMMUTABLE, D3D11_BIND_VERTEX_BUFFER, 0, //UINT CPUAccessFlags 0, //UINT MiscFlags; 0, //UINT StructureByteStride; }; D3D11_SUBRESOURCE_DATA VBInitData = {&VB[0], 0, 0}; hr = pd3dDevice->CreateBuffer(&VBDesc, &VBInitData , &m_pVertBuff); CHECK_HR_RET(hr, _T("Failed to create the Earth heimsphere vertex buffer") ) m_uiNumStitchIndices = (UINT)StitchIB.size(); D3D11_BUFFER_DESC StitchIndexBufferDesc= { (UINT)(m_uiNumStitchIndices * sizeof(StitchIB[0])), D3D11_USAGE_IMMUTABLE, D3D11_BIND_INDEX_BUFFER, 0, //UINT CPUAccessFlags 0, //UINT MiscFlags; 0, //UINT StructureByteStride; }; D3D11_SUBRESOURCE_DATA IBInitData = {&StitchIB[0], 0, 0}; // Create the buffer V( pd3dDevice->CreateBuffer( &StitchIndexBufferDesc, &IBInitData, &m_pStitchIndBuff) ); V( CreateRenderStates(pd3dDevice) ); m_RenderEarthHemisphereZOnlyTech.SetDeviceAndContext(pd3dDevice, pd3dImmediateContext); V( m_RenderEarthHemisphereZOnlyTech.CreateVGPShadersFromFile( L"fx\\Terrain.fx", "HemisphereZOnlyVS", NULL, NULL, NULL ) ); m_RenderEarthHemisphereZOnlyTech.SetDS( m_pEnableDepthTestDS ); m_RenderEarthHemisphereZOnlyTech.SetRS( m_pRSZOnlyPass ); m_RenderEarthHemisphereZOnlyTech.SetBS( m_pDefaultBS ); RenderNormalMap(pd3dDevice, pd3dImmediateContext, pHeightMap, HeightMapPitch, iHeightMapDim); D3DX11CreateShaderResourceViewFromFile(pd3dDevice, MaterialMaskPath, nullptr, nullptr, &m_ptex2DMtrlMaskSRV, nullptr); // Load tiles for(int iTileTex = 0; iTileTex < (int)NUM_TILE_TEXTURES; iTileTex++) { V( D3DX11CreateShaderResourceViewFromFile(pd3dDevice, TileTexturePath[iTileTex], NULL, NULL, &m_ptex2DTilesSRV[iTileTex], NULL) ); D3DX11_IMAGE_LOAD_INFO LoadInfo; memset( &LoadInfo, 0, sizeof(LoadInfo)); D3DX11_IMAGE_INFO NMFileInfo; D3DX11GetImageInfoFromFile(TileNormalMapPath[iTileTex],NULL,&NMFileInfo,NULL); LoadInfo.Width = NMFileInfo.Width; LoadInfo.Height = NMFileInfo.Height; LoadInfo.Depth = NMFileInfo.Depth; LoadInfo.MipLevels = (int)( log( (double)max(NMFileInfo.Width, NMFileInfo.Height)) / log(2.0) ); LoadInfo.BindFlags = D3D11_BIND_SHADER_RESOURCE; LoadInfo.Usage = D3D11_USAGE_IMMUTABLE; LoadInfo.Format = DXGI_FORMAT_R8G8B8A8_UNORM; LoadInfo.MipFilter = D3DX11_DEFAULT; LoadInfo.Filter = D3DX11_DEFAULT; V( D3DX11CreateShaderResourceViewFromFile(pd3dDevice, TileNormalMapPath[iTileTex], &LoadInfo, NULL, &m_ptex2DTilNormalMapsSRV[iTileTex], NULL) ); } D3D11_BUFFER_DESC CBDesc = { 0, D3D11_USAGE_DYNAMIC, D3D11_BIND_CONSTANT_BUFFER, D3D11_CPU_ACCESS_WRITE, //UINT CPUAccessFlags 0, //UINT MiscFlags; 0, //UINT StructureByteStride; }; CBDesc.ByteWidth = sizeof(STerrainAttribs); V( pd3dDevice->CreateBuffer( &CBDesc, NULL, &m_pcbTerrainAttribs) ); return S_OK; } void CEarthHemsiphere::OnD3D11DestroyDevice() { m_pStitchIndBuff.Release(); m_SphereMeshes.clear(); m_pVertBuff.Release(); m_pInputLayout.Release(); m_RenderEarthHemisphereTech.Release(); m_RenderEarthHemisphereZOnlyTech.Release(); m_psamPointClamp.Release(); m_psamLinearMirror.Release(); m_psamLinearWrap.Release(); m_psamLinearClamp.Release(); m_psamComaprison.Release(); m_pEnableDepthTestDS.Release(); m_pDisableDepthTestDS.Release(); m_pDefaultBS.Release(); m_pRSSolidFill.Release(); m_pRSSolidFillNoCull.Release(); m_pRSZOnlyPass.Release(); m_pRSWireframeFill.Release(); m_ptex2DNormalMapSRV.Release(); m_pcbTerrainAttribs.Release(); for(int iTileTex = 0; iTileTex < NUM_TILE_TEXTURES; iTileTex++) { m_ptex2DTilesSRV[iTileTex].Release(); m_ptex2DTilNormalMapsSRV[iTileTex].Release(); } } void CEarthHemsiphere::Render(ID3D11DeviceContext* pd3dImmediateContext, const D3DXMATRIX &CameraViewProjMatrix, ID3D11Buffer *pcbCameraAttribs, ID3D11Buffer *pcbLightAttribs, ID3D11Buffer *pcMediaScatteringParams, ID3D11ShaderResourceView *pShadowMapSRV, ID3D11ShaderResourceView *pLiSpCloudTransparencySRV, ID3D11ShaderResourceView *pPrecomputedNetDensitySRV, ID3D11ShaderResourceView *pAmbientSkylightSRV, bool bZOnlyPass) { if( GetAsyncKeyState(VK_F9) ) { m_RenderEarthHemisphereTech.Release(); } if( !m_RenderEarthHemisphereTech.IsValid() ) { HRESULT hr; CD3DShaderMacroHelper Macros; Macros.AddShaderMacro("TEXTURING_MODE", m_Params.m_TexturingMode); Macros.AddShaderMacro("NUM_TILE_TEXTURES", NUM_TILE_TEXTURES); Macros.AddShaderMacro("NUM_SHADOW_CASCADES", m_Params.m_iNumShadowCascades); Macros.AddShaderMacro("BEST_CASCADE_SEARCH", m_Params.m_bBestCascadeSearch ? true : false); Macros.AddShaderMacro("SMOOTH_SHADOWS", m_Params.m_bSmoothShadows ? true : false); Macros.AddShaderMacro("ENABLE_CLOUDS", m_Params.m_bEnableClouds ? true : false); Macros.Finalize(); CComPtr<ID3D11Device> pDevice; pd3dImmediateContext->GetDevice(&pDevice); m_RenderEarthHemisphereTech.SetDeviceAndContext(pDevice, pd3dImmediateContext); V( m_RenderEarthHemisphereTech.CreateVGPShadersFromFile( L"fx\\Terrain.fx", "HemisphereVS", NULL, "HemispherePS", Macros ) ); m_RenderEarthHemisphereTech.SetDS( m_pEnableDepthTestDS ); m_RenderEarthHemisphereTech.SetRS( m_pRSSolidFill ); m_RenderEarthHemisphereTech.SetBS( m_pDefaultBS ); if( !m_pInputLayout ) { // Create vertex input layout for bounding box buffer const D3D11_INPUT_ELEMENT_DESC layout[] = { { "WORLD_POS", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0*4, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "MASK0_UV", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 3*4, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; auto pVSByteCode = m_RenderEarthHemisphereTech.GetVSByteCode(); V( pDevice->CreateInputLayout( layout, ARRAYSIZE( layout ), pVSByteCode->GetBufferPointer(), pVSByteCode->GetBufferSize(), &m_pInputLayout ) ); } } SViewFrustum ViewFrustum; ExtractViewFrustumPlanesFromMatrix(CameraViewProjMatrix, ViewFrustum); UpdateConstantBuffer(pd3dImmediateContext, m_pcbTerrainAttribs, &m_Params.m_TerrainAttribs, sizeof(m_Params.m_TerrainAttribs)); ID3D11Buffer *pCBs[] = { m_pcbTerrainAttribs, pcMediaScatteringParams, pcbCameraAttribs, pcbLightAttribs }; pd3dImmediateContext->VSSetConstantBuffers(0, _countof(pCBs), pCBs); pd3dImmediateContext->PSSetConstantBuffers(0, _countof(pCBs), pCBs); ID3D11ShaderResourceView *pSRVs[4 + 2*NUM_TILE_TEXTURES] = { m_ptex2DNormalMapSRV, m_ptex2DMtrlMaskSRV, pShadowMapSRV, pLiSpCloudTransparencySRV }; for(int iTileTex = 0; iTileTex < NUM_TILE_TEXTURES; iTileTex++) { pSRVs[4+iTileTex] = m_ptex2DTilesSRV[iTileTex]; pSRVs[4+NUM_TILE_TEXTURES+iTileTex] = m_ptex2DTilNormalMapsSRV[iTileTex]; } pd3dImmediateContext->PSSetShaderResources(1, _countof(pSRVs), pSRVs); pSRVs[0] = nullptr; pSRVs[1] = pAmbientSkylightSRV; pSRVs[2] = nullptr; pSRVs[3] = nullptr; pSRVs[4] = nullptr; pSRVs[5] = pPrecomputedNetDensitySRV; pd3dImmediateContext->VSSetShaderResources(0, 6, pSRVs); ID3D11SamplerState *pSamplers[] = {m_psamLinearClamp, m_psamLinearMirror, m_psamLinearWrap, m_psamComaprison}; pd3dImmediateContext->VSSetSamplers(0, _countof(pSamplers), pSamplers); pd3dImmediateContext->PSSetSamplers(0, _countof(pSamplers), pSamplers); UINT offset[1] = { 0 }; UINT stride[1] = { sizeof(SHemisphereVertex) }; ID3D11Buffer* const ppBuffers[1] = { m_pVertBuff }; pd3dImmediateContext->IASetVertexBuffers( 0, 1, ppBuffers, stride, offset ); pd3dImmediateContext->IASetInputLayout( m_pInputLayout ); pd3dImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP ); if( bZOnlyPass ) m_RenderEarthHemisphereZOnlyTech.Apply(); else m_RenderEarthHemisphereTech.Apply(); for(auto MeshIt = m_SphereMeshes.begin(); MeshIt != m_SphereMeshes.end(); ++MeshIt) { UINT uiPlaneFlags = TEST_ALL_PLANES; if( bZOnlyPass ) { // It is necessary to ensure that shadow-casting patches, which are not visible // in the frustum, are still rendered into the shadow map. // For z-only pass, do not clip against far clipping plane (complimentary depth is used, // hence far, not near plane) uiPlaneFlags &= ~TEST_FAR_PLANE; } if(IsBoxVisible(ViewFrustum, MeshIt->BoundBox, uiPlaneFlags)) { pd3dImmediateContext->IASetIndexBuffer( MeshIt->pIndBuff, DXGI_FORMAT_R32_UINT, 0); pd3dImmediateContext->DrawIndexed(MeshIt->uiNumIndices, 0, 0); } } pd3dImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); pd3dImmediateContext->IASetIndexBuffer( m_pStitchIndBuff, DXGI_FORMAT_R32_UINT, 0); pd3dImmediateContext->DrawIndexed(m_uiNumStitchIndices, 0, 0); UnbindPSResources(pd3dImmediateContext); } void CEarthHemsiphere::UpdateParams(const SRenderingParams &NewParams) { if( m_Params.m_iNumShadowCascades != NewParams.m_iNumShadowCascades || m_Params.m_bBestCascadeSearch != NewParams.m_bBestCascadeSearch || m_Params.m_bSmoothShadows != NewParams.m_bSmoothShadows || m_Params.m_bEnableClouds != NewParams.m_bEnableClouds ) { m_RenderEarthHemisphereTech.Release(); } m_Params = NewParams; }
[ "alexhrao@gmail.com" ]
alexhrao@gmail.com
e74fdaf87eb139e795debd91a7445a0c782caf9e
23c524e47a96829d3b8e0aa6792fd40a20f3dd41
/.history/Map_20210529111042.hpp
6f6ef287ce4ef068304ee5eb6c385b1ff64c7d20
[]
no_license
nqqw/ft_containers
4c16d32fb209aea2ce39e7ec25d7f6648aed92e8
f043cf52059c7accd0cef7bffcaef0f6cb2c126b
refs/heads/master
2023-06-25T16:08:19.762870
2021-07-23T17:28:09
2021-07-23T17:28:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
21,906
hpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Map.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: dbliss <dbliss@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/05/19 17:14:29 by dbliss #+# #+# */ /* Updated: 2021/05/29 11:10:41 by dbliss ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef MAP_HPP #define MAP_HPP #include "Algorithm.hpp" #include "Identifiers.hpp" #include "MapIterator.hpp" #include <utility> #include <iomanip> #include <math.h> namespace ft { template <class Key, class T, class Compare = less<Key>, class Alloc = std::allocator<std::pair<const Key, T> > > class map { private: struct TreeNode { std::pair<const Key, T> val; TreeNode *left; TreeNode *right; TreeNode *parent; int height; }; public: typedef Key key_type; typedef T mapped_type; typedef std::pair<const key_type, mapped_type> value_type; typedef less<key_type> key_compare; typedef Alloc allocator_type; typedef typename Alloc::reference reference; typedef typename Alloc::const_reference const_reference; typedef typename Alloc::pointer pointer; typedef typename Alloc::const_pointer const_pointer; typedef typename ft::MapIterator<pointer, TreeNode> iterator; typedef typename ft::MapIterator<const pointer, TreeNode> const_iterator; typedef typename ft::myReverseIterator<iterator> reverse_iterator; typedef typename ft::myReverseIterator<const_iterator> const_reverse_iterator; typedef ptrdiff_t difference_type; typedef size_t size_type; typedef typename Alloc::template rebind<TreeNode>::other node_allocator_type; /*================================ 4 CONSTRUCTORS: ================================*/ /* EMPTY */ explicit map(const key_compare &comp = key_compare(), const allocator_type &alloc = allocator_type()) : _node(NULL), _comp(comp), _allocator_type(alloc) { this->_last_node = allocate_tree_node(); } /*RANGE*/ template <class InputIterator> map(InputIterator first, InputIterator last, const key_compare &comp = key_compare(), const allocator_type &alloc = allocator_type()); /*COPY*/ map(const map &x); /*================================ DESTRUCTOR: ================================*/ virtual ~map() {} /*================================ OPERATOR=: ================================*/ map &operator=(const map &x); /*================================ ITERATORS: ================================*/ iterator begin() { return (iterator(min_node(this->_node))); } const_iterator begin() const; iterator end() { return (iterator(this->_last_node)); } const_iterator end() const { return (const_iterator(this->_last_node)); } reverse_iterator rbegin() { return (reverse_iterator(end())); } const_reverse_iterator rbegin() const { return (const_reverse_iterator(end())); } reverse_iterator rend() { return (reverse_iterator(begin())); } const_reverse_iterator rend() const { return (const_reverse_iterator(begin())); } /*================================ CAPACITY: ================================*/ bool empty() const; size_type size() const { if (!_node) return (0); return (tree_size(_node)); } size_type max_size() const { return this->_alloc_node.max_size(); } /*================================ ELEMENT ACCESS: ================================*/ mapped_type &operator[](const key_type &k) { //return (*((this->insert(make_pair(k,mapped_type()))).first)).second); } /*================================ MODIFIERS: ================================*/ /* INSERT */ /* The single element versions (1) return a pair, with its member pair::first set to an iterator pointing to either the newly inserted element or to the element with an equivalent key in the map. The pair::second element in the pair is set to true if a new element was inserted or false if an equivalent key already existed. */ TreeNode *new_node(const value_type &val) { TreeNode *node; node = _alloc_node.allocate(1); _allocator_type.construct(&node->val, val); node->right = NULL; node->left = NULL; node->parent = NULL; node->height = 1; // new node is initially // added at leaf return (node); } // std::pair<iterator, bool> // insert(const value_type &val) // { // TreeNode *current = _node; // x // TreeNode *parent = NULL; // y // TreeNode *tmp = NULL; // node // // unlink end // while (current) //x // { // parent = current; // if (current->val.first == val.first) // return make_pair(iterator(current), false); // if (val.first < current->val.first) // { // current = current->left; // } // else // { // current = current->right; // } // } // tmp = new_node(val); // tmp->parent = parent; // if (parent == nullptr) // { // _node = tmp; // } // else if (tmp->val.first < parent->val.first) // { // parent->left = tmp; // } // else // { // parent->right = tmp; // } // // if (tmp->parent->parent == NULL) // // return make_pair(iterator(tmp), true); // insertFix(tmp, val); // return make_pair(iterator(tmp), true); // // link end (find min, find max, put left to min. right to last node) // } TreeNode *insertFix(TreeNode *node, const value_type &val) { if (node->parent) node->parent->height = 1 + max(height(node->left), height(node->right)); /* 3. Get the balance factor of this ancestor node to check whether this node became unbalanced */ int balance = getBalance(node); // If this node becomes unbalanced, then // there are 4 cases // Left Left Case if (balance > 1 && val.first < node->left->val.first) return rightRotate(node); // Right Right Case if (balance < -1 && val.first > node->right->val.first) return leftRotate(node); // Left Right Case if (balance > 1 && val.first > node->left->val.first) { node->left = leftRotate(node->left); return rightRotate(node); } // Right Left Case if (balance < -1 && val.first < node->right->val.first) { node->right = rightRotate(node->right); return leftRotate(node); } /* return the (unchanged) node pointer */ return node; } void unlink_end() { _last_node->right->right = NULL; } void link_end(TreeNode *node) { TreeNode *max = max_node(_node); _last_node->right->right = max; _last_node->left = min_node(_node); _last_node->right = max; } void configure_last_node(TreeNode *node) { link_end(node); _last_node->right } std::pair<iterator, bool> insert(const value_type &val) { _node = insert_node(_node, val); TreeNode *current = _node; TreeNode *parent = NULL; TreeNode *tmp = NULL; unlink_end(); while (current) { parent = current; if (current->val.first == val.first) return make_pair(iterator(current), false); if (val.first < current->val.first) { current = current->left; } else { current = current->right; } } tmp = new_node(val); tmp->parent = parent; if (parent == nullptr) { _node = tmp; } else if (tmp->val.first < parent->val.first) { parent->left = tmp; } else { parent->right = tmp; } return std::make_pair(iterator(_node), true); } // std::pair<iterator, bool> insert(const value_type &val) // { // iterator iter; // if (!this->_node) // Insert the first node, if root is NULL. // { // this->_node = allocate_tree_node(); // this->_allocator_type.construct(&_node->val, val); // this->_last_node->parent = this->_node; // this->_node->right = this->_last_node; // iter = this->_node; // return make_pair(iter, true); // } // else // { // TreeNode *new_node; // TreeNode *root = _node; // if (val.first <= _node->val.first) // { // while (root->left) // { // root = root->left; // } // new_node = construct_tree_node(val); // root->left = new_node; // new_node->right = NULL; // new_node->left = NULL; // new_node->parent = root; // iter = new_node; // } // else // { // while (root->right != _last_node) // { // root = root->right; // } // if (root->val.first == val.first) // return (make_pair(iterator(root), false)); // new_node = construct_tree_node(val); // root->right = new_node; // new_node->left = NULL; // new_node->right = _last_node; // _last_node->parent = new_node; // new_node->parent = root; // iter = _last_node; // } // return make_pair(iter, true); // } // } // then add balancing function ! iterator insert(iterator position, const value_type &val); template <class InputIterator> void insert(InputIterator first, InputIterator last); /* ERASE */ void erase(iterator position); size_type erase(const key_type &k); void erase(iterator first, iterator last); /* SWAP */ void swap(map &x); /* CLEAR */ void clear(); /*================================ OBSERVERS: ================================*/ key_compare key_comp() const; // value_compare value_comp() const; /*================================ OPERATIONS: ================================*/ iterator find(const key_type &k); const_iterator find(const key_type &k) const; size_type count(const key_type &k) const; iterator lower_bound(const key_type &k); const_iterator lower_bound(const key_type &k) const; iterator upper_bound(const key_type &k); const_iterator upper_bound(const key_type &k) const; std::pair<const_iterator, const_iterator> equal_range(const key_type &k) const; std::pair<iterator, iterator> equal_range(const key_type &k); /*================================ HELPING FUNCTIONS : ================================*/ TreeNode *allocate_tree_node() { TreeNode *node; node = this->_alloc_node.allocate(1); node->right = NULL; node->left = NULL; node->parent = NULL; std::memset(&node->val, 0, sizeof(node->val)); return node; } TreeNode *construct_tree_node(const_reference val) { TreeNode *node; node = allocate_tree_node(); this->_allocator_type.construct(&node->val, val); return (node); } size_type _height(TreeNode *tmp, int i = 1) { int x; int y; if (tmp && tmp != _last_node) { if (tmp->left && tmp->right && tmp->right != _last_node) { x = _height(tmp->left, i + 1); y = _height(tmp->right, i + 1); i = (x > y) ? x : y; } else if (tmp->left) i = _height(tmp->left, i + 1); else if (tmp->right && tmp->right != _last_node) i = _height(tmp->right, i + 1); } else return (0); return (i); } // A utility function to get maximum // of two integers int max(int a, int b) { return (a > b) ? a : b; } int height(TreeNode *N) { if (N == NULL) return 0; return N->height; } /* Helper function that allocates a new node with the given key and NULL left and right pointers. */ TreeNode *newNode(const value_type &val, TreeNode *parent = NULL) { TreeNode *node; node = _alloc_node.allocate(1); _allocator_type.construct(&node->val, val); node->right = NULL; node->left = NULL; node->parent = parent; node->height = 1; // new node is initially // added at leaf return (node); } // A utility function to right // rotate subtree rooted with y // See the diagram given above. TreeNode *rightRotate(TreeNode *y) { TreeNode *x = y->left; TreeNode *T2 = x->right; // Perform rotation x->right = y; y->left = T2; // Update parent pointers x->parent = y->parent; y->parent = x; if (T2) T2->parent = y; // Update heights y->height = max(height(y->left), height(y->right)) + 1; x->height = max(height(x->left), height(x->right)) + 1; // Return new root return x; } // A utility function to left // rotate subtree rooted with x // See the diagram given above. TreeNode *leftRotate(TreeNode *x) { TreeNode *y = x->right; TreeNode *T2 = y->left; // Perform rotation y->left = x; x->right = T2; // Update parent pointers y->parent = x->parent; x->parent = y; if (T2) T2->parent = x; // Update heights x->height = max(height(x->left), height(x->right)) + 1; y->height = max(height(y->left), height(y->right)) + 1; // Return new root return y; } // Get Balance factor of node N int getBalance(TreeNode *N) { if (N == NULL) return 0; return _height(N->left) - _height(N->right); } // Recursive function to insert a key // in the subtree rooted with node and // returns the new root of the subtree. TreeNode *insert_node(TreeNode *node, const value_type &val, TreeNode *parent = NULL) { if (node == NULL) return (newNode(val, parent)); // initially parent is set to NULL /* 1. Perform the normal BST insertion */ if (val.first < node->val.first) { node->left = insert_node(node->left, val, node); // here we instead of NULL parent has the value } else if (val.first > node->val.first) { node->right = insert_node(node->right, val, node); // here we instead of NULL parent has the value } else // Equal keys are not allowed in BST return node; /* 2. Update height of this ancestor node */ node->height = 1 + max(height(node->left), height(node->right)); /* 3. Get the balance factor of this ancestor node to check whether this node became unbalanced */ int balance = getBalance(node); // If this node becomes unbalanced, then // there are 4 cases // Left Left Case if (balance > 1 && val.first < node->left->val.first) return rightRotate(node); // Right Right Case if (balance < -1 && val.first > node->right->val.first) return leftRotate(node); // Left Right Case if (balance > 1 && val.first > node->left->val.first) { node->left = leftRotate(node->left); return rightRotate(node); } // Right Left Case if (balance < -1 && val.first < node->right->val.first) { node->right = rightRotate(node->right); return leftRotate(node); } /* return the (unchanged) node pointer */ return node; } TreeNode *min_node(TreeNode *node) { if (node) { while (node->left) node = node->left; } return (node); } TreeNode *max_node(TreeNode *node) { if (node) { while (node->right) node = node->right; } return (node); } size_type tree_size(TreeNode *node) const { if (node == NULL) return 0; return (tree_size(node->left) + 1 + tree_size(node->right)); } /* ----PRINT TREE---- */ /** These methods are not included in the *** container map. They can be used to *** check the balance of a tree. ** */ void treeprint() { int i = 0; while (i <= _height(_node) - 1) { printlv(i); i++; std::cout << std::endl; } } void printlv(int n) { TreeNode *temp = _node; int val = pow(2, _height(_node) - n + 1); std::cout << std::setw(val) << ""; dispLV(temp, n, val); } void dispLV(TreeNode *p, int lv, int d) { int disp = 2 * d; if (lv == 0) { if (p == NULL) { std::cout << " x "; std::cout << std::setw(disp - 3) << ""; return; } else { // int result = ((p->data.first <= 1) ? 1 : log10(p->data.first) + 1); std::cout << " " << p->val.first << " "; std::cout << std::setw(disp - 3) << ""; } } else { if (p == NULL && lv >= 1) { dispLV(NULL, lv - 1, d); dispLV(NULL, lv - 1, d); } else { dispLV(p->left, lv - 1, d); dispLV(p->right, lv - 1, d); } } } private: TreeNode *_node; TreeNode *_last_node; Compare _comp; allocator_type _allocator_type; node_allocator_type _alloc_node; }; } #endif
[ "asleonova.1@gmail.com" ]
asleonova.1@gmail.com
cc4cb2c60ef2ceed11447dcd689581ad6d0fa281
c25b77ca1d93c8f631db04aac1bc535985e9d3f8
/Moon/Moon/Neuron.cpp
a70b77102ce1a7524ce43587f5c2e3504d738ab9
[]
no_license
juby0601/NN-projects
f39355cb6046bfb3bdb8437418a2a78c281b44f0
86c462468d13e28582ab987d5a3ab956ad6c4d58
refs/heads/master
2020-12-24T19:50:58.043835
2017-04-02T15:30:17
2017-04-02T15:30:17
86,214,465
0
0
null
null
null
null
UTF-8
C++
false
false
1,561
cpp
#include "Config.h" #include "Neuron.h" #include <math.h> #include <iostream> using namespace std; Neuron::Neuron() { } Neuron::~Neuron() { } void Neuron::Init(std::vector<double> &inputVector) { inputs = inputVector; weights.resize(inputVector.size()); product.resize(inputVector.size()); GenerateInitialWeights(); } void Neuron::Init(double input) { vector<double> inputTemp; inputTemp.push_back(input); inputs = inputTemp; weights.resize(1); product.resize(1); GenerateInitialWeights(); } void Neuron::UpdateNeuron(std::vector<double> inputVector){ inputs = inputVector; } void Neuron::UpdateNeuron(double input){ vector<double> inputTemp; inputTemp.push_back(input); inputs = inputTemp; } double Neuron::ComputeOutput() { for (unsigned int i = 0; i < product.size(); i++) { product.at(i) = weights.at(i) * inputs.at(i); } return ActivationFunction(Sum(product)); } double Neuron::ActivationFunction(double input){ //sigmoid double output; output = 1/(1+exp(-input)); return output; } void Neuron::GenerateInitialWeights() { for (unsigned int i = 0; i < weights.size(); i++) { double r = ((double) rand() / (RAND_MAX))*2-1; weights.at(i) = WEIGHT_SCALE * r; } } double Neuron::Sum(std::vector<double> &vector) { double sum = 0; for (unsigned int i = 0; i < vector.size(); i++) { sum += vector.at(i); } return sum; } vector<double> Neuron::getWeights(){ return weights; } void Neuron::setWeights(vector<double> &inputWeights){ for (int i = 1; i<inputWeights.size(); i++){ weights[i] = inputWeights[i]; } }
[ "you@example.com" ]
you@example.com
872607087d4d7ba189c06423ac20319e49532829
f8e7b0dd30e12f3a4b8a0f65e119a15e3a6407ee
/Baekjoon/BJ5622.cpp
3f954d140f7709cd8e94cf765d5059f0be8165a5
[]
no_license
BaeJuneHyuck/BaekJune
def023503c51e7ab574e28994c3d22089b5694f3
c90c7f210f5d0e12b4c0a9dcd3e3280b1d6f318f
refs/heads/master
2020-06-24T15:18:19.782424
2020-01-28T07:59:41
2020-01-28T07:59:41
198,998,731
1
0
null
null
null
null
UHC
C++
false
false
525
cpp
// 백준 5622번 다이얼 // ABC 2, DEF3... PQRS 7 TuV8 WXYZ 9 #include<iostream> #include<string.h> using namespace std; int main() { char input[16]; cin >> input; int sum = 0; for (int i = 0; i < strlen(input); i++) { char a = input[i]; if (a <= 'C') sum += 3; else if (a <= 'F')sum += 4; else if (a <= 'I') sum += 5; else if (a <= 'L') sum += 6; else if (a <= 'O') sum += 7; else if (a <= 'S') sum += 8; else if (a <= 'V') sum += 9; else sum += 10; } cout << sum; system("pause"); return 0; }
[ "37135285+BaeJuneHyuck@users.noreply.github.com" ]
37135285+BaeJuneHyuck@users.noreply.github.com
d2db2ba230e19f304e82112a7b84e997f83a340e
4648b1ce396ac5f0b6b7a7864c45eac1aad8ab5d
/src/Experiments/Scalability/query500/query10K.cpp
b645d38a7b7c3a9a77a4e5e1769fc462d8ae4047
[ "MIT" ]
permissive
Anonymous82338590/AdaptiveDynamicArray
a8c110e6008c095a4ef680dfaf8c3a4db5024d8a
47786167d6b6238da8f717ef8126fd68a6939990
refs/heads/master
2022-12-25T23:40:10.079790
2020-09-30T10:27:04
2020-09-30T10:27:04
276,539,229
0
0
null
null
null
null
UTF-8
C++
false
false
8,679
cpp
#include <iostream> #include <fstream> #include <chrono> #include <random> #include <algorithm> #include "../../../HeaderFiles/CountedBtree.h" #include "../../../HeaderFiles/StandardArray.h" #include "../../../HeaderFiles/AdaptiveDynamicArray.h" #include "../../../HeaderFiles/LinkedList.h" #include "../../../HeaderFiles/tiered-vector.h" using namespace std; using namespace Seq; typedef std::chrono::high_resolution_clock::time_point TimeVar; #define duration(a) std::chrono::duration_cast<std::chrono::nanoseconds>(a).count() #define timeNow() std::chrono::high_resolution_clock::now() bool CompareArray(const int *a, const int *b, int len) { if (a == nullptr || b == nullptr) { cout<<"null pointer error!" << endl; return false ; } for (int i = 0; i < len; ++i) { if (a[i] != b[i]) { return false; } } return true; } // A function to return a seeded random number generator. inline std::mt19937& generator() { // the generator will only be seeded once (per thread) since it's static static thread_local std::mt19937 gen(std::random_device{}()); return gen; } // A function to generate integers in the range [min, max] int RandomInt(int min, int max) { std::uniform_int_distribution<int> dist(min, max); return dist(generator()); } int* RangeDistributionRandom( int num, int min, int max) { int * n = new int[num]; for (int j = 0; j < num; ++j) { n[j] = RandomInt(min, max); } shuffle(n, n + num, generator()); return n; } int main(int argc, char** argv) { string filepath[3] = {"query10K.csv", "query10KLog.txt"}; ofstream finstant, flog, ffinal; finstant.open(filepath[0], ios::out | ios::in | ios::trunc); flog.open(filepath[1], ios::out | ios::in | ios::trunc); finstant<<" ,DA,SA,LL,CBT,TV"<<endl; long long Tsa = 0, Tda = 0, Tll = 0, Tcbt = 0, Ttv = 0; int queryLength = 500, queryNum = 0; int iniNum = 10000; int danodesize = 20; int CbtOrder = 20; int m = 500; //for linked list int operations = 1000000; int InsertActions = operations * 25 / 100; int DeleteActions = operations * 25 / 100; int ReorderActions = operations * 25 / 100; int SwapActions = operations * 25 / 100; int TotalActions = DeleteActions + InsertActions + ReorderActions+SwapActions; printf("%d, %d, %d, %d\n", InsertActions, DeleteActions, ReorderActions, SwapActions); printf("# of operations = %d\n", operations); int CurOutputNum = 0; int *a = new int[TotalActions]; int ua = 0; for (int y = 0; y < ReorderActions; y++) { a[ua] = 4; ua++; } for (int y = 0; y < SwapActions; y++) { a[ua] = 5; ua++; } for (int y = 0; y < InsertActions; y++) { a[ua] = 2; ua++; } for (int y = 0; y < DeleteActions; y++) { a[ua] = 3; ua++; } shuffle(a, a + TotalActions, generator()); //random_shuffle(&a[DeleteActions+InsertActions], &a[TotalActions]); //random_shuffle(&a[0], &a[MoveActions+SwapActions+ReorderActions]); //random_shuffle(&a[0], &a[operations]); //int * shortqueryrange = RangeDistributionRandom(, 1, 100); int * reorderrange = RangeDistributionRandom(ReorderActions, 1, 1000); int ir = 0; TimeVar time1, time2; int NowTotalNum = iniNum; int ToInsert = iniNum + 1; int * array = new int[iniNum]; for (int i = 0; i < iniNum; ++i) { array[i] = i+1; } DynamicArray *da = NewDynamicArray(array, iniNum, danodesize); StandardArray *sa = NewStandardArray(array, iniNum); CountedBtree * cbt = NewCBTreeForArray(CbtOrder, iniNum); LinkedList * ll = NewLinkedListForArray(m, array, iniNum); Seq::Tiered<int, LayerItr<LayerEnd, Layer<22, Layer<22, Layer<22>>>>> tiered; tiered.initialize(array, iniNum); delete []array; int NumSA; cout<<"da depth = "<<da->Depth() << endl; int depth = 1; int numUpdate = 0; for (int lt = 0; lt < TotalActions; lt++) { if (lt % 5000 == 0) { cout<<"lt = "<<lt; cout<<"da depth = "<<da->Depth() << endl; flog<<"lt = "<<lt<<endl; flog<<"da depth = "<<da->Depth() << endl; } if (da->Depth() > depth) { depth++; flog<<"numUpdate = "<<numUpdate<<" da depth = "<<depth<<endl; } switch (a[lt]) { case 2: //insert { int pos = RandomInt(1, NowTotalNum); sa->Insert(ToInsert, pos); da->Insert(ToInsert, pos); cbt->Insert(ToInsert, pos); ll->Insert(ToInsert, pos); tiered.insert(pos, ToInsert); ToInsert++; NowTotalNum++; break; } case 3: //delete { int pos = RandomInt(1, NowTotalNum); sa->Delete(pos); da->Delete(pos); cbt->Delete(pos); ll->Delete(pos); tiered.remove(pos); NowTotalNum--; break; } case 4: //reorder { int len = reorderrange[ir]; ir++; if (len >= NowTotalNum) { len = NowTotalNum-1; } int start = RandomInt(1, NowTotalNum - len); int end = start + len - 1; if (end >= NowTotalNum) { end = NowTotalNum - 1; } int * oldArray = sa->RangeQuery(start, end, &NumSA); int * newArray = new int[len]; for (int j = 0; j < len; ++j) { newArray[j] = oldArray[len-j-1]; } sa->Reorder(start, end, newArray); da->Reorder(start, end, newArray); cbt->Reorder(start, end, newArray); ll->Reorder(start, end, newArray); tiered.Reorder(start, end, newArray); delete []newArray; delete []oldArray; break; } case 5: //swap { int b[4] = {}; for (int & j : b) { j = RandomInt(1, NowTotalNum); } sort(b, b + 4); if (b[1] == b[2]) { continue; } int start1 = b[0]; int end1 = b[1]; int start2 = b[2]; int end2 = b[3]; sa->Swap(start1, end1, start2, end2); da->Swap(start1, end1, start2, end2); cbt->Swap(start1, end1, start2, end2); ll->Swap(start1, end1, start2, end2); tiered.Swap(start1, end1, start2, end2); break; } } if ((lt+1)%100000 == 0) { numUpdate ++; queryNum++; CurOutputNum ++; long long t1=0, t2=0, t3=0, t4=0, t5=0; int start1 = RandomInt(1, NowTotalNum-queryLength-3); int end1 = start1 + queryLength -1; int num, * qans; time1 = timeNow(); qans = da->RangeQuery(start1, end1, &num); time2 = timeNow(); t1 = duration(time2-time1); Tda += t1; time1 = timeNow(); qans = sa->RangeQuery(start1, end1, &num); time2 = timeNow(); t2 = duration(time2-time1); Tsa += t2; time1 = timeNow(); qans = ll->RangeQuery(start1, end1, &num); time2 = timeNow(); t3 = duration(time2 - time1); Tll += t3; time1 = timeNow(); qans = cbt->RangeQuery(start1, end1, &num); time2 = timeNow(); t4 = duration(time2 - time1); Tcbt += t4; time1 = timeNow(); qans = tiered.RangeQuery(start1, end1, num); time2 = timeNow(); t5 = duration(time2 - time1); Ttv += t5; finstant <<t1 << ","<< t2<<","<<t3<<","<<t4<<","<<t5<<endl; cout<<"lt = "<< lt <<" da depth = "<<da->Depth()<<endl; flog<<"lt= "<<lt<<" ll length = "<<ll->NumItem<<endl; } } //for lt <= loopTime finstant <<Tda/queryNum << ","<< Tsa/queryNum<<","<<Tll/queryNum<<","<<Tcbt/queryNum<<","<<Ttv/queryNum<<endl; flog<<"da depth = "<<da->Depth() << endl; delete []reorderrange; delete []a; flog.close(); finstant.close(); return 0; }
[ "anonymous82338590@gmail.com" ]
anonymous82338590@gmail.com
522a62f88d8bb74b9aaf8c4475d6b311f9750c12
caefd84ac575cf192a6a6e2de9b4f3fac41e466c
/trunk/knewcode/kc_web_plugins/kc_web_page_data_idname/one_level/func_lib.cpp
fb5e42807d0a5c1f332e04c119da4bc8a19d07df
[ "Apache-2.0" ]
permissive
zogyzen/knewcode
43ffdf81a10a22d879671b663c59c7739636eaf7
bd414a52330cde040ceaf91d1b380c402b2814b4
refs/heads/master
2020-06-16T21:31:31.158295
2016-11-29T10:36:39
2016-11-29T10:36:39
75,064,119
0
0
null
null
null
null
UTF-8
C++
false
false
1,947
cpp
#include "../std.h" #include "func_lib.h" //////////////////////////////////////////////////////////////////////////////// // TFuncLib类 KC::one_level::TFuncLib::TFuncLib(IIDNameItemWork& wk, IKCActionData& act, string name, const TKcLoadFullFL& load) : TFuncLibItemBase(wk, act, name), m_loadSyn(load) { } // 获取函数定义 TKcFuncDefFL& KC::one_level::TFuncLib::GetFuncDef(string funcName, IFuncCallDyn& dyn) { // 模块名称 string sModName = m_loadSyn.GetVal<0>().GetVal<0>().GetVal<0>().GetVal<0>(); // 获取函数指针 KLoadLibrary<>* pLib = m_loadSyn.GetVal<0>().GetVal<1>().get(); if (nullptr == pLib) throw TIDNameWorkSrvException(m_act.GetCurrLineID(), __FUNCTION__, (boost::format(m_work.getHint("Not_set_dynamic_libraries")) % (sModName + "." + funcName) % m_act.GetCurrLineID()).str(), m_work, sModName + "." + funcName); string sError = pLib->LoadLib(); if (!sError.empty()) throw TIDNameWorkSrvException(m_act.GetCurrLineID(), __FUNCTION__, sError + " [" + sModName + "." + funcName + "], at line " + lexical_cast<string>(m_act.GetCurrLineID()), m_work, sModName + "." + funcName); TFuncPointer funcPtr = pLib->GetLibFunc<TFuncPointer>(funcName.c_str()); if (nullptr == funcPtr) throw TIDNameWorkSrvException(m_act.GetCurrLineID(), __FUNCTION__, (boost::format(m_work.getHint("Can_t_access_functions")) % (sModName + "." + funcName) % m_act.GetCurrLineID()).str(), m_work, sModName + "." + funcName); // 设置函数指针 dyn.SetFunc(funcPtr); // 获取函数定义 std::vector<TKcFuncDefFL>& fdList = *(m_loadSyn.GetVal<1>().ValList.get()); for (auto& fd: fdList) if (fd.GetVal<1>() == funcName) return fd; throw TIDNameWorkSrvException(m_act.GetCurrLineID(), __FUNCTION__, (boost::format(m_work.getHint("Function_is_not_defined")) % (sModName + "." + funcName) % m_act.GetCurrLineID()).str(), m_work, sModName + "." + funcName); }
[ "zogy@163.com" ]
zogy@163.com
65749cce1406398c5e650e323f5e3c88b844d40d
2747910fdf1422832b5b2531837729a26c9f09fa
/Project02/Airport.hpp
2056fce6520f0149f674b4c1153b79ec1f322f76
[]
no_license
jvolden/CS250
6f851c40d674da5eaa9ba6120b3f18dbd34f2636
3d65986153187eb9328f70c209f15c550a14b486
refs/heads/master
2021-08-28T00:35:40.018375
2017-12-10T21:56:03
2017-12-10T21:56:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
625
hpp
#ifndef _AIRPLANE_HPP #define _AIRPLANE_HPP #include <iostream> #include <cstdlib> #include <stack> #include <queue> #include <iomanip> using namespace std; #include "Traveller.hpp" #include "DataStructures/Queue.hpp" //! Airport structure that has a "waiting room" and a Line to prepare for boarding class Airport { public: void LineUp(Traveller* traveller); Traveller* NextInLine(); bool IsEmpty(); int WaitingCount(); void SetMaxCapacity(int size); int GetMaxCapacity(); private: int m_maxCapacity; // Add a Queue of Traveller*'s Queue<Traveller*> m_traveller; }; #endif
[ "volden.jon@gmail.com" ]
volden.jon@gmail.com
2f1f8872adbf099ba6bc8106fad1494e62864620
e5f3053c071ca0a5e321ebcdd26ecb20739bfd57
/BSTLEAF.h
1306805ca8fad2cd97c53fd41d57f187d79cbd80
[]
no_license
Styerstyler8/AVLTree
f160271438ec5506c430098ceceacd9b982e22c8
321076d7736937a24e6eb5833ee0fccb76306893
refs/heads/master
2020-12-19T16:04:44.555356
2020-01-23T11:39:12
2020-01-23T11:39:12
235,784,462
0
0
null
null
null
null
UTF-8
C++
false
false
14,278
h
#ifndef BSTLEAF_H_INCLUDED #define BSTLEAF_H_INCLUDED #include <iostream> //For size_t and other things #include <stdexcept> //For exceptions namespace cop3530{ //BST for inserting at leafs template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> class BSTLEAF{ private: struct node{ key_type key; value_type value; node* left; node* right; }; node* root; size_t get_size(node* curr); //Function to recursively get amount of key-value pairs node* do_insert(node* curr, key_type k, value_type v); //Recursively inserts k-v pair node* do_delete(node* curr, key_type k); //Removes node using recursion to fix tree void deletion(node* curr); //Helps the clear function. Deletes recursively int get_height(node* curr); //Helps height function, recursively calls for height on nodes void recursive_copy(node*& curr); public: BSTLEAF(); BSTLEAF(const BSTLEAF& b); //copy constructor BSTLEAF& operator=(const BSTLEAF& b); //Copy assignment operator BSTLEAF(BSTLEAF&& b); //Move constructor BSTLEAF& operator=(BSTLEAF&& b); //Move-assignment operator ~BSTLEAF(); void insert(key_type k, value_type v); //Adds k-v pair to map void remove(key_type k); //Removes k-v pair from map value_type& lookup(key_type k); //Returns a reference to the value associated with given key bool contains(key_type k); //Returns true if tree contains value associated with key bool is_empty(); //Returns true if tree is empty bool is_full(); //Returns true if no more pairs can be added to map size_t size(); //Returns all key value pairs in map void clear(); //Removes all elements from map int height(); //Returns tree's height int balance(); //Returns tree's balance factor }; //CONSTRUCTORS AND DESTRUCTORS template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> BSTLEAF<key_type, value_type, compare, equals> :: BSTLEAF(){ root = nullptr; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> BSTLEAF<key_type, value_type, compare, equals> :: BSTLEAF(const BSTLEAF& b){ //Deep copy constructor root = nullptr; node* curr = b.root; recursive_copy(curr); } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> BSTLEAF<key_type, value_type, compare, equals>& BSTLEAF<key_type, value_type, compare, equals> :: operator=(const BSTLEAF& b){ //Copy assignment operator //Check that this and given BST arent the same if(this == &b){ return *this; } //Else, clear the tree and add a deep copy of given BST clear(); node* curr = b.root; recursive_copy(curr); return *this; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> BSTLEAF<key_type, value_type, compare, equals> :: BSTLEAF(BSTLEAF&& b){ //Move constructor //Creates a shallow copy and sets root of given BST to nullptr root = b.root; b.root = nullptr; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> BSTLEAF<key_type, value_type, compare, equals>& BSTLEAF<key_type, value_type, compare, equals> :: operator=(BSTLEAF&& b){ //Move assignment operator //Check that this and given BST arent the same if(this == &b){ return *this; } //Free existing BST, copy from given, then set to default given BST clear(); root = b.root; b.root = nullptr; return *this; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> BSTLEAF<key_type, value_type, compare, equals> :: ~BSTLEAF(){ //To destroy BST, clear it and get rid of root deletion(root); } //HELPER FUNCTIONS template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> void BSTLEAF<key_type, value_type, compare, equals> :: recursive_copy(node*& curr){ if(curr){ insert(curr->key, curr->value); } if(curr->left){ recursive_copy(curr->left); } if(curr->right){ recursive_copy(curr->right); } } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> size_t BSTLEAF<key_type, value_type, compare, equals> :: get_size(node* curr){ //Recursively goes through counting number of nodes //Case if node we are on doesn't exist if(!curr){ return 0; } //Case where we reached bottom of tree, count 1 if(!curr->left && !curr->right){ return 1; } //Return left side + right + 1 to account for itself return get_size(curr->left) + get_size(curr->right) + 1; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> int BSTLEAF<key_type, value_type, compare, equals> :: get_height(node* curr){ //Gets max height of left and right size, returns max int left_max = 1; int right_max = 1; //Case we are on node that does not exist if(!curr){ return 0; } //Bottom of tree, add 1 and work our way up if(!curr->left && !curr->right){ return 1; } //Keep adding to specific side and work recursively left_max += get_height(curr->left); right_max += get_height(curr->right); //Return the side with most items if(left_max > right_max){ return left_max; } return right_max; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> void BSTLEAF<key_type, value_type, compare, equals> :: deletion(node* curr){ //Deletion goes to bottom of tree and works its way up, deleting each node on the way and setting children to nullptr if(curr){ deletion(curr->left); deletion(curr->right); delete curr; } } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> typename BSTLEAF<key_type, value_type, compare, equals> :: node* BSTLEAF<key_type, value_type, compare, equals> :: do_delete(node* curr, key_type k){ //Removing, this means we have a match and curr is on node we have to remove if(equals(k, curr->key)){ //Case 1: no children, just delete curr and set to nullptr for parent if(!curr->left && !curr->right){ delete curr; curr = nullptr; } //Case 2: One child. Simply delete and return right child so parent has that child else if(!curr->left){ node* temp = curr; curr = curr->right; delete temp; } //Case 2 but for other child else if(!curr->right){ node* temp = curr; curr = curr->left; delete temp; } //Case 3: 2 children from deletion node else{ //Get the in-order successor node* temp = curr->right; while(temp->left){ temp = temp->left; } //Swap in order successor's values with deletion node's curr->key = temp->key; curr->value = temp->value; //Keep working in order to fix tree curr->right = do_delete(curr->right, temp->key); } } //Key comes before node we are currently on, so go left else if(compare(k, curr->key)){ curr->left = do_delete(curr->left, k); } //Key greater than, go right else{ curr->right = do_delete(curr->right, k); } //Return node to keep track of children return curr; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> typename BSTLEAF<key_type, value_type, compare, equals> :: node* BSTLEAF<key_type, value_type, compare, equals> :: do_insert(node* curr, key_type k, value_type v){ //Since we are inserting at leaf, only insert when curr is nullptr if(!curr){ curr = new node; curr->key = k; curr->value = v; curr->left = nullptr; curr->right = nullptr; return curr; } //Key is less than current node, go left else if(compare(k, curr->key)){ curr->left = do_insert(curr->left, k, v); } //Go right else{ curr->right = do_insert(curr->right, k, v); } //Return child, with no changes made (keep going down) return curr; } //PUBLIC FUNCTIONS template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> void BSTLEAF<key_type, value_type, compare, equals> :: insert(key_type k, value_type v){ //If tree empty, just insert at root, otherwise check if key already used and recursively insert k-v pair if(is_empty()){ root = new node; root->key = k; root->value = v; root->left = nullptr; root->right = nullptr; return; } if(contains(k)){ throw std::runtime_error("Already contain that key"); } do_insert(root, k, v); } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> void BSTLEAF<key_type, value_type, compare, equals> :: remove(key_type k){ //Check if empty to avoid errors, then call recursive function to remove if(is_empty()){ throw std::runtime_error("Cannot remove from an empty map"); } do_delete(root, k); } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> value_type& BSTLEAF<key_type, value_type, compare, equals> :: lookup(key_type k){ //Again check if empty and then go through tree looking for key if(is_empty()){ throw std::runtime_error("Cannot lookup in an empty map"); } node* curr = root; while(curr){ //Key matched node we are on if(equals(k, curr->key)){ return curr->value; } //Key comes before node we are on, go left else if(compare(k, curr->key)){ curr = curr->left; } //Go right else{ curr = curr->right; } } //No key was found, return error throw std::runtime_error("Given key was not in the map to remove"); } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> bool BSTLEAF<key_type, value_type, compare, equals> :: contains(key_type k){ //Same as lookup, just returning bool instead of value if(is_empty()){ return false; } node* curr = root; while(curr){ if(equals(k, curr->key)){ return true; } else if(compare(k, curr->key)){ curr = curr->left; } else{ curr = curr->right; } } return false; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> bool BSTLEAF<key_type, value_type, compare, equals> :: is_empty(){ //BST only empty if root doesnt exist if(!root){ return true; } return false; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> bool BSTLEAF<key_type, value_type, compare, equals> :: is_full(){ //BST never full return false; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> size_t BSTLEAF<key_type, value_type, compare, equals> :: size(){ //Calls on the recursive function for size return get_size(root); } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> void BSTLEAF<key_type, value_type, compare, equals> :: clear(){ //Calls recursive deletion, then sets root to nullptr to indicate empty deletion(root); root = nullptr; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> int BSTLEAF<key_type, value_type, compare, equals> :: height(){ //Calls recursive function height and subtracts 1 to get rid of counting root as 1 return get_height(root) - 1; } template<typename key_type, typename value_type, bool (*compare)(key_type, key_type), bool (*equals)(key_type, key_type)> int BSTLEAF<key_type, value_type, compare, equals> :: balance(){ //If empty or size == 1, then its 0, otherwise left - right if(is_empty() || size() == 1){ return 0; } return get_height(root->left) - get_height(root->right); } } #endif
[ "styerstyler8@gmail.com" ]
styerstyler8@gmail.com
3a533ceaee3f53fd2620c8fa3f2383d14d49e20b
0781025fbcd1188d64d557bda7daf71ee1620596
/Source/Browse.cpp
719d4e95db3610bb0f637656c0c153e20ceaf756
[]
no_license
Sedisan/TimeManagment
ef179ee2286075387060ec6075f63f0572f641ac
fe5ed9cd624778210bbaa7bf80813bb9488ad5da
refs/heads/master
2021-06-26T19:05:29.813249
2018-03-20T18:53:10
2018-03-20T18:53:10
96,586,122
0
0
null
null
null
null
UTF-8
C++
false
false
2,182
cpp
#include "stdafx.h" #include <iostream> #include <fstream> #include <cstdlib> #include <map> #include <thread> #include <chrono> #include "Header/Header.h" #include "Header/Date.h" #include "Header/Browse.h" #define DaysLimit 20 std::string getNameOfBASEWITHALLRECORD(); void BrowseHistory::show() { for (size_t i = 1; i<mapWithFile.size() + 1; i++) { std::cout << i << "."; std::cout << mapWithFile[i] << '\n'; } } void BrowseHistory::actOnFile() { countOfLine = 1; std::ifstream iff(getNameOfBASEWITHALLRECORD()); if (!iff) { std::cout << "Base is empty. Program will exit\n"; exit(-1); } std::string line; while (std::getline(iff, line)) { countOfLine++; } iff.close(); } void BrowseHistory::decision() { this->actOnFile(); std::ifstream iff(getNameOfBASEWITHALLRECORD()); if (!iff)exit(-1); std::string line; int lineInt = 0; auto lambdaToAllFileRecord = [&]() { while (std::getline(iff, line)) { lineInt++; for (int i = 0; i<1; i++) mapWithFile[countOfLine - lineInt] = line; } }; if (countOfLine>DaysLimit) { int decision; std::cout << "The history is higher than: " << DaysLimit << ".Show all day(press 1), or press 0 to show last 7 days\n"; std::cin >> decision; if (decision == 1) lambdaToAllFileRecord(); else { int countHowMany = 0; while (std::getline(iff, line)) { lineInt++; if (countOfLine <= lineInt + 7) for (int i = 0; i<1; i++) { countHowMany++; mapWithFile[countHowMany] = line; } } } } else lambdaToAllFileRecord(); this->show(); int select; std::cout << "Enter number: " << '\n'; std::cin >> select; if (!std::cin)throw "Unrecognized number\n"; if (select>lineInt || select<0)throw "Too long, or to small number"; std::ifstream file(mapWithFile[select]+".txt"); if (!file) { std::cerr << "Not find the file\n"; throw "Not find File"; } std::string allLine=""; if (file.is_open()) { while (file.good()) { std::getline(file, line); allLine += line; allLine += '\n'; } } std::cout << "Your activity in: " << mapWithFile[select] << '\n'; Settings::writeOnTheScreenText(allLine); file.close(); }
[ "szymonryl@gmail.com" ]
szymonryl@gmail.com
9a00e4211ae6605f1bc73d6e74c126fabf0b3d04
fffb732290af97687ea3221ce4a6ce4d95640aff
/courses/w16/source_tx2/VisionWorks-SFM-0.90-Samples/nvxio/src/NVX/FrameSource/OpenCV/OpenCVVideoFrameSource.cpp
a3c2a29ed01a540d0e70e704e3adc1c49516fc53
[]
no_license
NamWoo/self_driving_car
851de73ae909639e03756eea4d49ab663447fc19
cd5c1142c9e543e607ca9dc258f689de6879d207
refs/heads/master
2021-07-24T19:51:54.459485
2021-07-06T13:58:19
2021-07-06T13:58:19
186,267,543
9
7
null
null
null
null
UTF-8
C++
false
false
4,920
cpp
/* # Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of NVIDIA 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 ``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. */ #ifdef USE_OPENCV #include "FrameSource/OpenCV/OpenCVVideoFrameSource.hpp" #include <opencv2/imgproc/imgproc.hpp> namespace nvidiaio { OpenCVVideoFrameSource::OpenCVVideoFrameSource(int _cameraId): OpenCVBaseFrameSource(nvxio::FrameSource::CAMERA_SOURCE, "OpenCVVideoFrameSource"), fileName(), cameraId(_cameraId) { } OpenCVVideoFrameSource::OpenCVVideoFrameSource(const std::string& _fileName, bool sequence): OpenCVBaseFrameSource(sequence ? nvxio::FrameSource::IMAGE_SEQUENCE_SOURCE : nvxio::FrameSource::VIDEO_SOURCE, "OpenCVVideoFrameSource"), fileName(_fileName), cameraId(-1) { } bool OpenCVVideoFrameSource::open() { bool opened = false; if (fileName.empty()) opened = capture.open(cameraId); else opened = capture.open(fileName); if (opened) updateConfiguration(); return opened; } bool OpenCVVideoFrameSource::setConfiguration(const FrameSource::Parameters& params) { NVXIO_ASSERT(!capture.isOpened()); bool result = true; // ignore FPS, width, height values if (params.frameWidth != (uint32_t)-1) result = false; if (params.frameHeight != (uint32_t)-1) result = false; if (params.fps != (uint32_t)-1) result = false; NVXIO_ASSERT((params.format == NVXCU_DF_IMAGE_NV12) || (params.format == NVXCU_DF_IMAGE_U8) || (params.format == NVXCU_DF_IMAGE_RGB) || (params.format == NVXCU_DF_IMAGE_RGBX)|| (params.format == NVXCU_DF_IMAGE_NONE)); configuration.format = params.format; return result; } void OpenCVVideoFrameSource::updateConfiguration() { configuration.fps = static_cast<uint32_t>(capture.get(CV_CAP_PROP_FPS)); configuration.frameWidth = static_cast<uint32_t>(capture.get(CV_CAP_PROP_FRAME_WIDTH)); configuration.frameHeight = static_cast<uint32_t>(capture.get(CV_CAP_PROP_FRAME_HEIGHT)); int type = capture.get(CV_CAP_PROP_FORMAT), depth = CV_MAT_DEPTH(type); NVXIO_ASSERT(depth == CV_8U); // the code below gives cn == 1 even for RGB/RGBX frames // looks like it's OpenCV issue. /* int cn = CV_MAT_CN(type); configuration.format = cn == 1 ? NVXCU_DF_IMAGE_U8 : cn == 3 ? NVXCU_DF_IMAGE_RGB : cn == 4 ? NVXCU_DF_IMAGE_RGBX : NVXCU_DF_IMAGE_NONE; */ // so, let's use RGBX as a default format configuration.format = NVXCU_DF_IMAGE_RGBX; } FrameSource::Parameters OpenCVVideoFrameSource::getConfiguration() { return configuration; } cv::Mat OpenCVVideoFrameSource::fetch() { cv::Mat imageconv; if (!capture.retrieve(image)) { close(); return imageconv; } // swap channels int cn = image.channels(); if (cn == 3) cv::cvtColor(image, imageconv, CV_BGR2RGB); else if (cn == 4) cv::cvtColor(image, imageconv, CV_BGRA2RGBA); else image.copyTo(imageconv); return imageconv; } bool OpenCVVideoFrameSource::grab() { return capture.grab(); } void OpenCVVideoFrameSource::close() { capture.release(); } OpenCVVideoFrameSource::~OpenCVVideoFrameSource() { close(); } } #endif
[ "pre3ice@gmail.com" ]
pre3ice@gmail.com
fdf6262c042bd8677e4b78d19704624ef9104e91
37aabc655cd6e17c148bbac7e8e8112c91375ff3
/src/zmq/zmqabstractnotifier.h
77c85f3b24226753597d683b77ca0513662d3420
[ "MIT" ]
permissive
Chellit/Chellit
84ac02c08ab286ffbab3582b4ef2cce0addec1cf
7d804cfc64b4e91234b68f14b82f12c752eb6aae
refs/heads/master
2023-02-12T01:49:33.344076
2021-01-12T23:10:20
2021-01-12T23:10:20
283,389,696
2
1
null
null
null
null
UTF-8
C++
false
false
1,289
h
// Copyright (c) 2015 The Bitcoin Core developers // Copyright (c) 2017-2019 The Raven Core developers // Copyright (c) 2020 The Chellit Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef CHELLIT_ZMQ_ZMQABSTRACTNOTIFIER_H #define CHELLIT_ZMQ_ZMQABSTRACTNOTIFIER_H #include "zmqconfig.h" class CBlockIndex; class CZMQAbstractNotifier; typedef CZMQAbstractNotifier* (*CZMQNotifierFactory)(); class CZMQAbstractNotifier { public: CZMQAbstractNotifier() : psocket(nullptr) { } virtual ~CZMQAbstractNotifier(); template <typename T> static CZMQAbstractNotifier* Create() { return new T(); } std::string GetType() const { return type; } void SetType(const std::string &t) { type = t; } std::string GetAddress() const { return address; } void SetAddress(const std::string &a) { address = a; } virtual bool Initialize(void *pcontext) = 0; virtual void Shutdown() = 0; virtual bool NotifyBlock(const CBlockIndex *pindex); virtual bool NotifyTransaction(const CTransaction &transaction); protected: void *psocket; std::string type; std::string address; }; #endif // CHELLIT_ZMQ_ZMQABSTRACTNOTIFIER_H
[ "chellitcoin@gmail.com" ]
chellitcoin@gmail.com
0cf44d2f89118b8fbb803d3a97dd50fdc5ce92aa
13508677af95d0940a6774e60002c5bcfba7ae9f
/10858 - Unique Factorization.cpp
0130f477b3aa9693c4abb7494fb46d1c1a030f9c
[]
no_license
kuonanhong/UVa-2
f40686287e1aa717b6da4af81d0eafa07b0afd17
f58813d6a926f1ae4f61644d51dc1fe28b923cbd
refs/heads/master
2021-04-30T15:22:20.138385
2016-06-13T06:26:44
2016-06-13T06:26:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,328
cpp
/** UVa 10858 - Unique Factorization by Rico Tiongson Submitted: July 5, 2013 Accepted 0.029s C++ O(m sqrt n) time */ #include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<algorithm> using namespace std; int n, lim, sz, temp[35]; vector<int> factors; vector<vector<int> > out; void factorize(){ factors.clear(); lim = sqrt(n)+1; sz = 0; for( int i=2; i<lim; ++i ){ if( n%i==0 ){ factors.push_back( i ); temp[sz] = n/i; ++sz; } } if( !sz ) return; if( factors.back()==temp[sz-1] ) --sz; while( sz ){ factors.push_back( temp[--sz] ); } } void addfactors( int x ){ if( x==1 ){ if( sz>1 ) out.push_back( vector<int>(temp,temp+sz) ); return; } for( int i=(sz ? (int)(lower_bound(factors.begin(),factors.end(),temp[sz-1])-factors.begin()) : 0 ); i<factors.size(); ++i ){ if( x%factors[i]==0 ){ temp[sz] = factors[i]; ++sz; addfactors( x/factors[i] ); --sz; } } } int main(){ int i, j; scanf("%d",&n); while( n ){ factorize(); // print(); out.clear(); addfactors( n ); cout << out.size() << endl; for( i=0; i<out.size(); ++i ){ printf("%d", out[i][0]); for( j=1; j<out[i].size(); ++j ){ printf(" %d", out[i][j]); } putchar('\n'); } scanf("%d",&n); } }
[ "thericotiongson@gmail.com" ]
thericotiongson@gmail.com
c260f86cc4a51b88fb5c50b6360e2e087127e3ff
85e9720615bdab031242c9108bfcc1f85c949d92
/esp32/L07-ADC/ADC_Test/ADC_Test.ino
6365655bea262362a44ad53a8dcdc44a1189eedb
[]
no_license
zmaker/video
795f215e2eb2c51e524b9446f5d415bb382eb0c2
51253c6896f77908bc00f198235840e50910984c
refs/heads/master
2023-06-07T13:41:50.948217
2023-06-06T07:13:32
2023-06-06T07:13:32
230,980,996
10
3
null
null
null
null
UTF-8
C++
false
false
175
ino
void setup() { Serial.begin(115200); delay(3000); analogReadResolution(12); //da 9 a 12 } void loop() { int v = analogRead(34); Serial.println(v); delay(500); }
[ "zeppelinmaker@gmail.com" ]
zeppelinmaker@gmail.com
ab0d0f73e25f3d5ee61310eaeab8600b66fefa0b
a0f5ed95c261ad5baef324bfaa990072987ea26e
/frames.h
d61c65dbf8c2ebdfb4317a709e06701faa8b397f
[]
no_license
andudu/Activity_Recongnition_Fisrt_Person
1f92b36435af41ab96730b7824e0506e1e5741b9
20b14d614efb32620cb65936096be5e0efd111aa
refs/heads/master
2021-01-15T16:52:39.626794
2014-07-12T06:12:35
2014-07-12T06:12:35
61,765,262
1
0
null
2016-06-23T02:03:32
2016-06-23T02:03:31
null
UTF-8
C++
false
false
1,364
h
// // frames.h // FP_ADL_Detector // // Created by Yahoo on 11/10/12. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #ifndef FP_ADL_Detector_frames_h #define FP_ADL_Detector_frames_h #include <stdlib.h> #include <iostream> #include <vector> #include <cv.h> #include <highgui.h> #include <cxcore.h> #include <fstream> #include <map> #include <math.h> #include <boost/algorithm/string.hpp> #define NUM_FEATURE_TOTAL 89 using namespace std; using namespace cv; using namespace boost; class frameNode{ public: vector<float> feature; vector< vector<Rect> > result_list; }; class FrameModel{ public: //variable string name; vector<frameNode> frameList; int FPN; int frame_start; int frame_count; int num_frames; int num_features; vector<string> feature_name;//This is for use in showing detection result //constructor FrameModel(bool ground_truth_detect, int FPN); ~FrameModel(); //public functions int getFPN(); bool loadVideo_realtime(map<string, string> args); bool playVideo(); bool showFeature(int index); bool playImage_with_detected_results(bool pause_when_detected, IplImage *tempFrame, string activity, string prob); bool print_info(string info_id); private: string video_path; bool ground_truth_detect; }; #endif
[ "shane7226107@gmail.com" ]
shane7226107@gmail.com
21f7b9e043ea7e9b1fb4dfbf5aa59712a672ea4f
f89e32cc183d64db5fc4eb17c47644a15c99e104
/pcsx2-rr/pcsx2/x86/microVU_Clamp.inl
6d6675fbe1285b8dc8d28abcdf8595eaaf0579c6
[]
no_license
mauzus/progenitor
f99b882a48eb47a1cdbfacd2f38505e4c87480b4
7b4f30eb1f022b08e6da7eaafa5d2e77634d7bae
refs/heads/master
2021-01-10T07:24:00.383776
2011-04-28T11:03:43
2011-04-28T11:03:43
45,171,114
0
0
null
null
null
null
UTF-8
C++
false
false
4,482
inl
/* PCSX2 - PS2 Emulator for PCs * Copyright (C) 2002-2010 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. * * PCSX2 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 PCSX2. * If not, see <http://www.gnu.org/licenses/>. */ #pragma once //------------------------------------------------------------------ // Micro VU - Clamp Functions //------------------------------------------------------------------ const __aligned16 u32 sse4_minvals[2][4] = { { 0xff7fffff, 0xffffffff, 0xffffffff, 0xffffffff }, //1000 { 0xff7fffff, 0xff7fffff, 0xff7fffff, 0xff7fffff }, //1111 }; const __aligned16 u32 sse4_maxvals[2][4] = { { 0x7f7fffff, 0x7fffffff, 0x7fffffff, 0x7fffffff }, //1000 { 0x7f7fffff, 0x7f7fffff, 0x7f7fffff, 0x7f7fffff }, //1111 }; // Used for Result Clamping // Note: This function will not preserve NaN values' sign. // The theory behind this is that when we compute a result, and we've // gotten a NaN value, then something went wrong; and the NaN's sign // is not to be trusted. Games like positive values better usually, // and its faster... so just always make NaNs into positive infinity. void mVUclamp1(const xmm& reg, const xmm& regT1, int xyzw, bool bClampE = 0) { if ((!clampE && CHECK_VU_OVERFLOW) || (clampE && bClampE)) { switch (xyzw) { case 1: case 2: case 4: case 8: xMIN.SS(reg, ptr32[mVUglob.maxvals]); xMAX.SS(reg, ptr32[mVUglob.minvals]); break; default: xMIN.PS(reg, ptr32[mVUglob.maxvals]); xMAX.PS(reg, ptr32[mVUglob.minvals]); break; } } } // Used for Operand Clamping // Note 1: If 'preserve sign' mode is on, it will preserve the sign of NaN values. // Note 2: Using regalloc here seems to contaminate some regs in certain games. // Must be some specific case I've overlooked (or I used regalloc improperly on an opcode) // so we just use a temporary mem location for our backup for now... (non-sse4 version only) void mVUclamp2(microVU* mVU, const xmm& reg, const xmm& regT1in, int xyzw, bool bClampE = 0) { if ((!clampE && CHECK_VU_SIGN_OVERFLOW) || (clampE && bClampE && CHECK_VU_SIGN_OVERFLOW)) { if (x86caps.hasStreamingSIMD4Extensions) { int i = (xyzw==1||xyzw==2||xyzw==4||xyzw==8) ? 0: 1; xPMIN.SD(reg, ptr128[&sse4_maxvals[i][0]]); xPMIN.UD(reg, ptr128[&sse4_minvals[i][0]]); return; } //const xmm& regT1 = regT1b ? mVU->regAlloc->allocReg() : regT1in; const xmm& regT1 = regT1in.IsEmpty() ? xmm((reg.Id + 1) % 8) : regT1in; if (regT1 != regT1in) xMOVAPS(ptr128[mVU->xmmCTemp], regT1); switch (xyzw) { case 1: case 2: case 4: case 8: xMOVAPS(regT1, reg); xAND.PS(regT1, ptr128[mVUglob.signbit]); xMIN.SS(reg, ptr128[mVUglob.maxvals]); xMAX.SS(reg, ptr128[mVUglob.minvals]); xOR.PS (reg, regT1); break; default: xMOVAPS(regT1, reg); xAND.PS(regT1, ptr128[mVUglob.signbit]); xMIN.PS(reg, ptr128[mVUglob.maxvals]); xMAX.PS(reg, ptr128[mVUglob.minvals]); xOR.PS (reg, regT1); break; } //if (regT1 != regT1in) mVU->regAlloc->clearNeeded(regT1); if (regT1 != regT1in) xMOVAPS(regT1, ptr128[mVU->xmmCTemp]); } else mVUclamp1(reg, regT1in, xyzw, bClampE); } // Used for operand clamping on every SSE instruction (add/sub/mul/div) void mVUclamp3(microVU* mVU, const xmm& reg, const xmm& regT1, int xyzw) { if (clampE) mVUclamp2(mVU, reg, regT1, xyzw, 1); } // Used for result clamping on every SSE instruction (add/sub/mul/div) // Note: Disabled in "preserve sign" mode because in certain cases it // makes too much code-gen, and you get jump8-overflows in certain // emulated opcodes (causing crashes). Since we're clamping the operands // with mVUclamp3, we should almost never be getting a NaN result, // but this clamp is just a precaution just-in-case. void mVUclamp4(const xmm& reg, const xmm& regT1, int xyzw) { if (clampE && !CHECK_VU_SIGN_OVERFLOW) mVUclamp1(reg, regT1, xyzw, 1); }
[ "koeiprogenitor@bfa1b011-20a7-a6e3-c617-88e5d26e11c5" ]
koeiprogenitor@bfa1b011-20a7-a6e3-c617-88e5d26e11c5
5f6acc7a69346d3c30ab731b99742a5581d9f132
0bb63178342cf99764d1184f3af772d79190f399
/interface/templates/test.tpp
8821521ce26283e1f24ba4ee7bf5431a8cd95eac
[]
no_license
vveckaln/TauAnalysis
7c669d6cc079eda0571c60499fb0d7b3e87ecf29
dc1c3563737d3f0343efed9aeda60d0333c779d2
refs/heads/master
2020-04-06T05:32:15.655099
2015-05-26T14:46:23
2015-05-26T14:46:23
26,512,828
0
0
null
null
null
null
UTF-8
C++
false
false
432
tpp
#include "LIP/TauAnalysis/interface/ObjectPool.hh" using namespace cpHistogramPoolRegister; template<class Object> void ObjectPool<Object>::Draw(Option_t * draw_option){ for (typename map<TString, Object*>::iterator it = object_map.begin(); it != object_map.end(); ++it){ TCanvas_pool -> at(it -> first) -> cd(TCanvas_pool -> cd_pad); it -> second -> Draw(draw_option); gPad -> Modified(); gPad -> Update(); } }
[ "viesturs.veckalns@cern.ch" ]
viesturs.veckalns@cern.ch
0678b33ed5d07d6ed57edd6eeb5de52e46b07029
338074d69c95f8108bfc6e096130ea3d9ee63a1b
/sources/MSHGEOTOOLS/ExtractMeshNodes.h
b7e24314eabdc199ee1b84099d5dc31e4e330729
[ "BSD-2-Clause" ]
permissive
drjod/ogs_kb1
6ac54acaad903353235752cc3d96b527e6b81d36
659060ce0e8955761444af0a68a5219b5c281f2f
refs/heads/master
2023-04-15T03:58:08.946299
2022-05-24T10:03:11
2022-05-24T10:03:11
38,899,008
3
3
NOASSERTION
2022-05-31T10:00:22
2015-07-10T19:46:06
C++
UTF-8
C++
false
false
6,436
h
/* * ExtractMeshNodes.h * * Created on: Dec 3, 2010 * Author: TF */ #ifndef EXTRACTMESHNODES_H_ #define EXTRACTMESHNODES_H_ #include <iostream> // MSH #include "msh_lib.h" #include "msh_mesh.h" // GEO #include "GEOObjects.h" #include "PointWithID.h" #include "Polygon.h" namespace MeshLib { /** * This class implements an algorithm to extract mesh node ids from a given *extruded* mesh. */ class ExtractMeshNodes { public: /** * constructor - takes a *extruded* mesh * @param msh an instance of class CFEMesh */ ExtractMeshNodes(const CFEMesh* msh); /** * This method first projects a mesh node into the x-y-plane (z=0). * Then it checks if this mesh node is within the given polygon * (polygon have to be located in the x-y-plane (z=0). * The IDs of all (projected) mesh nodes within the polygon will * be written to the stream os. For visual control the mesh nodes * will be written (as gli points) to the stream gli_out. * @param os output stream for IDs * @param gli_out output stream for points * @param polygon the polygon that have to be located in the x-y-plane (z=0) */ void writeMeshNodeIDs (std::ostream& os, std::ostream& gli_out, const GEOLIB::Polygon& polygon); /** * This method first projects all mesh nodes into the x-y-plane (z=0). * Then it checks if mesh nodes are within the given polygon * (polygon have to be located in the x-y-plane (z=0). All the mesh * nodes are located within a "cylinder". The method sorts the mesh nodes * lexicographical (first by x, then by y and in the end by z). The id of the * mesh node with largest z coordinate and identical x and y coordinates * will be written to the stream os. For visual control the associated mesh * node will be written to the stream gli_out (as gli point). * @param os output stream for IDs * @param gli_out output stream for points * @param polygon the polygon that have to be located in the x-y-plane (z=0) */ void writeTopSurfaceMeshNodeIDs (std::ostream& os, std::ostream& gli_out, const GEOLIB::Polygon& polygon); void writeMesh2DNodeIDAndArea (std::ostream& os, std::ostream& gli_out, const GEOLIB::Polygon& polygon); /** * Method computes the ids of mesh nodes that are inside the bounding polygon * and not inside a "hole". It writes these ids to the output stream. * @param os out put stream * @param gli_out mesh nodes as point for visualization purposes * @param bounding_polygon the bounding polygon (all mesh nodes inside this polygon are candidates) * @param holes mesh nodes insides these polygons are excluded from the output */ void writeMesh2DNodeIDAndArea (std::ostream& os, std::ostream& gli_out, const GEOLIB::Polygon& bounding_polygon, std::vector<GEOLIB::Polygon*> const& holes); void writeNearestMeshNodeToPoint (std::ostream& os, std::ostream& gli_out, GEOLIB::Point const & pnt); /** * computes the mesh nodes along a polyline belonging to the bottom surface * @param ply computation along the polyline ply * @param bottom_points the bottom mesh nodes as points */ void getBottomMeshNodesAlongPolylineAsPoints(const GEOLIB::Polyline& ply, std::vector<GEOLIB::Point*>& bottom_points) const; /** * computes the mesh nodes along a polyline belonging to the top surface * @param polyline computation along the polyline ply * @param top_points the top mesh nodes as points */ void getTopMeshNodesAlongPolylineAsPoints( const GEOLIB::Polyline& polyline, std::vector<GEOLIB::Point*>& top_points) const; /** * Method computes the polygon to a given polyline that is consisting of the projection * of this polyline to the bottom and the top surface of the mesh and the links between * these two polylines. * @param polyline the ("defining") polyline * @param geo_obj geometric objects manager * @param name the name of the group of geometric objects * @param polygon pointer to the resulting polygon * warning: the pointer to an already existing polygon will be destroyed */ void getPolygonFromPolyline(const GEOLIB::Polyline& polyline, GEOLIB::GEOObjects* geo_obj, std::string const& name, GEOLIB::Polygon* &polygon) const; /** * get a polyline that is projected to the appropriate "layer" into the mesh * @param ply_in polyline that can have arbitrary z coordinates * @param geo_obj pointer to a GEOLIB::GEOObjects object (used for returning the data) * @param name the name of the new data * @param ply_out polyline with points that have the same x- and y-coordinates, * the z-coordinate is set from the layer * @param layer "layer" of the mesh */ void getProjectedPolylineFromPolyline(GEOLIB::Polyline const& ply_in, GEOLIB::GEOObjects* geo_obj, std::string const& name, GEOLIB::Polyline* &ply_out, size_t layer = 0) const; /** * Method searchs the mesh nodes within a given volume described by a * polygon, i.e. a part of the mesh volume. The method does not take the * \f$z\f$ coordinates for both the polygon and the mesh nodes into * account. * @param polygon [input] the polygon that is the boundary * @param node_ids [output] the ids of the mesh nodes which \f$x\f$ and \f$y\f$ * coordinates are inside the boundary polygon */ void getMeshNodeIDsWithinPolygon(GEOLIB::Polygon const& polygon, std::vector<size_t> & node_ids) const; private: /** * This method searchs all mesh nodes with the same x and y coordinates * like the polyline points. It returns the mesh nodes as points and the ids * within objects of type PointWithID. The mesh nodes / points are * sorted lexicographically. * @param polyline the "defining" polyline * @param nodes_as_points vector of GEOLIB::Point objects */ void getOrthogonalProjectedMeshNodesAlongPolyline ( GEOLIB::Polyline const& polyline, std::vector<GEOLIB::PointWithID>& nodes_as_points) const; const CFEMesh* _msh; /** * offset for gli point index */ size_t _gli_pnt_offset; }; } #endif /* EXTRACTMESHNODES_H_ */
[ "jod@gpi.uni-kiel.de" ]
jod@gpi.uni-kiel.de
8a618c30ebd4a01a1b85ce346506840415fa4ea1
eb87d0b2a87220e19bc771f9f29b6fd2125bcdb9
/widgets/work/task/sizewidget.cpp
303bd3cf44cd3f81d986de1c134a595f0a654e8a
[]
no_license
shul20/proprint
dc472ec13fc5eba3be408ae9111c6db42eae9269
21323a293fadb5c45a0cb79d82800e77b6a2af28
refs/heads/master
2021-01-17T17:48:09.792853
2016-06-12T08:30:55
2016-06-12T08:30:55
60,956,366
0
0
null
null
null
null
UTF-8
C++
false
false
1,788
cpp
#include "sizewidget.h" #include "ui_sizewidget.h" #include "entity/order/work.h" SizeWidget::SizeWidget(QWidget *parent) : QWidget(parent), ui(new Ui::SizeWidget), width(0), height(0), amount(0), workSize(0) { ui->setupUi(this); } SizeWidget::~SizeWidget() { delete ui; } void SizeWidget::on_width_valueChanged(int arg1) { width = arg1; calculateSize(); } void SizeWidget::on_height_valueChanged(int arg1) { height = arg1; calculateSize(); } void SizeWidget::on_amount_valueChanged(int arg1) { amount = arg1; calculateSize(); } void SizeWidget::calculateSize() { if (width < height) { workSize = Size(width * amount, height); } else { workSize = Size(width, height * amount); } ui->size->setText(workSize.toString()); emit sizeChanged(); } void SizeWidget::clear(){ ui->width->setValue(0); ui->height->setValue(0); ui->amount->setValue(0); } void SizeWidget::entity2Form(Entity *entity) { ui->width->setValue(entity->fields["work_width"].toInt()); ui->height->setValue(entity->fields["work_height"].toInt()); ui->amount->setValue(entity->fields["work_amount"].toInt()); } bool SizeWidget::form2Entity(Entity *entity) { int size = workSize.value; if (size == 0) { return false; } entity->fields["work_width"] = ui->width->value(); entity->fields["work_height"] = ui->height->value(); entity->fields["work_amount"] = ui->amount->value(); entity->fields["work_size"] = size; return true; } int SizeWidget::getAmount() { return ui->amount->value(); } int SizeWidget::getWidth() { return ui->width->value(); } int SizeWidget::getHeight() { return ui->height->value(); } Size &SizeWidget::getSize() { return workSize; }
[ "shul20@ukr.net" ]
shul20@ukr.net
46ac7cafad0a295c5569d8050f58bd2c4a1d769d
51c1c5e9b8489ef8afa029b162aaf4c8f8bda7fc
/easybuilder/src/easybuilder/frame/SettingOutputDlg.cpp
bc4b7ebc0cf520aee3937e8decdaa573f2322acd
[ "MIT" ]
permissive
aimoonchen/easyeditor
3e5c77f0173a40a802fd73d7b741c064095d83e6
9dabdbfb8ad7b00c992d997d6662752130d5a02d
refs/heads/master
2021-04-26T23:06:27.016240
2018-02-12T02:28:50
2018-02-12T02:28:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,011
cpp
#include "SettingOutputDlg.h" using namespace ebuilder; SettingOutputDlg::SettingOutputDlg(wxWindow* parent) : wxDialog(parent, wxID_ANY, wxT("output")) { wxSizer* sizer = new wxBoxSizer(wxVERTICAL); { wxArrayString choices; choices.Add(wxT("love2d")); choices.Add(wxT("libgdx")); choices.Add(wxT("cocos2d-x")); choices.Add(wxT("easy2d")); // choices.Add(wxT("unity")); m_typeChoice = new wxRadioBox(this, wxID_ANY, wxT("type"), wxDefaultPosition, wxDefaultSize, choices, 1, wxRA_SPECIFY_COLS); m_typeChoice->SetSelection(Settings::code); sizer->Add(m_typeChoice, 0, wxCENTRE | wxALL, 20); } { wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL); btnSizer->Add(new wxButton(this, wxID_OK), 0, wxRIGHT, 5); btnSizer->Add(new wxButton(this, wxID_CANCEL), 0, wxLEFT, 5); sizer->Add(btnSizer, 0, wxCENTRE | wxALL, 10); } sizer->Fit(this); SetSizer(sizer); } Settings::CodeType SettingOutputDlg::getType() const { return Settings::CodeType(m_typeChoice->GetSelection()); }
[ "zhuguang@ejoy.com" ]
zhuguang@ejoy.com
ae7a6bc1fb8a412b0a4446ec47e579687fe951ba
0f7a4119185aff6f48907e8a5b2666d91a47c56b
/sstd_utility/windows_boost/boost/compute/exception.hpp
6dd4541277e81d68ba868cbd1acf3c66fe917aa6
[]
no_license
jixhua/QQmlQuickBook
6636c77e9553a86f09cd59a2e89a83eaa9f153b6
782799ec3426291be0b0a2e37dc3e209006f0415
refs/heads/master
2021-09-28T13:02:48.880908
2018-11-17T10:43:47
2018-11-17T10:43:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
861
hpp
//---------------------------------------------------------------------------// // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com> // // 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 // // See http://boostorg.github.com/compute for more information. //---------------------------------------------------------------------------// #ifndef BOOST_COMPUTE_EXCEPTION_HPP #define BOOST_COMPUTE_EXCEPTION_HPP /// \file /// /// Meta-header to include all Boost.Compute exception headers. #include <boost/compute/exception/context_error.hpp> #include <boost/compute/exception/no_device_found.hpp> #include <boost/compute/exception/opencl_error.hpp> #include <boost/compute/exception/unsupported_extension_error.hpp> #endif // BOOST_COMPUTE_EXCEPTION_HPP
[ "nanguazhude@vip.qq.com" ]
nanguazhude@vip.qq.com
446ddd47cb61332c3246b6bdaed84b92568fcf96
217344a59ed800b31bbd447dd5857cad3faca2d4
/AtCoder/Code-Festival-2016/R1/A.cc
06af32e5743f2f052214121fead5b3c78494d672
[]
no_license
yl3i/Retired
99fb62a0835589e6523df19525f93283a7e9c89f
472a96ccc2ef3c5bd0c2df7ddbe37604030723c4
refs/heads/master
2021-05-22T01:58:55.381070
2018-05-21T09:30:39
2018-05-21T09:30:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
478
cc
/************************************************************************* > File: A.cc > Author: lyyllyyl > Mail: riho.yoshioka@yandex.com > Created Time: Sat 24 Sep 2016 08:02:17 PM CST *************************************************************************/ #include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(0); std::string s; std::cin >> s; std::cout << s.substr(0, 4) + " " + s.substr(4) << std::endl; return 0; }
[ "yuzhou627@gmail.com" ]
yuzhou627@gmail.com
ce256d067df1d09bed5467bf3c42a4c8923c98bc
62fca7aa07094bea44aea3f781576f3448590e8c
/The First Person/Temp/StagingArea/Data/il2cppOutput/Bulk_Mono.Security_1.cpp
7ac4cdd30f1512b8c9b8c10b9006e136b7df4dda
[]
no_license
RandomProduct/FirstPerson
ebd721ee93326413d110e2a787ff159690cb1157
5e07fcbf028bae55f3b4fc7635f20f5bb0088105
refs/heads/master
2021-01-10T16:12:46.329009
2016-03-01T05:49:03
2016-03-01T05:49:03
52,850,978
0
0
null
null
null
null
UTF-8
C++
false
false
60,019
cpp
#include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <cstring> #include <string.h> #include <stdio.h> #include <cmath> #include <limits> #include <assert.h> struct t885; struct t832; struct t740; struct t800; struct t798; struct t35; struct t886; struct t887; struct t888; struct t889; struct t890; struct t891; struct t17; struct t767; struct t353; struct t354; struct t867; struct t875; struct t553; struct t868; struct t865; struct t853; struct t874; struct t854; struct t892; #include "class-internals.h" #include "codegen/il2cpp-codegen.h" #include "t144.h" #include "t885.h" #include "t885MD.h" #include "t145.h" #include "t832.h" #include "mscorlib_ArrayTypes.h" #include "t498.h" #include "t859MD.h" #include "t859.h" #include "t845.h" #include "t832MD.h" #include "t847MD.h" #include "t847.h" #include "t798.h" #include "t798MD.h" #include "t850MD.h" #include "t800MD.h" #include "t153.h" #include "t800.h" #include "t850.h" #include "t148.h" #include "t849MD.h" #include "t829MD.h" #include "t802MD.h" #include "t818MD.h" #include "t815MD.h" #include "t820MD.h" #include "t836.h" #include "t817.h" #include "t818.h" #include "t815.h" #include "t809.h" #include "t820.h" #include "t831.h" #include "t849.h" #include "t829.h" #include "t802.h" #include "t35.h" #include "t774.h" #include "t774MD.h" #include "t17.h" #include "t819.h" #include "t836MD.h" #include "t865MD.h" #include "t35MD.h" #include "t876MD.h" #include "t875MD.h" #include "t805MD.h" #include "t164MD.h" #include "t826.h" #include "t865.h" #include "t935.h" #include "t875.h" #include "t805.h" #include "t806.h" #include "t171.h" #include "t837.h" #include "t837MD.h" #include "t876.h" #include "t164.h" #include "t165.h" #include "t848MD.h" #include "t821MD.h" #include "t821.h" #include "t848.h" #include "t724MD.h" #include "t967MD.h" #include "t968MD.h" #include "t969MD.h" #include "t724.h" #include "t965.h" #include "t965MD.h" #include "t966.h" #include "t967.h" #include "t966MD.h" #include "t968.h" #include "t969.h" #include "t717MD.h" #include "t352.h" #include "t717.h" #include "t886.h" #include "t886MD.h" #include "Mono.Security_ArrayTypes.h" #include "t879.h" #include "t773MD.h" #include "t914MD.h" #include "t773.h" #include "t916.h" #include "t914.h" #include "t887.h" #include "t887MD.h" #include "t761MD.h" #include "t902.h" #include "t902MD.h" #include "t901.h" #include "t762.h" #include "t846.h" #include "t870MD.h" #include "t785.h" #include "t870.h" #include "t785MD.h" #include "t824MD.h" #include "t824.h" #include "t888.h" #include "t888MD.h" #include "t753MD.h" #include "t844.h" #include "t841MD.h" #include "t833MD.h" #include "t833.h" #include "t835MD.h" #include "t834.h" #include "t889.h" #include "t889MD.h" #include "t890.h" #include "t890MD.h" #include "t877.h" #include "t794.h" #include "t891.h" #include "t891MD.h" #include "t22.h" #include "t769.h" #include "t767.h" #include "t354.h" #include "t867.h" #include "t867MD.h" #include "t868.h" #include "t868MD.h" #include "t853.h" #include "t853MD.h" #include "t874.h" #include "t854.h" #include "t854MD.h" #include "t892.h" #include "t893.h" #include "t893MD.h" #include "t894.h" #include "t894MD.h" #include "t895.h" #include "t895MD.h" #include "t896.h" #include "t896MD.h" #include "t897.h" #include "t897MD.h" #include "t898.h" #include "t898MD.h" #include "t899.h" #include "t899MD.h" #include "t900.h" #include "t900MD.h" #include "t901MD.h" #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif extern "C" void m4770 (t885 * __this, t832 * p0, t740* p1, const MethodInfo* method) { { t832 * L_0 = p0; t740* L_1 = p1; m4735(__this, L_0, ((int32_t)11), L_1, NULL); return; } } extern "C" void m4771 (t885 * __this, const MethodInfo* method) { { m4740(__this, NULL); t832 * L_0 = m4736(__this, NULL); t847 * L_1 = m4438(L_0, NULL); t798 * L_2 = (__this->f9); m4697(L_1, L_2, NULL); t832 * L_3 = m4736(__this, NULL); t847 * L_4 = m4438(L_3, NULL); m4706(L_4, NULL); return; } } extern "C" void m4772 (t885 * __this, const MethodInfo* method) { { VirtActionInvoker0::Invoke(24 /* System.Void Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate::ProcessAsTls1() */, __this); return; } } extern TypeInfo* t798_TI_var; extern TypeInfo* t800_TI_var; extern "C" void m4773 (t885 * __this, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t798_TI_var = il2cpp_codegen_type_info_from_index(460); t800_TI_var = il2cpp_codegen_type_info_from_index(466); s_Il2CppMethodIntialized = true; } int32_t V_0 = 0; int32_t V_1 = 0; int32_t V_2 = 0; t740* V_3 = {0}; t800 * V_4 = {0}; { t798 * L_0 = (t798 *)il2cpp_codegen_object_new (t798_TI_var); m4212(L_0, NULL); __this->f9 = L_0; V_0 = 0; int32_t L_1 = m4719(__this, NULL); V_1 = L_1; goto IL_004d; } IL_0019: { int32_t L_2 = m4719(__this, NULL); V_2 = L_2; int32_t L_3 = V_0; V_0 = ((int32_t)((int32_t)L_3+(int32_t)3)); int32_t L_4 = V_2; if ((((int32_t)L_4) <= ((int32_t)0))) { goto IL_004d; } } { int32_t L_5 = V_2; t740* L_6 = m4720(__this, L_5, NULL); V_3 = L_6; t740* L_7 = V_3; t800 * L_8 = (t800 *)il2cpp_codegen_object_new (t800_TI_var); m4172(L_8, L_7, NULL); V_4 = L_8; t798 * L_9 = (__this->f9); t800 * L_10 = V_4; m4216(L_9, L_10, NULL); int32_t L_11 = V_0; int32_t L_12 = V_2; V_0 = ((int32_t)((int32_t)L_11+(int32_t)L_12)); } IL_004d: { int32_t L_13 = V_0; int32_t L_14 = V_1; if ((((int32_t)L_13) < ((int32_t)L_14))) { goto IL_0019; } } { t798 * L_15 = (__this->f9); m4775(__this, L_15, NULL); return; } } extern TypeInfo* t836_TI_var; extern TypeInfo* t818_TI_var; extern TypeInfo* t815_TI_var; extern TypeInfo* t820_TI_var; extern Il2CppCodeGenString* _stringLiteral695; extern Il2CppCodeGenString* _stringLiteral696; extern Il2CppCodeGenString* _stringLiteral571; extern Il2CppCodeGenString* _stringLiteral697; extern Il2CppCodeGenString* _stringLiteral698; extern "C" bool m4774 (t885 * __this, t800 * p0, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t836_TI_var = il2cpp_codegen_type_info_from_index(497); t818_TI_var = il2cpp_codegen_type_info_from_index(556); t815_TI_var = il2cpp_codegen_type_info_from_index(489); t820_TI_var = il2cpp_codegen_type_info_from_index(557); _stringLiteral695 = il2cpp_codegen_string_literal_from_index(695); _stringLiteral696 = il2cpp_codegen_string_literal_from_index(696); _stringLiteral571 = il2cpp_codegen_string_literal_from_index(571); _stringLiteral697 = il2cpp_codegen_string_literal_from_index(697); _stringLiteral698 = il2cpp_codegen_string_literal_from_index(698); s_Il2CppMethodIntialized = true; } t836 * V_0 = {0}; int32_t V_1 = {0}; t818 * V_2 = {0}; t815 * V_3 = {0}; t809 * V_4 = {0}; t820 * V_5 = {0}; int32_t V_6 = {0}; int32_t G_B19_0 = 0; int32_t G_B26_0 = 0; { t832 * L_0 = m4736(__this, NULL); V_0 = ((t836 *)CastclassClass(L_0, t836_TI_var)); t800 * L_1 = p0; int32_t L_2 = m4194(L_1, NULL); if ((((int32_t)L_2) >= ((int32_t)3))) { goto IL_001a; } } { return 1; } IL_001a: { V_1 = 0; t836 * L_3 = V_0; t849 * L_4 = m4482(L_3, NULL); t829 * L_5 = m4552(L_4, NULL); int32_t L_6 = m4345(L_5, NULL); V_6 = L_6; int32_t L_7 = V_6; if (L_7 == 0) { goto IL_0061; } if (L_7 == 1) { goto IL_0068; } if (L_7 == 2) { goto IL_006a; } if (L_7 == 3) { goto IL_0059; } if (L_7 == 4) { goto IL_004e; } } { goto IL_006a; } IL_004e: { V_1 = ((int32_t)128); goto IL_006a; } IL_0059: { V_1 = ((int32_t)32); goto IL_006a; } IL_0061: { V_1 = 8; goto IL_006a; } IL_0068: { return 0; } IL_006a: { V_2 = (t818 *)NULL; V_3 = (t815 *)NULL; t800 * L_8 = p0; t802 * L_9 = m4178(L_8, NULL); t809 * L_10 = m4266(L_9, _stringLiteral695, NULL); V_4 = L_10; t809 * L_11 = V_4; if (!L_11) { goto IL_008f; } } { t809 * L_12 = V_4; t818 * L_13 = (t818 *)il2cpp_codegen_object_new (t818_TI_var); m4300(L_13, L_12, NULL); V_2 = L_13; } IL_008f: { t800 * L_14 = p0; t802 * L_15 = m4178(L_14, NULL); t809 * L_16 = m4266(L_15, _stringLiteral696, NULL); V_4 = L_16; t809 * L_17 = V_4; if (!L_17) { goto IL_00b0; } } { t809 * L_18 = V_4; t815 * L_19 = (t815 *)il2cpp_codegen_object_new (t815_TI_var); m4291(L_19, L_18, NULL); V_3 = L_19; } IL_00b0: { t818 * L_20 = V_2; if (!L_20) { goto IL_00f3; } } { t815 * L_21 = V_3; if (!L_21) { goto IL_00f3; } } { t818 * L_22 = V_2; int32_t L_23 = V_1; bool L_24 = m4303(L_22, L_23, NULL); if (L_24) { goto IL_00ca; } } { return 0; } IL_00ca: { t815 * L_25 = V_3; t774 * L_26 = m4294(L_25, NULL); bool L_27 = (bool)VirtFuncInvoker1< bool, t17 * >::Invoke(32 /* System.Boolean System.Collections.ArrayList::Contains(System.Object) */, L_26, _stringLiteral571); if (L_27) { goto IL_00f1; } } { t815 * L_28 = V_3; t774 * L_29 = m4294(L_28, NULL); bool L_30 = (bool)VirtFuncInvoker1< bool, t17 * >::Invoke(32 /* System.Boolean System.Collections.ArrayList::Contains(System.Object) */, L_29, _stringLiteral697); G_B19_0 = ((int32_t)(L_30)); goto IL_00f2; } IL_00f1: { G_B19_0 = 1; } IL_00f2: { return G_B19_0; } IL_00f3: { t818 * L_31 = V_2; if (!L_31) { goto IL_0101; } } { t818 * L_32 = V_2; int32_t L_33 = V_1; bool L_34 = m4303(L_32, L_33, NULL); return L_34; } IL_0101: { t815 * L_35 = V_3; if (!L_35) { goto IL_0130; } } { t815 * L_36 = V_3; t774 * L_37 = m4294(L_36, NULL); bool L_38 = (bool)VirtFuncInvoker1< bool, t17 * >::Invoke(32 /* System.Boolean System.Collections.ArrayList::Contains(System.Object) */, L_37, _stringLiteral571); if (L_38) { goto IL_012e; } } { t815 * L_39 = V_3; t774 * L_40 = m4294(L_39, NULL); bool L_41 = (bool)VirtFuncInvoker1< bool, t17 * >::Invoke(32 /* System.Boolean System.Collections.ArrayList::Contains(System.Object) */, L_40, _stringLiteral697); G_B26_0 = ((int32_t)(L_41)); goto IL_012f; } IL_012e: { G_B26_0 = 1; } IL_012f: { return G_B26_0; } IL_0130: { t800 * L_42 = p0; t802 * L_43 = m4178(L_42, NULL); t809 * L_44 = m4266(L_43, _stringLiteral698, NULL); V_4 = L_44; t809 * L_45 = V_4; if (!L_45) { goto IL_015c; } } { t809 * L_46 = V_4; t820 * L_47 = (t820 *)il2cpp_codegen_object_new (t820_TI_var); m4305(L_47, L_46, NULL); V_5 = L_47; t820 * L_48 = V_5; bool L_49 = m4307(L_48, ((int32_t)64), NULL); return L_49; } IL_015c: { return 1; } } extern const Il2CppType* t153_0_0_0_var; extern TypeInfo* t836_TI_var; extern TypeInfo* t935_TI_var; extern TypeInfo* t35_TI_var; extern TypeInfo* t876_TI_var; extern TypeInfo* t875_TI_var; extern TypeInfo* t774_TI_var; extern TypeInfo* t153_TI_var; extern TypeInfo* t798_TI_var; extern TypeInfo* t805_TI_var; extern TypeInfo* t171_TI_var; extern TypeInfo* t164_TI_var; extern TypeInfo* t553_TI_var; extern Il2CppCodeGenString* _stringLiteral699; extern Il2CppCodeGenString* _stringLiteral700; extern Il2CppCodeGenString* _stringLiteral701; extern "C" void m4775 (t885 * __this, t798 * p0, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t153_0_0_0_var = il2cpp_codegen_type_from_index(55); t836_TI_var = il2cpp_codegen_type_info_from_index(497); t935_TI_var = il2cpp_codegen_type_info_from_index(558); t35_TI_var = il2cpp_codegen_type_info_from_index(26); t876_TI_var = il2cpp_codegen_type_info_from_index(520); t875_TI_var = il2cpp_codegen_type_info_from_index(543); t774_TI_var = il2cpp_codegen_type_info_from_index(441); t153_TI_var = il2cpp_codegen_type_info_from_index(55); t798_TI_var = il2cpp_codegen_type_info_from_index(460); t805_TI_var = il2cpp_codegen_type_info_from_index(559); t171_TI_var = il2cpp_codegen_type_info_from_index(38); t164_TI_var = il2cpp_codegen_type_info_from_index(24); t553_TI_var = il2cpp_codegen_type_info_from_index(560); _stringLiteral699 = il2cpp_codegen_string_literal_from_index(699); _stringLiteral700 = il2cpp_codegen_string_literal_from_index(700); _stringLiteral701 = il2cpp_codegen_string_literal_from_index(701); s_Il2CppMethodIntialized = true; } t836 * V_0 = {0}; uint8_t V_1 = {0}; t865 * V_2 = {0}; int64_t V_3 = 0; t35* V_4 = {0}; t800 * V_5 = {0}; t875 * V_6 = {0}; t774 * V_7 = {0}; t798 * V_8 = {0}; t805 * V_9 = {0}; bool V_10 = false; t553* V_11 = {0}; int64_t V_12 = 0; int32_t V_13 = {0}; t171 * __last_unhandled_exception = 0; NO_UNUSED_WARNING (__last_unhandled_exception); t171 * __exception_local = 0; NO_UNUSED_WARNING (__exception_local); int32_t __leave_target = 0; NO_UNUSED_WARNING (__leave_target); { t832 * L_0 = m4736(__this, NULL); V_0 = ((t836 *)CastclassClass(L_0, t836_TI_var)); V_1 = ((int32_t)42); t836 * L_1 = V_0; t837 * L_2 = m4398(L_1, NULL); bool L_3 = (bool)VirtFuncInvoker0< bool >::Invoke(29 /* System.Boolean Mono.Security.Protocol.Tls.SslClientStream::get_HaveRemoteValidation2Callback() */, L_2); if (!L_3) { goto IL_00b4; } } { t836 * L_4 = V_0; t837 * L_5 = m4398(L_4, NULL); t798 * L_6 = p0; t865 * L_7 = (t865 *)VirtFuncInvoker1< t865 *, t798 * >::Invoke(32 /* Mono.Security.Protocol.Tls.ValidationResult Mono.Security.Protocol.Tls.SslClientStream::RaiseServerCertificateValidation2(Mono.Security.X509.X509CertificateCollection) */, L_5, L_6); V_2 = L_7; t865 * L_8 = V_2; bool L_9 = m4559(L_8, NULL); if (!L_9) { goto IL_0038; } } { return; } IL_0038: { t865 * L_10 = V_2; int32_t L_11 = m4560(L_10, NULL); V_3 = (((int64_t)((int64_t)L_11))); int64_t L_12 = V_3; V_12 = L_12; int64_t L_13 = V_12; if ((((int64_t)L_13) == ((int64_t)(((int64_t)((uint64_t)(((uint32_t)((uint32_t)((int32_t)-2146762487)))))))))) { goto IL_007f; } } { int64_t L_14 = V_12; if ((((int64_t)L_14) == ((int64_t)(((int64_t)((uint64_t)(((uint32_t)((uint32_t)((int32_t)-2146762486)))))))))) { goto IL_0077; } } { int64_t L_15 = V_12; if ((((int64_t)L_15) == ((int64_t)(((int64_t)((uint64_t)(((uint32_t)((uint32_t)((int32_t)-2146762495)))))))))) { goto IL_006f; } } { goto IL_0087; } IL_006f: { V_1 = ((int32_t)45); goto IL_008f; } IL_0077: { V_1 = ((int32_t)48); goto IL_008f; } IL_007f: { V_1 = ((int32_t)48); goto IL_008f; } IL_0087: { V_1 = ((int32_t)46); goto IL_008f; } IL_008f: { int64_t L_16 = V_3; int64_t L_17 = L_16; t17 * L_18 = Box(t935_TI_var, &L_17); IL2CPP_RUNTIME_CLASS_INIT(t35_TI_var); t35* L_19 = m710(NULL, _stringLiteral699, L_18, NULL); V_4 = L_19; uint8_t L_20 = V_1; t35* L_21 = V_4; t35* L_22 = m724(NULL, _stringLiteral700, L_21, NULL); t876 * L_23 = (t876 *)il2cpp_codegen_object_new (t876_TI_var); m4691(L_23, L_20, L_22, NULL); il2cpp_codegen_raise_exception((Il2CppCodeGenException*)L_23); } IL_00b4: { t798 * L_24 = p0; t800 * L_25 = m4215(L_24, 0, NULL); V_5 = L_25; t800 * L_26 = V_5; t740* L_27 = (t740*)VirtFuncInvoker0< t740* >::Invoke(12 /* System.Byte[] Mono.Security.X509.X509Certificate::get_RawData() */, L_26); t875 * L_28 = (t875 *)il2cpp_codegen_object_new (t875_TI_var); m4939(L_28, L_27, NULL); V_6 = L_28; t774 * L_29 = (t774 *)il2cpp_codegen_object_new (t774_TI_var); m4825(L_29, NULL); V_7 = L_29; t800 * L_30 = V_5; bool L_31 = m4774(__this, L_30, NULL); if (L_31) { goto IL_00f1; } } { t774 * L_32 = V_7; int32_t L_33 = ((int32_t)-2146762490); t17 * L_34 = Box(t153_TI_var, &L_33); VirtFuncInvoker1< int32_t, t17 * >::Invoke(30 /* System.Int32 System.Collections.ArrayList::Add(System.Object) */, L_32, L_34); } IL_00f1: { t800 * L_35 = V_5; bool L_36 = m4776(__this, L_35, NULL); if (L_36) { goto IL_0110; } } { t774 * L_37 = V_7; int32_t L_38 = ((int32_t)-2146762481); t17 * L_39 = Box(t153_TI_var, &L_38); VirtFuncInvoker1< int32_t, t17 * >::Invoke(30 /* System.Int32 System.Collections.ArrayList::Add(System.Object) */, L_37, L_39); } IL_0110: { t798 * L_40 = p0; t798 * L_41 = (t798 *)il2cpp_codegen_object_new (t798_TI_var); m4213(L_41, L_40, NULL); V_8 = L_41; t798 * L_42 = V_8; t800 * L_43 = V_5; m4222(L_42, L_43, NULL); t798 * L_44 = V_8; t805 * L_45 = (t805 *)il2cpp_codegen_object_new (t805_TI_var); m4225(L_45, L_44, NULL); V_9 = L_45; V_10 = 0; } IL_012d: try { // begin try (depth: 1) t805 * L_46 = V_9; t800 * L_47 = V_5; bool L_48 = m4228(L_46, L_47, NULL); V_10 = L_48; goto IL_0146; } // end try (depth: 1) catch(Il2CppExceptionWrapper& e) { __exception_local = (t171 *)e.ex; if(il2cpp_codegen_class_is_assignable_from (t171_TI_var, e.ex->object.klass)) goto CATCH_013d; throw e; } CATCH_013d: { // begin catch(System.Exception) V_10 = 0; goto IL_0146; } // end catch (depth: 1) IL_0146: { bool L_49 = V_10; if (L_49) { goto IL_0243; } } { t805 * L_50 = V_9; int32_t L_51 = m4226(L_50, NULL); V_13 = L_51; int32_t L_52 = V_13; if ((((int32_t)L_52) == ((int32_t)1))) { goto IL_01d9; } } { int32_t L_53 = V_13; if ((((int32_t)L_53) == ((int32_t)2))) { goto IL_01c2; } } { int32_t L_54 = V_13; if ((((int32_t)L_54) == ((int32_t)8))) { goto IL_01ab; } } { int32_t L_55 = V_13; if ((((int32_t)L_55) == ((int32_t)((int32_t)32)))) { goto IL_020d; } } { int32_t L_56 = V_13; if ((((int32_t)L_56) == ((int32_t)((int32_t)1024)))) { goto IL_0194; } } { int32_t L_57 = V_13; if ((((int32_t)L_57) == ((int32_t)((int32_t)65536)))) { goto IL_01f3; } } { goto IL_0227; } IL_0194: { t774 * L_58 = V_7; int32_t L_59 = ((int32_t)-2146869223); t17 * L_60 = Box(t153_TI_var, &L_59); VirtFuncInvoker1< int32_t, t17 * >::Invoke(30 /* System.Int32 System.Collections.ArrayList::Add(System.Object) */, L_58, L_60); goto IL_0243; } IL_01ab: { t774 * L_61 = V_7; int32_t L_62 = ((int32_t)-2146869232); t17 * L_63 = Box(t153_TI_var, &L_62); VirtFuncInvoker1< int32_t, t17 * >::Invoke(30 /* System.Int32 System.Collections.ArrayList::Add(System.Object) */, L_61, L_63); goto IL_0243; } IL_01c2: { t774 * L_64 = V_7; int32_t L_65 = ((int32_t)-2146762494); t17 * L_66 = Box(t153_TI_var, &L_65); VirtFuncInvoker1< int32_t, t17 * >::Invoke(30 /* System.Int32 System.Collections.ArrayList::Add(System.Object) */, L_64, L_66); goto IL_0243; } IL_01d9: { V_1 = ((int32_t)45); t774 * L_67 = V_7; int32_t L_68 = ((int32_t)-2146762495); t17 * L_69 = Box(t153_TI_var, &L_68); VirtFuncInvoker1< int32_t, t17 * >::Invoke(30 /* System.Int32 System.Collections.ArrayList::Add(System.Object) */, L_67, L_69); goto IL_0243; } IL_01f3: { V_1 = ((int32_t)48); t774 * L_70 = V_7; int32_t L_71 = ((int32_t)-2146762486); t17 * L_72 = Box(t153_TI_var, &L_71); VirtFuncInvoker1< int32_t, t17 * >::Invoke(30 /* System.Int32 System.Collections.ArrayList::Add(System.Object) */, L_70, L_72); goto IL_0243; } IL_020d: { V_1 = ((int32_t)48); t774 * L_73 = V_7; int32_t L_74 = ((int32_t)-2146762487); t17 * L_75 = Box(t153_TI_var, &L_74); VirtFuncInvoker1< int32_t, t17 * >::Invoke(30 /* System.Int32 System.Collections.ArrayList::Add(System.Object) */, L_73, L_75); goto IL_0243; } IL_0227: { V_1 = ((int32_t)46); t774 * L_76 = V_7; t805 * L_77 = V_9; int32_t L_78 = m4226(L_77, NULL); int32_t L_79 = L_78; t17 * L_80 = Box(t153_TI_var, &L_79); VirtFuncInvoker1< int32_t, t17 * >::Invoke(30 /* System.Int32 System.Collections.ArrayList::Add(System.Object) */, L_76, L_80); goto IL_0243; } IL_0243: { t774 * L_81 = V_7; IL2CPP_RUNTIME_CLASS_INIT(t164_TI_var); t164 * L_82 = m512(NULL, LoadTypeToken(t153_0_0_0_var), NULL); t144 * L_83 = (t144 *)VirtFuncInvoker1< t144 *, t164 * >::Invoke(48 /* System.Array System.Collections.ArrayList::ToArray(System.Type) */, L_81, L_82); V_11 = ((t553*)Castclass(L_83, t553_TI_var)); t836 * L_84 = V_0; t837 * L_85 = m4398(L_84, NULL); t875 * L_86 = V_6; t553* L_87 = V_11; bool L_88 = (bool)VirtFuncInvoker2< bool, t875 *, t553* >::Invoke(31 /* System.Boolean Mono.Security.Protocol.Tls.SslClientStream::RaiseServerCertificateValidation(System.Security.Cryptography.X509Certificates.X509Certificate,System.Int32[]) */, L_85, L_86, L_87); if (L_88) { goto IL_027b; } } { uint8_t L_89 = V_1; t876 * L_90 = (t876 *)il2cpp_codegen_object_new (t876_TI_var); m4691(L_90, L_89, _stringLiteral701, NULL); il2cpp_codegen_raise_exception((Il2CppCodeGenException*)L_90); } IL_027b: { return; } } extern TypeInfo* t836_TI_var; extern TypeInfo* t821_TI_var; extern TypeInfo* t35_TI_var; extern Il2CppCodeGenString* _stringLiteral702; extern "C" bool m4776 (t885 * __this, t800 * p0, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t836_TI_var = il2cpp_codegen_type_info_from_index(497); t821_TI_var = il2cpp_codegen_type_info_from_index(561); t35_TI_var = il2cpp_codegen_type_info_from_index(26); _stringLiteral702 = il2cpp_codegen_string_literal_from_index(702); s_Il2CppMethodIntialized = true; } t836 * V_0 = {0}; t35* V_1 = {0}; t809 * V_2 = {0}; t821 * V_3 = {0}; t35* V_4 = {0}; t211* V_5 = {0}; int32_t V_6 = 0; t35* V_7 = {0}; t211* V_8 = {0}; int32_t V_9 = 0; { t832 * L_0 = m4736(__this, NULL); V_0 = ((t836 *)CastclassClass(L_0, t836_TI_var)); t836 * L_1 = V_0; t848 * L_2 = m4439(L_1, NULL); t35* L_3 = m4679(L_2, NULL); V_1 = L_3; t800 * L_4 = p0; t802 * L_5 = m4178(L_4, NULL); t809 * L_6 = m4266(L_5, _stringLiteral702, NULL); V_2 = L_6; t809 * L_7 = V_2; if (!L_7) { goto IL_00a4; } } { t809 * L_8 = V_2; t821 * L_9 = (t821 *)il2cpp_codegen_object_new (t821_TI_var); m4309(L_9, L_8, NULL); V_3 = L_9; t821 * L_10 = V_3; t211* L_11 = m4311(L_10, NULL); V_5 = L_11; V_6 = 0; goto IL_0062; } IL_0046: { t211* L_12 = V_5; int32_t L_13 = V_6; int32_t L_14 = L_13; V_4 = (*(t35**)(t35**)SZArrayLdElema(L_12, L_14, sizeof(t35*))); t35* L_15 = V_1; t35* L_16 = V_4; bool L_17 = m4778(NULL, L_15, L_16, NULL); if (!L_17) { goto IL_005c; } } { return 1; } IL_005c: { int32_t L_18 = V_6; V_6 = ((int32_t)((int32_t)L_18+(int32_t)1)); } IL_0062: { int32_t L_19 = V_6; t211* L_20 = V_5; if ((((int32_t)L_19) < ((int32_t)(((int32_t)((int32_t)(((t144 *)L_20)->max_length))))))) { goto IL_0046; } } { t821 * L_21 = V_3; t211* L_22 = m4312(L_21, NULL); V_8 = L_22; V_9 = 0; goto IL_0099; } IL_007d: { t211* L_23 = V_8; int32_t L_24 = V_9; int32_t L_25 = L_24; V_7 = (*(t35**)(t35**)SZArrayLdElema(L_23, L_25, sizeof(t35*))); t35* L_26 = V_7; t35* L_27 = V_1; IL2CPP_RUNTIME_CLASS_INIT(t35_TI_var); bool L_28 = m514(NULL, L_26, L_27, NULL); if (!L_28) { goto IL_0093; } } { return 1; } IL_0093: { int32_t L_29 = V_9; V_9 = ((int32_t)((int32_t)L_29+(int32_t)1)); } IL_0099: { int32_t L_30 = V_9; t211* L_31 = V_8; if ((((int32_t)L_30) < ((int32_t)(((int32_t)((int32_t)(((t144 *)L_31)->max_length))))))) { goto IL_007d; } } IL_00a4: { t800 * L_32 = p0; t35* L_33 = (t35*)VirtFuncInvoker0< t35* >::Invoke(16 /* System.String Mono.Security.X509.X509Certificate::get_SubjectName() */, L_32); bool L_34 = m4777(__this, L_33, NULL); return L_34; } } extern TypeInfo* t836_TI_var; extern TypeInfo* t35_TI_var; extern TypeInfo* t724_TI_var; extern Il2CppCodeGenString* _stringLiteral703; extern "C" bool m4777 (t885 * __this, t35* p0, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t836_TI_var = il2cpp_codegen_type_info_from_index(497); t35_TI_var = il2cpp_codegen_type_info_from_index(26); t724_TI_var = il2cpp_codegen_type_info_from_index(401); _stringLiteral703 = il2cpp_codegen_string_literal_from_index(703); s_Il2CppMethodIntialized = true; } t836 * V_0 = {0}; t35* V_1 = {0}; t724 * V_2 = {0}; t965 * V_3 = {0}; { t832 * L_0 = m4736(__this, NULL); V_0 = ((t836 *)CastclassClass(L_0, t836_TI_var)); IL2CPP_RUNTIME_CLASS_INIT(t35_TI_var); t35* L_1 = ((t35_SFs*)t35_TI_var->static_fields)->f2; V_1 = L_1; t724 * L_2 = (t724 *)il2cpp_codegen_object_new (t724_TI_var); m4949(L_2, _stringLiteral703, NULL); V_2 = L_2; t724 * L_3 = V_2; t35* L_4 = p0; t965 * L_5 = m4950(L_3, L_4, NULL); V_3 = L_5; t965 * L_6 = V_3; int32_t L_7 = (int32_t)VirtFuncInvoker0< int32_t >::Invoke(4 /* System.Int32 System.Text.RegularExpressions.MatchCollection::get_Count() */, L_6); if ((!(((uint32_t)L_7) == ((uint32_t)1)))) { goto IL_005f; } } { t965 * L_8 = V_3; t966 * L_9 = (t966 *)VirtFuncInvoker1< t966 *, int32_t >::Invoke(9 /* System.Text.RegularExpressions.Match System.Text.RegularExpressions.MatchCollection::get_Item(System.Int32) */, L_8, 0); bool L_10 = m4951(L_9, NULL); if (!L_10) { goto IL_005f; } } { t965 * L_11 = V_3; t966 * L_12 = (t966 *)VirtFuncInvoker1< t966 *, int32_t >::Invoke(9 /* System.Text.RegularExpressions.Match System.Text.RegularExpressions.MatchCollection::get_Item(System.Int32) */, L_11, 0); t968 * L_13 = (t968 *)VirtFuncInvoker0< t968 * >::Invoke(4 /* System.Text.RegularExpressions.GroupCollection System.Text.RegularExpressions.Match::get_Groups() */, L_12); t967 * L_14 = m4952(L_13, 1, NULL); t35* L_15 = m4953(L_14, NULL); t35* L_16 = m3828(L_15, NULL); V_1 = L_16; } IL_005f: { t836 * L_17 = V_0; t848 * L_18 = m4439(L_17, NULL); t35* L_19 = m4679(L_18, NULL); t35* L_20 = V_1; bool L_21 = m4778(NULL, L_19, L_20, NULL); return L_21; } } extern TypeInfo* t717_TI_var; extern TypeInfo* t35_TI_var; extern "C" bool m4778 (t17 * __this , t35* p0, t35* p1, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t717_TI_var = il2cpp_codegen_type_info_from_index(445); t35_TI_var = il2cpp_codegen_type_info_from_index(26); s_Il2CppMethodIntialized = true; } int32_t V_0 = 0; int32_t V_1 = 0; t35* V_2 = {0}; int32_t V_3 = 0; int32_t V_4 = 0; t35* V_5 = {0}; int32_t G_B15_0 = 0; { t35* L_0 = p1; int32_t L_1 = m2588(L_0, ((int32_t)42), NULL); V_0 = L_1; int32_t L_2 = V_0; if ((!(((uint32_t)L_2) == ((uint32_t)(-1))))) { goto IL_0021; } } { t35* L_3 = p0; t35* L_4 = p1; IL2CPP_RUNTIME_CLASS_INIT(t717_TI_var); t717 * L_5 = m4834(NULL, NULL); IL2CPP_RUNTIME_CLASS_INIT(t35_TI_var); int32_t L_6 = m4954(NULL, L_3, L_4, 1, L_5, NULL); return ((((int32_t)L_6) == ((int32_t)0))? 1 : 0); } IL_0021: { int32_t L_7 = V_0; t35* L_8 = p1; int32_t L_9 = m2521(L_8, NULL); if ((((int32_t)L_7) == ((int32_t)((int32_t)((int32_t)L_9-(int32_t)1))))) { goto IL_0041; } } { t35* L_10 = p1; int32_t L_11 = V_0; uint16_t L_12 = m2538(L_10, ((int32_t)((int32_t)L_11+(int32_t)1)), NULL); if ((((int32_t)L_12) == ((int32_t)((int32_t)46)))) { goto IL_0041; } } { return 0; } IL_0041: { t35* L_13 = p1; int32_t L_14 = V_0; int32_t L_15 = m4955(L_13, ((int32_t)42), ((int32_t)((int32_t)L_14+(int32_t)1)), NULL); V_1 = L_15; int32_t L_16 = V_1; if ((((int32_t)L_16) == ((int32_t)(-1)))) { goto IL_0056; } } { return 0; } IL_0056: { t35* L_17 = p1; int32_t L_18 = V_0; t35* L_19 = m2565(L_17, ((int32_t)((int32_t)L_18+(int32_t)1)), NULL); V_2 = L_19; t35* L_20 = p0; int32_t L_21 = m2521(L_20, NULL); t35* L_22 = V_2; int32_t L_23 = m2521(L_22, NULL); V_3 = ((int32_t)((int32_t)L_21-(int32_t)L_23)); int32_t L_24 = V_3; if ((((int32_t)L_24) > ((int32_t)0))) { goto IL_0077; } } { return 0; } IL_0077: { t35* L_25 = p0; int32_t L_26 = V_3; t35* L_27 = V_2; t35* L_28 = V_2; int32_t L_29 = m2521(L_28, NULL); IL2CPP_RUNTIME_CLASS_INIT(t717_TI_var); t717 * L_30 = m4834(NULL, NULL); IL2CPP_RUNTIME_CLASS_INIT(t35_TI_var); int32_t L_31 = m4956(NULL, L_25, L_26, L_27, 0, L_29, 1, L_30, NULL); if (!L_31) { goto IL_0093; } } { return 0; } IL_0093: { int32_t L_32 = V_0; if (L_32) { goto IL_00c3; } } { t35* L_33 = p0; int32_t L_34 = m2588(L_33, ((int32_t)46), NULL); V_4 = L_34; int32_t L_35 = V_4; if ((((int32_t)L_35) == ((int32_t)(-1)))) { goto IL_00c1; } } { int32_t L_36 = V_4; t35* L_37 = p0; int32_t L_38 = m2521(L_37, NULL); t35* L_39 = V_2; int32_t L_40 = m2521(L_39, NULL); G_B15_0 = ((((int32_t)((((int32_t)L_36) < ((int32_t)((int32_t)((int32_t)L_38-(int32_t)L_40))))? 1 : 0)) == ((int32_t)0))? 1 : 0); goto IL_00c2; } IL_00c1: { G_B15_0 = 1; } IL_00c2: { return G_B15_0; } IL_00c3: { t35* L_41 = p1; int32_t L_42 = V_0; t35* L_43 = m2539(L_41, 0, L_42, NULL); V_5 = L_43; t35* L_44 = p0; t35* L_45 = V_5; t35* L_46 = V_5; int32_t L_47 = m2521(L_46, NULL); IL2CPP_RUNTIME_CLASS_INIT(t717_TI_var); t717 * L_48 = m4834(NULL, NULL); IL2CPP_RUNTIME_CLASS_INIT(t35_TI_var); int32_t L_49 = m4956(NULL, L_44, 0, L_45, 0, L_47, 1, L_48, NULL); return ((((int32_t)L_49) == ((int32_t)0))? 1 : 0); } } extern "C" void m4779 (t886 * __this, t832 * p0, t740* p1, const MethodInfo* method) { { t832 * L_0 = p0; t740* L_1 = p1; m4735(__this, L_0, ((int32_t)13), L_1, NULL); return; } } extern "C" void m4780 (t886 * __this, const MethodInfo* method) { { m4740(__this, NULL); t832 * L_0 = m4736(__this, NULL); t847 * L_1 = m4438(L_0, NULL); t878* L_2 = (__this->f9); m4704(L_1, L_2, NULL); t832 * L_3 = m4736(__this, NULL); t847 * L_4 = m4438(L_3, NULL); t211* L_5 = (__this->f10); m4705(L_4, L_5, NULL); t832 * L_6 = m4736(__this, NULL); t847 * L_7 = m4438(L_6, NULL); m4703(L_7, 1, NULL); return; } } extern "C" void m4781 (t886 * __this, const MethodInfo* method) { { VirtActionInvoker0::Invoke(24 /* System.Void Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificateRequest::ProcessAsTls1() */, __this); return; } } extern TypeInfo* t878_TI_var; extern TypeInfo* t773_TI_var; extern TypeInfo* t211_TI_var; extern TypeInfo* t914_TI_var; extern "C" void m4782 (t886 * __this, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t878_TI_var = il2cpp_codegen_type_info_from_index(562); t773_TI_var = il2cpp_codegen_type_info_from_index(442); t211_TI_var = il2cpp_codegen_type_info_from_index(93); t914_TI_var = il2cpp_codegen_type_info_from_index(446); s_Il2CppMethodIntialized = true; } int32_t V_0 = 0; int32_t V_1 = 0; t773 * V_2 = {0}; int32_t V_3 = 0; t773 * V_4 = {0}; { uint8_t L_0 = m4717(__this, NULL); V_0 = L_0; int32_t L_1 = V_0; __this->f9 = ((t878*)SZArrayNew(t878_TI_var, L_1)); V_1 = 0; goto IL_002c; } IL_001a: { t878* L_2 = (__this->f9); int32_t L_3 = V_1; uint8_t L_4 = m4717(__this, NULL); *((int32_t*)(int32_t*)SZArrayLdElema(L_2, L_3, sizeof(int32_t))) = (int32_t)L_4; int32_t L_5 = V_1; V_1 = ((int32_t)((int32_t)L_5+(int32_t)1)); } IL_002c: { int32_t L_6 = V_1; int32_t L_7 = V_0; if ((((int32_t)L_6) < ((int32_t)L_7))) { goto IL_001a; } } { int16_t L_8 = m4718(__this, NULL); if (!L_8) { goto IL_00aa; } } { int16_t L_9 = m4718(__this, NULL); t740* L_10 = m4720(__this, L_9, NULL); t773 * L_11 = (t773 *)il2cpp_codegen_object_new (t773_TI_var); m4014(L_11, L_10, NULL); V_2 = L_11; t773 * L_12 = V_2; int32_t L_13 = m4015(L_12, NULL); __this->f10 = ((t211*)SZArrayNew(t211_TI_var, L_13)); V_3 = 0; goto IL_009e; } IL_0068: { t773 * L_14 = V_2; int32_t L_15 = V_3; t773 * L_16 = m4026(L_14, L_15, NULL); t740* L_17 = m4018(L_16, NULL); t773 * L_18 = (t773 *)il2cpp_codegen_object_new (t773_TI_var); m4014(L_18, L_17, NULL); V_4 = L_18; t211* L_19 = (__this->f10); int32_t L_20 = V_3; IL2CPP_RUNTIME_CLASS_INIT(t914_TI_var); t914 * L_21 = m4864(NULL, NULL); t773 * L_22 = V_4; t773 * L_23 = m4026(L_22, 1, NULL); t740* L_24 = m4018(L_23, NULL); t35* L_25 = (t35*)VirtFuncInvoker1< t35*, t740* >::Invoke(22 /* System.String System.Text.Encoding::GetString(System.Byte[]) */, L_21, L_24); ArrayElementTypeCheck (L_19, L_25); *((t35**)(t35**)SZArrayLdElema(L_19, L_20, sizeof(t35*))) = (t35*)L_25; int32_t L_26 = V_3; V_3 = ((int32_t)((int32_t)L_26+(int32_t)1)); } IL_009e: { int32_t L_27 = V_3; t773 * L_28 = V_2; int32_t L_29 = m4015(L_28, NULL); if ((((int32_t)L_27) < ((int32_t)L_29))) { goto IL_0068; } } IL_00aa: { return; } } extern "C" void m4783 (t887 * __this, t832 * p0, t740* p1, const MethodInfo* method) { { t832 * L_0 = p0; t740* L_1 = p1; m4735(__this, L_0, ((int32_t)20), L_1, NULL); return; } } extern TypeInfo* t740_TI_var; extern TypeInfo* t887_TI_var; extern FieldInfo* t902_f14_FieldInfo_var; extern "C" void m4784 (t17 * __this , const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t740_TI_var = il2cpp_codegen_type_info_from_index(421); t887_TI_var = il2cpp_codegen_type_info_from_index(519); t902_f14_FieldInfo_var = il2cpp_codegen_field_info_from_index(438, 14); s_Il2CppMethodIntialized = true; } { t740* L_0 = ((t740*)SZArrayNew(t740_TI_var, 4)); m3934(NULL, (t144 *)(t144 *)L_0, LoadFieldToken(t902_f14_FieldInfo_var), NULL); ((t887_SFs*)t887_TI_var->static_fields)->f9 = L_0; return; } } extern "C" void m4785 (t887 * __this, const MethodInfo* method) { { m4740(__this, NULL); t832 * L_0 = m4736(__this, NULL); m4443(L_0, 2, NULL); return; } } extern TypeInfo* t870_TI_var; extern TypeInfo* t887_TI_var; extern TypeInfo* t829_TI_var; extern TypeInfo* t876_TI_var; extern Il2CppCodeGenString* _stringLiteral704; extern "C" void m4786 (t887 * __this, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t870_TI_var = il2cpp_codegen_type_info_from_index(554); t887_TI_var = il2cpp_codegen_type_info_from_index(519); t829_TI_var = il2cpp_codegen_type_info_from_index(496); t876_TI_var = il2cpp_codegen_type_info_from_index(520); _stringLiteral704 = il2cpp_codegen_string_literal_from_index(704); s_Il2CppMethodIntialized = true; } t785 * V_0 = {0}; t740* V_1 = {0}; t740* V_2 = {0}; t740* V_3 = {0}; { t832 * L_0 = m4736(__this, NULL); t740* L_1 = m4463(L_0, NULL); t870 * L_2 = (t870 *)il2cpp_codegen_object_new (t870_TI_var); m4603(L_2, L_1, NULL); V_0 = L_2; t832 * L_3 = m4736(__this, NULL); t850 * L_4 = m4450(L_3, NULL); t740* L_5 = m4727(L_4, NULL); V_1 = L_5; t785 * L_6 = V_0; t740* L_7 = V_1; t740* L_8 = V_1; t740* L_9 = V_1; VirtFuncInvoker5< int32_t, t740*, int32_t, int32_t, t740*, int32_t >::Invoke(6 /* System.Int32 System.Security.Cryptography.HashAlgorithm::TransformBlock(System.Byte[],System.Int32,System.Int32,System.Byte[],System.Int32) */, L_6, L_7, 0, (((int32_t)((int32_t)(((t144 *)L_8)->max_length)))), L_9, 0); t785 * L_10 = V_0; IL2CPP_RUNTIME_CLASS_INIT(t887_TI_var); t740* L_11 = ((t887_SFs*)t887_TI_var->static_fields)->f9; t740* L_12 = ((t887_SFs*)t887_TI_var->static_fields)->f9; t740* L_13 = ((t887_SFs*)t887_TI_var->static_fields)->f9; VirtFuncInvoker5< int32_t, t740*, int32_t, int32_t, t740*, int32_t >::Invoke(6 /* System.Int32 System.Security.Cryptography.HashAlgorithm::TransformBlock(System.Byte[],System.Int32,System.Int32,System.Byte[],System.Int32) */, L_10, L_11, 0, (((int32_t)((int32_t)(((t144 *)L_12)->max_length)))), L_13, 0); t785 * L_14 = V_0; IL2CPP_RUNTIME_CLASS_INIT(t829_TI_var); t740* L_15 = ((t829_SFs*)t829_TI_var->static_fields)->f0; VirtFuncInvoker3< t740*, t740*, int32_t, int32_t >::Invoke(7 /* System.Byte[] System.Security.Cryptography.HashAlgorithm::TransformFinalBlock(System.Byte[],System.Int32,System.Int32) */, L_14, L_15, 0, 0); int64_t L_16 = (int64_t)VirtFuncInvoker0< int64_t >::Invoke(8 /* System.Int64 Mono.Security.Protocol.Tls.TlsStream::get_Length() */, __this); t740* L_17 = m4720(__this, (((int32_t)((int32_t)L_16))), NULL); V_2 = L_17; t785 * L_18 = V_0; t740* L_19 = (t740*)VirtFuncInvoker0< t740* >::Invoke(9 /* System.Byte[] System.Security.Cryptography.HashAlgorithm::get_Hash() */, L_18); V_3 = L_19; t740* L_20 = V_3; t740* L_21 = V_2; bool L_22 = m4742(NULL, L_20, L_21, NULL); if (L_22) { goto IL_0086; } } { t876 * L_23 = (t876 *)il2cpp_codegen_object_new (t876_TI_var); m4691(L_23, ((int32_t)71), _stringLiteral704, NULL); il2cpp_codegen_raise_exception((Il2CppCodeGenException*)L_23); } IL_0086: { return; } } extern TypeInfo* t824_TI_var; extern TypeInfo* t876_TI_var; extern Il2CppCodeGenString* _stringLiteral705; extern Il2CppCodeGenString* _stringLiteral704; extern "C" void m4787 (t887 * __this, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t824_TI_var = il2cpp_codegen_type_info_from_index(541); t876_TI_var = il2cpp_codegen_type_info_from_index(520); _stringLiteral705 = il2cpp_codegen_string_literal_from_index(705); _stringLiteral704 = il2cpp_codegen_string_literal_from_index(704); s_Il2CppMethodIntialized = true; } t740* V_0 = {0}; t785 * V_1 = {0}; t740* V_2 = {0}; t740* V_3 = {0}; t740* V_4 = {0}; { int64_t L_0 = (int64_t)VirtFuncInvoker0< int64_t >::Invoke(8 /* System.Int64 Mono.Security.Protocol.Tls.TlsStream::get_Length() */, __this); t740* L_1 = m4720(__this, (((int32_t)((int32_t)L_0))), NULL); V_0 = L_1; t824 * L_2 = (t824 *)il2cpp_codegen_object_new (t824_TI_var); m4321(L_2, NULL); V_1 = L_2; t832 * L_3 = m4736(__this, NULL); t850 * L_4 = m4450(L_3, NULL); t740* L_5 = m4727(L_4, NULL); V_2 = L_5; t785 * L_6 = V_1; t740* L_7 = V_2; t740* L_8 = V_2; t740* L_9 = m4855(L_6, L_7, 0, (((int32_t)((int32_t)(((t144 *)L_8)->max_length)))), NULL); V_3 = L_9; t832 * L_10 = m4736(__this, NULL); t849 * L_11 = m4481(L_10, NULL); t829 * L_12 = m4552(L_11, NULL); t832 * L_13 = m4736(__this, NULL); t740* L_14 = m4463(L_13, NULL); t740* L_15 = V_3; t740* L_16 = m4363(L_12, L_14, _stringLiteral705, L_15, ((int32_t)12), NULL); V_4 = L_16; t740* L_17 = V_4; t740* L_18 = V_0; bool L_19 = m4742(NULL, L_17, L_18, NULL); if (L_19) { goto IL_0073; } } { t876 * L_20 = (t876 *)il2cpp_codegen_object_new (t876_TI_var); m4686(L_20, _stringLiteral704, NULL); il2cpp_codegen_raise_exception((Il2CppCodeGenException*)L_20); } IL_0073: { return; } } extern "C" void m4788 (t888 * __this, t832 * p0, t740* p1, const MethodInfo* method) { { t832 * L_0 = p0; t740* L_1 = p1; m4735(__this, L_0, 2, L_1, NULL); return; } } extern TypeInfo* t740_TI_var; extern "C" void m4789 (t888 * __this, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t740_TI_var = il2cpp_codegen_type_info_from_index(421); s_Il2CppMethodIntialized = true; } int32_t V_0 = 0; int32_t V_1 = 0; int32_t V_2 = 0; t740* V_3 = {0}; t740* V_4 = {0}; { m4740(__this, NULL); t832 * L_0 = m4736(__this, NULL); t740* L_1 = (__this->f11); m4435(L_0, L_1, NULL); t832 * L_2 = m4736(__this, NULL); t740* L_3 = (__this->f10); m4458(L_2, L_3, NULL); t832 * L_4 = m4736(__this, NULL); t849 * L_5 = m4482(L_4, NULL); t829 * L_6 = (__this->f12); m4553(L_5, L_6, NULL); t832 * L_7 = m4736(__this, NULL); int32_t L_8 = (__this->f9); m4437(L_7, L_8, NULL); t832 * L_9 = m4736(__this, NULL); m4429(L_9, 1, NULL); t832 * L_10 = m4736(__this, NULL); t740* L_11 = m4455(L_10, NULL); V_0 = (((int32_t)((int32_t)(((t144 *)L_11)->max_length)))); t832 * L_12 = m4736(__this, NULL); t740* L_13 = m4457(L_12, NULL); V_1 = (((int32_t)((int32_t)(((t144 *)L_13)->max_length)))); int32_t L_14 = V_0; int32_t L_15 = V_1; V_2 = ((int32_t)((int32_t)L_14+(int32_t)L_15)); int32_t L_16 = V_2; V_3 = ((t740*)SZArrayNew(t740_TI_var, L_16)); t832 * L_17 = m4736(__this, NULL); t740* L_18 = m4455(L_17, NULL); t740* L_19 = V_3; int32_t L_20 = V_0; m3917(NULL, (t144 *)(t144 *)L_18, 0, (t144 *)(t144 *)L_19, 0, L_20, NULL); t832 * L_21 = m4736(__this, NULL); t740* L_22 = m4457(L_21, NULL); t740* L_23 = V_3; int32_t L_24 = V_0; int32_t L_25 = V_1; m3917(NULL, (t144 *)(t144 *)L_22, 0, (t144 *)(t144 *)L_23, L_24, L_25, NULL); t832 * L_26 = m4736(__this, NULL); t740* L_27 = V_3; m4460(L_26, L_27, NULL); int32_t L_28 = V_2; V_4 = ((t740*)SZArrayNew(t740_TI_var, L_28)); t832 * L_29 = m4736(__this, NULL); t740* L_30 = m4457(L_29, NULL); t740* L_31 = V_4; int32_t L_32 = V_1; m3917(NULL, (t144 *)(t144 *)L_30, 0, (t144 *)(t144 *)L_31, 0, L_32, NULL); t832 * L_33 = m4736(__this, NULL); t740* L_34 = m4455(L_33, NULL); t740* L_35 = V_4; int32_t L_36 = V_1; int32_t L_37 = V_0; m3917(NULL, (t144 *)(t144 *)L_34, 0, (t144 *)(t144 *)L_35, L_36, L_37, NULL); t832 * L_38 = m4736(__this, NULL); t740* L_39 = V_4; m4462(L_38, L_39, NULL); return; } } extern "C" void m4790 (t888 * __this, const MethodInfo* method) { { VirtActionInvoker0::Invoke(24 /* System.Void Mono.Security.Protocol.Tls.Handshake.Client.TlsServerHello::ProcessAsTls1() */, __this); return; } } extern TypeInfo* t841_TI_var; extern TypeInfo* t876_TI_var; extern Il2CppCodeGenString* _stringLiteral706; extern "C" void m4791 (t888 * __this, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t841_TI_var = il2cpp_codegen_type_info_from_index(523); t876_TI_var = il2cpp_codegen_type_info_from_index(520); _stringLiteral706 = il2cpp_codegen_string_literal_from_index(706); s_Il2CppMethodIntialized = true; } int32_t V_0 = 0; int16_t V_1 = 0; { int16_t L_0 = m4718(__this, NULL); m4792(__this, L_0, NULL); t740* L_1 = m4720(__this, ((int32_t)32), NULL); __this->f10 = L_1; uint8_t L_2 = m4717(__this, NULL); V_0 = L_2; int32_t L_3 = V_0; if ((((int32_t)L_3) <= ((int32_t)0))) { goto IL_0076; } } { int32_t L_4 = V_0; t740* L_5 = m4720(__this, L_4, NULL); __this->f11 = L_5; t832 * L_6 = m4736(__this, NULL); t848 * L_7 = m4439(L_6, NULL); t35* L_8 = m4679(L_7, NULL); t740* L_9 = (__this->f11); IL2CPP_RUNTIME_CLASS_INIT(t841_TI_var); m4420(NULL, L_8, L_9, NULL); t832 * L_10 = m4736(__this, NULL); t740* L_11 = (__this->f11); t832 * L_12 = m4736(__this, NULL); t740* L_13 = m4434(L_12, NULL); bool L_14 = m4742(NULL, L_11, L_13, NULL); m4427(L_10, L_14, NULL); goto IL_0082; } IL_0076: { t832 * L_15 = m4736(__this, NULL); m4427(L_15, 0, NULL); } IL_0082: { int16_t L_16 = m4718(__this, NULL); V_1 = L_16; t832 * L_17 = m4736(__this, NULL); t833 * L_18 = m4448(L_17, NULL); int16_t L_19 = V_1; int32_t L_20 = m4389(L_18, L_19, NULL); if ((!(((uint32_t)L_20) == ((uint32_t)(-1))))) { goto IL_00ad; } } { t876 * L_21 = (t876 *)il2cpp_codegen_object_new (t876_TI_var); m4691(L_21, ((int32_t)71), _stringLiteral706, NULL); il2cpp_codegen_raise_exception((Il2CppCodeGenException*)L_21); } IL_00ad: { t832 * L_22 = m4736(__this, NULL); t833 * L_23 = m4448(L_22, NULL); int16_t L_24 = V_1; t829 * L_25 = m4382(L_23, L_24, NULL); __this->f12 = L_25; uint8_t L_26 = m4717(__this, NULL); __this->f9 = L_26; return; } } extern TypeInfo* t876_TI_var; extern Il2CppCodeGenString* _stringLiteral647; extern "C" void m4792 (t888 * __this, int16_t p0, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t876_TI_var = il2cpp_codegen_type_info_from_index(520); _stringLiteral647 = il2cpp_codegen_string_literal_from_index(647); s_Il2CppMethodIntialized = true; } int32_t V_0 = {0}; { t832 * L_0 = m4736(__this, NULL); int16_t L_1 = p0; int32_t L_2 = m4479(L_0, L_1, NULL); V_0 = L_2; int32_t L_3 = V_0; t832 * L_4 = m4736(__this, NULL); int32_t L_5 = m4432(L_4, NULL); int32_t L_6 = V_0; if ((((int32_t)((int32_t)((int32_t)L_3&(int32_t)L_5))) == ((int32_t)L_6))) { goto IL_003b; } } { t832 * L_7 = m4736(__this, NULL); int32_t L_8 = m4432(L_7, NULL); if ((!(((uint32_t)((int32_t)((int32_t)L_8&(int32_t)((int32_t)-1073741824)))) == ((uint32_t)((int32_t)-1073741824))))) { goto IL_0079; } } IL_003b: { t832 * L_9 = m4736(__this, NULL); int32_t L_10 = V_0; m4431(L_9, L_10, NULL); t832 * L_11 = m4736(__this, NULL); t833 * L_12 = m4448(L_11, NULL); m4387(L_12, NULL); t832 * L_13 = m4736(__this, NULL); m4449(L_13, (t833 *)NULL, NULL); t832 * L_14 = m4736(__this, NULL); int32_t L_15 = V_0; t833 * L_16 = m4394(NULL, L_15, NULL); m4449(L_14, L_16, NULL); goto IL_0086; } IL_0079: { t876 * L_17 = (t876 *)il2cpp_codegen_object_new (t876_TI_var); m4691(L_17, ((int32_t)70), _stringLiteral647, NULL); il2cpp_codegen_raise_exception((Il2CppCodeGenException*)L_17); } IL_0086: { return; } } extern "C" void m4793 (t889 * __this, t832 * p0, t740* p1, const MethodInfo* method) { { t832 * L_0 = p0; t740* L_1 = p1; m4735(__this, L_0, ((int32_t)14), L_1, NULL); return; } } extern "C" void m4794 (t889 * __this, const MethodInfo* method) { { return; } } extern "C" void m4795 (t889 * __this, const MethodInfo* method) { { return; } } extern "C" void m4796 (t890 * __this, t832 * p0, t740* p1, const MethodInfo* method) { { t832 * L_0 = p0; t740* L_1 = p1; m4735(__this, L_0, ((int32_t)12), L_1, NULL); m4800(__this, NULL); return; } } extern "C" void m4797 (t890 * __this, const MethodInfo* method) { { m4740(__this, NULL); t832 * L_0 = m4736(__this, NULL); t847 * L_1 = m4438(L_0, NULL); m4695(L_1, 1, NULL); t832 * L_2 = m4736(__this, NULL); t847 * L_3 = m4438(L_2, NULL); t877 L_4 = (__this->f9); m4700(L_3, L_4, NULL); t832 * L_5 = m4736(__this, NULL); t847 * L_6 = m4438(L_5, NULL); t740* L_7 = (__this->f10); m4701(L_6, L_7, NULL); return; } } extern "C" void m4798 (t890 * __this, const MethodInfo* method) { { VirtActionInvoker0::Invoke(24 /* System.Void Mono.Security.Protocol.Tls.Handshake.Client.TlsServerKeyExchange::ProcessAsTls1() */, __this); return; } } extern TypeInfo* t877_TI_var; extern "C" void m4799 (t890 * __this, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t877_TI_var = il2cpp_codegen_type_info_from_index(455); s_Il2CppMethodIntialized = true; } t877 V_0 = {0}; { Initobj (t877_TI_var, (&V_0)); t877 L_0 = V_0; __this->f9 = L_0; t877 * L_1 = &(__this->f9); int16_t L_2 = m4718(__this, NULL); t740* L_3 = m4720(__this, L_2, NULL); L_1->f6 = L_3; t877 * L_4 = &(__this->f9); int16_t L_5 = m4718(__this, NULL); t740* L_6 = m4720(__this, L_5, NULL); L_4->f7 = L_6; int16_t L_7 = m4718(__this, NULL); t740* L_8 = m4720(__this, L_7, NULL); __this->f10 = L_8; return; } } extern TypeInfo* t824_TI_var; extern TypeInfo* t850_TI_var; extern TypeInfo* t876_TI_var; extern Il2CppCodeGenString* _stringLiteral707; extern "C" void m4800 (t890 * __this, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t824_TI_var = il2cpp_codegen_type_info_from_index(541); t850_TI_var = il2cpp_codegen_type_info_from_index(498); t876_TI_var = il2cpp_codegen_type_info_from_index(520); _stringLiteral707 = il2cpp_codegen_string_literal_from_index(707); s_Il2CppMethodIntialized = true; } t824 * V_0 = {0}; int32_t V_1 = 0; t850 * V_2 = {0}; bool V_3 = false; { t824 * L_0 = (t824 *)il2cpp_codegen_object_new (t824_TI_var); m4321(L_0, NULL); V_0 = L_0; t877 * L_1 = &(__this->f9); t740* L_2 = (L_1->f6); t877 * L_3 = &(__this->f9); t740* L_4 = (L_3->f7); V_1 = ((int32_t)((int32_t)((int32_t)((int32_t)(((int32_t)((int32_t)(((t144 *)L_2)->max_length))))+(int32_t)(((int32_t)((int32_t)(((t144 *)L_4)->max_length))))))+(int32_t)4)); t850 * L_5 = (t850 *)il2cpp_codegen_object_new (t850_TI_var); m4707(L_5, NULL); V_2 = L_5; t850 * L_6 = V_2; t832 * L_7 = m4736(__this, NULL); t740* L_8 = m4459(L_7, NULL); m4725(L_6, L_8, NULL); t850 * L_9 = V_2; t740* L_10 = m4727(__this, NULL); int32_t L_11 = V_1; VirtActionInvoker3< t740*, int32_t, int32_t >::Invoke(18 /* System.Void Mono.Security.Protocol.Tls.TlsStream::Write(System.Byte[],System.Int32,System.Int32) */, L_9, L_10, 0, L_11); t824 * L_12 = V_0; t850 * L_13 = V_2; t740* L_14 = m4727(L_13, NULL); m4883(L_12, L_14, NULL); t850 * L_15 = V_2; m4726(L_15, NULL); t824 * L_16 = V_0; t832 * L_17 = m4736(__this, NULL); t847 * L_18 = m4438(L_17, NULL); t794 * L_19 = m4698(L_18, NULL); t740* L_20 = (__this->f10); bool L_21 = m4326(L_16, L_19, L_20, NULL); V_3 = L_21; bool L_22 = V_3; if (L_22) { goto IL_008c; } } { t876 * L_23 = (t876 *)il2cpp_codegen_object_new (t876_TI_var); m4691(L_23, ((int32_t)50), _stringLiteral707, NULL); il2cpp_codegen_raise_exception((Il2CppCodeGenException*)L_23); } IL_008c: { return; } } extern "C" void m4801 (t891 * __this, t17 * p0, t22 p1, const MethodInfo* method) { __this->f0 = (methodPointerType)((MethodInfo*)p1.f0)->method; __this->f3 = p1; __this->f2 = p0; } extern "C" bool m4802 (t891 * __this, t767 * p0, int32_t p1, const MethodInfo* method) { if(__this->f9 != NULL) { m4802((t891 *)__this->f9,p0, p1, method); } il2cpp_codegen_raise_execution_engine_exception_if_method_is_not_found((MethodInfo*)(__this->f3.f0)); bool ___methodIsStatic = MethodIsStatic((MethodInfo*)(__this->f3.f0)); if (__this->f2 != NULL && ___methodIsStatic) { typedef bool (*FunctionPointerType) (t17 *, t17 * __this, t767 * p0, int32_t p1, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(NULL,__this->f2,p0, p1,(MethodInfo*)(__this->f3.f0)); } else if (__this->f2 != NULL || ___methodIsStatic) { typedef bool (*FunctionPointerType) (t17 * __this, t767 * p0, int32_t p1, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(__this->f2,p0, p1,(MethodInfo*)(__this->f3.f0)); } else { typedef bool (*FunctionPointerType) (t17 * __this, int32_t p1, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(p0, p1,(MethodInfo*)(__this->f3.f0)); } } extern "C" bool pinvoke_delegate_wrapper_t891(Il2CppObject* delegate, t767 * p0, int32_t p1) { // Marshaling of parameter 'p0' to native representation t767 * _p0_marshaled = { 0 }; il2cpp_codegen_raise_exception((Il2CppCodeGenException*)il2cpp_codegen_get_not_supported_exception("Cannot marshal type 'Mono.Math.BigInteger'.")); } extern TypeInfo* t769_TI_var; extern "C" t17 * m4803 (t891 * __this, t767 * p0, int32_t p1, t354 * p2, t17 * p3, const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if (!s_Il2CppMethodIntialized) { t769_TI_var = il2cpp_codegen_type_info_from_index(564); s_Il2CppMethodIntialized = true; } void *__d_args[3] = {0}; __d_args[0] = p0; __d_args[1] = Box(t769_TI_var, &p1); return (t17 *)il2cpp_delegate_begin_invoke((Il2CppDelegate*)__this, __d_args, (Il2CppDelegate*)p2, (Il2CppObject*)p3); } extern "C" bool m4804 (t891 * __this, t17 * p0, const MethodInfo* method) { Il2CppObject *__result = il2cpp_delegate_end_invoke((Il2CppAsyncResult*) p0, 0); return *(bool*)UnBox ((Il2CppCodeGenObject*)__result); } extern "C" void m4805 (t867 * __this, t17 * p0, t22 p1, const MethodInfo* method) { __this->f0 = (methodPointerType)((MethodInfo*)p1.f0)->method; __this->f3 = p1; __this->f2 = p0; } extern "C" bool m4806 (t867 * __this, t875 * p0, t553* p1, const MethodInfo* method) { if(__this->f9 != NULL) { m4806((t867 *)__this->f9,p0, p1, method); } il2cpp_codegen_raise_execution_engine_exception_if_method_is_not_found((MethodInfo*)(__this->f3.f0)); bool ___methodIsStatic = MethodIsStatic((MethodInfo*)(__this->f3.f0)); if (__this->f2 != NULL && ___methodIsStatic) { typedef bool (*FunctionPointerType) (t17 *, t17 * __this, t875 * p0, t553* p1, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(NULL,__this->f2,p0, p1,(MethodInfo*)(__this->f3.f0)); } else if (__this->f2 != NULL || ___methodIsStatic) { typedef bool (*FunctionPointerType) (t17 * __this, t875 * p0, t553* p1, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(__this->f2,p0, p1,(MethodInfo*)(__this->f3.f0)); } else { typedef bool (*FunctionPointerType) (t17 * __this, t553* p1, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(p0, p1,(MethodInfo*)(__this->f3.f0)); } } extern "C" bool pinvoke_delegate_wrapper_t867(Il2CppObject* delegate, t875 * p0, t553* p1) { // Marshaling of parameter 'p0' to native representation t875 * _p0_marshaled = { 0 }; il2cpp_codegen_raise_exception((Il2CppCodeGenException*)il2cpp_codegen_get_not_supported_exception("Cannot marshal type 'System.Security.Cryptography.X509Certificates.X509Certificate'.")); } extern "C" t17 * m4807 (t867 * __this, t875 * p0, t553* p1, t354 * p2, t17 * p3, const MethodInfo* method) { void *__d_args[3] = {0}; __d_args[0] = p0; __d_args[1] = p1; return (t17 *)il2cpp_delegate_begin_invoke((Il2CppDelegate*)__this, __d_args, (Il2CppDelegate*)p2, (Il2CppObject*)p3); } extern "C" bool m4808 (t867 * __this, t17 * p0, const MethodInfo* method) { Il2CppObject *__result = il2cpp_delegate_end_invoke((Il2CppAsyncResult*) p0, 0); return *(bool*)UnBox ((Il2CppCodeGenObject*)__result); } extern "C" void m4809 (t868 * __this, t17 * p0, t22 p1, const MethodInfo* method) { __this->f0 = (methodPointerType)((MethodInfo*)p1.f0)->method; __this->f3 = p1; __this->f2 = p0; } extern "C" t865 * m4810 (t868 * __this, t798 * p0, const MethodInfo* method) { if(__this->f9 != NULL) { m4810((t868 *)__this->f9,p0, method); } il2cpp_codegen_raise_execution_engine_exception_if_method_is_not_found((MethodInfo*)(__this->f3.f0)); bool ___methodIsStatic = MethodIsStatic((MethodInfo*)(__this->f3.f0)); if (__this->f2 != NULL && ___methodIsStatic) { typedef t865 * (*FunctionPointerType) (t17 *, t17 * __this, t798 * p0, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(NULL,__this->f2,p0,(MethodInfo*)(__this->f3.f0)); } else if (__this->f2 != NULL || ___methodIsStatic) { typedef t865 * (*FunctionPointerType) (t17 * __this, t798 * p0, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(__this->f2,p0,(MethodInfo*)(__this->f3.f0)); } else { typedef t865 * (*FunctionPointerType) (t17 * __this, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(p0,(MethodInfo*)(__this->f3.f0)); } } extern "C" t865 * pinvoke_delegate_wrapper_t868(Il2CppObject* delegate, t798 * p0) { // Marshaling of parameter 'p0' to native representation t798 * _p0_marshaled = { 0 }; il2cpp_codegen_raise_exception((Il2CppCodeGenException*)il2cpp_codegen_get_not_supported_exception("Cannot marshal type 'Mono.Security.X509.X509CertificateCollection'.")); } extern "C" t17 * m4811 (t868 * __this, t798 * p0, t354 * p1, t17 * p2, const MethodInfo* method) { void *__d_args[2] = {0}; __d_args[0] = p0; return (t17 *)il2cpp_delegate_begin_invoke((Il2CppDelegate*)__this, __d_args, (Il2CppDelegate*)p1, (Il2CppObject*)p2); } extern "C" t865 * m4812 (t868 * __this, t17 * p0, const MethodInfo* method) { Il2CppObject *__result = il2cpp_delegate_end_invoke((Il2CppAsyncResult*) p0, 0); return (t865 *)__result; } extern "C" void m4813 (t853 * __this, t17 * p0, t22 p1, const MethodInfo* method) { __this->f0 = (methodPointerType)((MethodInfo*)p1.f0)->method; __this->f3 = p1; __this->f2 = p0; } extern "C" t875 * m4814 (t853 * __this, t874 * p0, t875 * p1, t35* p2, t874 * p3, const MethodInfo* method) { if(__this->f9 != NULL) { m4814((t853 *)__this->f9,p0, p1, p2, p3, method); } il2cpp_codegen_raise_execution_engine_exception_if_method_is_not_found((MethodInfo*)(__this->f3.f0)); bool ___methodIsStatic = MethodIsStatic((MethodInfo*)(__this->f3.f0)); if (__this->f2 != NULL && ___methodIsStatic) { typedef t875 * (*FunctionPointerType) (t17 *, t17 * __this, t874 * p0, t875 * p1, t35* p2, t874 * p3, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(NULL,__this->f2,p0, p1, p2, p3,(MethodInfo*)(__this->f3.f0)); } else if (__this->f2 != NULL || ___methodIsStatic) { typedef t875 * (*FunctionPointerType) (t17 * __this, t874 * p0, t875 * p1, t35* p2, t874 * p3, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(__this->f2,p0, p1, p2, p3,(MethodInfo*)(__this->f3.f0)); } else { typedef t875 * (*FunctionPointerType) (t17 * __this, t875 * p1, t35* p2, t874 * p3, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(p0, p1, p2, p3,(MethodInfo*)(__this->f3.f0)); } } extern "C" t875 * pinvoke_delegate_wrapper_t853(Il2CppObject* delegate, t874 * p0, t875 * p1, t35* p2, t874 * p3) { // Marshaling of parameter 'p0' to native representation t874 * _p0_marshaled = { 0 }; il2cpp_codegen_raise_exception((Il2CppCodeGenException*)il2cpp_codegen_get_not_supported_exception("Cannot marshal type 'System.Security.Cryptography.X509Certificates.X509CertificateCollection'.")); } extern "C" t17 * m4815 (t853 * __this, t874 * p0, t875 * p1, t35* p2, t874 * p3, t354 * p4, t17 * p5, const MethodInfo* method) { void *__d_args[5] = {0}; __d_args[0] = p0; __d_args[1] = p1; __d_args[2] = p2; __d_args[3] = p3; return (t17 *)il2cpp_delegate_begin_invoke((Il2CppDelegate*)__this, __d_args, (Il2CppDelegate*)p4, (Il2CppObject*)p5); } extern "C" t875 * m4816 (t853 * __this, t17 * p0, const MethodInfo* method) { Il2CppObject *__result = il2cpp_delegate_end_invoke((Il2CppAsyncResult*) p0, 0); return (t875 *)__result; } extern "C" void m4817 (t854 * __this, t17 * p0, t22 p1, const MethodInfo* method) { __this->f0 = (methodPointerType)((MethodInfo*)p1.f0)->method; __this->f3 = p1; __this->f2 = p0; } extern "C" t892 * m4818 (t854 * __this, t875 * p0, t35* p1, const MethodInfo* method) { if(__this->f9 != NULL) { m4818((t854 *)__this->f9,p0, p1, method); } il2cpp_codegen_raise_execution_engine_exception_if_method_is_not_found((MethodInfo*)(__this->f3.f0)); bool ___methodIsStatic = MethodIsStatic((MethodInfo*)(__this->f3.f0)); if (__this->f2 != NULL && ___methodIsStatic) { typedef t892 * (*FunctionPointerType) (t17 *, t17 * __this, t875 * p0, t35* p1, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(NULL,__this->f2,p0, p1,(MethodInfo*)(__this->f3.f0)); } else if (__this->f2 != NULL || ___methodIsStatic) { typedef t892 * (*FunctionPointerType) (t17 * __this, t875 * p0, t35* p1, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(__this->f2,p0, p1,(MethodInfo*)(__this->f3.f0)); } else { typedef t892 * (*FunctionPointerType) (t17 * __this, t35* p1, const MethodInfo* method); return ((FunctionPointerType)__this->f0)(p0, p1,(MethodInfo*)(__this->f3.f0)); } } extern "C" t892 * pinvoke_delegate_wrapper_t854(Il2CppObject* delegate, t875 * p0, t35* p1) { // Marshaling of parameter 'p0' to native representation t875 * _p0_marshaled = { 0 }; il2cpp_codegen_raise_exception((Il2CppCodeGenException*)il2cpp_codegen_get_not_supported_exception("Cannot marshal type 'System.Security.Cryptography.X509Certificates.X509Certificate'.")); } extern "C" t17 * m4819 (t854 * __this, t875 * p0, t35* p1, t354 * p2, t17 * p3, const MethodInfo* method) { void *__d_args[3] = {0}; __d_args[0] = p0; __d_args[1] = p1; return (t17 *)il2cpp_delegate_begin_invoke((Il2CppDelegate*)__this, __d_args, (Il2CppDelegate*)p2, (Il2CppObject*)p3); } extern "C" t892 * m4820 (t854 * __this, t17 * p0, const MethodInfo* method) { Il2CppObject *__result = il2cpp_delegate_end_invoke((Il2CppAsyncResult*) p0, 0); return (t892 *)__result; } #ifdef __clang__ #pragma clang diagnostic pop #endif
[ "ream@uwec.edu" ]
ream@uwec.edu
90054aa3307a029d1ba7bd1076bae672647ffe40
bddb40149f9028297d9b4f3f6b77514cadac9bca
/Source/Jeremy/FBTool/FrameWork/Communication3/FC3_debug_message.cpp
89b27436cea75435dfae76ba969469bc84df1773
[]
no_license
JamesTerm/GremlinGames
91d61a50d0926b8e95cad21053ba2cf6c3316003
fd0366af007bff8cffe4941b4bb5bb16948a8c66
refs/heads/master
2021-10-20T21:15:53.121770
2019-03-01T15:45:58
2019-03-01T15:45:58
173,261,435
0
1
null
null
null
null
UTF-8
C++
false
false
3,100
cpp
#include "StdAfx.h" #include "FrameWork.Communication3.h" using namespace FrameWork::Communication3::debug; message::message( const std::pair< DWORD, DWORD > sizes ) : m_ref( 1 ), m_p_category( NULL ), m_p_message( NULL ), FrameWork::Communication3::implementation::message( header_size + ( sizes.first + sizes.second + 2 ) * sizeof( wchar_t ) ) { // Error if ( !FrameWork::Communication3::implementation::message::error() ) { // Set the size type() = message_type_debug; // Get the header pointer m_p_header = (header*)ptr(); // Setup the header m_p_header->m_category_size = sizes.first; m_p_header->m_message_size = sizes.second; // Setup the string pointers m_p_category = (wchar_t*)ptr( header_size ); m_p_message = m_p_category + sizes.first + 1; } } // Internal use only :) message::message( const DWORD block_id, const DWORD addr ) : m_ref( 1 ), m_p_category( NULL ), m_p_message( NULL ), FrameWork::Communication3::implementation::message( block_id, addr ) { // Check the size and the type if ( !FrameWork::Communication3::implementation::message::error() ) { // If the type is correct, set it up. if ( type() == message_type_debug ) { // Get the header pointer m_p_header = (header*)ptr(); // Setup the string pointers m_p_category = (wchar_t*)ptr( header_size ); m_p_message = m_p_category + m_p_header->m_category_size + 1; } } } message::~message( void ) { } // Is there an error in this message, most likely caused by a failed allocation or transmission bool message::error( void ) const { if ( FrameWork::Communication3::implementation::message::error() ) return true; return ( type() != message_type_debug ); } // Reference counting const long message::addref( void ) const { // One more person cares about me return ::_InterlockedIncrement( &m_ref ); } const long message::release( void ) const { // Delete ? const long ret = ::_InterlockedDecrement( &m_ref ); assert( ret >= 0 ); if ( !ret ) delete this; return ret; } const long message::refcount( void ) const { return m_ref; } // Parse this message const bool message::parse( FrameWork::xml::node *p_node ) const { // Parse the string. return FrameWork::xml::load_from_string( (const char*)ptr(), p_node ); } const wchar_t* message::category( void ) const { assert( !error() ); return m_p_category; } wchar_t* message::category( void ) { assert( !error() ); return m_p_category; } const wchar_t* message::content( void ) const { assert( !error() ); return m_p_message; } wchar_t* message::content( void ) { assert( !error() ); return m_p_message; } // This ensures that people can delete the read_with_info structs returned above correctly void* message::operator new ( const size_t size ) { return ::malloc( size ); } void message::operator delete ( void* ptr ) { ::free( ptr ); } void* message::operator new [] ( const size_t size ) { return ::malloc( size ); } void message::operator delete [] ( void* ptr ) { ::free( ptr ); }
[ "james@e2c3bcc0-b32a-0410-840c-db224dcf21cb" ]
james@e2c3bcc0-b32a-0410-840c-db224dcf21cb
681b6d92f354b33eca95cee187a0c7013c174060
c3203a11c0ab4f9e3a853fcd658166990cf8487b
/URI/Level1/1960/ideone_ZRcD9R.cpp
0f83eb3ab05a127ef4db502e5fd4e95c9f7a3598
[]
no_license
betogaona7/CompetitiveProgramming
3d37688f028593a2314c676f3e01cc0e5b6d1d8e
5ac5b7bf13941cc56f28e595eeb33acfa98650b3
refs/heads/master
2021-01-12T06:09:24.069374
2020-04-23T15:02:16
2020-04-23T15:02:16
77,318,404
0
0
null
null
null
null
UTF-8
C++
false
false
692
cpp
#include <stdio.h> #include <iostream> #include <bits/stdc++.h> using namespace std; main(){ map <int, string> r; r[1] = "I"; r[2] = "II"; r[3] = "III"; r[4] = "IV"; r[5] = "V"; r[6] = "VI"; r[7] = "VII"; r[8] = "VIII"; r[9] = "IX"; r[10] = "X"; r[20] = "XX"; r[30] = "XXX"; r[40] = "XL"; r[50] = "L"; r[60] = "LX"; r[70] = "LXX"; r[80] = "LXXX"; r[90] = "XC"; r[100] = "C"; r[200] = "CC"; r[300] = "CCC"; r[400] = "CD"; r[500] = "D"; r[600] = "DC"; r[700] = "DCC"; r[800] = "DCCC"; r[900] = "CM"; int num, c, d; scanf("%d", &num); c = (num/100) * 100; num -= c; d = (num/10) * 10; num -= d; cout << r[c] << r[d] << r[num] << "\n"; return 0; }
[ "albertoo_3c@hotmail.com" ]
albertoo_3c@hotmail.com
21b541d855cf34cf33a6b8d4152afb7c7b8dbdc9
a695bb7e12f830a2159035002b993973d3e993ee
/cpp/queue/loopqueue.h
481cf01c8152b26105b8fe74eca48b8c63bc1a16
[]
no_license
shiwk/takeiteasy
c7d74303c93534196bb20c02e6ec73515c12268d
c9f3db88964782ab908e05bf5acde614ff918884
refs/heads/master
2022-11-30T20:18:20.550346
2022-11-20T15:12:27
2022-11-20T15:12:27
210,109,243
0
0
null
null
null
null
UTF-8
C++
false
false
374
h
// // Created by swk on 2019-06-25. // #ifndef CPP_LTC_LOOPQUEUE_H #define CPP_LTC_LOOPQUEUE_H namespace happycoding{ class loopqueue { public: int dequeue(); bool enqueue(int queue); explicit loopqueue(int size); private: int head; int tail; int size; int* arr; }; } #endif //CPP_LTC_LOOPQUEUE_H
[ "shiwk@tju.edu.cn" ]
shiwk@tju.edu.cn
0a27c7b0f0efa4f2c456e055acbfeac1ecdfeb05
005cb1c69358d301f72c6a6890ffeb430573c1a1
/Pods/Headers/Private/GeoFeatures/boost/mpl/aux_/preprocessed/no_ttp/apply_fwd.hpp
c441ba56ae3943db43a95d786caafb921539568c
[ "Apache-2.0" ]
permissive
TheClimateCorporation/DemoCLUs
05588dcca687cc5854755fad72f07759f81fe673
f343da9b41807694055151a721b497cf6267f829
refs/heads/master
2021-01-10T15:10:06.021498
2016-04-19T20:31:34
2016-04-19T20:31:34
51,960,444
0
0
null
null
null
null
UTF-8
C++
false
false
96
hpp
../../../../../../../../GeoFeatures/GeoFeatures/boost/mpl/aux_/preprocessed/no_ttp/apply_fwd.hpp
[ "tommy.rogers@climate.com" ]
tommy.rogers@climate.com
65720dae8c9f77a86231241a8c336f743bcac76e
92a63b0e9fa1c5692eecc6d811ffe43ac98cb6d2
/include/google/protobuf/any_test.pb.h
47c071ed9bb3dfcf28461cd79383b44dfc0a3115
[ "MIT" ]
permissive
zhouyunpeng/framework
75f1d465388ab9c7d171e19f13a654753273a728
500b73cf72de332968fac85b113c6a8d51fa7401
refs/heads/master
2020-11-29T04:24:40.868421
2019-12-25T01:18:22
2019-12-25T01:19:05
230,021,307
7
1
null
null
null
null
UTF-8
C++
false
true
13,722
h
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/any_test.proto #ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_5ftest_2eproto #define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_5ftest_2eproto #include <limits> #include <string> #include <google/protobuf/port_def.inc> #if PROTOBUF_VERSION < 3011000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif #if 3011000 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif #include <google/protobuf/port_undef.inc> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #include <google/protobuf/generated_message_table_driven.h> #include <google/protobuf/generated_message_util.h> #include <google/protobuf/inlined_string_field.h> #include <google/protobuf/metadata.h> #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/message.h> #include <google/protobuf/repeated_field.h> // IWYU pragma: export #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/any.pb.h> // @@protoc_insertion_point(includes) #include <google/protobuf/port_def.inc> #define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fany_5ftest_2eproto PROTOBUF_NAMESPACE_OPEN namespace internal { class AnyMetadata; } // namespace internal PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct TableStruct_google_2fprotobuf_2fany_5ftest_2eproto { static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] PROTOBUF_SECTION_VARIABLE(protodesc_cold); static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[] PROTOBUF_SECTION_VARIABLE(protodesc_cold); static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] PROTOBUF_SECTION_VARIABLE(protodesc_cold); static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_5ftest_2eproto; namespace protobuf_unittest { class TestAny; class TestAnyDefaultTypeInternal; extern TestAnyDefaultTypeInternal _TestAny_default_instance_; } // namespace protobuf_unittest PROTOBUF_NAMESPACE_OPEN template<> ::protobuf_unittest::TestAny* Arena::CreateMaybeMessage<::protobuf_unittest::TestAny>(Arena*); PROTOBUF_NAMESPACE_CLOSE namespace protobuf_unittest { // =================================================================== class TestAny : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.TestAny) */ { public: TestAny(); virtual ~TestAny(); TestAny(const TestAny& from); TestAny(TestAny&& from) noexcept : TestAny() { *this = ::std::move(from); } inline TestAny& operator=(const TestAny& from) { CopyFrom(from); return *this; } inline TestAny& operator=(TestAny&& from) noexcept { if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); } return *this; } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { return GetMetadataStatic().descriptor; } static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } static const TestAny& default_instance(); static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const TestAny* internal_default_instance() { return reinterpret_cast<const TestAny*>( &_TestAny_default_instance_); } static constexpr int kIndexInFileMessages = 0; friend void swap(TestAny& a, TestAny& b) { a.Swap(&b); } inline void Swap(TestAny* other) { if (other == this) return; InternalSwap(other); } // implements Message ---------------------------------------------- inline TestAny* New() const final { return CreateMaybeMessage<TestAny>(nullptr); } TestAny* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { return CreateMaybeMessage<TestAny>(arena); } void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; void CopyFrom(const TestAny& from); void MergeFrom(const TestAny& from); PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; size_t ByteSizeLong() const final; const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; int GetCachedSize() const final { return _cached_size_.Get(); } private: inline void SharedCtor(); inline void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(TestAny* other); friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "protobuf_unittest.TestAny"; } private: inline ::PROTOBUF_NAMESPACE_ID::Arena* GetArenaNoVirtual() const { return nullptr; } inline void* MaybeArenaPtr() const { return nullptr; } public: ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fany_5ftest_2eproto); return ::descriptor_table_google_2fprotobuf_2fany_5ftest_2eproto.file_level_metadata[kIndexInFileMessages]; } public: // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- enum : int { kRepeatedAnyValueFieldNumber = 3, kAnyValueFieldNumber = 2, kInt32ValueFieldNumber = 1, }; // repeated .google.protobuf.Any repeated_any_value = 3; int repeated_any_value_size() const; private: int _internal_repeated_any_value_size() const; public: void clear_repeated_any_value(); PROTOBUF_NAMESPACE_ID::Any* mutable_repeated_any_value(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Any >* mutable_repeated_any_value(); private: const PROTOBUF_NAMESPACE_ID::Any& _internal_repeated_any_value(int index) const; PROTOBUF_NAMESPACE_ID::Any* _internal_add_repeated_any_value(); public: const PROTOBUF_NAMESPACE_ID::Any& repeated_any_value(int index) const; PROTOBUF_NAMESPACE_ID::Any* add_repeated_any_value(); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Any >& repeated_any_value() const; // .google.protobuf.Any any_value = 2; bool has_any_value() const; private: bool _internal_has_any_value() const; public: void clear_any_value(); const PROTOBUF_NAMESPACE_ID::Any& any_value() const; PROTOBUF_NAMESPACE_ID::Any* release_any_value(); PROTOBUF_NAMESPACE_ID::Any* mutable_any_value(); void set_allocated_any_value(PROTOBUF_NAMESPACE_ID::Any* any_value); private: const PROTOBUF_NAMESPACE_ID::Any& _internal_any_value() const; PROTOBUF_NAMESPACE_ID::Any* _internal_mutable_any_value(); public: // int32 int32_value = 1; void clear_int32_value(); ::PROTOBUF_NAMESPACE_ID::int32 int32_value() const; void set_int32_value(::PROTOBUF_NAMESPACE_ID::int32 value); private: ::PROTOBUF_NAMESPACE_ID::int32 _internal_int32_value() const; void _internal_set_int32_value(::PROTOBUF_NAMESPACE_ID::int32 value); public: // @@protoc_insertion_point(class_scope:protobuf_unittest.TestAny) private: class _Internal; ::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Any > repeated_any_value_; PROTOBUF_NAMESPACE_ID::Any* any_value_; ::PROTOBUF_NAMESPACE_ID::int32 int32_value_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; friend struct ::TableStruct_google_2fprotobuf_2fany_5ftest_2eproto; }; // =================================================================== // =================================================================== #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif // __GNUC__ // TestAny // int32 int32_value = 1; inline void TestAny::clear_int32_value() { int32_value_ = 0; } inline ::PROTOBUF_NAMESPACE_ID::int32 TestAny::_internal_int32_value() const { return int32_value_; } inline ::PROTOBUF_NAMESPACE_ID::int32 TestAny::int32_value() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestAny.int32_value) return _internal_int32_value(); } inline void TestAny::_internal_set_int32_value(::PROTOBUF_NAMESPACE_ID::int32 value) { int32_value_ = value; } inline void TestAny::set_int32_value(::PROTOBUF_NAMESPACE_ID::int32 value) { _internal_set_int32_value(value); // @@protoc_insertion_point(field_set:protobuf_unittest.TestAny.int32_value) } // .google.protobuf.Any any_value = 2; inline bool TestAny::_internal_has_any_value() const { return this != internal_default_instance() && any_value_ != nullptr; } inline bool TestAny::has_any_value() const { return _internal_has_any_value(); } inline const PROTOBUF_NAMESPACE_ID::Any& TestAny::_internal_any_value() const { const PROTOBUF_NAMESPACE_ID::Any* p = any_value_; return p != nullptr ? *p : *reinterpret_cast<const PROTOBUF_NAMESPACE_ID::Any*>( &PROTOBUF_NAMESPACE_ID::_Any_default_instance_); } inline const PROTOBUF_NAMESPACE_ID::Any& TestAny::any_value() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestAny.any_value) return _internal_any_value(); } inline PROTOBUF_NAMESPACE_ID::Any* TestAny::release_any_value() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestAny.any_value) PROTOBUF_NAMESPACE_ID::Any* temp = any_value_; any_value_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::Any* TestAny::_internal_mutable_any_value() { if (any_value_ == nullptr) { auto* p = CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::Any>(GetArenaNoVirtual()); any_value_ = p; } return any_value_; } inline PROTOBUF_NAMESPACE_ID::Any* TestAny::mutable_any_value() { // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestAny.any_value) return _internal_mutable_any_value(); } inline void TestAny::set_allocated_any_value(PROTOBUF_NAMESPACE_ID::Any* any_value) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == nullptr) { delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(any_value_); } if (any_value) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = nullptr; if (message_arena != submessage_arena) { any_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, any_value, submessage_arena); } } else { } any_value_ = any_value; // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestAny.any_value) } // repeated .google.protobuf.Any repeated_any_value = 3; inline int TestAny::_internal_repeated_any_value_size() const { return repeated_any_value_.size(); } inline int TestAny::repeated_any_value_size() const { return _internal_repeated_any_value_size(); } inline PROTOBUF_NAMESPACE_ID::Any* TestAny::mutable_repeated_any_value(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestAny.repeated_any_value) return repeated_any_value_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Any >* TestAny::mutable_repeated_any_value() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestAny.repeated_any_value) return &repeated_any_value_; } inline const PROTOBUF_NAMESPACE_ID::Any& TestAny::_internal_repeated_any_value(int index) const { return repeated_any_value_.Get(index); } inline const PROTOBUF_NAMESPACE_ID::Any& TestAny::repeated_any_value(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestAny.repeated_any_value) return _internal_repeated_any_value(index); } inline PROTOBUF_NAMESPACE_ID::Any* TestAny::_internal_add_repeated_any_value() { return repeated_any_value_.Add(); } inline PROTOBUF_NAMESPACE_ID::Any* TestAny::add_repeated_any_value() { // @@protoc_insertion_point(field_add:protobuf_unittest.TestAny.repeated_any_value) return _internal_add_repeated_any_value(); } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::Any >& TestAny::repeated_any_value() const { // @@protoc_insertion_point(field_list:protobuf_unittest.TestAny.repeated_any_value) return repeated_any_value_; } #ifdef __GNUC__ #pragma GCC diagnostic pop #endif // __GNUC__ // @@protoc_insertion_point(namespace_scope) } // namespace protobuf_unittest // @@protoc_insertion_point(global_scope) #include <google/protobuf/port_undef.inc> #endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_5ftest_2eproto
[ "zyp@hoteamsoft.com" ]
zyp@hoteamsoft.com