blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
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
sequencelengths
1
1
author_id
stringlengths
0
158
d3d3f3982ca289bbf1232c48490a1baa86c87742
5a6e95ea550c1ab70933db273782c79c520ac2ec
/SDK/src/mfc/appinit.cpp
0c8642ed12b040f10c2d8a336f359b6a1ace8405
[]
no_license
15831944/Longhorn_SDK_And_DDK_4074
ffa9ce6c99345a6c43a414dab9458e4c29f9eb2a
c07d26bb49ecfa056d00b1dffd8981f50e11c553
refs/heads/master
2023-03-21T09:27:53.770894
2020-10-10T03:34:29
2020-10-10T03:34:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,133
cpp
// This is a part of the Microsoft Foundation Classes C++ library. // Copyright (C) 1992-1998 Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Microsoft Foundation Classes Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Microsoft Foundation Classes product. #include "stdafx.h" #ifdef AFX_INIT_SEG #pragma code_seg(AFX_INIT_SEG) #endif #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// BOOL AFXAPI AfxWinInit(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { ASSERT(hPrevInstance == NULL); // handle critical errors and avoid Windows message boxes SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); // set resource handles AFX_MODULE_STATE* pModuleState = AfxGetModuleState(); pModuleState->m_hCurrentInstanceHandle = hInstance; pModuleState->m_hCurrentResourceHandle = hInstance; // fill in the initial state for the application CWinApp* pApp = AfxGetApp(); if (pApp != NULL) { // Windows specific initialization (not done if no CWinApp) pApp->m_hInstance = hInstance; pApp->m_hPrevInstance = hPrevInstance; pApp->m_lpCmdLine = lpCmdLine; pApp->m_nCmdShow = nCmdShow; pApp->SetCurrentHandles(); } // initialize thread specific data (for main thread) if (!afxContextIsDLL) AfxInitThread(); return TRUE; } /////////////////////////////////////////////////////////////////////////// // CWinApp Initialization void CWinApp::SetCurrentHandles() { ASSERT(this == afxCurrentWinApp); ASSERT(afxCurrentAppName == NULL); AFX_MODULE_STATE* pModuleState = _AFX_CMDTARGET_GETSTATE(); pModuleState->m_hCurrentInstanceHandle = m_hInstance; pModuleState->m_hCurrentResourceHandle = m_hInstance; // Note: there are a number of _tcsdup (aka strdup) calls that are // made here for the exe path, help file path, etc. In previous // versions of MFC, this memory was never freed. In this and future // versions this memory is automatically freed during CWinApp's // destructor. If you are freeing the memory yourself, you should // either remove the code or set the pointers to NULL after freeing // the memory. // get path of executable TCHAR szBuff[_MAX_PATH]; DWORD dwRet = ::GetModuleFileName(m_hInstance, szBuff, _MAX_PATH); ASSERT( dwRet != 0 && dwRet != _MAX_PATH ); if( dwRet == 0 || dwRet == _MAX_PATH ) AfxThrowUserException(); LPTSTR lpszExt = _tcsrchr(szBuff, '.'); ASSERT(lpszExt != NULL); if( lpszExt == NULL ) AfxThrowUserException(); ASSERT(*lpszExt == '.'); *lpszExt = 0; // no suffix TCHAR szExeName[_MAX_PATH]; TCHAR szTitle[256]; // get the exe title from the full path name [no extension] dwRet = AfxGetFileName(szBuff, szExeName, _MAX_PATH); ASSERT( dwRet == 0 ); if( dwRet != 0 ) AfxThrowUserException(); if (m_pszExeName == NULL) { BOOL bEnable = AfxEnableMemoryTracking(FALSE); m_pszExeName = _tcsdup(szExeName); // save non-localized name AfxEnableMemoryTracking(bEnable); } // m_pszAppName is the name used to present to the user if (m_pszAppName == NULL) { BOOL bEnable = AfxEnableMemoryTracking(FALSE); if (AfxLoadString(AFX_IDS_APP_TITLE, szTitle) != 0) m_pszAppName = _tcsdup(szTitle); // human readable title else m_pszAppName = _tcsdup(m_pszExeName); // same as EXE AfxEnableMemoryTracking(bEnable); } pModuleState->m_lpszCurrentAppName = m_pszAppName; ASSERT(afxCurrentAppName != NULL); // get path of .HLP file if (m_pszHelpFilePath == NULL) { lstrcpy(lpszExt, _T(".HLP")); BOOL bEnable = AfxEnableMemoryTracking(FALSE); m_pszHelpFilePath = _tcsdup(szBuff); AfxEnableMemoryTracking(bEnable); *lpszExt = '\0'; // back to no suffix } if (m_pszProfileName == NULL) { lstrcat(szExeName, _T(".INI")); // will be enough room in buffer BOOL bEnable = AfxEnableMemoryTracking(FALSE); m_pszProfileName = _tcsdup(szExeName); AfxEnableMemoryTracking(bEnable); } } ///////////////////////////////////////////////////////////////////////////// // CFile implementation helpers #ifdef AfxGetFileName #undef AfxGetFileName #endif UINT AFXAPI AfxGetFileName(LPCTSTR lpszPathName, LPTSTR lpszTitle, UINT nMax) { ASSERT(lpszTitle == NULL || AfxIsValidAddress(lpszTitle, _MAX_FNAME)); ASSERT(AfxIsValidString(lpszPathName)); // always capture the complete file name including extension (if present) LPTSTR lpszTemp = (LPTSTR)lpszPathName; for (LPCTSTR lpsz = lpszPathName; *lpsz != '\0'; lpsz = _tcsinc(lpsz)) { // remember last directory/drive separator if (*lpsz == '\\' || *lpsz == '/' || *lpsz == ':') lpszTemp = (LPTSTR)_tcsinc(lpsz); } // lpszTitle can be NULL which just returns the number of bytes if (lpszTitle == NULL) return lstrlen(lpszTemp)+1; // otherwise copy it into the buffer provided lstrcpyn(lpszTitle, lpszTemp, nMax); return 0; } /////////////////////////////////////////////////////////////////////////////
436730c6b7d0e4d94ca39ba6bb79fa7f3b7536b9
507922e12c92a3b3d1325241d74a45299c49c47b
/readbranchdetails.cc
d4ab6d528ad3947be5522ca6383a74926d9aceeb
[]
no_license
mandeepsimak/SeatPlan-CGI
4e04c80bca51ad184842a2fb5cc1623fd1690995
36cd1b1459b3f57c3a967ee72a5076d170e356a8
refs/heads/master
2020-06-04T16:37:57.330292
2013-01-24T07:13:14
2013-01-24T07:13:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,591
cc
#include "rollnodetails.h" ReadBranchDetails :: ReadBranchDetails() { } void ReadBranchDetails :: readBranchDetails() { fi = formData.getElement(total_branches); if( !fi->isEmpty() && fi != (*formData).end()) { temp = **fi; totalBranches = atoi(temp.c_str()); } for(i = 0; i < totalBranches; i++) { branchName[i] = readField(branch_name, i); totalSubjects[i] = atoi(readField(total_subjects, i).c_str()); subjectcode[i] = readField(subject_code, i); subjectname[i] = readField(subject_name, i); } } string ReadBranchDetails :: readField(string fieldname, int i) { std::stringstream no; string result; no << (i+1); temp = fieldname + no.str(); fi = formData.getElement(temp); if( !fi->isEmpty() &&fi != (*formData).end()) { result = **fi; } else { result = " "; } return result; } void ReadBranchDetails :: splitSujects() { for(i = 0; i < totalBranches; i++) { int size = subjectcode[i].size() + 1; char largchar[size]; // = roll[i].c_str();//"1-10 12 34 15 20 25-30"; j = 0; strcpy(largchar, subjectcode[i].c_str()); char* chars_array = strtok(largchar, ","); while(chars_array) { if(j < totalSubjects[i]) subjectCode[i][j] = chars_array;//atoi (chars_array));//n++; chars_array = strtok(NULL, ","); j++; } } for(i = 0; i < totalBranches; i++) { int size = subjectname[i].size() + 1; char largchar[size]; // = roll[i].c_str();//"1-10 12 34 15 20 25-30"; j = 0; strcpy(largchar, subjectname[i].c_str()); char* chars_array = strtok(largchar, ","); while(chars_array) { if(j < totalSubjects[i]) subjectName[i][j] = chars_array;//atoi (chars_array));//n++; chars_array = strtok(NULL, ","); j++; } } } void ReadBranchDetails :: writeBranchDetails() { outfile.open(BranchDetails_in); outfile << totalBranches << endl; for(i = 0; i < totalBranches; i++) { outfile << branchName[i] << endl << totalSubjects[i] << endl; for(j = 0; j < totalSubjects[i]; j++) outfile << subjectName[i][j] << endl << subjectCode[i][j] << endl; } outfile.close(); } void ReadBranchDetails :: Main() { readBranchDetails(); splitSujects(); writeBranchDetails(); }
09c7169897b222d3d85f33fcf0274e3dd1f874be
f73a19044559edadf649e232f226ea361831e022
/Software/Nepoužité zdrojové kódy (Testovací)/Testing0_sampleUno/Testing0_sampleUno.ino
4bff9e91389deae672c9b001416c51dc11064081
[]
no_license
Tmthetom/bachelor_thesis
186c9e9ae76f0634ab91ac1008f67c73fe6447a8
43500f2ce383776f4e437bde5aebba96a9384db2
refs/heads/master
2021-01-21T08:02:09.185971
2016-05-16T02:37:30
2016-05-16T02:37:30
83,326,652
0
0
null
null
null
null
UTF-8
C++
false
false
1,944
ino
#include "gps_gsm_sim908Serial0.h" void setup () { gps_init (); //init GPS pin Serial.begin (9600); //serial0 connect computer start_gps (); //open GPS } void loop () { int stat = gps_get_gga (); // read data from GPS, return 0 is ok if (stat == 0 || stat == 1) { if (gps_gga_is_fix ()) { //true if fix gsm_set_numble ("776006865"); // change it to your receiver phone number gsm_send_message (gps_gga_utc_s ()); gsm_send_message (gps_gga_EW ()); gsm_send_message (gps_gga_NS ()); gsm_send_message (gps_gga_lat_s ()); gsm_send_message (gps_gga_long_s ()); gsm_end_send (); delay(5000); } } switch (stat) { case 0: #ifdef DEBUG Serial.println ("data checksum is ok"); #endif break; case 1: #ifdef DEBUG Serial.println ("GPGGA ID is error!"); #endif break; case 2: #ifdef DEBUG Serial.println ("data is error!"); #endif break; } #ifdef DEBUG Serial.println ("$GPGGA data:"); gps_gga_print (); //for test #endif /* if (gps_gga_is_fix () == 0) //check if is fix Serial.println ("can't fix! please go outside!"); else { Serial.println ("ok! is fix!"); Serial.println ("gps_gga_utc_hh ()"); Serial.println (gps_gga_utc_hh ()); Serial.println ("gps_gga_utc_mm ()"); Serial.println (gps_gga_utc_mm ()); Serial.println ("gps_gga_utc_ss ()"); Serial.println (gps_gga_utc_ss ()); Serial.println ("gps_gga_NS ()"); Serial.println (gps_gga_NS (), 6); Serial.println ("gps_gga_EW ()"); Serial.println (gps_gga_EW (), 6); Serial.println ("gps_gga_lat ()"); Serial.println (gps_gga_lat (), 6); Serial.println ("gps_gga_long ()"); Serial.println (gps_gga_long (), 6); Serial.println ("gps_gga_HDOP ()"); Serial.println (gps_gga_HDOP (), 6); Serial.println ("gps_gga_MSL ()"); Serial.println (gps_gga_MSL (), 6); Serial.println (); } */ }
b277dbed2e464ed7686237eae64d4e4bbf99ffc5
f769e4df3e80746adadf5ef3c843dda5212809cf
/chuck-norris-joke-part2/HoundCpp/HoundJSON/EquationSolverInformationNuggetJSON.cpp
7a0b0bbbc5a328bb186db7ab24b72af4d4529237
[]
no_license
jiintonic/weekend-task
0758296644780e172a07b2308ed91d7e5a51b77d
07ec0ba5a0f809d424d134d33e0635376d290c69
refs/heads/master
2020-03-30T09:07:29.518881
2018-10-03T15:13:58
2018-10-03T15:13:58
151,061,148
1
0
null
null
null
null
UTF-8
C++
false
false
11,493
cpp
/* file "EquationSolverInformationNuggetJSON.cpp" */ /* Generated automatically by Classy JSON. */ #pragma implementation "EquationSolverInformationNuggetJSON.h" #include "EquationSolverInformationNuggetJSON.h" EquationSolverInformationNuggetJSON::TypeSolutionsJSON::TypeSolutionsJSON(const TypeSolutionsJSON &) { assert(false); } EquationSolverInformationNuggetJSON::TypeSolutionsJSON &EquationSolverInformationNuggetJSON::TypeSolutionsJSON::operator=(const TypeSolutionsJSON &other) { assert(false); throw "Illegal operator=() call."; } void EquationSolverInformationNuggetJSON::TypeSolutionsJSON::fromJSONReal(JSONValue *json_value, bool ignore_extras) { assert(json_value != NULL); const JSONRationalValue *json_rational = json_value->rational_value(); std::string the_rational_text; if (json_rational != NULL) { the_rational_text = json_rational->getText(); } else { const JSONIntegerValue *json_integer = json_value->integer_value(); if (json_integer != NULL) { the_rational_text = json_integer->getText(); } else { throw("The value for field Real of TypeSolutionsJSON is not a number."); } } setRealText(the_rational_text); } void EquationSolverInformationNuggetJSON::TypeSolutionsJSON::fromJSONImaginary(JSONValue *json_value, bool ignore_extras) { assert(json_value != NULL); const JSONRationalValue *json_rational = json_value->rational_value(); std::string the_rational_text; if (json_rational != NULL) { the_rational_text = json_rational->getText(); } else { const JSONIntegerValue *json_integer = json_value->integer_value(); if (json_integer != NULL) { the_rational_text = json_integer->getText(); } else { throw("The value for field Imaginary of TypeSolutionsJSON is not a number."); } } setImaginaryText(the_rational_text); } EquationSolverInformationNuggetJSON::TypeSolutionsJSON::TypeSolutionsJSON(void) : flagHasReal(false), flagHasImaginary(false) { extraIndex = create_string_index(); } EquationSolverInformationNuggetJSON::TypeSolutionsJSON::~TypeSolutionsJSON(void) { size_t extra_count = extraValues.size(); for (size_t extra_num = 0; extra_num < extra_count; ++extra_num) extraValues[extra_num]->remove_reference(); destroy_string_index(extraIndex); } bool EquationSolverInformationNuggetJSON::TypeSolutionsJSON::hasReal(void) const { return flagHasReal; } double EquationSolverInformationNuggetJSON::TypeSolutionsJSON::getReal(void) { assert(flagHasReal); if (textStoreReal != "") { return atof(textStoreReal.c_str()); } return storeReal; } const double EquationSolverInformationNuggetJSON::TypeSolutionsJSON::getReal(void) const { assert(flagHasReal); if (textStoreReal != "") { return atof(textStoreReal.c_str()); } return storeReal; } std::string EquationSolverInformationNuggetJSON::TypeSolutionsJSON::getRealAsText(void) const { assert(flagHasReal); if (textStoreReal == "") { char buffer[100]; sprintf(&(buffer[0]), "%g", storeReal); return &(buffer[0]); } else { return (textStoreReal); } } bool EquationSolverInformationNuggetJSON::TypeSolutionsJSON::hasImaginary(void) const { return flagHasImaginary; } double EquationSolverInformationNuggetJSON::TypeSolutionsJSON::getImaginary(void) { assert(flagHasImaginary); if (textStoreImaginary != "") { return atof(textStoreImaginary.c_str()); } return storeImaginary; } const double EquationSolverInformationNuggetJSON::TypeSolutionsJSON::getImaginary(void) const { assert(flagHasImaginary); if (textStoreImaginary != "") { return atof(textStoreImaginary.c_str()); } return storeImaginary; } std::string EquationSolverInformationNuggetJSON::TypeSolutionsJSON::getImaginaryAsText(void) const { assert(flagHasImaginary); if (textStoreImaginary == "") { char buffer[100]; sprintf(&(buffer[0]), "%g", storeImaginary); return &(buffer[0]); } else { return (textStoreImaginary); } } EquationSolverInformationNuggetJSON::EquationSolverInformationNuggetJSON(const EquationSolverInformationNuggetJSON &) { assert(false); } EquationSolverInformationNuggetJSON &EquationSolverInformationNuggetJSON::operator=(const EquationSolverInformationNuggetJSON &other) { assert(false); throw "Illegal operator=() call."; } JSONValue *EquationSolverInformationNuggetJSON::extraEquationToJSON(void) const { JSONStringValue *generated_string_Equation = new JSONStringValue(storeEquation.c_str()); return generated_string_Equation; } JSONValue *EquationSolverInformationNuggetJSON::extraVariableToJSON(void) const { JSONStringValue *generated_string_Variable = new JSONStringValue(storeVariable.c_str()); return generated_string_Variable; } JSONValue *EquationSolverInformationNuggetJSON::extraSolutionsToJSON(void) const { JSONArrayValue *generated_array_1_Solutions = new JSONArrayValue(); for (size_t num1 = 0; num1 < storeSolutions.size(); ++num1) { JSONValueHandler handler_Solutions; storeSolutions[num1]->write_as_json(&handler_Solutions); handler_Solutions.result->add_reference(); generated_array_1_Solutions->appendComponent(handler_Solutions.result); handler_Solutions.result->remove_reference(); } return generated_array_1_Solutions; } void EquationSolverInformationNuggetJSON::fromJSONEquation(JSONValue *json_value, bool ignore_extras) { assert(json_value != NULL); const JSONStringValue *json_string = json_value->string_value(); if (json_string == NULL) throw("The value for field Equation of EquationSolverInformationNuggetJSON is not a string."); setEquation(std::string(json_string->getData())); } void EquationSolverInformationNuggetJSON::fromJSONVariable(JSONValue *json_value, bool ignore_extras) { assert(json_value != NULL); const JSONStringValue *json_string = json_value->string_value(); if (json_string == NULL) throw("The value for field Variable of EquationSolverInformationNuggetJSON is not a string."); setVariable(std::string(json_string->getData())); } void EquationSolverInformationNuggetJSON::fromJSONSolutions(JSONValue *json_value, bool ignore_extras) { assert(json_value != NULL); JSONArrayValue *json_array1 = json_value->array_value(); if (json_array1 == NULL) throw("The value for field Solutions of EquationSolverInformationNuggetJSON is not an array."); size_t count1 = json_array1->componentCount(); std::vector< TypeSolutionsJSON * > vector_Solutions1(count1); for (size_t num1 = 0; num1 < count1; ++num1) { TypeSolutionsJSON *convert_classy = TypeSolutionsJSON::from_json(json_array1->component(num1), ignore_extras); convert_classy->add_reference(); vector_Solutions1[num1] = convert_classy; } initSolutions(); for (size_t num2 = 0; num2 < vector_Solutions1.size(); ++num2) appendSolutions(vector_Solutions1[num2]); for (size_t num1 = 0; num1 < vector_Solutions1.size(); ++num1) { vector_Solutions1[num1]->remove_reference(); } } EquationSolverInformationNuggetJSON::EquationSolverInformationNuggetJSON(void) : flagHasEquation(false), flagHasVariable(false), flagHasSolutions(false) { extraIndex = create_string_index(); } EquationSolverInformationNuggetJSON::~EquationSolverInformationNuggetJSON(void) { if (flagHasSolutions) { for (size_t num4 = 0; num4 < storeSolutions.size(); ++num4) { storeSolutions[num4]->remove_reference(); } } size_t extra_count = extraValues.size(); for (size_t extra_num = 0; extra_num < extra_count; ++extra_num) extraValues[extra_num]->remove_reference(); destroy_string_index(extraIndex); } const char *EquationSolverInformationNuggetJSON::getNuggetKind(void) const { return "EquationSolverInformationNugget"; } bool EquationSolverInformationNuggetJSON::hasEquation(void) const { return flagHasEquation; } std::string EquationSolverInformationNuggetJSON::getEquation(void) { assert(flagHasEquation); return storeEquation; } const std::string EquationSolverInformationNuggetJSON::getEquation(void) const { assert(flagHasEquation); return storeEquation; } bool EquationSolverInformationNuggetJSON::hasVariable(void) const { return flagHasVariable; } std::string EquationSolverInformationNuggetJSON::getVariable(void) { assert(flagHasVariable); return storeVariable; } const std::string EquationSolverInformationNuggetJSON::getVariable(void) const { assert(flagHasVariable); return storeVariable; } bool EquationSolverInformationNuggetJSON::hasSolutions(void) const { return flagHasSolutions; } size_t EquationSolverInformationNuggetJSON::countOfSolutions(void) const { assert(flagHasSolutions); return storeSolutions.size(); } EquationSolverInformationNuggetJSON::TypeSolutionsJSON * EquationSolverInformationNuggetJSON::elementOfSolutions(size_t element_num) { assert(flagHasSolutions); return storeSolutions[element_num]; } const EquationSolverInformationNuggetJSON::TypeSolutionsJSON * EquationSolverInformationNuggetJSON::elementOfSolutions(size_t element_num) const { assert(flagHasSolutions); return storeSolutions[element_num]; } std::vector< EquationSolverInformationNuggetJSON::TypeSolutionsJSON * > EquationSolverInformationNuggetJSON::getSolutions(void) { assert(flagHasSolutions); return storeSolutions; } const std::vector< EquationSolverInformationNuggetJSON::TypeSolutionsJSON * > EquationSolverInformationNuggetJSON::getSolutions(void) const { assert(flagHasSolutions); return storeSolutions; } EquationSolverInformationNuggetJSON::TypeSolutionsJSON *EquationSolverInformationNuggetJSON::TypeSolutionsJSON::from_json(JSONValue *json_value, bool ignore_extras) { TypeSolutionsJSON *result; { JSONHoldingGenerator<Generator, RCHandle<TypeSolutionsJSON>, TypeSolutionsJSON *, bool> generator("Type TypeSolutions", ignore_extras); json_value->write(&generator); assert(generator.have_value); result = generator.value.referenced(); result->add_reference(); }; result->remove_reference_no_delete(); return result; } EquationSolverInformationNuggetJSON *EquationSolverInformationNuggetJSON::from_json(JSONValue *json_value, bool ignore_extras) { EquationSolverInformationNuggetJSON *result; { JSONHoldingGenerator<Generator, RCHandle<EquationSolverInformationNuggetJSON>, EquationSolverInformationNuggetJSON *, bool> generator("Type EquationSolverInformationNugget", ignore_extras); json_value->write(&generator); assert(generator.have_value); result = generator.value.referenced(); result->add_reference(); }; result->remove_reference_no_delete(); return result; }
ed6fc6f127364000e8956d38d40f3f94d8b2d3b1
39fecb83b12b5e17f0db7ff7583285619e5e5028
/src/rpcserver.cpp
4354f0265bc7669de596c77fd0ce18be1895fb75
[ "MIT" ]
permissive
PlanetPay/PlanetPay
8c23c2d04457fd5dd483d66673c7d3b0cc6a77b5
17c6a28825c062d80d3324bc5711f53155fb6c25
refs/heads/master
2020-03-27T19:55:37.233697
2018-09-01T23:43:06
2018-09-01T23:43:06
147,021,675
0
1
null
null
null
null
UTF-8
C++
false
false
34,653
cpp
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "rpcserver.h" #include "base58.h" #include "init.h" #include "util.h" #include "sync.h" #include "base58.h" #include "db.h" #include "ui_interface.h" #ifdef ENABLE_WALLET #include "wallet.h" #endif #include <boost/algorithm/string.hpp> #include <boost/asio.hpp> #include <boost/asio/ip/v6_only.hpp> #include <boost/asio/ssl.hpp> #include <boost/bind.hpp> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include <boost/foreach.hpp> #include <boost/iostreams/concepts.hpp> #include <boost/iostreams/stream.hpp> #include <boost/lexical_cast.hpp> #include <boost/shared_ptr.hpp> #include <list> using namespace std; using namespace boost; using namespace boost::asio; using namespace json_spirit; static std::string strRPCUserColonPass; // These are created by StartRPCThreads, destroyed in StopRPCThreads static asio::io_service* rpc_io_service = NULL; static map<string, boost::shared_ptr<deadline_timer> > deadlineTimers; static ssl::context* rpc_ssl_context = NULL; static boost::thread_group* rpc_worker_group = NULL; void RPCTypeCheck(const Array& params, const list<Value_type>& typesExpected, bool fAllowNull) { unsigned int i = 0; BOOST_FOREACH(Value_type t, typesExpected) { if (params.size() <= i) break; const Value& v = params[i]; if (!((v.type() == t) || (fAllowNull && (v.type() == null_type)))) { string err = strprintf("Expected type %s, got %s", Value_type_name[t], Value_type_name[v.type()]); throw JSONRPCError(RPC_TYPE_ERROR, err); } i++; } } void RPCTypeCheck(const Object& o, const map<string, Value_type>& typesExpected, bool fAllowNull) { BOOST_FOREACH(const PAIRTYPE(string, Value_type)& t, typesExpected) { const Value& v = find_value(o, t.first); if (!fAllowNull && v.type() == null_type) throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first)); if (!((v.type() == t.second) || (fAllowNull && (v.type() == null_type)))) { string err = strprintf("Expected type %s for %s, got %s", Value_type_name[t.second], t.first, Value_type_name[v.type()]); throw JSONRPCError(RPC_TYPE_ERROR, err); } } } int64_t AmountFromValue(const Value& value) { double dAmount = value.get_real(); if (dAmount <= 0.0 || dAmount > MAX_MONEY) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount"); CAmount nAmount = roundint64(dAmount * COIN); if (!MoneyRange(nAmount)) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount"); return nAmount; } Value ValueFromAmount(int64_t amount) { return (double)amount / (double)COIN; } // // Utilities: convert hex-encoded Values // (throws error if not hex). // uint256 ParseHashV(const Value& v, string strName) { string strHex; if (v.type() == str_type) strHex = v.get_str(); if (!IsHex(strHex)) // Note: IsHex("") is false throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')"); uint256 result; result.SetHex(strHex); return result; } uint256 ParseHashO(const Object& o, string strKey) { return ParseHashV(find_value(o, strKey), strKey); } vector<unsigned char> ParseHexV(const Value& v, string strName) { string strHex; if (v.type() == str_type) strHex = v.get_str(); if (!IsHex(strHex)) throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')"); return ParseHex(strHex); } vector<unsigned char> ParseHexO(const Object& o, string strKey) { return ParseHexV(find_value(o, strKey), strKey); } /// /// Note: This interface may still be subject to change. /// string CRPCTable::help(string strCommand) const { string strRet; set<rpcfn_type> setDone; for (map<string, const CRPCCommand*>::const_iterator mi = mapCommands.begin(); mi != mapCommands.end(); ++mi) { const CRPCCommand *pcmd = mi->second; string strMethod = mi->first; // We already filter duplicates, but these deprecated screw up the sort order if (strMethod.find("label") != string::npos) continue; if (strCommand != "" && strMethod != strCommand) continue; #ifdef ENABLE_WALLET if (pcmd->reqWallet && !pwalletMain) continue; #endif try { Array params; rpcfn_type pfn = pcmd->actor; if (setDone.insert(pfn).second) (*pfn)(params, true); } catch (std::exception& e) { // Help text is returned in an exception string strHelp = string(e.what()); if (strCommand == "") if (strHelp.find('\n') != string::npos) strHelp = strHelp.substr(0, strHelp.find('\n')); strRet += strHelp + "\n"; } } if (strRet == "") strRet = strprintf("help: unknown command: %s\n", strCommand); strRet = strRet.substr(0,strRet.size()-1); return strRet; } Value help(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "help [command]\n" "List commands, or get help for a command."); string strCommand; if (params.size() > 0) strCommand = params[0].get_str(); return tableRPC.help(strCommand); } Value stop(const Array& params, bool fHelp) { // Accept the deprecated and ignored 'detach' boolean argument if (fHelp || params.size() > 1) throw runtime_error( "stop\n" "Stop Planetpay server."); // Shutdown will take long enough that the response should get back StartShutdown(); return "Planetpay server stopping"; } // // Call Table // static const CRPCCommand vRPCCommands[] = { // name actor (function) okSafeMode threadSafe reqWallet // ------------------------ ----------------------- ---------- ---------- --------- { "help", &help, true, true, false }, { "stop", &stop, true, true, false }, { "getbestblockhash", &getbestblockhash, true, false, false }, { "getblockcount", &getblockcount, true, false, false }, { "getconnectioncount", &getconnectioncount, true, false, false }, { "getpeerinfo", &getpeerinfo, true, false, false }, { "addnode", &addnode, true, true, false }, { "getaddednodeinfo", &getaddednodeinfo, true, true, false }, { "ping", &ping, true, false, false }, { "setban", &setban, true, false, false }, { "listbanned", &listbanned, true, false, false }, { "clearbanned", &clearbanned, true, false, false }, { "getnettotals", &getnettotals, true, true, false }, { "getdifficulty", &getdifficulty, true, false, false }, { "getinfo", &getinfo, true, false, false }, { "getrawmempool", &getrawmempool, true, false, false }, { "getblock", &getblock, false, false, false }, { "getblockbynumber", &getblockbynumber, false, false, false }, { "getblockhash", &getblockhash, false, false, false }, { "getrawtransaction", &getrawtransaction, false, false, false }, { "createrawtransaction", &createrawtransaction, false, false, false }, { "decoderawtransaction", &decoderawtransaction, false, false, false }, { "decodescript", &decodescript, false, false, false }, { "signrawtransaction", &signrawtransaction, false, false, false }, { "sendrawtransaction", &sendrawtransaction, false, false, false }, { "getcheckpoint", &getcheckpoint, true, false, false }, { "sendalert", &sendalert, false, false, false }, { "validateaddress", &validateaddress, true, false, false }, { "validatepubkey", &validatepubkey, true, false, false }, { "verifymessage", &verifymessage, false, false, false }, { "searchrawtransactions", &searchrawtransactions, false, false, false }, /* Dark features */ { "spork", &spork, true, false, false }, { "masternode", &masternode, true, false, true }, { "masternodelist", &masternodelist, true, false, false }, #ifdef ENABLE_WALLET { "darksend", &darksend, false, false, true }, { "getmininginfo", &getmininginfo, true, false, false }, { "getstakinginfo", &getstakinginfo, true, false, false }, { "getnewaddress", &getnewaddress, true, false, true }, { "getnewpubkey", &getnewpubkey, true, false, true }, { "getaccountaddress", &getaccountaddress, true, false, true }, { "setaccount", &setaccount, true, false, true }, { "getaccount", &getaccount, false, false, true }, { "getaddressesbyaccount", &getaddressesbyaccount, true, false, true }, { "sendtoaddress", &sendtoaddress, false, false, true }, { "getreceivedbyaddress", &getreceivedbyaddress, false, false, true }, { "getreceivedbyaccount", &getreceivedbyaccount, false, false, true }, { "listreceivedbyaddress", &listreceivedbyaddress, false, false, true }, { "listreceivedbyaccount", &listreceivedbyaccount, false, false, true }, { "backupwallet", &backupwallet, true, false, true }, { "keypoolrefill", &keypoolrefill, true, false, true }, { "walletpassphrase", &walletpassphrase, true, false, true }, { "walletpassphrasechange", &walletpassphrasechange, false, false, true }, { "walletlock", &walletlock, true, false, true }, { "encryptwallet", &encryptwallet, false, false, true }, { "getbalance", &getbalance, false, false, true }, { "move", &movecmd, false, false, true }, { "sendfrom", &sendfrom, false, false, true }, { "sendmany", &sendmany, false, false, true }, { "addmultisigaddress", &addmultisigaddress, false, false, true }, { "addredeemscript", &addredeemscript, false, false, true }, { "gettransaction", &gettransaction, false, false, true }, { "listtransactions", &listtransactions, false, false, true }, { "listaddressgroupings", &listaddressgroupings, false, false, true }, { "signmessage", &signmessage, false, false, true }, { "getwork", &getwork, true, false, true }, { "getworkex", &getworkex, true, false, true }, { "listaccounts", &listaccounts, false, false, true }, { "getblocktemplate", &getblocktemplate, true, false, false }, { "submitblock", &submitblock, false, false, false }, { "listsinceblock", &listsinceblock, false, false, true }, { "dumpprivkey", &dumpprivkey, false, false, true }, { "dumpwallet", &dumpwallet, true, false, true }, { "importprivkey", &importprivkey, false, false, true }, { "importwallet", &importwallet, false, false, true }, { "importaddress", &importaddress, false, false, true }, { "listunspent", &listunspent, false, false, true }, { "settxfee", &settxfee, false, false, true }, { "getsubsidy", &getsubsidy, true, true, false }, { "getstakesubsidy", &getstakesubsidy, true, true, false }, { "reservebalance", &reservebalance, false, true, true }, { "createmultisig", &createmultisig, true, true, false }, { "checkwallet", &checkwallet, false, true, true }, { "repairwallet", &repairwallet, false, true, true }, { "resendtx", &resendtx, false, true, true }, { "makekeypair", &makekeypair, false, true, false }, { "checkkernel", &checkkernel, true, false, true }, { "getnewstealthaddress", &getnewstealthaddress, false, false, true }, { "liststealthaddresses", &liststealthaddresses, false, false, true }, { "scanforalltxns", &scanforalltxns, false, false, false }, { "scanforstealthtxns", &scanforstealthtxns, false, false, false }, { "importstealthaddress", &importstealthaddress, false, false, true }, { "sendtostealthaddress", &sendtostealthaddress, false, false, true }, { "smsgenable", &smsgenable, false, false, false }, { "smsgdisable", &smsgdisable, false, false, false }, { "smsglocalkeys", &smsglocalkeys, false, false, false }, { "smsgoptions", &smsgoptions, false, false, false }, { "smsgscanchain", &smsgscanchain, false, false, false }, { "smsgscanbuckets", &smsgscanbuckets, false, false, false }, { "smsgaddkey", &smsgaddkey, false, false, false }, { "smsggetpubkey", &smsggetpubkey, false, false, false }, { "smsgsend", &smsgsend, false, false, false }, { "smsgsendanon", &smsgsendanon, false, false, false }, { "smsginbox", &smsginbox, false, false, false }, { "smsgoutbox", &smsgoutbox, false, false, false }, { "smsgbuckets", &smsgbuckets, false, false, false }, #endif }; CRPCTable::CRPCTable() { unsigned int vcidx; for (vcidx = 0; vcidx < (sizeof(vRPCCommands) / sizeof(vRPCCommands[0])); vcidx++) { const CRPCCommand *pcmd; pcmd = &vRPCCommands[vcidx]; mapCommands[pcmd->name] = pcmd; } } const CRPCCommand *CRPCTable::operator[](string name) const { map<string, const CRPCCommand*>::const_iterator it = mapCommands.find(name); if (it == mapCommands.end()) return NULL; return (*it).second; } bool HTTPAuthorized(map<string, string>& mapHeaders) { string strAuth = mapHeaders["authorization"]; if (strAuth.substr(0,6) != "Basic ") return false; string strUserPass64 = strAuth.substr(6); boost::trim(strUserPass64); string strUserPass = DecodeBase64(strUserPass64); return TimingResistantEqual(strUserPass, strRPCUserColonPass); } void ErrorReply(std::ostream& stream, const Object& objError, const Value& id) { // Send error reply from json-rpc error object int nStatus = HTTP_INTERNAL_SERVER_ERROR; int code = find_value(objError, "code").get_int(); if (code == RPC_INVALID_REQUEST) nStatus = HTTP_BAD_REQUEST; else if (code == RPC_METHOD_NOT_FOUND) nStatus = HTTP_NOT_FOUND; string strReply = JSONRPCReply(Value::null, objError, id); stream << HTTPReply(nStatus, strReply, false) << std::flush; } bool ClientAllowed(const boost::asio::ip::address& address) { // Make sure that IPv4-compatible and IPv4-mapped IPv6 addresses are treated as IPv4 addresses if (address.is_v6() && (address.to_v6().is_v4_compatible() || address.to_v6().is_v4_mapped())) return ClientAllowed(address.to_v6().to_v4()); if (address == asio::ip::address_v4::loopback() || address == asio::ip::address_v6::loopback() || (address.is_v4() // Check whether IPv4 addresses match 127.0.0.0/8 (loopback subnet) && (address.to_v4().to_ulong() & 0xff000000) == 0x7f000000)) return true; const string strAddress = address.to_string(); const vector<string>& vAllow = mapMultiArgs["-rpcallowip"]; BOOST_FOREACH(string strAllow, vAllow) if (WildcardMatch(strAddress, strAllow)) return true; return false; } class AcceptedConnection { public: virtual ~AcceptedConnection() {} virtual std::iostream& stream() = 0; virtual std::string peer_address_to_string() const = 0; virtual void close() = 0; }; template <typename Protocol> class AcceptedConnectionImpl : public AcceptedConnection { public: AcceptedConnectionImpl( asio::io_service& io_service, ssl::context &context, bool fUseSSL) : sslStream(io_service, context), _d(sslStream, fUseSSL), _stream(_d) { } virtual std::iostream& stream() { return _stream; } virtual std::string peer_address_to_string() const { return peer.address().to_string(); } virtual void close() { _stream.close(); } typename Protocol::endpoint peer; asio::ssl::stream<typename Protocol::socket> sslStream; private: SSLIOStreamDevice<Protocol> _d; iostreams::stream< SSLIOStreamDevice<Protocol> > _stream; }; void ServiceConnection(AcceptedConnection *conn); // Forward declaration required for RPCListen template <typename Protocol, typename SocketAcceptorService> static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor, ssl::context& context, bool fUseSSL, AcceptedConnection* conn, const boost::system::error_code& error); /** * Sets up I/O resources to accept and handle a new connection. */ template <typename Protocol, typename SocketAcceptorService> static void RPCListen(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor, ssl::context& context, const bool fUseSSL) { // Accept connection AcceptedConnectionImpl<Protocol>* conn = new AcceptedConnectionImpl<Protocol>(acceptor->get_io_service(), context, fUseSSL); acceptor->async_accept( conn->sslStream.lowest_layer(), conn->peer, boost::bind(&RPCAcceptHandler<Protocol, SocketAcceptorService>, acceptor, boost::ref(context), fUseSSL, conn, boost::asio::placeholders::error)); } /** * Accept and handle incoming connection. */ template <typename Protocol, typename SocketAcceptorService> static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor, ssl::context& context, const bool fUseSSL, AcceptedConnection* conn, const boost::system::error_code& error) { // Immediately start accepting new connections, except when we're cancelled or our socket is closed. if (error != asio::error::operation_aborted && acceptor->is_open()) RPCListen(acceptor, context, fUseSSL); AcceptedConnectionImpl<ip::tcp>* tcp_conn = dynamic_cast< AcceptedConnectionImpl<ip::tcp>* >(conn); // TODO: Actually handle errors if (error) { delete conn; } // Restrict callers by IP. It is important to // do this before starting client thread, to filter out // certain DoS and misbehaving clients. else if (tcp_conn && !ClientAllowed(tcp_conn->peer.address())) { // Only send a 403 if we're not using SSL to prevent a DoS during the SSL handshake. if (!fUseSSL) conn->stream() << HTTPReply(HTTP_FORBIDDEN, "", false) << std::flush; delete conn; } else { ServiceConnection(conn); conn->close(); delete conn; } } void StartRPCThreads() { strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]; if (((mapArgs["-rpcpassword"] == "") || (mapArgs["-rpcuser"] == mapArgs["-rpcpassword"])) && Params().RequireRPCPassword()) { unsigned char rand_pwd[32]; GetRandBytes(rand_pwd, 32); string strWhatAmI = "To use Planetpayd"; if (mapArgs.count("-server")) strWhatAmI = strprintf(_("To use the %s option"), "\"-server\""); else if (mapArgs.count("-daemon")) strWhatAmI = strprintf(_("To use the %s option"), "\"-daemon\""); uiInterface.ThreadSafeMessageBox(strprintf( _("%s, you must set a rpcpassword in the configuration file:\n" "%s\n" "It is recommended you use the following random password:\n" "rpcuser=Planetpayrpc\n" "rpcpassword=%s\n" "(you do not need to remember this password)\n" "The username and password MUST NOT be the same.\n" "If the file does not exist, create it with owner-readable-only file permissions.\n" "It is also recommended to set alertnotify so you are notified of problems;\n" "for example: alertnotify=echo %%s | mail -s \"Planetpay Alert\" [email protected]\n"), strWhatAmI, GetConfigFile().string(), EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32)), "", CClientUIInterface::MSG_ERROR); StartShutdown(); return; } assert(rpc_io_service == NULL); rpc_io_service = new asio::io_service(); rpc_ssl_context = new ssl::context(*rpc_io_service, ssl::context::sslv23); const bool fUseSSL = GetBoolArg("-rpcssl", false); if (fUseSSL) { rpc_ssl_context->set_options(ssl::context::no_sslv2 | ssl::context::no_sslv3); filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert")); if (!pathCertFile.is_complete()) pathCertFile = filesystem::path(GetDataDir()) / pathCertFile; if (filesystem::exists(pathCertFile)) rpc_ssl_context->use_certificate_chain_file(pathCertFile.string()); else LogPrintf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string()); filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem")); if (!pathPKFile.is_complete()) pathPKFile = filesystem::path(GetDataDir()) / pathPKFile; if (filesystem::exists(pathPKFile)) rpc_ssl_context->use_private_key_file(pathPKFile.string(), ssl::context::pem); else LogPrintf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string()); string strCiphers = GetArg("-rpcsslciphers", "TLSv1.2+HIGH:TLSv1+HIGH:!SSLv3:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH"); SSL_CTX_set_cipher_list(rpc_ssl_context->impl(), strCiphers.c_str()); } // Try a dual IPv6/IPv4 socket, falling back to separate IPv4 and IPv6 sockets const bool loopback = !mapArgs.count("-rpcallowip"); asio::ip::address bindAddress = loopback ? asio::ip::address_v6::loopback() : asio::ip::address_v6::any(); ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", Params().RPCPort())); boost::system::error_code v6_only_error; boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(*rpc_io_service)); bool fListening = false; std::string strerr; try { acceptor->open(endpoint.protocol()); acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); // Try making the socket dual IPv6/IPv4 (if listening on the "any" address) acceptor->set_option(boost::asio::ip::v6_only(loopback), v6_only_error); acceptor->bind(endpoint); acceptor->listen(socket_base::max_connections); RPCListen(acceptor, *rpc_ssl_context, fUseSSL); fListening = true; } catch(boost::system::system_error &e) { strerr = strprintf(_("An error occurred while setting up the RPC port %u for listening on IPv6, falling back to IPv4: %s"), endpoint.port(), e.what()); } try { // If dual IPv6/IPv4 failed (or we're opening loopback interfaces only), open IPv4 separately if (!fListening || loopback || v6_only_error) { bindAddress = loopback ? asio::ip::address_v4::loopback() : asio::ip::address_v4::any(); endpoint.address(bindAddress); acceptor.reset(new ip::tcp::acceptor(*rpc_io_service)); acceptor->open(endpoint.protocol()); acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); acceptor->bind(endpoint); acceptor->listen(socket_base::max_connections); RPCListen(acceptor, *rpc_ssl_context, fUseSSL); fListening = true; } } catch(boost::system::system_error &e) { strerr = strprintf(_("An error occurred while setting up the RPC port %u for listening on IPv4: %s"), endpoint.port(), e.what()); } if (!fListening) { uiInterface.ThreadSafeMessageBox(strerr, "", CClientUIInterface::MSG_ERROR); StartShutdown(); return; } rpc_worker_group = new boost::thread_group(); for (int i = 0; i < GetArg("-rpcthreads", 4); i++) rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service)); } void StopRPCThreads() { if (rpc_io_service == NULL) return; deadlineTimers.clear(); rpc_io_service->stop(); if (rpc_worker_group != NULL) rpc_worker_group->join_all(); delete rpc_worker_group; rpc_worker_group = NULL; delete rpc_ssl_context; rpc_ssl_context = NULL; delete rpc_io_service; rpc_io_service = NULL; } void RPCRunHandler(const boost::system::error_code& err, boost::function<void(void)> func) { if (!err) func(); } void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds) { assert(rpc_io_service != NULL); if (deadlineTimers.count(name) == 0) { deadlineTimers.insert(make_pair(name, boost::shared_ptr<deadline_timer>(new deadline_timer(*rpc_io_service)))); } deadlineTimers[name]->expires_from_now(posix_time::seconds(nSeconds)); deadlineTimers[name]->async_wait(boost::bind(RPCRunHandler, _1, func)); } class JSONRequest { public: Value id; string strMethod; Array params; JSONRequest() { id = Value::null; } void parse(const Value& valRequest); }; void JSONRequest::parse(const Value& valRequest) { // Parse request if (valRequest.type() != obj_type) throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object"); const Object& request = valRequest.get_obj(); // Parse id now so errors from here on will have the id id = find_value(request, "id"); // Parse method Value valMethod = find_value(request, "method"); if (valMethod.type() == null_type) throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method"); if (valMethod.type() != str_type) throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string"); strMethod = valMethod.get_str(); if (strMethod != "getwork" && strMethod != "getblocktemplate") LogPrint("rpc", "ThreadRPCServer method=%s\n", strMethod); // Parse params Value valParams = find_value(request, "params"); if (valParams.type() == array_type) params = valParams.get_array(); else if (valParams.type() == null_type) params = Array(); else throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array"); } static Object JSONRPCExecOne(const Value& req) { Object rpc_result; JSONRequest jreq; try { jreq.parse(req); Value result = tableRPC.execute(jreq.strMethod, jreq.params); rpc_result = JSONRPCReplyObj(result, Value::null, jreq.id); } catch (Object& objError) { rpc_result = JSONRPCReplyObj(Value::null, objError, jreq.id); } catch (std::exception& e) { rpc_result = JSONRPCReplyObj(Value::null, JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id); } return rpc_result; } static string JSONRPCExecBatch(const Array& vReq) { Array ret; for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++) ret.push_back(JSONRPCExecOne(vReq[reqIdx])); return write_string(Value(ret), false) + "\n"; } void ServiceConnection(AcceptedConnection *conn) { bool fRun = true; while (fRun) { int nProto = 0; map<string, string> mapHeaders; string strRequest, strMethod, strURI; // Read HTTP request line if (!ReadHTTPRequestLine(conn->stream(), nProto, strMethod, strURI)) break; // Read HTTP message headers and body ReadHTTPMessage(conn->stream(), mapHeaders, strRequest, nProto, MAX_SIZE); if (strURI != "/") { conn->stream() << HTTPReply(HTTP_NOT_FOUND, "", false) << std::flush; break; } // Check authorization if (mapHeaders.count("authorization") == 0) { conn->stream() << HTTPReply(HTTP_UNAUTHORIZED, "", false) << std::flush; break; } if (!HTTPAuthorized(mapHeaders)) { LogPrintf("ThreadRPCServer incorrect password attempt from %s\n", conn->peer_address_to_string()); /* Deter brute-forcing short passwords. If this results in a DoS the user really shouldn't have their RPC port exposed. */ if (mapArgs["-rpcpassword"].size() < 20) MilliSleep(250); conn->stream() << HTTPReply(HTTP_UNAUTHORIZED, "", false) << std::flush; break; } if (mapHeaders["connection"] == "close") fRun = false; JSONRequest jreq; try { // Parse request Value valRequest; if (!read_string(strRequest, valRequest)) throw JSONRPCError(RPC_PARSE_ERROR, "Parse error"); string strReply; // singleton request if (valRequest.type() == obj_type) { jreq.parse(valRequest); Value result = tableRPC.execute(jreq.strMethod, jreq.params); // Send reply strReply = JSONRPCReply(result, Value::null, jreq.id); // array of requests } else if (valRequest.type() == array_type) strReply = JSONRPCExecBatch(valRequest.get_array()); else throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error"); conn->stream() << HTTPReply(HTTP_OK, strReply, fRun) << std::flush; } catch (Object& objError) { ErrorReply(conn->stream(), objError, jreq.id); break; } catch (std::exception& e) { ErrorReply(conn->stream(), JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id); break; } } } json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_spirit::Array &params) const { // Find method const CRPCCommand *pcmd = tableRPC[strMethod]; if (!pcmd) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found"); #ifdef ENABLE_WALLET if (pcmd->reqWallet && !pwalletMain) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)"); #endif // Observe safe mode string strWarning = GetWarnings("rpc"); if (strWarning != "" && !GetBoolArg("-disablesafemode", false) && !pcmd->okSafeMode) throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning); try { // Execute Value result; { if (pcmd->threadSafe) result = pcmd->actor(params, false); #ifdef ENABLE_WALLET else if (!pwalletMain) { LOCK(cs_main); result = pcmd->actor(params, false); } else { LOCK2(cs_main, pwalletMain->cs_wallet); result = pcmd->actor(params, false); } #else // ENABLE_WALLET else { LOCK(cs_main); result = pcmd->actor(params, false); } #endif // !ENABLE_WALLET } return result; } catch (std::exception& e) { throw JSONRPCError(RPC_MISC_ERROR, e.what()); } } std::string HelpExampleCli(string methodname, string args){ return "> Planetpayd " + methodname + " " + args + "\n"; } std::string HelpExampleRpc(string methodname, string args){ return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", " "\"method\": \"" + methodname + "\", \"params\": [" + args + "] }' -H 'content-type: text/plain;' http://127.0.0.1:9998/\n"; } const CRPCTable tableRPC;
3907b308422a056ac23f23c806e14eaa2a0e4b4e
51f2677bfc321d247dc8bebc7883470614445323
/arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h
835bd13f6c1c0fcb624d2299049391364a0d2942
[]
no_license
ppplinday/vgg16-by-ARM-Compute-Library
26446a805a62a1bcd11bcff9478969c7ea2d7757
7bd8013ff7d1522ec32de3befb7f9644b8148676
refs/heads/master
2021-05-23T05:35:22.528114
2019-06-20T22:56:55
2019-06-20T22:56:55
95,099,572
35
18
null
null
null
null
UTF-8
C++
false
false
2,290
h
/* * Copyright (c) 2016, 2017 ARM Limited. * * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ARM_COMPUTE_NEPIXELWISEMULTIPLICATION_H__ #define __ARM_COMPUTE_NEPIXELWISEMULTIPLICATION_H__ #include "arm_compute/core/Types.h" #include "arm_compute/runtime/NEON/INESimpleFunction.h" namespace arm_compute { class ITensor; /** Basic function to run @ref NEPixelWiseMultiplicationKernel */ class NEPixelWiseMultiplication : public INESimpleFunction { public: /** Initialise the kernel's inputs, output and convertion policy. * * @param[in] input1 First tensor input. Data types supported: U8 or S16. * @param[in] input2 Second tensor input. Data types supported: U8 or S16. * @param[out] output Output tensor. Data types supported: U8 or S16. * @param[in] scale Scale to apply after multiplication. Must be positive. * @param[in] overflow_policy Overflow policy. * @param[in] rounding_policy Rounding policy. */ void configure(const ITensor *input1, const ITensor *input2, ITensor *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy); }; } #endif /*__ARM_COMPUTE_NEPIXELWISEMULTIPLICATION_H__ */
3ef0b49aa1472c8548f3e3a0659f2db359c012a9
fc7d5b988d885bd3a5ca89296a04aa900e23c497
/Programming/mbed-os-example-sockets/mbed-os/storage/blockdevice/source/FlashSimBlockDevice.cpp
6d6361510cc15490a2f428131072ac90b6f8680a
[ "Apache-2.0" ]
permissive
AlbinMartinsson/master_thesis
52746f035bc24e302530aabde3cbd88ea6c95b77
495d0e53dd00c11adbe8114845264b65f14b8163
refs/heads/main
2023-06-04T09:31:45.174612
2021-06-29T16:35:44
2021-06-29T16:35:44
334,069,714
3
1
Apache-2.0
2021-03-16T16:32:16
2021-01-29T07:28:32
C++
UTF-8
C++
false
false
5,206
cpp
/* mbed Microcontroller Library * Copyright (c) 2018 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * 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 "blockdevice/FlashSimBlockDevice.h" #include "platform/mbed_assert.h" #include "platform/mbed_atomic.h" #include <algorithm> #include <stdlib.h> #include <string.h> #include "mbed_assert.h" namespace mbed { static const bd_size_t min_blank_buf_size = 32; static inline uint32_t align_up(bd_size_t val, bd_size_t size) { return (((val - 1) / size) + 1) * size; } FlashSimBlockDevice::FlashSimBlockDevice(BlockDevice *bd, uint8_t erase_value) : _erase_value(erase_value), _blank_buf_size(0), _blank_buf(0), _bd(bd), _init_ref_count(0), _is_initialized(false) { MBED_ASSERT(bd); } FlashSimBlockDevice::~FlashSimBlockDevice() { deinit(); delete[] _blank_buf; } int FlashSimBlockDevice::init() { int err; uint32_t val = core_util_atomic_incr_u32(&_init_ref_count, 1); if (val != 1) { return BD_ERROR_OK; } err = _bd->init(); if (err) { goto fail; } _blank_buf_size = align_up(min_blank_buf_size, _bd->get_program_size()); if (!_blank_buf) { _blank_buf = new uint8_t[_blank_buf_size]; memset(_blank_buf, 0, _blank_buf_size); MBED_ASSERT(_blank_buf); } _is_initialized = true; return BD_ERROR_OK; fail: _is_initialized = false; _init_ref_count = 0; return err; } int FlashSimBlockDevice::deinit() { if (!_is_initialized) { return BD_ERROR_OK; } uint32_t val = core_util_atomic_decr_u32(&_init_ref_count, 1); if (val) { return BD_ERROR_OK; } _is_initialized = false; return _bd->deinit(); } int FlashSimBlockDevice::sync() { if (!_is_initialized) { return BD_ERROR_DEVICE_ERROR; } return _bd->sync(); } bd_size_t FlashSimBlockDevice::get_read_size() const { if (!_is_initialized) { return 0; } return _bd->get_read_size(); } bd_size_t FlashSimBlockDevice::get_program_size() const { if (!_is_initialized) { return 0; } return _bd->get_program_size(); } bd_size_t FlashSimBlockDevice::get_erase_size() const { if (!_is_initialized) { return 0; } return _bd->get_erase_size(); } bd_size_t FlashSimBlockDevice::get_erase_size(bd_addr_t addr) const { if (!_is_initialized) { return 0; } return _bd->get_erase_size(addr); } bd_size_t FlashSimBlockDevice::size() const { if (!_is_initialized) { return 0; } return _bd->size(); } int FlashSimBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size) { if (!_is_initialized) { return BD_ERROR_DEVICE_ERROR; } return _bd->read(b, addr, size); } int FlashSimBlockDevice::program(const void *b, bd_addr_t addr, bd_size_t size) { if (!_is_initialized) { return BD_ERROR_DEVICE_ERROR; } if (!is_valid_program(addr, size)) { return BD_ERROR_DEVICE_ERROR; } bd_addr_t curr_addr = addr; bd_size_t curr_size = size; const uint8_t *buf = (const uint8_t *) b; while (curr_size) { bd_size_t read_size = std::min(_blank_buf_size, curr_size); int ret = _bd->read(_blank_buf, curr_addr, read_size); if (ret) { return ret; } for (bd_size_t i = 0; i < read_size; i++) { // Allow either programming on blanks or programming the same value // (as real flash devices do) if ((_blank_buf[i] != _erase_value) && (_blank_buf[i] != *buf)) { return BD_ERROR_NOT_ERASED; } buf++; } curr_addr += read_size; curr_size -= read_size; } return _bd->program(b, addr, size); } int FlashSimBlockDevice::erase(bd_addr_t addr, bd_size_t size) { if (!_is_initialized) { return BD_ERROR_DEVICE_ERROR; } if (!is_valid_erase(addr, size)) { return BD_ERROR_DEVICE_ERROR; } bd_addr_t curr_addr = addr; bd_size_t curr_size = size; memset(_blank_buf, _erase_value, (unsigned int) _blank_buf_size); while (curr_size) { bd_size_t prog_size = std::min(_blank_buf_size, curr_size); int ret = _bd->program(_blank_buf, curr_addr, prog_size); if (ret) { return ret; } curr_addr += prog_size; curr_size -= prog_size; } return BD_ERROR_OK; } int FlashSimBlockDevice::get_erase_value() const { return _erase_value; } const char *FlashSimBlockDevice::get_type() const { if (_bd != NULL) { return _bd->get_type(); } return NULL; } } // namespace mbed
d00cdb88eb6800918e29394827558cfb31664268
e2bb8568b21bb305de3b896cf81786650b1a11f9
/SDK/SCUM_Hiking_Boots_02_classes.hpp
5f64f16a13aa7568c5414fc0b3692c835358b4ac
[]
no_license
Buttars/SCUM-SDK
822e03fe04c30e04df0ba2cb4406fe2c18a6228e
954f0ab521b66577097a231dab2bdc1dd35861d3
refs/heads/master
2020-03-28T02:45:14.719920
2018-09-05T17:53:23
2018-09-05T17:53:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
671
hpp
#pragma once // SCUM (0.1.17) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "SCUM_Hiking_Boots_02_structs.hpp" namespace SDK { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass Hiking_Boots_02.Hiking_Boots_02_C // 0x0000 (0x0800 - 0x0800) class AHiking_Boots_02_C : public AClothesItem { public: static UClass* StaticClass() { static auto ptr = UObject::FindObject<UClass>("BlueprintGeneratedClass Hiking_Boots_02.Hiking_Boots_02_C"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
506158f52cbd5d92c5b4cf646dd2430140a114af
f3c60e4671480bae1a4b0117687da7d8b5cd06a9
/codeforces/582/B/B.cpp
22f84a7b17e9452b95522a2e74f974eb09911b90
[]
no_license
nathanPro/mac0214
c971fd96d1a4517685b1cf7bb12379348889aad9
57b99deda183ab280901d019fa58e0f2016fe675
refs/heads/master
2021-01-21T04:53:57.302770
2016-06-23T16:23:49
2016-06-23T16:23:49
51,778,456
0
0
null
null
null
null
UTF-8
C++
false
false
1,062
cpp
#include <bits/stdc++.h> using namespace std; typedef int num; typedef int node; typedef int edge; const int MOD = 1e9+7; struct mod { num x; mod () : x(0) {} mod (num a) : x(a) {} mod operator+(mod b) { return (1ll*x+1ll*b.x)%MOD; } mod operator*(mod b) { return (1ll*x*1ll*b.x)%MOD; } }; const int MN = 1e5+7; int f[MN], inv[MN], b[MN], a[MN], m, n; int amb; int main() { scanf(" %d%d", &n, &m); for(int i=1;i<n+1;i++) scanf(" %d", f+i); for(int i=1;i<n+1;i++) { if (inv[f[i]] == 0) inv[f[i]] = i; else inv[f[i]] = -1; } amb = 0; for(int i=1;i<m+1;i++) { scanf(" %d", b+i); if( inv[b[i]] == -1 ) amb |= 1; else if( inv[b[i]] == 0 ) { printf("Impossible\n"); return 0; } else a[i] = inv[b[i]]; } if(amb) printf("Ambiguity\n"); else { printf("Possible\n"); for(int i=1;i<m+1;i++) printf("%d ", a[i]); } }
72bd39945e4d7f80542643dd39c3f18fd63b5d3a
d92304badb95993099633c5989f6cd8af57f9b1f
/AtCoder/dp_h.cpp
3c8e799a12959e75c1370440c9c0c207ddf3d2e0
[]
no_license
tajirhas9/Problem-Solving-and-Programming-Practice
c5e2b77c7ac69982a53d5320cebe874a7adec750
00c298233a9cde21a1cdca1f4a2b6146d0107e73
refs/heads/master
2020-09-25T22:52:00.716014
2019-12-05T13:04:40
2019-12-05T13:04:40
226,103,342
0
0
null
null
null
null
UTF-8
C++
false
false
6,048
cpp
#include<bits/stdc++.h> /* #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including */ using namespace std; //using namespace __gnu_pbds; //typedefs typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef pair<int,int> pii; typedef pair<double, double> pdd; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll; typedef vector<int>::iterator vit; typedef set<int>::iterator sit; /* template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<typename F, typename S> using ordered_map = tree<F, S, less<F>, rb_tree_tag, tree_order_statistics_node_update>; */ //#Defines #define rep(i,a,b) for(i=a;i<=b;i++) #define repR(i,a,b) for(i=a;i>=b;i--) //#define pb push_back #define pb emplace_back #define F first #define S second #define mp make_pair #define all(c) c.begin(),c.end() #define endl '\n' #define pf printf #define sf scanf //#define left __left //#define right __right //#define tree __tree #define MOD 1000000007 //#define harmonic(n) 0.57721566490153286l+log(n) #define RESET(a,b) memset(a,b,sizeof(a)) #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*(b/gcd(a,b))) #define sqr(a) ((a) * (a)) #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield); const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const ll infLL = 9000000000000000000; //Bit Operations inline bool checkBit(ll n, int i) { return n&(1LL<<i); } inline ll setBit(ll n, int i) { return n|(1LL<<i);; } inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); } int fx[] = {0, 0, +1, -1}; int fy[] = {+1, -1, 0, 0}; //int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1}; //int dy[] = {0, +1, 0, -1, +1, -1, +1, -1}; //Inline functions inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; } inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); } inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); } inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; } inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; } inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; } inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; } inline ll modInverse(ll a) { return modPow(a, MOD-2); } inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); } inline bool isInside(pii p,ll n,ll m) { return (p.first>=0&&p.first<n&&p.second>=0&&p.second<m); } inline bool isInside(pii p,ll n) { return (p.first>=0&&p.first<n&&p.second>=0&&p.second<n); } inline bool isSquare(ll x) { ll s = sqrt(x); return (s*s==x); } inline bool isFib(ll x) { return isSquare(5*x*x+4)|| isSquare(5*x*x-4); } inline bool isPowerOfTwo(ll x) { return ((1LL<<(ll)log2(x))==x); } struct func { //this is a sample overloading function for sorting stl bool operator()(pii const &a, pii const &b) { if(a.F==b.F) return (a.S<b.S); return (a.F<b.F); } }; //Prime Number Generator /* #define M 100000000 int marked[M/64 + 2]; #define on(x) (marked[x/64] & (1<<((x%64)/2))) #define mark(x) marked[x/64] |= (1<<((x%64)/2)) vl prime; bool isPrime(int num) { return num > 1 && (num == 2 || ((num & 1) && !on(num))); } void sieve(ll n) { for (ll i = 3; i * i < n; i += 2) { if (!on(i)) { for (ll j = i * i; j <= n; j += i + i) { mark(j); } } } prime.pb(2); for(ll i = 3; i <= n; i += 2) { if(!on(i)) prime.pb(i); } } */ // //debug #ifdef tajir template < typename F, typename S > ostream& operator << ( ostream& os, const pair< F, S > & p ) { return os << "(" << p.first << ", " << p.second << ")"; } template < typename T > ostream &operator << ( ostream & os, const vector< T > &v ) { os << "{"; for(auto it = v.begin(); it != v.end(); ++it) { if( it != v.begin() ) os << ", "; os << *it; } return os << "}"; } template < typename T > ostream &operator << ( ostream & os, const set< T > &v ) { os << "["; for(auto it = v.begin(); it != v.end(); ++it) { if( it != v.begin() ) os << ", "; os << *it; } return os << "]"; } template < typename T > ostream &operator << ( ostream & os, const multiset< T > &v ) { os << "["; for(auto it = v.begin(); it != v.end(); ++it) { if( it != v.begin() ) os << ", "; os << *it; } return os << "]"; } template < typename F, typename S > ostream &operator << ( ostream & os, const map< F, S > &v ) { os << "["; for(auto it = v.begin(); it != v.end(); ++it) { if( it != v.begin() ) os << ", "; os << it -> first << " = " << it -> second ; } return os << "]"; } #define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0) clock_t tStart = clock(); #define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC) void faltu () { cerr << endl; } template <typename T> void faltu( T a[], int n ) { for(int i = 0; i < n; ++i) cerr << a[i] << ' '; cerr << endl; } template <typename T, typename ... hello> void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); } #else #define dbg(args...) #endif // tajir vector < string > g; vvi dp; int n,m; int solve(int i,int j) { dbg(i,j,g[i][j]); int &ret = dp[i][j]; if(ret != -1) return ret; ret = 0; if(i+1 < n && g[i+1][j] == '.') ret = modAdd(ret , solve(i+1,j)); if(j+1 < m && g[i][j+1] == '.') ret = modAdd(ret , solve(i,j+1)); if(i == n-1 && j == m-1) return ret = 1; return ret; } int main() { #ifdef tajir freopen("input.txt", "r", stdin); #else // online submission #endif optimize(); cin >> n >> m; g.resize(n); for(int i = 0; i < n; ++i) cin >> g[i]; dbg(g); dp.assign(n+1, vi(m+1,-1)); cout << solve(0,0) << endl; return 0; }
49a2034f2f0f897a8913442218d256606dbd8b0c
64429e5a02b82a967da179d2b12d7fadbefa6c64
/Task_Key.h
06648db9acb85d1924af727287f12729f105664b
[]
no_license
sirasusuisan/slimeaction
ec3c99d3c1946ecc1ef6f0aca4604ad7ab8f501e
c7d602252cee4f641b777f8bd59ba920bcfd7b71
refs/heads/master
2020-04-12T13:14:12.663269
2019-02-08T02:38:24
2019-02-08T02:38:24
162,516,846
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
1,837
h
#pragma warning(disable:4996) #pragma once //------------------------------------------------------------------- // //------------------------------------------------------------------- #include "BChara.h" namespace KEY { //タスクに割り当てるグループ名と固有名 const string defGroupName("カギ"); //グループ名 const string defName("noName"); //タスク名 //------------------------------------------------------------------- class Resource { bool Initialize(); bool Finalize(); Resource(); public: ~Resource(); typedef shared_ptr<Resource> SP; typedef weak_ptr<Resource> WP; static WP instance; static Resource::SP Create(); //変更可◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇ //共有する変数はここに追加する string keyImage; }; //------------------------------------------------------------------- class Object : public BChara { public: virtual ~Object(); typedef shared_ptr<Object> SP; typedef weak_ptr<Object> WP; //生成窓口 引数はtrueでタスクシステムへ自動登録 static Object::SP Create(bool flagGameEnginePushBack_); Resource::SP res; private: Object(); bool B_Initialize(); bool B_Finalize(); bool Initialize(); //「初期化」タスク生成時に1回だけ行う処理 void UpDate(); //「実行」1フレーム毎に行う処理 void Render2D_AF(); //「2D描画」1フレーム毎に行う処理 bool Finalize(); //「終了」タスク消滅時に1回だけ行う処理 public: //変更可◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇ //追加したい変数・メソッドはここに追加する //BCharaに含まれないモノのみここに追加する bool Havekey; }; }
959efeeb7db355fca7247954421aeae1e365911f
7f439919fb8c3a8bbd0111f91217f3fd8668d262
/Projects/AILib/Cluster/Cluster_2_0/Source/main.cpp
6129e590c194a91dd46c3c451b6312071fd07fee
[]
no_license
quant-guy/Projects
459aa1e17e72057b1eef58c1926206686b32a78f
f50361dbfa9ee6e4d40cf99abf63edc6fc7e5308
refs/heads/master
2023-07-19T19:20:05.850481
2023-07-07T23:32:08
2023-07-07T23:32:08
48,806,322
0
0
null
null
null
null
UTF-8
C++
false
false
2,565
cpp
/////////////////////////////////////////////////////////////////////////////////// // COPYRIGHT 2015 Kovach Technologies, Inc. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. All advertising materials mentioning features or use of this software // must display the following acknowledgement: // This product includes software developed by the Kovach Technologies, LLC. // 4. Neither the name of the Kovach Technologies, LLC 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 Kovach Technologies, LLC 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 Kovach Technologies, LLC 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. // // AUTHOR : Daniel Kovach // DATE : 2015-12-30 10:19:06.739857 /////////////////////////////////////////////////////////////////////////////////// #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include <windows.h> #include "ClusterLibCallers.h" #ifdef _MANAGED #pragma managed( push, off ) #endif // _MANAGED BOOL APIENTRY DllMain( HMODULE, // hmodule DWORD reason_for_call, // reason for call LPVOID ) // lp reserved { switch ( reason_for_call ) { case DLL_PROCESS_ATTACH : case DLL_THREAD_ATTACH : case DLL_THREAD_DETACH : case DLL_PROCESS_DETACH : break; } return TRUE; } #ifdef _MANAGED #pragma managed( pop ) #endif // _MANAGED #endif // WIN32
f8d129f3eed5c781a15d4faf2d8e0af407ad691e
e0818dd68188d2a8db6be31944745cc6d22f27f0
/core/logic/NativeOwner.h
60cb4ef4ef0b113f0899e7c1b8dfe94b8be4d50e
[]
no_license
PMArkive/simillimum
4f36d329fa93dd3be6a034680c8a4678842c8acd
08757300821ac9b4511873416475a20615e08956
refs/heads/master
2023-03-28T07:26:57.123535
2013-07-04T23:02:54
2013-07-04T23:02:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,389
h
#ifndef _INCLUDE_SIMILLIMUM_NATIVE_OWNER_H_ #define _INCLUDE_SIMILLIMUM_NATIVE_OWNER_H_ #include <sp_vm_types.h> #include <sh_list.h> #include "common_logic.h" struct NativeEntry; class CPlugin; using namespace Simillimum; struct WeakNative { WeakNative(IPlugin *plugin, uint32_t index) : pl(plugin), idx(index), entry(NULL) { pl = plugin; idx = index; } WeakNative(IPlugin *plugin, uint32_t index, NativeEntry *pEntry) : pl(plugin), idx(index), entry(pEntry) { pl = plugin; idx = index; } IPlugin *pl; uint32_t idx; NativeEntry *entry; }; using namespace SourceHook; class CNativeOwner { public: CNativeOwner(); public: virtual void DropEverything(); public: void AddNatives(const sp_nativeinfo_t *info); public: void SetMarkSerial(unsigned int serial); unsigned int GetMarkSerial(); void PropagateMarkSerial(unsigned int serial); public: void AddDependent(CPlugin *pPlugin); void AddWeakRef(const WeakNative & ref); void DropRefsTo(CPlugin *pPlugin); void AddReplacedNative(NativeEntry *pEntry); private: void DropWeakRefsTo(CPlugin *pPlugin); void UnbindWeakRef(const WeakNative & ref); protected: List<CPlugin *> m_Dependents; unsigned int m_nMarkSerial; List<WeakNative> m_WeakRefs; List<NativeEntry *> m_Natives; List<NativeEntry *> m_ReplacedNatives; }; extern CNativeOwner g_CoreNatives; #endif //_INCLUDE_SIMILLIMUM_NATIVE_OWNER_H_
0a23dbe51a1c809ac6dd44abaeedc443b5450eb2
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/git/gumtree/git_new_log_2051.cpp
9c6b73d00565d485cf0ab8a6ddf748bbc606d0ab
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
80
cpp
die("size_t overflow: %"PRIuMAX" * %"PRIuMAX, (uintmax_t)a, (uintmax_t)b);
368596a8fb4c4f6c48cc8c8ff3619046f1a258e8
0744dcc5394cebf57ebcba343747af6871b67017
/external/protobuf/src/google/protobuf/arena_unittest.cc
c6ff25e8cda4a841ae54ce2ba501ca5507071ec3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-protobuf" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C++
false
false
52,334
cc
// Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ // // 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 Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <google/protobuf/arena.h> #include <algorithm> #include <cstring> #include <memory> #ifndef _SHARED_PTR_H #include <google/protobuf/stubs/shared_ptr.h> #endif #include <string> #include <typeinfo> #include <vector> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/arena_test_util.h> #include <google/protobuf/test_util.h> #include <google/protobuf/unittest.pb.h> #include <google/protobuf/unittest_arena.pb.h> #include <google/protobuf/unittest_no_arena.pb.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/message.h> #include <google/protobuf/message_lite.h> #include <google/protobuf/repeated_field.h> #include <google/protobuf/wire_format_lite.h> #include <google/protobuf/unknown_field_set.h> #include <gtest/gtest.h> namespace google { using proto2_arena_unittest::ArenaMessage; using protobuf_unittest::TestAllTypes; using protobuf_unittest::TestAllExtensions; using protobuf_unittest::TestOneof2; using protobuf_unittest::TestEmptyMessage; namespace protobuf { namespace { class Notifier { public: Notifier() : count_(0) {} void Notify() { count_++; } int GetCount() { return count_; } private: int count_; }; class SimpleDataType { public: SimpleDataType() : notifier_(NULL) {} void SetNotifier(Notifier* notifier) { notifier_ = notifier; } virtual ~SimpleDataType() { if (notifier_ != NULL) { notifier_->Notify(); } }; private: Notifier* notifier_; }; // A simple class that does not allow copying and so cannot be used as a // parameter type without "const &". class PleaseDontCopyMe { public: explicit PleaseDontCopyMe(int value) : value_(value) {} int value() const { return value_; } private: int value_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PleaseDontCopyMe); }; // A class that takes four different types as constructor arguments. class MustBeConstructedWithOneThroughFour { public: MustBeConstructedWithOneThroughFour( int one, const char* two, const string& three, const PleaseDontCopyMe* four) : one_(one), two_(two), three_(three), four_(four) {} int one_; const char* const two_; string three_; const PleaseDontCopyMe* four_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MustBeConstructedWithOneThroughFour); }; // A class that takes eight different types as constructor arguments. class MustBeConstructedWithOneThroughEight { public: MustBeConstructedWithOneThroughEight( int one, const char* two, const string& three, const PleaseDontCopyMe* four, int five, const char* six, const string& seven, const string& eight) : one_(one), two_(two), three_(three), four_(four), five_(five), six_(six), seven_(seven), eight_(eight) {} int one_; const char* const two_; string three_; const PleaseDontCopyMe* four_; int five_; const char* const six_; string seven_; string eight_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MustBeConstructedWithOneThroughEight); }; TEST(ArenaTest, ArenaConstructable) { EXPECT_TRUE(Arena::is_arena_constructable<TestAllTypes>::type::value); EXPECT_TRUE(Arena::is_arena_constructable<const TestAllTypes>::type::value); EXPECT_FALSE(Arena::is_arena_constructable<Arena>::type::value); } TEST(ArenaTest, BasicCreate) { Arena arena; EXPECT_TRUE(Arena::Create<int32>(&arena) != NULL); EXPECT_TRUE(Arena::Create<int64>(&arena) != NULL); EXPECT_TRUE(Arena::Create<float>(&arena) != NULL); EXPECT_TRUE(Arena::Create<double>(&arena) != NULL); EXPECT_TRUE(Arena::Create<string>(&arena) != NULL); arena.Own(new int32); arena.Own(new int64); arena.Own(new float); arena.Own(new double); arena.Own(new string); arena.Own<int>(NULL); Notifier notifier; SimpleDataType* data = Arena::Create<SimpleDataType>(&arena); data->SetNotifier(&notifier); data = new SimpleDataType; data->SetNotifier(&notifier); arena.Own(data); arena.Reset(); EXPECT_EQ(2, notifier.GetCount()); } TEST(ArenaTest, CreateAndConstCopy) { Arena arena; const string s("foo"); const string* s_copy = Arena::Create<string>(&arena, s); EXPECT_TRUE(s_copy != NULL); EXPECT_EQ("foo", s); EXPECT_EQ("foo", *s_copy); } TEST(ArenaTest, CreateAndNonConstCopy) { Arena arena; string s("foo"); const string* s_copy = Arena::Create<string>(&arena, s); EXPECT_TRUE(s_copy != NULL); EXPECT_EQ("foo", s); EXPECT_EQ("foo", *s_copy); } #if LANG_CXX11 TEST(ArenaTest, CreateAndMove) { Arena arena; string s("foo"); const string* s_move = Arena::Create<string>(&arena, std::move(s)); EXPECT_TRUE(s_move != NULL); EXPECT_TRUE(s.empty()); // NOLINT EXPECT_EQ("foo", *s_move); } #endif TEST(ArenaTest, CreateWithFourConstructorArguments) { Arena arena; const string three("3"); const PleaseDontCopyMe four(4); const MustBeConstructedWithOneThroughFour* new_object = Arena::Create<MustBeConstructedWithOneThroughFour>( &arena, 1, "2", three, &four); EXPECT_TRUE(new_object != NULL); ASSERT_EQ(1, new_object->one_); ASSERT_STREQ("2", new_object->two_); ASSERT_EQ("3", new_object->three_); ASSERT_EQ(4, new_object->four_->value()); } TEST(ArenaTest, CreateWithEightConstructorArguments) { Arena arena; const string three("3"); const PleaseDontCopyMe four(4); const string seven("7"); const string eight("8"); const MustBeConstructedWithOneThroughEight* new_object = Arena::Create<MustBeConstructedWithOneThroughEight>( &arena, 1, "2", three, &four, 5, "6", seven, eight); EXPECT_TRUE(new_object != NULL); ASSERT_EQ(1, new_object->one_); ASSERT_STREQ("2", new_object->two_); ASSERT_EQ("3", new_object->three_); ASSERT_EQ(4, new_object->four_->value()); ASSERT_EQ(5, new_object->five_); ASSERT_STREQ("6", new_object->six_); ASSERT_EQ("7", new_object->seven_); ASSERT_EQ("8", new_object->eight_); } #if LANG_CXX11 class PleaseMoveMe { public: explicit PleaseMoveMe(const string& value) : value_(value) {} PleaseMoveMe(PleaseMoveMe&&) = default; PleaseMoveMe(const PleaseMoveMe&) = delete; const string& value() const { return value_; } private: string value_; }; TEST(ArenaTest, CreateWithMoveArguments) { Arena arena; PleaseMoveMe one("1"); const PleaseMoveMe* new_object = Arena::Create<PleaseMoveMe>(&arena, std::move(one)); EXPECT_TRUE(new_object); ASSERT_EQ("1", new_object->value()); } #endif TEST(ArenaTest, InitialBlockTooSmall) { // Construct a small (64 byte) initial block of memory to be used by the // arena allocator; then, allocate an object which will not fit in the // initial block. std::vector<char> arena_block(72); ArenaOptions options; options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); Arena arena(options); char* p = ::google::protobuf::Arena::CreateArray<char>(&arena, 96); uintptr_t allocation = reinterpret_cast<uintptr_t>(p); // Ensure that the arena allocator did not return memory pointing into the // initial block of memory. uintptr_t arena_start = reinterpret_cast<uintptr_t>(&arena_block[0]); uintptr_t arena_end = arena_start + arena_block.size(); EXPECT_FALSE(allocation >= arena_start && allocation < arena_end); // Write to the memory we allocated; this should (but is not guaranteed to) // trigger a check for heap corruption if the object was allocated from the // initially-provided block. memset(p, '\0', 96); } TEST(ArenaTest, Parsing) { TestAllTypes original; TestUtil::SetAllFields(&original); // Test memory leak. Arena arena; TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); arena_message->ParseFromString(original.SerializeAsString()); TestUtil::ExpectAllFieldsSet(*arena_message); // Test that string fields have nul terminator bytes (earlier bug). EXPECT_EQ(strlen(original.optional_string().c_str()), strlen(arena_message->optional_string().c_str())); } TEST(ArenaTest, UnknownFields) { TestAllTypes original; TestUtil::SetAllFields(&original); // Test basic parsing into (populating) and reading out of unknown fields on // an arena. Arena arena; TestEmptyMessage* arena_message = Arena::CreateMessage<TestEmptyMessage>(&arena); arena_message->ParseFromString(original.SerializeAsString()); TestAllTypes copied; copied.ParseFromString(arena_message->SerializeAsString()); TestUtil::ExpectAllFieldsSet(copied); // Exercise UFS manual manipulation (setters). arena_message = Arena::CreateMessage<TestEmptyMessage>(&arena); arena_message->mutable_unknown_fields()->AddVarint( TestAllTypes::kOptionalInt32FieldNumber, 42); copied.Clear(); copied.ParseFromString(arena_message->SerializeAsString()); EXPECT_TRUE(copied.has_optional_int32()); EXPECT_EQ(42, copied.optional_int32()); // Exercise UFS swap path. TestEmptyMessage* arena_message_2 = Arena::CreateMessage<TestEmptyMessage>(&arena); arena_message_2->Swap(arena_message); copied.Clear(); copied.ParseFromString(arena_message_2->SerializeAsString()); EXPECT_TRUE(copied.has_optional_int32()); EXPECT_EQ(42, copied.optional_int32()); // Test field manipulation. TestEmptyMessage* arena_message_3 = Arena::CreateMessage<TestEmptyMessage>(&arena); arena_message_3->mutable_unknown_fields()->AddVarint(1000, 42); arena_message_3->mutable_unknown_fields()->AddFixed32(1001, 42); arena_message_3->mutable_unknown_fields()->AddFixed64(1002, 42); arena_message_3->mutable_unknown_fields()->AddLengthDelimited(1003); arena_message_3->mutable_unknown_fields()->DeleteSubrange(0, 2); arena_message_3->mutable_unknown_fields()->DeleteByNumber(1002); arena_message_3->mutable_unknown_fields()->DeleteByNumber(1003); EXPECT_TRUE(arena_message_3->unknown_fields().empty()); } TEST(ArenaTest, Swap) { Arena arena1; Arena arena2; TestAllTypes* arena1_message; TestAllTypes* arena2_message; // Case 1: Swap(), no UFS on either message, both messages on different // arenas. Arena pointers should remain the same after swap. arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2); arena1_message->Swap(arena2_message); EXPECT_EQ(&arena1, arena1_message->GetArena()); EXPECT_EQ(&arena2, arena2_message->GetArena()); // Case 2: Swap(), UFS on one message, both messages on different arenas. arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2); arena1_message->mutable_unknown_fields()->AddVarint(1, 42); arena1_message->Swap(arena2_message); EXPECT_EQ(&arena1, arena1_message->GetArena()); EXPECT_EQ(&arena2, arena2_message->GetArena()); EXPECT_EQ(0, arena1_message->unknown_fields().field_count()); EXPECT_EQ(1, arena2_message->unknown_fields().field_count()); EXPECT_EQ(42, arena2_message->unknown_fields().field(0).varint()); // Case 3: Swap(), UFS on both messages, both messages on different arenas. arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2); arena1_message->mutable_unknown_fields()->AddVarint(1, 42); arena2_message->mutable_unknown_fields()->AddVarint(2, 84); arena1_message->Swap(arena2_message); EXPECT_EQ(&arena1, arena1_message->GetArena()); EXPECT_EQ(&arena2, arena2_message->GetArena()); EXPECT_EQ(1, arena1_message->unknown_fields().field_count()); EXPECT_EQ(1, arena2_message->unknown_fields().field_count()); EXPECT_EQ(84, arena1_message->unknown_fields().field(0).varint()); EXPECT_EQ(42, arena2_message->unknown_fields().field(0).varint()); } TEST(ArenaTest, ReflectionSwapFields) { Arena arena1; Arena arena2; TestAllTypes* arena1_message; TestAllTypes* arena2_message; // Case 1: messages on different arenas, only one message is set. arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2); TestUtil::SetAllFields(arena1_message); const Reflection* reflection = arena1_message->GetReflection(); std::vector<const FieldDescriptor*> fields; reflection->ListFields(*arena1_message, &fields); reflection->SwapFields(arena1_message, arena2_message, fields); EXPECT_EQ(&arena1, arena1_message->GetArena()); EXPECT_EQ(&arena2, arena2_message->GetArena()); string output; arena1_message->SerializeToString(&output); EXPECT_EQ(0, output.size()); TestUtil::ExpectAllFieldsSet(*arena2_message); reflection->SwapFields(arena1_message, arena2_message, fields); arena2_message->SerializeToString(&output); EXPECT_EQ(0, output.size()); TestUtil::ExpectAllFieldsSet(*arena1_message); // Case 2: messages on different arenas, both messages are set. arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2); TestUtil::SetAllFields(arena1_message); TestUtil::SetAllFields(arena2_message); reflection->SwapFields(arena1_message, arena2_message, fields); EXPECT_EQ(&arena1, arena1_message->GetArena()); EXPECT_EQ(&arena2, arena2_message->GetArena()); TestUtil::ExpectAllFieldsSet(*arena1_message); TestUtil::ExpectAllFieldsSet(*arena2_message); // Case 3: messages on different arenas with different lifetimes. arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); { Arena arena3; TestAllTypes* arena3_message = Arena::CreateMessage<TestAllTypes>(&arena3); TestUtil::SetAllFields(arena3_message); reflection->SwapFields(arena1_message, arena3_message, fields); } TestUtil::ExpectAllFieldsSet(*arena1_message); // Case 4: one message on arena, the other on heap. arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); TestAllTypes message; TestUtil::SetAllFields(arena1_message); reflection->SwapFields(arena1_message, &message, fields); EXPECT_EQ(&arena1, arena1_message->GetArena()); EXPECT_EQ(NULL, message.GetArena()); arena1_message->SerializeToString(&output); EXPECT_EQ(0, output.size()); TestUtil::ExpectAllFieldsSet(message); } TEST(ArenaTest, SetAllocatedMessage) { Arena arena; TestAllTypes *arena_message = Arena::CreateMessage<TestAllTypes>(&arena); TestAllTypes::NestedMessage* nested = new TestAllTypes::NestedMessage; nested->set_bb(118); arena_message->set_allocated_optional_nested_message(nested); EXPECT_EQ(118, arena_message->optional_nested_message().bb()); protobuf_unittest_no_arena::TestNoArenaMessage no_arena_message; EXPECT_FALSE(no_arena_message.has_arena_message()); no_arena_message.set_allocated_arena_message(NULL); EXPECT_FALSE(no_arena_message.has_arena_message()); no_arena_message.set_allocated_arena_message(new ArenaMessage); EXPECT_TRUE(no_arena_message.has_arena_message()); } TEST(ArenaTest, ReleaseMessage) { Arena arena; TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); arena_message->mutable_optional_nested_message()->set_bb(118); google::protobuf::scoped_ptr<TestAllTypes::NestedMessage> nested( arena_message->release_optional_nested_message()); EXPECT_EQ(118, nested->bb()); TestAllTypes::NestedMessage* released_null = arena_message->release_optional_nested_message(); EXPECT_EQ(NULL, released_null); } TEST(ArenaTest, SetAllocatedString) { Arena arena; TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); string* allocated_str = new string("hello"); arena_message->set_allocated_optional_string(allocated_str); EXPECT_EQ("hello", arena_message->optional_string()); } TEST(ArenaTest, ReleaseString) { Arena arena; TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); arena_message->set_optional_string("hello"); google::protobuf::scoped_ptr<string> released_str( arena_message->release_optional_string()); EXPECT_EQ("hello", *released_str); // Test default value. } TEST(ArenaTest, SwapBetweenArenasWithAllFieldsSet) { Arena arena1; TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); { Arena arena2; TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2); TestUtil::SetAllFields(arena2_message); arena2_message->Swap(arena1_message); string output; arena2_message->SerializeToString(&output); EXPECT_EQ(0, output.size()); } TestUtil::ExpectAllFieldsSet(*arena1_message); } TEST(ArenaTest, SwapBetweenArenaAndNonArenaWithAllFieldsSet) { TestAllTypes non_arena_message; TestUtil::SetAllFields(&non_arena_message); { Arena arena2; TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2); TestUtil::SetAllFields(arena2_message); arena2_message->Swap(&non_arena_message); TestUtil::ExpectAllFieldsSet(*arena2_message); TestUtil::ExpectAllFieldsSet(non_arena_message); } } TEST(ArenaTest, UnsafeArenaSwap) { Arena shared_arena; TestAllTypes* message1 = Arena::CreateMessage<TestAllTypes>(&shared_arena); TestAllTypes* message2 = Arena::CreateMessage<TestAllTypes>(&shared_arena); TestUtil::SetAllFields(message1); message1->UnsafeArenaSwap(message2); TestUtil::ExpectAllFieldsSet(*message2); } TEST(ArenaTest, SwapBetweenArenasUsingReflection) { Arena arena1; TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); { Arena arena2; TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2); TestUtil::SetAllFields(arena2_message); const Reflection* r = arena2_message->GetReflection(); r->Swap(arena1_message, arena2_message); string output; arena2_message->SerializeToString(&output); EXPECT_EQ(0, output.size()); } TestUtil::ExpectAllFieldsSet(*arena1_message); } TEST(ArenaTest, SwapBetweenArenaAndNonArenaUsingReflection) { TestAllTypes non_arena_message; TestUtil::SetAllFields(&non_arena_message); { Arena arena2; TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2); TestUtil::SetAllFields(arena2_message); const Reflection* r = arena2_message->GetReflection(); r->Swap(&non_arena_message, arena2_message); TestUtil::ExpectAllFieldsSet(*arena2_message); TestUtil::ExpectAllFieldsSet(non_arena_message); } } TEST(ArenaTest, ReleaseFromArenaMessageMakesCopy) { TestAllTypes::NestedMessage* nested_msg = NULL; string* nested_string = NULL; { Arena arena; TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); arena_message->mutable_optional_nested_message()->set_bb(42); *arena_message->mutable_optional_string() = "Hello"; nested_msg = arena_message->release_optional_nested_message(); nested_string = arena_message->release_optional_string(); } EXPECT_EQ(42, nested_msg->bb()); EXPECT_EQ("Hello", *nested_string); delete nested_msg; delete nested_string; } #ifndef GOOGLE_PROTOBUF_NO_RTTI TEST(ArenaTest, ReleaseFromArenaMessageUsingReflectionMakesCopy) { TestAllTypes::NestedMessage* nested_msg = NULL; // Note: no string: reflection API only supports releasing submessages. { Arena arena; TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); arena_message->mutable_optional_nested_message()->set_bb(42); const Reflection* r = arena_message->GetReflection(); const FieldDescriptor* f = arena_message->GetDescriptor()->FindFieldByName( "optional_nested_message"); nested_msg = static_cast<TestAllTypes::NestedMessage*>( r->ReleaseMessage(arena_message, f)); } EXPECT_EQ(42, nested_msg->bb()); delete nested_msg; } #endif // !GOOGLE_PROTOBUF_NO_RTTI TEST(ArenaTest, UnsafeArenaReleaseDoesNotMakeCopy) { Arena arena; TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); TestAllTypes::NestedMessage* nested_msg = NULL; TestAllTypes::NestedMessage* orig_nested_msg = NULL; string* nested_string = NULL; string* orig_nested_string = NULL; arena_message->mutable_optional_nested_message()->set_bb(42); *arena_message->mutable_optional_string() = "Hello"; orig_nested_msg = arena_message->mutable_optional_nested_message(); orig_nested_string = arena_message->mutable_optional_string(); nested_msg = arena_message->unsafe_arena_release_optional_nested_message(); nested_string = arena_message->unsafe_arena_release_optional_string(); EXPECT_EQ(orig_nested_msg, nested_msg); EXPECT_EQ(orig_nested_string, nested_string); // Released pointers still on arena; no 'delete' calls needed here. } TEST(ArenaTest, SetAllocatedAcrossArenas) { Arena arena1; TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); TestAllTypes::NestedMessage* heap_submessage = new TestAllTypes::NestedMessage(); heap_submessage->set_bb(42); arena1_message->set_allocated_optional_nested_message(heap_submessage); // Should keep same object and add to arena's Own()-list. EXPECT_EQ(heap_submessage, arena1_message->mutable_optional_nested_message()); { Arena arena2; TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2); arena2_submessage->set_bb(42); arena1_message->set_allocated_optional_nested_message(arena2_submessage); EXPECT_NE(arena2_submessage, arena1_message->mutable_optional_nested_message()); } TestAllTypes::NestedMessage* arena1_submessage = Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena1); arena1_submessage->set_bb(42); TestAllTypes* heap_message = new TestAllTypes; heap_message->set_allocated_optional_nested_message(arena1_submessage); EXPECT_NE(arena1_submessage, heap_message->mutable_optional_nested_message()); delete heap_message; } TEST(ArenaTest, SetAllocatedAcrossArenasWithReflection) { // Same as above, with reflection. Arena arena1; TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); const Reflection* r = arena1_message->GetReflection(); const Descriptor* d = arena1_message->GetDescriptor(); const FieldDescriptor* msg_field = d->FindFieldByName( "optional_nested_message"); TestAllTypes::NestedMessage* heap_submessage = new TestAllTypes::NestedMessage(); heap_submessage->set_bb(42); r->SetAllocatedMessage(arena1_message, heap_submessage, msg_field); // Should keep same object and add to arena's Own()-list. EXPECT_EQ(heap_submessage, arena1_message->mutable_optional_nested_message()); { Arena arena2; TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2); arena2_submessage->set_bb(42); r->SetAllocatedMessage(arena1_message, arena2_submessage, msg_field); EXPECT_NE(arena2_submessage, arena1_message->mutable_optional_nested_message()); } TestAllTypes::NestedMessage* arena1_submessage = Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena1); arena1_submessage->set_bb(42); TestAllTypes* heap_message = new TestAllTypes; r->SetAllocatedMessage(heap_message, arena1_submessage, msg_field); EXPECT_NE(arena1_submessage, heap_message->mutable_optional_nested_message()); delete heap_message; } TEST(ArenaTest, AddAllocatedWithReflection) { Arena arena1; ArenaMessage* arena1_message = Arena::CreateMessage<ArenaMessage>(&arena1); const Reflection* r = arena1_message->GetReflection(); const Descriptor* d = arena1_message->GetDescriptor(); const FieldDescriptor* fd = d->FindFieldByName("repeated_import_no_arena_message"); // Message with cc_enable_arenas = false; r->AddMessage(arena1_message, fd); r->AddMessage(arena1_message, fd); r->AddMessage(arena1_message, fd); EXPECT_EQ(3, r->FieldSize(*arena1_message, fd)); // Message with cc_enable_arenas = true; fd = d->FindFieldByName("repeated_nested_message"); r->AddMessage(arena1_message, fd); r->AddMessage(arena1_message, fd); r->AddMessage(arena1_message, fd); EXPECT_EQ(3, r->FieldSize(*arena1_message, fd)); } TEST(ArenaTest, RepeatedPtrFieldAddClearedTest) { { RepeatedPtrField<TestAllTypes> repeated_field; EXPECT_TRUE(repeated_field.empty()); EXPECT_EQ(0, repeated_field.size()); // Ownership is passed to repeated_field. TestAllTypes* cleared = new TestAllTypes(); repeated_field.AddCleared(cleared); EXPECT_TRUE(repeated_field.empty()); EXPECT_EQ(0, repeated_field.size()); } { RepeatedPtrField<TestAllTypes> repeated_field; EXPECT_TRUE(repeated_field.empty()); EXPECT_EQ(0, repeated_field.size()); // Ownership is passed to repeated_field. TestAllTypes* cleared = new TestAllTypes(); repeated_field.AddAllocated(cleared); EXPECT_FALSE(repeated_field.empty()); EXPECT_EQ(1, repeated_field.size()); } } TEST(ArenaTest, AddAllocatedToRepeatedField) { // Heap->arena case. Arena arena1; TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); for (int i = 0; i < 10; i++) { TestAllTypes::NestedMessage* heap_submessage = new TestAllTypes::NestedMessage(); heap_submessage->set_bb(42); arena1_message->mutable_repeated_nested_message()-> AddAllocated(heap_submessage); // Should not copy object -- will use arena_->Own(). EXPECT_EQ(heap_submessage, &arena1_message->repeated_nested_message(i)); EXPECT_EQ(42, arena1_message->repeated_nested_message(i).bb()); } // Arena1->Arena2 case. arena1_message->Clear(); for (int i = 0; i < 10; i++) { Arena arena2; TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2); arena2_submessage->set_bb(42); arena1_message->mutable_repeated_nested_message()-> AddAllocated(arena2_submessage); // Should copy object. EXPECT_NE(arena2_submessage, &arena1_message->repeated_nested_message(i)); EXPECT_EQ(42, arena1_message->repeated_nested_message(i).bb()); } // Arena->heap case. TestAllTypes* heap_message = new TestAllTypes(); for (int i = 0; i < 10; i++) { Arena arena2; TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2); arena2_submessage->set_bb(42); heap_message->mutable_repeated_nested_message()-> AddAllocated(arena2_submessage); // Should copy object. EXPECT_NE(arena2_submessage, &heap_message->repeated_nested_message(i)); EXPECT_EQ(42, heap_message->repeated_nested_message(i).bb()); } delete heap_message; // Heap-arena case for strings (which are not arena-allocated). arena1_message->Clear(); for (int i = 0; i < 10; i++) { string* s = new string("Test"); arena1_message->mutable_repeated_string()-> AddAllocated(s); // Should not copy. EXPECT_EQ(s, &arena1_message->repeated_string(i)); EXPECT_EQ("Test", arena1_message->repeated_string(i)); } } TEST(ArenaTest, AddAllocatedToRepeatedFieldViaReflection) { // Heap->arena case. Arena arena1; TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); const Reflection* r = arena1_message->GetReflection(); const Descriptor* d = arena1_message->GetDescriptor(); const FieldDescriptor* fd = d->FindFieldByName("repeated_nested_message"); for (int i = 0; i < 10; i++) { TestAllTypes::NestedMessage* heap_submessage = new TestAllTypes::NestedMessage; heap_submessage->set_bb(42); r->AddAllocatedMessage(arena1_message, fd, heap_submessage); // Should not copy object -- will use arena_->Own(). EXPECT_EQ(heap_submessage, &arena1_message->repeated_nested_message(i)); EXPECT_EQ(42, arena1_message->repeated_nested_message(i).bb()); } // Arena1->Arena2 case. arena1_message->Clear(); for (int i = 0; i < 10; i++) { Arena arena2; TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2); arena2_submessage->set_bb(42); r->AddAllocatedMessage(arena1_message, fd, arena2_submessage); // Should copy object. EXPECT_NE(arena2_submessage, &arena1_message->repeated_nested_message(i)); EXPECT_EQ(42, arena1_message->repeated_nested_message(i).bb()); } // Arena->heap case. TestAllTypes* heap_message = new TestAllTypes; for (int i = 0; i < 10; i++) { Arena arena2; TestAllTypes::NestedMessage* arena2_submessage = Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2); arena2_submessage->set_bb(42); r->AddAllocatedMessage(heap_message, fd, arena2_submessage); // Should copy object. EXPECT_NE(arena2_submessage, &heap_message->repeated_nested_message(i)); EXPECT_EQ(42, heap_message->repeated_nested_message(i).bb()); } delete heap_message; } TEST(ArenaTest, ReleaseLastRepeatedField) { // Release from arena-allocated repeated field and ensure that returned object // is heap-allocated. Arena arena; TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); for (int i = 0; i < 10; i++) { TestAllTypes::NestedMessage* nested = Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena); nested->set_bb(42); arena_message->mutable_repeated_nested_message()->AddAllocated(nested); } for (int i = 0; i < 10; i++) { const TestAllTypes::NestedMessage *orig_submessage = &arena_message->repeated_nested_message(10 - 1 - i); // last element TestAllTypes::NestedMessage *released = arena_message->mutable_repeated_nested_message()->ReleaseLast(); EXPECT_NE(released, orig_submessage); EXPECT_EQ(42, released->bb()); delete released; } // Test UnsafeArenaReleaseLast(). for (int i = 0; i < 10; i++) { TestAllTypes::NestedMessage* nested = Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena); nested->set_bb(42); arena_message->mutable_repeated_nested_message()->AddAllocated(nested); } for (int i = 0; i < 10; i++) { const TestAllTypes::NestedMessage *orig_submessage = &arena_message->repeated_nested_message(10 - 1 - i); // last element TestAllTypes::NestedMessage *released = arena_message->mutable_repeated_nested_message()-> UnsafeArenaReleaseLast(); EXPECT_EQ(released, orig_submessage); EXPECT_EQ(42, released->bb()); // no delete -- |released| is on the arena. } // Test string case as well. ReleaseLast() in this case must copy the string, // even though it was originally heap-allocated and its pointer was simply // appended to the repeated field's internal vector, because the string was // placed on the arena's destructor list and cannot be removed from that list // (so the arena permanently owns the original instance). arena_message->Clear(); for (int i = 0; i < 10; i++) { string* s = new string("Test"); arena_message->mutable_repeated_string()->AddAllocated(s); } for (int i = 0; i < 10; i++) { const string* orig_element = &arena_message->repeated_string(10 - 1 - i); string* released = arena_message->mutable_repeated_string()->ReleaseLast(); EXPECT_NE(released, orig_element); EXPECT_EQ("Test", *released); delete released; } } TEST(ArenaTest, UnsafeArenaReleaseAdd) { // Use unsafe_arena_release() and unsafe_arena_set_allocated() to transfer an // arena-allocated string from one message to another. Arena arena; TestAllTypes* message1 = Arena::CreateMessage<TestAllTypes>(&arena); TestAllTypes* message2 = Arena::CreateMessage<TestAllTypes>(&arena); string* arena_string = Arena::Create<string>(&arena); *arena_string = "Test content"; message1->unsafe_arena_set_allocated_optional_string(arena_string); EXPECT_EQ(arena_string, message1->mutable_optional_string()); message2->unsafe_arena_set_allocated_optional_string( message1->unsafe_arena_release_optional_string()); EXPECT_EQ(arena_string, message2->mutable_optional_string()); } TEST(ArenaTest, UnsafeArenaAddAllocated) { Arena arena; TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); for (int i = 0; i < 10; i++) { string* arena_string = Arena::Create<string>(&arena); message->mutable_repeated_string()->UnsafeArenaAddAllocated(arena_string); EXPECT_EQ(arena_string, message->mutable_repeated_string(i)); } } TEST(ArenaTest, UnsafeArenaRelease) { Arena arena; TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); string* s = new string("test string"); message->unsafe_arena_set_allocated_optional_string(s); EXPECT_TRUE(message->has_optional_string()); EXPECT_EQ("test string", message->optional_string()); s = message->unsafe_arena_release_optional_string(); EXPECT_FALSE(message->has_optional_string()); delete s; s = new string("test string"); message->unsafe_arena_set_allocated_oneof_string(s); EXPECT_TRUE(message->has_oneof_string()); EXPECT_EQ("test string", message->oneof_string()); s = message->unsafe_arena_release_oneof_string(); EXPECT_FALSE(message->has_oneof_string()); delete s; } TEST(ArenaTest, OneofMerge) { Arena arena; TestAllTypes* message0 = Arena::CreateMessage<TestAllTypes>(&arena); TestAllTypes* message1 = Arena::CreateMessage<TestAllTypes>(&arena); message0->unsafe_arena_set_allocated_oneof_string(new string("x")); ASSERT_TRUE(message0->has_oneof_string()); message1->unsafe_arena_set_allocated_oneof_string(new string("y")); ASSERT_TRUE(message1->has_oneof_string()); EXPECT_EQ("x", message0->oneof_string()); EXPECT_EQ("y", message1->oneof_string()); message0->MergeFrom(*message1); EXPECT_EQ("y", message0->oneof_string()); EXPECT_EQ("y", message1->oneof_string()); delete message0->unsafe_arena_release_oneof_string(); delete message1->unsafe_arena_release_oneof_string(); } TEST(ArenaTest, ArenaOneofReflection) { Arena arena; TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); const Descriptor* desc = message->GetDescriptor(); const Reflection* refl = message->GetReflection(); const FieldDescriptor* string_field = desc->FindFieldByName( "oneof_string"); const FieldDescriptor* msg_field = desc->FindFieldByName( "oneof_nested_message"); const OneofDescriptor* oneof = desc->FindOneofByName( "oneof_field"); refl->SetString(message, string_field, "Test value"); EXPECT_TRUE(refl->HasOneof(*message, oneof)); refl->ClearOneof(message, oneof); EXPECT_FALSE(refl->HasOneof(*message, oneof)); Message* submsg = refl->MutableMessage(message, msg_field); EXPECT_TRUE(refl->HasOneof(*message, oneof)); refl->ClearOneof(message, oneof); EXPECT_FALSE(refl->HasOneof(*message, oneof)); refl->MutableMessage(message, msg_field); EXPECT_TRUE(refl->HasOneof(*message, oneof)); submsg = refl->ReleaseMessage(message, msg_field); EXPECT_FALSE(refl->HasOneof(*message, oneof)); EXPECT_TRUE(submsg->GetArena() == NULL); delete submsg; } void TestSwapRepeatedField(Arena* arena1, Arena* arena2) { // Test "safe" (copying) semantics for direct Swap() on RepeatedPtrField // between arenas. RepeatedPtrField<TestAllTypes> field1(arena1); RepeatedPtrField<TestAllTypes> field2(arena2); for (int i = 0; i < 10; i++) { TestAllTypes* t = Arena::CreateMessage<TestAllTypes>(arena1); t->set_optional_string("field1"); t->set_optional_int32(i); if (arena1 != NULL) { field1.UnsafeArenaAddAllocated(t); } else { field1.AddAllocated(t); } } for (int i = 0; i < 5; i++) { TestAllTypes* t = Arena::CreateMessage<TestAllTypes>(arena2); t->set_optional_string("field2"); t->set_optional_int32(i); if (arena2 != NULL) { field2.UnsafeArenaAddAllocated(t); } else { field2.AddAllocated(t); } } field1.Swap(&field2); EXPECT_EQ(5, field1.size()); EXPECT_EQ(10, field2.size()); EXPECT_TRUE(string("field1") == field2.Get(0).optional_string()); EXPECT_TRUE(string("field2") == field1.Get(0).optional_string()); // Ensure that fields retained their original order: for (int i = 0; i < field1.size(); i++) { EXPECT_EQ(i, field1.Get(i).optional_int32()); } for (int i = 0; i < field2.size(); i++) { EXPECT_EQ(i, field2.Get(i).optional_int32()); } } TEST(ArenaTest, SwapRepeatedField) { Arena arena; TestSwapRepeatedField(&arena, &arena); } TEST(ArenaTest, SwapRepeatedFieldWithDifferentArenas) { Arena arena1; Arena arena2; TestSwapRepeatedField(&arena1, &arena2); } TEST(ArenaTest, SwapRepeatedFieldWithNoArenaOnRightHandSide) { Arena arena; TestSwapRepeatedField(&arena, NULL); } TEST(ArenaTest, SwapRepeatedFieldWithNoArenaOnLeftHandSide) { Arena arena; TestSwapRepeatedField(NULL, &arena); } TEST(ArenaTest, ExtensionsOnArena) { Arena arena; // Ensure no leaks. TestAllExtensions* message_ext = Arena::CreateMessage<TestAllExtensions>(&arena); message_ext->SetExtension( protobuf_unittest::optional_int32_extension, 42); message_ext->SetExtension( protobuf_unittest::optional_string_extension, string("test")); message_ext->MutableExtension( protobuf_unittest::optional_nested_message_extension)->set_bb(42); } TEST(ArenaTest, RepeatedFieldOnArena) { // Preallocate an initial arena block to avoid mallocs during hooked region. std::vector<char> arena_block(1024 * 1024); ArenaOptions options; options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); Arena arena(options); { internal::NoHeapChecker no_heap; // Fill some repeated fields on the arena to test for leaks. Also verify no // memory allocations. RepeatedField<int32> repeated_int32(&arena); RepeatedPtrField<TestAllTypes> repeated_message(&arena); for (int i = 0; i < 100; i++) { repeated_int32.Add(42); repeated_message.Add()->set_optional_int32(42); EXPECT_EQ(&arena, repeated_message.Get(0).GetArena()); const TestAllTypes* msg_in_repeated_field = &repeated_message.Get(0); TestAllTypes* msg = repeated_message.UnsafeArenaReleaseLast(); EXPECT_EQ(msg_in_repeated_field, msg); } // UnsafeArenaExtractSubrange (i) should not leak and (ii) should return // on-arena pointers. for (int i = 0; i < 10; i++) { repeated_message.Add()->set_optional_int32(42); } TestAllTypes* extracted_messages[5]; repeated_message.UnsafeArenaExtractSubrange(0, 5, extracted_messages); EXPECT_EQ(&arena, repeated_message.Get(0).GetArena()); EXPECT_EQ(5, repeated_message.size()); } // Now, outside the scope of the NoHeapChecker, test ExtractSubrange's copying // semantics. { RepeatedPtrField<TestAllTypes> repeated_message(&arena); for (int i = 0; i < 100; i++) { repeated_message.Add()->set_optional_int32(42); } TestAllTypes* extracted_messages[5]; // ExtractSubrange should copy to the heap. repeated_message.ExtractSubrange(0, 5, extracted_messages); EXPECT_EQ(NULL, extracted_messages[0]->GetArena()); // We need to free the heap-allocated messages to prevent a leak. for (int i = 0; i < 5; i++) { delete extracted_messages[i]; extracted_messages[i] = NULL; } } // Now check that we can create RepeatedFields/RepeatedPtrFields themselves on // the arena. They have the necessary type traits so that they can behave like // messages in this way. This is useful for higher-level generic templated // code that may allocate messages or repeated fields of messages on an arena. { RepeatedPtrField<TestAllTypes>* repeated_ptr_on_arena = Arena::CreateMessage< RepeatedPtrField<TestAllTypes> >(&arena); for (int i = 0; i < 10; i++) { // Add some elements and let the leak-checker ensure that everything is // freed. repeated_ptr_on_arena->Add(); } RepeatedField<int>* repeated_int_on_arena = Arena::CreateMessage< RepeatedField<int> >(&arena); for (int i = 0; i < 100; i++) { repeated_int_on_arena->Add(i); } } arena.Reset(); } #ifndef GOOGLE_PROTOBUF_NO_RTTI TEST(ArenaTest, MutableMessageReflection) { Arena arena; TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); const Reflection* r = message->GetReflection(); const Descriptor* d = message->GetDescriptor(); const FieldDescriptor* field = d->FindFieldByName("optional_nested_message"); TestAllTypes::NestedMessage* submessage = static_cast<TestAllTypes::NestedMessage*>( r->MutableMessage(message, field)); TestAllTypes::NestedMessage* submessage_expected = message->mutable_optional_nested_message(); EXPECT_EQ(submessage_expected, submessage); EXPECT_EQ(&arena, submessage->GetArena()); const FieldDescriptor* oneof_field = d->FindFieldByName("oneof_nested_message"); submessage = static_cast<TestAllTypes::NestedMessage*>( r->MutableMessage(message, oneof_field)); submessage_expected = message->mutable_oneof_nested_message(); EXPECT_EQ(submessage_expected, submessage); EXPECT_EQ(&arena, submessage->GetArena()); } #endif // !GOOGLE_PROTOBUF_NO_RTTI void FillArenaAwareFields(TestAllTypes* message) { string test_string = "hello world"; message->set_optional_int32(42); message->set_optional_string(test_string); message->set_optional_bytes(test_string); message->mutable_optional_nested_message()->set_bb(42); message->set_oneof_uint32(42); message->mutable_oneof_nested_message()->set_bb(42); message->set_oneof_string(test_string); message->set_oneof_bytes(test_string); message->add_repeated_int32(42); // No repeated string: not yet arena-aware. message->add_repeated_nested_message()->set_bb(42); message->mutable_optional_lazy_message()->set_bb(42); } // Test: no allocations occur on heap while touching all supported field types. TEST(ArenaTest, NoHeapAllocationsTest) { // Allocate a large initial block to avoid mallocs during hooked test. std::vector<char> arena_block(128 * 1024); ArenaOptions options; options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); Arena arena(options); { TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); FillArenaAwareFields(message); } arena.Reset(); } TEST(ArenaTest, ParseCorruptedString) { TestAllTypes message; TestUtil::SetAllFields(&message); TestParseCorruptedString<TestAllTypes, true>(message); TestParseCorruptedString<TestAllTypes, false>(message); } #ifndef GOOGLE_PROTOBUF_NO_RTTI // Test construction on an arena via generic MessageLite interface. We should be // able to successfully deserialize on the arena without incurring heap // allocations, i.e., everything should still be arena-allocation-aware. TEST(ArenaTest, MessageLiteOnArena) { std::vector<char> arena_block(128 * 1024); ArenaOptions options; options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); Arena arena(options); const google::protobuf::MessageLite* prototype = &TestAllTypes::default_instance(); TestAllTypes initial_message; FillArenaAwareFields(&initial_message); string serialized; initial_message.SerializeToString(&serialized); { google::protobuf::MessageLite* generic_message = prototype->New(&arena); EXPECT_TRUE(generic_message != NULL); EXPECT_EQ(&arena, generic_message->GetArena()); EXPECT_TRUE(generic_message->ParseFromString(serialized)); TestAllTypes* deserialized = static_cast<TestAllTypes*>(generic_message); EXPECT_EQ(42, deserialized->optional_int32()); } arena.Reset(); } #endif // !GOOGLE_PROTOBUF_NO_RTTI // RepeatedField should support non-POD types, and invoke constructors and // destructors appropriately, because it's used this way by lots of other code // (even if this was not its original intent). TEST(ArenaTest, RepeatedFieldWithNonPODType) { { RepeatedField<string> field_on_heap; for (int i = 0; i < 100; i++) { *field_on_heap.Add() = "test string long enough to exceed inline buffer"; } } { Arena arena; RepeatedField<string> field_on_arena(&arena); for (int i = 0; i < 100; i++) { *field_on_arena.Add() = "test string long enough to exceed inline buffer"; } } } // Align n to next multiple of 8 uint64 Align8(uint64 n) { return (n + 7) & -8; } TEST(ArenaTest, SpaceAllocated_and_Used) { ArenaOptions options; options.start_block_size = 256; options.max_block_size = 8192; Arena arena_1(options); EXPECT_EQ(0, arena_1.SpaceAllocated()); EXPECT_EQ(0, arena_1.SpaceUsed()); EXPECT_EQ(0, arena_1.Reset()); ::google::protobuf::Arena::CreateArray<char>(&arena_1, 320); // Arena will allocate slightly more than 320 for the block headers. EXPECT_LE(320, arena_1.SpaceAllocated()); EXPECT_EQ(Align8(320), arena_1.SpaceUsed()); EXPECT_LE(320, arena_1.Reset()); // Test with initial block. std::vector<char> arena_block(1024); options.initial_block = &arena_block[0]; options.initial_block_size = arena_block.size(); Arena arena_2(options); EXPECT_EQ(1024, arena_2.SpaceAllocated()); EXPECT_EQ(0, arena_2.SpaceUsed()); EXPECT_EQ(1024, arena_2.Reset()); ::google::protobuf::Arena::CreateArray<char>(&arena_2, 55); EXPECT_EQ(1024, arena_2.SpaceAllocated()); EXPECT_EQ(Align8(55), arena_2.SpaceUsed()); EXPECT_EQ(1024, arena_2.Reset()); // Reset options to test doubling policy explicitly. options.initial_block = NULL; options.initial_block_size = 0; Arena arena_3(options); EXPECT_EQ(0, arena_3.SpaceUsed()); ::google::protobuf::Arena::CreateArray<char>(&arena_3, 182); EXPECT_EQ(256, arena_3.SpaceAllocated()); EXPECT_EQ(Align8(182), arena_3.SpaceUsed()); ::google::protobuf::Arena::CreateArray<char>(&arena_3, 70); EXPECT_EQ(256 + 512, arena_3.SpaceAllocated()); EXPECT_EQ(Align8(182) + Align8(70), arena_3.SpaceUsed()); EXPECT_EQ(256 + 512, arena_3.Reset()); } TEST(ArenaTest, Alignment) { ::google::protobuf::Arena arena; for (int i = 0; i < 200; i++) { void* p = ::google::protobuf::Arena::CreateArray<char>(&arena, i); GOOGLE_CHECK_EQ(reinterpret_cast<uintptr_t>(p) % 8, 0) << i << ": " << p; } } TEST(ArenaTest, BlockSizeSmallerThanAllocation) { for (size_t i = 0; i <= 8; ++i) { ::google::protobuf::ArenaOptions opt; opt.start_block_size = opt.max_block_size = i; ::google::protobuf::Arena arena(opt); *::google::protobuf::Arena::Create<int64>(&arena) = 42; EXPECT_GE(arena.SpaceAllocated(), 8); EXPECT_EQ(8, arena.SpaceUsed()); *::google::protobuf::Arena::Create<int64>(&arena) = 42; EXPECT_GE(arena.SpaceAllocated(), 16); EXPECT_EQ(16, arena.SpaceUsed()); } } TEST(ArenaTest, GetArenaShouldReturnTheArenaForArenaAllocatedMessages) { ::google::protobuf::Arena arena; ArenaMessage* message = Arena::CreateMessage<ArenaMessage>(&arena); const ArenaMessage* const_pointer_to_message = message; EXPECT_EQ(&arena, Arena::GetArena(message)); EXPECT_EQ(&arena, Arena::GetArena(const_pointer_to_message)); } TEST(ArenaTest, GetArenaShouldReturnNullForNonArenaAllocatedMessages) { ArenaMessage message; const ArenaMessage* const_pointer_to_message = &message; EXPECT_EQ(NULL, Arena::GetArena(&message)); EXPECT_EQ(NULL, Arena::GetArena(const_pointer_to_message)); } TEST(ArenaTest, UnsafeSetAllocatedOnArena) { ::google::protobuf::Arena arena; TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); EXPECT_FALSE(message->has_optional_string()); string owned_string = "test with long enough content to heap-allocate"; message->unsafe_arena_set_allocated_optional_string(&owned_string); EXPECT_TRUE(message->has_optional_string()); message->unsafe_arena_set_allocated_optional_string(NULL); EXPECT_FALSE(message->has_optional_string()); } // A helper utility class to only contain static hook functions, some // counters to be used to verify the counters have been called and a cookie // value to be verified. class ArenaHooksTestUtil { public: static void* on_init(::google::protobuf::Arena* arena) { ++num_init; int* cookie = new int(kCookieValue); return static_cast<void*>(cookie); } static void on_allocation(const std::type_info* /*unused*/, uint64 alloc_size, void* cookie) { ++num_allocations; int cookie_value = *static_cast<int*>(cookie); EXPECT_EQ(kCookieValue, cookie_value); } static void on_reset(::google::protobuf::Arena* arena, void* cookie, uint64 space_used) { ++num_reset; int cookie_value = *static_cast<int*>(cookie); EXPECT_EQ(kCookieValue, cookie_value); } static void on_destruction(::google::protobuf::Arena* arena, void* cookie, uint64 space_used) { ++num_destruct; int cookie_value = *static_cast<int*>(cookie); EXPECT_EQ(kCookieValue, cookie_value); delete static_cast<int*>(cookie); } static const int kCookieValue = 999; static uint32 num_init; static uint32 num_allocations; static uint32 num_reset; static uint32 num_destruct; }; uint32 ArenaHooksTestUtil::num_init = 0; uint32 ArenaHooksTestUtil::num_allocations = 0; uint32 ArenaHooksTestUtil::num_reset = 0; uint32 ArenaHooksTestUtil::num_destruct = 0; const int ArenaHooksTestUtil::kCookieValue; // Test the hooks are correctly called and that the cookie is passed. TEST(ArenaTest, ArenaHooksSanity) { ::google::protobuf::ArenaOptions options; options.on_arena_init = ArenaHooksTestUtil::on_init; options.on_arena_allocation = ArenaHooksTestUtil::on_allocation; options.on_arena_reset = ArenaHooksTestUtil::on_reset; options.on_arena_destruction = ArenaHooksTestUtil::on_destruction; // Scope for defining the arena { ::google::protobuf::Arena arena(options); EXPECT_EQ(1, ArenaHooksTestUtil::num_init); EXPECT_EQ(0, ArenaHooksTestUtil::num_allocations); ::google::protobuf::Arena::Create<uint64>(&arena); if (google::protobuf::internal::has_trivial_destructor<uint64>::value) { EXPECT_EQ(1, ArenaHooksTestUtil::num_allocations); } else { EXPECT_EQ(2, ArenaHooksTestUtil::num_allocations); } arena.Reset(); arena.Reset(); EXPECT_EQ(2, ArenaHooksTestUtil::num_reset); } EXPECT_EQ(3, ArenaHooksTestUtil::num_reset); EXPECT_EQ(1, ArenaHooksTestUtil::num_destruct); } } // namespace } // namespace protobuf } // namespace google
4ef08c3490c13f50e4f5dbaafe7898adbd282da1
76ac094e1bdb51b21cc8ea9caf9b4c486e6e5e15
/GPRO-Graphics1/include/gpro/ray.h
183d3d71b248a42a2360fe06fc218f40281ef5fa
[ "Apache-2.0" ]
permissive
cmurph2412/cameronMurphy_gpr-200
b5cb7866bc14137a11e35e95733f22f84a14a771
a0095b310382787a03c43167285f1be1472111f1
refs/heads/master
2023-01-13T14:34:29.267996
2020-09-11T11:15:52
2020-09-11T11:15:52
292,635,591
0
0
null
null
null
null
UTF-8
C++
false
false
696
h
#pragma once /* Author: Cameron-Murphy Class: GPR-200-01 Assignment: Lab 1: Hello Modern Graphics Due Date: 9/11/20 */ #include <iostream> #include "gpro-math/gproVector.h" using namespace std; //Class for casting a ray class ray { public: ray() {} //Default constructor ray(const point3& origin, const vec3& direction) : orig(origin), dir(direction) {} //Constructor (takes origin and direction of ray) point3 origin() const { return orig; } //Returns origin vec3 direction() const { return dir; } //Returns direction //Points at specified point point3 at(float t) const { return orig + t * dir; } private: //Member variables point3 orig; vec3 dir; };
7c320b5a5d57a3e7118198f9725d8dee6fa9d6d4
64cb681c4430d699035e24bdc6e29019c72b0f94
/renderdoc/driver/d3d12/d3d12_command_list4_wrap.cpp
2d1d6b854391132e06ca92bdeb6856dbf2795f7d
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
new-TonyWang/renderdoc
ebd7d0e338b0e56164930915ebce4c0f411f2977
ac9c37e2e9ba4b9ab6740c020e65681eceba45dd
refs/heads/v1.x
2023-07-09T17:03:11.345913
2021-08-18T02:54:41
2021-08-18T02:54:41
379,597,382
0
0
MIT
2021-08-18T03:15:31
2021-06-23T12:35:00
C++
UTF-8
C++
false
false
17,496
cpp
/****************************************************************************** * The MIT License (MIT) * * Copyright (c) 2019-2021 Baldur Karlsson * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. ******************************************************************************/ #include "d3d12_command_list.h" #include "d3d12_debug.h" template <typename SerialiserType> bool WrappedID3D12GraphicsCommandList::Serialise_BeginRenderPass( SerialiserType &ser, UINT NumRenderTargets, const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, D3D12_RENDER_PASS_FLAGS Flags) { ID3D12GraphicsCommandList4 *pCommandList = this; SERIALISE_ELEMENT(pCommandList); SERIALISE_ELEMENT(NumRenderTargets); SERIALISE_ELEMENT_ARRAY(pRenderTargets, NumRenderTargets); SERIALISE_ELEMENT_OPT(pDepthStencil); SERIALISE_ELEMENT(Flags); // since CPU handles are consumed in the call, we need to read out and serialise the contents // here. rdcarray<D3D12Descriptor> RTVs; D3D12Descriptor DSV; { if(ser.IsWriting()) { for(UINT i = 0; i < NumRenderTargets; i++) RTVs.push_back(*GetWrapped(pRenderTargets[i].cpuDescriptor)); } // read and serialise the D3D12Descriptor contents directly, as the call has semantics of // consuming the descriptor immediately SERIALISE_ELEMENT(RTVs).Named("RenderTargetDescriptors"_lit); } { // read and serialise the D3D12Descriptor contents directly, as the call has semantics of // consuming the descriptor immediately. const D3D12Descriptor *pDSV = NULL; if(ser.IsWriting()) pDSV = pDepthStencil ? GetWrapped(pDepthStencil->cpuDescriptor) : NULL; SERIALISE_ELEMENT_OPT(pDSV).Named("DepthStencilDescriptor"_lit); if(pDSV) DSV = *pDSV; } SERIALISE_CHECK_READ_ERRORS(); if(IsReplayingAndReading()) { if(GetWrapped(pCommandList)->GetReal4() == NULL) { RDCERR("Can't replay ID3D12GraphicsCommandList4 command"); return false; } m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList)); // patch the parameters so that we point into our local CPU descriptor handles that are up // to date { D3D12_RENDER_PASS_RENDER_TARGET_DESC *rts = (D3D12_RENDER_PASS_RENDER_TARGET_DESC *)pRenderTargets; D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *ds = (D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *)pDepthStencil; for(UINT i = 0; i < NumRenderTargets; i++) rts[i].cpuDescriptor = Unwrap(m_pDevice->GetDebugManager()->GetTempDescriptor(RTVs[i], i)); if(ds) ds->cpuDescriptor = Unwrap(m_pDevice->GetDebugManager()->GetTempDescriptor(DSV)); } bool stateUpdate = false; if(IsActiveReplaying(m_State)) { if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID)) { // perform any clears needed for(UINT i = 0; i < NumRenderTargets; i++) { if(pRenderTargets[i].BeginningAccess.Type == D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR) { Unwrap(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID)) ->ClearRenderTargetView(pRenderTargets[i].cpuDescriptor, pRenderTargets[i].BeginningAccess.Clear.ClearValue.Color, 0, NULL); } } if(pDepthStencil) { D3D12_CLEAR_FLAGS flags = {}; if(pDepthStencil->DepthBeginningAccess.Type == D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR) flags |= D3D12_CLEAR_FLAG_DEPTH; if(pDepthStencil->StencilBeginningAccess.Type == D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR) flags |= D3D12_CLEAR_FLAG_STENCIL; if(flags != 0) { // we can safely read from either depth/stencil clear values because if the access // type isn't clear the corresponding flag will be unset - so whatever garbage value // we have isn't used. Unwrap(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID)) ->ClearDepthStencilView( pDepthStencil->cpuDescriptor, flags, pDepthStencil->DepthBeginningAccess.Clear.ClearValue.DepthStencil.Depth, pDepthStencil->StencilBeginningAccess.Clear.ClearValue.DepthStencil.Stencil, 0, NULL); } } { D3D12_CPU_DESCRIPTOR_HANDLE rtHandles[8]; D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = {}; if(pDepthStencil) dsvHandle = pDepthStencil->cpuDescriptor; for(UINT i = 0; i < NumRenderTargets; i++) rtHandles[i] = pRenderTargets[i].cpuDescriptor; // need to unwrap here, as FromPortableHandle unwraps too. Unwrap(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID)) ->OMSetRenderTargets(NumRenderTargets, rtHandles, FALSE, dsvHandle.ptr ? &dsvHandle : NULL); } // Unwrap4(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))->BeginRenderPass(NumRenderTargets, // pRenderTargets, pDepthStencil, Flags); if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID)) { m_Cmd->m_Partial[D3D12CommandData::Primary].renderPassActive = true; } stateUpdate = true; } else if(!m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID)) { stateUpdate = true; } } else { for(UINT i = 0; i < NumRenderTargets; i++) { if(pRenderTargets[i].BeginningAccess.Type == D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR) { Unwrap(pCommandList) ->ClearRenderTargetView(pRenderTargets[i].cpuDescriptor, pRenderTargets[i].BeginningAccess.Clear.ClearValue.Color, 0, NULL); } } if(pDepthStencil) { D3D12_CLEAR_FLAGS flags = {}; if(pDepthStencil->DepthBeginningAccess.Type == D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR) flags |= D3D12_CLEAR_FLAG_DEPTH; if(pDepthStencil->StencilBeginningAccess.Type == D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR) flags |= D3D12_CLEAR_FLAG_STENCIL; if(flags != 0) { // we can safely read from either depth/stencil clear values because if the access // type isn't clear the corresponding flag will be unset - so whatever garbage value // we have isn't used. Unwrap(pCommandList) ->ClearDepthStencilView( pDepthStencil->cpuDescriptor, flags, pDepthStencil->DepthBeginningAccess.Clear.ClearValue.DepthStencil.Depth, pDepthStencil->StencilBeginningAccess.Clear.ClearValue.DepthStencil.Stencil, 0, NULL); } } D3D12_CPU_DESCRIPTOR_HANDLE rtHandles[8]; D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = {}; if(pDepthStencil) dsvHandle = pDepthStencil->cpuDescriptor; for(UINT i = 0; i < NumRenderTargets; i++) rtHandles[i] = pRenderTargets[i].cpuDescriptor; // need to unwrap here, as FromPortableHandle unwraps too. Unwrap(pCommandList) ->OMSetRenderTargets(NumRenderTargets, rtHandles, FALSE, dsvHandle.ptr ? &dsvHandle : NULL); GetCrackedList()->OMSetRenderTargets(NumRenderTargets, rtHandles, FALSE, dsvHandle.ptr ? &dsvHandle : NULL); // Unwrap4(pCommandList)->BeginRenderPass(NumRenderTargets, pRenderTargets, pDepthStencil, // Flags); // GetCrackedList4()->BeginRenderPass(NumRenderTargets, pRenderTargets, pDepthStencil, Flags); m_Cmd->AddEvent(); DrawcallDescription draw; draw.name = "BeginRenderPass()"; draw.flags |= DrawFlags::BeginPass | DrawFlags::PassBoundary; m_Cmd->AddDrawcall(draw, true); stateUpdate = true; } if(stateUpdate) { D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state; state.rts = RTVs; state.dsv = DSV; state.renderpass = true; state.rpRTs.resize(NumRenderTargets); for(UINT r = 0; r < NumRenderTargets; r++) state.rpRTs[r] = pRenderTargets[r]; state.rpDSV = {}; if(pDepthStencil) state.rpDSV = *pDepthStencil; state.rpFlags = Flags; } } return true; } void WrappedID3D12GraphicsCommandList::BeginRenderPass( UINT NumRenderTargets, const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, D3D12_RENDER_PASS_FLAGS Flags) { D3D12_RENDER_PASS_RENDER_TARGET_DESC *unwrappedRTs = m_pDevice->GetTempArray<D3D12_RENDER_PASS_RENDER_TARGET_DESC>(NumRenderTargets); for(UINT i = 0; i < NumRenderTargets; i++) { unwrappedRTs[i] = pRenderTargets[i]; unwrappedRTs[i].cpuDescriptor = Unwrap(unwrappedRTs[i].cpuDescriptor); } D3D12_RENDER_PASS_DEPTH_STENCIL_DESC unwrappedDSV; if(pDepthStencil) { unwrappedDSV = *pDepthStencil; unwrappedDSV.cpuDescriptor = Unwrap(unwrappedDSV.cpuDescriptor); } SERIALISE_TIME_CALL(m_pList4->BeginRenderPass(NumRenderTargets, unwrappedRTs, pDepthStencil ? &unwrappedDSV : NULL, Flags)); if(IsCaptureMode(m_State)) { CACHE_THREAD_SERIALISER(); SCOPED_SERIALISE_CHUNK(D3D12Chunk::List_BeginRenderPass); Serialise_BeginRenderPass(ser, NumRenderTargets, pRenderTargets, pDepthStencil, Flags); m_ListRecord->AddChunk(scope.Get(m_ListRecord->cmdInfo->alloc)); for(UINT i = 0; i < NumRenderTargets; i++) { D3D12Descriptor *desc = GetWrapped(pRenderTargets[i].cpuDescriptor); m_ListRecord->MarkResourceFrameReferenced(desc->GetHeapResourceId(), eFrameRef_Read); m_ListRecord->MarkResourceFrameReferenced(desc->GetResResourceId(), eFrameRef_PartialWrite); if(pRenderTargets[i].EndingAccess.Type == D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE) { m_ListRecord->MarkResourceFrameReferenced( GetResID(pRenderTargets[i].EndingAccess.Resolve.pSrcResource), eFrameRef_PartialWrite); m_ListRecord->MarkResourceFrameReferenced( GetResID(pRenderTargets[i].EndingAccess.Resolve.pDstResource), eFrameRef_PartialWrite); } } if(pDepthStencil) { D3D12Descriptor *desc = GetWrapped(pDepthStencil->cpuDescriptor); m_ListRecord->MarkResourceFrameReferenced(desc->GetHeapResourceId(), eFrameRef_Read); m_ListRecord->MarkResourceFrameReferenced(desc->GetResResourceId(), eFrameRef_PartialWrite); if(pDepthStencil->DepthEndingAccess.Type == D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE) { m_ListRecord->MarkResourceFrameReferenced( GetResID(pDepthStencil->DepthEndingAccess.Resolve.pSrcResource), eFrameRef_PartialWrite); m_ListRecord->MarkResourceFrameReferenced( GetResID(pDepthStencil->DepthEndingAccess.Resolve.pDstResource), eFrameRef_PartialWrite); } if(pDepthStencil->StencilEndingAccess.Type == D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE) { m_ListRecord->MarkResourceFrameReferenced( GetResID(pDepthStencil->StencilEndingAccess.Resolve.pSrcResource), eFrameRef_PartialWrite); m_ListRecord->MarkResourceFrameReferenced( GetResID(pDepthStencil->StencilEndingAccess.Resolve.pDstResource), eFrameRef_PartialWrite); } } } } template <typename SerialiserType> bool WrappedID3D12GraphicsCommandList::Serialise_EndRenderPass(SerialiserType &ser) { ID3D12GraphicsCommandList4 *pCommandList = this; SERIALISE_ELEMENT(pCommandList); SERIALISE_CHECK_READ_ERRORS(); if(IsReplayingAndReading()) { if(GetWrapped(pCommandList)->GetReal4() == NULL) { RDCERR("Can't replay ID3D12GraphicsCommandList4 command"); return false; } m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList)); bool stateUpdate = false; if(IsActiveReplaying(m_State)) { if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID)) { // Unwrap4(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))->EndRenderPass(); if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID)) { m_Cmd->m_Partial[D3D12CommandData::Primary].renderPassActive = false; } stateUpdate = true; } else if(!m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID)) { stateUpdate = true; } } else { // Unwrap4(pCommandList)->EndRenderPass(); // GetCrackedList4()->EndRenderPass(); m_Cmd->AddEvent(); DrawcallDescription draw; draw.name = "EndRenderPass()"; draw.flags |= DrawFlags::EndPass | DrawFlags::PassBoundary; m_Cmd->AddDrawcall(draw, true); stateUpdate = true; } if(stateUpdate) { D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state; state.rts.clear(); state.dsv = D3D12Descriptor(); state.renderpass = false; state.rpRTs.clear(); state.rpDSV = {}; state.rpFlags = D3D12_RENDER_PASS_FLAG_NONE; } } return true; } void WrappedID3D12GraphicsCommandList::EndRenderPass() { SERIALISE_TIME_CALL(m_pList4->EndRenderPass()); if(IsCaptureMode(m_State)) { CACHE_THREAD_SERIALISER(); SCOPED_SERIALISE_CHUNK(D3D12Chunk::List_EndRenderPass); Serialise_EndRenderPass(ser); m_ListRecord->AddChunk(scope.Get(m_ListRecord->cmdInfo->alloc)); } } void WrappedID3D12GraphicsCommandList::InitializeMetaCommand( _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, _In_ SIZE_T InitializationParametersDataSizeInBytes) { RDCERR("InitializeMetaCommand called but no meta commands reported!"); } void WrappedID3D12GraphicsCommandList::ExecuteMetaCommand( _In_ ID3D12MetaCommand *pMetaCommand, _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, _In_ SIZE_T ExecutionParametersDataSizeInBytes) { RDCERR("ExecuteMetaCommand called but no meta commands reported!"); } void WrappedID3D12GraphicsCommandList::BuildRaytracingAccelerationStructure( _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, _In_ UINT NumPostbuildInfoDescs, _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs) { RDCERR("BuildRaytracingAccelerationStructure called but raytracing is not supported!"); } void WrappedID3D12GraphicsCommandList::EmitRaytracingAccelerationStructurePostbuildInfo( _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, _In_ UINT NumSourceAccelerationStructures, _In_reads_(NumSourceAccelerationStructures) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData) { RDCERR( "EmitRaytracingAccelerationStructurePostbuildInfo called but raytracing is not supported!"); } void WrappedID3D12GraphicsCommandList::CopyRaytracingAccelerationStructure( _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode) { RDCERR("CopyRaytracingAccelerationStructure called but raytracing is not supported!"); } void WrappedID3D12GraphicsCommandList::SetPipelineState1(_In_ ID3D12StateObject *pStateObject) { RDCERR("SetPipelineState1 called but raytracing is not supported!"); } void WrappedID3D12GraphicsCommandList::DispatchRays(_In_ const D3D12_DISPATCH_RAYS_DESC *pDesc) { RDCERR("DispatchRays called but raytracing is not supported!"); } INSTANTIATE_FUNCTION_SERIALISED(void, WrappedID3D12GraphicsCommandList, BeginRenderPass, UINT NumRenderTargets, const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, D3D12_RENDER_PASS_FLAGS Flags); INSTANTIATE_FUNCTION_SERIALISED(void, WrappedID3D12GraphicsCommandList, EndRenderPass);
651e324033995d4670fd1a510de2ed3f384b84b0
91934b8ad2f42f29c445d511c6dd273b7e35ed86
/juce/extras/Jucer (experimental)/Source/Project/jucer_ResourceFile.h
2da1661c8a5e2e1ac47d1046a43709815a54d7d6
[]
no_license
fubyo/osccalibrator
882d348ecf738a11f9bfddf3511693a69d6c1d9e
9c3652957c2ddc3d2a550f80be1cdb5e6707b8ce
refs/heads/master
2021-01-10T21:04:00.712697
2015-03-16T12:45:03
2015-03-16T12:45:03
32,316,417
0
0
null
null
null
null
UTF-8
C++
false
false
2,483
h
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-10 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE 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. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ #ifndef __JUCER_RESOURCEFILE_JUCEHEADER__ #define __JUCER_RESOURCEFILE_JUCEHEADER__ #include "../jucer_Headers.h" #include "jucer_Project.h" //============================================================================== class ResourceFile { public: //============================================================================== ResourceFile (Project& project); ~ResourceFile(); //============================================================================== static bool isResourceFile (const File& file); //============================================================================== void setJuceHeaderToInclude (const File& header); void setClassName (const String& className); void addFile (const File& file); int getNumFiles() const { return files.size(); } int64 getTotalDataSize() const; bool write (const File& cppFile); bool write (const File& cppFile, OutputStream& cpp, OutputStream& header); //============================================================================== private: OwnedArray <File> files; Project& project; File juceHeader; String className; void addResourcesFromProjectItem (const Project::Item& node); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResourceFile); }; #endif // __JUCER_RESOURCEFILE_JUCEHEADER__
beab033f0dcb4ed184d77a23c80c4501bed420f2
88c71cdaf84eae321d4d31d96e2ed7c685f7e56e
/network_programming/threaded_async_client_server/threaded_async_client_server---Example-1---Version-1/my_connection.hpp
74cddf78baacb0e03592303edaff3c0879199d2e
[]
no_license
joydeeps/boost.asio
44b3e4f49818c5028c082a79eea41302778da63c
3c953d595d96d7be9d51a7d429fc4f083557a15f
refs/heads/master
2021-01-17T04:32:11.792370
2016-06-09T17:43:51
2016-06-09T17:43:51
58,666,470
0
0
null
null
null
null
UTF-8
C++
false
false
1,199
hpp
#include <boost/asio.hpp> #include <boost/shared_ptr.hpp> #include <boost/thread.hpp> class my_connection { public: my_connection() // constructor { close = false; // create new socket into which to receive the new connection this->socket = boost::shared_ptr<boost::asio::ip::tcp::socket>( new boost::asio::ip::tcp::socket(this->io_service) ); } // we must have a new io_service for EVERY THREAD! boost::asio::io_service io_service; // where we receive the accepted socket and endpoint boost::shared_ptr<boost::asio::ip::tcp::socket> socket; boost::asio::ip::tcp::endpoint endpoint; // keep track of the thread for this connection boost::shared_ptr<boost::thread> thread; // keep track of the acceptor io_service so we can call stop() on it! boost::asio::io_service *master_io_service; // boolean to indicate a desire to kill this connection bool close; // NOTE: you can add other variables here that store connection-specific // data, such as received HTML headers, or logged in username, or whatever // else you want to keep track of over a connection };
a6101f3c7eafe8f79855577a8992d23bf6954098
b5b5e825a618a37587f5cd41e03a52ad1c6e58f1
/src/doppelganger-routing/model/ipv4-doppelganger-routing.cc
684696f080acc5771e151ec7525e6fc67af28259
[]
no_license
wantonsolutions/replica-selection
e6cb2243284021b0f1d0d95c66bc8a15582451b3
7ac34eaacc6477f0801c4b744c6592152a40d8b0
refs/heads/master
2021-04-21T22:01:26.876399
2021-02-02T19:07:14
2021-02-02T19:07:14
249,820,031
1
0
null
null
null
null
UTF-8
C++
false
false
45,170
cc
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ #include "ipv4-doppelganger-routing.h" #include "ns3/log.h" #include "ns3/simulator.h" #include "ns3/net-device.h" #include "ns3/channel.h" #include "ns3/node.h" #include "ns3/flow-id-tag.h" #include "ns3/rpc-server.h" #include "ipv4-doppelganger-tag.h" #include <algorithm> #define LOOPBACK_PORT 0 namespace ns3 { NS_LOG_COMPONENT_DEFINE("Ipv4DoppelgangerRouting"); NS_OBJECT_ENSURE_REGISTERED(Ipv4DoppelgangerRouting); Ipv4DoppelgangerRouting::Ipv4DoppelgangerRouting() : // Parameters m_isLeaf(false), m_leafId(0), m_tdre(MicroSeconds(200)), m_alpha(0.2), m_C(DataRate("1Gbps")), m_Q(3), m_agingTime(MilliSeconds(10)), m_flowletTimeout(MicroSeconds(50)), // The default value of flowlet timeout is small for experimental purpose m_ecmpMode(false), // Variables m_feedbackIndex(0), m_dreEvent(), m_agingEvent(), m_ipv4(0), // doppelganger added parameters m_addr(1), m_serverLoad(NULL), m_serverLoad_update(NULL), m_fattree_switch_type(endhost), m_packet_redirections(0), m_total_packets(0), m_fattree_k(0) { NS_LOG_FUNCTION(this); } void translateIp(int base, int *a, int *b, int *c, int *d) { *d = base % 256; base = base / 256; *c = base % 256; base = base / 256; *b = base % 256; base = base / 256; *a = base % 256; return; } uint32_t toIP(int a, int b, int c, int d) { uint32_t total = 0; total += a << 24; total += b << 16; total += c << 8; total += d; return total; } std::string stringIP(uint32_t ip) { int a, b, c, d; translateIp(ip, &a, &b, &c, &d); std::ostringstream oss; oss << a << "." << b << "." << c << "." << d; std::string var = oss.str(); return var; } void printIP(uint32_t ip) { int a, b, c, d; translateIp(ip, &a, &b, &c, &d); NS_LOG_WARN(a << "." << b << "." << c << "." << d); } bool SamePod(Ipv4Address first, Ipv4Address second) { int a1, b1, c1, d1, a2, b2, c2, d2; translateIp(first.Get(), &a1, &b1, &c1, &d1); translateIp(second.Get(), &a2, &b2, &c2, &d2); return b1 == b2; } bool ClientBelowTor(uint32_t torIp, uint32_t clientIp){ int a1, b1, c1, d1, a2, b2, c2, d2; translateIp(torIp, &a1, &b1, &c1, &d1); translateIp(clientIp, &a2, &b2, &c2, &d2); return (a1 == a2 && b1 == b2 && c1 == c2); } uint32_t OtherPodAddress(Ipv4Address current, int K) { int a, b, c, d; translateIp(current.Get(), &a, &b, &c, &d); //Simple other pod, it requires knowledge of K though b = (b + 1) % K; return toIP(a, b, c, d); } uint64_t GetInformationDelay(InformationDelayFunction df, uint64_t constant_delay) { switch (df) { case constant: //This requires that we have some measure of distance to the servers that we are going to return Simulator::Now().GetNanoSeconds() - constant_delay; break; case (uniformRandomErrorSTD || 1): //This is some serious bullshit why wont the const value of uniformRandomErrorSTD link to a local package { uint64_t mean = constant_delay; uint64_t std = (mean * 65) / 100; uint64_t error_value; //Deal with case where mean is 0 if (std == 0) { error_value = 0; } else { error_value = rand() % std; } uint64_t final_delay = 0; if (rand() % 2) { final_delay = mean - error_value; } else { final_delay = mean + error_value; } uint64_t now = Simulator::Now().GetNanoSeconds(); return now - final_delay; } default: { NS_LOG_INFO("The Strategy " << df << " is not yet implemented check ipv4-doppleganger-routing.cc (InformationDelayFuction) -- Returning 0 delay"); return Simulator::Now().GetNanoSeconds(); } } } Ipv4DoppelgangerRouting::~Ipv4DoppelgangerRouting() { NS_LOG_FUNCTION(this); } TypeId Ipv4DoppelgangerRouting::GetTypeId(void) { static TypeId tid = TypeId("ns3::Ipv4DoppelgangerRouting") .SetParent<Object>() .SetGroupName("Internet") .AddConstructor<Ipv4DoppelgangerRouting>(); return tid; } void Ipv4DoppelgangerRouting::SetLeafId(uint32_t leafId) { m_isLeaf = true; m_leafId = leafId; } void Ipv4DoppelgangerRouting::SetFlowletTimeout(Time timeout) { m_flowletTimeout = timeout; } void Ipv4DoppelgangerRouting::SetAlpha(double alpha) { m_alpha = alpha; } void Ipv4DoppelgangerRouting::SetTDre(Time time) { m_tdre = time; } void Ipv4DoppelgangerRouting::SetLinkCapacity(DataRate dataRate) { m_C = dataRate; } void Ipv4DoppelgangerRouting::SetLinkCapacity(uint32_t interface, DataRate dataRate) { m_Cs[interface] = dataRate; } void Ipv4DoppelgangerRouting::SetQ(uint32_t q) { m_Q = q; } void Ipv4DoppelgangerRouting::AddAddressToLeafIdMap(Ipv4Address addr, uint32_t leafId) { m_ipLeafIdMap[addr] = leafId; } void Ipv4DoppelgangerRouting::EnableEcmpMode() { m_ecmpMode = true; } void Ipv4DoppelgangerRouting::SetQueueDelta(uint32_t delta) { m_delta_queue_difference = delta; } uint32_t Ipv4DoppelgangerRouting::GetQueueDelta() { return m_delta_queue_difference; } void Ipv4DoppelgangerRouting::InitCongestion(uint32_t leafId, uint32_t port, uint32_t congestion) { std::map<uint32_t, std::map<uint32_t, std::pair<Time, uint32_t>>>::iterator itr = m_doppelgangerToLeafTable.find(leafId); if (itr != m_doppelgangerToLeafTable.end()) { (itr->second)[port] = std::make_pair(Simulator::Now(), congestion); } else { std::map<uint32_t, std::pair<Time, uint32_t>> newMap; newMap[port] = std::make_pair(Simulator::Now(), congestion); m_doppelgangerToLeafTable[leafId] = newMap; } } void Ipv4DoppelgangerRouting::AddRoute(Ipv4Address network, Ipv4Mask networkMask, uint32_t port) { NS_LOG_LOGIC(this << " Add Doppelganger routing entry: " << network << "/" << networkMask << " would go through port: " << port); DoppelgangerRouteEntry doppelgangerRouteEntry; doppelgangerRouteEntry.network = network; doppelgangerRouteEntry.networkMask = networkMask; doppelgangerRouteEntry.port = port; m_routeEntryList.push_back(doppelgangerRouteEntry); } std::vector<DoppelgangerRouteEntry> Ipv4DoppelgangerRouting::LookupDoppelgangerRouteEntries(Ipv4Address dest) { std::vector<DoppelgangerRouteEntry> doppelgangerRouteEntries; std::vector<DoppelgangerRouteEntry>::iterator itr = m_routeEntryList.begin(); for (; itr != m_routeEntryList.end(); ++itr) { if ((*itr).networkMask.IsMatch(dest, (*itr).network)) { doppelgangerRouteEntries.push_back(*itr); } } return doppelgangerRouteEntries; } std::vector<DoppelgangerRouteEntry> Ipv4DoppelgangerRouting::LookupDoppelgangerRouteEntriesIP(Ipv4Address dest) { std::vector<DoppelgangerRouteEntry> doppelgangerRouteEntries; std::vector<DoppelgangerRouteEntry>::iterator itr = m_routeEntryList.begin(); for (; itr != m_routeEntryList.end(); ++itr) { if (dest.Get() == (*itr).network.Get()) { doppelgangerRouteEntries.push_back(*itr); } } return doppelgangerRouteEntries; } Ptr<Ipv4Route> Ipv4DoppelgangerRouting::ConstructIpv4Route(uint32_t port, Ipv4Address destAddress) { Ptr<NetDevice> dev = m_ipv4->GetNetDevice(port); Ptr<Channel> channel = dev->GetChannel(); uint32_t otherEnd = (channel->GetDevice(0) == dev) ? 1 : 0; Ptr<Node> nextHop = channel->GetDevice(otherEnd)->GetNode(); uint32_t nextIf = channel->GetDevice(otherEnd)->GetIfIndex(); Ipv4Address nextHopAddr = nextHop->GetObject<Ipv4>()->GetAddress(nextIf, 0).GetLocal(); Ptr<Ipv4Route> route = Create<Ipv4Route>(); route->SetOutputDevice(m_ipv4->GetNetDevice(port)); route->SetGateway(nextHopAddr); route->SetSource(m_ipv4->GetAddress(port, 0).GetLocal()); route->SetDestination(destAddress); return route; } /* BEGIN DoppleGanger Routing */ void Ipv4DoppelgangerRouting::SetRpcServices(std::vector<std::vector<int>> rpcServices) { m_rpc_server_replicas = rpcServices; } void Ipv4DoppelgangerRouting::SetGlobalServerLoad(uint64_t *serverLoad) { m_serverLoad = serverLoad; } void Ipv4DoppelgangerRouting::SetLocalServerLoad(std::map<uint32_t,uint64_t> local_load){ m_local_server_load = local_load; } void Ipv4DoppelgangerRouting::InitLocalServerLoad() { std::map<uint32_t, uint32_t>::iterator it; for ( it = m_server_ip_map.begin(); it != m_server_ip_map.end(); it++ ) { m_local_server_load[it->first] = 0; } } void Ipv4DoppelgangerRouting::SetGlobalServerLoadUpdate(Time *serverLoad_update) { m_serverLoad_update = serverLoad_update; } void Ipv4DoppelgangerRouting::SetGlobalServerLoadLog(std::vector<std::vector<LoadEvent>> *global_load_log) { m_load_log = global_load_log; } void Ipv4DoppelgangerRouting::SetIPServerMap(std::map<uint32_t, uint32_t> ip_map) { m_server_ip_map = ip_map; } uint64_t Ipv4DoppelgangerRouting::GetDuration() { return m_duration; } void Ipv4DoppelgangerRouting::SetDuration(uint64_t duration) { m_duration = duration; } void Ipv4DoppelgangerRouting::InitTorMsgTimerMap(std::map<uint32_t, uint32_t> server_ip_map) { std::map<uint32_t,uint64_t> tor_msg_timer_map; int a, b, c, d; std::map<uint32_t, uint32_t>::iterator it; for ( it = server_ip_map.begin(); it != server_ip_map.end(); it++ ) { uint32_t server_ip = it->first; translateIp(server_ip, &a, &b, &c, &d); uint32_t tor_ip = toIP(a,b,c,1); tor_msg_timer_map[tor_ip] = 0; //m_local_server_load[it->first] = 0; } m_tor_msg_timer_map = tor_msg_timer_map; } void Ipv4DoppelgangerRouting::SetLoadBalencingStrategy(LoadBalencingStrategy strat) { m_load_balencing_strategy = strat; } void Ipv4DoppelgangerRouting::SetAddress(Ipv4Address addr) { m_addr = addr; } Ipv4Address Ipv4DoppelgangerRouting::GetAddress() { return m_addr; } void Ipv4DoppelgangerRouting::SetFatTreeSwitchType(FatTreeSwitchType ftst) { m_fattree_switch_type = ftst; } Ipv4DoppelgangerRouting::FatTreeSwitchType Ipv4DoppelgangerRouting::GetFatTreeSwitchType() { return m_fattree_switch_type; } uint64_t Ipv4DoppelgangerRouting::GetPacketRedirections() { return m_packet_redirections; } uint64_t Ipv4DoppelgangerRouting::GetTotalPackets() { return m_total_packets; } void Ipv4DoppelgangerRouting::SetFatTreeK(uint k) { m_fattree_k = k; } uint Ipv4DoppelgangerRouting::GetFatTreeK(void) { return m_fattree_k; } void Ipv4DoppelgangerRouting::SetInformationDelayFunction(InformationDelayFunction delay_function) { m_delay_function = delay_function; } InformationDelayFunction Ipv4DoppelgangerRouting::GetInformationDelayFunction() { return m_delay_function; } void Ipv4DoppelgangerRouting::SetConstantDelay(uint64_t delay) { m_constant_information_delay = delay; } uint64_t Ipv4DoppelgangerRouting::GetConstantDelay() { return m_constant_information_delay; } void Ipv4DoppelgangerRouting::SetLoadSpreadInterval(uint64_t spread_interval){ m_load_spread_interval = spread_interval; } uint64_t Ipv4DoppelgangerRouting::GetLoadSpreadInterval() { return m_load_spread_interval; } void Ipv4DoppelgangerRouting::SetGlobalTorQueueDepth(std::map<uint32_t,uint32_t> *tor_service_queue_depth){ m_tor_service_queue_depth = tor_service_queue_depth; //cheating for now, this is also going to intialize the local tor Queue Depth } void Ipv4DoppelgangerRouting::SetLocalTorQueueDepth(std::map<uint32_t,uint32_t> tor_service_queue_depth) { m_local_tor_service_queue_depth = tor_service_queue_depth; } void Ipv4DoppelgangerRouting::UpdateLocalTorQueueDepth(Ipv4DoppelgangerTag tag){ if (tag.TorQueuesAreNULL()){ return; } for(int i=0;i<KTAG/2;i++) { m_local_tor_service_queue_depth[tag.GetTorReplica(i)] = tag.GetTorReplicaQueueDepth(i); } UpdateMsgTimers(tag); } void Ipv4DoppelgangerRouting::UpdateMsgTimers(Ipv4DoppelgangerTag tag) { //Update information about the timing of the last update uint32_t host_ip = tag.GetTorReplica(0); //use any endhost int a,b,c,d; translateIp(host_ip,&a,&b,&c,&d); uint32_t tor_ip = toIP(a,b,c,1); m_tor_msg_timer_map[tor_ip] = Simulator::Now().GetNanoSeconds(); } void Ipv4DoppelgangerRouting::SetTagTorQueueDepth(Ipv4DoppelgangerTag *tag) { uint i=0; std::map<uint32_t,uint32_t>::iterator it; for ( it = m_local_tor_service_queue_depth.begin(); it != m_local_tor_service_queue_depth.end(); it++ ) { if( ClientBelowTor(m_addr.Get(), it->first) ) { tag->SetTorQueueDepth(i,it->first,m_local_tor_service_queue_depth[it->first]); i++; } } } /* END DoppleGanger Routing function additions*/ Ptr<Ipv4Route> Ipv4DoppelgangerRouting::RouteOutput(Ptr<Packet> packet, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) { NS_LOG_WARN("ROUTING OUTPUT"); return 0; } uint64_t Ipv4DoppelgangerRouting::GetInstantenousLoad(int server_id) { Time now = Simulator::Now(); int64_t time_passed; time_passed = now.GetNanoSeconds() - m_serverLoad_update[server_id].GetNanoSeconds(); //Recalculate load int64_t tmp_load = m_serverLoad[server_id]; //use a tmp variable to prevent overflow tmp_load -= time_passed; //Prevent load from going below 0 if (tmp_load < 0) { tmp_load = 0; } //Update Server Load m_serverLoad[server_id] = tmp_load; m_serverLoad_update[server_id] = now; return m_serverLoad[server_id]; } uint64_t Ipv4DoppelgangerRouting::GetInformationTime() { return GetInformationDelay(m_delay_function, m_constant_information_delay); } //Returns the IP of a minuimum latency replica uint32_t Ipv4DoppelgangerRouting::replicaSelectionStrategy_minimumLoad(std::vector<uint32_t> ips) { uint64_t minLoad = UINT64_MAX; uint32_t minReplica; //TODO make this a command line argument switch (m_information_collection_method){ case instant: { uint64_t time = GetInformationTime(); //This will likely have to be extended for (uint i = 0; i < ips.size(); i++) { uint32_t replica = m_server_ip_map[ips[i]]; uint64_t dialated_load = ServerLoadAtTime(replica, time, m_load_log); if (dialated_load < minLoad) { minLoad = dialated_load; minReplica = ips[i]; } } return minReplica; } case piggyback: { NS_LOG_INFO("Piggyback routing"); for (uint i = 0; i < ips.size(); i++) { uint32_t load = m_local_server_load[ips[i]]; if (load < minLoad) { minLoad = load; minReplica = ips[i]; } } return minReplica; } default: { NS_LOG_WARN("Information collection method " << m_information_collection_method << "is not implemented"); break; } } NS_LOG_WARN("ERROR information not collected - min routing strategy failed"); return 0; } //Returns the IP of a minuimum latency replica uint32_t Ipv4DoppelgangerRouting::replicaSelectionStrategy_minimumLoad_correct_delay(std::vector<uint32_t> ips) { uint64_t minLoad = UINT64_MAX; uint32_t minReplica; uint64_t information_delay = GetInformationTime(); //This will likely have to be extended std::vector<uint64_t> delayed_loads; for (uint i = 0; i < ips.size(); i++) { uint32_t replica = m_server_ip_map[ips[i]]; uint64_t dialated_load = ServerLoadAtTime(replica, information_delay, m_load_log); delayed_loads.push_back(dialated_load); } //delayed loads represents the load of servers some time in the past //uint64_t client_mean_request_generation = 8500; //Change this per experiment uint64_t client_mean_request_generation = 11800; //Change this per experiment uint64_t server_mean_processing_time = 10000; uint64_t rtt = 7000; uint64_t core_delay_to_server = (rtt / 4) + information_delay; //simulate requets to min // calculate the min replica for every time step, where a time step is a guess that a client generated a request for (uint64_t time_simulated = 0; time_simulated < core_delay_to_server; time_simulated += client_mean_request_generation) { minLoad = UINT64_MAX; minReplica = 0; // This is intended to cause a crash or many dropped packets if there is a bug ip = 0 uint minReplica_index; for (uint i = 0; i < delayed_loads.size(); i++) { if (delayed_loads[i] < minLoad) { minLoad = delayed_loads[i]; minReplica = ips[i]; minReplica_index = i; } } //We have the guessed min replica for this point in the simulated time delayed_loads[minReplica_index] += server_mean_processing_time; } return minReplica; } std::vector<uint32_t> Ipv4DoppelgangerRouting::replicaSelectionStrategy_minimumDownwardDistance(std::vector<uint32_t> ips) { std::vector<uint32_t> min_distance_replicas; for (uint i = 0; i < ips.size(); ++i) { int a1, b1, c1, d1, a2, b2, c2, d2; translateIp(m_addr.Get(), &a1, &b1, &c1, &d1); translateIp(ips[i], &a2, &b2, &c2, &d2); switch (m_fattree_switch_type) { case edge: if (a1 == a2 && b1 == b2 && c1 == c2) { min_distance_replicas.push_back(ips[i]); } break; case agg: if (b1 == b2) { min_distance_replicas.push_back(ips[i]); } break; case core: min_distance_replicas.push_back(ips[i]); break; default: NS_LOG_WARN("Min Distance Protocol for this routing is not defined, check how you are defining the switch"); break; } } if (min_distance_replicas.size() == 0) { //There is no min distance replica below us in the suppled list. Push the responsibility higher up the tree by returning all ips. return ips; } else { return min_distance_replicas; } } bool Ipv4DoppelgangerRouting::RouteInput(Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) { //NS_LOG_WARN("HELLO CORE WE ARE NOW ROUTING!!"); NS_ASSERT(m_ipv4->GetInterfaceForDevice(idev) >= 0); Ipv4Header headerPrime = header; if ((m_spread_load_info) && (m_fattree_switch_type == edge) && (m_load_balencing_strategy == torQueueDepth) && (!m_started_spreading_info)) { NS_LOG_INFO("Load information being spread for the first time on " << stringIP(m_addr.Get())); SpreadLoadInfo(headerPrime, ucb); } Ptr<Packet> packet = ConstCast<Packet>(p); Ipv4Address destAddress = headerPrime.GetDestination(); Ipv4DoppelgangerTag tag; bool found = packet->PeekPacketTag(tag); //Check that the packet has a doppleganger tag, return if not found if (found) { //printf("Found the packet tag\n"); NS_LOG_WARN("We have a packet tag!!"); } else { //printf("where on earth is this pacekt tag\n"); NS_LOG_WARN("Packet Has no tag, this should not be routed by this router, something is wrong!!!"); return false; } std::vector<uint32_t> replicas; uint32_t *tag_replicas = tag.GetReplicas(); for (int i = 0; i < tag.GetReplicaCount(); ++i) { //NS_LOG_INFO("Pulling replica " << stringIP(tag_replicas[i]) << " from packet tag"); replicas.push_back(tag_replicas[i]); } if (tag.GetPacketType() == Ipv4DoppelgangerTag::request) { //Total packets is now the incorrect name for this variable. It only tracks request packets. Stewart May 17 2020. m_total_packets++; switch (m_load_balencing_strategy) { //no load balencing forward packets to end hosts based on source chosen destination case none: //Don't do anything here, we use source routing in this case tag.SetCanRouteDown(true); break; //minimumLoad - Switches have global instantenous knowledge of server load. //They route to minimum replicas based on this information at every step. //The destination of the end host can change multiple times per packet. case minimumLoad: { uint32_t min_replica = replicaSelectionStrategy_minimumLoad(replicas); Ipv4Address ipv4Addr = headerPrime.GetDestination(); if (min_replica == ipv4Addr.Get() || tag.GetRedirections() >= tag.GetReplicaCount()) { NS_LOG_INFO("replica is the same as the min! Replica: " << stringIP(min_replica)); } else { NS_LOG_INFO("the best case replica has changed since source send:" << stringIP(ipv4Addr.Get()) << " --> " << stringIP(min_replica)); destAddress.Set(min_replica); headerPrime.SetDestination(destAddress); tag.SetRedirections(tag.GetRedirections() + 1); m_packet_redirections++; } //Tag can be routed down from anywhere tag.SetCanRouteDown(true); break; } //coreOnly - Switches perform min load routing, but only if the router in //question is a core router. This does not min route packets which would //have never crossed the core. case coreOnly: { uint32_t min_replica = replicaSelectionStrategy_minimumLoad(replicas); //uint32_t min_replica = replicaSelectionStrategy_minimumLoad_correct_delay(replicas); //uint32_t min_replica = replicaSelectionStrategy_minimumLoad_with_noise(replicas); Ipv4Address ipv4Addr = headerPrime.GetDestination(); if (min_replica == ipv4Addr.Get()) { NS_LOG_INFO("replica is the same as the min! Replica: " << stringIP(min_replica)); } else { if (m_fattree_switch_type == core) { NS_LOG_INFO("the best case replica has changed since source send:" << stringIP(ipv4Addr.Get()) << " --> " << stringIP(min_replica)); destAddress.Set(min_replica); headerPrime.SetDestination(destAddress); tag.SetCanRouteDown(true); tag.SetRedirections(tag.GetRedirections() + 1); m_packet_redirections++; } else { NS_LOG_INFO("Not rerouting because not a core router.. Fix this in the future to be it's own routing protocol"); } } tag.SetCanRouteDown(true); break; } case minDistanceMinLoad: { std::vector<uint32_t> min_distance_down_replicas = replicaSelectionStrategy_minimumDownwardDistance(replicas); uint32_t min_replica = replicaSelectionStrategy_minimumLoad(min_distance_down_replicas); Ipv4Address ipv4Addr = headerPrime.GetDestination(); if (min_replica == ipv4Addr.Get()) { NS_LOG_INFO("replica is the same as the min! Replica: " << stringIP(min_replica)); } else { destAddress.Set(min_replica); headerPrime.SetDestination(destAddress); tag.SetCanRouteDown(true); tag.SetRedirections(tag.GetRedirections() + 1); m_packet_redirections++; } tag.SetCanRouteDown(true); break; } case coreForcedMinDistanceMinLoad: { NS_LOG_WARN("Running Core Fored Min Distance Min Load (non nessisarily a core router)"); //All packets must reach the core router before they can be routed down. if (m_fattree_switch_type == core) { NS_LOG_WARN("-------------Reached the Core--------------"); tag.SetCanRouteDown(true); } //If a packet is on it's way down the tree use the min load balencing with minimum distance strategy if (tag.GetCanRouteDown()) { NS_LOG_WARN("Able to route down the tree"); std::vector<uint32_t> min_distance_down_replicas = replicaSelectionStrategy_minimumDownwardDistance(replicas); //minimum distance replicas for (uint i = 0; i < min_distance_down_replicas.size(); i++) { NS_LOG_WARN("min distance replicas(" << i << "): " << stringIP(min_distance_down_replicas[i])); } uint32_t min_replica = replicaSelectionStrategy_minimumLoad(min_distance_down_replicas); Ipv4Address ipv4Addr = headerPrime.GetDestination(); if (min_replica == ipv4Addr.Get()) { NS_LOG_INFO("replica is the same as the min! Replica: " << stringIP(min_replica)); } else { NS_LOG_WARN("Host: " << stringIP(m_addr.Get()) << " the best case replica has changed since source send:" << stringIP(ipv4Addr.Get()) << " --> " << stringIP(min_replica)); destAddress.Set(min_replica); headerPrime.SetDestination(destAddress); tag.SetRedirections(tag.GetRedirections() + 1); m_packet_redirections++; } } else { NS_LOG_WARN("Still Routing UP The tree"); //Packet is either on a node/edge/agg router, and is going up the tree. //We need to make sure that the destination being routed to will at //least take the packet to the core routers. To do this we first check //if the address in the destination is in the same pod as the router. //If it's not we don't need to do anything becasue the regular routing //will take care of it. If the packet is in the same pod, we need to //pick a cross core address to look up in the routing table to force //the extra distance of routing. if (SamePod(destAddress, m_addr)) { //modify the destination address //do not change the actual packet destination NS_LOG_WARN("Matching Pod Routing Up The Tree"); destAddress.Set(OtherPodAddress(destAddress, GetFatTreeK())); } } break; } //toronly is identical to core only, with the exception that rerouting only occurs at the tor case torOnly: { uint32_t min_replica = replicaSelectionStrategy_minimumLoad(replicas); Ipv4Address ipv4Addr = headerPrime.GetDestination(); if (min_replica == ipv4Addr.Get()) { NS_LOG_INFO("replica is the same as the min! Replica: " << stringIP(min_replica)); } else { //.if (m_fattree_switch_type == edge && tag.GetRedirections() <= MAX_REPLICAS) if (m_fattree_switch_type == edge && tag.GetRedirections() <= tag.GetReplicaCount() && m_local_server_load[headerPrime.GetDestination().Get()] > 30000 ) { NS_LOG_INFO("the best case replica has changed since source send:" << stringIP(ipv4Addr.Get()) << " --> " << stringIP(min_replica)); destAddress.Set(min_replica); headerPrime.SetDestination(destAddress); tag.SetCanRouteDown(true); tag.SetRedirections(tag.GetRedirections() + 1); m_packet_redirections++; } else { NS_LOG_INFO("Not rerouting because not a TOR router.. Fix this in the future to be it's own routing protocol"); } } tag.SetCanRouteDown(true); break; } case torQueueDepth: { if (m_fattree_switch_type == edge) { //Find the global min tor queue //Choose between local and global routing std::map<uint32_t,uint32_t>* tor_queue_depths; switch (m_information_collection_method){ case instant: { tor_queue_depths=m_tor_service_queue_depth; } case piggyback: { tor_queue_depths=&m_local_tor_service_queue_depth; //UpdateLocalTorQueueDepth(tag); } } uint32_t min = UINT32_MAX; uint32_t min_replica; for(uint i=0;i<replicas.size();i++) { if((*tor_queue_depths)[replicas[i]] < min) { min_replica = replicas[i]; } //Debugging info uint32_t depth = (*tor_queue_depths)[replicas[i]]; NS_LOG_INFO(stringIP(replicas[i]) << " -- " << depth); } uint32_t selected_replica; //Check if the packet has been redirected Ipv4Address ipv4Addr = headerPrime.GetDestination(); if (min_replica == ipv4Addr.Get()) { NS_LOG_INFO("replica is the same as the min! Replica: " << stringIP(min_replica)); } else { NS_LOG_INFO("min tor has changed. potentiall prevent additonal routing was: " << stringIP(ipv4Addr.Get()) << " is: " << stringIP(min_replica)); } //TODO these decisions should be made together // Check that a threshold is met before re-routing //Only make a routing decision if the client is below you if( ClientBelowTor(m_addr.Get(),ipv4Addr.Get())) { if ((*tor_queue_depths)[min_replica] + m_delta_queue_difference < (*tor_queue_depths)[ipv4Addr.Get()]) { NS_LOG_INFO("&&&&&&&&&&&&&&&&&&&&&&& TOR QUEUE DIFF " << m_delta_queue_difference); //printf("TOR QUEUE DEPTH %d\n", m_delta_queue_difference); //exit(0); selected_replica = min_replica; } else { selected_replica = ipv4Addr.Get(); } // Over ride desicion if the packet has been redirected allready //Only redirect a packet if another replica is available don't send in network indefinatly if (tag.GetRedirections() >= 1) { selected_replica = ipv4Addr.Get(); } //Set the minimum destination, and increment packet redirections if nessisary if (selected_replica != ipv4Addr.Get()) { destAddress.Set(selected_replica); headerPrime.SetDestination(destAddress); tag.SetCanRouteDown(true); tag.SetRedirections(tag.GetRedirections() + 1); m_packet_redirections++; } //Increment Tor counter if the request is to be routed down if (ClientBelowTor(m_addr.Get(), destAddress.Get())) { NS_LOG_INFO("Tor " << stringIP(m_addr.Get()) << " passing new request queue incremend"); (*tor_queue_depths)[destAddress.Get()]++; } } //SetTagTorQueueDepth(&tag); } } break; default: NS_LOG_WARN("Unable to find load ballencing strategy"); break; } } else if (tag.GetPacketType() == Ipv4DoppelgangerTag::response) { NS_LOG_INFO("Received response routing back to client" << stringIP(headerPrime.GetSource().Get()) << " To " << tag.GetHostLoad()); } else if (tag.GetPacketType() == Ipv4DoppelgangerTag::load) { Ipv4Address source = headerPrime.GetSource(); m_local_server_load[source.Get()] = tag.GetHostLoad(); NS_LOG_INFO("Updated Server load " << stringIP(source.Get()) << " To " << tag.GetHostLoad()); } else if (tag.GetPacketType() == Ipv4DoppelgangerTag::response_piggyback) { //TODO this should only be used if information is being piggybacked Ipv4Address source = headerPrime.GetSource(); m_local_server_load[source.Get()] = tag.GetHostLoad(); NS_LOG_INFO("Updated Server load from piggybacked response" << stringIP(source.Get()) << " To " << tag.GetHostLoad()); //This is the incorrect place to put this becasue it has perfect information, it should not be under piggyback. switch (m_load_balencing_strategy) { case torQueueDepth: { if (m_fattree_switch_type == edge) { std::map<uint32_t,uint32_t>* tor_queue_depths; switch (m_information_collection_method){ case instant: { tor_queue_depths=m_tor_service_queue_depth; } case piggyback: { tor_queue_depths=&m_local_tor_service_queue_depth; //UpdateLocalTorQueueDepth(tag); } } NS_LOG_INFO("Checking Tor Queue Depth"); Ipv4Address source = headerPrime.GetSource(); //Increment Tor counter if the request is below NS_LOG_INFO("Server Address " << stringIP(source.Get()) << " Tor IP " << stringIP(m_addr.Get())); if (ClientBelowTor(m_addr.Get(), source.Get())) { NS_LOG_INFO("Tor " << stringIP(m_addr.Get()) << " completed request subtracting queue"); (*tor_queue_depths)[source.Get()]--; NS_LOG_INFO("Tor queu depth now " << (*tor_queue_depths)[source.Get()]); } //SetTagTorQueueDepth(&tag); } break; } default: { NS_LOG_INFO("Not doing anything special based on load balancing strategy (piggyback)"); } } } else if (tag.GetPacketType() == Ipv4DoppelgangerTag::tor_to_tor_load) { if (m_load_balencing_strategy == torQueueDepth && m_fattree_switch_type == edge){ NS_LOG_INFO("RECEIVED LOAD PACKET FROM " << stringIP(header.GetSource().Get()) << "(tor to tor) Updateing local tor queue depth"); UpdateLocalTorQueueDepth(tag); return true; } else { NS_LOG_INFO("Not doing anything with tor load queue info"); } //return true; } else { NS_LOG_INFO("Unknown packet type routing as usual"); } packet->ReplacePacketTag(tag); // Packet arrival time Time now = Simulator::Now(); std::vector<DoppelgangerRouteEntry> routeEntries = Ipv4DoppelgangerRouting::LookupDoppelgangerRouteEntriesIP(destAddress); //Find routing entry for the given IP if (routeEntries.size() > 0) { NS_LOG_WARN("Host: " << stringIP(m_addr.Get()) << " Entry Hit for " << stringIP(destAddress.Get()) << " Found " << routeEntries.size() << " Entries"); } else { NS_LOG_WARN("Host: " << stringIP(m_addr.Get()) << " Entries MISS for " << stringIP(destAddress.Get())); return false; } //Ecmp uint32_t selectedPort = routeEntries[rand() % routeEntries.size()].port; NS_LOG_WARN("Host: " << stringIP(m_addr.Get()) << " Setting up route for dest address " << stringIP(header.GetDestination().Get()) << " port " << selectedPort); Ptr<Ipv4Route> route = Ipv4DoppelgangerRouting::ConstructIpv4Route(selectedPort, destAddress); //Check channel state Ptr<Channel> chan = idev->GetChannel(); //ucb (route, packet, header); ucb(route, packet, headerPrime); return true; } void Ipv4DoppelgangerRouting::SpreadLoadInfo(Ipv4Header header, UnicastForwardCallback ucb) { m_started_spreading_info = true; NS_LOG_INFO("<<<<<<<<<<<<<<<<<<SPREADING TOR LOAD INFO>>>>>>>>>>>>>>>>>> On Host " << stringIP(m_addr.Get()) << " At Time: " << Simulator::Now().GetNanoSeconds()); std::map<uint32_t, uint64_t>::iterator it; for ( it = m_tor_msg_timer_map.begin(); it != m_tor_msg_timer_map.end(); it++ ) { NS_LOG_INFO("Inspecting TOR IP " << stringIP(it->first)); uint32_t tor_ip = it->first; uint64_t last_msg = it->second; if (tor_ip == m_addr.Get()) { NS_LOG_INFO("Tor Info to self inspected... I don't need to update myself... skipping"); continue; } //if ((Simulator::Now().GetNanoSeconds() - last_msg) >= m_load_spread_interval) { if (true) { NS_LOG_INFO(">>>>>>>>>> Last Message to " << stringIP(tor_ip) << " is " << Simulator::Now().GetNanoSeconds() - last_msg << " ns out of date sending info"); //create a fake dest address //Set it to the first host under the selected TOR int a, b, c, d; translateIp(tor_ip,&a,&b,&c,&d); Ipv4Address destAddress = Ipv4Address(toIP(a,b,c,2)); Ptr<Packet> p; uint32_t packet_size = 128; p = Create<Packet>(packet_size); Ipv4DoppelgangerTag ipv4DoppelgangerTag; // PacketID is an analog for sequence number, for now request are a single packet so always set to 0 ipv4DoppelgangerTag.SetCanRouteDown(true); ipv4DoppelgangerTag.SetPacketType(Ipv4DoppelgangerTag::tor_to_tor_load); ipv4DoppelgangerTag.SetPacketID(0); ipv4DoppelgangerTag.SetHostSojournTime(0); ipv4DoppelgangerTag.SetRedirections(0); ipv4DoppelgangerTag.SetTorQueuesNULL(); // Generate the location of the next reuqest ipv4DoppelgangerTag.SetRequestID(0); for (uint i=0;i<MAX_REPLICAS;i++) { ipv4DoppelgangerTag.SetReplica(i,destAddress.Get()); } SetTagTorQueueDepth(&ipv4DoppelgangerTag); p->AddPacketTag(ipv4DoppelgangerTag); std::vector<DoppelgangerRouteEntry> routeEntries = Ipv4DoppelgangerRouting::LookupDoppelgangerRouteEntriesIP(destAddress); //Find routing entry for the given IP if (routeEntries.size() > 0) { NS_LOG_WARN("<tor_load> Host: " << stringIP(m_addr.Get()) << " Entry Hit for " << stringIP(destAddress.Get()) << " Found " << routeEntries.size() << " Entries"); } else { NS_LOG_WARN("<tor_load> Host: " << stringIP(m_addr.Get()) << " Entries MISS for " << stringIP(destAddress.Get())); } //Ecmp uint32_t selectedPort = routeEntries[rand() % routeEntries.size()].port; Ptr<Ipv4Route> route = Ipv4DoppelgangerRouting::ConstructIpv4Route(selectedPort, destAddress); header.SetDestination(destAddress); //ucb (route, packet, header); ucb(route, p, header); m_tor_msg_timer_map[tor_ip] = Simulator::Now().GetNanoSeconds(); } else { NS_LOG_INFO("Not sending to " << stringIP(tor_ip) << " had a message sent just " << Simulator::Now().GetNanoSeconds() - last_msg << " ns ago"); } } if (Simulator::Now().GetNanoSeconds() < NanoSeconds(m_duration)) { Simulator::Schedule(NanoSeconds((m_load_spread_interval)), &Ipv4DoppelgangerRouting::SpreadLoadInfo, this, header, ucb); } } void Ipv4DoppelgangerRouting::NotifyInterfaceUp(uint32_t interface) { } void Ipv4DoppelgangerRouting::NotifyInterfaceDown(uint32_t interface) { } void Ipv4DoppelgangerRouting::NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) { } void Ipv4DoppelgangerRouting::NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) { } void Ipv4DoppelgangerRouting::SetIpv4(Ptr<Ipv4> ipv4) { NS_LOG_LOGIC(this << "Setting up Ipv4: " << ipv4); NS_ASSERT(m_ipv4 == 0 && ipv4 != 0); m_ipv4 = ipv4; } /* void Ipv4DoppelgangerRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const { printf("routing-table-stub"); } */ void Ipv4DoppelgangerRouting::PrintRoutingTable(Ptr<OutputStreamWrapper> stream, Time::Unit unit) const { } void Ipv4DoppelgangerRouting::DoDispose(void) { std::map<uint32_t, Flowlet *>::iterator itr = m_flowletTable.begin(); for (; itr != m_flowletTable.end(); ++itr) { delete (itr->second); } m_dreEvent.Cancel(); m_agingEvent.Cancel(); m_ipv4 = 0; Ipv4RoutingProtocol::DoDispose(); } uint32_t Ipv4DoppelgangerRouting::UpdateLocalDre(const Ipv4Header &header, Ptr<Packet> packet, uint32_t port) { uint32_t X = 0; std::map<uint32_t, uint32_t>::iterator XItr = m_XMap.find(port); if (XItr != m_XMap.end()) { X = XItr->second; } uint32_t newX = X + packet->GetSize() + header.GetSerializedSize(); NS_LOG_LOGIC(this << " Update local dre, new X: " << newX); m_XMap[port] = newX; return newX; } void Ipv4DoppelgangerRouting::DreEvent() { bool moveToIdleStatus = true; std::map<uint32_t, uint32_t>::iterator itr = m_XMap.begin(); for (; itr != m_XMap.end(); ++itr) { uint32_t newX = itr->second * (1 - m_alpha); itr->second = newX; if (newX != 0) { moveToIdleStatus = false; } } NS_LOG_LOGIC(this << " Dre event finished, the dre table is now: "); Ipv4DoppelgangerRouting::PrintDreTable(); if (!moveToIdleStatus) { m_dreEvent = Simulator::Schedule(m_tdre, &Ipv4DoppelgangerRouting::DreEvent, this); } else { NS_LOG_LOGIC(this << " Dre event goes into idle status"); } } void Ipv4DoppelgangerRouting::AgingEvent() { bool moveToIdleStatus = true; std::map<uint32_t, std::map<uint32_t, std::pair<Time, uint32_t>>>::iterator itr = m_doppelgangerToLeafTable.begin(); for (; itr != m_doppelgangerToLeafTable.end(); ++itr) { std::map<uint32_t, std::pair<Time, uint32_t>>::iterator innerItr = (itr->second).begin(); for (; innerItr != (itr->second).end(); ++innerItr) { if (Simulator::Now() - (innerItr->second).first > m_agingTime) { (innerItr->second).second = 0; } else { moveToIdleStatus = false; } } } std::map<uint32_t, std::map<uint32_t, FeedbackInfo>>::iterator itr2 = m_doppelgangerFromLeafTable.begin(); for (; itr2 != m_doppelgangerFromLeafTable.end(); ++itr2) { std::map<uint32_t, FeedbackInfo>::iterator innerItr2 = (itr2->second).begin(); for (; innerItr2 != (itr2->second).end(); ++innerItr2) { if (Simulator::Now() - (innerItr2->second).updateTime > m_agingTime) { (itr2->second).erase(innerItr2); if ((itr2->second).empty()) { m_doppelgangerFromLeafTable.erase(itr2); } } else { moveToIdleStatus = false; } } } if (!moveToIdleStatus) { m_agingEvent = Simulator::Schedule(m_agingTime / 4, &Ipv4DoppelgangerRouting::AgingEvent, this); } else { NS_LOG_LOGIC(this << " Aging event goes into idle status"); } } uint32_t Ipv4DoppelgangerRouting::QuantizingX(uint32_t interface, uint32_t X) { DataRate c = m_C; std::map<uint32_t, DataRate>::iterator itr = m_Cs.find(interface); if (itr != m_Cs.end()) { c = itr->second; } double ratio = static_cast<double>(X * 8) / (c.GetBitRate() * m_tdre.GetSeconds() / m_alpha); NS_LOG_LOGIC("ratio: " << ratio); return static_cast<uint32_t>(ratio * std::pow(2, m_Q)); } void Ipv4DoppelgangerRouting::PrintDoppelgangerToLeafTable() { /* std::ostringstream oss; oss << "===== DoppelgangerToLeafTable For Leaf: " << m_leafId <<"=====" << std::endl; std::map<uint32_t, std::map<uint32_t, uint32_t> >::iterator itr = m_doppelgangerToLeafTable.begin (); for ( ; itr != m_doppelgangerToLeafTable.end (); ++itr ) { oss << "Leaf ID: " << itr->first << std::endl<<"\t"; std::map<uint32_t, uint32_t>::iterator innerItr = (itr->second).begin (); for ( ; innerItr != (itr->second).end (); ++innerItr) { oss << "{ port: " << innerItr->first << ", ce: " << (innerItr->second) << " } "; } oss << std::endl; } oss << "============================"; NS_LOG_LOGIC (oss.str ()); */ } void Ipv4DoppelgangerRouting::PrintDoppelgangerFromLeafTable() { /* std::ostringstream oss; oss << "===== DoppelgangerFromLeafTable For Leaf: " << m_leafId << "=====" <<std::endl; std::map<uint32_t, std::map<uint32_t, FeedbackInfo> >::iterator itr = m_doppelgangerFromLeafTable.begin (); for ( ; itr != m_doppelgangerFromLeafTable.end (); ++itr ) { oss << "Leaf ID: " << itr->first << std::endl << "\t"; std::map<uint32_t, FeedbackInfo>::iterator innerItr = (itr->second).begin (); for ( ; innerItr != (itr->second).end (); ++innerItr) { oss << "{ port: " << innerItr->first << ", ce: " << (innerItr->second).ce << ", change: " << (innerItr->second).change << " } "; } oss << std::endl; } oss << "=============================="; NS_LOG_LOGIC (oss.str ()); */ } void Ipv4DoppelgangerRouting::PrintFlowletTable() { /* std::ostringstream oss; oss << "===== Flowlet For Leaf: " << m_leafId << "=====" << std::endl; std::map<uint32_t, Flowlet*>::iterator itr = m_flowletTable.begin (); for ( ; itr != m_flowletTable.end(); ++itr ) { oss << "flowId: " << itr->first << std::endl << "\t" << "port: " << (itr->second)->port << "\t" << "activeTime" << (itr->second)->activeTime << std::endl; } oss << "==================="; NS_LOG_LOGIC (oss.str ()); */ } void Ipv4DoppelgangerRouting::PrintDreTable() { /* std::ostringstream oss; std::string switchType = m_isLeaf == true ? "leaf switch" : "spine switch"; oss << "==== Local Dre for " << switchType << " ====" <<std::endl; std::map<uint32_t, uint32_t>::iterator itr = m_XMap.begin (); for ( ; itr != m_XMap.end (); ++itr) { oss << "port: " << itr->first << ", X: " << itr->second << ", Quantized X: " << Ipv4DoppelgangerRouting::QuantizingX (itr->second) <<std::endl; } oss << "================================="; NS_LOG_LOGIC (oss.str ()); */ } } // namespace ns3
a8ee913cbe3970b250aa6982f2e43afbb0646ff5
98f882a8225f270ac73cc02490b70f37534b0f03
/hls/workspace/nnet_stream/solution1/syn/systemc/fc_layer3_fc_layeh8b.h
3c94a50a8745271fcd868cd6581b4a674bfc4fa6
[]
no_license
sergiududa/lic
ab890c5701d2a41c32f162341724068ef6d7c858
89dee2dee3ccd8f4dd33efdefe40b3526b23cc57
refs/heads/master
2020-03-08T08:47:03.901715
2018-06-18T12:59:28
2018-06-18T12:59:28
128,030,620
0
0
null
null
null
null
UTF-8
C++
false
false
33,556
h
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.4.1 // Copyright (C) 1986-2018 Xilinx, Inc. All Rights Reserved. // // ============================================================== #ifndef __fc_layer3_fc_layeh8b_H__ #define __fc_layer3_fc_layeh8b_H__ #include <systemc> using namespace sc_core; using namespace sc_dt; #include <iostream> #include <fstream> struct fc_layer3_fc_layeh8b_ram : public sc_core::sc_module { static const unsigned DataWidth = 12; static const unsigned AddressRange = 840; static const unsigned AddressWidth = 10; //latency = 1 //input_reg = 1 //output_reg = 0 sc_core::sc_in <sc_lv<AddressWidth> > address0; sc_core::sc_in <sc_logic> ce0; sc_core::sc_out <sc_lv<DataWidth> > q0; sc_core::sc_in <sc_lv<AddressWidth> > address1; sc_core::sc_in <sc_logic> ce1; sc_core::sc_out <sc_lv<DataWidth> > q1; sc_core::sc_in<sc_logic> reset; sc_core::sc_in<bool> clk; sc_lv<DataWidth> ram[AddressRange]; SC_CTOR(fc_layer3_fc_layeh8b_ram) { ram[0] = "0b001100110110"; ram[1] = "0b111001000010"; ram[2] = "0b001000101010"; ram[3] = "0b000101011111"; ram[4] = "0b110101000110"; ram[5] = "0b000011011100"; ram[6] = "0b001101010100"; ram[7] = "0b001101101101"; ram[8] = "0b000011010110"; ram[9] = "0b110110101110"; ram[10] = "0b001000100110"; ram[11] = "0b000110010000"; ram[12] = "0b001100100011"; ram[13] = "0b111100011001"; ram[14] = "0b001110101000"; ram[15] = "0b000110011111"; ram[16] = "0b111000001111"; ram[17] = "0b001010110111"; ram[18] = "0b001111011010"; ram[19] = "0b001001111111"; ram[20] = "0b111010110100"; ram[21] = "0b000010000100"; ram[22] = "0b110110001000"; ram[23] = "0b111010000100"; ram[24] = "0b110100010100"; ram[25] = "0b001000010001"; ram[26] = "0b110000001111"; ram[27] = "0b111110000101"; ram[28] = "0b110010110111"; ram[29] = "0b111111110101"; ram[30] = "0b111101010110"; ram[31] = "0b111011110010"; ram[32] = "0b110000110100"; ram[33] = "0b001101101100"; ram[34] = "0b110001100111"; ram[35] = "0b001011000110"; ram[36] = "0b001110001101"; ram[37] = "0b001110101000"; ram[38] = "0b110101101011"; ram[39] = "0b001100011011"; ram[40] = "0b000011100001"; ram[41] = "0b110001011001"; ram[42] = "0b010000000011"; ram[43] = "0b000100011011"; ram[44] = "0b110101000110"; ram[45] = "0b110101001101"; ram[46] = "0b110001110100"; ram[47] = "0b111101000000"; ram[48] = "0b110011000101"; ram[49] = "0b110001100000"; ram[50] = "0b000111101111"; ram[51] = "0b001111001101"; ram[52] = "0b000011001101"; ram[53] = "0b110000101111"; ram[54] = "0b110001011100"; ram[55] = "0b001001010010"; ram[56] = "0b010000001010"; ram[57] = "0b001101110101"; ram[58] = "0b001000101110"; ram[59] = "0b111011100011"; ram[60] = "0b101111110101"; ram[61] = "0b111000100010"; ram[62] = "0b110011111001"; ram[63] = "0b001111100101"; ram[64] = "0b000001000011"; ram[65] = "0b001101001100"; ram[66] = "0b111001100110"; ram[67] = "0b000010001000"; ram[68] = "0b001110110111"; ram[69] = "0b110111000011"; ram[70] = "0b001111110110"; ram[71] = "0b111100010101"; ram[72] = "0b110001101000"; ram[73] = "0b111011100101"; ram[74] = "0b111000010011"; ram[75] = "0b001100101011"; ram[76] = "0b110010101111"; ram[77] = "0b000001111100"; ram[78] = "0b001010000011"; ram[79] = "0b111100010111"; ram[80] = "0b001111010110"; ram[81] = "0b111100001001"; ram[82] = "0b111110011001"; ram[83] = "0b111001110110"; ram[84] = "0b001111110101"; ram[85] = "0b001111111100"; ram[86] = "0b000100011100"; ram[87] = "0b000101100101"; ram[88] = "0b001001110000"; ram[89] = "0b001011011011"; ram[90] = "0b000110000010"; ram[91] = "0b111101111111"; ram[92] = "0b110111101010"; ram[93] = "0b111101110111"; ram[94] = "0b111011011011"; ram[95] = "0b111111000011"; ram[96] = "0b001001010111"; ram[97] = "0b001010010101"; ram[98] = "0b000001101011"; ram[99] = "0b110000111001"; ram[100] = "0b000010101001"; ram[101] = "0b001100011000"; ram[102] = "0b001001000010"; ram[103] = "0b000101101000"; ram[104] = "0b001010001101"; ram[105] = "0b111011100111"; ram[106] = "0b000101010101"; ram[107] = "0b001101001010"; ram[108] = "0b110011110101"; ram[109] = "0b111001110011"; ram[110] = "0b111111010010"; ram[111] = "0b010000000011"; ram[112] = "0b111101001001"; ram[113] = "0b001100101100"; ram[114] = "0b001110111010"; ram[115] = "0b001001010001"; ram[116] = "0b110111011000"; ram[117] = "0b111011001110"; ram[118] = "0b111100110001"; ram[119] = "0b110101001001"; ram[120] = "0b111010010101"; ram[121] = "0b111100110010"; ram[122] = "0b111110111100"; ram[123] = "0b000010111111"; ram[124] = "0b110111001010"; ram[125] = "0b001101101101"; ram[126] = "0b000101011110"; ram[127] = "0b001111011001"; ram[128] = "0b000010011011"; ram[129] = "0b001101010110"; ram[130] = "0b110110101010"; ram[131] = "0b000011111001"; ram[132] = "0b111000101010"; ram[133] = "0b001011010010"; ram[134] = "0b111000010110"; ram[135] = "0b001011110001"; ram[136] = "0b000100000000"; ram[137] = "0b110110001000"; ram[138] = "0b000110000001"; ram[139] = "0b110110100001"; ram[140] = "0b000100001101"; ram[141] = "0b001101101100"; ram[142] = "0b000001101100"; ram[143] = "0b110010000000"; ram[144] = "0b110101010110"; ram[145] = "0b000011111110"; ram[146] = "0b000111000010"; ram[147] = "0b001100100000"; ram[148] = "0b111011100011"; ram[149] = "0b111001111100"; ram[150] = "0b111110111011"; ram[151] = "0b111000001100"; ram[152] = "0b000011000101"; ram[153] = "0b110010011110"; ram[154] = "0b000110100001"; ram[155] = "0b000001100000"; ram[156] = "0b110001011110"; ram[157] = "0b000101001101"; ram[158] = "0b001111100001"; ram[159] = "0b001111010011"; ram[160] = "0b110000110100"; ram[161] = "0b001010110011"; ram[162] = "0b111001111011"; ram[163] = "0b001101101110"; ram[164] = "0b000011001100"; ram[165] = "0b001101110100"; ram[166] = "0b000011101001"; ram[167] = "0b111110011110"; ram[168] = "0b111110011001"; ram[169] = "0b111101001111"; ram[170] = "0b001101001100"; ram[171] = "0b000111101110"; ram[172] = "0b000001011001"; ram[173] = "0b110111011001"; ram[174] = "0b110100010000"; ram[175] = "0b001011011000"; ram[176] = "0b110111100001"; ram[177] = "0b000110110100"; ram[178] = "0b000110111010"; ram[179] = "0b111000010001"; ram[180] = "0b000001001101"; ram[181] = "0b001100100110"; ram[182] = "0b001101010100"; ram[183] = "0b000010110111"; ram[184] = "0b001111011010"; ram[185] = "0b110010010010"; ram[186] = "0b001010100011"; ram[187] = "0b111001011100"; ram[188] = "0b111110101001"; ram[189] = "0b110101111001"; ram[190] = "0b110100010100"; ram[191] = "0b000101010111"; ram[192] = "0b110111100001"; ram[193] = "0b001101101100"; ram[194] = "0b111100110011"; ram[195] = "0b000011000001"; ram[196] = "0b110100000110"; ram[197] = "0b001100010101"; ram[198] = "0b001011101111"; ram[199] = "0b111110100011"; ram[200] = "0b000111001011"; ram[201] = "0b111111001111"; ram[202] = "0b111111001010"; ram[203] = "0b111000101111"; ram[204] = "0b000111001110"; ram[205] = "0b110111010101"; ram[206] = "0b000000001000"; ram[207] = "0b000101110010"; ram[208] = "0b000111000011"; ram[209] = "0b000011111101"; ram[210] = "0b110011001010"; ram[211] = "0b111010011000"; ram[212] = "0b000010101010"; ram[213] = "0b000110010101"; ram[214] = "0b110001101110"; ram[215] = "0b000111100000"; ram[216] = "0b110001011100"; ram[217] = "0b110010111111"; ram[218] = "0b110101010101"; ram[219] = "0b110011100101"; ram[220] = "0b000111100100"; ram[221] = "0b111011110111"; ram[222] = "0b110000101100"; ram[223] = "0b111000101000"; ram[224] = "0b000011101111"; ram[225] = "0b000011110100"; ram[226] = "0b111100111101"; ram[227] = "0b111111111010"; ram[228] = "0b001000111010"; ram[229] = "0b001011111001"; ram[230] = "0b110101011001"; ram[231] = "0b110000100111"; ram[232] = "0b110111011010"; ram[233] = "0b001100101000"; ram[234] = "0b000001010101"; ram[235] = "0b110101000001"; ram[236] = "0b001111001001"; ram[237] = "0b111101101100"; ram[238] = "0b000010001101"; ram[239] = "0b110011010011"; ram[240] = "0b111010111011"; ram[241] = "0b111010010011"; ram[242] = "0b000110111000"; ram[243] = "0b111111001001"; ram[244] = "0b111110000111"; ram[245] = "0b001000101011"; ram[246] = "0b000101111100"; ram[247] = "0b111011010010"; ram[248] = "0b110001010000"; ram[249] = "0b110100010110"; ram[250] = "0b001101111000"; ram[251] = "0b001010011001"; ram[252] = "0b000101101001"; ram[253] = "0b000111010000"; ram[254] = "0b000111110000"; ram[255] = "0b001011100011"; ram[256] = "0b111000001011"; ram[257] = "0b110011010010"; ram[258] = "0b110011101011"; ram[259] = "0b111010111010"; ram[260] = "0b000110111011"; ram[261] = "0b111011001000"; ram[262] = "0b001011111110"; ram[263] = "0b001010110000"; ram[264] = "0b001011000001"; ram[265] = "0b110110000000"; ram[266] = "0b000101101101"; ram[267] = "0b000010111001"; ram[268] = "0b111101100110"; ram[269] = "0b001100001101"; ram[270] = "0b001010110100"; ram[271] = "0b110010110001"; ram[272] = "0b111110111000"; ram[273] = "0b000010010000"; ram[274] = "0b111010010000"; ram[275] = "0b111111111010"; ram[276] = "0b001001101100"; ram[277] = "0b000110110111"; ram[278] = "0b111010000010"; ram[279] = "0b000000001110"; ram[280] = "0b110000110011"; ram[281] = "0b000101111110"; ram[282] = "0b000011111011"; ram[283] = "0b110100000000"; ram[284] = "0b001101100001"; ram[285] = "0b110010100110"; ram[286] = "0b110101100110"; ram[287] = "0b110001111101"; ram[288] = "0b111010101000"; ram[289] = "0b110001010011"; ram[290] = "0b001100011000"; ram[291] = "0b110000100101"; ram[292] = "0b110110101010"; ram[293] = "0b000010100000"; ram[294] = "0b001011010001"; ram[295] = "0b110010011111"; ram[296] = "0b110100101000"; ram[297] = "0b111010101100"; ram[298] = "0b110001001111"; ram[299] = "0b110000110010"; ram[300] = "0b111101111100"; ram[301] = "0b111110110000"; ram[302] = "0b110010110111"; ram[303] = "0b000010101010"; ram[304] = "0b111001010011"; ram[305] = "0b001001000110"; ram[306] = "0b000000001000"; ram[307] = "0b111100001101"; ram[308] = "0b001100011110"; ram[309] = "0b110100100011"; ram[310] = "0b000100110110"; ram[311] = "0b000000100001"; ram[312] = "0b111000010011"; ram[313] = "0b110010011001"; ram[314] = "0b110101001001"; ram[315] = "0b110000111011"; ram[316] = "0b110101001101"; ram[317] = "0b001111110100"; ram[318] = "0b000101000010"; ram[319] = "0b001101101010"; ram[320] = "0b111100000111"; ram[321] = "0b110100100101"; ram[322] = "0b001000000011"; ram[323] = "0b001011100110"; ram[324] = "0b001000000111"; ram[325] = "0b110101000101"; ram[326] = "0b110111001000"; ram[327] = "0b110110010110"; ram[328] = "0b111100001110"; ram[329] = "0b111011111111"; ram[330] = "0b110111111011"; ram[331] = "0b001000100110"; ram[332] = "0b110100001000"; ram[333] = "0b001110010111"; ram[334] = "0b000101100010"; ram[335] = "0b111111001010"; ram[336] = "0b000001101000"; ram[337] = "0b110011101010"; ram[338] = "0b000100111110"; ram[339] = "0b110010110110"; ram[340] = "0b000101100101"; ram[341] = "0b000111100101"; ram[342] = "0b111111101110"; ram[343] = "0b110101001100"; ram[344] = "0b000110001100"; ram[345] = "0b111111011011"; ram[346] = "0b110000111110"; ram[347] = "0b110001000010"; ram[348] = "0b111100110101"; ram[349] = "0b000101110000"; ram[350] = "0b110101001110"; ram[351] = "0b000101110010"; ram[352] = "0b110000010111"; ram[353] = "0b110010110000"; ram[354] = "0b111010011010"; ram[355] = "0b110001011111"; ram[356] = "0b001010010101"; ram[357] = "0b000111000000"; ram[358] = "0b110111000110"; ram[359] = "0b001001100101"; ram[360] = "0b111111101101"; ram[361] = "0b110011000101"; ram[362] = "0b111111111011"; ram[363] = "0b000000101101"; ram[364] = "0b110010101110"; ram[365] = "0b110010100110"; ram[366] = "0b110111010100"; ram[367] = "0b111000110010"; ram[368] = "0b110101010100"; ram[369] = "0b110101011110"; ram[370] = "0b001100111101"; ram[371] = "0b001111011000"; ram[372] = "0b000000110100"; ram[373] = "0b111111011001"; ram[374] = "0b001100101001"; ram[375] = "0b000101001101"; ram[376] = "0b111010110100"; ram[377] = "0b000110010001"; ram[378] = "0b110001111001"; ram[379] = "0b000011100001"; ram[380] = "0b001000000111"; ram[381] = "0b111110010001"; ram[382] = "0b000010011010"; ram[383] = "0b000110110100"; ram[384] = "0b001011101001"; ram[385] = "0b001011000000"; ram[386] = "0b000001110101"; ram[387] = "0b110100101101"; ram[388] = "0b000011001101"; ram[389] = "0b111101001111"; ram[390] = "0b000000111111"; ram[391] = "0b000010001000"; ram[392] = "0b000001001101"; ram[393] = "0b001001111001"; ram[394] = "0b111010100010"; ram[395] = "0b001110011111"; ram[396] = "0b001001000011"; ram[397] = "0b000000101101"; ram[398] = "0b110100000100"; ram[399] = "0b000010101100"; ram[400] = "0b111111110100"; ram[401] = "0b111010110111"; ram[402] = "0b001101000110"; ram[403] = "0b111110001001"; ram[404] = "0b001011000111"; ram[405] = "0b001011101111"; ram[406] = "0b111101011010"; ram[407] = "0b110011111101"; ram[408] = "0b000001110001"; ram[409] = "0b111101111011"; ram[410] = "0b000110101100"; ram[411] = "0b111101110100"; ram[412] = "0b000101110100"; ram[413] = "0b000000110111"; ram[414] = "0b110000001101"; ram[415] = "0b000001100111"; ram[416] = "0b000110000110"; ram[417] = "0b110000111110"; ram[418] = "0b110111110100"; ram[419] = "0b000110100010"; ram[420] = "0b001011001110"; ram[421] = "0b110111011011"; ram[422] = "0b000101001001"; ram[423] = "0b001111110001"; ram[424] = "0b001101011000"; ram[425] = "0b010000000011"; ram[426] = "0b110111111111"; ram[427] = "0b110110110101"; ram[428] = "0b110010101101"; ram[429] = "0b111011011011"; ram[430] = "0b111001101001"; ram[431] = "0b001010000101"; ram[432] = "0b000111101110"; ram[433] = "0b000111111100"; ram[434] = "0b111010100000"; ram[435] = "0b000010010101"; ram[436] = "0b111111000000"; ram[437] = "0b001100110101"; ram[438] = "0b111101000101"; ram[439] = "0b111001011101"; ram[440] = "0b110010110001"; ram[441] = "0b111001011101"; ram[442] = "0b111001100101"; ram[443] = "0b111010111110"; ram[444] = "0b001111011001"; ram[445] = "0b001010000111"; ram[446] = "0b000011010110"; ram[447] = "0b111100110100"; ram[448] = "0b111100010100"; ram[449] = "0b000010100101"; ram[450] = "0b110101010010"; ram[451] = "0b111111101101"; ram[452] = "0b111101001001"; ram[453] = "0b001001001001"; ram[454] = "0b001000100001"; ram[455] = "0b001101000000"; ram[456] = "0b001001111101"; ram[457] = "0b000011100110"; ram[458] = "0b000001000111"; ram[459] = "0b001010010011"; ram[460] = "0b000110100010"; ram[461] = "0b000110010011"; ram[462] = "0b111000100011"; ram[463] = "0b110100000001"; ram[464] = "0b111110100101"; ram[465] = "0b110111110111"; ram[466] = "0b111100000001"; ram[467] = "0b001111101011"; ram[468] = "0b001101100101"; ram[469] = "0b001100010010"; ram[470] = "0b000100001001"; ram[471] = "0b001001001000"; ram[472] = "0b101111111000"; ram[473] = "0b001001000111"; ram[474] = "0b110011011011"; ram[475] = "0b110111010101"; ram[476] = "0b111000011101"; ram[477] = "0b001110100011"; ram[478] = "0b001010111110"; ram[479] = "0b110011111101"; ram[480] = "0b111101011001"; ram[481] = "0b111110110011"; ram[482] = "0b111011001111"; ram[483] = "0b110001111000"; ram[484] = "0b000011001100"; ram[485] = "0b110010101001"; ram[486] = "0b110010000000"; ram[487] = "0b110111000001"; ram[488] = "0b000110100001"; ram[489] = "0b110110010010"; ram[490] = "0b111110110011"; ram[491] = "0b110110011100"; ram[492] = "0b001010110100"; ram[493] = "0b000110100000"; ram[494] = "0b000100010001"; ram[495] = "0b111010010110"; ram[496] = "0b000000101101"; ram[497] = "0b111100011110"; ram[498] = "0b111000001111"; ram[499] = "0b001111001000"; ram[500] = "0b110001011100"; ram[501] = "0b111010110100"; ram[502] = "0b000100001101"; ram[503] = "0b001110111011"; ram[504] = "0b001010011110"; ram[505] = "0b110010010110"; ram[506] = "0b111011111000"; ram[507] = "0b110111110101"; ram[508] = "0b000111001000"; ram[509] = "0b000100101111"; ram[510] = "0b111110010000"; ram[511] = "0b110001100011"; ram[512] = "0b110111010111"; ram[513] = "0b000000101100"; ram[514] = "0b001010010010"; ram[515] = "0b110110111100"; ram[516] = "0b111110101111"; ram[517] = "0b111111101111"; ram[518] = "0b000001100000"; ram[519] = "0b001101100000"; ram[520] = "0b111111101101"; ram[521] = "0b001110101011"; ram[522] = "0b111010100000"; ram[523] = "0b111101100110"; ram[524] = "0b111011001001"; ram[525] = "0b111000110001"; ram[526] = "0b111011100011"; ram[527] = "0b000101100000"; ram[528] = "0b111110110001"; ram[529] = "0b111000110111"; ram[530] = "0b110010001000"; ram[531] = "0b111000011111"; ram[532] = "0b001011111100"; ram[533] = "0b001011001001"; ram[534] = "0b001011111001"; ram[535] = "0b001001010110"; ram[536] = "0b111010001110"; ram[537] = "0b000101011101"; ram[538] = "0b001100110100"; ram[539] = "0b110000001111"; ram[540] = "0b111110011111"; ram[541] = "0b000001001001"; ram[542] = "0b111110100101"; ram[543] = "0b000001101100"; ram[544] = "0b000101100101"; ram[545] = "0b110100100111"; ram[546] = "0b111010111000"; ram[547] = "0b001011001001"; ram[548] = "0b000100001101"; ram[549] = "0b000110101100"; ram[550] = "0b111111101101"; ram[551] = "0b110000110110"; ram[552] = "0b111111101101"; ram[553] = "0b000100111111"; ram[554] = "0b001111001000"; ram[555] = "0b110100011000"; ram[556] = "0b111100101100"; ram[557] = "0b000110111101"; ram[558] = "0b001101001010"; ram[559] = "0b111111100100"; ram[560] = "0b111011110100"; ram[561] = "0b110011010101"; ram[562] = "0b000110111101"; ram[563] = "0b111011001110"; ram[564] = "0b000011110110"; ram[565] = "0b110001100100"; ram[566] = "0b000001101001"; ram[567] = "0b111101101000"; ram[568] = "0b110101110000"; ram[569] = "0b001101111000"; ram[570] = "0b000111001000"; ram[571] = "0b001001010111"; ram[572] = "0b110101000011"; ram[573] = "0b111100010111"; ram[574] = "0b000010110110"; ram[575] = "0b110100110100"; ram[576] = "0b000001110000"; ram[577] = "0b110001010100"; ram[578] = "0b111011010101"; ram[579] = "0b000110110001"; ram[580] = "0b001111100011"; ram[581] = "0b000010101110"; ram[582] = "0b111111010100"; ram[583] = "0b110111011111"; ram[584] = "0b001010011101"; ram[585] = "0b000010011001"; ram[586] = "0b111011101011"; ram[587] = "0b110000100100"; ram[588] = "0b000000111000"; ram[589] = "0b001111110011"; ram[590] = "0b110001110101"; ram[591] = "0b111011101000"; ram[592] = "0b111100010011"; ram[593] = "0b000011101100"; ram[594] = "0b110010100011"; ram[595] = "0b000010000110"; ram[596] = "0b110100110000"; ram[597] = "0b001110011010"; ram[598] = "0b001100011101"; ram[599] = "0b001011000010"; ram[600] = "0b110111010100"; ram[601] = "0b110111011000"; ram[602] = "0b110111111101"; ram[603] = "0b111000110011"; ram[604] = "0b001110011011"; ram[605] = "0b110010011000"; ram[606] = "0b001010101101"; ram[607] = "0b000001100101"; ram[608] = "0b110011011010"; ram[609] = "0b111000010110"; ram[610] = "0b001100001001"; ram[611] = "0b110100110000"; ram[612] = "0b110111010001"; ram[613] = "0b111000111010"; ram[614] = "0b001011000010"; ram[615] = "0b000001011111"; ram[616] = "0b001000100100"; ram[617] = "0b110110010110"; ram[618] = "0b110100010101"; ram[619] = "0b111001110110"; ram[620] = "0b001100011100"; ram[621] = "0b111001010100"; ram[622] = "0b111110001101"; ram[623] = "0b001110100010"; ram[624] = "0b000100001111"; ram[625] = "0b001101111100"; ram[626] = "0b110001111110"; ram[627] = "0b111011111011"; ram[628] = "0b111101100110"; ram[629] = "0b000100100101"; ram[630] = "0b110011100100"; ram[631] = "0b000100011100"; ram[632] = "0b110010001001"; ram[633] = "0b110010011110"; ram[634] = "0b110101100101"; ram[635] = "0b010000001001"; ram[636] = "0b111100111010"; ram[637] = "0b110000000110"; ram[638] = "0b001100110110"; ram[639] = "0b001001101000"; ram[640] = "0b111001101011"; ram[641] = "0b000111111010"; ram[642] = "0b001110011110"; ram[643] = "0b110111101001"; ram[644] = "0b000101011100"; ram[645] = "0b110010101011"; ram[646] = "0b001001001111"; ram[647] = "0b110110000000"; ram[648] = "0b110010100000"; ram[649] = "0b110010110110"; ram[650] = "0b101111111100"; ram[651] = "0b001011111000"; ram[652] = "0b010000001000"; ram[653] = "0b001100100011"; ram[654] = "0b111100111111"; ram[655] = "0b000110010100"; ram[656] = "0b000110000011"; ram[657] = "0b111010001111"; ram[658] = "0b111110101111"; ram[659] = "0b110101101001"; ram[660] = "0b001111001010"; ram[661] = "0b110111111101"; ram[662] = "0b111101010010"; ram[663] = "0b110110111010"; ram[664] = "0b111111111010"; ram[665] = "0b001001100111"; ram[666] = "0b110110110101"; ram[667] = "0b111101001000"; ram[668] = "0b110111111100"; ram[669] = "0b001100010000"; ram[670] = "0b001100001000"; ram[671] = "0b111011110111"; ram[672] = "0b001101010000"; ram[673] = "0b111101100101"; ram[674] = "0b001111100100"; ram[675] = "0b000111010101"; ram[676] = "0b111010110100"; ram[677] = "0b111010101001"; ram[678] = "0b110110110111"; ram[679] = "0b001111100010"; ram[680] = "0b001110101100"; ram[681] = "0b110111010001"; ram[682] = "0b111011000010"; ram[683] = "0b000111010001"; ram[684] = "0b001010101111"; ram[685] = "0b001100000101"; ram[686] = "0b000011001101"; ram[687] = "0b001011001010"; ram[688] = "0b001111001110"; ram[689] = "0b001110001010"; ram[690] = "0b111000000101"; ram[691] = "0b111110110111"; ram[692] = "0b101111111001"; ram[693] = "0b111111101010"; ram[694] = "0b010000000001"; ram[695] = "0b110101100111"; ram[696] = "0b000111001001"; ram[697] = "0b101111110110"; ram[698] = "0b001010111000"; ram[699] = "0b000001000100"; ram[700] = "0b111010010000"; ram[701] = "0b110010000110"; ram[702] = "0b101111111100"; ram[703] = "0b110100010011"; ram[704] = "0b001101011001"; ram[705] = "0b001101110011"; ram[706] = "0b000001110001"; ram[707] = "0b111001111110"; ram[708] = "0b111011010110"; ram[709] = "0b000101001010"; ram[710] = "0b110011011011"; ram[711] = "0b110000111100"; ram[712] = "0b001000101001"; ram[713] = "0b000101110011"; ram[714] = "0b000010010100"; ram[715] = "0b000011011100"; ram[716] = "0b110000110110"; ram[717] = "0b110101101100"; ram[718] = "0b000101100011"; ram[719] = "0b110011111000"; ram[720] = "0b000000100111"; ram[721] = "0b110011100100"; ram[722] = "0b000011110110"; ram[723] = "0b111000101000"; ram[724] = "0b001000001100"; ram[725] = "0b000010111100"; ram[726] = "0b001001011010"; ram[727] = "0b111001011111"; ram[728] = "0b111011100000"; ram[729] = "0b111110001100"; ram[730] = "0b110001100001"; ram[731] = "0b001100101001"; ram[732] = "0b001110110000"; ram[733] = "0b000101111000"; ram[734] = "0b110000010001"; ram[735] = "0b001110100001"; ram[736] = "0b000000101111"; ram[737] = "0b000101010101"; ram[738] = "0b001010010000"; ram[739] = "0b000110011111"; ram[740] = "0b111001010001"; ram[741] = "0b111000100101"; ram[742] = "0b111001000100"; ram[743] = "0b000100111110"; ram[744] = "0b110111010001"; ram[745] = "0b001011011111"; ram[746] = "0b000110100111"; ram[747] = "0b110100100000"; ram[748] = "0b001111111011"; ram[749] = "0b111101100000"; ram[750] = "0b001111000111"; ram[751] = "0b001111110100"; ram[752] = "0b111111101100"; ram[753] = "0b001100001000"; ram[754] = "0b001011101101"; ram[755] = "0b111001110001"; ram[756] = "0b110010010000"; ram[757] = "0b111101110111"; ram[758] = "0b000110111011"; ram[759] = "0b001110001001"; ram[760] = "0b000000101110"; ram[761] = "0b000111010101"; ram[762] = "0b000011101011"; ram[763] = "0b001110010001"; ram[764] = "0b111010101111"; ram[765] = "0b111101100010"; ram[766] = "0b001001010000"; ram[767] = "0b110010101000"; ram[768] = "0b000001111000"; ram[769] = "0b000100111011"; ram[770] = "0b001111101110"; ram[771] = "0b001010011110"; ram[772] = "0b111010100000"; ram[773] = "0b001101010100"; ram[774] = "0b001100111011"; ram[775] = "0b001110000111"; ram[776] = "0b001011000111"; ram[777] = "0b000000100101"; ram[778] = "0b110000010111"; ram[779] = "0b111011000010"; ram[780] = "0b001101011101"; ram[781] = "0b000011011101"; ram[782] = "0b000000001110"; ram[783] = "0b000000111100"; ram[784] = "0b111100101001"; ram[785] = "0b111011010000"; ram[786] = "0b110100100111"; ram[787] = "0b000001110011"; ram[788] = "0b110110001001"; ram[789] = "0b001101011001"; ram[790] = "0b110111000000"; ram[791] = "0b110000100111"; ram[792] = "0b001111100010"; ram[793] = "0b001110011000"; ram[794] = "0b110010110111"; ram[795] = "0b111101001000"; ram[796] = "0b001110011010"; ram[797] = "0b110111110101"; ram[798] = "0b101111111011"; ram[799] = "0b110110011110"; ram[800] = "0b110000111111"; ram[801] = "0b001101001001"; ram[802] = "0b000101110001"; ram[803] = "0b110000101000"; ram[804] = "0b110101010001"; ram[805] = "0b110100010010"; ram[806] = "0b000111110111"; ram[807] = "0b110001110011"; ram[808] = "0b000100111000"; ram[809] = "0b111011011000"; ram[810] = "0b001100101000"; ram[811] = "0b110011111010"; ram[812] = "0b111110100000"; ram[813] = "0b000001111111"; ram[814] = "0b111000111000"; ram[815] = "0b111011000001"; ram[816] = "0b000000101011"; ram[817] = "0b000101010100"; ram[818] = "0b000100110010"; ram[819] = "0b110000100111"; ram[820] = "0b001000100011"; ram[821] = "0b110000001110"; ram[822] = "0b110000111110"; ram[823] = "0b001111101111"; ram[824] = "0b110101110100"; ram[825] = "0b110100011011"; ram[826] = "0b000010011100"; ram[827] = "0b111100111101"; ram[828] = "0b001110100111"; ram[829] = "0b111010011011"; ram[830] = "0b000001001000"; ram[831] = "0b111000010110"; ram[832] = "0b111100111101"; ram[833] = "0b110111100001"; ram[834] = "0b001000100100"; ram[835] = "0b000100100000"; ram[836] = "0b000000100111"; ram[837] = "0b110100000001"; ram[838] = "0b111000100011"; ram[839] = "0b000111001111"; SC_METHOD(prc_write_0); sensitive<<clk.pos(); SC_METHOD(prc_write_1); sensitive<<clk.pos(); } void prc_write_0() { if (ce0.read() == sc_dt::Log_1) { if(address0.read().is_01() && address0.read().to_uint()<AddressRange) q0 = ram[address0.read().to_uint()]; else q0 = sc_lv<DataWidth>(); } } void prc_write_1() { if (ce1.read() == sc_dt::Log_1) { if(address1.read().is_01() && address1.read().to_uint()<AddressRange) q1 = ram[address1.read().to_uint()]; else q1 = sc_lv<DataWidth>(); } } }; //endmodule SC_MODULE(fc_layer3_fc_layeh8b) { static const unsigned DataWidth = 12; static const unsigned AddressRange = 840; static const unsigned AddressWidth = 10; sc_core::sc_in <sc_lv<AddressWidth> > address0; sc_core::sc_in<sc_logic> ce0; sc_core::sc_out <sc_lv<DataWidth> > q0; sc_core::sc_in <sc_lv<AddressWidth> > address1; sc_core::sc_in<sc_logic> ce1; sc_core::sc_out <sc_lv<DataWidth> > q1; sc_core::sc_in<sc_logic> reset; sc_core::sc_in<bool> clk; fc_layer3_fc_layeh8b_ram* meminst; SC_CTOR(fc_layer3_fc_layeh8b) { meminst = new fc_layer3_fc_layeh8b_ram("fc_layer3_fc_layeh8b_ram"); meminst->address0(address0); meminst->ce0(ce0); meminst->q0(q0); meminst->address1(address1); meminst->ce1(ce1); meminst->q1(q1); meminst->reset(reset); meminst->clk(clk); } ~fc_layer3_fc_layeh8b() { delete meminst; } };//endmodule #endif
[ "sergiududa" ]
sergiududa
94fc4d2357efafe566f2b37dde16fa8e6bdf6e2d
afa5ba387a946289585931bf45aafb1be6c80440
/include/lexy/callback/integer.hpp
75c5ac472fbe40f9528422b03e4e1a66ea7c73af
[ "BSL-1.0" ]
permissive
ExternalRepositories/lexy
f315ae41108777d7ce50cdba252a28b794e14338
edc6bd4aabd6f0ecbddba6f2bbf9bd2c6e4fa61d
refs/heads/main
2023-07-15T23:30:30.027012
2021-08-22T16:12:15
2021-08-22T16:19:30
331,607,380
2
0
BSL-1.0
2021-01-21T11:31:20
2021-01-21T11:31:19
null
UTF-8
C++
false
false
1,237
hpp
// Copyright (C) 2020-2021 Jonathan Müller <[email protected]> // This file is subject to the license terms in the LICENSE file // found in the top-level directory of this distribution. #ifndef LEXY_CALLBACK_INTEGER_HPP_INCLUDED #define LEXY_CALLBACK_INTEGER_HPP_INCLUDED #include <lexy/callback/base.hpp> #include <lexy/dsl/sign.hpp> namespace lexy { template <typename T> struct _int { using return_type = T; // You don't actually produce an integer value. constexpr T operator()(lexy::plus_sign) const = delete; constexpr T operator()(lexy::minus_sign) const = delete; template <typename Integer> constexpr T operator()(const Integer& value) const { return T(value); } template <typename Integer> constexpr T operator()(lexy::plus_sign, const Integer& value) const { return T(value); } template <typename Integer> constexpr T operator()(lexy::minus_sign, const Integer& value) const { return T(-value); } }; // A callback that takes an optional sign and an integer and produces the signed integer. template <typename T> constexpr auto as_integer = _int<T>{}; } // namespace lexy #endif // LEXY_CALLBACK_INTEGER_HPP_INCLUDED
108cf14cd23641d59966ec9db47522fec22f0d8e
cd8c53b7337944103974235cf3e2fab028392459
/sources/ui/file_browser_model.h
bb7a7478118f0dc10e7cf1b6d2f2cc6587969f75
[ "BSL-1.0" ]
permissive
Outcue/smf-dsp
0b2aab47a0093f655cfe014bb200c78048e4c28f
07681746b8a7b9106b837d7ff457d3cdf8704ccc
refs/heads/master
2023-03-04T03:52:19.241950
2021-01-17T13:20:08
2021-01-17T13:20:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,485
h
// Copyright Jean Pierre Cimalando 2019. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at // http://www.boost.org/LICENSE_1_0.txt) #pragma once #include "file_entry.h" #include <gsl/gsl> #include <vector> #include <string> #include <functional> class File_Browser_Model { public: File_Browser_Model(); explicit File_Browser_Model(gsl::cstring_span cwd); std::string current_filename() const; void set_current_filename(gsl::cstring_span file); std::string filename(size_t index) const; std::string current_path() const; void set_current_path(gsl::cstring_span path); const std::string &cwd() const noexcept { return cwd_; } void set_cwd(gsl::cstring_span dir); size_t selection() const noexcept { return sel_; } void set_selection(size_t sel); size_t count() const noexcept { return entries_.size(); } const File_Entry &entry(size_t index) const noexcept { return entries_[index]; } const File_Entry *current_entry() const noexcept; size_t find_entry(gsl::cstring_span name) const; void refresh(); void trigger_entry(size_t index); void trigger_selected_entry(); std::function<void (const std::string &, const File_Entry *, size_t, size_t)> FileOpenCallback; std::function<bool (const File_Entry &)> FileFilterCallback; private: size_t sel_ = 0; std::string cwd_; std::vector<File_Entry> entries_; };
7ce44058134becb22afbfedf19bca82a9c6002b6
16946f13aa1e000a8f9b9245b59f5423d0c78a5c
/devel/include/stdr_msgs/DeleteRobotAction.h
c18affdc806fb563a1ebd35107e97f24ce9854c4
[]
no_license
tahlia5119/cw2_ws_fin
d0eb27d0d0650fa9b7f15df5ab061d929624154d
3d38549a316dabe1d07c598e1840e14fb579f6f0
refs/heads/master
2020-03-12T18:25:43.927382
2018-04-23T21:36:43
2018-04-23T21:36:43
130,759,687
0
0
null
null
null
null
UTF-8
C++
false
false
11,163
h
// Generated by gencpp from file stdr_msgs/DeleteRobotAction.msg // DO NOT EDIT! #ifndef STDR_MSGS_MESSAGE_DELETEROBOTACTION_H #define STDR_MSGS_MESSAGE_DELETEROBOTACTION_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> #include <stdr_msgs/DeleteRobotActionGoal.h> #include <stdr_msgs/DeleteRobotActionResult.h> #include <stdr_msgs/DeleteRobotActionFeedback.h> namespace stdr_msgs { template <class ContainerAllocator> struct DeleteRobotAction_ { typedef DeleteRobotAction_<ContainerAllocator> Type; DeleteRobotAction_() : action_goal() , action_result() , action_feedback() { } DeleteRobotAction_(const ContainerAllocator& _alloc) : action_goal(_alloc) , action_result(_alloc) , action_feedback(_alloc) { (void)_alloc; } typedef ::stdr_msgs::DeleteRobotActionGoal_<ContainerAllocator> _action_goal_type; _action_goal_type action_goal; typedef ::stdr_msgs::DeleteRobotActionResult_<ContainerAllocator> _action_result_type; _action_result_type action_result; typedef ::stdr_msgs::DeleteRobotActionFeedback_<ContainerAllocator> _action_feedback_type; _action_feedback_type action_feedback; typedef boost::shared_ptr< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> const> ConstPtr; }; // struct DeleteRobotAction_ typedef ::stdr_msgs::DeleteRobotAction_<std::allocator<void> > DeleteRobotAction; typedef boost::shared_ptr< ::stdr_msgs::DeleteRobotAction > DeleteRobotActionPtr; typedef boost::shared_ptr< ::stdr_msgs::DeleteRobotAction const> DeleteRobotActionConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> & v) { ros::message_operations::Printer< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace stdr_msgs namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': False} // {'nav_msgs': ['/opt/ros/kinetic/share/nav_msgs/cmake/../msg'], 'geometry_msgs': ['/opt/ros/kinetic/share/geometry_msgs/cmake/../msg'], 'actionlib_msgs': ['/opt/ros/kinetic/share/actionlib_msgs/cmake/../msg'], 'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'stdr_msgs': ['/home/tahlia/cw2_redo/src/comp313p/stdr_simulator/stdr_msgs/msg', '/home/tahlia/cw2_redo/devel/share/stdr_msgs/msg']} // !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types'] template <class ContainerAllocator> struct IsFixedSize< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct IsFixedSize< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> const> : FalseType { }; template <class ContainerAllocator> struct IsMessage< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> const> : FalseType { }; template<class ContainerAllocator> struct MD5Sum< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> > { static const char* value() { return "380d84e297a0fec2ae31cb6218729730"; } static const char* value(const ::stdr_msgs::DeleteRobotAction_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0x380d84e297a0fec2ULL; static const uint64_t static_value2 = 0xae31cb6218729730ULL; }; template<class ContainerAllocator> struct DataType< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> > { static const char* value() { return "stdr_msgs/DeleteRobotAction"; } static const char* value(const ::stdr_msgs::DeleteRobotAction_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> > { static const char* value() { return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\ \n\ DeleteRobotActionGoal action_goal\n\ DeleteRobotActionResult action_result\n\ DeleteRobotActionFeedback action_feedback\n\ \n\ ================================================================================\n\ MSG: stdr_msgs/DeleteRobotActionGoal\n\ # ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\ \n\ Header header\n\ actionlib_msgs/GoalID goal_id\n\ DeleteRobotGoal goal\n\ \n\ ================================================================================\n\ MSG: std_msgs/Header\n\ # Standard metadata for higher-level stamped data types.\n\ # This is generally used to communicate timestamped data \n\ # in a particular coordinate frame.\n\ # \n\ # sequence ID: consecutively increasing ID \n\ uint32 seq\n\ #Two-integer timestamp that is expressed as:\n\ # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\ # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\ # time-handling sugar is provided by the client library\n\ time stamp\n\ #Frame this data is associated with\n\ # 0: no frame\n\ # 1: global frame\n\ string frame_id\n\ \n\ ================================================================================\n\ MSG: actionlib_msgs/GoalID\n\ # The stamp should store the time at which this goal was requested.\n\ # It is used by an action server when it tries to preempt all\n\ # goals that were requested before a certain time\n\ time stamp\n\ \n\ # The id provides a way to associate feedback and\n\ # result message with specific goal requests. The id\n\ # specified must be unique.\n\ string id\n\ \n\ \n\ ================================================================================\n\ MSG: stdr_msgs/DeleteRobotGoal\n\ # ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\ #goal definition\n\ string name\n\ \n\ ================================================================================\n\ MSG: stdr_msgs/DeleteRobotActionResult\n\ # ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\ \n\ Header header\n\ actionlib_msgs/GoalStatus status\n\ DeleteRobotResult result\n\ \n\ ================================================================================\n\ MSG: actionlib_msgs/GoalStatus\n\ GoalID goal_id\n\ uint8 status\n\ uint8 PENDING = 0 # The goal has yet to be processed by the action server\n\ uint8 ACTIVE = 1 # The goal is currently being processed by the action server\n\ uint8 PREEMPTED = 2 # The goal received a cancel request after it started executing\n\ # and has since completed its execution (Terminal State)\n\ uint8 SUCCEEDED = 3 # The goal was achieved successfully by the action server (Terminal State)\n\ uint8 ABORTED = 4 # The goal was aborted during execution by the action server due\n\ # to some failure (Terminal State)\n\ uint8 REJECTED = 5 # The goal was rejected by the action server without being processed,\n\ # because the goal was unattainable or invalid (Terminal State)\n\ uint8 PREEMPTING = 6 # The goal received a cancel request after it started executing\n\ # and has not yet completed execution\n\ uint8 RECALLING = 7 # The goal received a cancel request before it started executing,\n\ # but the action server has not yet confirmed that the goal is canceled\n\ uint8 RECALLED = 8 # The goal received a cancel request before it started executing\n\ # and was successfully cancelled (Terminal State)\n\ uint8 LOST = 9 # An action client can determine that a goal is LOST. This should not be\n\ # sent over the wire by an action server\n\ \n\ #Allow for the user to associate a string with GoalStatus for debugging\n\ string text\n\ \n\ \n\ ================================================================================\n\ MSG: stdr_msgs/DeleteRobotResult\n\ # ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\ #result definition\n\ bool success\n\ \n\ ================================================================================\n\ MSG: stdr_msgs/DeleteRobotActionFeedback\n\ # ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\ \n\ Header header\n\ actionlib_msgs/GoalStatus status\n\ DeleteRobotFeedback feedback\n\ \n\ ================================================================================\n\ MSG: stdr_msgs/DeleteRobotFeedback\n\ # ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\ #feedback\n\ \n\ "; } static const char* value(const ::stdr_msgs::DeleteRobotAction_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.action_goal); stream.next(m.action_result); stream.next(m.action_feedback); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct DeleteRobotAction_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::stdr_msgs::DeleteRobotAction_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::stdr_msgs::DeleteRobotAction_<ContainerAllocator>& v) { s << indent << "action_goal: "; s << std::endl; Printer< ::stdr_msgs::DeleteRobotActionGoal_<ContainerAllocator> >::stream(s, indent + " ", v.action_goal); s << indent << "action_result: "; s << std::endl; Printer< ::stdr_msgs::DeleteRobotActionResult_<ContainerAllocator> >::stream(s, indent + " ", v.action_result); s << indent << "action_feedback: "; s << std::endl; Printer< ::stdr_msgs::DeleteRobotActionFeedback_<ContainerAllocator> >::stream(s, indent + " ", v.action_feedback); } }; } // namespace message_operations } // namespace ros #endif // STDR_MSGS_MESSAGE_DELETEROBOTACTION_H
53ff0d15d53f86d16420c5cb3949008f077b3dcd
cf086a1895e22c9ecb6841a71def0f43a18a004e
/libraries/chain/worker_evaluator.cpp
40130dab465ca8628450f735e8ce021c7bdd7b75
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
justshabir/VINchain-blockchain
95de7c4547043185c800f526d20802f88dcecfe6
c52ec3bf67c6d4700bbaf5ec903185d31a2d63ec
refs/heads/master
2022-02-28T23:28:45.551508
2019-10-27T12:08:01
2019-10-27T12:17:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,853
cpp
/* * Copyright (c) 2015 Cryptonomex, Inc., and contributors. * * The MIT License * * 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 <graphene/chain/database.hpp> #include <graphene/chain/worker_evaluator.hpp> #include <graphene/chain/account_object.hpp> #include <graphene/chain/vesting_balance_object.hpp> #include <graphene/chain/worker_object.hpp> #include <graphene/chain/protocol/vote.hpp> namespace graphene { namespace chain { void_result worker_create_evaluator::do_evaluate(const worker_create_evaluator::operation_type &o) { try { database &d = db(); FC_ASSERT(d.get(o.owner).is_lifetime_member()); FC_ASSERT(o.work_begin_date >= d.head_block_time()); return void_result(); } FC_CAPTURE_AND_RETHROW((o)) } struct worker_init_visitor { typedef void result_type; worker_object &worker; database &db; worker_init_visitor(worker_object &w, database &d) : worker(w), db(d) {} result_type operator()(const vesting_balance_worker_initializer &i) const { vesting_balance_worker_type w; w.balance = db.create<vesting_balance_object>([&](vesting_balance_object &b) { b.owner = worker.worker_account; b.balance = asset(0); cdd_vesting_policy policy; policy.vesting_seconds = fc::days(i.pay_vesting_period_days).to_seconds(); policy.coin_seconds_earned = 0; policy.coin_seconds_earned_last_update = db.head_block_time(); b.policy = policy; }).id; worker.worker = w; } template<typename T> result_type operator()(const T &) const { // DO NOTHING FOR OTHER WORKERS } }; object_id_type worker_create_evaluator::do_apply(const worker_create_evaluator::operation_type &o) { try { database &d = db(); vote_id_type for_id, against_id; d.modify(d.get_global_properties(), [&for_id, &against_id](global_property_object &p) { for_id = get_next_vote_id(p, vote_id_type::worker); against_id = get_next_vote_id(p, vote_id_type::worker); }); return d.create<worker_object>([&](worker_object &w) { w.worker_account = o.owner; w.daily_pay = o.daily_pay; w.work_begin_date = o.work_begin_date; w.work_end_date = o.work_end_date; w.name = o.name; w.url = o.url; w.vote_for = for_id; w.vote_against = against_id; w.worker.set_which(o.initializer.which()); o.initializer.visit(worker_init_visitor(w, d)); }).id; } FC_CAPTURE_AND_RETHROW((o)) } void refund_worker_type::pay_worker(share_type pay, database &db) { total_burned += pay; db.modify(db.get(asset_id_type()).dynamic_data(db), [pay](asset_dynamic_data_object &d) { d.current_supply -= pay; }); } void vesting_balance_worker_type::pay_worker(share_type pay, database &db) { db.modify(balance(db), [&](vesting_balance_object &b) { b.deposit(db.head_block_time(), asset(pay)); }); } void burn_worker_type::pay_worker(share_type pay, database &db) { total_burned += pay; db.adjust_balance(GRAPHENE_NULL_ACCOUNT, pay); } } } // graphene::chain
4d5c4033f6545148aa8035e00c8257cdc634804a
952376f77207bc583ac725dd5715619c7e2b0391
/chapter11/11.33.cpp
a32020c1aa90d99efdeaf178feadcaf7b5260ae3
[]
no_license
piaoliangkb/cppprimer
3cda790a34bf8c211fe47025fc6fd063eb1e93d8
15ccb60b8c74540256eff944d3e7a83decdc9245
refs/heads/master
2022-05-08T20:31:41.551005
2022-03-14T02:05:06
2022-03-14T02:05:06
173,749,818
0
0
null
null
null
null
UTF-8
C++
false
false
1,816
cpp
#include <fstream> #include <map> #include <string> #include <iostream> #include <sstream> // 主转换函数,调用 transformer // 接受两个参数,第一个参数是映射规则的文件输入,第二个参数是要转换的段落输入 void word_transformer(std::fstream& mapfile, std::fstream& input); // 接受一个映射规则的文件流,读取映射规则 // 返回一个映射的 map table std::map<std::string, std::string> buildmap(std::fstream &mapfile); // 转换函数 const std::string& transformer(const std::string& s, const std::map<std::string, std::string> &map); std::map<std::string, std::string> buildmap(std::fstream& mapfile) { std::string key; std::string value; std::map<std::string, std::string> map_table; while ((mapfile>>key) && (getline(mapfile, value))) { map_table[key] = value.substr(1).substr(0, value.find_last_not_of(' ')); } return map_table; } const std::string& transformer(const std::string& s, const std::map<std::string, std::string>& map) { auto iter = map.find(s); if (iter != map.end()) return iter->second; return s; } void word_transformer(std::fstream& mapfile, std::fstream& input) { auto map_table = buildmap(mapfile); std::string text; while (getline(input, text)) { std::istringstream iss(text); std::string word; while (iss >> word) { std::cout << transformer(word, map_table) << " "; } std::cout << std::endl; } } int main() { std::fstream mapfile("map_rules_11_33.txt"); std::fstream sourcetext("convert_source_11_33.txt"); if (mapfile && sourcetext) word_transformer(mapfile, sourcetext); else std::cout << "cant find file of map_rules or source_text" << std::endl; return 0; }
9656b14e580ceb5dcf2d69c1a05c96fb461378cb
f81124e4a52878ceeb3e4b85afca44431ce68af2
/re20_3/processor28/constant/polyMesh/points
b7c9577a9ff5b9400ae75442a10f304d50a7c38c
[]
no_license
chaseguy15/coe-of2
7f47a72987638e60fd7491ee1310ee6a153a5c10
dc09e8d5f172489eaa32610e08e1ee7fc665068c
refs/heads/master
2023-03-29T16:59:14.421456
2021-04-06T23:26:52
2021-04-06T23:26:52
355,040,336
0
1
null
null
null
null
UTF-8
C++
false
false
72,760
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class vectorField; location "constant/polyMesh"; object points; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 2254 ( (2.875 0 -0.05) (2.9125 0 -0.05) (2.95 0 -0.05) (2.9875 0 -0.05) (3.025 0 -0.05) (3.0625 0 -0.05) (2.874728715 0.02563388111 -0.05) (2.912230143 0.02562301976 -0.05) (2.949731571 0.02561215842 -0.05) (2.987232999 0.02560129708 -0.05) (3.024734427 0.02559043574 -0.05) (3.062235854 0.02557957439 -0.05) (2.873915048 0.05125355941 -0.05) (2.911420758 0.05123191148 -0.05) (2.948926468 0.05121026354 -0.05) (2.986432179 0.05118861561 -0.05) (3.023937889 0.05116696768 -0.05) (3.061443599 0.05114531974 -0.05) (2.872559555 0.07684484185 -0.05) (2.9100724 0.07681255678 -0.05) (2.947585244 0.07678027171 -0.05) (2.985098088 0.07674798663 -0.05) (3.022610933 0.07671570156 -0.05) (3.060123777 0.07668341649 -0.05) (2.870663166 0.1023935548 -0.05) (2.908185992 0.1023508567 -0.05) (2.945708817 0.1023081585 -0.05) (2.983231642 0.1022654603 -0.05) (3.020754468 0.1022227622 -0.05) (3.058277293 0.102180064 -0.05) (2.868227181 0.1278855539 -0.05) (2.905762827 0.1278327412 -0.05) (2.943298474 0.1277799284 -0.05) (2.98083412 0.1277271157 -0.05) (3.018369766 0.1276743029 -0.05) (3.055905413 0.1276214901 -0.05) (2.865253268 0.1533067336 -0.05) (2.902804567 0.153244179 -0.05) (2.940355865 0.1531816243 -0.05) (2.977907164 0.1531190697 -0.05) (3.015458463 0.1530565151 -0.05) (3.053009761 0.1529939605 -0.05) (2.861743467 0.1786430368 -0.05) (2.899313238 0.178571187 -0.05) (2.936883009 0.1784993373 -0.05) (2.974452781 0.1784274875 -0.05) (3.012022552 0.1783556377 -0.05) (3.049592323 0.178283788 -0.05) (2.857700182 0.2038804647 -0.05) (2.895291234 0.2037998402 -0.05) (2.932882286 0.2037192156 -0.05) (2.970473337 0.2036385911 -0.05) (3.008064389 0.2035579666 -0.05) (3.045655441 0.2034773421 -0.05) (2.853126185 0.2290050862 -0.05) (2.89074131 0.2289162806 -0.05) (2.928356436 0.2288274751 -0.05) (2.965971561 0.2287386695 -0.05) (3.003586686 0.228649864 -0.05) (3.041201812 0.2285610585 -0.05) (2.84802461 0.2540030475 -0.05) (2.885666586 0.2539067275 -0.05) (2.923308562 0.2538104076 -0.05) (2.960950538 0.2537140877 -0.05) (2.998592513 0.2536177677 -0.05) (3.036234489 0.2535214478 -0.05) (3.073876465 0.2534251279 -0.05) (2.842398955 0.2788605817 -0.05) (2.880070539 0.2787574864 -0.05) (2.917742124 0.2786543912 -0.05) (2.955413708 0.2785512959 -0.05) (2.993085292 0.2784482007 -0.05) (3.030756877 0.2783451055 -0.05) (3.068428461 0.2782420102 -0.05) (2.873957004 0.3034549585 -0.05) (2.911660936 0.303345899 -0.05) (2.949364867 0.3032368395 -0.05) (2.987068798 0.30312778 -0.05) (3.024772729 0.3030187205 -0.05) (3.06247666 0.302909661 -0.05) (2.867330172 0.32798565 -0.05) (2.905069166 0.3278715087 -0.05) (2.94280816 0.3277573673 -0.05) (2.980547153 0.327643226 -0.05) (3.018286147 0.3275290847 -0.05) (3.056025141 0.3274149433 -0.05) (2.860194584 0.3523361816 -0.05) (2.897971332 0.3522179117 -0.05) (2.93574808 0.3520996417 -0.05) (2.973524828 0.3519813718 -0.05) (3.011301577 0.3518631019 -0.05) (3.049078325 0.3517448319 -0.05) (2.85255513 0.3764932973 -0.05) (2.890372298 0.3763719221 -0.05) (2.928189467 0.3762505469 -0.05) (2.966006635 0.3761291718 -0.05) (3.003823804 0.3760077966 -0.05) (3.041640973 0.3758864214 -0.05) (2.844417046 0.4004438737 -0.05) (2.882277273 0.4003204861 -0.05) (2.9201375 0.4001970985 -0.05) (2.957997727 0.4000737108 -0.05) (2.995857955 0.3999503232 -0.05) (3.033718182 0.3998269356 -0.05) (3.071578409 0.399703548 -0.05) (2.835785909 0.424174929 -0.05) (2.873691804 0.4240506904 -0.05) (2.911597698 0.4239264518 -0.05) (2.949503593 0.4238022133 -0.05) (2.987409488 0.4236779747 -0.05) (3.025315382 0.4235537362 -0.05) (3.063221277 0.4234294976 -0.05) (2.864621775 0.4475497716 -0.05) (2.902575915 0.4474259115 -0.05) (2.940530054 0.4473020514 -0.05) (2.978484193 0.4471781912 -0.05) (3.016438333 0.4470543311 -0.05) (3.054392472 0.446930471 -0.05) (2.855073403 0.4708051246 -0.05) (2.893078331 0.4706829394 -0.05) (2.93108326 0.4705607541 -0.05) (2.969088189 0.4704385688 -0.05) (3.007093118 0.4703163835 -0.05) (3.045098046 0.4701941983 -0.05) (2.845053231 0.4938043114 -0.05) (2.883111458 0.4936851635 -0.05) (2.921169686 0.4935660157 -0.05) (2.959227913 0.4934468679 -0.05) (2.997286141 0.4933277201 -0.05) (3.035344368 0.4932085722 -0.05) (3.073402596 0.4930894244 -0.05) (2.834568127 0.5165350693 -0.05) (2.872682126 0.5164203868 -0.05) (2.910796125 0.5163057042 -0.05) (2.948910125 0.5161910216 -0.05) (2.987024124 0.5160763391 -0.05) (3.025138123 0.5159616565 -0.05) (3.063252123 0.5158469739 -0.05) (2.861797482 0.5388765948 -0.05) (2.899969688 0.5387678695 -0.05) (2.938141894 0.5386591443 -0.05) (2.9763141 0.538550419 -0.05) (3.014486306 0.5384416938 -0.05) (3.052658512 0.5383329685 -0.05) (2.850464987 0.5610419645 -0.05) (2.888697794 0.5609407519 -0.05) (2.926930602 0.5608395392 -0.05) (2.965163409 0.5607383265 -0.05) (3.003396217 0.5606371139 -0.05) (3.041629024 0.5605359012 -0.05) (2.838692406 0.5829048722 -0.05) (2.876988169 0.5828127896 -0.05) (2.915283931 0.582720707 -0.05) (2.953579694 0.5826286244 -0.05) (2.991875456 0.5825365418 -0.05) (3.030171219 0.5824444592 -0.05) (3.068466981 0.5823523766 -0.05) (2.864848837 0.6043726275 -0.05) (2.903209865 0.6042913534 -0.05) (2.941570893 0.6042100793 -0.05) (2.97993192 0.6041288052 -0.05) (3.018292948 0.6040475312 -0.05) (3.056653976 0.6039662571 -0.05) (2.852288119 0.6256091239 -0.05) (2.890716677 0.6255403968 -0.05) (2.929145236 0.6254716697 -0.05) (2.967573794 0.6254029425 -0.05) (3.006002353 0.6253342154 -0.05) (3.044430911 0.6252654882 -0.05) (2.839314622 0.6465113592 -0.05) (2.87781293 0.6464569761 -0.05) (2.916311239 0.646402593 -0.05) (2.954809547 0.6463482099 -0.05) (2.993307856 0.6462938268 -0.05) (3.031806164 0.6462394437 -0.05) (3.070304473 0.6461850606 -0.05) (2.864507468 0.6670304581 -0.05) (2.903077698 0.6669922736 -0.05) (2.941647928 0.6669540892 -0.05) (2.980218158 0.6669159047 -0.05) (3.018788388 0.6668777202 -0.05) (3.057358618 0.6668395357 -0.05) (2.85080941 0.6872504447 -0.05) (2.889453683 0.6872303696 -0.05) (2.928097957 0.6872102945 -0.05) (2.96674223 0.6871902195 -0.05) (3.005386504 0.6871701444 -0.05) (3.044030777 0.6871500693 -0.05) (2.836728143 0.70710678 -0.05) (2.875448531 0.70710678 -0.05) (2.91416892 0.70710678 -0.05) (2.952889308 0.70710678 -0.05) (2.991609697 0.70710678 -0.05) (3.030330085 0.70710678 -0.05) (3.069050473 0.70710678 -0.05) (2.875 0 0.05) (2.9125 0 0.05) (2.95 0 0.05) (2.9875 0 0.05) (3.025 0 0.05) (3.0625 0 0.05) (2.874728715 0.02563388111 0.05) (2.912230143 0.02562301976 0.05) (2.949731571 0.02561215842 0.05) (2.987232999 0.02560129708 0.05) (3.024734427 0.02559043574 0.05) (3.062235854 0.02557957439 0.05) (2.873915048 0.05125355941 0.05) (2.911420758 0.05123191148 0.05) (2.948926468 0.05121026354 0.05) (2.986432179 0.05118861561 0.05) (3.023937889 0.05116696768 0.05) (3.061443599 0.05114531974 0.05) (2.872559555 0.07684484185 0.05) (2.9100724 0.07681255678 0.05) (2.947585244 0.07678027171 0.05) (2.985098088 0.07674798663 0.05) (3.022610933 0.07671570156 0.05) (3.060123777 0.07668341649 0.05) (2.870663166 0.1023935548 0.05) (2.908185992 0.1023508567 0.05) (2.945708817 0.1023081585 0.05) (2.983231642 0.1022654603 0.05) (3.020754468 0.1022227622 0.05) (3.058277293 0.102180064 0.05) (2.868227181 0.1278855539 0.05) (2.905762827 0.1278327412 0.05) (2.943298474 0.1277799284 0.05) (2.98083412 0.1277271157 0.05) (3.018369766 0.1276743029 0.05) (3.055905413 0.1276214901 0.05) (2.865253268 0.1533067336 0.05) (2.902804567 0.153244179 0.05) (2.940355865 0.1531816243 0.05) (2.977907164 0.1531190697 0.05) (3.015458463 0.1530565151 0.05) (3.053009761 0.1529939605 0.05) (2.861743467 0.1786430368 0.05) (2.899313238 0.178571187 0.05) (2.936883009 0.1784993373 0.05) (2.974452781 0.1784274875 0.05) (3.012022552 0.1783556377 0.05) (3.049592323 0.178283788 0.05) (2.857700182 0.2038804647 0.05) (2.895291234 0.2037998402 0.05) (2.932882286 0.2037192156 0.05) (2.970473337 0.2036385911 0.05) (3.008064389 0.2035579666 0.05) (3.045655441 0.2034773421 0.05) (2.853126185 0.2290050862 0.05) (2.89074131 0.2289162806 0.05) (2.928356436 0.2288274751 0.05) (2.965971561 0.2287386695 0.05) (3.003586686 0.228649864 0.05) (3.041201812 0.2285610585 0.05) (2.84802461 0.2540030475 0.05) (2.885666586 0.2539067275 0.05) (2.923308562 0.2538104076 0.05) (2.960950538 0.2537140877 0.05) (2.998592513 0.2536177677 0.05) (3.036234489 0.2535214478 0.05) (3.073876465 0.2534251279 0.05) (2.842398955 0.2788605817 0.05) (2.880070539 0.2787574864 0.05) (2.917742124 0.2786543912 0.05) (2.955413708 0.2785512959 0.05) (2.993085292 0.2784482007 0.05) (3.030756877 0.2783451055 0.05) (3.068428461 0.2782420102 0.05) (2.873957004 0.3034549585 0.05) (2.911660936 0.303345899 0.05) (2.949364867 0.3032368395 0.05) (2.987068798 0.30312778 0.05) (3.024772729 0.3030187205 0.05) (3.06247666 0.302909661 0.05) (2.867330172 0.32798565 0.05) (2.905069166 0.3278715087 0.05) (2.94280816 0.3277573673 0.05) (2.980547153 0.327643226 0.05) (3.018286147 0.3275290847 0.05) (3.056025141 0.3274149433 0.05) (2.860194584 0.3523361816 0.05) (2.897971332 0.3522179117 0.05) (2.93574808 0.3520996417 0.05) (2.973524828 0.3519813718 0.05) (3.011301577 0.3518631019 0.05) (3.049078325 0.3517448319 0.05) (2.85255513 0.3764932973 0.05) (2.890372298 0.3763719221 0.05) (2.928189467 0.3762505469 0.05) (2.966006635 0.3761291718 0.05) (3.003823804 0.3760077966 0.05) (3.041640973 0.3758864214 0.05) (2.844417046 0.4004438737 0.05) (2.882277273 0.4003204861 0.05) (2.9201375 0.4001970985 0.05) (2.957997727 0.4000737108 0.05) (2.995857955 0.3999503232 0.05) (3.033718182 0.3998269356 0.05) (3.071578409 0.399703548 0.05) (2.835785909 0.424174929 0.05) (2.873691804 0.4240506904 0.05) (2.911597698 0.4239264518 0.05) (2.949503593 0.4238022133 0.05) (2.987409488 0.4236779747 0.05) (3.025315382 0.4235537362 0.05) (3.063221277 0.4234294976 0.05) (2.864621775 0.4475497716 0.05) (2.902575915 0.4474259115 0.05) (2.940530054 0.4473020514 0.05) (2.978484193 0.4471781912 0.05) (3.016438333 0.4470543311 0.05) (3.054392472 0.446930471 0.05) (2.855073403 0.4708051246 0.05) (2.893078331 0.4706829394 0.05) (2.93108326 0.4705607541 0.05) (2.969088189 0.4704385688 0.05) (3.007093118 0.4703163835 0.05) (3.045098046 0.4701941983 0.05) (2.845053231 0.4938043114 0.05) (2.883111458 0.4936851635 0.05) (2.921169686 0.4935660157 0.05) (2.959227913 0.4934468679 0.05) (2.997286141 0.4933277201 0.05) (3.035344368 0.4932085722 0.05) (3.073402596 0.4930894244 0.05) (2.834568127 0.5165350693 0.05) (2.872682126 0.5164203868 0.05) (2.910796125 0.5163057042 0.05) (2.948910125 0.5161910216 0.05) (2.987024124 0.5160763391 0.05) (3.025138123 0.5159616565 0.05) (3.063252123 0.5158469739 0.05) (2.861797482 0.5388765948 0.05) (2.899969688 0.5387678695 0.05) (2.938141894 0.5386591443 0.05) (2.9763141 0.538550419 0.05) (3.014486306 0.5384416938 0.05) (3.052658512 0.5383329685 0.05) (2.850464987 0.5610419645 0.05) (2.888697794 0.5609407519 0.05) (2.926930602 0.5608395392 0.05) (2.965163409 0.5607383265 0.05) (3.003396217 0.5606371139 0.05) (3.041629024 0.5605359012 0.05) (2.838692406 0.5829048722 0.05) (2.876988169 0.5828127896 0.05) (2.915283931 0.582720707 0.05) (2.953579694 0.5826286244 0.05) (2.991875456 0.5825365418 0.05) (3.030171219 0.5824444592 0.05) (3.068466981 0.5823523766 0.05) (2.864848837 0.6043726275 0.05) (2.903209865 0.6042913534 0.05) (2.941570893 0.6042100793 0.05) (2.97993192 0.6041288052 0.05) (3.018292948 0.6040475312 0.05) (3.056653976 0.6039662571 0.05) (2.852288119 0.6256091239 0.05) (2.890716677 0.6255403968 0.05) (2.929145236 0.6254716697 0.05) (2.967573794 0.6254029425 0.05) (3.006002353 0.6253342154 0.05) (3.044430911 0.6252654882 0.05) (2.839314622 0.6465113592 0.05) (2.87781293 0.6464569761 0.05) (2.916311239 0.646402593 0.05) (2.954809547 0.6463482099 0.05) (2.993307856 0.6462938268 0.05) (3.031806164 0.6462394437 0.05) (3.070304473 0.6461850606 0.05) (2.864507468 0.6670304581 0.05) (2.903077698 0.6669922736 0.05) (2.941647928 0.6669540892 0.05) (2.980218158 0.6669159047 0.05) (3.018788388 0.6668777202 0.05) (3.057358618 0.6668395357 0.05) (2.85080941 0.6872504447 0.05) (2.889453683 0.6872303696 0.05) (2.928097957 0.6872102945 0.05) (2.96674223 0.6871902195 0.05) (3.005386504 0.6871701444 0.05) (3.044030777 0.6871500693 0.05) (2.836728143 0.70710678 0.05) (2.875448531 0.70710678 0.05) (2.91416892 0.70710678 0.05) (2.952889308 0.70710678 0.05) (2.991609697 0.70710678 0.05) (3.030330085 0.70710678 0.05) (3.069050473 0.70710678 0.05) (2.875448531 0.7619883337 -0.05) (2.91416892 0.7619883337 -0.05) (2.952889308 0.7619883337 -0.05) (2.991609697 0.7619883337 -0.05) (3.030330085 0.7619883337 -0.05) (3.069050473 0.7619883337 -0.05) (2.875448531 0.8168698873 -0.05) (2.91416892 0.8168698873 -0.05) (2.952889308 0.8168698873 -0.05) (2.991609697 0.8168698873 -0.05) (3.030330085 0.8168698873 -0.05) (3.069050473 0.8168698873 -0.05) (2.875448531 0.871751441 -0.05) (2.91416892 0.871751441 -0.05) (2.952889308 0.871751441 -0.05) (2.991609697 0.871751441 -0.05) (3.030330085 0.871751441 -0.05) (3.069050473 0.871751441 -0.05) (2.875448531 0.9266329947 -0.05) (2.91416892 0.9266329947 -0.05) (2.952889308 0.9266329947 -0.05) (2.991609697 0.9266329947 -0.05) (3.030330085 0.9266329947 -0.05) (3.069050473 0.9266329947 -0.05) (2.875448531 0.9815145483 -0.05) (2.91416892 0.9815145483 -0.05) (2.952889308 0.9815145483 -0.05) (2.991609697 0.9815145483 -0.05) (3.030330085 0.9815145483 -0.05) (3.069050473 0.9815145483 -0.05) (2.875448531 1.036396102 -0.05) (2.91416892 1.036396102 -0.05) (2.952889308 1.036396102 -0.05) (2.991609697 1.036396102 -0.05) (3.030330085 1.036396102 -0.05) (3.069050473 1.036396102 -0.05) (2.875448531 1.091277656 -0.05) (2.91416892 1.091277656 -0.05) (2.952889308 1.091277656 -0.05) (2.991609697 1.091277656 -0.05) (3.030330085 1.091277656 -0.05) (3.069050473 1.091277656 -0.05) (2.875448531 1.146159209 -0.05) (2.91416892 1.146159209 -0.05) (2.952889308 1.146159209 -0.05) (2.991609697 1.146159209 -0.05) (3.030330085 1.146159209 -0.05) (3.069050473 1.146159209 -0.05) (2.875448531 1.201040763 -0.05) (2.91416892 1.201040763 -0.05) (2.952889308 1.201040763 -0.05) (2.991609697 1.201040763 -0.05) (3.030330085 1.201040763 -0.05) (3.069050473 1.201040763 -0.05) (2.875448531 1.255922317 -0.05) (2.91416892 1.255922317 -0.05) (2.952889308 1.255922317 -0.05) (2.991609697 1.255922317 -0.05) (3.030330085 1.255922317 -0.05) (3.069050473 1.255922317 -0.05) (2.875448531 1.31080387 -0.05) (2.91416892 1.31080387 -0.05) (2.952889308 1.31080387 -0.05) (2.991609697 1.31080387 -0.05) (3.030330085 1.31080387 -0.05) (3.069050473 1.31080387 -0.05) (2.875448531 1.365685424 -0.05) (2.91416892 1.365685424 -0.05) (2.952889308 1.365685424 -0.05) (2.991609697 1.365685424 -0.05) (3.030330085 1.365685424 -0.05) (3.069050473 1.365685424 -0.05) (2.875448531 1.420566978 -0.05) (2.91416892 1.420566978 -0.05) (2.952889308 1.420566978 -0.05) (2.991609697 1.420566978 -0.05) (3.030330085 1.420566978 -0.05) (3.069050473 1.420566978 -0.05) (2.875448531 1.475448531 -0.05) (2.91416892 1.475448531 -0.05) (2.952889308 1.475448531 -0.05) (2.991609697 1.475448531 -0.05) (3.030330085 1.475448531 -0.05) (3.069050473 1.475448531 -0.05) (2.875448531 1.530330085 -0.05) (2.91416892 1.530330085 -0.05) (2.952889308 1.530330085 -0.05) (2.991609697 1.530330085 -0.05) (3.030330085 1.530330085 -0.05) (3.069050473 1.530330085 -0.05) (2.875448531 1.585211639 -0.05) (2.91416892 1.585211639 -0.05) (2.952889308 1.585211639 -0.05) (2.991609697 1.585211639 -0.05) (3.030330085 1.585211639 -0.05) (3.069050473 1.585211639 -0.05) (2.875448531 1.640093192 -0.05) (2.91416892 1.640093192 -0.05) (2.952889308 1.640093192 -0.05) (2.991609697 1.640093192 -0.05) (3.030330085 1.640093192 -0.05) (3.069050473 1.640093192 -0.05) (2.875448531 1.694974746 -0.05) (2.91416892 1.694974746 -0.05) (2.952889308 1.694974746 -0.05) (2.991609697 1.694974746 -0.05) (3.030330085 1.694974746 -0.05) (3.069050473 1.694974746 -0.05) (2.875448531 1.7498563 -0.05) (2.91416892 1.7498563 -0.05) (2.952889308 1.7498563 -0.05) (2.991609697 1.7498563 -0.05) (3.030330085 1.7498563 -0.05) (3.069050473 1.7498563 -0.05) (2.875448531 1.804737853 -0.05) (2.91416892 1.804737853 -0.05) (2.952889308 1.804737853 -0.05) (2.991609697 1.804737853 -0.05) (3.030330085 1.804737853 -0.05) (3.069050473 1.804737853 -0.05) (2.875448531 1.859619407 -0.05) (2.91416892 1.859619407 -0.05) (2.952889308 1.859619407 -0.05) (2.991609697 1.859619407 -0.05) (3.030330085 1.859619407 -0.05) (3.069050473 1.859619407 -0.05) (2.875448531 1.914500961 -0.05) (2.91416892 1.914500961 -0.05) (2.952889308 1.914500961 -0.05) (2.991609697 1.914500961 -0.05) (3.030330085 1.914500961 -0.05) (3.069050473 1.914500961 -0.05) (2.875448531 1.969382514 -0.05) (2.91416892 1.969382514 -0.05) (2.952889308 1.969382514 -0.05) (2.991609697 1.969382514 -0.05) (3.030330085 1.969382514 -0.05) (3.069050473 1.969382514 -0.05) (2.875448531 2.024264068 -0.05) (2.91416892 2.024264068 -0.05) (2.952889308 2.024264068 -0.05) (2.991609697 2.024264068 -0.05) (3.030330085 2.024264068 -0.05) (3.069050473 2.024264068 -0.05) (2.875448531 2.079145622 -0.05) (2.91416892 2.079145622 -0.05) (2.952889308 2.079145622 -0.05) (2.991609697 2.079145622 -0.05) (3.030330085 2.079145622 -0.05) (3.069050473 2.079145622 -0.05) (2.875448531 2.134027175 -0.05) (2.91416892 2.134027175 -0.05) (2.952889308 2.134027175 -0.05) (2.991609697 2.134027175 -0.05) (3.030330085 2.134027175 -0.05) (3.069050473 2.134027175 -0.05) (2.875448531 2.188908729 -0.05) (2.91416892 2.188908729 -0.05) (2.952889308 2.188908729 -0.05) (2.991609697 2.188908729 -0.05) (3.030330085 2.188908729 -0.05) (3.069050473 2.188908729 -0.05) (2.875448531 2.243790283 -0.05) (2.91416892 2.243790283 -0.05) (2.952889308 2.243790283 -0.05) (2.991609697 2.243790283 -0.05) (3.030330085 2.243790283 -0.05) (3.069050473 2.243790283 -0.05) (2.875448531 2.298671836 -0.05) (2.91416892 2.298671836 -0.05) (2.952889308 2.298671836 -0.05) (2.991609697 2.298671836 -0.05) (3.030330085 2.298671836 -0.05) (3.069050473 2.298671836 -0.05) (2.875448531 2.35355339 -0.05) (2.91416892 2.35355339 -0.05) (2.952889308 2.35355339 -0.05) (2.991609697 2.35355339 -0.05) (3.030330085 2.35355339 -0.05) (3.069050473 2.35355339 -0.05) (2.875448531 2.408434944 -0.05) (2.91416892 2.408434944 -0.05) (2.952889308 2.408434944 -0.05) (2.991609697 2.408434944 -0.05) (3.030330085 2.408434944 -0.05) (3.069050473 2.408434944 -0.05) (2.875448531 2.463316497 -0.05) (2.91416892 2.463316497 -0.05) (2.952889308 2.463316497 -0.05) (2.991609697 2.463316497 -0.05) (3.030330085 2.463316497 -0.05) (3.069050473 2.463316497 -0.05) (2.875448531 2.518198051 -0.05) (2.91416892 2.518198051 -0.05) (2.952889308 2.518198051 -0.05) (2.991609697 2.518198051 -0.05) (3.030330085 2.518198051 -0.05) (3.069050473 2.518198051 -0.05) (2.875448531 2.573079605 -0.05) (2.91416892 2.573079605 -0.05) (2.952889308 2.573079605 -0.05) (2.991609697 2.573079605 -0.05) (3.030330085 2.573079605 -0.05) (3.069050473 2.573079605 -0.05) (2.875448531 2.627961158 -0.05) (2.91416892 2.627961158 -0.05) (2.952889308 2.627961158 -0.05) (2.991609697 2.627961158 -0.05) (3.030330085 2.627961158 -0.05) (3.069050473 2.627961158 -0.05) (2.875448531 2.682842712 -0.05) (2.91416892 2.682842712 -0.05) (2.952889308 2.682842712 -0.05) (2.991609697 2.682842712 -0.05) (3.030330085 2.682842712 -0.05) (3.069050473 2.682842712 -0.05) (2.875448531 2.737724266 -0.05) (2.91416892 2.737724266 -0.05) (2.952889308 2.737724266 -0.05) (2.991609697 2.737724266 -0.05) (3.030330085 2.737724266 -0.05) (3.069050473 2.737724266 -0.05) (2.875448531 2.792605819 -0.05) (2.91416892 2.792605819 -0.05) (2.952889308 2.792605819 -0.05) (2.991609697 2.792605819 -0.05) (3.030330085 2.792605819 -0.05) (3.069050473 2.792605819 -0.05) (2.875448531 2.847487373 -0.05) (2.91416892 2.847487373 -0.05) (2.952889308 2.847487373 -0.05) (2.991609697 2.847487373 -0.05) (3.030330085 2.847487373 -0.05) (3.069050473 2.847487373 -0.05) (2.875448531 2.902368927 -0.05) (2.91416892 2.902368927 -0.05) (2.952889308 2.902368927 -0.05) (2.991609697 2.902368927 -0.05) (3.030330085 2.902368927 -0.05) (3.069050473 2.902368927 -0.05) (2.875448531 2.95725048 -0.05) (2.91416892 2.95725048 -0.05) (2.952889308 2.95725048 -0.05) (2.991609697 2.95725048 -0.05) (3.030330085 2.95725048 -0.05) (3.069050473 2.95725048 -0.05) (2.875448531 3.012132034 -0.05) (2.91416892 3.012132034 -0.05) (2.952889308 3.012132034 -0.05) (2.991609697 3.012132034 -0.05) (3.030330085 3.012132034 -0.05) (3.069050473 3.012132034 -0.05) (2.875448531 3.067013588 -0.05) (2.91416892 3.067013588 -0.05) (2.952889308 3.067013588 -0.05) (2.991609697 3.067013588 -0.05) (3.030330085 3.067013588 -0.05) (3.069050473 3.067013588 -0.05) (2.875448531 3.121895141 -0.05) (2.91416892 3.121895141 -0.05) (2.952889308 3.121895141 -0.05) (2.991609697 3.121895141 -0.05) (3.030330085 3.121895141 -0.05) (3.069050473 3.121895141 -0.05) (2.875448531 3.176776695 -0.05) (2.91416892 3.176776695 -0.05) (2.952889308 3.176776695 -0.05) (2.991609697 3.176776695 -0.05) (3.030330085 3.176776695 -0.05) (3.069050473 3.176776695 -0.05) (2.875448531 3.231658249 -0.05) (2.91416892 3.231658249 -0.05) (2.952889308 3.231658249 -0.05) (2.991609697 3.231658249 -0.05) (3.030330085 3.231658249 -0.05) (3.069050473 3.231658249 -0.05) (2.875448531 3.286539802 -0.05) (2.91416892 3.286539802 -0.05) (2.952889308 3.286539802 -0.05) (2.991609697 3.286539802 -0.05) (3.030330085 3.286539802 -0.05) (3.069050473 3.286539802 -0.05) (2.875448531 3.341421356 -0.05) (2.91416892 3.341421356 -0.05) (2.952889308 3.341421356 -0.05) (2.991609697 3.341421356 -0.05) (3.030330085 3.341421356 -0.05) (3.069050473 3.341421356 -0.05) (2.875448531 3.39630291 -0.05) (2.91416892 3.39630291 -0.05) (2.952889308 3.39630291 -0.05) (2.991609697 3.39630291 -0.05) (3.030330085 3.39630291 -0.05) (3.069050473 3.39630291 -0.05) (2.875448531 3.451184463 -0.05) (2.91416892 3.451184463 -0.05) (2.952889308 3.451184463 -0.05) (2.991609697 3.451184463 -0.05) (3.030330085 3.451184463 -0.05) (3.069050473 3.451184463 -0.05) (2.875448531 3.506066017 -0.05) (2.91416892 3.506066017 -0.05) (2.952889308 3.506066017 -0.05) (2.991609697 3.506066017 -0.05) (3.030330085 3.506066017 -0.05) (3.069050473 3.506066017 -0.05) (2.875448531 3.560947571 -0.05) (2.91416892 3.560947571 -0.05) (2.952889308 3.560947571 -0.05) (2.991609697 3.560947571 -0.05) (3.030330085 3.560947571 -0.05) (3.069050473 3.560947571 -0.05) (2.875448531 3.615829124 -0.05) (2.91416892 3.615829124 -0.05) (2.952889308 3.615829124 -0.05) (2.991609697 3.615829124 -0.05) (3.030330085 3.615829124 -0.05) (3.069050473 3.615829124 -0.05) (2.875448531 3.670710678 -0.05) (2.91416892 3.670710678 -0.05) (2.952889308 3.670710678 -0.05) (2.991609697 3.670710678 -0.05) (3.030330085 3.670710678 -0.05) (3.069050473 3.670710678 -0.05) (2.875448531 3.725592232 -0.05) (2.91416892 3.725592232 -0.05) (2.952889308 3.725592232 -0.05) (2.991609697 3.725592232 -0.05) (3.030330085 3.725592232 -0.05) (3.069050473 3.725592232 -0.05) (2.875448531 3.780473785 -0.05) (2.91416892 3.780473785 -0.05) (2.952889308 3.780473785 -0.05) (2.991609697 3.780473785 -0.05) (3.030330085 3.780473785 -0.05) (3.069050473 3.780473785 -0.05) (2.875448531 3.835355339 -0.05) (2.91416892 3.835355339 -0.05) (2.952889308 3.835355339 -0.05) (2.991609697 3.835355339 -0.05) (3.030330085 3.835355339 -0.05) (3.069050473 3.835355339 -0.05) (2.875448531 3.890236893 -0.05) (2.91416892 3.890236893 -0.05) (2.952889308 3.890236893 -0.05) (2.991609697 3.890236893 -0.05) (3.030330085 3.890236893 -0.05) (3.069050473 3.890236893 -0.05) (2.875448531 3.945118446 -0.05) (2.91416892 3.945118446 -0.05) (2.952889308 3.945118446 -0.05) (2.991609697 3.945118446 -0.05) (3.030330085 3.945118446 -0.05) (3.069050473 3.945118446 -0.05) (2.875448531 4 -0.05) (2.91416892 4 -0.05) (2.952889308 4 -0.05) (2.991609697 4 -0.05) (3.030330085 4 -0.05) (3.069050473 4 -0.05) (2.875448531 0.7619883337 0.05) (2.91416892 0.7619883337 0.05) (2.952889308 0.7619883337 0.05) (2.991609697 0.7619883337 0.05) (3.030330085 0.7619883337 0.05) (3.069050473 0.7619883337 0.05) (2.875448531 0.8168698873 0.05) (2.91416892 0.8168698873 0.05) (2.952889308 0.8168698873 0.05) (2.991609697 0.8168698873 0.05) (3.030330085 0.8168698873 0.05) (3.069050473 0.8168698873 0.05) (2.875448531 0.871751441 0.05) (2.91416892 0.871751441 0.05) (2.952889308 0.871751441 0.05) (2.991609697 0.871751441 0.05) (3.030330085 0.871751441 0.05) (3.069050473 0.871751441 0.05) (2.875448531 0.9266329947 0.05) (2.91416892 0.9266329947 0.05) (2.952889308 0.9266329947 0.05) (2.991609697 0.9266329947 0.05) (3.030330085 0.9266329947 0.05) (3.069050473 0.9266329947 0.05) (2.875448531 0.9815145483 0.05) (2.91416892 0.9815145483 0.05) (2.952889308 0.9815145483 0.05) (2.991609697 0.9815145483 0.05) (3.030330085 0.9815145483 0.05) (3.069050473 0.9815145483 0.05) (2.875448531 1.036396102 0.05) (2.91416892 1.036396102 0.05) (2.952889308 1.036396102 0.05) (2.991609697 1.036396102 0.05) (3.030330085 1.036396102 0.05) (3.069050473 1.036396102 0.05) (2.875448531 1.091277656 0.05) (2.91416892 1.091277656 0.05) (2.952889308 1.091277656 0.05) (2.991609697 1.091277656 0.05) (3.030330085 1.091277656 0.05) (3.069050473 1.091277656 0.05) (2.875448531 1.146159209 0.05) (2.91416892 1.146159209 0.05) (2.952889308 1.146159209 0.05) (2.991609697 1.146159209 0.05) (3.030330085 1.146159209 0.05) (3.069050473 1.146159209 0.05) (2.875448531 1.201040763 0.05) (2.91416892 1.201040763 0.05) (2.952889308 1.201040763 0.05) (2.991609697 1.201040763 0.05) (3.030330085 1.201040763 0.05) (3.069050473 1.201040763 0.05) (2.875448531 1.255922317 0.05) (2.91416892 1.255922317 0.05) (2.952889308 1.255922317 0.05) (2.991609697 1.255922317 0.05) (3.030330085 1.255922317 0.05) (3.069050473 1.255922317 0.05) (2.875448531 1.31080387 0.05) (2.91416892 1.31080387 0.05) (2.952889308 1.31080387 0.05) (2.991609697 1.31080387 0.05) (3.030330085 1.31080387 0.05) (3.069050473 1.31080387 0.05) (2.875448531 1.365685424 0.05) (2.91416892 1.365685424 0.05) (2.952889308 1.365685424 0.05) (2.991609697 1.365685424 0.05) (3.030330085 1.365685424 0.05) (3.069050473 1.365685424 0.05) (2.875448531 1.420566978 0.05) (2.91416892 1.420566978 0.05) (2.952889308 1.420566978 0.05) (2.991609697 1.420566978 0.05) (3.030330085 1.420566978 0.05) (3.069050473 1.420566978 0.05) (2.875448531 1.475448531 0.05) (2.91416892 1.475448531 0.05) (2.952889308 1.475448531 0.05) (2.991609697 1.475448531 0.05) (3.030330085 1.475448531 0.05) (3.069050473 1.475448531 0.05) (2.875448531 1.530330085 0.05) (2.91416892 1.530330085 0.05) (2.952889308 1.530330085 0.05) (2.991609697 1.530330085 0.05) (3.030330085 1.530330085 0.05) (3.069050473 1.530330085 0.05) (2.875448531 1.585211639 0.05) (2.91416892 1.585211639 0.05) (2.952889308 1.585211639 0.05) (2.991609697 1.585211639 0.05) (3.030330085 1.585211639 0.05) (3.069050473 1.585211639 0.05) (2.875448531 1.640093192 0.05) (2.91416892 1.640093192 0.05) (2.952889308 1.640093192 0.05) (2.991609697 1.640093192 0.05) (3.030330085 1.640093192 0.05) (3.069050473 1.640093192 0.05) (2.875448531 1.694974746 0.05) (2.91416892 1.694974746 0.05) (2.952889308 1.694974746 0.05) (2.991609697 1.694974746 0.05) (3.030330085 1.694974746 0.05) (3.069050473 1.694974746 0.05) (2.875448531 1.7498563 0.05) (2.91416892 1.7498563 0.05) (2.952889308 1.7498563 0.05) (2.991609697 1.7498563 0.05) (3.030330085 1.7498563 0.05) (3.069050473 1.7498563 0.05) (2.875448531 1.804737853 0.05) (2.91416892 1.804737853 0.05) (2.952889308 1.804737853 0.05) (2.991609697 1.804737853 0.05) (3.030330085 1.804737853 0.05) (3.069050473 1.804737853 0.05) (2.875448531 1.859619407 0.05) (2.91416892 1.859619407 0.05) (2.952889308 1.859619407 0.05) (2.991609697 1.859619407 0.05) (3.030330085 1.859619407 0.05) (3.069050473 1.859619407 0.05) (2.875448531 1.914500961 0.05) (2.91416892 1.914500961 0.05) (2.952889308 1.914500961 0.05) (2.991609697 1.914500961 0.05) (3.030330085 1.914500961 0.05) (3.069050473 1.914500961 0.05) (2.875448531 1.969382514 0.05) (2.91416892 1.969382514 0.05) (2.952889308 1.969382514 0.05) (2.991609697 1.969382514 0.05) (3.030330085 1.969382514 0.05) (3.069050473 1.969382514 0.05) (2.875448531 2.024264068 0.05) (2.91416892 2.024264068 0.05) (2.952889308 2.024264068 0.05) (2.991609697 2.024264068 0.05) (3.030330085 2.024264068 0.05) (3.069050473 2.024264068 0.05) (2.875448531 2.079145622 0.05) (2.91416892 2.079145622 0.05) (2.952889308 2.079145622 0.05) (2.991609697 2.079145622 0.05) (3.030330085 2.079145622 0.05) (3.069050473 2.079145622 0.05) (2.875448531 2.134027175 0.05) (2.91416892 2.134027175 0.05) (2.952889308 2.134027175 0.05) (2.991609697 2.134027175 0.05) (3.030330085 2.134027175 0.05) (3.069050473 2.134027175 0.05) (2.875448531 2.188908729 0.05) (2.91416892 2.188908729 0.05) (2.952889308 2.188908729 0.05) (2.991609697 2.188908729 0.05) (3.030330085 2.188908729 0.05) (3.069050473 2.188908729 0.05) (2.875448531 2.243790283 0.05) (2.91416892 2.243790283 0.05) (2.952889308 2.243790283 0.05) (2.991609697 2.243790283 0.05) (3.030330085 2.243790283 0.05) (3.069050473 2.243790283 0.05) (2.875448531 2.298671836 0.05) (2.91416892 2.298671836 0.05) (2.952889308 2.298671836 0.05) (2.991609697 2.298671836 0.05) (3.030330085 2.298671836 0.05) (3.069050473 2.298671836 0.05) (2.875448531 2.35355339 0.05) (2.91416892 2.35355339 0.05) (2.952889308 2.35355339 0.05) (2.991609697 2.35355339 0.05) (3.030330085 2.35355339 0.05) (3.069050473 2.35355339 0.05) (2.875448531 2.408434944 0.05) (2.91416892 2.408434944 0.05) (2.952889308 2.408434944 0.05) (2.991609697 2.408434944 0.05) (3.030330085 2.408434944 0.05) (3.069050473 2.408434944 0.05) (2.875448531 2.463316497 0.05) (2.91416892 2.463316497 0.05) (2.952889308 2.463316497 0.05) (2.991609697 2.463316497 0.05) (3.030330085 2.463316497 0.05) (3.069050473 2.463316497 0.05) (2.875448531 2.518198051 0.05) (2.91416892 2.518198051 0.05) (2.952889308 2.518198051 0.05) (2.991609697 2.518198051 0.05) (3.030330085 2.518198051 0.05) (3.069050473 2.518198051 0.05) (2.875448531 2.573079605 0.05) (2.91416892 2.573079605 0.05) (2.952889308 2.573079605 0.05) (2.991609697 2.573079605 0.05) (3.030330085 2.573079605 0.05) (3.069050473 2.573079605 0.05) (2.875448531 2.627961158 0.05) (2.91416892 2.627961158 0.05) (2.952889308 2.627961158 0.05) (2.991609697 2.627961158 0.05) (3.030330085 2.627961158 0.05) (3.069050473 2.627961158 0.05) (2.875448531 2.682842712 0.05) (2.91416892 2.682842712 0.05) (2.952889308 2.682842712 0.05) (2.991609697 2.682842712 0.05) (3.030330085 2.682842712 0.05) (3.069050473 2.682842712 0.05) (2.875448531 2.737724266 0.05) (2.91416892 2.737724266 0.05) (2.952889308 2.737724266 0.05) (2.991609697 2.737724266 0.05) (3.030330085 2.737724266 0.05) (3.069050473 2.737724266 0.05) (2.875448531 2.792605819 0.05) (2.91416892 2.792605819 0.05) (2.952889308 2.792605819 0.05) (2.991609697 2.792605819 0.05) (3.030330085 2.792605819 0.05) (3.069050473 2.792605819 0.05) (2.875448531 2.847487373 0.05) (2.91416892 2.847487373 0.05) (2.952889308 2.847487373 0.05) (2.991609697 2.847487373 0.05) (3.030330085 2.847487373 0.05) (3.069050473 2.847487373 0.05) (2.875448531 2.902368927 0.05) (2.91416892 2.902368927 0.05) (2.952889308 2.902368927 0.05) (2.991609697 2.902368927 0.05) (3.030330085 2.902368927 0.05) (3.069050473 2.902368927 0.05) (2.875448531 2.95725048 0.05) (2.91416892 2.95725048 0.05) (2.952889308 2.95725048 0.05) (2.991609697 2.95725048 0.05) (3.030330085 2.95725048 0.05) (3.069050473 2.95725048 0.05) (2.875448531 3.012132034 0.05) (2.91416892 3.012132034 0.05) (2.952889308 3.012132034 0.05) (2.991609697 3.012132034 0.05) (3.030330085 3.012132034 0.05) (3.069050473 3.012132034 0.05) (2.875448531 3.067013588 0.05) (2.91416892 3.067013588 0.05) (2.952889308 3.067013588 0.05) (2.991609697 3.067013588 0.05) (3.030330085 3.067013588 0.05) (3.069050473 3.067013588 0.05) (2.875448531 3.121895141 0.05) (2.91416892 3.121895141 0.05) (2.952889308 3.121895141 0.05) (2.991609697 3.121895141 0.05) (3.030330085 3.121895141 0.05) (3.069050473 3.121895141 0.05) (2.875448531 3.176776695 0.05) (2.91416892 3.176776695 0.05) (2.952889308 3.176776695 0.05) (2.991609697 3.176776695 0.05) (3.030330085 3.176776695 0.05) (3.069050473 3.176776695 0.05) (2.875448531 3.231658249 0.05) (2.91416892 3.231658249 0.05) (2.952889308 3.231658249 0.05) (2.991609697 3.231658249 0.05) (3.030330085 3.231658249 0.05) (3.069050473 3.231658249 0.05) (2.875448531 3.286539802 0.05) (2.91416892 3.286539802 0.05) (2.952889308 3.286539802 0.05) (2.991609697 3.286539802 0.05) (3.030330085 3.286539802 0.05) (3.069050473 3.286539802 0.05) (2.875448531 3.341421356 0.05) (2.91416892 3.341421356 0.05) (2.952889308 3.341421356 0.05) (2.991609697 3.341421356 0.05) (3.030330085 3.341421356 0.05) (3.069050473 3.341421356 0.05) (2.875448531 3.39630291 0.05) (2.91416892 3.39630291 0.05) (2.952889308 3.39630291 0.05) (2.991609697 3.39630291 0.05) (3.030330085 3.39630291 0.05) (3.069050473 3.39630291 0.05) (2.875448531 3.451184463 0.05) (2.91416892 3.451184463 0.05) (2.952889308 3.451184463 0.05) (2.991609697 3.451184463 0.05) (3.030330085 3.451184463 0.05) (3.069050473 3.451184463 0.05) (2.875448531 3.506066017 0.05) (2.91416892 3.506066017 0.05) (2.952889308 3.506066017 0.05) (2.991609697 3.506066017 0.05) (3.030330085 3.506066017 0.05) (3.069050473 3.506066017 0.05) (2.875448531 3.560947571 0.05) (2.91416892 3.560947571 0.05) (2.952889308 3.560947571 0.05) (2.991609697 3.560947571 0.05) (3.030330085 3.560947571 0.05) (3.069050473 3.560947571 0.05) (2.875448531 3.615829124 0.05) (2.91416892 3.615829124 0.05) (2.952889308 3.615829124 0.05) (2.991609697 3.615829124 0.05) (3.030330085 3.615829124 0.05) (3.069050473 3.615829124 0.05) (2.875448531 3.670710678 0.05) (2.91416892 3.670710678 0.05) (2.952889308 3.670710678 0.05) (2.991609697 3.670710678 0.05) (3.030330085 3.670710678 0.05) (3.069050473 3.670710678 0.05) (2.875448531 3.725592232 0.05) (2.91416892 3.725592232 0.05) (2.952889308 3.725592232 0.05) (2.991609697 3.725592232 0.05) (3.030330085 3.725592232 0.05) (3.069050473 3.725592232 0.05) (2.875448531 3.780473785 0.05) (2.91416892 3.780473785 0.05) (2.952889308 3.780473785 0.05) (2.991609697 3.780473785 0.05) (3.030330085 3.780473785 0.05) (3.069050473 3.780473785 0.05) (2.875448531 3.835355339 0.05) (2.91416892 3.835355339 0.05) (2.952889308 3.835355339 0.05) (2.991609697 3.835355339 0.05) (3.030330085 3.835355339 0.05) (3.069050473 3.835355339 0.05) (2.875448531 3.890236893 0.05) (2.91416892 3.890236893 0.05) (2.952889308 3.890236893 0.05) (2.991609697 3.890236893 0.05) (3.030330085 3.890236893 0.05) (3.069050473 3.890236893 0.05) (2.875448531 3.945118446 0.05) (2.91416892 3.945118446 0.05) (2.952889308 3.945118446 0.05) (2.991609697 3.945118446 0.05) (3.030330085 3.945118446 0.05) (3.069050473 3.945118446 0.05) (2.875448531 4 0.05) (2.91416892 4 0.05) (2.952889308 4 0.05) (2.991609697 4 0.05) (3.030330085 4 0.05) (3.069050473 4 0.05) (2.836728143 -0.70710678 -0.05) (2.836728143 -2.079145622 -0.05) (2.836728143 -2.134027175 -0.05) (2.836728143 -2.188908729 -0.05) (2.836728143 -2.243790283 -0.05) (2.836728143 -2.298671836 -0.05) (2.836728143 -2.35355339 -0.05) (2.836728143 -2.408434944 -0.05) (2.836728143 -2.463316497 -0.05) (2.836728143 -2.518198051 -0.05) (2.836728143 -2.573079605 -0.05) (2.836728143 -2.627961158 -0.05) (2.836728143 -2.682842712 -0.05) (2.836728143 -2.737724266 -0.05) (2.836728143 -2.792605819 -0.05) (2.836728143 -2.847487373 -0.05) (2.836728143 -2.902368927 -0.05) (2.836728143 -2.95725048 -0.05) (2.836728143 -3.012132034 -0.05) (2.836728143 -3.067013588 -0.05) (2.836728143 -3.121895141 -0.05) (2.836728143 -3.176776695 -0.05) (2.836728143 -3.231658249 -0.05) (2.836728143 -3.286539802 -0.05) (2.836728143 -3.341421356 -0.05) (2.836728143 -3.39630291 -0.05) (2.836728143 -3.451184463 -0.05) (2.836728143 -3.506066017 -0.05) (2.836728143 -3.560947571 -0.05) (2.836728143 -3.615829124 -0.05) (2.836728143 -3.670710678 -0.05) (2.836728143 -3.725592232 -0.05) (2.836728143 -3.780473785 -0.05) (2.836728143 -3.835355339 -0.05) (2.836728143 -3.890236893 -0.05) (2.836728143 -3.945118446 -0.05) (2.836728143 -4 -0.05) (2.875448531 -0.70710678 -0.05) (2.875448531 -0.7619883337 -0.05) (2.875448531 -0.8168698873 -0.05) (2.875448531 -0.871751441 -0.05) (2.875448531 -0.9266329947 -0.05) (2.875448531 -0.9815145483 -0.05) (2.875448531 -1.036396102 -0.05) (2.875448531 -1.091277656 -0.05) (2.875448531 -1.146159209 -0.05) (2.875448531 -1.201040763 -0.05) (2.875448531 -1.255922317 -0.05) (2.875448531 -1.31080387 -0.05) (2.875448531 -1.365685424 -0.05) (2.875448531 -1.420566978 -0.05) (2.875448531 -1.475448531 -0.05) (2.875448531 -1.530330085 -0.05) (2.875448531 -1.585211639 -0.05) (2.875448531 -1.640093192 -0.05) (2.875448531 -1.694974746 -0.05) (2.875448531 -1.7498563 -0.05) (2.875448531 -1.804737853 -0.05) (2.875448531 -1.859619407 -0.05) (2.875448531 -1.914500961 -0.05) (2.875448531 -1.969382514 -0.05) (2.875448531 -2.024264068 -0.05) (2.875448531 -2.079145622 -0.05) (2.875448531 -2.134027175 -0.05) (2.875448531 -2.188908729 -0.05) (2.875448531 -2.243790283 -0.05) (2.875448531 -2.298671836 -0.05) (2.875448531 -2.35355339 -0.05) (2.875448531 -2.408434944 -0.05) (2.875448531 -2.463316497 -0.05) (2.875448531 -2.518198051 -0.05) (2.875448531 -2.573079605 -0.05) (2.875448531 -2.627961158 -0.05) (2.875448531 -2.682842712 -0.05) (2.875448531 -2.737724266 -0.05) (2.875448531 -2.792605819 -0.05) (2.875448531 -2.847487373 -0.05) (2.875448531 -2.902368927 -0.05) (2.875448531 -2.95725048 -0.05) (2.875448531 -3.012132034 -0.05) (2.875448531 -3.067013588 -0.05) (2.875448531 -3.121895141 -0.05) (2.875448531 -3.176776695 -0.05) (2.875448531 -3.231658249 -0.05) (2.875448531 -3.286539802 -0.05) (2.875448531 -3.341421356 -0.05) (2.875448531 -3.39630291 -0.05) (2.875448531 -3.451184463 -0.05) (2.875448531 -3.506066017 -0.05) (2.875448531 -3.560947571 -0.05) (2.875448531 -3.615829124 -0.05) (2.875448531 -3.670710678 -0.05) (2.875448531 -3.725592232 -0.05) (2.875448531 -3.780473785 -0.05) (2.875448531 -3.835355339 -0.05) (2.875448531 -3.890236893 -0.05) (2.875448531 -3.945118446 -0.05) (2.875448531 -4 -0.05) (2.91416892 -0.70710678 -0.05) (2.91416892 -0.7619883337 -0.05) (2.91416892 -0.8168698873 -0.05) (2.91416892 -0.871751441 -0.05) (2.91416892 -0.9266329947 -0.05) (2.91416892 -0.9815145483 -0.05) (2.91416892 -1.036396102 -0.05) (2.91416892 -1.091277656 -0.05) (2.91416892 -1.146159209 -0.05) (2.91416892 -1.201040763 -0.05) (2.91416892 -1.255922317 -0.05) (2.91416892 -1.31080387 -0.05) (2.91416892 -1.365685424 -0.05) (2.91416892 -1.420566978 -0.05) (2.91416892 -1.475448531 -0.05) (2.91416892 -1.530330085 -0.05) (2.91416892 -1.585211639 -0.05) (2.91416892 -1.640093192 -0.05) (2.91416892 -1.694974746 -0.05) (2.91416892 -1.7498563 -0.05) (2.91416892 -1.804737853 -0.05) (2.91416892 -1.859619407 -0.05) (2.91416892 -1.914500961 -0.05) (2.91416892 -1.969382514 -0.05) (2.91416892 -2.024264068 -0.05) (2.91416892 -2.079145622 -0.05) (2.91416892 -2.134027175 -0.05) (2.91416892 -2.188908729 -0.05) (2.91416892 -2.243790283 -0.05) (2.91416892 -2.298671836 -0.05) (2.91416892 -2.35355339 -0.05) (2.91416892 -2.408434944 -0.05) (2.91416892 -2.463316497 -0.05) (2.91416892 -2.518198051 -0.05) (2.91416892 -2.573079605 -0.05) (2.91416892 -2.627961158 -0.05) (2.91416892 -2.682842712 -0.05) (2.91416892 -2.737724266 -0.05) (2.91416892 -2.792605819 -0.05) (2.91416892 -2.847487373 -0.05) (2.91416892 -2.902368927 -0.05) (2.91416892 -2.95725048 -0.05) (2.91416892 -3.012132034 -0.05) (2.91416892 -3.067013588 -0.05) (2.91416892 -3.121895141 -0.05) (2.91416892 -3.176776695 -0.05) (2.91416892 -3.231658249 -0.05) (2.91416892 -3.286539802 -0.05) (2.91416892 -3.341421356 -0.05) (2.91416892 -3.39630291 -0.05) (2.91416892 -3.451184463 -0.05) (2.91416892 -3.506066017 -0.05) (2.91416892 -3.560947571 -0.05) (2.91416892 -3.615829124 -0.05) (2.91416892 -3.670710678 -0.05) (2.91416892 -3.725592232 -0.05) (2.91416892 -3.780473785 -0.05) (2.91416892 -3.835355339 -0.05) (2.91416892 -3.890236893 -0.05) (2.91416892 -3.945118446 -0.05) (2.91416892 -4 -0.05) (2.952889308 -0.70710678 -0.05) (2.952889308 -0.7619883337 -0.05) (2.952889308 -0.8168698873 -0.05) (2.952889308 -0.871751441 -0.05) (2.952889308 -0.9266329947 -0.05) (2.952889308 -0.9815145483 -0.05) (2.952889308 -1.036396102 -0.05) (2.952889308 -1.091277656 -0.05) (2.952889308 -1.146159209 -0.05) (2.952889308 -1.201040763 -0.05) (2.952889308 -1.255922317 -0.05) (2.952889308 -1.31080387 -0.05) (2.952889308 -1.365685424 -0.05) (2.952889308 -1.420566978 -0.05) (2.952889308 -1.475448531 -0.05) (2.952889308 -1.530330085 -0.05) (2.952889308 -1.585211639 -0.05) (2.952889308 -1.640093192 -0.05) (2.952889308 -1.694974746 -0.05) (2.952889308 -1.7498563 -0.05) (2.952889308 -1.804737853 -0.05) (2.952889308 -1.859619407 -0.05) (2.952889308 -1.914500961 -0.05) (2.952889308 -1.969382514 -0.05) (2.952889308 -2.024264068 -0.05) (2.952889308 -2.079145622 -0.05) (2.952889308 -2.134027175 -0.05) (2.952889308 -2.188908729 -0.05) (2.952889308 -2.243790283 -0.05) (2.952889308 -2.298671836 -0.05) (2.952889308 -2.35355339 -0.05) (2.952889308 -2.408434944 -0.05) (2.952889308 -2.463316497 -0.05) (2.952889308 -2.518198051 -0.05) (2.952889308 -2.573079605 -0.05) (2.952889308 -2.627961158 -0.05) (2.952889308 -2.682842712 -0.05) (2.952889308 -2.737724266 -0.05) (2.952889308 -2.792605819 -0.05) (2.952889308 -2.847487373 -0.05) (2.952889308 -2.902368927 -0.05) (2.952889308 -2.95725048 -0.05) (2.952889308 -3.012132034 -0.05) (2.952889308 -3.067013588 -0.05) (2.952889308 -3.121895141 -0.05) (2.952889308 -3.176776695 -0.05) (2.952889308 -3.231658249 -0.05) (2.952889308 -3.286539802 -0.05) (2.952889308 -3.341421356 -0.05) (2.952889308 -3.39630291 -0.05) (2.952889308 -3.451184463 -0.05) (2.952889308 -3.506066017 -0.05) (2.952889308 -3.560947571 -0.05) (2.952889308 -3.615829124 -0.05) (2.952889308 -3.670710678 -0.05) (2.952889308 -3.725592232 -0.05) (2.952889308 -3.780473785 -0.05) (2.952889308 -3.835355339 -0.05) (2.952889308 -3.890236893 -0.05) (2.952889308 -3.945118446 -0.05) (2.952889308 -4 -0.05) (2.991609697 -0.70710678 -0.05) (2.991609697 -0.7619883337 -0.05) (2.991609697 -0.8168698873 -0.05) (2.991609697 -0.871751441 -0.05) (2.991609697 -0.9266329947 -0.05) (2.991609697 -0.9815145483 -0.05) (2.991609697 -1.036396102 -0.05) (2.991609697 -1.091277656 -0.05) (2.991609697 -1.146159209 -0.05) (2.991609697 -1.201040763 -0.05) (2.991609697 -1.255922317 -0.05) (2.991609697 -1.31080387 -0.05) (2.991609697 -1.365685424 -0.05) (2.991609697 -1.420566978 -0.05) (2.991609697 -1.475448531 -0.05) (2.991609697 -1.530330085 -0.05) (2.991609697 -1.585211639 -0.05) (2.991609697 -1.640093192 -0.05) (2.991609697 -1.694974746 -0.05) (2.991609697 -1.7498563 -0.05) (2.991609697 -1.804737853 -0.05) (2.991609697 -1.859619407 -0.05) (2.991609697 -1.914500961 -0.05) (2.991609697 -1.969382514 -0.05) (2.991609697 -2.024264068 -0.05) (2.991609697 -2.079145622 -0.05) (2.991609697 -2.134027175 -0.05) (2.991609697 -2.188908729 -0.05) (2.991609697 -2.243790283 -0.05) (2.991609697 -2.298671836 -0.05) (2.991609697 -2.35355339 -0.05) (2.991609697 -2.408434944 -0.05) (2.991609697 -2.463316497 -0.05) (2.991609697 -2.518198051 -0.05) (2.991609697 -2.573079605 -0.05) (2.991609697 -2.627961158 -0.05) (2.991609697 -2.682842712 -0.05) (2.991609697 -2.737724266 -0.05) (2.991609697 -2.792605819 -0.05) (2.991609697 -2.847487373 -0.05) (2.991609697 -2.902368927 -0.05) (2.991609697 -2.95725048 -0.05) (2.991609697 -3.012132034 -0.05) (2.991609697 -3.067013588 -0.05) (2.991609697 -3.121895141 -0.05) (2.991609697 -3.176776695 -0.05) (2.991609697 -3.231658249 -0.05) (2.991609697 -3.286539802 -0.05) (2.991609697 -3.341421356 -0.05) (2.991609697 -3.39630291 -0.05) (2.991609697 -3.451184463 -0.05) (2.991609697 -3.506066017 -0.05) (2.991609697 -3.560947571 -0.05) (2.991609697 -3.615829124 -0.05) (2.991609697 -3.670710678 -0.05) (2.991609697 -3.725592232 -0.05) (2.991609697 -3.780473785 -0.05) (2.991609697 -3.835355339 -0.05) (2.991609697 -3.890236893 -0.05) (2.991609697 -3.945118446 -0.05) (2.991609697 -4 -0.05) (3.030330085 -0.70710678 -0.05) (3.030330085 -0.7619883337 -0.05) (3.030330085 -0.8168698873 -0.05) (3.030330085 -0.871751441 -0.05) (3.030330085 -0.9266329947 -0.05) (3.030330085 -0.9815145483 -0.05) (3.030330085 -1.036396102 -0.05) (3.030330085 -1.091277656 -0.05) (3.030330085 -1.146159209 -0.05) (3.030330085 -1.201040763 -0.05) (3.030330085 -1.255922317 -0.05) (3.030330085 -1.31080387 -0.05) (3.030330085 -1.365685424 -0.05) (3.030330085 -1.420566978 -0.05) (3.030330085 -1.475448531 -0.05) (3.030330085 -1.530330085 -0.05) (3.030330085 -1.585211639 -0.05) (3.030330085 -1.640093192 -0.05) (3.030330085 -1.694974746 -0.05) (3.030330085 -1.7498563 -0.05) (3.030330085 -1.804737853 -0.05) (3.030330085 -1.859619407 -0.05) (3.030330085 -1.914500961 -0.05) (3.030330085 -1.969382514 -0.05) (3.030330085 -2.024264068 -0.05) (3.030330085 -2.079145622 -0.05) (3.030330085 -2.134027175 -0.05) (3.030330085 -2.188908729 -0.05) (3.030330085 -2.243790283 -0.05) (3.030330085 -2.298671836 -0.05) (3.030330085 -2.35355339 -0.05) (3.030330085 -2.408434944 -0.05) (3.030330085 -2.463316497 -0.05) (3.030330085 -2.518198051 -0.05) (3.030330085 -2.573079605 -0.05) (3.030330085 -2.627961158 -0.05) (3.030330085 -2.682842712 -0.05) (3.030330085 -2.737724266 -0.05) (3.030330085 -2.792605819 -0.05) (3.030330085 -2.847487373 -0.05) (3.030330085 -2.902368927 -0.05) (3.030330085 -2.95725048 -0.05) (3.030330085 -3.012132034 -0.05) (3.030330085 -3.067013588 -0.05) (3.030330085 -3.121895141 -0.05) (3.030330085 -3.176776695 -0.05) (3.030330085 -3.231658249 -0.05) (3.030330085 -3.286539802 -0.05) (3.030330085 -3.341421356 -0.05) (3.030330085 -3.39630291 -0.05) (3.030330085 -3.451184463 -0.05) (3.030330085 -3.506066017 -0.05) (3.030330085 -3.560947571 -0.05) (3.030330085 -3.615829124 -0.05) (3.030330085 -3.670710678 -0.05) (3.030330085 -3.725592232 -0.05) (3.030330085 -3.780473785 -0.05) (3.030330085 -3.835355339 -0.05) (3.030330085 -3.890236893 -0.05) (3.030330085 -3.945118446 -0.05) (3.030330085 -4 -0.05) (3.069050473 -0.70710678 -0.05) (3.069050473 -0.7619883337 -0.05) (3.069050473 -0.8168698873 -0.05) (3.069050473 -0.871751441 -0.05) (3.069050473 -0.9266329947 -0.05) (3.069050473 -0.9815145483 -0.05) (3.069050473 -1.036396102 -0.05) (3.069050473 -1.091277656 -0.05) (3.069050473 -1.146159209 -0.05) (3.069050473 -1.201040763 -0.05) (3.069050473 -1.255922317 -0.05) (3.069050473 -1.31080387 -0.05) (3.069050473 -1.365685424 -0.05) (3.069050473 -1.420566978 -0.05) (3.069050473 -1.475448531 -0.05) (3.069050473 -1.530330085 -0.05) (3.069050473 -1.585211639 -0.05) (3.069050473 -1.640093192 -0.05) (3.069050473 -1.694974746 -0.05) (3.069050473 -1.7498563 -0.05) (3.069050473 -1.804737853 -0.05) (3.069050473 -1.859619407 -0.05) (3.069050473 -1.914500961 -0.05) (3.069050473 -1.969382514 -0.05) (3.069050473 -2.024264068 -0.05) (3.069050473 -2.079145622 -0.05) (3.069050473 -2.134027175 -0.05) (3.069050473 -2.188908729 -0.05) (3.069050473 -2.243790283 -0.05) (3.069050473 -2.298671836 -0.05) (3.069050473 -2.35355339 -0.05) (3.069050473 -2.408434944 -0.05) (3.069050473 -2.463316497 -0.05) (3.069050473 -2.518198051 -0.05) (3.069050473 -2.573079605 -0.05) (3.069050473 -2.627961158 -0.05) (3.069050473 -2.682842712 -0.05) (3.069050473 -2.737724266 -0.05) (3.069050473 -2.792605819 -0.05) (3.069050473 -2.847487373 -0.05) (3.069050473 -2.902368927 -0.05) (3.069050473 -2.95725048 -0.05) (3.069050473 -3.012132034 -0.05) (3.069050473 -3.067013588 -0.05) (3.069050473 -3.121895141 -0.05) (3.069050473 -3.176776695 -0.05) (3.069050473 -3.231658249 -0.05) (2.836728143 -0.70710678 0.05) (2.836728143 -2.079145622 0.05) (2.836728143 -2.134027175 0.05) (2.836728143 -2.188908729 0.05) (2.836728143 -2.243790283 0.05) (2.836728143 -2.298671836 0.05) (2.836728143 -2.35355339 0.05) (2.836728143 -2.408434944 0.05) (2.836728143 -2.463316497 0.05) (2.836728143 -2.518198051 0.05) (2.836728143 -2.573079605 0.05) (2.836728143 -2.627961158 0.05) (2.836728143 -2.682842712 0.05) (2.836728143 -2.737724266 0.05) (2.836728143 -2.792605819 0.05) (2.836728143 -2.847487373 0.05) (2.836728143 -2.902368927 0.05) (2.836728143 -2.95725048 0.05) (2.836728143 -3.012132034 0.05) (2.836728143 -3.067013588 0.05) (2.836728143 -3.121895141 0.05) (2.836728143 -3.176776695 0.05) (2.836728143 -3.231658249 0.05) (2.836728143 -3.286539802 0.05) (2.836728143 -3.341421356 0.05) (2.836728143 -3.39630291 0.05) (2.836728143 -3.451184463 0.05) (2.836728143 -3.506066017 0.05) (2.836728143 -3.560947571 0.05) (2.836728143 -3.615829124 0.05) (2.836728143 -3.670710678 0.05) (2.836728143 -3.725592232 0.05) (2.836728143 -3.780473785 0.05) (2.836728143 -3.835355339 0.05) (2.836728143 -3.890236893 0.05) (2.836728143 -3.945118446 0.05) (2.836728143 -4 0.05) (2.875448531 -0.70710678 0.05) (2.875448531 -0.7619883337 0.05) (2.875448531 -0.8168698873 0.05) (2.875448531 -0.871751441 0.05) (2.875448531 -0.9266329947 0.05) (2.875448531 -0.9815145483 0.05) (2.875448531 -1.036396102 0.05) (2.875448531 -1.091277656 0.05) (2.875448531 -1.146159209 0.05) (2.875448531 -1.201040763 0.05) (2.875448531 -1.255922317 0.05) (2.875448531 -1.31080387 0.05) (2.875448531 -1.365685424 0.05) (2.875448531 -1.420566978 0.05) (2.875448531 -1.475448531 0.05) (2.875448531 -1.530330085 0.05) (2.875448531 -1.585211639 0.05) (2.875448531 -1.640093192 0.05) (2.875448531 -1.694974746 0.05) (2.875448531 -1.7498563 0.05) (2.875448531 -1.804737853 0.05) (2.875448531 -1.859619407 0.05) (2.875448531 -1.914500961 0.05) (2.875448531 -1.969382514 0.05) (2.875448531 -2.024264068 0.05) (2.875448531 -2.079145622 0.05) (2.875448531 -2.134027175 0.05) (2.875448531 -2.188908729 0.05) (2.875448531 -2.243790283 0.05) (2.875448531 -2.298671836 0.05) (2.875448531 -2.35355339 0.05) (2.875448531 -2.408434944 0.05) (2.875448531 -2.463316497 0.05) (2.875448531 -2.518198051 0.05) (2.875448531 -2.573079605 0.05) (2.875448531 -2.627961158 0.05) (2.875448531 -2.682842712 0.05) (2.875448531 -2.737724266 0.05) (2.875448531 -2.792605819 0.05) (2.875448531 -2.847487373 0.05) (2.875448531 -2.902368927 0.05) (2.875448531 -2.95725048 0.05) (2.875448531 -3.012132034 0.05) (2.875448531 -3.067013588 0.05) (2.875448531 -3.121895141 0.05) (2.875448531 -3.176776695 0.05) (2.875448531 -3.231658249 0.05) (2.875448531 -3.286539802 0.05) (2.875448531 -3.341421356 0.05) (2.875448531 -3.39630291 0.05) (2.875448531 -3.451184463 0.05) (2.875448531 -3.506066017 0.05) (2.875448531 -3.560947571 0.05) (2.875448531 -3.615829124 0.05) (2.875448531 -3.670710678 0.05) (2.875448531 -3.725592232 0.05) (2.875448531 -3.780473785 0.05) (2.875448531 -3.835355339 0.05) (2.875448531 -3.890236893 0.05) (2.875448531 -3.945118446 0.05) (2.875448531 -4 0.05) (2.91416892 -0.70710678 0.05) (2.91416892 -0.7619883337 0.05) (2.91416892 -0.8168698873 0.05) (2.91416892 -0.871751441 0.05) (2.91416892 -0.9266329947 0.05) (2.91416892 -0.9815145483 0.05) (2.91416892 -1.036396102 0.05) (2.91416892 -1.091277656 0.05) (2.91416892 -1.146159209 0.05) (2.91416892 -1.201040763 0.05) (2.91416892 -1.255922317 0.05) (2.91416892 -1.31080387 0.05) (2.91416892 -1.365685424 0.05) (2.91416892 -1.420566978 0.05) (2.91416892 -1.475448531 0.05) (2.91416892 -1.530330085 0.05) (2.91416892 -1.585211639 0.05) (2.91416892 -1.640093192 0.05) (2.91416892 -1.694974746 0.05) (2.91416892 -1.7498563 0.05) (2.91416892 -1.804737853 0.05) (2.91416892 -1.859619407 0.05) (2.91416892 -1.914500961 0.05) (2.91416892 -1.969382514 0.05) (2.91416892 -2.024264068 0.05) (2.91416892 -2.079145622 0.05) (2.91416892 -2.134027175 0.05) (2.91416892 -2.188908729 0.05) (2.91416892 -2.243790283 0.05) (2.91416892 -2.298671836 0.05) (2.91416892 -2.35355339 0.05) (2.91416892 -2.408434944 0.05) (2.91416892 -2.463316497 0.05) (2.91416892 -2.518198051 0.05) (2.91416892 -2.573079605 0.05) (2.91416892 -2.627961158 0.05) (2.91416892 -2.682842712 0.05) (2.91416892 -2.737724266 0.05) (2.91416892 -2.792605819 0.05) (2.91416892 -2.847487373 0.05) (2.91416892 -2.902368927 0.05) (2.91416892 -2.95725048 0.05) (2.91416892 -3.012132034 0.05) (2.91416892 -3.067013588 0.05) (2.91416892 -3.121895141 0.05) (2.91416892 -3.176776695 0.05) (2.91416892 -3.231658249 0.05) (2.91416892 -3.286539802 0.05) (2.91416892 -3.341421356 0.05) (2.91416892 -3.39630291 0.05) (2.91416892 -3.451184463 0.05) (2.91416892 -3.506066017 0.05) (2.91416892 -3.560947571 0.05) (2.91416892 -3.615829124 0.05) (2.91416892 -3.670710678 0.05) (2.91416892 -3.725592232 0.05) (2.91416892 -3.780473785 0.05) (2.91416892 -3.835355339 0.05) (2.91416892 -3.890236893 0.05) (2.91416892 -3.945118446 0.05) (2.91416892 -4 0.05) (2.952889308 -0.70710678 0.05) (2.952889308 -0.7619883337 0.05) (2.952889308 -0.8168698873 0.05) (2.952889308 -0.871751441 0.05) (2.952889308 -0.9266329947 0.05) (2.952889308 -0.9815145483 0.05) (2.952889308 -1.036396102 0.05) (2.952889308 -1.091277656 0.05) (2.952889308 -1.146159209 0.05) (2.952889308 -1.201040763 0.05) (2.952889308 -1.255922317 0.05) (2.952889308 -1.31080387 0.05) (2.952889308 -1.365685424 0.05) (2.952889308 -1.420566978 0.05) (2.952889308 -1.475448531 0.05) (2.952889308 -1.530330085 0.05) (2.952889308 -1.585211639 0.05) (2.952889308 -1.640093192 0.05) (2.952889308 -1.694974746 0.05) (2.952889308 -1.7498563 0.05) (2.952889308 -1.804737853 0.05) (2.952889308 -1.859619407 0.05) (2.952889308 -1.914500961 0.05) (2.952889308 -1.969382514 0.05) (2.952889308 -2.024264068 0.05) (2.952889308 -2.079145622 0.05) (2.952889308 -2.134027175 0.05) (2.952889308 -2.188908729 0.05) (2.952889308 -2.243790283 0.05) (2.952889308 -2.298671836 0.05) (2.952889308 -2.35355339 0.05) (2.952889308 -2.408434944 0.05) (2.952889308 -2.463316497 0.05) (2.952889308 -2.518198051 0.05) (2.952889308 -2.573079605 0.05) (2.952889308 -2.627961158 0.05) (2.952889308 -2.682842712 0.05) (2.952889308 -2.737724266 0.05) (2.952889308 -2.792605819 0.05) (2.952889308 -2.847487373 0.05) (2.952889308 -2.902368927 0.05) (2.952889308 -2.95725048 0.05) (2.952889308 -3.012132034 0.05) (2.952889308 -3.067013588 0.05) (2.952889308 -3.121895141 0.05) (2.952889308 -3.176776695 0.05) (2.952889308 -3.231658249 0.05) (2.952889308 -3.286539802 0.05) (2.952889308 -3.341421356 0.05) (2.952889308 -3.39630291 0.05) (2.952889308 -3.451184463 0.05) (2.952889308 -3.506066017 0.05) (2.952889308 -3.560947571 0.05) (2.952889308 -3.615829124 0.05) (2.952889308 -3.670710678 0.05) (2.952889308 -3.725592232 0.05) (2.952889308 -3.780473785 0.05) (2.952889308 -3.835355339 0.05) (2.952889308 -3.890236893 0.05) (2.952889308 -3.945118446 0.05) (2.952889308 -4 0.05) (2.991609697 -0.70710678 0.05) (2.991609697 -0.7619883337 0.05) (2.991609697 -0.8168698873 0.05) (2.991609697 -0.871751441 0.05) (2.991609697 -0.9266329947 0.05) (2.991609697 -0.9815145483 0.05) (2.991609697 -1.036396102 0.05) (2.991609697 -1.091277656 0.05) (2.991609697 -1.146159209 0.05) (2.991609697 -1.201040763 0.05) (2.991609697 -1.255922317 0.05) (2.991609697 -1.31080387 0.05) (2.991609697 -1.365685424 0.05) (2.991609697 -1.420566978 0.05) (2.991609697 -1.475448531 0.05) (2.991609697 -1.530330085 0.05) (2.991609697 -1.585211639 0.05) (2.991609697 -1.640093192 0.05) (2.991609697 -1.694974746 0.05) (2.991609697 -1.7498563 0.05) (2.991609697 -1.804737853 0.05) (2.991609697 -1.859619407 0.05) (2.991609697 -1.914500961 0.05) (2.991609697 -1.969382514 0.05) (2.991609697 -2.024264068 0.05) (2.991609697 -2.079145622 0.05) (2.991609697 -2.134027175 0.05) (2.991609697 -2.188908729 0.05) (2.991609697 -2.243790283 0.05) (2.991609697 -2.298671836 0.05) (2.991609697 -2.35355339 0.05) (2.991609697 -2.408434944 0.05) (2.991609697 -2.463316497 0.05) (2.991609697 -2.518198051 0.05) (2.991609697 -2.573079605 0.05) (2.991609697 -2.627961158 0.05) (2.991609697 -2.682842712 0.05) (2.991609697 -2.737724266 0.05) (2.991609697 -2.792605819 0.05) (2.991609697 -2.847487373 0.05) (2.991609697 -2.902368927 0.05) (2.991609697 -2.95725048 0.05) (2.991609697 -3.012132034 0.05) (2.991609697 -3.067013588 0.05) (2.991609697 -3.121895141 0.05) (2.991609697 -3.176776695 0.05) (2.991609697 -3.231658249 0.05) (2.991609697 -3.286539802 0.05) (2.991609697 -3.341421356 0.05) (2.991609697 -3.39630291 0.05) (2.991609697 -3.451184463 0.05) (2.991609697 -3.506066017 0.05) (2.991609697 -3.560947571 0.05) (2.991609697 -3.615829124 0.05) (2.991609697 -3.670710678 0.05) (2.991609697 -3.725592232 0.05) (2.991609697 -3.780473785 0.05) (2.991609697 -3.835355339 0.05) (2.991609697 -3.890236893 0.05) (2.991609697 -3.945118446 0.05) (2.991609697 -4 0.05) (3.030330085 -0.70710678 0.05) (3.030330085 -0.7619883337 0.05) (3.030330085 -0.8168698873 0.05) (3.030330085 -0.871751441 0.05) (3.030330085 -0.9266329947 0.05) (3.030330085 -0.9815145483 0.05) (3.030330085 -1.036396102 0.05) (3.030330085 -1.091277656 0.05) (3.030330085 -1.146159209 0.05) (3.030330085 -1.201040763 0.05) (3.030330085 -1.255922317 0.05) (3.030330085 -1.31080387 0.05) (3.030330085 -1.365685424 0.05) (3.030330085 -1.420566978 0.05) (3.030330085 -1.475448531 0.05) (3.030330085 -1.530330085 0.05) (3.030330085 -1.585211639 0.05) (3.030330085 -1.640093192 0.05) (3.030330085 -1.694974746 0.05) (3.030330085 -1.7498563 0.05) (3.030330085 -1.804737853 0.05) (3.030330085 -1.859619407 0.05) (3.030330085 -1.914500961 0.05) (3.030330085 -1.969382514 0.05) (3.030330085 -2.024264068 0.05) (3.030330085 -2.079145622 0.05) (3.030330085 -2.134027175 0.05) (3.030330085 -2.188908729 0.05) (3.030330085 -2.243790283 0.05) (3.030330085 -2.298671836 0.05) (3.030330085 -2.35355339 0.05) (3.030330085 -2.408434944 0.05) (3.030330085 -2.463316497 0.05) (3.030330085 -2.518198051 0.05) (3.030330085 -2.573079605 0.05) (3.030330085 -2.627961158 0.05) (3.030330085 -2.682842712 0.05) (3.030330085 -2.737724266 0.05) (3.030330085 -2.792605819 0.05) (3.030330085 -2.847487373 0.05) (3.030330085 -2.902368927 0.05) (3.030330085 -2.95725048 0.05) (3.030330085 -3.012132034 0.05) (3.030330085 -3.067013588 0.05) (3.030330085 -3.121895141 0.05) (3.030330085 -3.176776695 0.05) (3.030330085 -3.231658249 0.05) (3.030330085 -3.286539802 0.05) (3.030330085 -3.341421356 0.05) (3.030330085 -3.39630291 0.05) (3.030330085 -3.451184463 0.05) (3.030330085 -3.506066017 0.05) (3.030330085 -3.560947571 0.05) (3.030330085 -3.615829124 0.05) (3.030330085 -3.670710678 0.05) (3.030330085 -3.725592232 0.05) (3.030330085 -3.780473785 0.05) (3.030330085 -3.835355339 0.05) (3.030330085 -3.890236893 0.05) (3.030330085 -3.945118446 0.05) (3.030330085 -4 0.05) (3.069050473 -0.70710678 0.05) (3.069050473 -0.7619883337 0.05) (3.069050473 -0.8168698873 0.05) (3.069050473 -0.871751441 0.05) (3.069050473 -0.9266329947 0.05) (3.069050473 -0.9815145483 0.05) (3.069050473 -1.036396102 0.05) (3.069050473 -1.091277656 0.05) (3.069050473 -1.146159209 0.05) (3.069050473 -1.201040763 0.05) (3.069050473 -1.255922317 0.05) (3.069050473 -1.31080387 0.05) (3.069050473 -1.365685424 0.05) (3.069050473 -1.420566978 0.05) (3.069050473 -1.475448531 0.05) (3.069050473 -1.530330085 0.05) (3.069050473 -1.585211639 0.05) (3.069050473 -1.640093192 0.05) (3.069050473 -1.694974746 0.05) (3.069050473 -1.7498563 0.05) (3.069050473 -1.804737853 0.05) (3.069050473 -1.859619407 0.05) (3.069050473 -1.914500961 0.05) (3.069050473 -1.969382514 0.05) (3.069050473 -2.024264068 0.05) (3.069050473 -2.079145622 0.05) (3.069050473 -2.134027175 0.05) (3.069050473 -2.188908729 0.05) (3.069050473 -2.243790283 0.05) (3.069050473 -2.298671836 0.05) (3.069050473 -2.35355339 0.05) (3.069050473 -2.408434944 0.05) (3.069050473 -2.463316497 0.05) (3.069050473 -2.518198051 0.05) (3.069050473 -2.573079605 0.05) (3.069050473 -2.627961158 0.05) (3.069050473 -2.682842712 0.05) (3.069050473 -2.737724266 0.05) (3.069050473 -2.792605819 0.05) (3.069050473 -2.847487373 0.05) (3.069050473 -2.902368927 0.05) (3.069050473 -2.95725048 0.05) (3.069050473 -3.012132034 0.05) (3.069050473 -3.067013588 0.05) (3.069050473 -3.121895141 0.05) (3.069050473 -3.176776695 0.05) (3.069050473 -3.231658249 0.05) (2.85080941 -0.6872504447 -0.05) (2.889453683 -0.6872303696 -0.05) (2.928097957 -0.6872102945 -0.05) (2.96674223 -0.6871902195 -0.05) (3.005386504 -0.6871701444 -0.05) (3.044030777 -0.6871500693 -0.05) (2.864507468 -0.6670304581 -0.05) (2.903077698 -0.6669922736 -0.05) (2.941647928 -0.6669540892 -0.05) (2.980218158 -0.6669159047 -0.05) (3.018788388 -0.6668777202 -0.05) (3.057358618 -0.6668395357 -0.05) (2.839314622 -0.6465113592 -0.05) (2.87781293 -0.6464569761 -0.05) (2.916311239 -0.646402593 -0.05) (2.954809547 -0.6463482099 -0.05) (2.993307856 -0.6462938268 -0.05) (3.031806164 -0.6462394437 -0.05) (3.070304473 -0.6461850606 -0.05) (2.852288119 -0.6256091239 -0.05) (2.890716677 -0.6255403968 -0.05) (2.929145236 -0.6254716697 -0.05) (2.967573794 -0.6254029425 -0.05) (3.006002353 -0.6253342154 -0.05) (3.044430911 -0.6252654882 -0.05) (2.864848837 -0.6043726275 -0.05) (2.903209865 -0.6042913534 -0.05) (2.941570893 -0.6042100793 -0.05) (2.97993192 -0.6041288052 -0.05) (3.018292948 -0.6040475312 -0.05) (3.056653976 -0.6039662571 -0.05) (2.838692406 -0.5829048722 -0.05) (2.876988169 -0.5828127896 -0.05) (2.915283931 -0.582720707 -0.05) (2.953579694 -0.5826286244 -0.05) (2.991875456 -0.5825365418 -0.05) (3.030171219 -0.5824444592 -0.05) (3.068466981 -0.5823523766 -0.05) (2.850464987 -0.5610419645 -0.05) (2.888697794 -0.5609407519 -0.05) (2.926930602 -0.5608395392 -0.05) (2.965163409 -0.5607383265 -0.05) (3.003396217 -0.5606371139 -0.05) (3.041629024 -0.5605359012 -0.05) (2.861797482 -0.5388765948 -0.05) (2.899969688 -0.5387678695 -0.05) (2.938141894 -0.5386591443 -0.05) (2.9763141 -0.538550419 -0.05) (3.014486306 -0.5384416938 -0.05) (3.052658512 -0.5383329685 -0.05) (2.834568127 -0.5165350693 -0.05) (2.872682126 -0.5164203868 -0.05) (2.910796125 -0.5163057042 -0.05) (2.948910125 -0.5161910216 -0.05) (2.987024124 -0.5160763391 -0.05) (3.025138123 -0.5159616565 -0.05) (3.063252123 -0.5158469739 -0.05) (2.845053231 -0.4938043114 -0.05) (2.883111458 -0.4936851635 -0.05) (2.921169686 -0.4935660157 -0.05) (2.959227913 -0.4934468679 -0.05) (2.997286141 -0.4933277201 -0.05) (3.035344368 -0.4932085722 -0.05) (3.073402596 -0.4930894244 -0.05) (2.855073403 -0.4708051246 -0.05) (2.893078331 -0.4706829394 -0.05) (2.93108326 -0.4705607541 -0.05) (2.969088189 -0.4704385688 -0.05) (3.007093118 -0.4703163835 -0.05) (3.045098046 -0.4701941983 -0.05) (2.864621775 -0.4475497716 -0.05) (2.902575915 -0.4474259115 -0.05) (2.940530054 -0.4473020514 -0.05) (2.978484193 -0.4471781912 -0.05) (3.016438333 -0.4470543311 -0.05) (3.054392472 -0.446930471 -0.05) (2.835785909 -0.424174929 -0.05) (2.873691804 -0.4240506904 -0.05) (2.911597698 -0.4239264518 -0.05) (2.949503593 -0.4238022133 -0.05) (2.987409488 -0.4236779747 -0.05) (3.025315382 -0.4235537362 -0.05) (3.063221277 -0.4234294976 -0.05) (2.844417046 -0.4004438737 -0.05) (2.882277273 -0.4003204861 -0.05) (2.9201375 -0.4001970985 -0.05) (2.957997727 -0.4000737108 -0.05) (2.995857955 -0.3999503232 -0.05) (3.033718182 -0.3998269356 -0.05) (3.071578409 -0.399703548 -0.05) (2.85255513 -0.3764932973 -0.05) (2.890372298 -0.3763719221 -0.05) (2.928189467 -0.3762505469 -0.05) (2.966006635 -0.3761291718 -0.05) (3.003823804 -0.3760077966 -0.05) (3.041640973 -0.3758864214 -0.05) (2.860194584 -0.3523361816 -0.05) (2.897971332 -0.3522179117 -0.05) (2.93574808 -0.3520996417 -0.05) (2.973524828 -0.3519813718 -0.05) (3.011301577 -0.3518631019 -0.05) (3.049078325 -0.3517448319 -0.05) (2.867330172 -0.32798565 -0.05) (2.905069166 -0.3278715087 -0.05) (2.94280816 -0.3277573673 -0.05) (2.980547153 -0.327643226 -0.05) (3.018286147 -0.3275290847 -0.05) (3.056025141 -0.3274149433 -0.05) (2.836253073 -0.303564018 -0.05) (2.873957004 -0.3034549585 -0.05) (2.911660936 -0.303345899 -0.05) (2.949364867 -0.3032368395 -0.05) (2.987068798 -0.30312778 -0.05) (3.024772729 -0.3030187205 -0.05) (3.06247666 -0.302909661 -0.05) (2.842398955 -0.2788605817 -0.05) (2.880070539 -0.2787574864 -0.05) (2.917742124 -0.2786543912 -0.05) (2.955413708 -0.2785512959 -0.05) (2.993085292 -0.2784482007 -0.05) (3.030756877 -0.2783451055 -0.05) (3.068428461 -0.2782420102 -0.05) (2.84802461 -0.2540030475 -0.05) (2.885666586 -0.2539067275 -0.05) (2.923308562 -0.2538104076 -0.05) (2.960950538 -0.2537140877 -0.05) (2.998592513 -0.2536177677 -0.05) (3.036234489 -0.2535214478 -0.05) (3.073876465 -0.2534251279 -0.05) (2.853126185 -0.2290050862 -0.05) (2.89074131 -0.2289162806 -0.05) (2.928356436 -0.2288274751 -0.05) (2.965971561 -0.2287386695 -0.05) (3.003586686 -0.228649864 -0.05) (3.041201812 -0.2285610585 -0.05) (2.857700182 -0.2038804647 -0.05) (2.895291234 -0.2037998402 -0.05) (2.932882286 -0.2037192156 -0.05) (2.970473337 -0.2036385911 -0.05) (3.008064389 -0.2035579666 -0.05) (3.045655441 -0.2034773421 -0.05) (2.861743467 -0.1786430368 -0.05) (2.899313238 -0.178571187 -0.05) (2.936883009 -0.1784993373 -0.05) (2.974452781 -0.1784274875 -0.05) (3.012022552 -0.1783556377 -0.05) (3.049592323 -0.178283788 -0.05) (2.865253268 -0.1533067336 -0.05) (2.902804567 -0.153244179 -0.05) (2.940355865 -0.1531816243 -0.05) (2.977907164 -0.1531190697 -0.05) (3.015458463 -0.1530565151 -0.05) (3.053009761 -0.1529939605 -0.05) (2.868227181 -0.1278855539 -0.05) (2.905762827 -0.1278327412 -0.05) (2.943298474 -0.1277799284 -0.05) (2.98083412 -0.1277271157 -0.05) (3.018369766 -0.1276743029 -0.05) (3.055905413 -0.1276214901 -0.05) (2.870663166 -0.1023935548 -0.05) (2.908185992 -0.1023508567 -0.05) (2.945708817 -0.1023081585 -0.05) (2.983231642 -0.1022654603 -0.05) (3.020754468 -0.1022227622 -0.05) (3.058277293 -0.102180064 -0.05) (2.872559555 -0.07684484185 -0.05) (2.9100724 -0.07681255678 -0.05) (2.947585244 -0.07678027171 -0.05) (2.985098088 -0.07674798663 -0.05) (3.022610933 -0.07671570156 -0.05) (3.060123777 -0.07668341649 -0.05) (2.873915048 -0.05125355941 -0.05) (2.911420758 -0.05123191148 -0.05) (2.948926468 -0.05121026354 -0.05) (2.986432179 -0.05118861561 -0.05) (3.023937889 -0.05116696768 -0.05) (3.061443599 -0.05114531974 -0.05) (2.874728715 -0.02563388111 -0.05) (2.912230143 -0.02562301976 -0.05) (2.949731571 -0.02561215842 -0.05) (2.987232999 -0.02560129708 -0.05) (3.024734427 -0.02559043574 -0.05) (3.062235854 -0.02557957439 -0.05) (2.85080941 -0.6872504447 0.05) (2.889453683 -0.6872303696 0.05) (2.928097957 -0.6872102945 0.05) (2.96674223 -0.6871902195 0.05) (3.005386504 -0.6871701444 0.05) (3.044030777 -0.6871500693 0.05) (2.864507468 -0.6670304581 0.05) (2.903077698 -0.6669922736 0.05) (2.941647928 -0.6669540892 0.05) (2.980218158 -0.6669159047 0.05) (3.018788388 -0.6668777202 0.05) (3.057358618 -0.6668395357 0.05) (2.839314622 -0.6465113592 0.05) (2.87781293 -0.6464569761 0.05) (2.916311239 -0.646402593 0.05) (2.954809547 -0.6463482099 0.05) (2.993307856 -0.6462938268 0.05) (3.031806164 -0.6462394437 0.05) (3.070304473 -0.6461850606 0.05) (2.852288119 -0.6256091239 0.05) (2.890716677 -0.6255403968 0.05) (2.929145236 -0.6254716697 0.05) (2.967573794 -0.6254029425 0.05) (3.006002353 -0.6253342154 0.05) (3.044430911 -0.6252654882 0.05) (2.864848837 -0.6043726275 0.05) (2.903209865 -0.6042913534 0.05) (2.941570893 -0.6042100793 0.05) (2.97993192 -0.6041288052 0.05) (3.018292948 -0.6040475312 0.05) (3.056653976 -0.6039662571 0.05) (2.838692406 -0.5829048722 0.05) (2.876988169 -0.5828127896 0.05) (2.915283931 -0.582720707 0.05) (2.953579694 -0.5826286244 0.05) (2.991875456 -0.5825365418 0.05) (3.030171219 -0.5824444592 0.05) (3.068466981 -0.5823523766 0.05) (2.850464987 -0.5610419645 0.05) (2.888697794 -0.5609407519 0.05) (2.926930602 -0.5608395392 0.05) (2.965163409 -0.5607383265 0.05) (3.003396217 -0.5606371139 0.05) (3.041629024 -0.5605359012 0.05) (2.861797482 -0.5388765948 0.05) (2.899969688 -0.5387678695 0.05) (2.938141894 -0.5386591443 0.05) (2.9763141 -0.538550419 0.05) (3.014486306 -0.5384416938 0.05) (3.052658512 -0.5383329685 0.05) (2.834568127 -0.5165350693 0.05) (2.872682126 -0.5164203868 0.05) (2.910796125 -0.5163057042 0.05) (2.948910125 -0.5161910216 0.05) (2.987024124 -0.5160763391 0.05) (3.025138123 -0.5159616565 0.05) (3.063252123 -0.5158469739 0.05) (2.845053231 -0.4938043114 0.05) (2.883111458 -0.4936851635 0.05) (2.921169686 -0.4935660157 0.05) (2.959227913 -0.4934468679 0.05) (2.997286141 -0.4933277201 0.05) (3.035344368 -0.4932085722 0.05) (3.073402596 -0.4930894244 0.05) (2.855073403 -0.4708051246 0.05) (2.893078331 -0.4706829394 0.05) (2.93108326 -0.4705607541 0.05) (2.969088189 -0.4704385688 0.05) (3.007093118 -0.4703163835 0.05) (3.045098046 -0.4701941983 0.05) (2.864621775 -0.4475497716 0.05) (2.902575915 -0.4474259115 0.05) (2.940530054 -0.4473020514 0.05) (2.978484193 -0.4471781912 0.05) (3.016438333 -0.4470543311 0.05) (3.054392472 -0.446930471 0.05) (2.835785909 -0.424174929 0.05) (2.873691804 -0.4240506904 0.05) (2.911597698 -0.4239264518 0.05) (2.949503593 -0.4238022133 0.05) (2.987409488 -0.4236779747 0.05) (3.025315382 -0.4235537362 0.05) (3.063221277 -0.4234294976 0.05) (2.844417046 -0.4004438737 0.05) (2.882277273 -0.4003204861 0.05) (2.9201375 -0.4001970985 0.05) (2.957997727 -0.4000737108 0.05) (2.995857955 -0.3999503232 0.05) (3.033718182 -0.3998269356 0.05) (3.071578409 -0.399703548 0.05) (2.85255513 -0.3764932973 0.05) (2.890372298 -0.3763719221 0.05) (2.928189467 -0.3762505469 0.05) (2.966006635 -0.3761291718 0.05) (3.003823804 -0.3760077966 0.05) (3.041640973 -0.3758864214 0.05) (2.860194584 -0.3523361816 0.05) (2.897971332 -0.3522179117 0.05) (2.93574808 -0.3520996417 0.05) (2.973524828 -0.3519813718 0.05) (3.011301577 -0.3518631019 0.05) (3.049078325 -0.3517448319 0.05) (2.867330172 -0.32798565 0.05) (2.905069166 -0.3278715087 0.05) (2.94280816 -0.3277573673 0.05) (2.980547153 -0.327643226 0.05) (3.018286147 -0.3275290847 0.05) (3.056025141 -0.3274149433 0.05) (2.836253073 -0.303564018 0.05) (2.873957004 -0.3034549585 0.05) (2.911660936 -0.303345899 0.05) (2.949364867 -0.3032368395 0.05) (2.987068798 -0.30312778 0.05) (3.024772729 -0.3030187205 0.05) (3.06247666 -0.302909661 0.05) (2.842398955 -0.2788605817 0.05) (2.880070539 -0.2787574864 0.05) (2.917742124 -0.2786543912 0.05) (2.955413708 -0.2785512959 0.05) (2.993085292 -0.2784482007 0.05) (3.030756877 -0.2783451055 0.05) (3.068428461 -0.2782420102 0.05) (2.84802461 -0.2540030475 0.05) (2.885666586 -0.2539067275 0.05) (2.923308562 -0.2538104076 0.05) (2.960950538 -0.2537140877 0.05) (2.998592513 -0.2536177677 0.05) (3.036234489 -0.2535214478 0.05) (3.073876465 -0.2534251279 0.05) (2.853126185 -0.2290050862 0.05) (2.89074131 -0.2289162806 0.05) (2.928356436 -0.2288274751 0.05) (2.965971561 -0.2287386695 0.05) (3.003586686 -0.228649864 0.05) (3.041201812 -0.2285610585 0.05) (2.857700182 -0.2038804647 0.05) (2.895291234 -0.2037998402 0.05) (2.932882286 -0.2037192156 0.05) (2.970473337 -0.2036385911 0.05) (3.008064389 -0.2035579666 0.05) (3.045655441 -0.2034773421 0.05) (2.861743467 -0.1786430368 0.05) (2.899313238 -0.178571187 0.05) (2.936883009 -0.1784993373 0.05) (2.974452781 -0.1784274875 0.05) (3.012022552 -0.1783556377 0.05) (3.049592323 -0.178283788 0.05) (2.865253268 -0.1533067336 0.05) (2.902804567 -0.153244179 0.05) (2.940355865 -0.1531816243 0.05) (2.977907164 -0.1531190697 0.05) (3.015458463 -0.1530565151 0.05) (3.053009761 -0.1529939605 0.05) (2.868227181 -0.1278855539 0.05) (2.905762827 -0.1278327412 0.05) (2.943298474 -0.1277799284 0.05) (2.98083412 -0.1277271157 0.05) (3.018369766 -0.1276743029 0.05) (3.055905413 -0.1276214901 0.05) (2.870663166 -0.1023935548 0.05) (2.908185992 -0.1023508567 0.05) (2.945708817 -0.1023081585 0.05) (2.983231642 -0.1022654603 0.05) (3.020754468 -0.1022227622 0.05) (3.058277293 -0.102180064 0.05) (2.872559555 -0.07684484185 0.05) (2.9100724 -0.07681255678 0.05) (2.947585244 -0.07678027171 0.05) (2.985098088 -0.07674798663 0.05) (3.022610933 -0.07671570156 0.05) (3.060123777 -0.07668341649 0.05) (2.873915048 -0.05125355941 0.05) (2.911420758 -0.05123191148 0.05) (2.948926468 -0.05121026354 0.05) (2.986432179 -0.05118861561 0.05) (3.023937889 -0.05116696768 0.05) (3.061443599 -0.05114531974 0.05) (2.874728715 -0.02563388111 0.05) (2.912230143 -0.02562301976 0.05) (2.949731571 -0.02561215842 0.05) (2.987232999 -0.02560129708 0.05) (3.024734427 -0.02559043574 0.05) (3.062235854 -0.02557957439 0.05) ) // ************************************************************************* //
9f11bb2e46c75c24dc2bbd665e2723f8ad4bce02
89b997940fb85ff7f91d0c2e6db48adad3a30cd7
/bkcuser/dev/include/confFile.hpp
27c00426c0d9c3b00c90547e2fc8e6974520dd1a
[]
no_license
lanathlor/bfc
8470a306b0f7b96b57aa75d7718ca21a1848f299
20c96fddfb5549e9b4d86b5aaa6a06d86d971733
refs/heads/master
2020-04-15T05:31:49.460863
2019-06-10T09:21:51
2019-06-10T09:21:51
164,427,086
0
0
null
null
null
null
UTF-8
C++
false
false
120
hpp
#pragma once #include <nlohmann/json.hpp> namespace bkc { nlohmann::json readConfFile(const std::string &fileName); }
8d9a66a36d5fe281ba3fbd1302978b8767a50f08
5e614944037c6c97a29738bc3fc2a7efaceb8cc4
/HW6/src/Shader.h
1f36140b4e2df0a6a8d57aaff9d13ecbc7b1019e
[]
no_license
dashuibihello/CG
ef27c6930a9846ea5d61fbefafeebd8b5e092b20
7b2ea9bff2c06b4e4f463fb19239ecc7cc9e90b4
refs/heads/master
2020-05-19T17:31:49.968672
2019-05-28T04:45:13
2019-05-28T04:45:13
185,136,670
0
0
null
null
null
null
GB18030
C++
false
false
692
h
#pragma once #include <glad/glad.h>; #include <string> #include <fstream> #include <sstream> #include <iostream> #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/type_ptr.hpp> class Shader { public: // 程序ID unsigned int ID; // 构造器读取并构建着色器 Shader(const GLchar* vertexPath, const GLchar* fragmentPath); // 使用/激活程序 void use(); // uniform工具函数 void setBool(const std::string &name, bool value) const; void setInt(const std::string &name, int value) const; void setFloat(const std::string &name, float value) const; void setMat4(const std::string& name, glm::mat4 value) const; };
37b34d7bc5437e3eede66052c00dc69c0f14eca9
491e8e6206af2f1aff586add23f3076280c684c6
/caffe2/operators/map_ops.h
161834cbecbfc7ee046be50c481029e586744b20
[ "BSD-3-Clause", "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause" ]
permissive
cesare-montresor/pytorch
7f2d0789b8990869a49e97504921fe2fbb3fef5d
514898c5f07ba90630b701ee1c37e618d06e760e
refs/heads/master
2020-04-04T16:34:51.088757
2018-11-04T13:18:58
2018-11-04T13:18:58
156,083,591
2
0
NOASSERTION
2018-11-04T13:18:59
2018-11-04T13:13:02
C++
UTF-8
C++
false
false
7,908
h
#ifndef CAFFE2_OPERATORS_MAP_OPS_H_ #define CAFFE2_OPERATORS_MAP_OPS_H_ #include <algorithm> #include <iterator> #include <string> #include <typeinfo> #include <unordered_map> #include <utility> #include <vector> #include "caffe2/core/blob_serialization.h" #include "caffe2/core/context.h" #include "caffe2/core/operator.h" namespace caffe2 { template <typename T> struct TypeNameTraits { static constexpr const char* name = "unknown"; }; template <> struct TypeNameTraits<int64_t> { static constexpr const char* name = "int64_t"; }; template <> struct TypeNameTraits<int32_t> { static constexpr const char* name = "int32_t"; }; template <typename KEY_T, typename VALUE_T> struct MapTypeTraits { using MapType = std::unordered_map<KEY_T, VALUE_T>; static string MapTypeName() { return string("(std::unordered_map<") + TypeNameTraits<KEY_T>::name + ", " + TypeNameTraits<VALUE_T>::name + ">)"; } }; using MapType64To64 = MapTypeTraits<int64_t, int64_t>::MapType; using MapType64To32 = MapTypeTraits<int64_t, int32_t>::MapType; using MapType32To32 = MapTypeTraits<int32_t, int32_t>::MapType; using MapType32To64 = MapTypeTraits<int32_t, int64_t>::MapType; template <class Context> class CreateMapOp final : public Operator<Context> { public: USE_OPERATOR_CONTEXT_FUNCTIONS; CreateMapOp(const OperatorDef& operator_def, Workspace* ws) : Operator<Context>(operator_def, ws) {} ~CreateMapOp() {} bool RunOnDevice() override { TensorProto::DataType key_dtype = static_cast<TensorProto::DataType>(this->template GetSingleArgument<int>( "key_dtype", TensorProto_DataType_INT32)); return DispatchHelper<TensorTypes<int32_t, int64_t>>::call( this, DataTypeToTypeMeta(key_dtype)); } template <typename KEY_T> bool DoRunWithType() { TensorProto::DataType value_dtype = static_cast<TensorProto::DataType>(this->template GetSingleArgument<int>( "value_dtype", TensorProto_DataType_INT32)); return DispatchHelper< TensorTypes2<int32_t, int64_t, GenericTensorImplementation>, KEY_T>::call(this, DataTypeToTypeMeta(value_dtype)); } template <typename KEY_T, typename VALUE_T> bool DoRunWithType2() { // clear to make sure the map is empty this->template Output<typename MapTypeTraits<KEY_T, VALUE_T>::MapType>(MAP) ->clear(); return true; } template <typename KEY_T> bool DoRunWithOtherType2() { TensorProto::DataType value_dtype = static_cast<TensorProto::DataType>(this->template GetSingleArgument<int>( "value_dtype", TensorProto_DataType_INT32)); CAFFE_THROW( "CreateMap is not implemented on value tensor of type ", DataTypeToTypeMeta(value_dtype).name(), "Consider adding it a type in the list DispatchHelper"); } OUTPUT_TAGS(MAP); }; template <class Context> class KeyValueToMapOp final : public Operator<Context> { public: USE_OPERATOR_CONTEXT_FUNCTIONS; KeyValueToMapOp(const OperatorDef& operator_def, Workspace* ws) : Operator<Context>(operator_def, ws) {} ~KeyValueToMapOp() {} bool RunOnDevice() override { return DispatchHelper<TensorTypes<int32_t, int64_t>>::call( this, Input(KEYS)); } template <typename KEY_T> bool DoRunWithType() { return DispatchHelper< TensorTypes2<int32_t, int64_t, GenericTensorImplementation>, KEY_T>::call(this, Input(VALUES)); } template <typename KEY_T, typename VALUE_T> bool DoRunWithType2() { using MapType = typename MapTypeTraits<KEY_T, VALUE_T>::MapType; const auto& key_input = Input(KEYS); const auto& value_input = Input(VALUES); CAFFE_ENFORCE_EQ(key_input.numel(), value_input.numel()); auto* key_data = key_input.template data<KEY_T>(); auto* value_data = value_input.template data<VALUE_T>(); auto* map_data = this->template Output<MapType>(MAP); for (int i = 0; i < key_input.numel(); ++i) { map_data->emplace(key_data[i], value_data[i]); } return true; } template <typename KEY_T> bool DoRunWithOtherType2() { CAFFE_THROW( "KeyValueToMap is not implemented on value tensor of type ", Input(VALUES).dtype().name(), "Consider adding it a type in the list DispatchHelper"); } INPUT_TAGS(KEYS, VALUES); OUTPUT_TAGS(MAP); }; template <class Context> class MapToKeyValueOp final : public Operator<Context> { public: USE_OPERATOR_CONTEXT_FUNCTIONS; MapToKeyValueOp(const OperatorDef& operator_def, Workspace* ws) : Operator<Context>(operator_def, ws) {} ~MapToKeyValueOp() {} bool RunOnDevice() override { return DispatchHelper<TensorTypes< MapType64To64, MapType64To32, MapType32To32, MapType32To64>>::call(this, OperatorBase::InputBlob(MAP)); } template <typename MAP_T> bool DoRunWithType() { using key_type = typename MAP_T::key_type; using mapped_type = typename MAP_T::mapped_type; auto& map_data = this->template Input<MAP_T>(MAP); auto* key_output = Output(KEYS); auto* value_output = Output(VALUES); key_output->Resize(map_data.size()); value_output->Resize(map_data.size()); auto* key_data = key_output->template mutable_data<key_type>(); auto* value_data = value_output->template mutable_data<mapped_type>(); for (const auto& it : map_data) { *key_data = it.first; *value_data = it.second; key_data++; value_data++; } return true; } INPUT_TAGS(MAP); OUTPUT_TAGS(KEYS, VALUES); }; template <typename KEY_T, typename VALUE_T> class MapSerializer : public BlobSerializerBase { public: using MapType = typename MapTypeTraits<KEY_T, VALUE_T>::MapType; void Serialize( const void* pointer, TypeMeta typeMeta, const string& name, BlobSerializerBase::SerializationAcceptor acceptor) override { CAFFE_ENFORCE(typeMeta.Match<MapType>()); const MapType& map_data = *static_cast<const MapType*>(pointer); int64_t sz = map_data.size(); Tensor key_tensor(CPU); key_tensor.Resize(sz); Tensor value_tensor(CPU); value_tensor.Resize(sz); auto* key_data = key_tensor.mutable_data<KEY_T>(); auto* value_data = value_tensor.mutable_data<VALUE_T>(); for (const auto& it : map_data) { *key_data = it.first; *value_data = it.second; key_data++; value_data++; } TensorProtos tensor_protos; TensorSerializer ser; ser.Serialize( key_tensor, name, tensor_protos.add_protos(), 0, key_tensor.numel()); ser.Serialize( value_tensor, name, tensor_protos.add_protos(), 0, value_tensor.numel()); BlobProto blob_proto; blob_proto.set_name(name); blob_proto.set_type(MapTypeTraits<KEY_T, VALUE_T>::MapTypeName()); blob_proto.set_content(SerializeAsString_EnforceCheck(tensor_protos)); acceptor(name, SerializeBlobProtoAsString_EnforceCheck(blob_proto)); } }; template <typename KEY_T, typename VALUE_T> class MapDeserializer : public BlobDeserializerBase { public: using MapType = typename MapTypeTraits<KEY_T, VALUE_T>::MapType; void Deserialize(const BlobProto& proto, Blob* blob) override { TensorProtos tensor_protos; CAFFE_ENFORCE( tensor_protos.ParseFromString(proto.content()), "Fail to parse TensorProtos"); TensorDeserializer deser; Tensor key_tensor(CPU), value_tensor(CPU); deser.Deserialize(tensor_protos.protos(0), &key_tensor); deser.Deserialize(tensor_protos.protos(1), &value_tensor); auto* key_data = key_tensor.data<KEY_T>(); auto* value_data = value_tensor.data<VALUE_T>(); auto* map_ptr = blob->template GetMutable<MapType>(); for (int i = 0; i < key_tensor.numel(); ++i) { map_ptr->emplace(key_data[i], value_data[i]); } } }; } // namespace caffe2 #endif // CAFFE2_OPERATORS_MAP_OPS_H_
230f53c8134f9a0ef6feb94ae356d51ae7358c39
3ddf249ab96612bf9f895eba8f093aa8d54d42b6
/4.STRUCT,UNION AND ENUMS/enum.cpp
efd6a6b4ef33a94fc59bd99627dea59ce58776dc
[]
no_license
Shashankcode99/Important-Topics-of-CPP
cd712b6374484deb6fc578ac670d91350f85904b
7aec2b92b7a740d570f43d960831e2a8c3ea26d1
refs/heads/master
2023-07-15T23:06:58.813082
2021-09-01T18:12:22
2021-09-01T18:12:22
397,718,439
0
1
null
null
null
null
UTF-8
C++
false
false
635
cpp
/*ENUMS are basically reading values as integers */ #include<iostream> using namespace std; int main() { enum MEAL { breakfast, lunch, dinner }; //printing the actual value read by the system of the variables used inside enum, cout<<"Value of breakfast :"<<breakfast<<endl; //0 cout<<"Value of lunch :"<<lunch<<endl; //1 cout<<"Value of dinner :"<<dinner<<endl; //2 // checking the output after storing it in another object; MEAL m1=lunch; cout<<m1<<endl; //1 // checking condition to be true or false cout<<(m1==2); //false return 0; }
a782fc85e9edfb53285a5d609578f4fa9f2628a6
313e0299c463bda5763c7940b7293ca78299e3f0
/DataStructures/DataStructures/Vector.hpp
2dbed10edd60ccd0c432bf92e8a780c4385e5f75
[]
no_license
danilotuzita/programacao-cientifica
84badfa043a39a721c1cb8edfce3719c28098305
9e3a2e1d80667aefd3d57379917982537d29984a
refs/heads/master
2022-02-21T23:25:20.563110
2019-09-24T05:19:06
2019-09-24T05:19:06
191,460,806
0
0
null
null
null
null
UTF-8
C++
false
false
9,019
hpp
#pragma once #include <stdexcept> #include <string> #include <iostream> #include <cstdlib> template <class T> class Vector { private: int _size; // points to the index of the last item included int maxSize; // stores the size alocated for the list T* list; // stores the pointer to the start of the list // INTERNAL FUNCTIONS void _reserve(int newSize); // reserves a new list (may be more or less than the old maxSize) void realloc_if_needed(); // reserves more memory if the user needs it // SORT HELPER FUNCTION void _sort(bool ascending); static int q_number_sort_asc(const void* a1, const void* a2); // function that is passed to the quicksort ascending inline static int q_number_sort_dsc(const void* a1, const void* a2) { return -q_number_sort_asc(a1, a2); }; // function that is passed to the quicksort descending public: // CONSTRUCTOR/DESTRUCTOR Vector(int max=10); // creates a vector with max items allocated (not assigned) Vector(int max, T def); // creates a vector with a default value Vector(Vector<T> &other); // creates a vector coping another inline ~Vector() { delete[] list; }; // deletes list from memory // MEMORY UTILS void reserve(int newSize); // reserves MORE memory for the list void resize(int newSize, T value); // resizes the vector and fills the new memory spaces with 'value' void resize(int newSize); // resizes the vector and fills the new memory spaces with an value-initialized void shrink_to_fit(); // resizes the capacity of the vetor to fit its size void clear(); // pops back all item // UTIL inline int size() const { return _size + 1; }; // gets the real size of the vector inline int capacity() const { return maxSize; }; // returns the capacity of the vector (current maxSize) inline bool is_empty() { return (size() == 0); }; // check if the vector is empty inline bool is_full() { return (_size == maxSize - 1); }; // checks if the vector is full // BASIC FUNCTIONS // definition functions void push_back(T value); // pushes an item at the end of the vector void set_at(int index, T value); // sets a value in a specific index; NOTE: calls LHS operator[] T pop_back(); // pops the last value and returns it // SORTING void sort(bool ascending=true); // sorts the vector with the default sorting function (works only for int, float, double, char) void sort(int(*compar)(const void *, const void *)); // sorts the vector with a specific sort comparing function (should mainly be used if you can't use the default sort function) // access functions T at(int index) const; // returns the item at index void copy_from(const Vector<T> &other); // copies all contents from an existing vector inline T end() { return at(_size); }; // returns the last item inline T begin() { return at(0); }; // returns the first item // operators inline void operator<<(T value) { push_back(value); }; // same as push_back void operator=(const Vector<T> &other) { copy_from(other); }; // same as copy_from inline T operator[](const int index) const { return at(index); }; // right-hand side operator[] (RHS) T& operator[](const int index); // left-hand side operator[] (LHS) // debug functions void print(); // prints the vector with bracets void simple_print(); // prints the vector without bracets void print_size(); // prints the vector size and capacitys }; template <class T> Vector<T>::Vector(int max) { if (max < 1) // cannot allocate less than 1 items throw std::bad_alloc(); _size = -1; // setting the current size of the list maxSize = max; // setting the max size of the list list = new T[maxSize]; // allocating list } template<class T> inline Vector<T>::Vector(int max, T def) : Vector(1) { resize(max, def); } // creates a vector with one item and resizes it putting a default value def template<class T> inline Vector<T>::Vector(Vector<T> &other) : Vector(1) { copy_from(other); } // creates a vector with one item and copies the content of the other vector // === MEMORY UTIL === // template<class T> void Vector<T>::_reserve(int newSize) // Reallocates the list size (Internal-use) { if (newSize < 1) // making sure the vector has at least capacity of 1 throw std::bad_array_new_length(); T* newList = new T[newSize]; // creating a new list that fits the new size for (int i = 0; i < newSize && i < size(); i++) // copying each item from the old list to the new list newList[i] = list[i]; delete[] list; // deleting the old list from memory list = newList; // setting the new list as the current list maxSize = newSize; // saving the new size } template<class T> void Vector<T>::reserve(int newSize) // Reallocates the list size (User-use) { if (newSize > maxSize) // checking if the user wants more space _reserve(newSize); // reserves more memory } template<class T> void Vector<T>::resize(int newSize, T value) { _reserve(newSize); // resizing the vector to the new size for (int i = size(); i < newSize; i++) // populating the new push_back(value); _size = newSize - 1; // making sure the size of the list is newSize } template<class T> void Vector<T>::resize(int newSize) { _reserve(newSize); // resizing the vector to the new size if (_size >= maxSize) _size = maxSize - 1; // making sure the _size is pointing to the last item } template<class T> inline void Vector<T>::realloc_if_needed() { if (_size > maxSize - 1) // if user needs more space _reserve(maxSize * 2 + (maxSize == 1)); // allocates more memory // NOTE: (maxSize == 1) fixes a bad allocation if maxSize = 1 } template<class T> inline void Vector<T>::_sort(bool ascending) { if (ascending) std::qsort(list, size(), sizeof(T), q_number_sort_asc); else std::qsort(list, size(), sizeof(T), q_number_sort_dsc); } template<class T> int Vector<T>::q_number_sort_asc(const void * a1, const void * a2) { if (*(T*)a1 < *(T*)a2) return -1; if (*(T*)a1 > *(T*)a2) return 1; return 0; } template <class T> void Vector<T>::shrink_to_fit() { if (size() < 1) throw std::bad_array_new_length(); _reserve(size()); } template<class T> inline void Vector<T>::clear() { while (!is_empty()) pop_back(); } // === BASIC FUNCTIONS === // template<class T> void Vector<T>::push_back(T value) { _size++; realloc_if_needed(); // check if the vector needs more memory list[_size] = value; // sets the item on the vector } template<class T> void Vector<T>::set_at(int index, T value) { (*this)[index] = value; } // calling LHS operator[] template<class T> T Vector<T>::pop_back() { if (is_empty()) // if the vector is empty throw std::out_of_range("Vector is empty"); T value = at(_size); // saves the last item _size--; // reduce list size return value; } template<class T> void Vector<T>::sort(int(*compar)(const void *, const void *)) { std::qsort(list, size(), sizeof(T), compar); } template<> inline void Vector<int>::sort(bool ascending) { _sort(ascending); } // if T is int calls the default sorting function template<> inline void Vector<float>::sort(bool ascending) { _sort(ascending); } // if T is float calls the default sorting function template<> inline void Vector<double>::sort(bool ascending) { _sort(ascending); } // if T is double calls the default sorting function template<> inline void Vector<char>::sort(bool ascending) { _sort(ascending); } // if T is char calls the default sorting function template<class T> T Vector<T>::at(int index) const { if (index > _size || index < 0) throw std::out_of_range("Item index [" + std::to_string(index) + "] does not exist"); return list[index]; } template<class T> inline void Vector<T>::copy_from(const Vector<T> &other) { _reserve(other.capacity()); // reserves the same capacity of the other vector _size = other.size() - 1; // sets the size of the vector to the same as the other vector (it's subtracted one because the size() function returns _size + 1) for (int i = 0; i < _size + 1; i++) set_at(i, other[i]); } template<class T> void Vector<T>::print() { std::cout << "[ "; for (int i = 0; i < maxSize; i++) { if (i < size()) std::cout << at(i) << " "; else std::cout << "# "; } std::cout << "]\n"; } template<class T> void Vector<T>::simple_print() { for (int i = 0; i < maxSize; i++) { if (i < size()) std::cout << at(i) << " "; else std::cout << "# "; } std::cout << "\n"; } template<class T> inline void Vector<T>::print_size() { std::cout << "(" << size() << "/" << capacity() << ")\n"; } // OPERATORS // left-hand side operator[] template<class T> T &Vector<T>::operator[](const int index) { if (index > size() - 1 || index < 0) throw std::out_of_range("Item index [" + std::to_string(index) + "] does not exist"); return list[index]; }
cc94781f9a7e099a89971713419131e27e60871d
3505220b09cd6df65fbf608be1a853742e029b48
/DistributedTrees/MatrixBPC.h
76cb7a2ebbbd7b05b0372a72523d921ce55dbeeb
[]
no_license
gjsanchez26/proyectoDiseno18
846a494e5d1aaf950e6d1a05122bc8047463b47a
df5462a352ab7690df96a5b80b8997a8bf880e26
refs/heads/master
2018-10-01T07:57:12.853937
2018-06-17T17:15:22
2018-06-17T17:15:22
120,678,726
0
0
null
2018-04-23T20:47:07
2018-02-07T22:17:05
C++
UTF-8
C++
false
false
2,836
h
/* * Copyright (C) 2018 Sygram * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* * File: MatrixBPC.h * Author: Sygram * * Created on May 5, 2018, 4:08 PM */ #ifndef MATRIXBPC_H #define MATRIXBPC_H #include "Matrix.h" #include "FeaturesMat.h" #include <stdlib.h> #include <omp.h> #include "CellBPC.h" #include <boost/serialization/split_member.hpp> namespace rdf { namespace bpc { //TODO - Work on better structure/interface for this class template <typename T> class Matrix: public rdf::Matrix<T> { public: Matrix(); Matrix(const FeaturesMat &); Matrix(const Matrix& orig); virtual ~Matrix(); void AddFeaturesMat(const FeaturesMat &mat); void AllocateCells(); // void train(); void Reduce(Matrix &other); void Average(int average); void Print(); void EvaluatePointInMatrix(int point); float CalculateFeatureResponse(int, int, int); bool EvaluateFeatureResponseForThreshold(float, int); T operator ()(int i, int j){ return cells_[i * this->rows_ + j]; } std::pair<int,int> FindBestPair(){ return std::make_pair(2,3); } /* Data members */ FeaturesMat featuresMatrix_; private: int rows_; int cols_; T* cells_; friend class boost::serialization::access; template<class Archive> void save(Archive & ar, const unsigned int version) const { ar & featuresMatrix_; ar & rows_; ar & cols_; for (size_t i = 0; i < rows_; i++) { for (size_t j = 0; j < cols_; j++) { ar & cells_[i * rows_ + j]; } } } template<class Archive> void load(Archive & ar, const unsigned int version) { ar & featuresMatrix_; ar & rows_; ar & cols_; AllocateCells(); for (size_t i = 0; i < rows_; i++) { for (size_t j = 0; j < cols_; j++) { ar & cells_[i * rows_ + j]; } } } BOOST_SERIALIZATION_SPLIT_MEMBER() }; } /* bpc */ } /* rdf */ #include "MatrixBPC.tpp" #endif /* MATRIXBPC_H */
fa12a12ac3cdba64dc4a92288b7a62c4bdb9a131
9f48417210f2e3a3312e041d8ca4817125317bb0
/MFCCalculator/bit_function.h
a59a85ba6d8e6f6702a00d7871abf09660356d77
[]
no_license
letuthptnguyendu/WindowsCalculator
b95cfcb8fa7ede1d806aec344f0215408bfcbacc
88bd4f3f0d33e48be7c506ded149a65d180db912
refs/heads/master
2021-04-15T07:52:57.984971
2018-03-28T19:45:06
2018-03-28T19:45:06
126,725,116
0
0
null
null
null
null
UTF-8
C++
false
false
365
h
#pragma once #include "define_const.h" using namespace std; unsigned int rotateBit(unsigned int &x, unsigned int moves); void setBit1At(unsigned int &x, int i);//set bit 1 at position i void toggleBit(unsigned int &x, int i);//toggle bit at position i int getBitAt(unsigned int x, int i); int charToNumber(char x);//get corresponding number of a character
30342f84df9bf2859564e9efc78d640ffe291fc8
ceec4b43ae576fc911000aaff4d045fcd50c1864
/prog/.svn/text-base/jack_subBSwave.cpp.svn-base
3b154d49baf183313cfe8ccb2de32e25669b73e9
[]
no_license
MasanoriYamada/analistic_functions
33a6ad29359892354b9ebb43ce323f70b8da7598
5a25771a4b97799eba1820058c0aad00c062bced
refs/heads/master
2016-09-09T19:55:28.512439
2013-11-26T07:14:28
2013-11-26T07:14:28
31,621,249
0
0
null
null
null
null
UTF-8
C++
false
false
8,522
#include "../include/analys.h" static const int datasize=XnodeSites*YnodeSites*ZnodeSites; static const int switch1=0; //0:bainary read 1:text read #define data(id,j) data[Confsize*id+j] #define I std::complex<double>(0.0,1.0) using namespace std; typedef std::complex<double> COMPLEX; int call_file(char[],COMPLEX[]); void call_data(int,COMPLEX[]); int out_file(int,char[],COMPLEX[]); void out_data(int,COMPLEX[]); void jack_avesub_calc(int,COMPLEX[],COMPLEX[]); static void endian_convert(double* buf,int len); int main(int argc , char** argv){ //make out put dir dir_path=argv[1]; cout <<"Directory path ::"<<dir_path<<endl; in_dir_path = dir_path; out_dir_path = dir_path; root_mkdir(dir_path.c_str()); out_dir_path=out_dir_path + "/Projwave"; root_mkdir(out_dir_path.c_str()); out_dir_path = out_dir_path + "/binProjwave"; root_mkdir(out_dir_path.c_str()); out_dir_path = out_dir_path + "/xyz"; root_mkdir(out_dir_path.c_str()); for (int it=T_in; it < (T_fi +1); it++) { cout << "time"<<it<<endl; COMPLEX *data= new COMPLEX[datasize*Confsize]; COMPLEX *jack_ave_sub_sub= new COMPLEX[datasize*binnumber]; call_data(it,&(data[0])); for (int id=0; id < datasize; id++) { COMPLEX jack_ave_sub[binnumber]; jack_avesub_calc(id,&(data[0]),&(jack_ave_sub[0])); for (int b=0; b<binnumber; b++) { jack_ave_sub_sub[id+datasize*(b)]=jack_ave_sub[b]; }} out_data(it,&(jack_ave_sub_sub[0])); } cout << "finish"<<endl; return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*******************************************************************************************************************************************/ //call_fileを利用して、複数のファイルから呼び出したデータを配列としてまとめる (読みだしたout用の配列(double) この中のfanameをいじると入力ファイルを変えられる。 // /******************************************************************************************************************************************/ void call_data(int it,COMPLEX data[Confsize*datasize]){ for (int j=0; j<Confsize; j++) { char fname[200]={0}; COMPLEX local[datasize]={0}; sprintf(fname,"%s/impBSwave/aveTshift/OmgOmgwave_PH1.+%03d.%s-%06d",in_dir_path.c_str(),it,base,j); cout << fname<<"reading now"<<endl; call_file(&(fname[0]),&(local[0])); for (int id=0; id < datasize; id++) { data(id,j)=local[id]; } } } /*******************************************************************************************************/ //ファイルからデータを呼び出す no (読み込むファイルパス,読みだしたout用の配列(double) // /******************************************************************************************************/ int call_file(char fname[300],COMPLEX data[datasize]){ //string ss; int tmpx[datasize]; int tmpy[datasize]; int tmpz[datasize]; if (switch1==0) { fstream infile; infile.open(fname,ios::in|ios::binary); if (!infile.is_open()) { cout << "ERROR file can't open (no exist) ::"<<fname<<endl; exit(1); return EXIT_FAILURE; } if (infile.fail()){ cout << "ERROR file size is 0 (can open) ::"<<fname<<endl; exit(1); return EXIT_FAILURE; } int id=0; while(!infile.eof()){ infile.read( ( char * ) &data[id], sizeof( COMPLEX ) ); id=id+1; //cout << id<<endl; } static int tmp=0; if (tmp==0) { cout <<"reading data size is ;;"<<id<<endl; tmp=tmp+1; } //endian_convert((double*)data,datasize*2); for (int point=0; point<id; point++) { //cout << data[point]<<endl; }} //----------------------------------------------------------------------------------------------------------------------------------------------------------- if (switch1==1) { std::ifstream ifs( fname , ios::in ); /* テキストモードで */ if(! ifs ) { cout << fname<<"ファイルが開きません"<<endl; return 1; } // getline( ifs,ss ); int tmpx[datasize]; int tmpy[datasize]; int tmpz[datasize]; for(int id=0; id<datasize; ++id) { ifs>>std::setw(3)>>tmpx[id]>>std::setw(3)>>tmpy[id]>>std::setw(3)>>tmpz[id]>>std::setw(15)>> data[id].real()>>std::setw(15)>>data[id].imag(); // cout<<std::setw(3)<<tmpx[id]<<std::setw(3)<<tmpy[id]<<std::setw(3)<<tmpz[id]<<std::setw(15)<< data[id].real()<<std::setw(15)<<data[id].imag()<<endl; }} return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*******************************************************************************************************************************************/ //call_fileを利用して、複数のファイルから呼び出したデータを配列としてまとめる (読みだしたout用の配列(double) この中のfanameをいじると入力ファイルを変えられる。 // /******************************************************************************************************************************************/ void out_data(int it,COMPLEX jack_ave_sub_sub[datasize*binnumber]){ for (int b=0; b<binnumber; b++) { char fname[200]={0}; sprintf(fname,"%s/binBS.%s.%06d-%06d.it%03d",out_dir_path.c_str(),base,binnumber,b,it); out_file(b,fname,&(jack_ave_sub_sub[0])); } } /*******************************************************************************************************/ //結果を書き出す no (書きだすファイルパス,平均(データの大きさ),誤差(データの大きさ) // /******************************************************************************************************/ int out_file(int b, char fname[200],COMPLEX jack_ave_sub_sub[binnumber*datasize]){ COMPLEX outdata[datasize]; if (switch1==0) { ofstream ofs_xyz; ofs_xyz.open(fname,ios::out|ios::binary|ios::trunc); if (!ofs_xyz.is_open()) { cout << "ERROR output file can't open (no exist)"<<endl; exit(1); return EXIT_FAILURE; } for (int z=0; z<ZnodeSites; z++) { for (int y=0; y<YnodeSites; y++) { for (int x=0; x<XnodeSites; x++) { int id=(x) +XnodeSites*((y) + YnodeSites*((z))); outdata[id]=jack_ave_sub_sub[id+datasize*(b)]; ofs_xyz.write((const char*) &(outdata[id]),sizeof( COMPLEX )); }}} } if (switch1==1) { std::ofstream ofs( &(fname[0]),std::ios::out | std::ios::trunc); for (int z=0; z<ZnodeSites; z++) { for (int y=0; y<YnodeSites; y++) { for (int x=0; x<XnodeSites; x++) { int id=(x) +XnodeSites*((y) + YnodeSites*((z))); outdata[id]=jack_ave_sub_sub[id+datasize*(b)]; ofs<<std::setw(3)<<x<<std::setw(3)<<y<<std::setw(3)<<z<<std::setw(21)<<setprecision(15)<< outdata[id].real()<<std::setw(21)<<setprecision(15)<<outdata[id].imag()<<endl; //cout<<std::setw(3)<<x<<std::setw(3)<<y<<std::setw(3)<<z<<std::setw(21) <<setprecision(15)<< outdata[id].real()<<std::setw(21) <<setprecision(15)<<outdata[id].imag()<<endl; }}}} return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*******************************************************************************************************/ //jackナイフのためにconf[j]を取り除き平均をとったomega_prop[j]をだす no(入力のデータ,出力のデータ) /*******************************************************************************************************/ void jack_avesub_calc(int id,COMPLEX data[datasize*Confsize],COMPLEX jack_ave_sub[binnumber]){ COMPLEX full=0.0; for (int j=0; j<Confsize; j++) { full=full+data(id,j); } for (int b=0; b<binnumber; b++) { COMPLEX subfull[Confsize]; COMPLEX localfull=0; for (int j=b*binsize; j<(b+1)*binsize; j++) { localfull=localfull+data(id,j); } subfull[b]=full-localfull; jack_ave_sub[b]=subfull[b]/((double)Confsize-(double)binsize); } } /*******************************************************************/ //endian convert /*******************************************************************/ static void endian_convert(double* buf,int len) { for(int i=0; i<len; i++){ char tmp[8]; ((double*)tmp)[0] = *buf; for(int j=0; j<8; j++){ ((char*)buf)[j] = ((char*)tmp)[7-j]; } buf++; } }
fa2cbd3f2be4b27ed151742a8532d12e4445fc08
e8717f54486d13ea334945386714b825ab125de4
/CF/1248B.cpp
bb3af7076d646e5c9fb7bb7894d1cc7016a7cf06
[]
no_license
prajwal1721/Competitve-Programming
a6a6de9c8a6c8e9fd3bf382166a53aa49d562551
39e5049e16044830396d6ff504f739e71dbec3bb
refs/heads/master
2023-02-10T05:26:24.143539
2020-12-21T03:45:59
2020-12-21T03:45:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
554
cpp
#include<iostream> #include <algorithm> #include<cmath> using namespace std; int main() { long long int a[1000000]; long long int n; cin>>n; int i; for(i=0;i<n;i++) cin>>a[i]; sort(a,a+n); long long s1=0,s2=0; for(i=0;i<floor(n/2);i++) { // cout<<a[i]<<"c1::"; s1+=a[i]; } // cout<<endl; for(;i<n;i++) { // cout<<a[i]<<"c2::"; s2+=a[i]; } cout<<s1*s1+s2*s2<<"\n"; }
14a9c6fb509d83cf7a28f36203dc065b49c39624
35b929181f587c81ad507c24103d172d004ee911
/SrcLib/patch/fwMDSemanticPatch/src/fwMDSemanticPatch/V1/V2/fwData/autoload.cpp
81d54e52d9a6b0ee68d672962416f7001241008e
[]
no_license
hamalawy/fw4spl
7853aa46ed5f96660123e88d2ba8b0465bd3f58d
680376662bf3fad54b9616d1e9d4c043d9d990df
refs/heads/master
2021-01-10T11:33:53.571504
2015-07-23T08:01:59
2015-07-23T08:01:59
50,699,438
2
1
null
null
null
null
UTF-8
C++
false
false
1,345
cpp
/* ***** BEGIN LICENSE BLOCK ***** * FW4SPL - Copyright (C) IRCAD, 2009-2014. * Distributed under the terms of the GNU Lesser General Public License (LGPL) as * published by the Free Software Foundation. * ****** END LICENSE BLOCK ****** */ #include <fwAtomsPatch/SemanticPatchDB.hpp> #include "fwMDSemanticPatch/V1/V2/fwData/Composite.hpp" #include "fwMDSemanticPatch/V1/V2/fwData/Study.hpp" #include "fwMDSemanticPatch/V1/V2/fwData/Patient.hpp" #include "fwMDSemanticPatch/V1/V2/fwData/Acquisition.hpp" namespace fwMDSemanticPatch { namespace V1 { namespace V2 { namespace fwData { /// Registers contextual patches dedicated to conversions from version 'V1' to version 'V2'. struct runner { runner() { ::fwAtomsPatch::SemanticPatchDB::sptr contextPatchDB = ::fwAtomsPatch::SemanticPatchDB::getDefault(); contextPatchDB->registerPatch(::fwMDSemanticPatch::V1::V2::fwData::Composite::New()); contextPatchDB->registerPatch(::fwMDSemanticPatch::V1::V2::fwData::Study::New()); contextPatchDB->registerPatch(::fwMDSemanticPatch::V1::V2::fwData::Patient::New()); contextPatchDB->registerPatch(::fwMDSemanticPatch::V1::V2::fwData::Acquisition::New()); } static runner r; }; runner runner::r; } // namespace fwData } // namespace V2 } // namespace V1 } // namespace fwMDSemanticPatch
cccf515430d9d7a9216df80e5601d574b48a7522
38370ec6d3ba86570dd0efd1de8841f6ff5bad59
/CrossApp/control/CAButton.cpp
15effca5af4f8bc9603ec5fe58777dec7cb87227
[]
no_license
RainbowMin/CrossApp
f3588907811cc5f3b9936439b95aade65eb29e5a
45b5d4893fab0bb955089e1655694b189760608d
refs/heads/master
2021-01-18T10:07:52.377093
2014-07-22T05:44:16
2014-07-22T05:44:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,096
cpp
// // CAButton.cpp // CrossApp // // Created by Li Yuanfeng on 14-3-23. // Copyright (c) 2014 http://9miao.com All rights reserved. // #include "CAButton.h" #include "view/CAScale9ImageView.h" #include "view/CAView.h" #include "dispatcher/CATouch.h" #include "support/CCPointExtension.h" #include "cocoa/CCSet.h" #include "view/CALabel.h" #include "basics/CAApplication.h" #define PLAYSOUND NS_CC_BEGIN CAButton::CAButton(CAButtonType buttonType) :m_bAllowsSelected(false) ,m_bSelected(false) ,m_textTag("") ,m_closeTapSound(false) ,m_bTouchClick(false) ,m_color(CAColor_white) ,m_eButtonType(buttonType) ,m_sTitleFontName("Helvetica-Bold") ,m_pImageView(NULL) ,m_pLabel(NULL) { for (int i=0; i<CAControlStateAll; i++) { m_pImage[i] = NULL; m_sTitle[i] = ""; m_sImageColor[i] = CAColor_white; m_sTitleColor[i] = CAColor_black; } m_pImageView = new CAImageView(); m_pImageView->init(); this->insertSubview(m_pImageView, 1); m_pLabel = new CALabel(); m_pLabel->init(); m_pLabel->setTextAlignment(CATextAlignmentCenter); m_pLabel->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel->setNumberOfLine(1); this->insertSubview(m_pLabel, 1); } CAButton::~CAButton(void) { CC_SAFE_RELEASE_NULL(m_pImageView); CC_SAFE_RELEASE_NULL(m_pLabel); } void CAButton::onExitTransitionDidStart() { CAControl::onExitTransitionDidStart(); } void CAButton::onEnterTransitionDidFinish() { CAControl::onEnterTransitionDidFinish(); this->setControlState(m_eControlState); } CAButton* CAButton::create(CAButtonType buttonType) { CAButton* btn = new CAButton(buttonType); if (btn && btn->init()) { btn->autorelease(); return btn; } CC_SAFE_DELETE(btn); return NULL; } CAButton* CAButton::createWithFrame(const CCRect& rect, CAButtonType buttonType) { CAButton* btn = new CAButton(buttonType); if (btn && btn->initWithFrame(rect)) { btn->autorelease(); return btn; } CC_SAFE_DELETE(btn); return NULL; } CAButton* CAButton::createWithCenter(const CCRect& rect, CAButtonType buttonType) { CAButton* btn = new CAButton(buttonType); if (btn && btn->initWithCenter(rect)) { btn->autorelease(); return btn; } CC_SAFE_DELETE(btn); return NULL; } bool CAButton::initWithFrame(const CCRect& rect) { if (!CAButton::init()) { return false; } this->setFrame(rect); return true; } bool CAButton::initWithCenter(const CCRect& rect) { if (!CAButton::init()) { return false; } this->setCenter(rect); return true; } bool CAButton::init() { if (!CAControl::init()) { return false; } this->setColor(CAColor_clear); switch (m_eButtonType) { case CAButtonTypeSquareRect: this->setBackGroundViewSquareRect(); break; case CAButtonTypeRoundedRect: this->setBackGroundViewRoundedRect(); break; default: break; } return true; } void CAButton::setBackGroundViewSquareRect() { const char* fileName[CAControlStateAll] = { "source_material/btn_square_normal.png", "source_material/btn_square_highlighted.png", "source_material/btn_square_disabled.png", "source_material/btn_square_selected.png" }; CAColor4B color[CAControlStateAll] = { ccc4( 46, 192, 255, 255), ccc4(255, 255, 255, 255), ccc4(255, 255, 255, 255), ccc4(255, 255, 255, 255) }; for (int i=0; i<CAControlStateAll; i++) { CAImage* image = CAImage::create(fileName[i]); CAScale9ImageView* bg = CAScale9ImageView::createWithImage(image); this->setBackGroundViewForState((CAControlState)i, bg); m_sTitleColor[i] = color[i]; } } void CAButton::setBackGroundViewRoundedRect() { const char* fileName[CAControlStateAll] = { "source_material/btn_rounded_normal.png", "source_material/btn_rounded_highlighted.png", "source_material/btn_rounded_disabled.png", "source_material/btn_rounded_selected.png" }; CAColor4B color[CAControlStateAll] = { ccc4( 46, 192, 255, 255), ccc4(255, 255, 255, 255), ccc4(255, 255, 255, 255), ccc4(255, 255, 255, 255) }; for (int i=0; i<CAControlStateAll; i++) { CAImage* image = CAImage::create(fileName[i]); CAScale9ImageView* bg = CAScale9ImageView::createWithImage(image); this->setBackGroundViewForState((CAControlState)i, bg); m_sTitleColor[i] = color[i]; } } void CAButton::setBackGroundViewForState(CAControlState controlState, CAView *var) { CAControl::setBackGroundViewForState(controlState, var); CC_RETURN_IF(var == NULL); if (this->getBounds().equals(CCRectZero)) { this->setBounds(CCRect(0, 0, var->getFrame().size.width, var->getFrame().size.height)); } this->updateWithPreferredSize(); } void CAButton::setImageForState(CAControlState controlState, CAImage* var) { if (controlState == CAControlStateAll) { for (int i=0; i<CAControlStateAll; i++) this->setImageForState((CAControlState)i, var); return; } if (m_pImage[controlState] != var) { CC_SAFE_RETAIN(var); CC_SAFE_RELEASE(m_pImage[controlState]); m_pImage[controlState] = var; } if (m_bRunning) { this->setControlState(m_eControlState); } } void CAButton::setTitleForState(CAControlState controlState, std::string var) { if (controlState == CAControlStateAll) { for (int i=0; i<CAControlStateAll; i++) this->setTitleForState((CAControlState)i, var); return; } if (m_sTitle[controlState] != var) { m_sTitle[controlState] = var; } if (m_bRunning) { this->setControlState(m_eControlState); } } void CAButton::setImageColorForState(CAControlState controlState, CAColor4B var) { if (controlState == CAControlStateAll) { for (int i=0; i<CAControlStateAll; i++) this->setImageColorForState((CAControlState)i, var); } else { m_sImageColor[controlState] = var; } if (m_bRunning) { this->setControlState(m_eControlState); } } void CAButton::setTitleColorForState(CAControlState controlState, CAColor4B var) { if (controlState == CAControlStateAll) { for (int i=0; i<CAControlStateAll; i++) this->setTitleColorForState((CAControlState)i, var); } else { m_sTitleColor[controlState] = var; } if (m_bRunning) { this->setControlState(m_eControlState); } } void CAButton::setTitleFontName(std::string var) { if (m_sTitleFontName.compare(var)) { m_sTitleFontName = var; m_pLabel->setFontName(m_sTitleFontName.c_str()); } if (m_bRunning) { this->setControlState(m_eControlState); } } void CAButton::updateWithPreferredSize() { for (int i=0; i<CAControlStateAll; i++) { CC_CONTINUE_IF(m_pBackGroundView[i] == NULL); CC_CONTINUE_IF(this->getBounds().equals(m_pBackGroundView[i]->getBounds())); if (CAScale9ImageView* _var = dynamic_cast<CAScale9ImageView*>(m_pBackGroundView[i])) { _var->setFrame(this->getBounds()); } else { m_pBackGroundView[i]->setFrame(this->getBounds()); } } m_pLabel->setFontSize(this->getBounds().size.height * 0.667f); } bool CAButton::ccTouchBegan(CrossApp::CATouch *pTouch, CrossApp::CAEvent *pEvent) { CCPoint point = pTouch->getLocation(); point = this->convertToNodeSpace(point); do { CC_BREAK_IF(!this->isVisible()); CC_BREAK_IF(!m_bTouchEnabled); CC_BREAK_IF(m_eControlState != CAControlStateNormal && m_eControlState != CAControlStateSelected); return this->setTouchBegin(point); } while (0); return false; } void CAButton::ccTouchMoved(CrossApp::CATouch *pTouch, CrossApp::CAEvent *pEvent) { CCPoint point = pTouch->getLocation(); point = this->convertToNodeSpace(point); if (!this->isTouchClick()) return; if (getBounds().containsPoint(point)) { this->setTouchMoved(point); this->setControlState(CAControlStateHighlighted); } else { this->setTouchMovedOutSide(point); if (m_bAllowsSelected && m_bSelected) { this->setControlState(CAControlStateSelected); } else { this->setControlState(CAControlStateNormal); } } } void CAButton::ccTouchEnded(CrossApp::CATouch *pTouch, CrossApp::CAEvent *pEvent) { CCPoint point = pTouch->getLocation(); point = this->convertToNodeSpace(point); if (!this->isTouchClick()) return; this->setTouchUpSide(point); if (getBounds().containsPoint(point)) { this->setTouchUpInSide(point); } do { CC_BREAK_IF(this->getControlState() != CAControlStateHighlighted); if (m_bAllowsSelected) { if (m_bSelected) { m_bSelected = false; this->setControlState(CAControlStateNormal); } else { m_bSelected = true; this->setControlState(CAControlStateSelected); } } else { this->setControlState(CAControlStateNormal); } } while (0); } void CAButton::ccTouchCancelled(CrossApp::CATouch *pTouch, CrossApp::CAEvent *pEvent) { if (m_bAllowsSelected && m_bSelected) { this->setControlState(CAControlStateSelected); } else { this->setControlState(CAControlStateNormal); } } void CAButton::setControlState(CAControlState var) { CAControl::setControlState(var); if (m_eControlState == CAControlStateSelected) { m_bSelected = true; } else if(m_eControlState != CAControlStateHighlighted) { m_bSelected = false; } CAImage* image = NULL; std::string title = ""; CCRect imageViewCenter = CCRectZero; CCRect rect = CCRectZero; CCRect labelCenter = this->getBounds(); float labelSize = 0; image = m_pImage[m_eControlState]; title = m_sTitle[m_eControlState]; if (image == NULL) { image = this->isSelected() ? m_pImage[CAControlStateSelected] : m_pImage[CAControlStateNormal]; } if (strcmp(title.c_str(), "") == 0) { title = this->isSelected() ? m_sTitle[CAControlStateSelected] : m_sTitle[CAControlStateNormal]; } if (image && title.compare("") == 0) { CCSize size = this->getBounds().size; CCSize iSize = image->getContentSize(); float scaleX = size.width / iSize.width * 0.75f; float scaleY = size.height / iSize.height * 0.75f; float scale = MIN(scaleX, scaleY); scale = MIN(scale, 1.0f); iSize = ccpMult(iSize, scale); imageViewCenter.origin = size / 2; imageViewCenter.size = iSize; } else if (image == NULL && title.compare("") != 0) { labelSize = this->getBounds().size.height * 0.4f; labelCenter.origin = this->getBounds().size / 2 ; } else if (image && title.compare("") != 0) { CCSize size = this->getBounds().size; CCSize iSize = image->getContentSize(); float scaleX = size.width / iSize.width * 0.5f; float scaleY = size.height / iSize.height * 0.5f; float scale = MIN(scaleX, scaleY); scale = MIN(scale, 1.0f); iSize = ccpMult(iSize, scale); imageViewCenter.size = iSize; imageViewCenter.origin.x = size.width / 2; imageViewCenter.origin.y = size.height * 0.35f; labelSize = size.height * 0.3f; labelCenter.origin.x = size.width / 2; labelCenter.origin.y = size.height * 0.75f; } m_pImageView->setColor(m_sImageColor[m_eControlState]); m_pImageView->setCenter(imageViewCenter); if (image != m_pImageView->getImage()) { m_pImageView->setImage(image); } m_pLabel->setColor(m_sTitleColor[m_eControlState]); m_pLabel->setCenter(labelCenter); if (!title.empty()) { m_pLabel->setFontSize(labelSize); } if (strcmp(title.c_str(), m_pLabel->getText().c_str())) { m_pLabel->setText(title.c_str()); } } void CAButton::interruptTouchState() { CC_RETURN_IF(m_bTouchClick == false); m_bTouchClick = false; CC_RETURN_IF(m_eControlState != CAControlStateHighlighted); if (m_bAllowsSelected && m_bSelected) { this->setControlState(CAControlStateSelected); } else { this->setControlState(CAControlStateNormal); } } bool CAButton::setTouchBegin(CCPoint point) { m_bTouchClick = true; if (m_pTarget[CAControlEventTouchDown] && m_selTouch[CAControlEventTouchDown]) { ((CAObject *)m_pTarget[CAControlEventTouchDown]->*m_selTouch[CAControlEventTouchDown])(this, point); } if (m_bTouchClick) { this->setControlState(CAControlStateHighlighted); } return m_bTouchClick; } void CAButton::setTouchUpInSide(CCPoint point) { if (m_pTarget[CAControlEventTouchUpInSide] && m_selTouch[CAControlEventTouchUpInSide]) { ((CAObject *)m_pTarget[CAControlEventTouchUpInSide]->*m_selTouch[CAControlEventTouchUpInSide])(this,point); } } void CAButton::setTouchUpSide(CCPoint point) { if (m_pTarget[CAControlEventTouchUpSide] && m_selTouch[CAControlEventTouchUpSide]) { ((CAObject *)m_pTarget[CAControlEventTouchUpSide]->*m_selTouch[CAControlEventTouchUpSide])(this,point); } } void CAButton::setTouchMoved(CrossApp::CCPoint point) { if (m_pTarget[CAControlEventTouchMoved] && m_selTouch[CAControlEventTouchMoved]) { ((CAObject *)m_pTarget[CAControlEventTouchMoved]->*m_selTouch[CAControlEventTouchMoved])(this,point); } } void CAButton::setTouchMovedOutSide(CrossApp::CCPoint point) { if (m_pTarget[CAControlEventTouchMovedOutSide] && m_selTouch[CAControlEventTouchMovedOutSide]) { ((CAObject *)m_pTarget[CAControlEventTouchMovedOutSide]->*m_selTouch[CAControlEventTouchMovedOutSide])(this,point); } } bool CAButton::isTextTagEqual(const char *text) { return (m_textTag.compare(text)==0); } void CAButton::setContentSize(const CCSize & var) { CCSize size = var; size.height = MAX(size.height, 60 * CROSSAPP_ADPTATION_RATIO); size.width = MAX(size.width, size.height); CAControl::setContentSize(size); this->updateWithPreferredSize(); this->setControlState(m_eControlState); } NS_CC_END
c2d3ae476f3d0d351d698e3b3cc50c2d90499233
244214ceac1f07216b6ddb19957c9e93bb20d9b6
/devel/include/handsnet_tftrt_yolo/Image_BB.h
dc6b9c9427c0d5757fd4223d57249bda1683da72
[ "MIT" ]
permissive
robertokcanale/ros-yolov5
fb19a8777ca355fbe675c3c9e4d45f476184178e
fb39975857c7020e198c15943b1259899743ea18
refs/heads/main
2023-06-13T22:17:51.707541
2021-06-30T08:06:00
2021-06-30T08:06:00
353,715,449
1
0
null
null
null
null
UTF-8
C++
false
false
5,762
h
// Generated by gencpp from file handsnet_tftrt_yolo/Image_BB.msg // DO NOT EDIT! #ifndef HANDSNET_TFTRT_YOLO_MESSAGE_IMAGE_BB_H #define HANDSNET_TFTRT_YOLO_MESSAGE_IMAGE_BB_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> #include <handsnet_tftrt_yolo/BB.h> namespace handsnet_tftrt_yolo { template <class ContainerAllocator> struct Image_BB_ { typedef Image_BB_<ContainerAllocator> Type; Image_BB_() : bb_number(0) , bb_array() { } Image_BB_(const ContainerAllocator& _alloc) : bb_number(0) , bb_array(_alloc) { (void)_alloc; } typedef int16_t _bb_number_type; _bb_number_type bb_number; typedef std::vector< ::handsnet_tftrt_yolo::BB_<ContainerAllocator> , typename ContainerAllocator::template rebind< ::handsnet_tftrt_yolo::BB_<ContainerAllocator> >::other > _bb_array_type; _bb_array_type bb_array; typedef boost::shared_ptr< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> const> ConstPtr; }; // struct Image_BB_ typedef ::handsnet_tftrt_yolo::Image_BB_<std::allocator<void> > Image_BB; typedef boost::shared_ptr< ::handsnet_tftrt_yolo::Image_BB > Image_BBPtr; typedef boost::shared_ptr< ::handsnet_tftrt_yolo::Image_BB const> Image_BBConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> & v) { ros::message_operations::Printer< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> >::stream(s, "", v); return s; } template<typename ContainerAllocator1, typename ContainerAllocator2> bool operator==(const ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator1> & lhs, const ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator2> & rhs) { return lhs.bb_number == rhs.bb_number && lhs.bb_array == rhs.bb_array; } template<typename ContainerAllocator1, typename ContainerAllocator2> bool operator!=(const ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator1> & lhs, const ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator2> & rhs) { return !(lhs == rhs); } } // namespace handsnet_tftrt_yolo namespace ros { namespace message_traits { template <class ContainerAllocator> struct IsMessage< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct IsFixedSize< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct IsFixedSize< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> const> : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> const> : FalseType { }; template<class ContainerAllocator> struct MD5Sum< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> > { static const char* value() { return "e36224c45647457f9e206d30e8546220"; } static const char* value(const ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0xe36224c45647457fULL; static const uint64_t static_value2 = 0x9e206d30e8546220ULL; }; template<class ContainerAllocator> struct DataType< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> > { static const char* value() { return "handsnet_tftrt_yolo/Image_BB"; } static const char* value(const ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> > { static const char* value() { return "int16 bb_number\n" "handsnet_tftrt_yolo/BB[] bb_array\n" "================================================================================\n" "MSG: handsnet_tftrt_yolo/BB\n" "string obj_class\n" "float32 confidence\n" "float32[] coordinates\n" ; } static const char* value(const ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.bb_number); stream.next(m.bb_array); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct Image_BB_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::handsnet_tftrt_yolo::Image_BB_<ContainerAllocator>& v) { s << indent << "bb_number: "; Printer<int16_t>::stream(s, indent + " ", v.bb_number); s << indent << "bb_array[]" << std::endl; for (size_t i = 0; i < v.bb_array.size(); ++i) { s << indent << " bb_array[" << i << "]: "; s << std::endl; s << indent; Printer< ::handsnet_tftrt_yolo::BB_<ContainerAllocator> >::stream(s, indent + " ", v.bb_array[i]); } } }; } // namespace message_operations } // namespace ros #endif // HANDSNET_TFTRT_YOLO_MESSAGE_IMAGE_BB_H
91c020fca52e2522ee386da99bc7217b3c660424
7844379f018944f9be77cc213a8985372eff0848
/src/saiga/vision/util/HistogramImage.h
b6f91d8dde9c5607941ba9a1160d91c235816fc7
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
muetimueti/saiga
344306e2340f4668b9fece1e3d0d934cd189feb2
32b54a8fc7b1251368e07e7d31c15ac90cee3b32
refs/heads/master
2020-07-31T12:42:29.096235
2019-09-25T16:50:09
2019-09-25T16:50:09
210,607,609
0
0
MIT
2019-09-24T13:17:44
2019-09-24T13:17:38
null
UTF-8
C++
false
false
714
h
/** * Copyright (c) 2017 Darius Rückert * Licensed under the MIT License. * See LICENSE file for more information. */ #pragma once #include "saiga/core/image/image.h" #include "saiga/vision/VisionTypes.h" namespace Saiga { class SAIGA_VISION_API HistogramImage { public: HistogramImage(int inputW, int inputH, int outputW, int outputH); void add(int y, int x, int value); void writeBinary(const std::string& file); int operator()(int y, int x) { return img(y, x); } // all elements larger or equal than threshold divided by size float density(int threshold = 1); private: int inputW, inputH, outputW, outputH; TemplatedImage<int> img; }; } // namespace Saiga
4fe96d62bf4c9624666e73f44dbe3e0c64e9e4e1
2a61b02c26e77686e38cd9039e6f4b0530ddb7c9
/bitbots_motion/bitbots_splines/src/Spline/pose_spline.cpp
c547677bd2c9e5898fc3828112ee19a4b83d7c4a
[ "MIT" ]
permissive
fly-pigTH/bitbots_thmos_meta
931413e86929751024013b8e35f87b799243e22c
f45ccc362dc689b69027be5b0d000d2a08580de4
refs/heads/master
2023-08-27T02:58:08.397650
2021-10-22T17:17:11
2021-10-22T17:17:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,796
cpp
#include "bitbots_splines/pose_spline.h" namespace bitbots_splines { tf2::Transform PoseSpline::getTfTransform(double time) { tf2::Transform trans; trans.setOrigin(getPositionPos(time)); trans.setRotation(getOrientation(time)); return trans; } geometry_msgs::Pose PoseSpline::getGeometryMsgPose(double time) { geometry_msgs::Pose msg; msg.position = getGeometryMsgPosition(time); msg.orientation = getGeometryMsgOrientation(time); return msg; } geometry_msgs::Point PoseSpline::getGeometryMsgPosition(double time) { geometry_msgs::Point msg; tf2::Vector3 tf_vec = getPositionPos(time); msg.x = tf_vec.x(); msg.y = tf_vec.y(); msg.z = tf_vec.z(); return msg; } geometry_msgs::Quaternion PoseSpline::getGeometryMsgOrientation(double time) { geometry_msgs::Quaternion msg; tf2::convert(getOrientation(time), msg); return msg; } tf2::Vector3 PoseSpline::getPositionPos(double time) { tf2::Vector3 pos; pos[0] = x_.pos(time); pos[1] = y_.pos(time); pos[2] = z_.pos(time); return pos; } tf2::Vector3 PoseSpline::getPositionVel(double time) { tf2::Vector3 vel; vel[0] = x_.vel(time); vel[1] = y_.vel(time); vel[2] = z_.vel(time); return vel; } tf2::Vector3 PoseSpline::getPositionAcc(double time) { tf2::Vector3 acc; acc[0] = x_.acc(time); acc[1] = y_.acc(time); acc[2] = z_.acc(time); return acc; } tf2::Vector3 PoseSpline::getEulerAngles(double time) { tf2::Vector3 pos; pos[0] = roll_.pos(time); pos[1] = pitch_.pos(time); pos[2] = yaw_.pos(time); return pos; } tf2::Vector3 PoseSpline::getEulerVel(double time) { tf2::Vector3 vel; vel[0] = roll_.vel(time); vel[1] = pitch_.vel(time); vel[2] = yaw_.vel(time); return vel; } tf2::Vector3 PoseSpline::getEulerAcc(double time) { tf2::Vector3 acc; acc[0] = roll_.acc(time); acc[1] = pitch_.acc(time); acc[2] = yaw_.acc(time); return acc; } tf2::Quaternion PoseSpline::getOrientation(double time) { tf2::Quaternion quat; tf2::Vector3 rpy = getEulerAngles(time); quat.setRPY(rpy[0], rpy[1], rpy[2]); quat.normalize(); return quat; } SmoothSpline *PoseSpline::x() { return &x_; } SmoothSpline *PoseSpline::y() { return &y_; } SmoothSpline *PoseSpline::z() { return &z_; } SmoothSpline *PoseSpline::roll() { return &roll_; } SmoothSpline *PoseSpline::pitch() { return &pitch_; } SmoothSpline *PoseSpline::yaw() { return &yaw_; } std::string PoseSpline::getDebugString() { std::string output; output += "x:\n" + x_.getDebugString() + "\n"; output += "y:\n" + y_.getDebugString() + "\n"; output += "z:\n" + z_.getDebugString() + "\n"; output += "roll:\n" + roll_.getDebugString() + "\n"; output += "pitch:\n" + pitch_.getDebugString() + "\n"; output += "yaw:\n" + yaw_.getDebugString() + "\n"; return output; } }
08995e3ae77335d3a07cd64c769441b728ed6e5d
25c3e1d01a55992a7fa2afa0907943e86ef34966
/Tera Emulator v1xxx VS Project [SRC]/TERA_C++_EMULATOR_1/RGetPlayerList.h
aa928a46b50f20a0ef357d5917de9ecefa670dfb
[]
no_license
highattack30/Tera_Emulator_v1xxx-1
6daba31ca976f61658481a4c8aca98f8bdf9759c
0c926ac903921912e69d9bb7e5cdc4022b0236f3
refs/heads/master
2021-01-21T19:01:50.117483
2016-08-22T09:17:14
2016-08-22T09:17:14
66,280,083
1
1
null
2016-08-22T14:33:30
2016-08-22T14:33:30
null
UTF-8
C++
false
false
295
h
#ifndef GET_PLAYER_LIST_H #define GET_PLAYER_LIST_H #include "SendPacket.h" #include <vector> class RGetPlayerList : public SendPacket { public: RGetPlayerList(); // Inherited via SendPacket virtual void Process(OpCode opCode, Stream * data, Client * caller) override; }; #endif
[ "Narcis@NARCIS-PC" ]
Narcis@NARCIS-PC
c4e523778e89a0581da73bd26cd6b26a5cae134f
be98f69059e467d4b1f2970bfcdd73c94f3cbe62
/Effects/converge.cpp
92d7165352d5be102f9158cee823d5728f02a8f8
[]
no_license
nhoudelot/antedominium-by-traction
0bc3fff258cc4b7b7ead515be1172efafe742726
defab2a06d120f4052c66bcd59e11ba35232017b
refs/heads/master
2020-03-07T23:26:18.099082
2018-04-02T16:24:07
2018-04-02T16:24:07
127,781,518
1
0
null
null
null
null
UTF-8
C++
false
false
5,599
cpp
#include "converge.hpp" #pragma warning(disable:4244) Lista *floaterlist; Path *convergecam; Path *convergetarget; int convergefloatercount; const int maxconvergefloatercount = 10000; const float maxrange = 6.7f; const float maxenergy = 0.05f; Vector grad(float xp, float yp, float zp, float tp, float(*func)(float x, float y, float z, float t)) { const float epsilon = 0.001f; const float dx = func(xp+epsilon, yp, zp, tp) - func(xp, yp, zp, tp); const float dy = func(xp, yp+epsilon, zp, tp) - func(xp, yp, zp, tp); const float dz = func(xp, yp, zp+epsilon, tp) - func(xp, yp, zp, tp); return Vector(dx, dy, dz); } float div(float xp, float yp, float zp, float tp, float(*func)(float x, float y, float z, float t)) { const float epsilon = 0.001f; const float dx = func(xp+epsilon, yp, zp, tp) - func(xp, yp, zp, tp); const float dy = func(xp, yp+epsilon, zp, tp) - func(xp, yp, zp, tp); const float dz = func(xp, yp, zp+epsilon, tp) - func(xp, yp, zp, tp); return dx+dy+dz; } Vector convergefunc1(float x, float y, float z, float t) { const float dist = (float)sqrt(x*x+y*y+z*z)*0.1f; Vector v = Vector(x, y, z)*dist; return v; } Vector convergefunc2(float x, float y, float z, float t) { Vector p1 = Vector((float)cos(t*24)*7+(float)sin(t*13.5f)*3, 7*(float)cos(t*56+0.2f), (float)cos(t*15)*7); Vector p2 = Vector((float)cos(t*17)*5, 19*(float)cos(t*26), (float)cos(t*11)*7); float d = (Vector(x, y, z)-p1).length(); float d2 = (Vector(x, y, z)-p2).length(); const float rotamount = (float)sin((d+d2)*0.4f*t); Matrix rot; rot.makeRotation(0, rotamount+t*16*0, 0); return Vector(1, 0, 0)*rot; } Vector convergefunc3(float x, float y, float z, float t) { const float s = 0.3f; const float s2 = 10.0f; float tx = (float)sin(1.4f*x*s + 1.7f*z *s + 0.6f*t*s2); float ty = (float)sin(0.7f*x*s + 0.8f*t*s2); float tz = (float)sin(1.335f*x*s + 0.94*t*s2); return Vector(tx, 0, tz); } Vector convergedirector(float x, float y, float z, float t) { const float starfieldstart = 0.0f; const float starfieldend = 0.6f; float starfieldpos = (1-calcPosFloat(t, starfieldstart, starfieldend))*3; if (starfieldpos > 1.0f) starfieldpos = 1.0f; float convergefunct = (0.5f+0.5f*(float)sin(t*24))*(1-calcPosFloat(t, 0.8f, 1.0f)); return convergefunc1(x, y, z, t)*starfieldpos + (convergefunc2(x, y, z, t)*convergefunct+convergefunc3(x,y,z,t)*(1-convergefunct))*(1-starfieldpos); } void converge(float aika) { const float alpha = calcSaturate(aika, 0, 1, 6); static float previousframe = 0.0f; float dt = aika- previousframe; previousframe = aika; glLoadIdentity(); const float angle = aika*7; // Vector campos = Vector(0, 8+4*(float)cos(aika*17), 0) + Vector((float)cos(angle), 0, (float)sin(angle))*20;; // Vector campos = Vector(0.1f, 25, 0.1f); Vector campos = convergecam->getValue(aika); Vector camtarget = Vector(0, 0, 0); gluLookAt(campos.x, campos.y, campos.z, camtarget.x, camtarget.y, camtarget.z, 0, 1, 0); glDisable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); glColor4f(0, 0, 0, alpha); const float gridstep = 0.25f; Vector (*vectorfield)(float x, float y, float z, float t) = convergedirector; /* glBegin(GL_LINES); for (z=-maxrange;z<maxrange;z+=gridstep) { for (x=-maxrange;x<maxrange;x+=gridstep) { const float scale = 1.0f; Vector v = Vector(x, 0, z)*scale; Vector v2 = v + vectorfield(x, 0, z, aika)*0.2f; glColor4f(0, 0, 0, alpha*0.3f); glVertex3fv((float *)&v); glColor4f(0, 0, 0, 0); glVertex3fv((float *)&v2); } } glEnd(); */ // glPointSize(3); glDisable(GL_DEPTH_TEST); glLineWidth(3); glBegin(GL_LINES); glColor4f(1, 0, 0, alpha); floaterlist->goToStart(); while (floaterlist->goForward()) { const float floaterspeed = 40.0f; Floater *f = (Floater *)floaterlist->getCurrent(); if (f->update(dt*1.5f, maxrange, vectorfield(f->pos.x, f->pos.y, f->pos.z, aika)*floaterspeed)) { f->draw(alpha); } else { floaterlist->remove(); f = new Floater(false, maxenergy, maxrange); floaterlist->add(f); } } glEnd(); } void converge_init() { int i; floaterlist = new Lista(); convergefloatercount = 0; srand(160917); for (i=0;i<maxconvergefloatercount;i++) { Floater *f = new Floater(false, maxenergy*1.0f, maxrange); floaterlist->add(f); } convergecam = new Path(); convergetarget = new Path(); convergecam->addpoint(Vector(1.1f, 15, -1.3f)); convergecam->addpoint(Vector(1.1f, 15, -1.3f)); convergecam->addpoint(Vector(1.1f, 15, -1.3f)); convergecam->addpoint(Vector(1.1f, 15, -1.3f)); convergecam->addpoint(Vector(1.1f, 25, -1.3f)); convergecam->addpoint(Vector(5.1f, 30, -1.3f)); convergecam->addpoint(Vector(9.1f, 30, -1.3f)); convergecam->addpoint(Vector(14.1f, 20, -1.3f)); convergecam->addpoint(Vector(17.1f, 6, -5.3f)); convergecam->addpoint(Vector(21.1f, 6, -13.3f)); convergecam->addpoint(Vector(19.1f, 8, -15.3f)); convergecam->addpoint(Vector(14.1f, 11, -12.3f)); // convergecam->addpoint(Vector(7, 4, -3)); // convergecam->addpoint(Vector(14, 2, -10)); // convergecam->addpoint(Vector(4, 11, -12)); // convergecam->addpoint(Vector(-7, 13, -7)); // convergecam->addpoint(Vector(-14, 9, -2)); } void converge_free() { floaterlist->destroy(); delete floaterlist; delete convergecam; delete convergetarget; }
317827ca429bb945e6b0e650a34ad29e84e4782c
83d8b49f1fb560583280e0b7eb2b1c639a772037
/pracman/mbUtils/mbFileList.cpp
c5d5fa646915f7564cdbe78995b231dab323d7a0
[]
no_license
mbirkeee/office-projects
2e1490db6d28afca26b0e38b576628efa716643a
9709db588eeade213319883ad97ac9a09dc70ed8
refs/heads/master
2022-08-28T10:34:36.723540
2022-08-07T18:30:21
2022-08-07T18:30:21
149,552,848
0
0
null
null
null
null
UTF-8
C++
false
false
29,494
cpp
//--------------------------------------------------------------------------- // File: mbFileListUtils.cpp //--------------------------------------------------------------------------- // Author: Michael A. Bree (c) 2001, Saskatoon SK Canada //--------------------------------------------------------------------------- // Date: Oct. 31, 2002 //--------------------------------------------------------------------------- // Description: // // File utilities and functions //--------------------------------------------------------------------------- #include <stdio.h> #include <dir.h> #include <vcl.h> #pragma hdrstop #include "mbTypes.h" #include "mbLock.h" #include "mbMalloc.h" #include "mbDebug.h" #include "mbDlg.h" #include "mbLog.h" #include "mbStrUtils.h" #include "mbFileUtils.h" #define MB_INIT_GLOBALS #include "mbFileList.h" #undef MB_INIT_GLOBALS //--------------------------------------------------------------------------- // Function: mbFileListSearch //--------------------------------------------------------------------------- // This function searches the file list for the given string //--------------------------------------------------------------------------- Int32s_t mbFileListSearch ( qHead_p file_q, Char_p search_p ) { Int32s_t returnCode = MB_RET_ERR; mbFileListStruct_p file_p; if( file_q == NIL || search_p == NIL ) goto exit; qWalk( file_p, file_q, mbFileListStruct_p ) { if( strcmp( file_p->fullName_p, search_p ) == 0 ) { returnCode = MB_RET_OK; break; } if( file_p->attrib & FA_DIREC ) { if( file_p->sub_q ) { returnCode = mbFileListSearch( file_p->sub_q, search_p ); if( returnCode == MB_RET_OK ) break; } } } exit: return returnCode; } //--------------------------------------------------------------------------- // Function: mbFileListGet //--------------------------------------------------------------------------- // This function (which may call itself recursively) returns the total size // of all the files in the list. // // 20021101: This function cannot recurse without a filter of *.* Fix later. //--------------------------------------------------------------------------- Int64u_t mbFileListGet ( Char_p dir_p, Char_p filter_p, qHead_p q_p, Boolean_t recurse ) { static int depthCount = 0; Int32s_t pathLen; Char_p path_p = NIL; Char_p search_p = NIL; struct ffblk ffblk; Int32s_t done; mbFileListStruct_p file_p; Int32s_t searchAttrib = 0; Int64u_t totalSize = 0; // Sanity check if( recurse && strcmp( filter_p, "*.*" ) != 0 ) { mbDlgDebug(( "Error: cannot recurse with filter_p != '*.*'\n" )); return totalSize; } // Sanity check if( depthCount > 25 ) { mbDlgDebug(( "ERROR: depth count > 25; not executing\n" )); return totalSize; } depthCount++; // Copy the target directory mbMalloc( path_p, 1024 ); mbMalloc( search_p, 1024 ); if( dir_p ) { strcpy( path_p, dir_p ); mbStrRemoveSlashTrailing( path_p ); } else { *path_p = 0; } // Get the length of the target directory pathLen = strlen( path_p ); if( pathLen > 0 ) { strcat( path_p, "\\" ); pathLen++; } if( pathLen ) { sprintf( search_p, "%s%s", path_p, filter_p ); } else { getcwd( search_p, 256 ); sprintf( path_p, "%s\\", search_p ); sprintf( search_p, "%s", filter_p ); } if( recurse ) { // If recursing or including directories, set appropriate search attributes searchAttrib = FA_DIREC; } // Now get list of all the files done = findfirst( search_p, &ffblk, searchAttrib ); while( !done ) { if( strcmp( ffblk.ff_name, "." ) != 0 && strcmp( ffblk.ff_name, ".." ) != 0 ) { mbCalloc( file_p, sizeof( mbFileListStruct_t ) ); mbMalloc( file_p->name_p, strlen( ffblk.ff_name ) + 1 ); mbStrClean( ffblk.ff_name, file_p->name_p, FALSE ); mbMalloc( file_p->fullName_p, strlen( ffblk.ff_name ) + strlen( path_p ) + 1 ); sprintf( file_p->fullName_p, "%s%s", path_p, ffblk.ff_name ); // Initialize queue of sub files file_p->sub_q = qInitialize( &file_p->subQueue ); // Record attributes file_p->attrib = ffblk.ff_attrib; file_p->date = ffblk.ff_fdate; file_p->time = ffblk.ff_ftime; if( ( ffblk.ff_attrib & FA_DIREC ) && recurse ) { // Include entry before recursing qInsertLast( q_p, file_p ); // Get files in the sub directory file_p->size64 = mbFileListGet( file_p->fullName_p, filter_p, file_p->sub_q, recurse ); } else { // Must be a file, insert into list qInsertLast( q_p, file_p ); file_p->size64 = (Int64u_t)ffblk.ff_fsize; } // Increment total size, be this a file or directory totalSize += file_p->size64; } done = findnext( &ffblk ); } findclose( &ffblk ); mbFree( path_p ); mbFree( search_p ); depthCount--; return totalSize; } //--------------------------------------------------------------------------- // Function: mbFileListGetNew //--------------------------------------------------------------------------- // 20050108: Based on mbFileListGet, but I don't want to accidentally break // pracman, which relies on this funtion. Add ability to get directories // only. //--------------------------------------------------------------------------- Int64u_t mbFileListGetNew ( Char_p dir_p, Char_p filter_p, qHead_p q_p, Boolean_t recurse, Boolean_t dirOnlyFlag, Boolean_t firstFlag, Int32u_t depthMax ) { static Int32u_t depthCount = 0; Int32s_t pathLen; Char_p path_p = NIL; Char_p search_p = NIL; struct ffblk ffblk; Int32s_t done; mbFileListStruct_p file_p; mbFileListStruct_p first_p; Int32s_t searchAttrib = 0; Int64u_t totalSize = 0; Char_t buf[256]; // Sanity check if( recurse && strcmp( filter_p, "*.*" ) != 0 ) { mbDlgDebug(( "Error: cannot recurse with filter_p != '*.*'\n" )); return totalSize; } if( depthCount > depthMax ) { return totalSize; } depthCount++; // Copy the target directory mbMalloc( path_p, 1024 ); mbMalloc( search_p, 1024 ); if( dir_p ) { strcpy( path_p, dir_p ); mbStrRemoveSlashTrailing( path_p ); } else { *path_p = 0; } // Get the length of the target directory pathLen = strlen( path_p ); if( pathLen > 0 ) { strcat( path_p, "\\" ); pathLen++; } if( pathLen ) { sprintf( search_p, "%s%s", path_p, filter_p ); } else { getcwd( search_p, 256 ); sprintf( path_p, "%s\\", search_p ); sprintf( search_p, "%s", filter_p ); } first_p = NIL; if( depthCount == 1 && firstFlag == TRUE ) { Char_t temp[MAX_PATH]; strcpy( temp, path_p ); mbStrRemoveSlashTrailing( temp ); mbCalloc( file_p, sizeof( mbFileListStruct_t ) ); mbMallocStr( file_p->name_p, temp ); mbMallocStr( file_p->fullName_p, temp ); mbMallocStr( file_p->path_p, temp ); // Record attributes file_p->attrib = ffblk.ff_attrib; file_p->date = ffblk.ff_fdate; file_p->time = ffblk.ff_ftime; mbMallocStr( file_p->timeStr_p, mbFFTimeToStr( file_p->time, buf ) ); mbMallocStr( file_p->dateStr_p, mbFFTimeToStr( file_p->date, buf ) ); file_p->sub_q = qInitialize( &file_p->subQueue ); file_p->attrib |= FA_DIREC; qInsertLast( q_p, file_p ); first_p = file_p; } if( recurse ) { // If recursing or including directories, set appropriate search attributes searchAttrib = FA_DIREC; } // Now get list of all the files done = findfirst( search_p, &ffblk, searchAttrib ); while( !done ) { if( strcmp( ffblk.ff_name, "." ) != 0 && strcmp( ffblk.ff_name, ".." ) != 0 ) { mbCalloc( file_p, sizeof( mbFileListStruct_t ) ); mbMalloc( file_p->name_p, strlen( ffblk.ff_name ) + 1 ); mbStrClean( ffblk.ff_name, file_p->name_p, FALSE ); mbMalloc( file_p->fullName_p, strlen( ffblk.ff_name ) + strlen( path_p ) + 1 ); sprintf( file_p->fullName_p, "%s%s", path_p, ffblk.ff_name ); mbMallocStr( file_p->path_p, file_p->fullName_p ); // This snippet trims the file name from the path { Ints_t l1, l2; l1 = strlen( file_p->name_p ); l2 = strlen( file_p->path_p ); if( l2 > ( l1 + 1 ) ) { *(file_p->path_p + l2 - l1 - 1) = (Char_t)0; } } // Initialize queue of sub files file_p->sub_q = qInitialize( &file_p->subQueue ); // Record attributes file_p->attrib = ffblk.ff_attrib; file_p->date = ffblk.ff_fdate; file_p->time = ffblk.ff_ftime; mbMallocStr( file_p->timeStr_p, mbFFTimeToStr( file_p->time, buf ) ); mbMallocStr( file_p->dateStr_p, mbFFDateToStr( file_p->date, buf ) ); if( ( ffblk.ff_attrib & FA_DIREC ) && recurse ) { // Include entry before recursing qInsertLast( q_p, file_p ); // Get files in the sub directory file_p->size64 = mbFileListGetNew( file_p->fullName_p, filter_p, file_p->sub_q, recurse, dirOnlyFlag, FALSE, depthMax ); } else { // Must be a file, insert into list unless doing dirs only if( dirOnlyFlag == FALSE ) { qInsertLast( q_p, file_p ); file_p->size64 = (Int64u_t)ffblk.ff_fsize; } else { mbFileListFreeElement( file_p ); file_p = NIL; } } // Increment total size, be this a file or directory if( file_p ) { totalSize += file_p->size64; mbMallocStr( file_p->sizeStr_p, mbStrInt64u( file_p->size64, buf ) ); } } done = findnext( &ffblk ); } findclose( &ffblk ); mbFree( path_p ); mbFree( search_p ); if( first_p ) { first_p->size64 = totalSize; mbMallocStr( first_p->sizeStr_p, mbStrInt64u( first_p->size64, buf ) ); } depthCount--; return totalSize; } //--------------------------------------------------------------------------- // Function: mbFileListFlatten //--------------------------------------------------------------------------- // Flatten the file list into a single queue //--------------------------------------------------------------------------- Int32s_t mbFileListFlatten( qHead_p file_q ) { qHead_t tempQueue; qHead_p temp_q; mbFileListStruct_p file_p; if( file_q == NIL ) goto exit; temp_q = qInitialize( &tempQueue ); mbFileListFlattenRecurse( file_q, temp_q ); while( !qEmpty( temp_q ) ) { file_p = (mbFileListStruct_p)qRemoveFirst( temp_q ); qInsertLast( file_q, file_p ); } exit: return TRUE; } //--------------------------------------------------------------------------- // Function: mbFileListFlattenRecurse //--------------------------------------------------------------------------- // Flatten the file list into a single queue //--------------------------------------------------------------------------- Int32s_t mbFileListFlattenRecurse( qHead_p file_q, qHead_p temp_q ) { mbFileListStruct_p file_p; while( !qEmpty( file_q ) ) { file_p = (mbFileListStruct_p)qRemoveFirst( file_q ); qInsertLast( temp_q, file_p ); mbFileListFlattenRecurse( file_p->sub_q, temp_q ); } return TRUE; } //--------------------------------------------------------------------------- // Function: mbFileListLog //--------------------------------------------------------------------------- // This function loops through all the echo files, and outputs to the log // file the contents of the list. //--------------------------------------------------------------------------- Int32s_t mbFileListLog( qHead_p file_q ) { mbFileListStruct_p file_p; qWalk( file_p, file_q, mbFileListStruct_p ) { if( file_p->attrib & FA_DIREC ) { mbLog( "mbFileList: directory: '%s' Size: %Ld\n", file_p->fullName_p, file_p->size64 ); if( file_p->sub_q ) mbFileListLog( file_p->sub_q ); } else { mbLog( "mbFileList: file: '%s' Size: %Ld\n", file_p->fullName_p, file_p->size64 ); } } return TRUE; } //--------------------------------------------------------------------------- // Function: mbFileListPurgeDuplicates //--------------------------------------------------------------------------- // Loop through list, purge dupicates (i.e., same name). //--------------------------------------------------------------------------- Int32s_t mbFileListPurgeDuplicates( qHead_p file_q ) { Int32s_t entriesFreed = 0; Int32u_t size; mbFileListStruct_p file1_p; mbFileListStruct_p file2_p; qHead_t tempQueue; qHead_p temp_q; if( file_q == NIL ) goto exit; temp_q = qInitialize( &tempQueue ); while( !qEmpty( file_q ) ) { file1_p = (mbFileListStruct_p)qRemoveFirst( file_q ); qInsertLast( temp_q, file1_p ); for( Int32u_t i = 0, size = file_q->size ; i < size ; i++ ) { file2_p = (mbFileListStruct_p)qRemoveFirst( file_q ); if( strcmp( file1_p->fullName_p, file2_p->fullName_p ) == 0 ) { mbLog( "Delete duplicate entry '%s'\n", file2_p->fullName_p ); mbFileListFreeElement( file2_p ); entriesFreed++; } else { qInsertLast( file_q, file2_p ); } } } // Done, now move files back into orig queue while( !qEmpty( temp_q ) ) { file1_p = (mbFileListStruct_p)qRemoveFirst( temp_q ); qInsertLast( file_q, file1_p ); } exit: return entriesFreed; } //--------------------------------------------------------------------------- // Function: mbFileListFreeElement //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- Int32s_t mbFileListFreeElement ( mbFileListStruct_p file_p ) { if( file_p == NIL ) return TRUE; // Recursively free subdirectories and files mbFileListFree( file_p->sub_q ); mbFree( file_p->name_p ); mbFree( file_p->fullName_p ); mbFree( file_p->target_p ); mbFree( file_p->path_p ); mbFree( file_p->crcStr_p ); mbFree( file_p->sizeStr_p ); mbFree( file_p->dateStr_p ); mbFree( file_p->timeStr_p ); mbFree( file_p ); return TRUE; } //--------------------------------------------------------------------------- // Function: mbFileListFree //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- Int32s_t mbFileListFree ( qHead_p q_p ) { mbFileListStruct_p file_p; if( q_p == NULL ) return TRUE; for( ; ; ) { if( qEmpty( q_p ) ) break; file_p = (mbFileListStruct_p)qRemoveFirst( q_p ); mbFileListFreeElement( file_p ); } return TRUE; } //--------------------------------------------------------------------------- // Function: mbFileListTargetMake //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- Int32s_t mbFileListTargetMake ( Char_p sourceIn_p, Char_p targetIn_p, qHead_p file_q ) { mbFileListStruct_p file_p; Int32s_t returnCode = MB_RET_ERR; Char_p source_p = NIL; Char_p target_p = NIL; if( sourceIn_p == NIL || targetIn_p == NIL || file_q == NIL ) goto exit; mbMallocStr( source_p, sourceIn_p ); mbMallocStr( target_p, targetIn_p ); mbStrRemoveSlashTrailing( target_p ); mbStrRemoveSlashTrailing( source_p ); qWalk( file_p, file_q, mbFileListStruct_p ) { mbFileListTargetMakeElement( source_p, target_p, file_p ); //mbLog( "mbFileList: %s: '%s' Size: %Ld\n", ( file_p->attrib & FA_DIREC ) ? "directory" : "file", file_p->fullName_p, file_p->size64 ); //if( file_p->target_p ) mbLog( "mbFileList: target: '%s' Size: %Ld\n", file_p->target_p, file_p->size64 ); if( file_p->attrib & FA_DIREC ) { // Recurse into sub directories if( file_p->sub_q ) mbFileListTargetMake( source_p, target_p, file_p->sub_q ); } } returnCode = MB_RET_OK; exit: if( target_p ) mbFree( target_p ); if( source_p ) mbFree( source_p ); return returnCode; } //--------------------------------------------------------------------------- // Function: mbFileListTargetMakeElement //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- Int32s_t mbFileListTargetMakeElement ( Char_p source_p, Char_p target_p, mbFileListStruct_p file_p ) { Int32s_t returnCode = FALSE; mbStrRemoveSlashTrailing( target_p ); mbStrRemoveSlashTrailing( source_p ); // First lets clear out any string already in the target if( file_p->target_p ) { mbFree( file_p->target_p ); file_p->target_p = NIL; } if( mbStrUpdateRoot( file_p->fullName_p, source_p, target_p, &file_p->target_p ) == NIL ) { mbDlgError( "Could not update file '%s'\n", file_p->fullName_p ); goto exit; } returnCode = TRUE; exit: return returnCode; } //--------------------------------------------------------------------------- // Function: mbFileListCopy //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- Int32s_t mbFileListCopy ( qHead_p file_q, Boolean_t thermometerFlag, Void_p this_p, Int32s_t (*cancelFunc)( Void_p this_p ), Int32s_t (*fileFunc)( Void_p this_p, Char_p name_p ), Int32s_t (*bytesFunc)( Void_p this_p, Int32u_t bytes_p ) ) { Int32s_t returnCode; TThermometer *thermometer_p = NIL; qHead_t dirCacheQueue; qHead_p dirCache_q; // For now, lets just set min/max to the number of files. // I would like to update this to bytes later on if( thermometerFlag ) thermometer_p = new TThermometer( "File Copy..." , 0, 10, TRUE ); // List for existing directories... to speed up detection // of existing directories dirCache_q = qInitialize( &dirCacheQueue ); returnCode = mbFileListCopyRecurse( file_q, dirCache_q, thermometer_p, this_p, cancelFunc, fileFunc, bytesFunc ); if( thermometer_p ) delete thermometer_p; mbStrListLog( dirCache_q ); mbStrListFree( dirCache_q ); return returnCode; } //--------------------------------------------------------------------------- // Function: mbFileListCopyRecurse //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- Int32s_t mbFileListCopyRecurse ( qHead_p file_q, qHead_p dirCache_q, TThermometer *thermometer_p, Void_p this_p, Int32s_t (*cancelFunc)( Void_p this_p ), Int32s_t (*fileFunc)( Void_p this_p, Char_p name_p ), Int32s_t (*bytesFunc)( Void_p this_p, Int32u_t bytes_p ) ) { mbFileListStruct_p file_p; Char_p buf_p = NIL; Int32s_t returnCode = MB_RET_ERROR; if( thermometer_p ) mbMalloc( buf_p, 1024 ); qWalk( file_p, file_q, mbFileListStruct_p ) { // Check for thermometer if( thermometer_p ) { sprintf( buf_p, "Copying file '%s'", file_p->name_p ); thermometer_p->SetCaption( buf_p ); if( thermometer_p->Increment( ) == FALSE ) { if( mbDlgYesNo( "Cancel file copy?" ) == MB_BUTTON_YES ) { returnCode = MB_RET_CANCEL; goto exit; } } } if( cancelFunc ) { // Call the cancel detect callback function Boolean_t result = (*cancelFunc)( this_p ); if( result == TRUE ) { if( mbDlgYesNo( "Cancel file copy?" ) == MB_BUTTON_YES ) { returnCode = MB_RET_CANCEL; goto exit; } } } // Indicate to the calling code the file that is being copied if( fileFunc ) (*fileFunc)( this_p, file_p->name_p ); if( file_p->attrib & FA_DIREC ) { mbLog( "mbFileListCopy: descend directory: '%s' Size: %Ld\n", file_p->fullName_p, file_p->size64 ); if( file_p->sub_q ) { returnCode = mbFileListCopyRecurse( file_p->sub_q, dirCache_q, thermometer_p, this_p, cancelFunc, fileFunc, bytesFunc ); if( returnCode != MB_RET_OK ) goto exit; } } else { returnCode = mbFileListCopyFile( file_p, dirCache_q, this_p, cancelFunc, bytesFunc ); if( returnCode != MB_RET_OK ) goto exit; } } returnCode = MB_RET_OK; exit: if( buf_p ) mbFree( buf_p ); return returnCode; } //--------------------------------------------------------------------------- // Function: mbFileListCopyFile //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- Int32s_t mbFileListCopyFile ( mbFileListStruct_p file_p, qHead_p dirCache_q, Void_p this_p, Int32s_t (*cancelFunc)( Void_p this_p ), Int32s_t (*bytesFunc)( Void_p this_p, Int32u_t bytes_p ) ) { Int32s_t returnCode = MB_RET_ERR; // Need to ensure that the target directory exists if( file_p == NIL ) goto exit; if( file_p->fullName_p == NIL ) goto exit; if( file_p->target_p == NIL ) goto exit; returnCode = mbFileDirCheckCreate( file_p->target_p, dirCache_q, // Check cache for directories ( file_p->attrib & FA_DIREC ) ? FALSE : TRUE, TRUE, // Create dir if required FALSE ); // Do not prompt if( returnCode != MB_RET_OK) goto exit; // At this point, it looks like the required directory exists // Proceed with the file copy. returnCode = mbFileCopyCall( file_p->fullName_p, file_p->target_p, NIL, NIL, this_p, cancelFunc, bytesFunc ); exit: return returnCode; } //--------------------------------------------------------------------------- // Function: mbFileListDelete //--------------------------------------------------------------------------- // This function will delete all the files in the list. // It calls itself recursively //--------------------------------------------------------------------------- Int32s_t mbFileListDelete ( qHead_p file_q, Boolean_t deleteDirs ) { mbFileListStruct_p file_p; Int32s_t returnCode = MB_RET_ERR; if( file_q == NIL ) { returnCode = MB_RET_OK; goto exit; } qWalk( file_p, file_q, mbFileListStruct_p ) { if( file_p->attrib & FA_DIREC ) { // This is a diretory. Must recursively delete contents // before directory can be deleted returnCode = mbFileListDelete( file_p->sub_q, deleteDirs ); if( returnCode != MB_RET_OK ) { goto exit; } if( deleteDirs ) { // mbLog( "Delete dir '%s'\n", file_p->fullName_p ); if( RemoveDirectory( file_p->fullName_p ) == 0 ) { mbLog( "Error deleting dir '%s'\n", file_p->fullName_p ); goto exit; } } } else { // This is a file... delete // mbLog( "Delete file '%s'\n", file_p->fullName_p ); if( unlink( file_p->fullName_p ) != 0 ) { mbLog( "Error deleting file '%s'\n", file_p->fullName_p ); goto exit; } } } returnCode = MB_RET_OK; exit: return returnCode; } //--------------------------------------------------------------------------- // Function: mbFFTimeToStr //--------------------------------------------------------------------------- // ff_ftime: // // Bits 0 to 4 Seconds divided by 2 (e.g. 10 here means 20 sec) // Bits 5 to 10 Minutes // Bits 11 to 15 Hours //--------------------------------------------------------------------------- Char_p mbFFTimeToStr( Int16u_t time, Char_p str_p ) { Int16u_t seconds; Int16u_t minutes; Int16u_t hours; if( str_p == NIL ) return "NIL"; // 15 14 13 12 | 11 10 9 8 | 7 6 5 4 | 3 2 1 0 // 1 1 1 1 | 1 1 1 1 | 1 1 1 1 | 1 1 1 1 seconds = time & 0x001F; seconds *=2; minutes = time & 0x07E0; minutes >>= 5; hours = time & 0xF800; hours >>= 11; if( hours > 11 && hours != 24 ) { if( hours > 12 ) hours -= 12; sprintf( str_p, "%d:%02d PM", hours, minutes ); } else { if( hours == 24 ) hours = 12; sprintf( str_p, "%d:%02d AM", hours, minutes ); } return str_p; } //--------------------------------------------------------------------------- // Function: mbFFDateToStr //--------------------------------------------------------------------------- // ff_fdate: // // Bits 0-4 Day // Bits 5-8 Month // Bits 9-15 Years since 1980 (for example 9 here means 1989) //--------------------------------------------------------------------------- Char_p mbFFDateToStr( Int16u_t date, Char_p str_p ) { Int16u_t day; Int16u_t month; Int16u_t year; Char_p monthStr_p[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; if( str_p == NIL ) return "NIL"; // 15 14 13 12 | 11 10 9 8 | 7 6 5 4 | 3 2 1 0 // 1 1 1 1 | 1 1 1 1 | 1 1 1 1 | 1 1 1 1 day = date & 0x001F; month = date & 0x01E0; month >>= 5; if( month > 0 ) month--; if( month > 11 ) month = 11; year = date & 0xFE00; year >>= 9; sprintf( str_p, "%d %s %d", day, monthStr_p[month], year + 1980 ); return str_p; }
80c8481ce85a58de56c2615e20fce5b7e92456b1
1a735cf4019a94b27e1ab0b36eb2215e8e7a1f81
/interruption/interruption.ino
ace78e4dffb1b7c6d4d52540a9b8d831a521e672
[]
no_license
subzeroDevelopment/Arduino
4495158cc8a0a063059f5ba7a72d12c17741d677
569ef5ae2f0fd4a4ef75704d58c2875a7e8d15b6
refs/heads/master
2020-12-22T13:07:09.266247
2016-06-16T02:07:55
2016-06-16T02:07:55
61,254,419
0
0
null
null
null
null
UTF-8
C++
false
false
499
ino
long start=0; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(13,OUTPUT); pinMode(2,INPUT); digitalWrite(2,HIGH); randomSeed(millis()); delay(random(1000,3000)); digitalWrite(13,HIGH); attachInterrupt(0,react,FALLING); start=millis(); } void loop() { // put your main code here, to run repeatedly: } void react(){ long fin=millis(); detachInterrupt(0); Serial.print("tu tiempo de reaccion: "); Serial.println(fin-start); }
57994e02fb1e3e2842419283e326721503884138
8e33ac84037c33fecdd04479cd4fac451a6947e2
/c++/parser/serializer/FileSerializer.cpp
505ee2565f225f60a194692e8e89d30d7f2c3338
[]
no_license
siprikorea/framework
278e3239f004ef9efe78eab55fee03385030f6c5
3ca17a0d17a2b6fb5e8f0216b4ce08eb8713cead
refs/heads/master
2020-12-11T05:45:23.017610
2017-09-11T09:02:08
2017-09-11T09:02:08
16,749,170
0
0
null
null
null
null
UHC
C++
false
false
5,139
cpp
#include "stdafx.h" #include "FileSerializer.h" #ifdef _DEBUG #define new DEBUG_NEW #endif /************************************************************ * @brief 생성자 * @param[in] strFileName 파일 이름 * @retval 없음 ************************************************************/ CFileSerializer::CFileSerializer(CString strFileName) { // 파일 열기 m_pFile = new CFile(); m_pFile->Open(strFileName, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary); m_byTemp = 0; m_serialized_bytes = 0; m_serialized_bits = 0; } /************************************************************ * @brief 소멸자 * @retval 없음 ************************************************************/ CFileSerializer::~CFileSerializer(void) { if (m_pFile) { // 파일 핸들 있음 if (CFile::hFileNull != m_pFile->m_hFile) { // 파일 닫기 m_pFile->Close(); } delete m_pFile; m_pFile = NULL; } } /************************************************************ * @brief 데이타설정(bool) * @param[in] pVal 설정데이타 * @retval TRUE 성공 * @retval FALSE 실패 ************************************************************/ BOOL CFileSerializer::SetData(bool* pVal) { // 파일 핸들 없음 if (CFile::hFileNull == m_pFile->m_hFile) { return FALSE; } // 데이터 설정 m_byTemp |= *(BYTE*)pVal << m_serialized_bits; // Serialized Bits 설정 m_serialized_bits++; // Serialized Bits 가 Byte 단위로 되었을 경우 if (!(m_serialized_bits % 8)) { // 파일 쓰기 m_pFile->Write(&m_byTemp, sizeof(BYTE)); m_byTemp = 0; // Serialized Bits 초기화 m_serialized_bits = 0; // Serialized Bytes 설정 m_serialized_bytes += sizeof(BYTE); } return TRUE; } /************************************************************ * @brief 데이타설정(BYTE) * @param[in] pVal 설정데이타 * @retval TRUE 성공 * @retval FALSE 실패 ************************************************************/ BOOL CFileSerializer::SetData(BYTE* pVal) { // 파일 핸들 없음 if (CFile::hFileNull == m_pFile->m_hFile) { return FALSE; } m_pFile->Write(pVal, sizeof(BYTE)); m_serialized_bytes += sizeof(BYTE); return TRUE; } /************************************************************ * @brief 데이타설정(WORD) * @param[in] pVal 설정데이타 * @retval TRUE 성공 * @retval FALSE 실패 ************************************************************/ BOOL CFileSerializer::SetData(WORD* pVal) { // 파일 핸들 없음 if (CFile::hFileNull == m_pFile->m_hFile) { return FALSE; } m_pFile->Write(pVal, sizeof(WORD)); m_serialized_bytes += sizeof(WORD); return TRUE; } /************************************************************ * @brief 데이타설정(DWORD) * @param[in] pVal 설정데이타 * @retval TRUE 성공 * @retval FALSE 실패 ************************************************************/ BOOL CFileSerializer::SetData(DWORD* pVal) { // 파일 핸들 없음 if (CFile::hFileNull == m_pFile->m_hFile) { return FALSE; } m_pFile->Write(pVal, sizeof(DWORD)); m_serialized_bytes += sizeof(DWORD); return TRUE; } /************************************************************ * @brief 데이타설정(void*) * @param[in] pVal 설정데이타 * @param[in] size 설정데이타사이즈 * @retval TRUE 성공 * @retval FALSE 실패 ************************************************************/ BOOL CFileSerializer::SetData(void* pVal, int size) { // 파일 핸들 없음 if (CFile::hFileNull == m_pFile->m_hFile) { return FALSE; } m_pFile->Write(pVal, size); m_serialized_bytes += size; return TRUE; } /************************************************************ * @brief Serialize 된 바이트수 설정 * @retval int Serialize 된 바이트수 ************************************************************/ void CFileSerializer::SetSerializedBytes(int size) { m_serialized_bytes = size; } /************************************************************ * @brief Serialize 된 비트수 설정 * @retval int Serialize 된 비트수 ************************************************************/ void CFileSerializer::SetSerializedBits(int size) { m_serialized_bits = size; } /************************************************************ * @brief Serialize 된 바이트수 취득 * @retval int Serialize 된 바이트수 ************************************************************/ int CFileSerializer::GetSerializedBytes(void) { return m_serialized_bytes; } /************************************************************ * @brief Serialize 된 비트수 취득 * @retval int Serialize 된 비트수 ************************************************************/ int CFileSerializer::GetSerializedBits(void) { return m_serialized_bits; }
b8dd3fb677bb5a34d77ac80ea5d44e0fad788448
d293e25b2bd8d68cbf9c3acea1a817812f6f22b9
/folly/executors/FutureExecutor.h
32a50e8aa64d93234b9540a2779a6860f1cff4f5
[ "Apache-2.0" ]
permissive
foreverhy/folly
9c70f83754fe2272dcf5c62d7f232bbc62e1634b
8d141fc119bbb2f703d145c1a7cb70e7f6ce282f
refs/heads/master
2020-03-22T20:28:28.698576
2018-07-11T16:53:05
2018-07-11T16:53:05
140,603,392
1
0
Apache-2.0
2018-07-11T16:41:44
2018-07-11T16:41:44
null
UTF-8
C++
false
false
2,592
h
/* * Copyright 2017-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <folly/functional/Invoke.h> #include <folly/futures/Future.h> namespace folly { template <typename ExecutorImpl> class FutureExecutor : public ExecutorImpl { public: template <typename... Args> explicit FutureExecutor(Args&&... args) : ExecutorImpl(std::forward<Args>(args)...) {} /* * Given a function func that returns a Future<T>, adds that function to the * contained Executor and returns a Future<T> which will be fulfilled with * func's result once it has been executed. * * For example: auto f = futureExecutor.addFuture([](){ * return doAsyncWorkAndReturnAFuture(); * }); */ template <typename F> typename std::enable_if< folly::isFuture<invoke_result_t<F>>::value, invoke_result_t<F>>::type addFuture(F func) { using T = typename invoke_result_t<F>::value_type; folly::Promise<T> promise; auto future = promise.getFuture(); ExecutorImpl::add( [ promise = std::move(promise), func = std::move(func) ]() mutable { func().then([promise = std::move(promise)]( folly::Try<T> && t) mutable { promise.setTry(std::move(t)); }); }); return future; } /* * Similar to addFuture above, but takes a func that returns some non-Future * type T. * * For example: auto f = futureExecutor.addFuture([]() { * return 42; * }); */ template <typename F> typename std::enable_if< !folly::isFuture<invoke_result_t<F>>::value, folly::Future<typename folly::lift_unit<invoke_result_t<F>>::type>>::type addFuture(F func) { using T = typename folly::lift_unit<invoke_result_t<F>>::type; folly::Promise<T> promise; auto future = promise.getFuture(); ExecutorImpl::add( [ promise = std::move(promise), func = std::move(func) ]() mutable { promise.setWith(std::move(func)); }); return future; } }; } // namespace folly
bdf8ca07c0f5464ee166fd5ef3fa9c0c8daa4076
151eb4753e9c43f3ac4823e28f17d9fde9a71b09
/Atividade-Vetores1-13-11/Ex1-Inverter-Vetor.cpp
7414f63fedf275cbd2c14ff1374f7ad108d12e12
[]
no_license
sinn-ss/FATEC-LinguagemDeProgramacao-ADSMA2
eb9ccaf84686cd7507009c7b4c316ac1fcd9863a
ebfcdea55cb956c05534f353b5ebd16f7afee068
refs/heads/master
2023-01-18T17:42:15.972789
2020-11-29T22:18:13
2020-11-29T22:18:13
300,652,466
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,708
cpp
// Aluno: Sindel C. S. Santos // RA: 1680482011032 // Turma: ADSMA2 || Disciplina: Linguagem de Programação // ATIVIDADE VETORES1 - Entrega dia 13/11/2020 // Exercício 1 // Receber via teclado 5 valores inteiros de um vetor X em seguida exiba os valores do vetor X e // um segundo vetor Y contem os elementos de X de trás para frente #include <stdio.h> #include <stdlib.h> #include <locale.h> int main(void) { setlocale(LC_ALL, ""); int x[5], y[5], contador, aux = 4; system("cls"); system("title Inversão de Vetores"); system("mode 65,30"); system("color 0A"); printf("-----------------------------------------------------------------\n"); printf("| ##### INVERSÃO DE VETORES ##### |\n"); printf("-----------------------------------------------------------------\n\n"); for (contador = 0; contador < 5; contador++) { printf(" Informe o valor de X[%d]: ", contador); scanf("%d", &x[contador]); y[aux] = x[contador]; aux--; } printf("\n"); printf("-----------------------------------------------------------------\n"); printf("| ##### INVERSÃO ##### |\n"); printf("-----------------------------------------------------------------\n\n"); printf("VETOR ORIGINAL: \n\n"); for (contador = 0; contador < 5; contador++) { printf(" X[%d]: %d\n", contador, x[contador]); } printf("\nVETOR INVERTIDO: \n\n"); for (contador = 0; contador < 5; contador++) { printf(" Y[%d]: %d\n", contador, y[contador]); } printf("-----------------------------------------------------------------\n"); system("PAUSE"); }
a5b0f11bf31972862de1656de43ead3c44aed67b
8567438779e6af0754620a25d379c348e4cd5a5d
/components/autofill/core/browser/webdata/autofill_wallet_syncable_service.cc
8ad43337b41d94f08ec733c01d02a2a82519ce88
[ "BSD-3-Clause" ]
permissive
thngkaiyuan/chromium
c389ac4b50ccba28ee077cbf6115c41b547955ae
dab56a4a71f87f64ecc0044e97b4a8f247787a68
refs/heads/master
2022-11-10T02:50:29.326119
2017-04-08T12:28:57
2017-04-08T12:28:57
84,073,924
0
1
BSD-3-Clause
2022-10-25T19:47:15
2017-03-06T13:04:15
null
UTF-8
C++
false
false
13,746
cc
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_service.h" #include <stddef.h> #include <set> #include <utility> #include "base/logging.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/webdata/autofill_table.h" #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/sync/model/sync_error_factory.h" #include "components/sync/protocol/sync.pb.h" namespace autofill { namespace { // The length of the GUIDs used for local autofill data. It is different than // the length used for server autofill data. const int kLocalGuidSize = 36; void* UserDataKey() { // Use the address of a static so that COMDAT folding won't ever fold // with something else. static int user_data_key = 0; return reinterpret_cast<void*>(&user_data_key); } const char* CardTypeFromWalletCardType( sync_pb::WalletMaskedCreditCard::WalletCardType type) { switch (type) { case sync_pb::WalletMaskedCreditCard::AMEX: return kAmericanExpressCard; case sync_pb::WalletMaskedCreditCard::DISCOVER: return kDiscoverCard; case sync_pb::WalletMaskedCreditCard::JCB: return kJCBCard; case sync_pb::WalletMaskedCreditCard::MASTER_CARD: return kMasterCard; case sync_pb::WalletMaskedCreditCard::VISA: return kVisaCard; // These aren't supported by the client, so just declare a generic card. case sync_pb::WalletMaskedCreditCard::MAESTRO: case sync_pb::WalletMaskedCreditCard::SOLO: case sync_pb::WalletMaskedCreditCard::SWITCH: default: return kGenericCard; } } CreditCard::ServerStatus ServerToLocalStatus( sync_pb::WalletMaskedCreditCard::WalletCardStatus status) { switch (status) { case sync_pb::WalletMaskedCreditCard::VALID: return CreditCard::OK; case sync_pb::WalletMaskedCreditCard::EXPIRED: default: DCHECK_EQ(sync_pb::WalletMaskedCreditCard::EXPIRED, status); return CreditCard::EXPIRED; } } CreditCard CardFromSpecifics(const sync_pb::WalletMaskedCreditCard& card) { CreditCard result(CreditCard::MASKED_SERVER_CARD, card.id()); result.SetNumber(base::UTF8ToUTF16(card.last_four())); result.SetServerStatus(ServerToLocalStatus(card.status())); result.SetTypeForMaskedCard(CardTypeFromWalletCardType(card.type())); result.SetRawInfo(CREDIT_CARD_NAME_FULL, base::UTF8ToUTF16(card.name_on_card())); result.SetExpirationMonth(card.exp_month()); result.SetExpirationYear(card.exp_year()); result.set_billing_address_id(card.billing_address_id()); return result; } AutofillProfile ProfileFromSpecifics( const sync_pb::WalletPostalAddress& address) { AutofillProfile profile(AutofillProfile::SERVER_PROFILE, std::string()); // AutofillProfile stores multi-line addresses with newline separators. std::vector<std::string> street_address(address.street_address().begin(), address.street_address().end()); profile.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, base::UTF8ToUTF16(base::JoinString(street_address, "\n"))); profile.SetRawInfo(COMPANY_NAME, base::UTF8ToUTF16(address.company_name())); profile.SetRawInfo(ADDRESS_HOME_STATE, base::UTF8ToUTF16(address.address_1())); profile.SetRawInfo(ADDRESS_HOME_CITY, base::UTF8ToUTF16(address.address_2())); profile.SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, base::UTF8ToUTF16(address.address_3())); // AutofillProfile doesn't support address_4 ("sub dependent locality"). profile.SetRawInfo(ADDRESS_HOME_ZIP, base::UTF8ToUTF16(address.postal_code())); profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, base::UTF8ToUTF16(address.sorting_code())); profile.SetRawInfo(ADDRESS_HOME_COUNTRY, base::UTF8ToUTF16(address.country_code())); profile.set_language_code(address.language_code()); // SetInfo instead of SetRawInfo so the constituent pieces will be parsed // for these data types. profile.SetInfo(AutofillType(NAME_FULL), base::UTF8ToUTF16(address.recipient_name()), profile.language_code()); profile.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), base::UTF8ToUTF16(address.phone_number()), profile.language_code()); profile.GenerateServerProfileIdentifier(); return profile; } // This function handles conditionally updating the AutofillTable with either // a set of CreditCards or AutocompleteProfiles only when the existing data // doesn't match. // // It's passed the getter and setter function on the AutofillTable for the // corresponding data type, and expects the types to implement a Compare // function. Note that the guid can't be used here as a key since these are // generated locally and will be different each time, and the server ID can't // be used because it's empty for addresses (though it could be used for credit // cards if we wanted separate implementations). // // Returns true if anything changed. The previous number of items in the table // (for sync tracking) will be placed into *prev_item_count. template <class Data> bool SetDataIfChanged( AutofillTable* table, const std::vector<Data>& data, bool (AutofillTable::*getter)(std::vector<std::unique_ptr<Data>>*) const, void (AutofillTable::*setter)(const std::vector<Data>&), size_t* prev_item_count) { std::vector<std::unique_ptr<Data>> existing_data; (table->*getter)(&existing_data); *prev_item_count = existing_data.size(); // If the user has a large number of addresses, don't bother verifying // anything changed and just rewrite the data. const size_t kTooBigToCheckThreshold = 8; bool difference_found; if (existing_data.size() != data.size() || data.size() > kTooBigToCheckThreshold) { difference_found = true; } else { difference_found = false; // Implement brute-force searching. Address and card counts are typically // small, and comparing them is relatively expensive (many string // compares). A std::set only uses operator< requiring multiple calls to // check equality, giving 8 compares for 2 elements and 16 for 3. For these // set sizes, brute force O(n^2) is faster. for (const auto& cur_existing : existing_data) { bool found_match_for_cur_existing = false; for (const Data& cur_new : data) { if (cur_existing->Compare(cur_new) == 0) { found_match_for_cur_existing = true; break; } } if (!found_match_for_cur_existing) { difference_found = true; break; } } } if (difference_found) { (table->*setter)(data); return true; } return false; } } // namespace AutofillWalletSyncableService::AutofillWalletSyncableService( AutofillWebDataBackend* webdata_backend, const std::string& app_locale) : webdata_backend_(webdata_backend) { } AutofillWalletSyncableService::~AutofillWalletSyncableService() { } syncer::SyncMergeResult AutofillWalletSyncableService::MergeDataAndStartSyncing( syncer::ModelType type, const syncer::SyncDataList& initial_sync_data, std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, std::unique_ptr<syncer::SyncErrorFactory> sync_error_factory) { DCHECK(thread_checker_.CalledOnValidThread()); sync_processor_ = std::move(sync_processor); syncer::SyncMergeResult result = SetSyncData(initial_sync_data); if (webdata_backend_) webdata_backend_->NotifyThatSyncHasStarted(type); return result; } void AutofillWalletSyncableService::StopSyncing(syncer::ModelType type) { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_EQ(type, syncer::AUTOFILL_WALLET_DATA); sync_processor_.reset(); } syncer::SyncDataList AutofillWalletSyncableService::GetAllSyncData( syncer::ModelType type) const { DCHECK(thread_checker_.CalledOnValidThread()); // This data type is never synced "up" so we don't need to implement this. syncer::SyncDataList current_data; return current_data; } syncer::SyncError AutofillWalletSyncableService::ProcessSyncChanges( const tracked_objects::Location& from_here, const syncer::SyncChangeList& change_list) { DCHECK(thread_checker_.CalledOnValidThread()); // Don't bother handling incremental updates. Wallet data changes very rarely // and has few items. Instead, just get all the current data and save it. SetSyncData(sync_processor_->GetAllSyncData(syncer::AUTOFILL_WALLET_DATA)); return syncer::SyncError(); } // static void AutofillWalletSyncableService::CreateForWebDataServiceAndBackend( AutofillWebDataService* web_data_service, AutofillWebDataBackend* webdata_backend, const std::string& app_locale) { web_data_service->GetDBUserData()->SetUserData( UserDataKey(), new AutofillWalletSyncableService(webdata_backend, app_locale)); } // static AutofillWalletSyncableService* AutofillWalletSyncableService::FromWebDataService( AutofillWebDataService* web_data_service) { return static_cast<AutofillWalletSyncableService*>( web_data_service->GetDBUserData()->GetUserData(UserDataKey())); } void AutofillWalletSyncableService::InjectStartSyncFlare( const syncer::SyncableService::StartSyncFlare& flare) { flare_ = flare; } // static void AutofillWalletSyncableService::PopulateWalletCardsAndAddresses( const syncer::SyncDataList& data_list, std::vector<CreditCard>* wallet_cards, std::vector<AutofillProfile>* wallet_addresses) { std::map<std::string, std::string> ids; for (const syncer::SyncData& data : data_list) { DCHECK_EQ(syncer::AUTOFILL_WALLET_DATA, data.GetDataType()); const sync_pb::AutofillWalletSpecifics& autofill_specifics = data.GetSpecifics().autofill_wallet(); if (autofill_specifics.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) { wallet_cards->push_back( CardFromSpecifics(autofill_specifics.masked_card())); } else { DCHECK_EQ(sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS, autofill_specifics.type()); wallet_addresses->push_back( ProfileFromSpecifics(autofill_specifics.address())); // Map the sync billing address id to the profile's id. ids[autofill_specifics.address().id()] = wallet_addresses->back().server_id(); } } // Set the billing address of the wallet cards to the id of the appropriate // profile. for (CreditCard& card : *wallet_cards) { auto it = ids.find(card.billing_address_id()); if (it != ids.end()) card.set_billing_address_id(it->second); } } // static void AutofillWalletSyncableService::CopyRelevantBillingAddressesFromDisk( const AutofillTable& table, std::vector<CreditCard>* cards_from_server) { std::vector<std::unique_ptr<CreditCard>> cards_on_disk; table.GetServerCreditCards(&cards_on_disk); // The reasons behind brute-force search are explained in SetDataIfChanged. for (const auto& saved_card : cards_on_disk) { for (CreditCard& server_card : *cards_from_server) { if (saved_card->server_id() == server_card.server_id()) { // Keep the billing address id of the saved cards only if it points to // a local address. if (saved_card->billing_address_id().length() == kLocalGuidSize) { server_card.set_billing_address_id(saved_card->billing_address_id()); break; } } } } } syncer::SyncMergeResult AutofillWalletSyncableService::SetSyncData( const syncer::SyncDataList& data_list) { std::vector<CreditCard> wallet_cards; std::vector<AutofillProfile> wallet_addresses; PopulateWalletCardsAndAddresses(data_list, &wallet_cards, &wallet_addresses); // Users can set billing address of the server credit card locally, but that // information does not propagate to either Chrome Sync or Google Payments // server. To preserve user's preferred billing address, copy the billing // addresses from disk into |wallet_cards|. AutofillTable* table = AutofillTable::FromWebDatabase(webdata_backend_->GetDatabase()); CopyRelevantBillingAddressesFromDisk(*table, &wallet_cards); // In the common case, the database won't have changed. Committing an update // to the database will require at least one DB page write and will schedule // a fsync. To avoid this I/O, it should be more efficient to do a read and // only do the writes if something changed. size_t prev_card_count = 0; size_t prev_address_count = 0; bool changed_cards = SetDataIfChanged( table, wallet_cards, &AutofillTable::GetServerCreditCards, &AutofillTable::SetServerCreditCards, &prev_card_count); bool changed_addresses = SetDataIfChanged( table, wallet_addresses, &AutofillTable::GetServerProfiles, &AutofillTable::SetServerProfiles, &prev_address_count); syncer::SyncMergeResult merge_result(syncer::AUTOFILL_WALLET_DATA); merge_result.set_num_items_before_association( static_cast<int>(prev_card_count + prev_address_count)); merge_result.set_num_items_after_association( static_cast<int>(wallet_cards.size() + wallet_addresses.size())); if (webdata_backend_ && (changed_cards || changed_addresses)) webdata_backend_->NotifyOfMultipleAutofillChanges(); return merge_result; } } // namespace autofil
34df35e0582cdd4bc810d4b11385a7661a432f09
8010df1fef10ddfd83bf07966cbf7e2e4b0d7ee9
/include/winsdk/winrt/Windows.ApplicationModel.VoiceCommands.h
4d30cec0db79c1925cfcdbc13ada8caed9dbb535
[]
no_license
light-tech/MSCpp
a23ab987b7e12329ab2d418b06b6b8055bde5ca2
012631b58c402ceec73c73d2bda443078bc151ef
refs/heads/master
2022-12-26T23:51:21.686396
2020-10-15T13:40:34
2020-10-15T13:40:34
188,921,341
6
0
null
null
null
null
UTF-8
C++
false
false
278,231
h
#pragma warning( disable: 4049 ) /* more than 64k source lines */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 500 #endif /* verify that the <rpcsal.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCSAL_H_VERSION__ #define __REQUIRED_RPCSAL_H_VERSION__ 100 #endif #include <rpc.h> #include <rpcndr.h> #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif /* __RPCNDR_H_VERSION__ */ #ifndef COM_NO_WINDOWS_H #include <windows.h> #include <ole2.h> #endif /*COM_NO_WINDOWS_H*/ #ifndef __windows2Eapplicationmodel2Evoicecommands_h__ #define __windows2Eapplicationmodel2Evoicecommands_h__ #ifndef __windows2Eapplicationmodel2Evoicecommands_p_h__ #define __windows2Eapplicationmodel2Evoicecommands_p_h__ #pragma once // // Deprecated attribute support // #pragma push_macro("DEPRECATED") #undef DEPRECATED #if !defined(DISABLE_WINRT_DEPRECATION) #if defined(__cplusplus) #if __cplusplus >= 201402 #define DEPRECATED(x) [[deprecated(x)]] #define DEPRECATEDENUMERATOR(x) [[deprecated(x)]] #elif defined(_MSC_VER) #if _MSC_VER >= 1900 #define DEPRECATED(x) [[deprecated(x)]] #define DEPRECATEDENUMERATOR(x) [[deprecated(x)]] #else #define DEPRECATED(x) __declspec(deprecated(x)) #define DEPRECATEDENUMERATOR(x) #endif // _MSC_VER >= 1900 #else // Not Standard C++ or MSVC, ignore the construct. #define DEPRECATED(x) #define DEPRECATEDENUMERATOR(x) #endif // C++ deprecation #else // C - disable deprecation #define DEPRECATED(x) #define DEPRECATEDENUMERATOR(x) #endif #else // Deprecation is disabled #define DEPRECATED(x) #define DEPRECATEDENUMERATOR(x) #endif /* DEPRECATED */ // Disable Deprecation for this header, MIDL verifies that cross-type access is acceptable #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" #else #pragma warning(push) #pragma warning(disable: 4996) #endif // Ensure that the setting of the /ns_prefix command line switch is consistent for all headers. // If you get an error from the compiler indicating "warning C4005: 'CHECK_NS_PREFIX_STATE': macro redefinition", this // indicates that you have included two different headers with different settings for the /ns_prefix MIDL command line switch #if !defined(DISABLE_NS_PREFIX_CHECKS) #define CHECK_NS_PREFIX_STATE "always" #endif // !defined(DISABLE_NS_PREFIX_CHECKS) #pragma push_macro("MIDL_CONST_ID") #undef MIDL_CONST_ID #define MIDL_CONST_ID const __declspec(selectany) // API Contract Inclusion Definitions #if !defined(SPECIFIC_API_CONTRACT_DEFINITIONS) #if !defined(WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION) #define WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION 0x40000 #endif // defined(WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION) #if !defined(WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION) #define WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION 0xa0000 #endif // defined(WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION) #if !defined(WINDOWS_GLOBALIZATION_GLOBALIZATIONJAPANESEPHONETICANALYZERCONTRACT_VERSION) #define WINDOWS_GLOBALIZATION_GLOBALIZATIONJAPANESEPHONETICANALYZERCONTRACT_VERSION 0x10000 #endif // defined(WINDOWS_GLOBALIZATION_GLOBALIZATIONJAPANESEPHONETICANALYZERCONTRACT_VERSION) #endif // defined(SPECIFIC_API_CONTRACT_DEFINITIONS) // Header files for imported files #include "inspectable.h" #include "AsyncInfo.h" #include "EventToken.h" #include "windowscontracts.h" #include "Windows.Foundation.h" #include "Windows.ApplicationModel.AppService.h" #include "Windows.Globalization.h" #include "Windows.Media.SpeechRecognition.h" #include "Windows.Storage.h" // Importing Collections header #include <windows.foundation.collections.h> #if defined(__cplusplus) && !defined(CINTERFACE) /* Forward Declarations */ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommand; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommand #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandCompletedEventArgs; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandCompletedEventArgs #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandConfirmationResult; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandConfirmationResult #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandContentTile; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandContentTile #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandDefinition; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandDefinition #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandDefinitionManagerStatics; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandDefinitionManagerStatics #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandDisambiguationResult; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandDisambiguationResult #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandResponse; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandResponseStatics; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponseStatics #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandServiceConnection; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandServiceConnection #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandServiceConnectionStatics; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandServiceConnectionStatics #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { interface IVoiceCommandUserMessage; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_FWD_DEFINED__ // Parameterized interface forward declarations (C++) // Collection interface definitions namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { class VoiceCommand; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_USE #define DEF___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { template <> struct __declspec(uuid("815f1854-4d79-570d-9b57-5b47e282cd66")) IAsyncOperation<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommand*> : IAsyncOperation_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommand*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommand*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.IAsyncOperation`1<Windows.ApplicationModel.VoiceCommands.VoiceCommand>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IAsyncOperation<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommand*> __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_t; #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand ABI::Windows::Foundation::__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_t /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_USE #define DEF___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { template <> struct __declspec(uuid("1024f849-b4a1-52e6-b771-6d2f08c30e63")) IAsyncOperationCompletedHandler<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommand*> : IAsyncOperationCompletedHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommand*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommand*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.AsyncOperationCompletedHandler`1<Windows.ApplicationModel.VoiceCommands.VoiceCommand>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IAsyncOperationCompletedHandler<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommand*> __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_t; #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand ABI::Windows::Foundation::__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_t /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { class VoiceCommandConfirmationResult; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_USE #define DEF___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { template <> struct __declspec(uuid("3b39db5f-d2a4-5d88-851f-e9a0ea0d947e")) IAsyncOperation<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandConfirmationResult*> : IAsyncOperation_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandConfirmationResult*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandConfirmationResult*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.IAsyncOperation`1<Windows.ApplicationModel.VoiceCommands.VoiceCommandConfirmationResult>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IAsyncOperation<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandConfirmationResult*> __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_t; #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult ABI::Windows::Foundation::__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_t /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_USE #define DEF___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { template <> struct __declspec(uuid("f5244cb8-f912-50c9-b218-d7a0403971aa")) IAsyncOperationCompletedHandler<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandConfirmationResult*> : IAsyncOperationCompletedHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandConfirmationResult*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandConfirmationResult*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.AsyncOperationCompletedHandler`1<Windows.ApplicationModel.VoiceCommands.VoiceCommandConfirmationResult>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IAsyncOperationCompletedHandler<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandConfirmationResult*> __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_t; #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult ABI::Windows::Foundation::__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_t /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { class VoiceCommandDisambiguationResult; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_USE #define DEF___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { template <> struct __declspec(uuid("b03d44c8-060f-5b98-953a-fd1eb1d46abc")) IAsyncOperation<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDisambiguationResult*> : IAsyncOperation_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDisambiguationResult*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandDisambiguationResult*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.IAsyncOperation`1<Windows.ApplicationModel.VoiceCommands.VoiceCommandDisambiguationResult>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IAsyncOperation<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDisambiguationResult*> __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_t; #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult ABI::Windows::Foundation::__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_t /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_USE #define DEF___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { template <> struct __declspec(uuid("46b96890-2942-5564-82d8-31a4851bd7b8")) IAsyncOperationCompletedHandler<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDisambiguationResult*> : IAsyncOperationCompletedHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDisambiguationResult*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandDisambiguationResult*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.AsyncOperationCompletedHandler`1<Windows.ApplicationModel.VoiceCommands.VoiceCommandDisambiguationResult>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IAsyncOperationCompletedHandler<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDisambiguationResult*> __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_t; #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult ABI::Windows::Foundation::__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_t /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIIterator_1_HSTRING_USE #define DEF___FIIterator_1_HSTRING_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("8c304ebb-6615-50a4-8829-879ecd443236")) IIterator<HSTRING> : IIterator_impl<HSTRING> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IIterator`1<String>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IIterator<HSTRING> __FIIterator_1_HSTRING_t; #define __FIIterator_1_HSTRING ABI::Windows::Foundation::Collections::__FIIterator_1_HSTRING_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIIterator_1_HSTRING_USE */ #ifndef DEF___FIIterable_1_HSTRING_USE #define DEF___FIIterable_1_HSTRING_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("e2fcc7c1-3bfc-5a0b-b2b0-72e769d1cb7e")) IIterable<HSTRING> : IIterable_impl<HSTRING> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IIterable`1<String>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IIterable<HSTRING> __FIIterable_1_HSTRING_t; #define __FIIterable_1_HSTRING ABI::Windows::Foundation::Collections::__FIIterable_1_HSTRING_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIIterable_1_HSTRING_USE */ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { class VoiceCommandContentTile; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE #define DEF___FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("968d589c-0710-52f0-85ed-112fac4cff35")) IIterator<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*> : IIterator_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandContentTile*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IIterator`1<Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTile>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IIterator<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*> __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_t; #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile ABI::Windows::Foundation::Collections::__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE #define DEF___FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("bd13249b-8099-5573-bf74-7457796e92e5")) IIterable<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*> : IIterable_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandContentTile*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IIterable`1<Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTile>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IIterable<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*> __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_t; #define __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile ABI::Windows::Foundation::Collections::__FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { class VoiceCommandDefinition; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE #define DEF___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("a932bfda-2ce5-5012-ae83-f397976e4a86")) IKeyValuePair<HSTRING, ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDefinition*> : IKeyValuePair_impl<HSTRING, ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDefinition*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandDefinition*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IKeyValuePair`2<String, Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IKeyValuePair<HSTRING, ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDefinition*> __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_t; #define __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition ABI::Windows::Foundation::Collections::__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE #define DEF___FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("91fbb58b-fb9c-5165-a1bf-815d2767300d")) IIterator<__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition*> : IIterator_impl<__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition*> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IIterator`1<Windows.Foundation.Collections.IKeyValuePair`2<String, Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition>>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IIterator<__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition*> __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_t; #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition ABI::Windows::Foundation::Collections::__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE #define DEF___FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("67693dd1-ac45-5ef3-9ba6-4d78709d9ee0")) IIterable<__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition*> : IIterable_impl<__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition*> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IIterable`1<Windows.Foundation.Collections.IKeyValuePair`2<String, Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition>>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IIterable<__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition*> __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_t; #define __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition ABI::Windows::Foundation::Collections::__FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIVectorView_1_HSTRING_USE #define DEF___FIVectorView_1_HSTRING_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("2f13c006-a03a-5f69-b090-75a43e33423e")) IVectorView<HSTRING> : IVectorView_impl<HSTRING> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IVectorView`1<String>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IVectorView<HSTRING> __FIVectorView_1_HSTRING_t; #define __FIVectorView_1_HSTRING ABI::Windows::Foundation::Collections::__FIVectorView_1_HSTRING_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIVectorView_1_HSTRING_USE */ #ifndef DEF___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_USE #define DEF___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("bcde03ad-ea71-5077-a961-1c0ecff57202")) IKeyValuePair<HSTRING, __FIVectorView_1_HSTRING*> : IKeyValuePair_impl<HSTRING, __FIVectorView_1_HSTRING*> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IKeyValuePair`2<String, Windows.Foundation.Collections.IVectorView`1<String>>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IKeyValuePair<HSTRING, __FIVectorView_1_HSTRING*> __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_t; #define __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING ABI::Windows::Foundation::Collections::__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_USE */ #ifndef DEF___FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_USE #define DEF___FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("643b6d83-457e-5a43-800f-b0449f91d96b")) IIterator<__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING*> : IIterator_impl<__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING*> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IIterator`1<Windows.Foundation.Collections.IKeyValuePair`2<String, Windows.Foundation.Collections.IVectorView`1<String>>>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IIterator<__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING*> __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_t; #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING ABI::Windows::Foundation::Collections::__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_USE */ #ifndef DEF___FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_USE #define DEF___FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("a4cd6151-2cc1-56f1-9014-df6ba3410beb")) IIterable<__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING*> : IIterable_impl<__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING*> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IIterable`1<Windows.Foundation.Collections.IKeyValuePair`2<String, Windows.Foundation.Collections.IVectorView`1<String>>>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IIterable<__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING*> __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_t; #define __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING ABI::Windows::Foundation::Collections::__FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_USE */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE #define DEF___FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("4c1168f0-a0b2-5312-b99a-471abd334e85")) IMapView<HSTRING, ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDefinition*> : IMapView_impl<HSTRING, ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDefinition*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandDefinition*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IMapView`2<String, Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IMapView<HSTRING, ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandDefinition*> __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_t; #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition ABI::Windows::Foundation::Collections::__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIMapView_2_HSTRING___FIVectorView_1_HSTRING_USE #define DEF___FIMapView_2_HSTRING___FIVectorView_1_HSTRING_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("2843d34f-d3e5-5fca-9fdc-b568dd5c1e64")) IMapView<HSTRING, __FIVectorView_1_HSTRING*> : IMapView_impl<HSTRING, __FIVectorView_1_HSTRING*> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IMapView`2<String, Windows.Foundation.Collections.IVectorView`1<String>>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IMapView<HSTRING, __FIVectorView_1_HSTRING*> __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_t; #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING ABI::Windows::Foundation::Collections::__FIMapView_2_HSTRING___FIVectorView_1_HSTRING_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIMapView_2_HSTRING___FIVectorView_1_HSTRING_USE */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE #define DEF___FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("cb2c6693-1fc9-5b95-99b5-7239679619b9")) IVectorView<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*> : IVectorView_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandContentTile*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IVectorView`1<Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTile>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IVectorView<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*> __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_t; #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile ABI::Windows::Foundation::Collections::__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE #define DEF___FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("e45fe700-ea08-5172-b88c-c4b3e048c3e8")) IVector<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*> : IVector_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandContentTile*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IVector`1<Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTile>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IVector<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTile*> __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_t; #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile ABI::Windows::Foundation::Collections::__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { class VoiceCommandServiceConnection; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { class VoiceCommandCompletedEventArgs; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef DEF___FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_USE #define DEF___FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { template <> struct __declspec(uuid("780a6352-b400-5767-993b-90875710d937")) ITypedEventHandler<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandServiceConnection*, ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandCompletedEventArgs*> : ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandServiceConnection*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandServiceConnection*>, ABI::Windows::Foundation::Internal::AggregateType<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandCompletedEventArgs*, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandCompletedEventArgs*>> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.TypedEventHandler`2<Windows.ApplicationModel.VoiceCommands.VoiceCommandServiceConnection, Windows.ApplicationModel.VoiceCommands.VoiceCommandCompletedEventArgs>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef ITypedEventHandler<ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandServiceConnection*, ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandCompletedEventArgs*> __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_t; #define __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_t /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_USE */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 namespace ABI { namespace Windows { namespace ApplicationModel { namespace AppService { class AppServiceTriggerDetails; } /* AppService */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #ifndef ____x_ABI_CWindows_CApplicationModel_CAppService_CIAppServiceTriggerDetails_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CAppService_CIAppServiceTriggerDetails_FWD_DEFINED__ namespace ABI { namespace Windows { namespace ApplicationModel { namespace AppService { interface IAppServiceTriggerDetails; } /* AppService */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CApplicationModel_CAppService_CIAppServiceTriggerDetails ABI::Windows::ApplicationModel::AppService::IAppServiceTriggerDetails #endif // ____x_ABI_CWindows_CApplicationModel_CAppService_CIAppServiceTriggerDetails_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CFoundation_CIAsyncAction_FWD_DEFINED__ #define ____x_ABI_CWindows_CFoundation_CIAsyncAction_FWD_DEFINED__ namespace ABI { namespace Windows { namespace Foundation { interface IAsyncAction; } /* Foundation */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CFoundation_CIAsyncAction ABI::Windows::Foundation::IAsyncAction #endif // ____x_ABI_CWindows_CFoundation_CIAsyncAction_FWD_DEFINED__ namespace ABI { namespace Windows { namespace Globalization { class Language; } /* Globalization */ } /* Windows */ } /* ABI */ #ifndef ____x_ABI_CWindows_CGlobalization_CILanguage_FWD_DEFINED__ #define ____x_ABI_CWindows_CGlobalization_CILanguage_FWD_DEFINED__ namespace ABI { namespace Windows { namespace Globalization { interface ILanguage; } /* Globalization */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CGlobalization_CILanguage ABI::Windows::Globalization::ILanguage #endif // ____x_ABI_CWindows_CGlobalization_CILanguage_FWD_DEFINED__ namespace ABI { namespace Windows { namespace Media { namespace SpeechRecognition { class SpeechRecognitionResult; } /* SpeechRecognition */ } /* Media */ } /* Windows */ } /* ABI */ #ifndef ____x_ABI_CWindows_CMedia_CSpeechRecognition_CISpeechRecognitionResult_FWD_DEFINED__ #define ____x_ABI_CWindows_CMedia_CSpeechRecognition_CISpeechRecognitionResult_FWD_DEFINED__ namespace ABI { namespace Windows { namespace Media { namespace SpeechRecognition { interface ISpeechRecognitionResult; } /* SpeechRecognition */ } /* Media */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CMedia_CSpeechRecognition_CISpeechRecognitionResult ABI::Windows::Media::SpeechRecognition::ISpeechRecognitionResult #endif // ____x_ABI_CWindows_CMedia_CSpeechRecognition_CISpeechRecognitionResult_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CStorage_CIStorageFile_FWD_DEFINED__ #define ____x_ABI_CWindows_CStorage_CIStorageFile_FWD_DEFINED__ namespace ABI { namespace Windows { namespace Storage { interface IStorageFile; } /* Storage */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CStorage_CIStorageFile ABI::Windows::Storage::IStorageFile #endif // ____x_ABI_CWindows_CStorage_CIStorageFile_FWD_DEFINED__ namespace ABI { namespace Windows { namespace Storage { class StorageFile; } /* Storage */ } /* Windows */ } /* ABI */ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { typedef enum VoiceCommandCompletionReason : int VoiceCommandCompletionReason; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { typedef enum VoiceCommandContentTileType : int VoiceCommandContentTileType; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { class VoiceCommandResponse; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { class VoiceCommandUserMessage; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ /* * * Struct Windows.ApplicationModel.VoiceCommands.VoiceCommandCompletionReason * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { enum VoiceCommandCompletionReason : int { VoiceCommandCompletionReason_Unknown = 0, VoiceCommandCompletionReason_CommunicationFailed = 1, VoiceCommandCompletionReason_ResourceLimitsExceeded = 2, VoiceCommandCompletionReason_Canceled = 3, VoiceCommandCompletionReason_TimeoutExceeded = 4, VoiceCommandCompletionReason_AppLaunched = 5, VoiceCommandCompletionReason_Completed = 6, }; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Struct Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTileType * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { enum VoiceCommandContentTileType : int { VoiceCommandContentTileType_TitleOnly = 0, VoiceCommandContentTileType_TitleWithText = 1, VoiceCommandContentTileType_TitleWith68x68Icon = 2, VoiceCommandContentTileType_TitleWith68x68IconAndText = 3, VoiceCommandContentTileType_TitleWith68x92Icon = 4, VoiceCommandContentTileType_TitleWith68x92IconAndText = 5, VoiceCommandContentTileType_TitleWith280x140Icon = 6, VoiceCommandContentTileType_TitleWith280x140IconAndText = 7, }; } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommand * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommand * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommand[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommand"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("936f5273-ec82-42a6-a55c-d2d79ec6f920") IVoiceCommand : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_CommandName( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_Properties( __FIMapView_2_HSTRING___FIVectorView_1_HSTRING** value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_SpeechRecognitionResult( ABI::Windows::Media::SpeechRecognition::ISpeechRecognitionResult** value ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommand = _uuidof(IVoiceCommand); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandCompletedEventArgs * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandCompletedEventArgs * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandCompletedEventArgs[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandCompletedEventArgs"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("c85e675d-fe42-432c-9907-09df9fcf64e8") IVoiceCommandCompletedEventArgs : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_Reason( ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandCompletionReason* value ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandCompletedEventArgs = _uuidof(IVoiceCommandCompletedEventArgs); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandConfirmationResult * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandConfirmationResult * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandConfirmationResult[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandConfirmationResult"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("a022593e-8221-4526-b083-840972262247") IVoiceCommandConfirmationResult : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_Confirmed( boolean* value ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandConfirmationResult = _uuidof(IVoiceCommandConfirmationResult); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandContentTile * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandContentTile[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandContentTile"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("3eefe9f0-b8c7-4c76-a0de-1607895ee327") IVoiceCommandContentTile : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_Title( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_Title( HSTRING value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_TextLine1( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_TextLine1( HSTRING value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_TextLine2( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_TextLine2( HSTRING value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_TextLine3( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_TextLine3( HSTRING value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_Image( ABI::Windows::Storage::IStorageFile** value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_Image( ABI::Windows::Storage::IStorageFile* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_AppContext( IInspectable** value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_AppContext( IInspectable* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_AppLaunchArgument( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_AppLaunchArgument( HSTRING value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_ContentTileType( ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTileType* value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_ContentTileType( ABI::Windows::ApplicationModel::VoiceCommands::VoiceCommandContentTileType value ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandContentTile = _uuidof(IVoiceCommandContentTile); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinition * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandDefinition[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinition"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("7972aad0-0974-4979-984b-cb8959cd61ae") IVoiceCommandDefinition : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_Language( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_Name( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE SetPhraseListAsync( HSTRING phraseListName, __FIIterable_1_HSTRING* phraseList, ABI::Windows::Foundation::IAsyncAction** updateAction ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandDefinition = _uuidof(IVoiceCommandDefinition); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinitionManagerStatics * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandDefinitionManagerStatics[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinitionManagerStatics"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("8fe7a69e-067e-4f16-a18c-5b17e9499940") IVoiceCommandDefinitionManagerStatics : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE InstallCommandDefinitionsFromStorageFileAsync( ABI::Windows::Storage::IStorageFile* file, ABI::Windows::Foundation::IAsyncAction** installAction ) = 0; virtual HRESULT STDMETHODCALLTYPE get_InstalledCommandDefinitions( __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition** voiceCommandDefinitions ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandDefinitionManagerStatics = _uuidof(IVoiceCommandDefinitionManagerStatics); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandDisambiguationResult * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandDisambiguationResult * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandDisambiguationResult[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandDisambiguationResult"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("ecc68cfe-c9ac-45df-a8ea-feea08ef9c5e") IVoiceCommandDisambiguationResult : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_SelectedItem( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandContentTile** value ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandDisambiguationResult = _uuidof(IVoiceCommandDisambiguationResult); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponse * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandResponse * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandResponse[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponse"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("0284b30e-8a3b-4cc4-a6a1-cad5be2716b5") IVoiceCommandResponse : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_Message( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage** value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_Message( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_RepeatMessage( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage** value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_RepeatMessage( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_AppLaunchArgument( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_AppLaunchArgument( HSTRING value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_VoiceCommandContentTiles( __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile** value ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandResponse = _uuidof(IVoiceCommandResponse); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponseStatics * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandResponse * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandResponseStatics[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponseStatics"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("2932f813-0d3b-49f2-96dd-625019bd3b5d") IVoiceCommandResponseStatics : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_MaxSupportedVoiceCommandContentTiles( UINT32* value ) = 0; virtual HRESULT STDMETHODCALLTYPE CreateResponse( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage* userMessage, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse** response ) = 0; virtual HRESULT STDMETHODCALLTYPE CreateResponseWithTiles( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage* message, __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* contentTiles, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse** response ) = 0; virtual HRESULT STDMETHODCALLTYPE CreateResponseForPrompt( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage* message, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage* repeatMessage, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse** response ) = 0; virtual HRESULT STDMETHODCALLTYPE CreateResponseForPromptWithTiles( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage* message, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandUserMessage* repeatMessage, __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* contentTiles, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse** response ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandResponseStatics = _uuidof(IVoiceCommandResponseStatics); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnection * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandServiceConnection * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandServiceConnection[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnection"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("d894bb9f-21da-44a4-98a2-fb131920a9cc") IVoiceCommandServiceConnection : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE GetVoiceCommandAsync( __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand** operation ) = 0; virtual HRESULT STDMETHODCALLTYPE RequestConfirmationAsync( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse* response, __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult** operation ) = 0; virtual HRESULT STDMETHODCALLTYPE RequestDisambiguationAsync( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse* response, __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult** operation ) = 0; virtual HRESULT STDMETHODCALLTYPE ReportProgressAsync( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse* response, ABI::Windows::Foundation::IAsyncAction** action ) = 0; virtual HRESULT STDMETHODCALLTYPE ReportSuccessAsync( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse* response, ABI::Windows::Foundation::IAsyncAction** action ) = 0; virtual HRESULT STDMETHODCALLTYPE ReportFailureAsync( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse* response, ABI::Windows::Foundation::IAsyncAction** action ) = 0; virtual HRESULT STDMETHODCALLTYPE RequestAppLaunchAsync( ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandResponse* response, ABI::Windows::Foundation::IAsyncAction** action ) = 0; virtual HRESULT STDMETHODCALLTYPE get_Language( ABI::Windows::Globalization::ILanguage** language ) = 0; virtual HRESULT STDMETHODCALLTYPE add_VoiceCommandCompleted( __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs* handler, EventRegistrationToken* token ) = 0; virtual HRESULT STDMETHODCALLTYPE remove_VoiceCommandCompleted( EventRegistrationToken token ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandServiceConnection = _uuidof(IVoiceCommandServiceConnection); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnectionStatics * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandServiceConnection * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandServiceConnectionStatics[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnectionStatics"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("370ebffb-2d34-42df-8770-074d0f334697") IVoiceCommandServiceConnectionStatics : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE FromAppServiceTriggerDetails( ABI::Windows::ApplicationModel::AppService::IAppServiceTriggerDetails* triggerDetails, ABI::Windows::ApplicationModel::VoiceCommands::IVoiceCommandServiceConnection** value ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandServiceConnectionStatics = _uuidof(IVoiceCommandServiceConnectionStatics); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandUserMessage * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandUserMessage * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandUserMessage[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandUserMessage"; namespace ABI { namespace Windows { namespace ApplicationModel { namespace VoiceCommands { MIDL_INTERFACE("674eb3c0-44f6-4f07-b979-4c723fc08597") IVoiceCommandUserMessage : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_DisplayMessage( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_DisplayMessage( HSTRING value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_SpokenMessage( HSTRING* value ) = 0; virtual HRESULT STDMETHODCALLTYPE put_SpokenMessage( HSTRING value ) = 0; }; extern MIDL_CONST_ID IID& IID_IVoiceCommandUserMessage = _uuidof(IVoiceCommandUserMessage); } /* VoiceCommands */ } /* ApplicationModel */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommand * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommand ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommand_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommand_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommand[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommand"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandCompletedEventArgs * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandCompletedEventArgs ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandCompletedEventArgs_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandCompletedEventArgs_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandCompletedEventArgs[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandCompletedEventArgs"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandConfirmationResult * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandConfirmationResult ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandConfirmationResult_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandConfirmationResult_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandConfirmationResult[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandConfirmationResult"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTile * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * RuntimeClass can be activated. * Type can be activated via RoActivateInstance starting with version 1.0 of the Windows.Foundation.UniversalApiContract API contract * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandContentTile ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandContentTile_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandContentTile_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandContentTile[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTile"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinition ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinition_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinition_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinition[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * RuntimeClass contains static methods. * Static Methods exist on the Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinitionManagerStatics interface starting with version 1.0 of the Windows.Foundation.UniversalApiContract API contract * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinitionManager_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinitionManager_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinitionManager[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandDisambiguationResult * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandDisambiguationResult ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDisambiguationResult_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDisambiguationResult_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandDisambiguationResult[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandDisambiguationResult"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandResponse * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * RuntimeClass contains static methods. * Static Methods exist on the Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponseStatics interface starting with version 1.0 of the Windows.Foundation.UniversalApiContract API contract * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponse ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandResponse_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandResponse_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandResponse[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandResponse"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandServiceConnection * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * RuntimeClass contains static methods. * Static Methods exist on the Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnectionStatics interface starting with version 1.0 of the Windows.Foundation.UniversalApiContract API contract * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnection ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandServiceConnection_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandServiceConnection_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandServiceConnection[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandServiceConnection"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandUserMessage * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * RuntimeClass can be activated. * Type can be activated via RoActivateInstance starting with version 1.0 of the Windows.Foundation.UniversalApiContract API contract * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandUserMessage ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandUserMessage_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandUserMessage_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandUserMessage[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandUserMessage"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #else // !defined(__cplusplus) /* Forward Declarations */ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage; #endif // ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_FWD_DEFINED__ // Parameterized interface forward declarations (C) // Collection interface definitions typedef interface __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand; #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_INTERFACE_DEFINED__) #define ____FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_INTERFACE_DEFINED__ typedef interface __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand; typedef struct __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This); ULONG (STDMETHODCALLTYPE* Release)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* put_Completed)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This, __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* handler); HRESULT (STDMETHODCALLTYPE* get_Completed)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This, __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand** result); HRESULT (STDMETHODCALLTYPE* GetResults)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand** result); END_INTERFACE } __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandVtbl; interface __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand { CONST_VTBL struct __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_put_Completed(This, handler) \ ((This)->lpVtbl->put_Completed(This, handler)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_get_Completed(This, result) \ ((This)->lpVtbl->get_Completed(This, result)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_GetResults(This, result) \ ((This)->lpVtbl->GetResults(This, result)) #endif /* COBJMACROS */ #endif // ____FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_INTERFACE_DEFINED__) #define ____FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_INTERFACE_DEFINED__ typedef interface __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand; typedef struct __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This); ULONG (STDMETHODCALLTYPE* Release)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This); HRESULT (STDMETHODCALLTYPE* Invoke)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* This, __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand* asyncInfo, AsyncStatus asyncStatus); END_INTERFACE } __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandVtbl; interface __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand { CONST_VTBL struct __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_Invoke(This, asyncInfo, asyncStatus) \ ((This)->lpVtbl->Invoke(This, asyncInfo, asyncStatus)) #endif /* COBJMACROS */ #endif // ____FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 typedef interface __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult; #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_INTERFACE_DEFINED__) #define ____FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_INTERFACE_DEFINED__ typedef interface __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult; typedef struct __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResultVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This); ULONG (STDMETHODCALLTYPE* Release)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* put_Completed)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This, __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* handler); HRESULT (STDMETHODCALLTYPE* get_Completed)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This, __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult** result); HRESULT (STDMETHODCALLTYPE* GetResults)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult** result); END_INTERFACE } __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResultVtbl; interface __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult { CONST_VTBL struct __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResultVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_put_Completed(This, handler) \ ((This)->lpVtbl->put_Completed(This, handler)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_get_Completed(This, result) \ ((This)->lpVtbl->get_Completed(This, result)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_GetResults(This, result) \ ((This)->lpVtbl->GetResults(This, result)) #endif /* COBJMACROS */ #endif // ____FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_INTERFACE_DEFINED__) #define ____FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_INTERFACE_DEFINED__ typedef interface __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult; typedef struct __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResultVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This); ULONG (STDMETHODCALLTYPE* Release)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This); HRESULT (STDMETHODCALLTYPE* Invoke)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* This, __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult* asyncInfo, AsyncStatus asyncStatus); END_INTERFACE } __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResultVtbl; interface __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult { CONST_VTBL struct __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResultVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_Invoke(This, asyncInfo, asyncStatus) \ ((This)->lpVtbl->Invoke(This, asyncInfo, asyncStatus)) #endif /* COBJMACROS */ #endif // ____FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 typedef interface __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult; #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_INTERFACE_DEFINED__) #define ____FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_INTERFACE_DEFINED__ typedef interface __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult; typedef struct __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResultVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This); ULONG (STDMETHODCALLTYPE* Release)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* put_Completed)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This, __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* handler); HRESULT (STDMETHODCALLTYPE* get_Completed)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This, __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult** result); HRESULT (STDMETHODCALLTYPE* GetResults)(__FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult** result); END_INTERFACE } __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResultVtbl; interface __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult { CONST_VTBL struct __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResultVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_put_Completed(This, handler) \ ((This)->lpVtbl->put_Completed(This, handler)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_get_Completed(This, result) \ ((This)->lpVtbl->get_Completed(This, result)) #define __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_GetResults(This, result) \ ((This)->lpVtbl->GetResults(This, result)) #endif /* COBJMACROS */ #endif // ____FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_INTERFACE_DEFINED__) #define ____FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_INTERFACE_DEFINED__ typedef interface __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult; typedef struct __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResultVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This); ULONG (STDMETHODCALLTYPE* Release)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This); HRESULT (STDMETHODCALLTYPE* Invoke)(__FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* This, __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult* asyncInfo, AsyncStatus asyncStatus); END_INTERFACE } __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResultVtbl; interface __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult { CONST_VTBL struct __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResultVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_Invoke(This, asyncInfo, asyncStatus) \ ((This)->lpVtbl->Invoke(This, asyncInfo, asyncStatus)) #endif /* COBJMACROS */ #endif // ____FIAsyncOperationCompletedHandler_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIIterator_1_HSTRING_INTERFACE_DEFINED__) #define ____FIIterator_1_HSTRING_INTERFACE_DEFINED__ typedef interface __FIIterator_1_HSTRING __FIIterator_1_HSTRING; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIIterator_1_HSTRING; typedef struct __FIIterator_1_HSTRINGVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIIterator_1_HSTRING* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIIterator_1_HSTRING* This); ULONG (STDMETHODCALLTYPE* Release)(__FIIterator_1_HSTRING* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIIterator_1_HSTRING* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIIterator_1_HSTRING* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIIterator_1_HSTRING* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Current)(__FIIterator_1_HSTRING* This, HSTRING* result); HRESULT (STDMETHODCALLTYPE* get_HasCurrent)(__FIIterator_1_HSTRING* This, boolean* result); HRESULT (STDMETHODCALLTYPE* MoveNext)(__FIIterator_1_HSTRING* This, boolean* result); HRESULT (STDMETHODCALLTYPE* GetMany)(__FIIterator_1_HSTRING* This, UINT32 itemsLength, HSTRING* items, UINT32* result); END_INTERFACE } __FIIterator_1_HSTRINGVtbl; interface __FIIterator_1_HSTRING { CONST_VTBL struct __FIIterator_1_HSTRINGVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIIterator_1_HSTRING_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIIterator_1_HSTRING_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIIterator_1_HSTRING_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIIterator_1_HSTRING_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIIterator_1_HSTRING_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIIterator_1_HSTRING_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIIterator_1_HSTRING_get_Current(This, result) \ ((This)->lpVtbl->get_Current(This, result)) #define __FIIterator_1_HSTRING_get_HasCurrent(This, result) \ ((This)->lpVtbl->get_HasCurrent(This, result)) #define __FIIterator_1_HSTRING_MoveNext(This, result) \ ((This)->lpVtbl->MoveNext(This, result)) #define __FIIterator_1_HSTRING_GetMany(This, itemsLength, items, result) \ ((This)->lpVtbl->GetMany(This, itemsLength, items, result)) #endif /* COBJMACROS */ #endif // ____FIIterator_1_HSTRING_INTERFACE_DEFINED__ #if !defined(____FIIterable_1_HSTRING_INTERFACE_DEFINED__) #define ____FIIterable_1_HSTRING_INTERFACE_DEFINED__ typedef interface __FIIterable_1_HSTRING __FIIterable_1_HSTRING; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIIterable_1_HSTRING; typedef struct __FIIterable_1_HSTRINGVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIIterable_1_HSTRING* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIIterable_1_HSTRING* This); ULONG (STDMETHODCALLTYPE* Release)(__FIIterable_1_HSTRING* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIIterable_1_HSTRING* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIIterable_1_HSTRING* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIIterable_1_HSTRING* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* First)(__FIIterable_1_HSTRING* This, __FIIterator_1_HSTRING** result); END_INTERFACE } __FIIterable_1_HSTRINGVtbl; interface __FIIterable_1_HSTRING { CONST_VTBL struct __FIIterable_1_HSTRINGVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIIterable_1_HSTRING_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIIterable_1_HSTRING_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIIterable_1_HSTRING_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIIterable_1_HSTRING_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIIterable_1_HSTRING_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIIterable_1_HSTRING_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIIterable_1_HSTRING_First(This, result) \ ((This)->lpVtbl->First(This, result)) #endif /* COBJMACROS */ #endif // ____FIIterable_1_HSTRING_INTERFACE_DEFINED__ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__) #define ____FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__ typedef interface __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile; typedef struct __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This); ULONG (STDMETHODCALLTYPE* Release)(__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Current)(__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile** result); HRESULT (STDMETHODCALLTYPE* get_HasCurrent)(__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, boolean* result); HRESULT (STDMETHODCALLTYPE* MoveNext)(__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, boolean* result); HRESULT (STDMETHODCALLTYPE* GetMany)(__FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32 itemsLength, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile** items, UINT32* result); END_INTERFACE } __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl; interface __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile { CONST_VTBL struct __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_get_Current(This, result) \ ((This)->lpVtbl->get_Current(This, result)) #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_get_HasCurrent(This, result) \ ((This)->lpVtbl->get_HasCurrent(This, result)) #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_MoveNext(This, result) \ ((This)->lpVtbl->MoveNext(This, result)) #define __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetMany(This, itemsLength, items, result) \ ((This)->lpVtbl->GetMany(This, itemsLength, items, result)) #endif /* COBJMACROS */ #endif // ____FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__) #define ____FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__ typedef interface __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile; typedef struct __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This); ULONG (STDMETHODCALLTYPE* Release)(__FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* First)(__FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, __FIIterator_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile** result); END_INTERFACE } __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl; interface __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile { CONST_VTBL struct __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_First(This, result) \ ((This)->lpVtbl->First(This, result)) #endif /* COBJMACROS */ #endif // ____FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__) #define ____FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__ typedef interface __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition; typedef struct __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This); ULONG (STDMETHODCALLTYPE* Release)(__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Key)(__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, HSTRING* result); HRESULT (STDMETHODCALLTYPE* get_Value)(__FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition** result); END_INTERFACE } __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl; interface __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition { CONST_VTBL struct __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_get_Key(This, result) \ ((This)->lpVtbl->get_Key(This, result)) #define __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_get_Value(This, result) \ ((This)->lpVtbl->get_Value(This, result)) #endif /* COBJMACROS */ #endif // ____FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__) #define ____FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__ typedef interface __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition; typedef struct __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This); ULONG (STDMETHODCALLTYPE* Release)(__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Current)(__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition** result); HRESULT (STDMETHODCALLTYPE* get_HasCurrent)(__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, boolean* result); HRESULT (STDMETHODCALLTYPE* MoveNext)(__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, boolean* result); HRESULT (STDMETHODCALLTYPE* GetMany)(__FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, UINT32 itemsLength, __FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition** items, UINT32* result); END_INTERFACE } __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl; interface __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition { CONST_VTBL struct __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_get_Current(This, result) \ ((This)->lpVtbl->get_Current(This, result)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_get_HasCurrent(This, result) \ ((This)->lpVtbl->get_HasCurrent(This, result)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_MoveNext(This, result) \ ((This)->lpVtbl->MoveNext(This, result)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetMany(This, itemsLength, items, result) \ ((This)->lpVtbl->GetMany(This, itemsLength, items, result)) #endif /* COBJMACROS */ #endif // ____FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__) #define ____FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__ typedef interface __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition; typedef struct __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This); ULONG (STDMETHODCALLTYPE* Release)(__FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* First)(__FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, __FIIterator_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition** result); END_INTERFACE } __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl; interface __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition { CONST_VTBL struct __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_First(This, result) \ ((This)->lpVtbl->First(This, result)) #endif /* COBJMACROS */ #endif // ____FIIterable_1___FIKeyValuePair_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIVectorView_1_HSTRING_INTERFACE_DEFINED__) #define ____FIVectorView_1_HSTRING_INTERFACE_DEFINED__ typedef interface __FIVectorView_1_HSTRING __FIVectorView_1_HSTRING; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIVectorView_1_HSTRING; typedef struct __FIVectorView_1_HSTRINGVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIVectorView_1_HSTRING* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIVectorView_1_HSTRING* This); ULONG (STDMETHODCALLTYPE* Release)(__FIVectorView_1_HSTRING* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIVectorView_1_HSTRING* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIVectorView_1_HSTRING* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIVectorView_1_HSTRING* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* GetAt)(__FIVectorView_1_HSTRING* This, UINT32 index, HSTRING* result); HRESULT (STDMETHODCALLTYPE* get_Size)(__FIVectorView_1_HSTRING* This, UINT32* result); HRESULT (STDMETHODCALLTYPE* IndexOf)(__FIVectorView_1_HSTRING* This, HSTRING value, UINT32* index, boolean* result); HRESULT (STDMETHODCALLTYPE* GetMany)(__FIVectorView_1_HSTRING* This, UINT32 startIndex, UINT32 itemsLength, HSTRING* items, UINT32* result); END_INTERFACE } __FIVectorView_1_HSTRINGVtbl; interface __FIVectorView_1_HSTRING { CONST_VTBL struct __FIVectorView_1_HSTRINGVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIVectorView_1_HSTRING_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIVectorView_1_HSTRING_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIVectorView_1_HSTRING_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIVectorView_1_HSTRING_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIVectorView_1_HSTRING_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIVectorView_1_HSTRING_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIVectorView_1_HSTRING_GetAt(This, index, result) \ ((This)->lpVtbl->GetAt(This, index, result)) #define __FIVectorView_1_HSTRING_get_Size(This, result) \ ((This)->lpVtbl->get_Size(This, result)) #define __FIVectorView_1_HSTRING_IndexOf(This, value, index, result) \ ((This)->lpVtbl->IndexOf(This, value, index, result)) #define __FIVectorView_1_HSTRING_GetMany(This, startIndex, itemsLength, items, result) \ ((This)->lpVtbl->GetMany(This, startIndex, itemsLength, items, result)) #endif /* COBJMACROS */ #endif // ____FIVectorView_1_HSTRING_INTERFACE_DEFINED__ #if !defined(____FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__) #define ____FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__ typedef interface __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING; typedef struct __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRINGVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This); ULONG (STDMETHODCALLTYPE* Release)(__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Key)(__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, HSTRING* result); HRESULT (STDMETHODCALLTYPE* get_Value)(__FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, __FIVectorView_1_HSTRING** result); END_INTERFACE } __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRINGVtbl; interface __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING { CONST_VTBL struct __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRINGVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_get_Key(This, result) \ ((This)->lpVtbl->get_Key(This, result)) #define __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_get_Value(This, result) \ ((This)->lpVtbl->get_Value(This, result)) #endif /* COBJMACROS */ #endif // ____FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__ #if !defined(____FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__) #define ____FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__ typedef interface __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING; typedef struct __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRINGVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This); ULONG (STDMETHODCALLTYPE* Release)(__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Current)(__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING** result); HRESULT (STDMETHODCALLTYPE* get_HasCurrent)(__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, boolean* result); HRESULT (STDMETHODCALLTYPE* MoveNext)(__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, boolean* result); HRESULT (STDMETHODCALLTYPE* GetMany)(__FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, UINT32 itemsLength, __FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING** items, UINT32* result); END_INTERFACE } __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRINGVtbl; interface __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING { CONST_VTBL struct __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRINGVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_get_Current(This, result) \ ((This)->lpVtbl->get_Current(This, result)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_get_HasCurrent(This, result) \ ((This)->lpVtbl->get_HasCurrent(This, result)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_MoveNext(This, result) \ ((This)->lpVtbl->MoveNext(This, result)) #define __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_GetMany(This, itemsLength, items, result) \ ((This)->lpVtbl->GetMany(This, itemsLength, items, result)) #endif /* COBJMACROS */ #endif // ____FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__ #if !defined(____FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__) #define ____FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__ typedef interface __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING; typedef struct __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRINGVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This); ULONG (STDMETHODCALLTYPE* Release)(__FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* First)(__FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING* This, __FIIterator_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING** result); END_INTERFACE } __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRINGVtbl; interface __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING { CONST_VTBL struct __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRINGVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_First(This, result) \ ((This)->lpVtbl->First(This, result)) #endif /* COBJMACROS */ #endif // ____FIIterable_1___FIKeyValuePair_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__ typedef interface __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition; #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__) #define ____FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__ typedef interface __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition; typedef struct __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This); ULONG (STDMETHODCALLTYPE* Release)(__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* Lookup)(__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, HSTRING key, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition** result); HRESULT (STDMETHODCALLTYPE* get_Size)(__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, UINT32* result); HRESULT (STDMETHODCALLTYPE* HasKey)(__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, HSTRING key, boolean* result); HRESULT (STDMETHODCALLTYPE* Split)(__FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition* This, __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition** first, __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition** second); END_INTERFACE } __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl; interface __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition { CONST_VTBL struct __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinitionVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_Lookup(This, key, result) \ ((This)->lpVtbl->Lookup(This, key, result)) #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_get_Size(This, result) \ ((This)->lpVtbl->get_Size(This, result)) #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_HasKey(This, key, result) \ ((This)->lpVtbl->HasKey(This, key, result)) #define __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_Split(This, first, second) \ ((This)->lpVtbl->Split(This, first, second)) #endif /* COBJMACROS */ #endif // ____FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 typedef interface __FIMapView_2_HSTRING___FIVectorView_1_HSTRING __FIMapView_2_HSTRING___FIVectorView_1_HSTRING; #if !defined(____FIMapView_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__) #define ____FIMapView_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__ typedef interface __FIMapView_2_HSTRING___FIVectorView_1_HSTRING __FIMapView_2_HSTRING___FIVectorView_1_HSTRING; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIMapView_2_HSTRING___FIVectorView_1_HSTRING; typedef struct __FIMapView_2_HSTRING___FIVectorView_1_HSTRINGVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIMapView_2_HSTRING___FIVectorView_1_HSTRING* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIMapView_2_HSTRING___FIVectorView_1_HSTRING* This); ULONG (STDMETHODCALLTYPE* Release)(__FIMapView_2_HSTRING___FIVectorView_1_HSTRING* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIMapView_2_HSTRING___FIVectorView_1_HSTRING* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIMapView_2_HSTRING___FIVectorView_1_HSTRING* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIMapView_2_HSTRING___FIVectorView_1_HSTRING* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* Lookup)(__FIMapView_2_HSTRING___FIVectorView_1_HSTRING* This, HSTRING key, __FIVectorView_1_HSTRING** result); HRESULT (STDMETHODCALLTYPE* get_Size)(__FIMapView_2_HSTRING___FIVectorView_1_HSTRING* This, UINT32* result); HRESULT (STDMETHODCALLTYPE* HasKey)(__FIMapView_2_HSTRING___FIVectorView_1_HSTRING* This, HSTRING key, boolean* result); HRESULT (STDMETHODCALLTYPE* Split)(__FIMapView_2_HSTRING___FIVectorView_1_HSTRING* This, __FIMapView_2_HSTRING___FIVectorView_1_HSTRING** first, __FIMapView_2_HSTRING___FIVectorView_1_HSTRING** second); END_INTERFACE } __FIMapView_2_HSTRING___FIVectorView_1_HSTRINGVtbl; interface __FIMapView_2_HSTRING___FIVectorView_1_HSTRING { CONST_VTBL struct __FIMapView_2_HSTRING___FIVectorView_1_HSTRINGVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_Lookup(This, key, result) \ ((This)->lpVtbl->Lookup(This, key, result)) #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_get_Size(This, result) \ ((This)->lpVtbl->get_Size(This, result)) #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_HasKey(This, key, result) \ ((This)->lpVtbl->HasKey(This, key, result)) #define __FIMapView_2_HSTRING___FIVectorView_1_HSTRING_Split(This, first, second) \ ((This)->lpVtbl->Split(This, first, second)) #endif /* COBJMACROS */ #endif // ____FIMapView_2_HSTRING___FIVectorView_1_HSTRING_INTERFACE_DEFINED__ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__) #define ____FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__ typedef interface __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile; typedef struct __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This); ULONG (STDMETHODCALLTYPE* Release)(__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* GetAt)(__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32 index, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile** result); HRESULT (STDMETHODCALLTYPE* get_Size)(__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32* result); HRESULT (STDMETHODCALLTYPE* IndexOf)(__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* value, UINT32* index, boolean* result); HRESULT (STDMETHODCALLTYPE* GetMany)(__FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32 startIndex, UINT32 itemsLength, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile** items, UINT32* result); END_INTERFACE } __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl; interface __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile { CONST_VTBL struct __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetAt(This, index, result) \ ((This)->lpVtbl->GetAt(This, index, result)) #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_get_Size(This, result) \ ((This)->lpVtbl->get_Size(This, result)) #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_IndexOf(This, value, index, result) \ ((This)->lpVtbl->IndexOf(This, value, index, result)) #define __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetMany(This, startIndex, itemsLength, items, result) \ ((This)->lpVtbl->GetMany(This, startIndex, itemsLength, items, result)) #endif /* COBJMACROS */ #endif // ____FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__) #define ____FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__ typedef interface __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile; typedef struct __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This); ULONG (STDMETHODCALLTYPE* Release)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* GetAt)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32 index, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile** result); HRESULT (STDMETHODCALLTYPE* get_Size)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32* result); HRESULT (STDMETHODCALLTYPE* GetView)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, __FIVectorView_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile** result); HRESULT (STDMETHODCALLTYPE* IndexOf)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* value, UINT32* index, boolean* result); HRESULT (STDMETHODCALLTYPE* SetAt)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32 index, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* value); HRESULT (STDMETHODCALLTYPE* InsertAt)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32 index, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* value); HRESULT (STDMETHODCALLTYPE* RemoveAt)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32 index); HRESULT (STDMETHODCALLTYPE* Append)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* value); HRESULT (STDMETHODCALLTYPE* RemoveAtEnd)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This); HRESULT (STDMETHODCALLTYPE* Clear)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This); HRESULT (STDMETHODCALLTYPE* GetMany)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32 startIndex, UINT32 itemsLength, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile** items, UINT32* result); HRESULT (STDMETHODCALLTYPE* ReplaceAll)(__FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* This, UINT32 itemsLength, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile** items); END_INTERFACE } __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl; interface __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile { CONST_VTBL struct __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTileVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetAt(This, index, result) \ ((This)->lpVtbl->GetAt(This, index, result)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_get_Size(This, result) \ ((This)->lpVtbl->get_Size(This, result)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetView(This, result) \ ((This)->lpVtbl->GetView(This, result)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_IndexOf(This, value, index, result) \ ((This)->lpVtbl->IndexOf(This, value, index, result)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_SetAt(This, index, value) \ ((This)->lpVtbl->SetAt(This, index, value)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_InsertAt(This, index, value) \ ((This)->lpVtbl->InsertAt(This, index, value)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_RemoveAt(This, index) \ ((This)->lpVtbl->RemoveAt(This, index)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_Append(This, value) \ ((This)->lpVtbl->Append(This, value)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_RemoveAtEnd(This) \ ((This)->lpVtbl->RemoveAtEnd(This)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_Clear(This) \ ((This)->lpVtbl->Clear(This)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_GetMany(This, startIndex, itemsLength, items, result) \ ((This)->lpVtbl->GetMany(This, startIndex, itemsLength, items, result)) #define __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_ReplaceAll(This, itemsLength, items) \ ((This)->lpVtbl->ReplaceAll(This, itemsLength, items)) #endif /* COBJMACROS */ #endif // ____FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_INTERFACE_DEFINED__) #define ____FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_INTERFACE_DEFINED__ typedef interface __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs; // Declare the parameterized interface IID. EXTERN_C const IID IID___FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs; typedef struct __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgsVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs* This); ULONG (STDMETHODCALLTYPE* Release)(__FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs* This); HRESULT (STDMETHODCALLTYPE* Invoke)(__FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* sender, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs* args); END_INTERFACE } __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgsVtbl; interface __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs { CONST_VTBL struct __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgsVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_Invoke(This, sender, args) \ ((This)->lpVtbl->Invoke(This, sender, args)) #endif /* COBJMACROS */ #endif // ____FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs_INTERFACE_DEFINED__ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef ____x_ABI_CWindows_CApplicationModel_CAppService_CIAppServiceTriggerDetails_FWD_DEFINED__ #define ____x_ABI_CWindows_CApplicationModel_CAppService_CIAppServiceTriggerDetails_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CApplicationModel_CAppService_CIAppServiceTriggerDetails __x_ABI_CWindows_CApplicationModel_CAppService_CIAppServiceTriggerDetails; #endif // ____x_ABI_CWindows_CApplicationModel_CAppService_CIAppServiceTriggerDetails_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CFoundation_CIAsyncAction_FWD_DEFINED__ #define ____x_ABI_CWindows_CFoundation_CIAsyncAction_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CFoundation_CIAsyncAction __x_ABI_CWindows_CFoundation_CIAsyncAction; #endif // ____x_ABI_CWindows_CFoundation_CIAsyncAction_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CGlobalization_CILanguage_FWD_DEFINED__ #define ____x_ABI_CWindows_CGlobalization_CILanguage_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CGlobalization_CILanguage __x_ABI_CWindows_CGlobalization_CILanguage; #endif // ____x_ABI_CWindows_CGlobalization_CILanguage_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CMedia_CSpeechRecognition_CISpeechRecognitionResult_FWD_DEFINED__ #define ____x_ABI_CWindows_CMedia_CSpeechRecognition_CISpeechRecognitionResult_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CMedia_CSpeechRecognition_CISpeechRecognitionResult __x_ABI_CWindows_CMedia_CSpeechRecognition_CISpeechRecognitionResult; #endif // ____x_ABI_CWindows_CMedia_CSpeechRecognition_CISpeechRecognitionResult_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CStorage_CIStorageFile_FWD_DEFINED__ #define ____x_ABI_CWindows_CStorage_CIStorageFile_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CStorage_CIStorageFile __x_ABI_CWindows_CStorage_CIStorageFile; #endif // ____x_ABI_CWindows_CStorage_CIStorageFile_FWD_DEFINED__ typedef enum __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CVoiceCommandCompletionReason __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CVoiceCommandCompletionReason; typedef enum __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CVoiceCommandContentTileType __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CVoiceCommandContentTileType; /* * * Struct Windows.ApplicationModel.VoiceCommands.VoiceCommandCompletionReason * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 enum __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CVoiceCommandCompletionReason { VoiceCommandCompletionReason_Unknown = 0, VoiceCommandCompletionReason_CommunicationFailed = 1, VoiceCommandCompletionReason_ResourceLimitsExceeded = 2, VoiceCommandCompletionReason_Canceled = 3, VoiceCommandCompletionReason_TimeoutExceeded = 4, VoiceCommandCompletionReason_AppLaunched = 5, VoiceCommandCompletionReason_Completed = 6, }; #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Struct Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTileType * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 enum __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CVoiceCommandContentTileType { VoiceCommandContentTileType_TitleOnly = 0, VoiceCommandContentTileType_TitleWithText = 1, VoiceCommandContentTileType_TitleWith68x68Icon = 2, VoiceCommandContentTileType_TitleWith68x68IconAndText = 3, VoiceCommandContentTileType_TitleWith68x92Icon = 4, VoiceCommandContentTileType_TitleWith68x92IconAndText = 5, VoiceCommandContentTileType_TitleWith280x140Icon = 6, VoiceCommandContentTileType_TitleWith280x140IconAndText = 7, }; #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommand * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommand * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommand[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommand"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_CommandName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* get_Properties)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand* This, __FIMapView_2_HSTRING___FIVectorView_1_HSTRING** value); HRESULT (STDMETHODCALLTYPE* get_SpeechRecognitionResult)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand* This, __x_ABI_CWindows_CMedia_CSpeechRecognition_CISpeechRecognitionResult** value); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_get_CommandName(This, value) \ ((This)->lpVtbl->get_CommandName(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_get_Properties(This, value) \ ((This)->lpVtbl->get_Properties(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_get_SpeechRecognitionResult(This, value) \ ((This)->lpVtbl->get_SpeechRecognitionResult(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommand_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandCompletedEventArgs * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandCompletedEventArgs * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandCompletedEventArgs[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandCompletedEventArgs"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgsVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Reason)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs* This, enum __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CVoiceCommandCompletionReason* value); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgsVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgsVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_get_Reason(This, value) \ ((This)->lpVtbl->get_Reason(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandCompletedEventArgs_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandConfirmationResult * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandConfirmationResult * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandConfirmationResult[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandConfirmationResult"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResultVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Confirmed)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult* This, boolean* value); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResultVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResultVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_get_Confirmed(This, value) \ ((This)->lpVtbl->get_Confirmed(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandConfirmationResult_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandContentTile * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandContentTile[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandContentTile"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTileVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Title)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* put_Title)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING value); HRESULT (STDMETHODCALLTYPE* get_TextLine1)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* put_TextLine1)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING value); HRESULT (STDMETHODCALLTYPE* get_TextLine2)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* put_TextLine2)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING value); HRESULT (STDMETHODCALLTYPE* get_TextLine3)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* put_TextLine3)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING value); HRESULT (STDMETHODCALLTYPE* get_Image)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, __x_ABI_CWindows_CStorage_CIStorageFile** value); HRESULT (STDMETHODCALLTYPE* put_Image)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, __x_ABI_CWindows_CStorage_CIStorageFile* value); HRESULT (STDMETHODCALLTYPE* get_AppContext)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, IInspectable** value); HRESULT (STDMETHODCALLTYPE* put_AppContext)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, IInspectable* value); HRESULT (STDMETHODCALLTYPE* get_AppLaunchArgument)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* put_AppLaunchArgument)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, HSTRING value); HRESULT (STDMETHODCALLTYPE* get_ContentTileType)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, enum __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CVoiceCommandContentTileType* value); HRESULT (STDMETHODCALLTYPE* put_ContentTileType)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile* This, enum __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CVoiceCommandContentTileType value); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTileVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTileVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_get_Title(This, value) \ ((This)->lpVtbl->get_Title(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_put_Title(This, value) \ ((This)->lpVtbl->put_Title(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_get_TextLine1(This, value) \ ((This)->lpVtbl->get_TextLine1(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_put_TextLine1(This, value) \ ((This)->lpVtbl->put_TextLine1(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_get_TextLine2(This, value) \ ((This)->lpVtbl->get_TextLine2(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_put_TextLine2(This, value) \ ((This)->lpVtbl->put_TextLine2(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_get_TextLine3(This, value) \ ((This)->lpVtbl->get_TextLine3(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_put_TextLine3(This, value) \ ((This)->lpVtbl->put_TextLine3(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_get_Image(This, value) \ ((This)->lpVtbl->get_Image(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_put_Image(This, value) \ ((This)->lpVtbl->put_Image(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_get_AppContext(This, value) \ ((This)->lpVtbl->get_AppContext(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_put_AppContext(This, value) \ ((This)->lpVtbl->put_AppContext(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_get_AppLaunchArgument(This, value) \ ((This)->lpVtbl->get_AppLaunchArgument(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_put_AppLaunchArgument(This, value) \ ((This)->lpVtbl->put_AppLaunchArgument(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_get_ContentTileType(This, value) \ ((This)->lpVtbl->get_ContentTileType(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_put_ContentTileType(This, value) \ ((This)->lpVtbl->put_ContentTileType(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinition * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandDefinition[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinition"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Language)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* get_Name)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* SetPhraseListAsync)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition* This, HSTRING phraseListName, __FIIterable_1_HSTRING* phraseList, __x_ABI_CWindows_CFoundation_CIAsyncAction** updateAction); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_get_Language(This, value) \ ((This)->lpVtbl->get_Language(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_get_Name(This, value) \ ((This)->lpVtbl->get_Name(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_SetPhraseListAsync(This, phraseListName, phraseList, updateAction) \ ((This)->lpVtbl->SetPhraseListAsync(This, phraseListName, phraseList, updateAction)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinition_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinitionManagerStatics * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandDefinitionManagerStatics[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinitionManagerStatics"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStaticsVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* InstallCommandDefinitionsFromStorageFileAsync)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics* This, __x_ABI_CWindows_CStorage_CIStorageFile* file, __x_ABI_CWindows_CFoundation_CIAsyncAction** installAction); HRESULT (STDMETHODCALLTYPE* get_InstalledCommandDefinitions)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics* This, __FIMapView_2_HSTRING_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDefinition** voiceCommandDefinitions); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStaticsVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStaticsVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_InstallCommandDefinitionsFromStorageFileAsync(This, file, installAction) \ ((This)->lpVtbl->InstallCommandDefinitionsFromStorageFileAsync(This, file, installAction)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_get_InstalledCommandDefinitions(This, voiceCommandDefinitions) \ ((This)->lpVtbl->get_InstalledCommandDefinitions(This, voiceCommandDefinitions)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDefinitionManagerStatics_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandDisambiguationResult * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandDisambiguationResult * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandDisambiguationResult[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandDisambiguationResult"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResultVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_SelectedItem)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandContentTile** value); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResultVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResultVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_get_SelectedItem(This, value) \ ((This)->lpVtbl->get_SelectedItem(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandDisambiguationResult_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponse * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandResponse * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandResponse[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponse"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Message)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage** value); HRESULT (STDMETHODCALLTYPE* put_Message)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* value); HRESULT (STDMETHODCALLTYPE* get_RepeatMessage)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage** value); HRESULT (STDMETHODCALLTYPE* put_RepeatMessage)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* value); HRESULT (STDMETHODCALLTYPE* get_AppLaunchArgument)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* put_AppLaunchArgument)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, HSTRING value); HRESULT (STDMETHODCALLTYPE* get_VoiceCommandContentTiles)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* This, __FIVector_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile** value); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_get_Message(This, value) \ ((This)->lpVtbl->get_Message(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_put_Message(This, value) \ ((This)->lpVtbl->put_Message(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_get_RepeatMessage(This, value) \ ((This)->lpVtbl->get_RepeatMessage(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_put_RepeatMessage(This, value) \ ((This)->lpVtbl->put_RepeatMessage(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_get_AppLaunchArgument(This, value) \ ((This)->lpVtbl->get_AppLaunchArgument(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_put_AppLaunchArgument(This, value) \ ((This)->lpVtbl->put_AppLaunchArgument(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_get_VoiceCommandContentTiles(This, value) \ ((This)->lpVtbl->get_VoiceCommandContentTiles(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponseStatics * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandResponse * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandResponseStatics[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponseStatics"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStaticsVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_MaxSupportedVoiceCommandContentTiles)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This, UINT32* value); HRESULT (STDMETHODCALLTYPE* CreateResponse)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* userMessage, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse** response); HRESULT (STDMETHODCALLTYPE* CreateResponseWithTiles)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* message, __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* contentTiles, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse** response); HRESULT (STDMETHODCALLTYPE* CreateResponseForPrompt)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* message, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* repeatMessage, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse** response); HRESULT (STDMETHODCALLTYPE* CreateResponseForPromptWithTiles)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* message, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* repeatMessage, __FIIterable_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandContentTile* contentTiles, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse** response); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStaticsVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStaticsVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_get_MaxSupportedVoiceCommandContentTiles(This, value) \ ((This)->lpVtbl->get_MaxSupportedVoiceCommandContentTiles(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_CreateResponse(This, userMessage, response) \ ((This)->lpVtbl->CreateResponse(This, userMessage, response)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_CreateResponseWithTiles(This, message, contentTiles, response) \ ((This)->lpVtbl->CreateResponseWithTiles(This, message, contentTiles, response)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_CreateResponseForPrompt(This, message, repeatMessage, response) \ ((This)->lpVtbl->CreateResponseForPrompt(This, message, repeatMessage, response)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_CreateResponseForPromptWithTiles(This, message, repeatMessage, contentTiles, response) \ ((This)->lpVtbl->CreateResponseForPromptWithTiles(This, message, repeatMessage, contentTiles, response)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponseStatics_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnection * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandServiceConnection * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandServiceConnection[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnection"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* GetVoiceCommandAsync)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommand** operation); HRESULT (STDMETHODCALLTYPE* RequestConfirmationAsync)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* response, __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandConfirmationResult** operation); HRESULT (STDMETHODCALLTYPE* RequestDisambiguationAsync)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* response, __FIAsyncOperation_1_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandDisambiguationResult** operation); HRESULT (STDMETHODCALLTYPE* ReportProgressAsync)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* response, __x_ABI_CWindows_CFoundation_CIAsyncAction** action); HRESULT (STDMETHODCALLTYPE* ReportSuccessAsync)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* response, __x_ABI_CWindows_CFoundation_CIAsyncAction** action); HRESULT (STDMETHODCALLTYPE* ReportFailureAsync)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* response, __x_ABI_CWindows_CFoundation_CIAsyncAction** action); HRESULT (STDMETHODCALLTYPE* RequestAppLaunchAsync)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandResponse* response, __x_ABI_CWindows_CFoundation_CIAsyncAction** action); HRESULT (STDMETHODCALLTYPE* get_Language)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, __x_ABI_CWindows_CGlobalization_CILanguage** language); HRESULT (STDMETHODCALLTYPE* add_VoiceCommandCompleted)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, __FITypedEventHandler_2_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandServiceConnection_Windows__CApplicationModel__CVoiceCommands__CVoiceCommandCompletedEventArgs* handler, EventRegistrationToken* token); HRESULT (STDMETHODCALLTYPE* remove_VoiceCommandCompleted)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection* This, EventRegistrationToken token); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_GetVoiceCommandAsync(This, operation) \ ((This)->lpVtbl->GetVoiceCommandAsync(This, operation)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_RequestConfirmationAsync(This, response, operation) \ ((This)->lpVtbl->RequestConfirmationAsync(This, response, operation)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_RequestDisambiguationAsync(This, response, operation) \ ((This)->lpVtbl->RequestDisambiguationAsync(This, response, operation)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_ReportProgressAsync(This, response, action) \ ((This)->lpVtbl->ReportProgressAsync(This, response, action)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_ReportSuccessAsync(This, response, action) \ ((This)->lpVtbl->ReportSuccessAsync(This, response, action)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_ReportFailureAsync(This, response, action) \ ((This)->lpVtbl->ReportFailureAsync(This, response, action)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_RequestAppLaunchAsync(This, response, action) \ ((This)->lpVtbl->RequestAppLaunchAsync(This, response, action)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_get_Language(This, language) \ ((This)->lpVtbl->get_Language(This, language)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_add_VoiceCommandCompleted(This, handler, token) \ ((This)->lpVtbl->add_VoiceCommandCompleted(This, handler, token)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_remove_VoiceCommandCompleted(This, token) \ ((This)->lpVtbl->remove_VoiceCommandCompleted(This, token)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnectionStatics * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandServiceConnection * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandServiceConnectionStatics[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnectionStatics"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStaticsVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* FromAppServiceTriggerDetails)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics* This, __x_ABI_CWindows_CApplicationModel_CAppService_CIAppServiceTriggerDetails* triggerDetails, __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnection** value); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStaticsVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStaticsVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_FromAppServiceTriggerDetails(This, triggerDetails, value) \ ((This)->lpVtbl->FromAppServiceTriggerDetails(This, triggerDetails, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandServiceConnectionStatics_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Interface Windows.ApplicationModel.VoiceCommands.IVoiceCommandUserMessage * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Interface is a part of the implementation of type Windows.ApplicationModel.VoiceCommands.VoiceCommandUserMessage * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_ApplicationModel_VoiceCommands_IVoiceCommandUserMessage[] = L"Windows.ApplicationModel.VoiceCommands.IVoiceCommandUserMessage"; typedef struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessageVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_DisplayMessage)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* put_DisplayMessage)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* This, HSTRING value); HRESULT (STDMETHODCALLTYPE* get_SpokenMessage)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* This, HSTRING* value); HRESULT (STDMETHODCALLTYPE* put_SpokenMessage)(__x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage* This, HSTRING value); END_INTERFACE } __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessageVtbl; interface __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage { CONST_VTBL struct __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessageVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_get_DisplayMessage(This, value) \ ((This)->lpVtbl->get_DisplayMessage(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_put_DisplayMessage(This, value) \ ((This)->lpVtbl->put_DisplayMessage(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_get_SpokenMessage(This, value) \ ((This)->lpVtbl->get_SpokenMessage(This, value)) #define __x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_put_SpokenMessage(This, value) \ ((This)->lpVtbl->put_SpokenMessage(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage; #endif /* !defined(____x_ABI_CWindows_CApplicationModel_CVoiceCommands_CIVoiceCommandUserMessage_INTERFACE_DEFINED__) */ #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommand * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommand ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommand_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommand_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommand[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommand"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandCompletedEventArgs * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandCompletedEventArgs ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandCompletedEventArgs_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandCompletedEventArgs_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandCompletedEventArgs[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandCompletedEventArgs"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandConfirmationResult * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandConfirmationResult ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandConfirmationResult_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandConfirmationResult_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandConfirmationResult[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandConfirmationResult"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTile * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * RuntimeClass can be activated. * Type can be activated via RoActivateInstance starting with version 1.0 of the Windows.Foundation.UniversalApiContract API contract * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandContentTile ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandContentTile_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandContentTile_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandContentTile[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandContentTile"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinition ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinition_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinition_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinition[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * RuntimeClass contains static methods. * Static Methods exist on the Windows.ApplicationModel.VoiceCommands.IVoiceCommandDefinitionManagerStatics interface starting with version 1.0 of the Windows.Foundation.UniversalApiContract API contract * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinitionManager_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinitionManager_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandDefinitionManager[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandDisambiguationResult * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandDisambiguationResult ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDisambiguationResult_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandDisambiguationResult_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandDisambiguationResult[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandDisambiguationResult"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandResponse * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * RuntimeClass contains static methods. * Static Methods exist on the Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponseStatics interface starting with version 1.0 of the Windows.Foundation.UniversalApiContract API contract * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandResponse ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandResponse_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandResponse_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandResponse[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandResponse"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandServiceConnection * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * RuntimeClass contains static methods. * Static Methods exist on the Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnectionStatics interface starting with version 1.0 of the Windows.Foundation.UniversalApiContract API contract * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandServiceConnection ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandServiceConnection_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandServiceConnection_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandServiceConnection[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandServiceConnection"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 /* * * Class Windows.ApplicationModel.VoiceCommands.VoiceCommandUserMessage * * Introduced to Windows.Foundation.UniversalApiContract in version 1.0 * * RuntimeClass can be activated. * Type can be activated via RoActivateInstance starting with version 1.0 of the Windows.Foundation.UniversalApiContract API contract * * Class implements the following interfaces: * Windows.ApplicationModel.VoiceCommands.IVoiceCommandUserMessage ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandUserMessage_DEFINED #define RUNTIMECLASS_Windows_ApplicationModel_VoiceCommands_VoiceCommandUserMessage_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_ApplicationModel_VoiceCommands_VoiceCommandUserMessage[] = L"Windows.ApplicationModel.VoiceCommands.VoiceCommandUserMessage"; #endif #endif // WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION >= 0x10000 #endif // defined(__cplusplus) #pragma pop_macro("MIDL_CONST_ID") // Restore the original value of the 'DEPRECATED' macro #pragma pop_macro("DEPRECATED") #ifdef __clang__ #pragma clang diagnostic pop // deprecated-declarations #else #pragma warning(pop) #endif #endif // __windows2Eapplicationmodel2Evoicecommands_p_h__ #endif // __windows2Eapplicationmodel2Evoicecommands_h__
d8458f7c549f398df18b4841cbfdd232481664a8
25820cc0eca78dcf4b95fdee2051d90d82222473
/GrayWorld 10/graysvr/graysvr.cpp
fce7eead42b7548edc1f454afa9ce8cb62adf391
[ "Apache-2.0" ]
permissive
HappyFeng119/Source-Archive
eb619bba21159d920715e7ad0e54dd323eb57953
ab24ba44ffd34c329accedb980699e94c196fceb
refs/heads/main
2023-03-03T17:29:37.860236
2021-02-11T19:06:54
2021-02-11T19:06:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
32,224
cpp
// // GRAYSRV.CPP. // game/login server for uo client // http://www.ayekan.com/awesomedev // or see my page: http://www.menasoft.com for more details. // // Dennis Robinson [[email protected]], http://www.menasoft.com // Damian Tedrow [[email protected]], http://www.ayekan.com/awesomedev // Nix [[email protected]] // Westy [[email protected]] // Terry [[email protected]] // Alluvian [[email protected]] // Keif Mayers [[email protected]] // // In works: // game/chess board. // Weapons damage. weapon animation. skill check and wrestling = no damage ? // Gray Agent Program to swap the login.cfg on client machine. (Terry) // New spells, Spells damage, and effects. (Alluvian) // Spawns and respawns of items destroyed/killed or taken. (me) // Regions - music and named regions. Adapt UOMAPX to create these. // // BUGS: // Fall thru floor of houses. // Strange accumulated lag ? // dclick sometimes not work at all ? // Skills used on corpse can't target. // Skills cause the "Criminal" dialog to appear on targetting ? // Missed clicks on skills and spells. Target object required flag ? // Scrolls to spell books. // Extra spells in spell book ? Necromancy can crash client // // Needs: // Increase the number of regions. Timer Items List ? // Tune Skill Checking and skill delays along with spell delays // Save world file. (binary) // Free guest log ins. // Enum creatures and there avail anims (blink out when bad anim occurs) // Enum flipped objects, dif num objects, anim objects. // Tweak menu. // Secure trade dialog. // Skills - Raw material skills - Lumber jacking, Mining, Fishing // Skills - Production skills - Smithy, Bowery, Carpentry, Tinkering, Tailoring, Inscrip, Alchemy // Skills - Transform skills - Cooking, Cartography, // Skills - Information skills - Forensics, Taste ID // Mining equipment and smelting // Sewing and scissors // Bandages and healing // Boats // Shrines for Resurrection // Move off line chars out of world file on world save ? // Single OnTick() for chars and items ? // // FIXED BUGS: // Vendors - Buy/Sell // Weight display ? // Skills not working- herding, hiding, etc. // anim human death = crash, equip items on corpse. // move after res = crash. unless full update. // +set color for chars. need to remove char // +res. gown is still ghost gown. // +gochar command // +quake = crash // +drop on top = ground. // +set color w/ no args. // +cutting piles. // +set karma -10000 // +filter unprintables | or ~ // // done: // opt weight changes and stat update s // dupe contents and creatures. // Houses and tents. Deeds // Location/Quandrant structures. -> Find by location faster. sparse array (me) // Default Creature templates. GrayChar.scp (Nix) // Enum of sounds. Lots of sounds we are not using for effects. (Alluvian) // Monsters casting spells. // Better bounding and mapping of the world. (NPC's walk through walls now) // Import WSC world files. // Healers // Food and hunger. Eating and drinking. // Win32 try and catch. exception handling. // /MUSIC command // /GOCLI command // Name rune mode. Cancel naming ? // Login with ip as encryption code fails ? (compiler related?) // Fix the stupid crashes. (location related crashes) = bad colors displayed ! // Store inventory by container. // Translate UID to pointers in game ? very quick lookup // spell sounds / creature sounds // Get dungeon and world teleporters. // follow/attack by npcs and other pet commands // Dynamic allocation of stuff. #include "graysvr.h" // predef header. const char * Dirs[DIR_QTY] = { "N", "NE", "E", "SE", "S", "SW", "W", "NW", }; const char * Runes[] = /// ??? fill this in. { "An", "Bet", "Corp", "Des", "Ex", "Flam", "Grav", "Hur", "In", "Jux", "Kal", "Lor", "Mani", "Nox", "Ort", "Por", "Quas", "Rel", "Sanct", "Tym", // never used. (Time?) "Uus", "Vas", "Wis", "Xen", "Ylem", "Zan", // never used. }; const char * Stat_Name[STAT_QTY] = { "STR", "INT", "DEX", "KARMA", "FAME", "KILLS", }; // Usefull info about skills. const CSkillDef Skills[SKILL_QTY+1] = { { "ALCHEMY", "Alchemist", NULL, "You pour the failed mixture from the mortar.", }, { "ANATOMY", "Scholar", "Select char to inspect.", "You can't think of anything about this creature", }, { "ANIMALLORE", "Scholar", "What animal do you want information on?", "You can't think of anything off hand", }, { "ITEMID", "Merchant", "Select item to inspect.", "You can't think of anything off hand" }, { "ARMSLORE", "Armsman", "Choose item to evaluate.", "You are uncertain about this item" }, { "PARRYING", "Shieldfighter", }, { "BEGGING", "Beggar", "Who do you want to grovel to?", }, { "BLACKSMITHING", "Blacksmith", NULL, "You have failed to make anything", }, { "BOWCRAFT", "Bowyer", NULL, "You fail to create the item", }, { "PEACEMAKING", "Bard", NULL, "You attempt at peacemaking has failed", }, { "CAMPING", "Camper", NULL, "You fail to light the camp fire", }, { "CARPENTRY", "Carpenter", NULL, "You fail to create the item", }, { "CARTOGRAPHY", "Cartographer", NULL, "Your hand is unsteady and you map is a failure", }, { "COOKING", "Cook", "What would you like to cook?", "Your cooking fails", }, { "DETECTINGHIDDEN","Detective", NULL, "You can't seem to find anything unussual", }, { "ENTICEMENT", "Bard", "Who would you like to entice?", "You music fails to entice them", }, { "EVALUATINGINTEL","Scholar", "Select char to inspect.", "You cannot seem to judge the creature correctly", }, { "HEALING", "Healer", "Who would you like to use the bandage on?", "You fail to apply the bandages correctly", }, { "FISHING", "Fisherman", "Where do you want to fish?", "You have no luck fishing", }, { "FORENSICS", "Scholar", "What corpse would you like to examine?", "You can tell nothing about the corpse.", }, { "HERDING", "Ranger", NULL, "You cannot seem to persuade the creature to move", }, { "HIDING", "Rogue", NULL, "You cannot seem to hide here", }, { "PROVOCATION", "Bard", "Who would you like to provoke?", "You fail to provoke enough anger to cause a fight", }, { "INSCRIPTION", "Scribe", NULL, "Your inscription fails. The scroll is ruined", }, { "LOCKPICKING", "Locksmith", "What would you like to use the pick on?", }, { "MAGERY", "Mage", NULL, "The spell fizzles", }, { "MAGICRESISTANCE","Resistor", }, { "TACTICS", "Warrior", }, { "SNOOPING", "Rogue", NULL, "You fail to peek into the container", }, { "MUSICIANSHIP", "Bard", NULL, "You play poorly", }, { "POISONING", "Assassin", NULL, "You fail to apply a does of poison", }, { "ARCHERY", "Archer", }, { "SPIRITSPEAK", "Medium", NULL, "You fail your attempt to contact the neither world", }, { "STEALING", "Thief", "What do you want to steal?", "You fail to steal anything", }, { "TAILORING", "Tailor", NULL, "You lose some cloth", }, { "TAMING", "Animal Tamer", "Choose the creature to tame.", "You fail to tame the creature", }, { "TASTEID", "Food Taster", "What would you like to taste?", "You cannot descern anything about this item", }, { "TINKERING", "Tinker", NULL, "Your tinkering attempt fails", }, { "TRACKING", "Ranger", NULL, "You fail to see any tracks", }, { "VETERINARY", "Veterinarian", "What animal would you like to heal?", "You fail to apply the bandages correctly", }, { "SWORDSMANSHIP", "Swordsman", }, { "MACEFIGHTING", "Macefighter", }, { "FENCING", "Fencer", }, { "WRESTLING", "Wrestler", }, { "LUMBERJACKING", "Lumberjack", "What tree do you want to chop?", "You hack at the tree for a while but fail to get usable wood", }, { "MINING", "Miner", "Where would you like to mine?", "You break up the rocks a bit but fail to find usable ore", }, { "ALLSKILLS", NULL, }, }; // Usefull info about spells. const CSpellDef Spells[] = // describe all my spells. { { 0 }, // all spells make a noise either from you or at target. // sound, runes,regs,scroll, image, directed, name // 1st { "Clumsy", 0x1df, "UJ", "BmNs", ITEMID_SPELL_1, ITEMID_SCROLL_2, SPELLFLAG_TARG_CHAR | SPELLFLAG_DIR_ANIM | SPELLFLAG_HARM }, // SPELL_Clumsy, { "Create Food", 0x1e2, "IMY", "GaGiMr", (ITEMID_TYPE) 0x2081, (ITEMID_TYPE) 0x1F2F, SPELLFLAG_TARG_XYZ, }, // SPELL_Create_Food, { "Feeblemind", 0x1e4, "RW", "GiNs", (ITEMID_TYPE) 0x2082, (ITEMID_TYPE) 0x1F30, SPELLFLAG_TARG_CHAR | SPELLFLAG_DIR_ANIM | SPELLFLAG_HARM }, // SPELL_Feeblemind, { "Heal", 0x1f2, "IM", "GaGsSs", (ITEMID_TYPE) 0x2083, (ITEMID_TYPE) 0x1f31, SPELLFLAG_TARG_CHAR }, // SPELL_Heal, { "Magic Arrow", 0x1e5, "IPY", "BpNs", (ITEMID_TYPE) 0x2084, (ITEMID_TYPE) 0x1f32, SPELLFLAG_TARG_CHAR | SPELLFLAG_DIR_ANIM | SPELLFLAG_HARM }, // SPELL_Magic_Arrow, { "Night Sight", 0x1e3, "IL", "SsSa", (ITEMID_TYPE) 0x2085, (ITEMID_TYPE) 0x1f33, SPELLFLAG_TARG_CHAR }, // SPELL_Night_Sight, { "Reactive Armor", 0x1f2, "FS", "GaSsSa", (ITEMID_TYPE) 0x2086, ITEMID_SCROLL_1, SPELLFLAG_TARG_CHAR }, // SPELL_Reactive_Armor, { "Weaken", 0x1e6, "DM", "GaNs", (ITEMID_TYPE) 0x2087, (ITEMID_TYPE) 0x1f34, SPELLFLAG_TARG_CHAR | SPELLFLAG_DIR_ANIM | SPELLFLAG_HARM }, // SPELL_Weaken, // 2nd { "Agility", 0x1e7, "EU", "BmMr", (ITEMID_TYPE) 0x2088, (ITEMID_TYPE) 0x1f35, SPELLFLAG_TARG_CHAR, }, // SPELL_Agility, { "Cunning", 0x1eb, "UW", "MrNs", (ITEMID_TYPE) 0x2089, (ITEMID_TYPE) 0x1f36, SPELLFLAG_TARG_CHAR, }, // SPELL_Cunning, { "Cure", 0x1e0, "AN", "GaGi", (ITEMID_TYPE) 0x208a, (ITEMID_TYPE) 0x1f37, SPELLFLAG_TARG_CHAR, }, // SPELL_Cure, { "Harm", 0x1f1, "AM", "NsSs", (ITEMID_TYPE) 0x208b, (ITEMID_TYPE) 0x1f3b, SPELLFLAG_TARG_CHAR | SPELLFLAG_DIR_ANIM | SPELLFLAG_HARM }, // SPELL_Harm, { "Magic Trap", 0x1ef, "IJ", "GaSsSa", (ITEMID_TYPE) 0x208c, (ITEMID_TYPE) 0x1f39, SPELLFLAG_TARG_OBJ, }, // SPELL_Magic_Trap, { "Magic Untrap", 0x1f0, "AJ", "BmSa", (ITEMID_TYPE) 0x208d, (ITEMID_TYPE) 0x1f3a, SPELLFLAG_TARG_OBJ, }, // SPELL_Magic_Untrap, { "Protection", 0x1ed, "US", "GaGiSa", (ITEMID_TYPE) 0x208e, (ITEMID_TYPE) 0x1f3b, SPELLFLAG_TARG_CHAR }, // SPELL_Protection, { "Strength", 0x1ee, "UM", "MrNs", (ITEMID_TYPE) 0x208f, (ITEMID_TYPE) 0x1f3c, SPELLFLAG_TARG_CHAR }, // SPELL_Strength, // 3rd { "Bless", 0x1ea, "RS", "0", (ITEMID_TYPE) 0x2090, (ITEMID_TYPE) 0x1f3d, SPELLFLAG_TARG_OBJ }, // SPELL_Bless, { "Fireball", 0x15f, "VF", "0", (ITEMID_TYPE) 0x2091, (ITEMID_TYPE) 0x1f3e, SPELLFLAG_TARG_CHAR | SPELLFLAG_DIR_ANIM | SPELLFLAG_HARM }, // SPELL_Fireball, { "Magic Lock", 0x1f4, "AP", "0", (ITEMID_TYPE) 0x2092, (ITEMID_TYPE) 0x1f3f, SPELLFLAG_TARG_OBJ }, // SPELL_Magic_Lock, { "Poison", 0x205, "IN", "0", (ITEMID_TYPE) 0x2093, (ITEMID_TYPE) 0x1f40, SPELLFLAG_TARG_CHAR | SPELLFLAG_DIR_ANIM | SPELLFLAG_HARM }, // SPELL_Poison, { "Telekin", 0x1f5, "OPY", "0", (ITEMID_TYPE) 0x2094, (ITEMID_TYPE) 0x1f41, SPELLFLAG_TARG_OBJ }, // SPELL_Telekin, { "Teleport", 0x1fe, "RP", "0", (ITEMID_TYPE) 0x2095, (ITEMID_TYPE) 0x1f42, SPELLFLAG_TARG_XYZ }, // SPELL_Teleport, { "Unlock", 0x1ff, "EP", "0", (ITEMID_TYPE) 0x2096, (ITEMID_TYPE) 0x1f43, SPELLFLAG_TARG_OBJ }, // SPELL_Unlock, { "Wall of Stone", 0x1f6, "ISY", "0", (ITEMID_TYPE) 0x2097, (ITEMID_TYPE) 0x1f44, SPELLFLAG_TARG_XYZ }, // SPELL_Wall_of_Stone, // 4th { "Arch Cure", 0x1e8, "VAN", "0", (ITEMID_TYPE) 0x2098, (ITEMID_TYPE) 0x1f45, 0 }, // SPELL_Arch_Cure, { "Arch Protection",0x1f7, "VUS", "0", (ITEMID_TYPE) 0x2099, (ITEMID_TYPE) 0x1f46, 0 }, // SPELL_Arch_Prot, { "Curse", 0x1e1, "DS", "0", (ITEMID_TYPE) 0x209a, (ITEMID_TYPE) 0x1f47, SPELLFLAG_TARG_OBJ | SPELLFLAG_DIR_ANIM | SPELLFLAG_HARM }, // SPELL_Curse, { "Fire Field", 0x225, "IFG", "0", (ITEMID_TYPE) 0x209b, (ITEMID_TYPE) 0x1f48, SPELLFLAG_TARG_XYZ | SPELLFLAG_HARM }, // SPELL_Fire_Field, { "Greater Heal", 0x202, "IVM", "0", (ITEMID_TYPE) 0x209c, (ITEMID_TYPE) 0x1f49, SPELLFLAG_TARG_CHAR }, // SPELL_Great_Heal, { "Lightning", 0x029, "POG", "0", (ITEMID_TYPE) 0x209d, (ITEMID_TYPE) 0x1f4a, SPELLFLAG_TARG_CHAR | SPELLFLAG_HARM }, // SPELL_Lightning, { "Mana Drain", 0x1f8, "OR", "0", (ITEMID_TYPE) 0x209e, (ITEMID_TYPE) 0x1f4b, SPELLFLAG_TARG_CHAR | SPELLFLAG_DIR_ANIM | SPELLFLAG_HARM }, // SPELL_Mana_Drain, { "Recall", 0x1fc, "KOP", "0", (ITEMID_TYPE) 0x209f, (ITEMID_TYPE) 0x1f4c, SPELLFLAG_TARG_OBJ }, // SPELL_Recall, // 5th { "Blade Spirit", 0x212, "IHJY","0", (ITEMID_TYPE) 0x20a0, (ITEMID_TYPE) 0x1f4d, SPELLFLAG_TARG_XYZ | SPELLFLAG_HARM }, // SPELL_Blade_Spirit, { "Dispel Field", 0x210, "AG", "0", (ITEMID_TYPE) 0x20a1, (ITEMID_TYPE) 0x1f4e, SPELLFLAG_TARG_OBJ }, // SPELL_Dispel_Field, { "Incognito", 0x1ec, "KIE", "0", (ITEMID_TYPE) 0x20a2, (ITEMID_TYPE) 0x1f4f, 0 }, // SPELL_Incognito, { "Magic Reflect", 0x1e8, "IJS", "0", (ITEMID_TYPE) 0x20a3, (ITEMID_TYPE) 0x1f50, SPELLFLAG_TARG_CHAR }, // SPELL_Magic_Reflect, { "Mind_Blast", 0x213, "PCW", "0", (ITEMID_TYPE) 0x20a4, (ITEMID_TYPE) 0x1f51, SPELLFLAG_TARG_CHAR|SPELLFLAG_DIR_ANIM| SPELLFLAG_HARM }, // SPELL_Mind_Blast, { "Paralyze", 0x204, "AEP", "0", (ITEMID_TYPE) 0x20a5, (ITEMID_TYPE) 0x1f52, SPELLFLAG_TARG_CHAR|SPELLFLAG_DIR_ANIM| SPELLFLAG_HARM }, // SPELL_Paralyze, { "Poison Field", 0x226, "ING", "0", (ITEMID_TYPE) 0x20a6, (ITEMID_TYPE) 0x1f53, SPELLFLAG_TARG_XYZ | SPELLFLAG_HARM }, // SPELL_Poison_Field, { "Summon", 0x215, "KX", "0", (ITEMID_TYPE) 0x20a7, (ITEMID_TYPE) 0x1f54, SPELLFLAG_TARG_XYZ }, // SPELL_Summon, // 6th { "Dispel", 0x201, "AO", "0", (ITEMID_TYPE) 0x20a8, (ITEMID_TYPE) 0x1f55, SPELLFLAG_TARG_CHAR |SPELLFLAG_DIR_ANIM, }, // SPELL_Dispel, { "Energy Bolt", 0x20a, "CP", "0", (ITEMID_TYPE) 0x20a9, (ITEMID_TYPE) 0x1f56, SPELLFLAG_TARG_CHAR |SPELLFLAG_DIR_ANIM| SPELLFLAG_HARM }, // SPELL_Energy_Bolt, { "Explosion", 0x207, "VOF", "0", (ITEMID_TYPE) 0x20aa, (ITEMID_TYPE) 0x1f57, SPELLFLAG_TARG_CHAR |SPELLFLAG_DIR_ANIM| SPELLFLAG_HARM }, // SPELL_Explosion, { "Invisibility", 0x203, "ALX", "0", (ITEMID_TYPE) 0x20ab, (ITEMID_TYPE) 0x1f58, SPELLFLAG_TARG_CHAR }, // SPELL_Invis, { "Mark", 0x1fa, "KPY", "0", (ITEMID_TYPE) 0x20ac, (ITEMID_TYPE) 0x1f59, SPELLFLAG_TARG_OBJ }, // SPELL_Mark, { "Mass_Curse", 0x1fb, "VDS", "0", (ITEMID_TYPE) 0x20ad, (ITEMID_TYPE) 0x1f5a, SPELLFLAG_HARM }, // SPELL_Mass_Curse, { "Paralyze Field", 0x211, "IEG", "0", (ITEMID_TYPE) 0x20ae, (ITEMID_TYPE) 0x1f5b, SPELLFLAG_HARM }, // SPELL_Paralyze_Field, { "Reveal", 0x1fd, "WQ", "0", (ITEMID_TYPE) 0x20af, (ITEMID_TYPE) 0x1f5c, 0, }, // SPELL_Reveal, // 7th { "Chain Lightning",0x029, "VOG", "0", (ITEMID_TYPE) 0x20b0, (ITEMID_TYPE) 0x1f5d, SPELLFLAG_TARG_XYZ|SPELLFLAG_HARM }, // SPELL_Chain_Lightning, { "Energy Field", 0x20b, "ISG", "0", (ITEMID_TYPE) 0x20b1, (ITEMID_TYPE) 0x1f5e, SPELLFLAG_TARG_XYZ|SPELLFLAG_HARM }, // SPELL_Energy_Field, { "Flame Strike", 0x208, "KVF", "0", (ITEMID_TYPE) 0x20b2, (ITEMID_TYPE) 0x1f5f, SPELLFLAG_TARG_OBJ|SPELLFLAG_HARM }, // SPELL_Flame_Strike, { "Gate Travel", 0x20e, "VRP", "0", (ITEMID_TYPE) 0x20b3, (ITEMID_TYPE) 0x1f60, SPELLFLAG_TARG_OBJ }, // SPELL_Gate_Travel, { "Mana Vampire", 0x1f9, "OS", "0", (ITEMID_TYPE) 0x20b4, (ITEMID_TYPE) 0x1f61, SPELLFLAG_TARG_CHAR|SPELLFLAG_DIR_ANIM| SPELLFLAG_HARM }, // SPELL_Mana_Vamp, { "Mass Dispel", 0x209, "VAO", "0", (ITEMID_TYPE) 0x20b5, (ITEMID_TYPE) 0x1f62, 0 }, // SPELL_Mass_Dispel, { "Meteor Swarm", 0x160, "FKDY","0", (ITEMID_TYPE) 0x20b6, (ITEMID_TYPE) 0x1f63, SPELLFLAG_TARG_XYZ|SPELLFLAG_HARM }, // SPELL_Meteor_Swarm, { "Polymorph", 0x20f, "VYR", "0", (ITEMID_TYPE) 0x20b7, (ITEMID_TYPE) 0x1f64, 0 }, // SPELL_Polymorph, // 8th { "Earthquake", 0x20d, "IVP", "0", (ITEMID_TYPE) 0x20b8, (ITEMID_TYPE) 0x1f65, SPELLFLAG_HARM }, // SPELL_Earthquake, { "Energy Vortex", 0x212, "VCP", "0", (ITEMID_TYPE) 0x20b9, (ITEMID_TYPE) 0x1f66, SPELLFLAG_TARG_XYZ | SPELLFLAG_HARM }, // SPELL_Vortex, { "Resurrection", 0x214, "AC", "0", (ITEMID_TYPE) 0x20ba, (ITEMID_TYPE) 0x1f67, SPELLFLAG_TARG_CHAR, }, // SPELL_Resurrection, { "Air Elemental", 0x217, "KVXH","0", (ITEMID_TYPE) 0x20bb, (ITEMID_TYPE) 0x1f68, SPELLFLAG_TARG_XYZ }, // SPELL_Air_Elem, { "Daemon", 0x216, "KVXC","0", (ITEMID_TYPE) 0x20bc, (ITEMID_TYPE) 0x1f69, SPELLFLAG_TARG_XYZ }, // SPELL_Daemon, { "Earth Elemental",0x217, "KVXY","0", (ITEMID_TYPE) 0x20bd, (ITEMID_TYPE) 0x1f6a, SPELLFLAG_TARG_XYZ }, // SPELL_Earth_Elem, { "Fire Elemental", 0x217, "KVXF","0", (ITEMID_TYPE) 0x20be, (ITEMID_TYPE) 0x1f6b, SPELLFLAG_TARG_XYZ }, // SPELL_Fire_Elem, { "Water Elemental",0x217, "KVXAF","0",ITEMID_SPELL_64, ITEMID_SCROLL_64, SPELLFLAG_TARG_XYZ }, // SPELL_Water_Elem, // Necro { "Summon Undead", 0x24a, "KNM", "0", ITEMID_ALCH_SYM_1, ITEMID_SCROLL_A, SPELLFLAG_TARG_XYZ }, { "Animate Dead", 0x1e8, "IAMG", "0", ITEMID_ALCH_SYM_2, ITEMID_SCROLL_B, SPELLFLAG_TARG_OBJ }, { "Bone Armor", 0x241, "ICSY", "0", ITEMID_ALCH_SYM_3, ITEMID_SCROLL_C, SPELLFLAG_TARG_OBJ }, }; const char * Gray_szDesc = #ifdef _WIN32 GRAY_TITLE " Version " GRAY_VERSION " Alpha [WIN32] by " GRAY_NAME " <" GRAY_EMAIL ">"; #else GRAY_TITLE " Version " GRAY_VERSION " Alpha [LINUX] by " GRAY_NAME " <" GRAY_EMAIL ">"; #endif // chars int CChar::sm_iCount = 0; // UID table. int CObjBase::sm_iCount = 0; CObjBase * UIDs[ MAX_OBJECTS ] = { NULL }; // UID Translation table. // game servers stuff. CWorld World; // the world. (we save this stuff) CServer Serv; // current state stuff not saved. CLog Log; CObList GMPage; // List of GM pages. // items. CObList ItemBase; // CItemBase int CItem::sm_iCount = 0; ////////////////////////////////////////////////////////////////// // util type stuff. #ifdef COMMENT int GetRandVal( int iqty ) { return( rand() % iqty ); // return( ( rand() * (DWORD) iqty ) / ( RAND_MAX + 1 )) ; } #endif DWORD ahextoi( const char * pszStr ) // Convert hex string to integer { // Unfortunatly the library func cant handle the number FFFFFFFF // char * sstop; return( strtol( s, &sstop, 16 )); DWORD val = 0; while ( 1 ) { char ch = *pszStr; if ( ch >= '0' && ch <= '9' ) ch -= '0'; else { ch |= 0x20; // toupper() if ( ch > 'f' || ch <'a' ) break; ch -= 'a' - 10; } val *= 0x10; val += ch; pszStr ++; } return( val ); } int GetDecimalVal( const char * & pArgs ) { int iVal = 0; bool fNeg = ( *pArgs == '-' ); if ( fNeg ) pArgs ++; while ( *pArgs >= '0' && *pArgs <= '9' ) { iVal *= 10; iVal += *pArgs - '0'; pArgs++; } if ( *pArgs == '.' ) { pArgs++; while ( *pArgs >= '0' && *pArgs <= '9' ) { iVal *= 10; iVal += *pArgs - '0'; pArgs++; } } if ( fNeg ) return( -iVal ); return( iVal ); } // FIXIT! int GetRangeVal( const char * pArgs ) { int iVal = GetDecimalVal( pArgs ); while ( *pArgs == ' ' ) pArgs ++; if ( *pArgs != '-' ) return( iVal ); pArgs++; while ( *pArgs == ' ' ) pArgs ++; int iRange = GetDecimalVal( pArgs ) - iVal; if ( iRange <= 0 ) return( iVal ); return( iVal + GetRandVal( iRange )); } char * GetTempStr( void ) { // Some scratch string space, random uses static int i=0; static char szTempStr[8][256]; if ( ++i >= 8 ) i = 0; return( szTempStr[i] ); } int FindID( WORD id, const WORD * pID, int iCount ) { for ( int i=0; i < iCount; i++ ) { if ( pID[i] == id ) return( i ); } return( -1 ); } int FindTable( const char * pFind, const char * const * ppTable, int iCount, int iElemSize ) { for ( int i=0; i<iCount; i++ ) { if ( ! strcmpi( *ppTable, pFind )) return( i ); ppTable = (const char * const *)((( const BYTE*) ppTable ) + iElemSize ); } return( -1 ); } bool FindStrWord( const char * pTextSearch, const char * pszKeyWord ) { // Find the pszKeyWord in the pTextSearch string. // Make sure we look for starts of words. int j=0; for ( int i=0; 1; i++ ) { if ( pszKeyWord[j] == '\0' ) return( true ); if ( pTextSearch[i] == '\0' ) return( false ); if ( !j && i ) { char ch = toupper( pTextSearch[i-1] ); if ( ch >= 'A' && ch <= 'Z' ) // not start of word ? continue; } if ( pTextSearch[i] == toupper( pszKeyWord[j] )) j++; else j=0; } } bool Parse( char * pLine, char ** pLine2 ) { // similar to strtok() int i=0; for ( ; pLine[i] != '\0'; i++ ) { if ( pLine[i] == '=' || pLine[i] == ',' || pLine[i] == ' ' ) break; } if ( pLine[i] == '\0' ) { *pLine2 = ""; return false; } pLine[i] = '\0'; *pLine2 = &pLine[i+1]; return true; } int ParseCmds( char * pCmdLine, char ** ppCmd, int iMax ) { int iQty = 1; ppCmd[0] = pCmdLine; while ( Parse( ppCmd[iQty-1], &(ppCmd[iQty]))) { if ( ++iQty >= iMax ) break; } return( iQty ); } /////////////////////////////////////////////////////////////// // -CObjUID CObjBase * CObjUID :: ObjFind() const { DWORD dwVal = ( m_Val & UID_MASK ); if ( dwVal > COUNTOF( UIDs )) return( NULL ); return( UIDs[ dwVal ] ); } CItem * CObjUID :: ItemFind() const // Does item still exist or has it been deleted { return( dynamic_cast <CItem *>( ObjFind()) ); } CChar * CObjUID :: CharFind() const // Does character still exist { return( dynamic_cast <CChar *>( ObjFind()) ); } /////////////////////////////////////////////////////////////// // -CFile void CFile :: Close() { if ( m_pFile == NULL ) return; fclose( m_pFile ); m_pFile = NULL; } bool CFile :: Open( const char *szFilename, bool fWrite, bool fBinary ) { // Open a file. Close(); const char * pMode; if ( fBinary ) pMode = ( fWrite ) ? "wb" : "rb"; else pMode = ( fWrite ) ? "w" : "r"; m_pFile = fopen( szFilename, pMode ); if ( m_pFile == NULL ) { DEBUG_ERR(( "ERROR: %s not found...\n", szFilename )); return( false ); } return( true ); } size_t CFile :: VPrintf( const char * pFormat, va_list args ) { if ( ! IsOpen()) return( 0 ); char * pTemp = GetTempStr(); size_t len = vsprintf( pTemp, pFormat, args ); return( fwrite( pTemp, len, 1, m_pFile )); } /////////////////////////////////////////////////////////////// // -CScript int CScript :: ReadLine() // Read a line from the opened script file { if ( m_fUnRead ) { m_fUnRead = false; return( 1 ); } while ( 1 ) { if ( CFile::ReadLine( m_Line, sizeof( m_Line )) == NULL ) { m_Line[0] = '\0'; return( EOF ); } // Remove CR and LF from the end of the line. int len = strlen( m_Line ); while ( len ) { len --; if ( m_Line[len] != '\n' && m_Line[len] != '\r' ) { len ++; break; } } if ( ! len ) continue; m_Line[len] = '\0'; if ( m_Line[0] == '/' && m_Line[1] == '/' ) continue; return( 1 ); } } bool CScript :: FindSec( const char *pName ) // Find a section in the current script { if ( strlen( pName ) > MAX_NAME_SIZE ) { DEBUG_ERR(( "ERROR: Bad script section name\n" )); return( false ); } Seek(); CString sSec; sSec.Format( "[%s]", pName ); do { if ( ReadLine() == EOF ) { DEBUG_ERR(( "WARNING: Did not find script section '%s'\n", pName )); return( false ); } } while ( strnicmp( sSec, m_Line, sSec.GetLength() )); return( true ); } bool CScript :: ReadParse() // Read line from script { if ( ! Read1()) { m_pArg = ""; return( false ); // end of section. } Parse( m_Line, &m_pArg ); return( true ); } /////////////////////////////////////////////////////////////// // -CLog void CLog :: Event( const char * pFormat, ... ) { va_list args; va_start( args, pFormat ); // Print to screen. Serv.VPrintf( pFormat, args ); // Print to log file. VPrintf( pFormat, args ); } void CLog :: Error( const char * pFormat, ... ) { va_list args; va_start( args, pFormat ); // Print to screen. Serv.VPrintf( pFormat, args ); // Print to file. VPrintf( pFormat, args ); } void CLog :: Dump( const BYTE * pData, int len ) { // Just dump a bunch of bytes. 16 bytes per line. while ( len ) { char szTmp[16*3+10]; int j=0; for ( ; j < 16; j++ ) { if ( ! len ) break; sprintf( szTmp+(j*3), "%02x ", * pData ); len --; pData ++; } strcpy( szTmp+(j*3), "\n" ); Serv.Printf( szTmp ); Printf( szTmp ); // Print to log file. } } /////////////////////////////////////////////////////////////// // -CPoint int CPoint :: GetDist( CPoint p ) const // Distance between points { int dx = abs(m_x-p.m_x); int dy = abs(m_y-p.m_y); return( max( dx, dy )); } DIR_TYPE CPoint :: GetDir( CPoint p ) const // Direction to point p { int dx = (m_x-p.m_x); int dy = (m_y-p.m_y); if ( dx > 0 ) // westish { if ( dy > 0 ) return( DIR_NW ); if ( dy < 0 ) return( DIR_SW ); return( DIR_W ); } else if ( dx < 0 ) // eastish { if ( dy > 0 ) return( DIR_NE ); if ( dy < 0 ) return( DIR_SE ); return( DIR_E ); } else { if ( dy < 0 ) return( DIR_S ); if ( dy > 0 ) return( DIR_N ); return( DIR_QTY ); // here ? } } void CPoint :: Move( DIR_TYPE dir, int amount ) { // Move a point in a direction. switch ( dir ) { case DIR_N: m_y -= amount; break; case DIR_NE: m_x += amount; m_y -= amount; break; case DIR_E: m_x += amount; break; case DIR_SE: m_x += amount; m_y += amount; break; case DIR_S: m_y += amount; break; case DIR_SW: m_x -= amount; m_y += amount; break; case DIR_W: m_x -= amount; break; case DIR_NW: m_x -= amount; m_y -= amount; break; } } void CPoint :: Read( char * pStr1 ) { char * pStr2; if ( ! Parse( pStr1, &pStr2 )) return; m_x = atoi( pStr1 ); if ( ! Parse( pStr2, &pStr1 )) return; m_y = atoi( pStr2 ); m_z = atoi( pStr1 ); } const char * CPoint :: Write( void ) const { char * pTemp = GetTempStr(); sprintf( pTemp, "%d,%d,%d", m_x, m_y, m_z ); return( pTemp ); } CQuadrant * CPoint :: GetQuadrant() const { // Get the world quadrant we are in. return( & ( World.m_Quads[ (( m_y / QUAD_SIZE_Y ) * QUAD_COLS ) + ( m_x / QUAD_SIZE_X ) ] )); } ///////////////////////////////////////////////////////////////// // -CObjBase stuff // Either a player, npc or item. CObjBase :: CObjBase( WORD id, bool fItem ) { sm_iCount ++; #ifdef _DEBUG m_dwSignature = COBJBASE_SIGNATURE; #endif SetPrivateID( m_id ); m_color=0; m_timeout=0; // Find a free UID slot for this. m_UID = UID_UNUSED; if ( ! World.IsLoading()) { // Don't do this yet if we are loading. SetPrivateUID( 0, fItem ); } } CObjBase :: ~CObjBase() { sm_iCount --; Remove(); // free up the UID slot. SetPrivateUID( UID_UNUSED, false ); #ifdef _DEBUG ASSERT( m_dwSignature == COBJBASE_SIGNATURE ); m_dwSignature = 0; #endif } void CObjBase :: SetPrivateUID( DWORD dwVal, bool fItem ) { // Move the serial number, // This is possibly dangerous if conflict arrises. if ( m_UID != UID_UNUSED ) { // remove the old UID. UIDs[ ((DWORD)m_UID) & UID_MASK ] = NULL; m_UID.ClearUID(); // Invalid this just in case. } if ( dwVal != UID_UNUSED ) { dwVal &= UID_MASK; if ( dwVal == 0 || dwVal >= MAX_OBJECTS ) // Just find the first free one. { for ( dwVal=1; dwVal<MAX_OBJECTS; dwVal++ ) { if ( UIDs[dwVal] == NULL ) break; } if ( dwVal >= MAX_OBJECTS ) { // We have run out of free UID's !!! // Replace a random item. (NEVER replace a char) dwVal = GetRandVal( MAX_OBJECTS-1 ) + 1; for ( int iCount = MAX_OBJECTS; iCount--; dwVal ++ ) { if ( ! dwVal ) continue; // don't take this one. if ( UIDs[ dwVal ]->IsItem()) break; } } } if ( UIDs[ dwVal ] != this ) { if ( UIDs[ dwVal ] != NULL ) { DEBUG_ERR(( "UID conflict delete %ld, '%s'\n", dwVal, UIDs[ dwVal ]->GetName() )); delete UIDs[ dwVal ]; // ASSERT( 0 ); } UIDs[ dwVal ] = this; } if ( fItem ) dwVal |= UID_ITEM; m_UID.SetUID( dwVal ); } } void CObjBase :: SetTimeout( int iDelay ) { if ( iDelay < 0 ) { m_timeout = 0; } else { m_timeout = World.m_Clock_Time + iDelay; } } void CObjBase :: Sound( WORD id ) const // Play sound effect for player { // play for everyone near by. if ( id >= 0x300 ) return; // Max sound id ??? for ( CClient * pClient = Serv.GetClientHead(); pClient!=NULL; pClient = pClient->GetNext()) { if ( ! pClient->CanSee( this )) continue; pClient->addSound( id, this ); } } void CObjBase :: Effect( BYTE motion, ITEMID_TYPE id, const CObjBase * pSource, BYTE speed, BYTE loop, BYTE explode ) const { // show for everyone near by. for ( CClient * pClient = Serv.GetClientHead(); pClient!=NULL; pClient = pClient->GetNext()) { if ( ! pClient->CanSee( this )) continue; pClient->addEffect( motion, id, this, pSource, speed, loop, explode ); } } void CObjBase :: MoveTo( CPoint p ) { // Move this item to it's point in the world. (ground or top level) // Low level. DOES NOT UPDATE DISPLAYS CQuadrant * pQuad = p.GetQuadrant(); if ( IsItem()) pQuad->m_Items.InsertAfter( this ); else pQuad->m_Chars.InsertAfter( this ); m_p = p; } void CObjBase :: UpdateCanSee( CCommand * pCmd, int iLen, CClient * pClientExclude ) const { // Send this update message to everyone who can see this. // NOTE: Need not be a top level object. CanSee() will calc that. for ( CClient * pClient = Serv.GetClientHead(); pClient!=NULL; pClient = pClient->GetNext()) { if ( pClient == pClientExclude ) continue; if ( ! pClient->CanSee( this )) continue; pClient->xSendPkt( pCmd, iLen ); } } void CObjBase :: Write( CScript & s ) const { s.Printf( "SERIAL=%x\n", GetUID() ); if ( ! m_sName.IsEmpty()) s.Printf( "NAME=%s\n", (const char*) m_sName ); if ( m_color ) s.Printf( "COLOR=%x\n", m_color ); if ( m_timeout ) s.Printf( "TIMER=%lx\n", m_timeout ); } bool CObjBase :: LoadVal( const char * pKey, char * pVal ) { static const char * table[] = { "NAME", "COLOR", "TIMER", }; // load the basic stuff. switch ( FindTable( pKey, table, COUNTOF( table ))) { case 0: SetName( pVal ); return true; case 1: m_color = ahextoi(pVal); return true; case 2: m_timeout = atoi(pVal); return true; } return false; } void CObjBase :: Remove( CClient * pClientExclude ) { // Remove this item from all clients. //CObjBase * pObj = GetTopLevelObj(); for ( CClient * pClient = Serv.GetClientHead(); pClient!=NULL; pClient = pClient->GetNext()) { if ( pClientExclude == pClient ) continue; //if ( pClient->m_pChar->GetDist( pObj ) > UO_MAP_VIEW_BIG_SIZE ) continue; pClient->addObjectRemove( this ); } } ///////////////////////////////////////////////////////////////// int main( int argc, char *argv[] ) { assert( MAX_BUFFER >= sizeof( CCommand )); assert( MAX_BUFFER >= sizeof( CEvent )); assert( sizeof( int ) == sizeof( DWORD )); // make this assumption often. assert( ( UO_BLOCKS_X % QUAD_SIZE_X ) == 0 ); assert( ( UO_BLOCKS_Y % QUAD_SIZE_Y ) == 0 ); #ifdef _WIN32 SetConsoleTitle( GRAY_TITLE " V" GRAY_VERSION ); #endif Log.Event( GRAY_TITLE " V" GRAY_VERSION #ifdef _WIN32 " for Win32\n" #else " for Linux\n" #endif "Client Version: " GRAY_CLIENT_STR "\n" "Compiled at " __DATE__ " (" __TIME__ " " GRAY_TIMEZONE ")\n" "by " GRAY_NAME " <" GRAY_EMAIL ">\n" "\n" ); if ( ! Serv.IniRead()) { Log.Error( "ERROR: The .INI file is corrupt or missing\n" ); return( 1 ); } if ( ! World.Load()) { return( 1 ); } if ( argc > 1 ) { // Do special debug type stuff. if ( ! World.CommandLine( argc, argv )) return( 1 ); } if ( ! Serv.SocketsInit()) { return( 1 ); } Log.Event( "Startup complete. %d items %d chars\n", CItem::sm_iCount, CChar::sm_iCount ); while ( Serv.m_fKeepRun ) { #ifdef _CPPUNWIND if ( Serv.m_fSecure ) // enable the try code. { try { Serv.OnTick(); } catch (...) // catch all { static time_t preverrortick = 0; if ( preverrortick != World.m_Clock_Time ) { DEBUG_ERR(( "ERROR: Unhandled Exception time=%d!!\n", World.m_Clock_Time )); preverrortick = World.m_Clock_Time; } // Try garbage collection here ! Try to recover ? } } else #endif Serv.OnTick(); } Serv.SocketsClose(); World.Close(); if ( Serv.m_error ) Log.Error( "ERROR: Server terminated by error!\n" ); else Log.Event( "Server shutdown complete!\n"); return( Serv.m_error ); }
5ada2a875e991bf16324004dea8aaee5ee204451
87ce1bdc1173dac037fc01e6876a4b49d2a27b83
/tasklist_main.cpp
9fa2e9ba85b78a972807c2b1f65c62319c96c80c
[]
no_license
ep3998/Tasklist493---Test
fc4f4722949eab6222c80caca89f3c83a405c52f
59e4b81b1ee01eab0030475edebe10facbc11304
refs/heads/master
2016-09-05T19:22:22.144798
2012-03-22T15:40:00
2012-03-22T15:40:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
21,071
cpp
#include <QtGui> #include <QDialog> #include <QtXml/QDomElement> #include <QtXml/QDomDocument> #include <QtXml/QDomNode> #include <QtXml/QDomText> #include <QString> #include <QMessageBox> #include "tasklist_main.h" #include "tasklist_lists.h" #include "tasklist_notes.h" #include "tasklist_options.h" #include "tasklist_templates.h" #include "my_listwidget.h" //XML //Add element to node tree QDomElement TaskList_Main::addElement(QDomDocument &doc, QDomNode &node, const QString &tag, const QString &value){ QDomElement elt = doc.createElement(tag); node.appendChild(elt); if (!value.isNull()){ QDomText txt = doc.createTextNode(value); elt.appendChild(txt); } return elt; } //XML //Parse XML into tasklist form int TaskList_Main::parseXML(QDomDocument &domTree){ QDomElement set = domTree.namedItem("listset").toElement(); QMessageBox msgBox; //If tree doesn't exist, stop if(set.isNull()){ msgBox.setText("No <listset> element at top level"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } //Iterate through all "list" items QDomElement n = set.firstChildElement("list"); for( ; !n.isNull(); n = n.nextSiblingElement("list")){ emit createList(n.namedItem("list_title").toElement().text()); delListAction->setEnabled(true); printAction->setEnabled(true); printAllAction->setEnabled(true); //Iterate through all "task" items part of "list" QDomElement o = n.firstChildElement("task"); for( ; !o.isNull(); o = o.nextSiblingElement("task")){ my_listwidget *currList = notePane->listMap[notePane->currList]; QListWidgetItem *currItem; QString tempStr; //If task is 'main' (not subtext/subnote) if(o.attribute("task_type") == "main"){ //Change task name notePane->addItemAction(o.namedItem("task_title").toElement().text(), false); currItem = currList->currentItem(); //Change task check state tempStr = o.namedItem("task_check").toElement().text(); if(tempStr == "unchecked") currItem->setCheckState(Qt::Unchecked); else if (tempStr == "checked") currItem->setCheckState(Qt::Checked); else if (tempStr == "part_check") currItem->setCheckState(Qt::PartiallyChecked); else{ msgBox.setText("Unknown check state"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } //Change task subnote currItem->setData(32, QVariant( o.namedItem("task_note").toElement().text())); //Change if task subnote is displayed tempStr = o.namedItem("task_display").toElement().text(); if(tempStr == "false"){ currItem->setData(33, QVariant(false)); currItem->setData(35, QVariant(false)); } else if(tempStr == "true"){ currItem->setData(33, QVariant(true)); currItem->setData(35, QVariant(true)); } else{ msgBox.setText("Unknown bool type - display"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } //Change the task due date tempStr = o.namedItem("task_date").toElement().text(); qDebug((const char *)tempStr.toAscii().data()); QDate tempDate; int year = tempStr.left(4).toInt(); int month = tempStr.mid(5, 2).toInt(); int day = tempStr.right(2).toInt(); tempDate.setDate(year, month, day); if(!tempDate.isValid()){ msgBox.setText("Unknown date type"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } currItem->setData(34, QVariant(tempDate)); //Change the task font tempStr = o.namedItem("task_font").toElement().text(); QFont tempFont; if(!tempFont.fromString(tempStr)){ msgBox.setText("Unknown font"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } currItem->setFont(tempFont); } //Else if it is a subtext/subnote for a 'main' else if (o.attribute("task_type") == "sub"){ //Change note's text notePane->addItemAction(o.namedItem("task_title").toElement().text(), true); currItem = currList->currentItem(); currItem->setFlags(0); //Change note's font tempStr = o.namedItem("task_font").toElement().text(); QFont tempFont; if(!tempFont.fromString(tempStr)){ msgBox.setText("Unknown font"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } currItem->setFont(tempFont); } //Else, exit gracefully else{ msgBox.setText("Unknown list type"); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); return -1; } //Synchronize the option pane optionPane->itemSelectDataIn(*currItem); } } return 0; } //XML //Converts the given lists and puts them in an XML tree QString TaskList_Main::listsToXML(const QListWidget &inList){ QDomDocument doc; QDomProcessingInstruction instr = doc.createProcessingInstruction( "xml", "version='1.0' encoding='UTF-8'"); doc.appendChild(instr); //Create list to hold individual task lists QDomElement listElement = addElement(doc, doc, "listset"); //Iteratore through available 'lists' for(int i = 0; i < inList.count(); ++i){ QDomElement list = addElement(doc, listElement, "list"); addElement(doc, list, "list_title", inList.item(i)->text()); //Find associated note mapping my_listwidget *listPtr = notePane->listMap[inList.item(i)]; //Iterates through 'tasks' in 'list' bool nextIsSub = false; for(int j = 0; j < listPtr->count(); ++j){ QDomElement task = addElement(doc, list, "task"); QListWidgetItem *taskPtr = listPtr->item(j); //If next item is subtext... if(nextIsSub){ nextIsSub = false; task.setAttribute("task_type", "sub"); addElement(doc, task, "task_title", taskPtr->text()); addElement(doc, task, "task_font", taskPtr->font().toString()); } //Else, we know it's main task else{ task.setAttribute("task_type", "main"); addElement(doc, task, "task_title", taskPtr->text()); if(taskPtr->checkState() == Qt::Unchecked) addElement(doc, task, "task_check", "unchecked"); if(taskPtr->checkState() == Qt::Checked) addElement(doc, task, "task_check", "checked"); if(taskPtr->checkState() == Qt::PartiallyChecked) addElement(doc, task, "task_check", "part_check"); addElement(doc, task, "task_note", taskPtr->data(32).toString()); addElement(doc, task, "task_display", taskPtr->data(33).toString()); addElement(doc, task, "task_date", taskPtr->data(34).toDate().toString(Qt::ISODate)); addElement(doc, task, "task_font", taskPtr->font().toString()); if(taskPtr->data(35).toBool() == true){ nextIsSub = true; } } } } //Return DOM document return doc.toString(); } //Slot for expanding and closing "additional info" //panel IE the right pane void TaskList_Main::expClick(){ if(optionPane->isHidden()){ optionPane->setHidden(false); expButton->setIcon(QIcon(":img/icon/left_arrow.png")); } else{ optionPane->setHidden(true); optionPane->applyClicked(); expButton->setIcon(QIcon(":img/icon/right_arrow.png")); } } //New list create wrapper (list has no name) void TaskList_Main::newListCreate(){ QString tempStr = NULL; emit createList(tempStr); delListAction->setEnabled(true); printAction->setEnabled(true); printAllAction->setEnabled(true); } //Generate template modal window void TaskList_Main::newListClick(){ tasklist_templates *tmpWidget = new tasklist_templates(this, Qt::Popup | Qt::Dialog); tmpWidget->setWindowModality(Qt::WindowModal); tmpWidget->show(); } //Delete list clicked void TaskList_Main::delListClick(){ listPane->deleteListClicked = true; QListWidgetItem * tempPtr = listPane->mainList->takeItem( listPane->mainList->currentRow()); notePane->listMap[tempPtr]->setParent(0); notePane->listMap[tempPtr]->setDisabled(true); notePane->listMap.erase(tempPtr); delete tempPtr; if(listPane->mainList->count() == 0){ qDebug("nothing left"); delListAction->setDisabled(true); printAction->setDisabled(true); printAllAction->setDisabled(true); notePane->listChanged(NULL); } else{ qDebug("something left"); notePane->listChanged(listPane->mainList->currentItem()); } listPane->deleteListClicked = false; } //Open XML action void TaskList_Main::openXML(QString &xmlPath){ if(!xmlPath.isEmpty()) openClickAction(xmlPath, false); else newListCreate(); } //Open click wrapper for button void TaskList_Main::openClick(){ QString name = ""; openClickAction(name, true); } //Open XML file clicked void TaskList_Main::openClickAction(QString inName, bool clearLists){ if(inName.trimmed().isEmpty()) inName = QFileDialog::getOpenFileName(this, tr("Open List File"), QDir::currentPath(), tr("LIST Files (*.xml)")); if(inName.isEmpty()) return; //Open file stream QFile in(inName); if(!in.open(QFile::ReadOnly| QFile::Text)){ QMessageBox::warning(this, tr("Open List"), tr("Cannot open file %1:\n%2") .arg(inName).arg(in.errorString())); return; } //If not a template, clear listing if(clearLists){ while(listPane->mainList->count() != 0) delListClick(); } //Create the XML document to read in QDomDocument doc; QString errorMsg; int errorLine, errorColumn; if(doc.setContent(&in, &errorMsg, &errorLine, &errorColumn)){ if(parseXML(doc) < 0){ while(listPane->mainList->count() != 0) delListClick(); } } else{ errorMsg.append(" line "); errorMsg.append(QString::number(errorLine)); errorMsg.append(" col "); errorMsg.append(QString::number(errorColumn)); QMessageBox msgBox; msgBox.setText(errorMsg.toAscii().data()); msgBox.setWindowTitle("Erorr parsing XML"); msgBox.exec(); } //Handle whether it came from template rsc. or from //actual user file qDebug(inName.toAscii().data()); if(!inName.contains(":/tmp/xml/")) myFileName = inName; //If task_week item, sync up next dates for tasks else if(inName.contains(":/tmp/xml/task_groceries.xml")){ QDate currDate = QDate::currentDate(); qDebug(currDate.toString().toAscii().data()); QListWidgetItem *listPtr = listPane->mainList->currentItem(); my_listwidget *taskPtr = notePane->listMap[listPtr]; for(int task = 0; task < taskPtr->count(); ++task){ taskPtr->item(task)->setData(34, QVariant(currDate)); optionPane->itemSelectDataIn(*taskPtr->item(task)); } } else if(inName.contains(":/tmp/xml/task_week.xml")){ QDate currDate = QDate::currentDate(); qDebug(currDate.toString().toAscii().data()); while(currDate.dayOfWeek() != 1){ qDebug("add day"); currDate = currDate.addDays(1); qDebug(currDate.toString().toAscii().data()); } for(int day = listPane->mainList->count()-7; day < listPane->mainList->count(); ++day){ QListWidgetItem *listPtr = listPane->mainList->item(day); my_listwidget *dayPtr = notePane->listMap[listPtr]; QString newTitle = currDate.toString(); listPtr->setText(newTitle); for(int task = 0; task < dayPtr->count(); ++task){ dayPtr->item(task)->setData(34, QVariant(currDate)); optionPane->itemSelectDataIn(*dayPtr->item(task)); } currDate = currDate.addDays(1); } } } //Save action clicked void TaskList_Main::saveClick(){ if(myFileName != ""){ //Open a file stream if file accessed already QFile file(myFileName); if(!file.open(QFile::WriteOnly | QFile::Text)){ QMessageBox::warning(this, tr("Save List"), tr("Cannot write file %1:\n%2") .arg(myFileName).arg(file.errorString())); return; } //If file successfully saved, update status if(file.write((const char *)listsToXML(*listPane->mainList).toAscii().data())){ statusBar()->showMessage(tr("File saved"), 2000); } } else saveAsClick(); //Get a file name/path } //Save as clicked, need to get new file path void TaskList_Main::saveAsClick(){ QString outFile = QFileDialog::getSaveFileName(this, tr("Save List File"), QDir::currentPath(), tr("LIST Files (*.xml)")); if(outFile.isEmpty()) return; //Open a file stream QFile file(outFile); if(!file.open(QFile::WriteOnly | QFile::Text)){ QMessageBox::warning(this, tr("Save List"), tr("Cannot write file %1:\n%2") .arg(outFile).arg(file.errorString())); return; } //Write to the file stream the XML metadata if(file.write((const char *)listsToXML(*listPane->mainList).toAscii().data())){ statusBar()->showMessage(tr("File saved"), 2000); myFileName = outFile; } } //Print clicked, format current list //for printing void TaskList_Main::printClick(){ QPrinter printer; //Create new print dialog (select printer) QPrintDialog *pDialog = new QPrintDialog(&printer, this); pDialog->setWindowTitle(tr("Print Document")); if(pDialog->exec() != QDialog::Accepted) return; else{ QTextDocument document; QString html = ""; QListWidgetItem *currList = listPane->mainList->currentItem(); my_listwidget *currNote = notePane->listMap[currList]; //Generate HTML driven output html += "<font size=\"8\"><b>" + currList->text() + "</b></font><br />"; for(int i = 0; i < currNote->count(); i++){ if(currNote->item(i)->flags() != 0) html += "<font size=\"5\">" + currNote->item(i)->text() + "</font><br />"; else html += "--<font size=\"4\">" + currNote->item(i)->text() + "</font><br />"; } //Set document's HTML info document.setHtml(html); //Print the HTML text document.print(&printer); } } //Print clicked, format all lists //for printing void TaskList_Main::printAllClick(){ QPrinter printer; //Create new print dialog (select printer) QPrintDialog *pDialog = new QPrintDialog(&printer, this); pDialog->setWindowTitle(tr("Print Document")); if(pDialog->exec() != QDialog::Accepted) return; else{ QTextDocument document; QString html = ""; for(int i = 0; i < listPane->mainList->count(); ++i){ QListWidgetItem *currList = listPane->mainList->item(i); my_listwidget *currNote = notePane->listMap[currList]; //Generate HTML driven output html += "<font size=\"7\"><b>" + currList->text() + "</b></font><br />"; for(int i = 0; i < currNote->count(); i++){ if(currNote->item(i)->flags() != 0) html += "<font size=\"5\">" + currNote->item(i)->text() + "</font><br />"; else html += "--<font size=\"4\"><i>" + currNote->item(i)->text() + "</i></font><br />"; } html += "<br />"; } //Set document's HTML info document.setHtml(html); //Print the HTML text document.print(&printer); } } //Create the menu bar void TaskList_Main::createMenu(){ menuBar = new QMenuBar; fileMenu = new QMenu(tr("File"), this); newListAction = fileMenu->addAction(tr("New List...")); newListAction->setShortcuts(QKeySequence::New); delListAction = fileMenu->addAction(tr("Delete Current List...")); delListAction->setShortcuts(QKeySequence::Delete); delListAction->setDisabled(true); openListAction = fileMenu->addAction(tr("Open List...")); openListAction->setShortcuts(QKeySequence::Open); saveAction = fileMenu->addAction(tr("Save Lists...")); saveAction->setShortcuts(QKeySequence::Save); saveAsAction = fileMenu->addAction(tr("Save Lists As...")); saveAsAction->setShortcuts(QKeySequence::SaveAs); printAction = fileMenu->addAction(tr("Print...")); printAction->setShortcuts(QKeySequence::Print); printAction->setDisabled(true); printAllAction = fileMenu->addAction(tr("Print all...")); printAllAction->setDisabled(true); quitAction = fileMenu->addAction(tr("Exit")); quitAction->setShortcuts(QKeySequence::Quit); //Show menu menuBar->addMenu(fileMenu); //Connect actions to associated slots connect(newListAction, SIGNAL(triggered()), this, SLOT(newListClick())); connect(delListAction, SIGNAL(triggered()), this, SLOT(delListClick())); connect(quitAction, SIGNAL(triggered()),this,SLOT(close())); connect(printAction, SIGNAL(triggered()), this, SLOT(printClick())); connect(printAllAction, SIGNAL(triggered()), this, SLOT(printAllClick())); connect(openListAction, SIGNAL(triggered()), this, SLOT(openClick())); connect(saveAction, SIGNAL(triggered()), this, SLOT(saveClick())); connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAsClick())); } //Sets up layout that combines left and right panes TaskList_Main::TaskList_Main(QWidget *parent) : QMainWindow(parent) { listPane = new tasklist_lists(this); listPane->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); notePane = new tasklist_notes(this); notePane->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); optionPane = new tasklist_options(this); optionPane->setHidden(true); expButton = new QPushButton(""); expButton->setAutoFillBackground(true); expButton->setIcon(QIcon(":img/icon/right_arrow.png")); expButton->setIconSize(QSize(15,300)); expButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding); QHBoxLayout *paneLayout = new QHBoxLayout; paneLayout->addWidget(listPane); paneLayout->addWidget(notePane); paneLayout->addWidget(expButton); paneLayout->addWidget(optionPane); //Set the central widget (work-around) QWidget *central = new QWidget(); central->setLayout(paneLayout); this->setCentralWidget(central); createMenu(); setMenuBar(menuBar); //Connect signals between different panes connect(expButton, SIGNAL(clicked()), this, SLOT(expClick())); connect(optionPane, SIGNAL(noteInfoSent(QListWidgetItem&)), notePane, SLOT(applyClicked(QListWidgetItem&))); connect(notePane, SIGNAL(itemSelectEmit(QListWidgetItem&)), optionPane, SLOT(itemSelectDataIn(QListWidgetItem&))); connect(optionPane, SIGNAL(cancelPane()), this, SLOT(expClick())); connect(this, SIGNAL(createList(QString)), listPane, SLOT(newList(const QString &))); connect(listPane, SIGNAL(listSelectEmit(QListWidgetItem*)), notePane, SLOT(listChanged(QListWidgetItem*))); }
c0aaf1ca2dde5ff742eea27b35ab64bd5c4fb314
ae2c06e5e01132bdc9d2fd3d78a558d0d92ad85b
/src/wallet/wallet.cpp
10d69d411f3a2546e0b23928bf9b9fbfb319374e
[ "MIT" ]
permissive
communitycoin1/cc
1cd8c2736a626635ffb0c59fab7a0c7ead3b0fb3
d539107da36b68ccebe320acaa4bfd1819751825
refs/heads/master
2020-03-21T16:13:08.729536
2018-06-27T21:25:11
2018-06-27T21:25:11
138,757,652
0
0
null
null
null
null
UTF-8
C++
false
false
157,266
cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Copyright (c) 2014-2017 The Communitycoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "wallet/wallet.h" #include "base58.h" #include "checkpoints.h" #include "chain.h" #include "coincontrol.h" #include "consensus/consensus.h" #include "consensus/validation.h" #include "key.h" #include "keystore.h" #include "validation.h" #include "net.h" #include "policy/policy.h" #include "primitives/block.h" #include "primitives/transaction.h" #include "script/script.h" #include "script/sign.h" #include "timedata.h" #include "txmempool.h" #include "util.h" #include "utilmoneystr.h" #include "governance.h" #include "instantx.h" #include "keepass.h" #include "privatesend-client.h" #include "spork.h" #include <assert.h> #include <boost/algorithm/string/replace.hpp> #include <boost/filesystem.hpp> #include <boost/thread.hpp> using namespace std; /** Transaction fee set by the user */ CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE); CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE; unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET; bool bSpendZeroConfChange = DEFAULT_SPEND_ZEROCONF_CHANGE; bool fSendFreeTransactions = DEFAULT_SEND_FREE_TRANSACTIONS; /** * Fees smaller than this (in duffs) are considered zero fee (for transaction creation) * Override with -mintxfee */ CFeeRate CWallet::minTxFee = CFeeRate(DEFAULT_TRANSACTION_MINFEE); /** * If fee estimation does not have enough data to provide estimates, use this fee instead. * Has no effect if not using fee estimation * Override with -fallbackfee */ CFeeRate CWallet::fallbackFee = CFeeRate(DEFAULT_FALLBACK_FEE); const uint256 CMerkleTx::ABANDON_HASH(uint256S("0000000000000000000000000000000000000000000000000000000000000001")); /** @defgroup mapWallet * * @{ */ struct CompareValueOnly { bool operator()(const pair<CAmount, pair<const CWalletTx*, unsigned int> >& t1, const pair<CAmount, pair<const CWalletTx*, unsigned int> >& t2) const { return t1.first < t2.first; } }; std::string COutput::ToString() const { return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue)); } int COutput::Priority() const { BOOST_FOREACH(CAmount d, CPrivateSend::GetStandardDenominations()) if(tx->vout[i].nValue == d) return 10000; if(tx->vout[i].nValue < 1*COIN) return 20000; //nondenom return largest first return -(tx->vout[i].nValue/COIN); } const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const { LOCK(cs_wallet); std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(hash); if (it == mapWallet.end()) return NULL; return &(it->second); } CPubKey CWallet::GenerateNewKey(uint32_t nAccountIndex, bool fInternal) { AssertLockHeld(cs_wallet); // mapKeyMetadata bool fCompressed = CanSupportFeature(FEATURE_COMPRPUBKEY); // default to compressed public keys if we want 0.6.0 wallets CKey secret; // Create new metadata int64_t nCreationTime = GetTime(); CKeyMetadata metadata(nCreationTime); CPubKey pubkey; // use HD key derivation if HD was enabled during wallet creation if (IsHDEnabled()) { DeriveNewChildKey(metadata, secret, nAccountIndex, fInternal); pubkey = secret.GetPubKey(); } else { secret.MakeNewKey(fCompressed); // Compressed public keys were introduced in version 0.6.0 if (fCompressed) SetMinVersion(FEATURE_COMPRPUBKEY); pubkey = secret.GetPubKey(); assert(secret.VerifyPubKey(pubkey)); // Create new metadata mapKeyMetadata[pubkey.GetID()] = metadata; if (!nTimeFirstKey || nCreationTime < nTimeFirstKey) nTimeFirstKey = nCreationTime; if (!AddKeyPubKey(secret, pubkey)) throw std::runtime_error(std::string(__func__) + ": AddKey failed"); } return pubkey; } void CWallet::DeriveNewChildKey(const CKeyMetadata& metadata, CKey& secretRet, uint32_t nAccountIndex, bool fInternal) { CHDChain hdChainTmp; if (!GetHDChain(hdChainTmp)) { throw std::runtime_error(std::string(__func__) + ": GetHDChain failed"); } if (!DecryptHDChain(hdChainTmp)) throw std::runtime_error(std::string(__func__) + ": DecryptHDChainSeed failed"); // make sure seed matches this chain if (hdChainTmp.GetID() != hdChainTmp.GetSeedHash()) throw std::runtime_error(std::string(__func__) + ": Wrong HD chain!"); CHDAccount acc; if (!hdChainTmp.GetAccount(nAccountIndex, acc)) throw std::runtime_error(std::string(__func__) + ": Wrong HD account!"); // derive child key at next index, skip keys already known to the wallet CExtKey childKey; uint32_t nChildIndex = fInternal ? acc.nInternalChainCounter : acc.nExternalChainCounter; do { hdChainTmp.DeriveChildExtKey(nAccountIndex, fInternal, nChildIndex, childKey); // increment childkey index nChildIndex++; } while (HaveKey(childKey.key.GetPubKey().GetID())); secretRet = childKey.key; CPubKey pubkey = secretRet.GetPubKey(); assert(secretRet.VerifyPubKey(pubkey)); // store metadata mapKeyMetadata[pubkey.GetID()] = metadata; if (!nTimeFirstKey || metadata.nCreateTime < nTimeFirstKey) nTimeFirstKey = metadata.nCreateTime; // update the chain model in the database CHDChain hdChainCurrent; GetHDChain(hdChainCurrent); if (fInternal) { acc.nInternalChainCounter = nChildIndex; } else { acc.nExternalChainCounter = nChildIndex; } if (!hdChainCurrent.SetAccount(nAccountIndex, acc)) throw std::runtime_error(std::string(__func__) + ": SetAccount failed"); if (IsCrypted()) { if (!SetCryptedHDChain(hdChainCurrent, false)) throw std::runtime_error(std::string(__func__) + ": SetCryptedHDChain failed"); } else { if (!SetHDChain(hdChainCurrent, false)) throw std::runtime_error(std::string(__func__) + ": SetHDChain failed"); } if (!AddHDPubKey(childKey.Neuter(), fInternal)) throw std::runtime_error(std::string(__func__) + ": AddHDPubKey failed"); } bool CWallet::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const { LOCK(cs_wallet); std::map<CKeyID, CHDPubKey>::const_iterator mi = mapHdPubKeys.find(address); if (mi != mapHdPubKeys.end()) { const CHDPubKey &hdPubKey = (*mi).second; vchPubKeyOut = hdPubKey.extPubKey.pubkey; return true; } else return CCryptoKeyStore::GetPubKey(address, vchPubKeyOut); } bool CWallet::GetKey(const CKeyID &address, CKey& keyOut) const { LOCK(cs_wallet); std::map<CKeyID, CHDPubKey>::const_iterator mi = mapHdPubKeys.find(address); if (mi != mapHdPubKeys.end()) { // if the key has been found in mapHdPubKeys, derive it on the fly const CHDPubKey &hdPubKey = (*mi).second; CHDChain hdChainCurrent; if (!GetHDChain(hdChainCurrent)) throw std::runtime_error(std::string(__func__) + ": GetHDChain failed"); if (!DecryptHDChain(hdChainCurrent)) throw std::runtime_error(std::string(__func__) + ": DecryptHDChainSeed failed"); // make sure seed matches this chain if (hdChainCurrent.GetID() != hdChainCurrent.GetSeedHash()) throw std::runtime_error(std::string(__func__) + ": Wrong HD chain!"); CExtKey extkey; hdChainCurrent.DeriveChildExtKey(hdPubKey.nAccountIndex, hdPubKey.nChangeIndex != 0, hdPubKey.extPubKey.nChild, extkey); keyOut = extkey.key; return true; } else { return CCryptoKeyStore::GetKey(address, keyOut); } } bool CWallet::HaveKey(const CKeyID &address) const { LOCK(cs_wallet); if (mapHdPubKeys.count(address) > 0) return true; return CCryptoKeyStore::HaveKey(address); } bool CWallet::LoadHDPubKey(const CHDPubKey &hdPubKey) { AssertLockHeld(cs_wallet); mapHdPubKeys[hdPubKey.extPubKey.pubkey.GetID()] = hdPubKey; return true; } bool CWallet::AddHDPubKey(const CExtPubKey &extPubKey, bool fInternal) { AssertLockHeld(cs_wallet); CHDChain hdChainCurrent; GetHDChain(hdChainCurrent); CHDPubKey hdPubKey; hdPubKey.extPubKey = extPubKey; hdPubKey.hdchainID = hdChainCurrent.GetID(); hdPubKey.nChangeIndex = fInternal ? 1 : 0; mapHdPubKeys[extPubKey.pubkey.GetID()] = hdPubKey; // check if we need to remove from watch-only CScript script; script = GetScriptForDestination(extPubKey.pubkey.GetID()); if (HaveWatchOnly(script)) RemoveWatchOnly(script); script = GetScriptForRawPubKey(extPubKey.pubkey); if (HaveWatchOnly(script)) RemoveWatchOnly(script); if (!fFileBacked) return true; return CWalletDB(strWalletFile).WriteHDPubKey(hdPubKey, mapKeyMetadata[extPubKey.pubkey.GetID()]); } bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey) { AssertLockHeld(cs_wallet); // mapKeyMetadata if (!CCryptoKeyStore::AddKeyPubKey(secret, pubkey)) return false; // check if we need to remove from watch-only CScript script; script = GetScriptForDestination(pubkey.GetID()); if (HaveWatchOnly(script)) RemoveWatchOnly(script); script = GetScriptForRawPubKey(pubkey); if (HaveWatchOnly(script)) RemoveWatchOnly(script); if (!fFileBacked) return true; if (!IsCrypted()) { return CWalletDB(strWalletFile).WriteKey(pubkey, secret.GetPrivKey(), mapKeyMetadata[pubkey.GetID()]); } return true; } bool CWallet::AddCryptedKey(const CPubKey &vchPubKey, const vector<unsigned char> &vchCryptedSecret) { if (!CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret)) return false; if (!fFileBacked) return true; { LOCK(cs_wallet); if (pwalletdbEncryption) return pwalletdbEncryption->WriteCryptedKey(vchPubKey, vchCryptedSecret, mapKeyMetadata[vchPubKey.GetID()]); else return CWalletDB(strWalletFile).WriteCryptedKey(vchPubKey, vchCryptedSecret, mapKeyMetadata[vchPubKey.GetID()]); } return false; } bool CWallet::LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &meta) { AssertLockHeld(cs_wallet); // mapKeyMetadata if (meta.nCreateTime && (!nTimeFirstKey || meta.nCreateTime < nTimeFirstKey)) nTimeFirstKey = meta.nCreateTime; mapKeyMetadata[pubkey.GetID()] = meta; return true; } bool CWallet::LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret) { return CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret); } bool CWallet::AddCScript(const CScript& redeemScript) { if (!CCryptoKeyStore::AddCScript(redeemScript)) return false; if (!fFileBacked) return true; return CWalletDB(strWalletFile).WriteCScript(Hash160(redeemScript), redeemScript); } bool CWallet::LoadCScript(const CScript& redeemScript) { /* A sanity check was added in pull #3843 to avoid adding redeemScripts * that never can be redeemed. However, old wallets may still contain * these. Do not add them to the wallet and warn. */ if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE) { std::string strAddr = CBitcoinAddress(CScriptID(redeemScript)).ToString(); LogPrintf("%s: Warning: This wallet contains a redeemScript of size %i which exceeds maximum size %i thus can never be redeemed. Do not use address %s.\n", __func__, redeemScript.size(), MAX_SCRIPT_ELEMENT_SIZE, strAddr); return true; } return CCryptoKeyStore::AddCScript(redeemScript); } bool CWallet::AddWatchOnly(const CScript &dest) { if (!CCryptoKeyStore::AddWatchOnly(dest)) return false; nTimeFirstKey = 1; // No birthday information for watch-only keys. NotifyWatchonlyChanged(true); if (!fFileBacked) return true; return CWalletDB(strWalletFile).WriteWatchOnly(dest); } bool CWallet::RemoveWatchOnly(const CScript &dest) { AssertLockHeld(cs_wallet); if (!CCryptoKeyStore::RemoveWatchOnly(dest)) return false; if (!HaveWatchOnly()) NotifyWatchonlyChanged(false); if (fFileBacked) if (!CWalletDB(strWalletFile).EraseWatchOnly(dest)) return false; return true; } bool CWallet::LoadWatchOnly(const CScript &dest) { return CCryptoKeyStore::AddWatchOnly(dest); } bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool fForMixingOnly) { SecureString strWalletPassphraseFinal; if (!IsLocked()) // was already fully unlocked, not only for mixing return true; // Verify KeePassIntegration if (strWalletPassphrase == "keepass" && GetBoolArg("-keepass", false)) { try { strWalletPassphraseFinal = keePassInt.retrievePassphrase(); } catch (std::exception& e) { LogPrintf("CWallet::Unlock could not retrieve passphrase from KeePass: Error: %s\n", e.what()); return false; } } else { strWalletPassphraseFinal = strWalletPassphrase; } CCrypter crypter; CKeyingMaterial vMasterKey; { LOCK(cs_wallet); BOOST_FOREACH(const MasterKeyMap::value_type& pMasterKey, mapMasterKeys) { if (!crypter.SetKeyFromPassphrase(strWalletPassphraseFinal, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) continue; // try another master key if (CCryptoKeyStore::Unlock(vMasterKey, fForMixingOnly)) { if(nWalletBackups == -2) { TopUpKeyPool(); LogPrintf("Keypool replenished, re-initializing automatic backups.\n"); nWalletBackups = GetArg("-createwalletbackups", 10); } return true; } } } return false; } bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase) { bool fWasLocked = IsLocked(true); bool bUseKeePass = false; SecureString strOldWalletPassphraseFinal; // Verify KeePassIntegration if(strOldWalletPassphrase == "keepass" && GetBoolArg("-keepass", false)) { bUseKeePass = true; try { strOldWalletPassphraseFinal = keePassInt.retrievePassphrase(); } catch (std::exception& e) { LogPrintf("CWallet::ChangeWalletPassphrase -- could not retrieve passphrase from KeePass: Error: %s\n", e.what()); return false; } } else { strOldWalletPassphraseFinal = strOldWalletPassphrase; } { LOCK(cs_wallet); Lock(); CCrypter crypter; CKeyingMaterial vMasterKey; BOOST_FOREACH(MasterKeyMap::value_type& pMasterKey, mapMasterKeys) { if(!crypter.SetKeyFromPassphrase(strOldWalletPassphraseFinal, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) return false; if (CCryptoKeyStore::Unlock(vMasterKey)) { int64_t nStartTime = GetTimeMillis(); crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod); pMasterKey.second.nDeriveIterations = pMasterKey.second.nDeriveIterations * (100 / ((double)(GetTimeMillis() - nStartTime))); nStartTime = GetTimeMillis(); crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod); pMasterKey.second.nDeriveIterations = (pMasterKey.second.nDeriveIterations + pMasterKey.second.nDeriveIterations * 100 / ((double)(GetTimeMillis() - nStartTime))) / 2; if (pMasterKey.second.nDeriveIterations < 25000) pMasterKey.second.nDeriveIterations = 25000; LogPrintf("Wallet passphrase changed to an nDeriveIterations of %i\n", pMasterKey.second.nDeriveIterations); if (!crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; if (!crypter.Encrypt(vMasterKey, pMasterKey.second.vchCryptedKey)) return false; CWalletDB(strWalletFile).WriteMasterKey(pMasterKey.first, pMasterKey.second); if (fWasLocked) Lock(); // Update KeePass if necessary if(bUseKeePass) { LogPrintf("CWallet::ChangeWalletPassphrase -- Updating KeePass with new passphrase"); try { keePassInt.updatePassphrase(strNewWalletPassphrase); } catch (std::exception& e) { LogPrintf("CWallet::ChangeWalletPassphrase -- could not update passphrase in KeePass: Error: %s\n", e.what()); return false; } } return true; } } } return false; } void CWallet::SetBestChain(const CBlockLocator& loc) { CWalletDB walletdb(strWalletFile); walletdb.WriteBestBlock(loc); } bool CWallet::SetMinVersion(enum WalletFeature nVersion, CWalletDB* pwalletdbIn, bool fExplicit) { LOCK(cs_wallet); // nWalletVersion if (nWalletVersion >= nVersion) return true; // when doing an explicit upgrade, if we pass the max version permitted, upgrade all the way if (fExplicit && nVersion > nWalletMaxVersion) nVersion = FEATURE_LATEST; nWalletVersion = nVersion; if (nVersion > nWalletMaxVersion) nWalletMaxVersion = nVersion; if (fFileBacked) { CWalletDB* pwalletdb = pwalletdbIn ? pwalletdbIn : new CWalletDB(strWalletFile); if (nWalletVersion > 40000) pwalletdb->WriteMinVersion(nWalletVersion); if (!pwalletdbIn) delete pwalletdb; } return true; } bool CWallet::SetMaxVersion(int nVersion) { LOCK(cs_wallet); // nWalletVersion, nWalletMaxVersion // cannot downgrade below current version if (nWalletVersion > nVersion) return false; nWalletMaxVersion = nVersion; return true; } set<uint256> CWallet::GetConflicts(const uint256& txid) const { set<uint256> result; AssertLockHeld(cs_wallet); std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(txid); if (it == mapWallet.end()) return result; const CWalletTx& wtx = it->second; std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range; BOOST_FOREACH(const CTxIn& txin, wtx.vin) { if (mapTxSpends.count(txin.prevout) <= 1) continue; // No conflict if zero or one spends range = mapTxSpends.equal_range(txin.prevout); for (TxSpends::const_iterator it = range.first; it != range.second; ++it) result.insert(it->second); } return result; } void CWallet::Flush(bool shutdown) { bitdb.Flush(shutdown); } bool CWallet::Verify(const string& walletFile, string& warningString, string& errorString) { if (!bitdb.Open(GetDataDir())) { // try moving the database env out of the way boost::filesystem::path pathDatabase = GetDataDir() / "database"; boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%d.bak", GetTime()); try { boost::filesystem::rename(pathDatabase, pathDatabaseBak); LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string(), pathDatabaseBak.string()); } catch (const boost::filesystem::filesystem_error&) { // failure is ok (well, not really, but it's not worse than what we started with) } // try again if (!bitdb.Open(GetDataDir())) { // if it still fails, it probably means we can't even create the database env string msg = strprintf(_("Error initializing wallet database environment %s!"), GetDataDir()); errorString += msg; return true; } } if (GetBoolArg("-salvagewallet", false)) { // Recover readable keypairs: if (!CWalletDB::Recover(bitdb, walletFile, true)) return false; } if (boost::filesystem::exists(GetDataDir() / walletFile)) { CDBEnv::VerifyResult r = bitdb.Verify(walletFile, CWalletDB::Recover); if (r == CDBEnv::RECOVER_OK) { warningString += strprintf(_("Warning: wallet.dat corrupt, data salvaged!" " Original wallet.dat saved as wallet.{timestamp}.bak in %s; if" " your balance or transactions are incorrect you should" " restore from a backup."), GetDataDir()); } if (r == CDBEnv::RECOVER_FAIL) errorString += _("wallet.dat corrupt, salvage failed"); } return true; } void CWallet::SyncMetaData(pair<TxSpends::iterator, TxSpends::iterator> range) { // We want all the wallet transactions in range to have the same metadata as // the oldest (smallest nOrderPos). // So: find smallest nOrderPos: int nMinOrderPos = std::numeric_limits<int>::max(); const CWalletTx* copyFrom = NULL; for (TxSpends::iterator it = range.first; it != range.second; ++it) { const uint256& hash = it->second; int n = mapWallet[hash].nOrderPos; if (n < nMinOrderPos) { nMinOrderPos = n; copyFrom = &mapWallet[hash]; } } // Now copy data from copyFrom to rest: for (TxSpends::iterator it = range.first; it != range.second; ++it) { const uint256& hash = it->second; CWalletTx* copyTo = &mapWallet[hash]; if (copyFrom == copyTo) continue; if (!copyFrom->IsEquivalentTo(*copyTo)) continue; copyTo->mapValue = copyFrom->mapValue; copyTo->vOrderForm = copyFrom->vOrderForm; // fTimeReceivedIsTxTime not copied on purpose // nTimeReceived not copied on purpose copyTo->nTimeSmart = copyFrom->nTimeSmart; copyTo->fFromMe = copyFrom->fFromMe; copyTo->strFromAccount = copyFrom->strFromAccount; // nOrderPos not copied on purpose // cached members not copied on purpose } } /** * Outpoint is spent if any non-conflicted transaction * spends it: */ bool CWallet::IsSpent(const uint256& hash, unsigned int n) const { const COutPoint outpoint(hash, n); pair<TxSpends::const_iterator, TxSpends::const_iterator> range; range = mapTxSpends.equal_range(outpoint); for (TxSpends::const_iterator it = range.first; it != range.second; ++it) { const uint256& wtxid = it->second; std::map<uint256, CWalletTx>::const_iterator mit = mapWallet.find(wtxid); if (mit != mapWallet.end()) { int depth = mit->second.GetDepthInMainChain(); if (depth > 0 || (depth == 0 && !mit->second.isAbandoned())) return true; // Spent } } return false; } void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid) { mapTxSpends.insert(make_pair(outpoint, wtxid)); setWalletUTXO.erase(outpoint); pair<TxSpends::iterator, TxSpends::iterator> range; range = mapTxSpends.equal_range(outpoint); SyncMetaData(range); } void CWallet::AddToSpends(const uint256& wtxid) { assert(mapWallet.count(wtxid)); CWalletTx& thisTx = mapWallet[wtxid]; if (thisTx.IsCoinBase()) // Coinbases don't spend anything! return; BOOST_FOREACH(const CTxIn& txin, thisTx.vin) AddToSpends(txin.prevout, wtxid); } bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) { if (IsCrypted()) return false; CKeyingMaterial vMasterKey; RandAddSeedPerfmon(); vMasterKey.resize(WALLET_CRYPTO_KEY_SIZE); GetRandBytes(&vMasterKey[0], WALLET_CRYPTO_KEY_SIZE); CMasterKey kMasterKey; RandAddSeedPerfmon(); kMasterKey.vchSalt.resize(WALLET_CRYPTO_SALT_SIZE); GetRandBytes(&kMasterKey.vchSalt[0], WALLET_CRYPTO_SALT_SIZE); CCrypter crypter; int64_t nStartTime = GetTimeMillis(); crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, 25000, kMasterKey.nDerivationMethod); kMasterKey.nDeriveIterations = 2500000 / ((double)(GetTimeMillis() - nStartTime)); nStartTime = GetTimeMillis(); crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod); kMasterKey.nDeriveIterations = (kMasterKey.nDeriveIterations + kMasterKey.nDeriveIterations * 100 / ((double)(GetTimeMillis() - nStartTime))) / 2; if (kMasterKey.nDeriveIterations < 25000) kMasterKey.nDeriveIterations = 25000; LogPrintf("Encrypting Wallet with an nDeriveIterations of %i\n", kMasterKey.nDeriveIterations); if (!crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod)) return false; if (!crypter.Encrypt(vMasterKey, kMasterKey.vchCryptedKey)) return false; { LOCK(cs_wallet); mapMasterKeys[++nMasterKeyMaxID] = kMasterKey; if (fFileBacked) { assert(!pwalletdbEncryption); pwalletdbEncryption = new CWalletDB(strWalletFile); if (!pwalletdbEncryption->TxnBegin()) { delete pwalletdbEncryption; pwalletdbEncryption = NULL; return false; } pwalletdbEncryption->WriteMasterKey(nMasterKeyMaxID, kMasterKey); } // must get current HD chain before EncryptKeys CHDChain hdChainCurrent; GetHDChain(hdChainCurrent); if (!EncryptKeys(vMasterKey)) { if (fFileBacked) { pwalletdbEncryption->TxnAbort(); delete pwalletdbEncryption; } // We now probably have half of our keys encrypted in memory, and half not... // die and let the user reload the unencrypted wallet. assert(false); } if (!hdChainCurrent.IsNull()) { assert(EncryptHDChain(vMasterKey)); CHDChain hdChainCrypted; assert(GetHDChain(hdChainCrypted)); DBG( printf("EncryptWallet -- current seed: '%s'\n", HexStr(hdChainCurrent.GetSeed()).c_str()); printf("EncryptWallet -- crypted seed: '%s'\n", HexStr(hdChainCrypted.GetSeed()).c_str()); ); // ids should match, seed hashes should not assert(hdChainCurrent.GetID() == hdChainCrypted.GetID()); assert(hdChainCurrent.GetSeedHash() != hdChainCrypted.GetSeedHash()); assert(SetCryptedHDChain(hdChainCrypted, false)); } // Encryption was introduced in version 0.4.0 SetMinVersion(FEATURE_WALLETCRYPT, pwalletdbEncryption, true); if (fFileBacked) { if (!pwalletdbEncryption->TxnCommit()) { delete pwalletdbEncryption; // We now have keys encrypted in memory, but not on disk... // die to avoid confusion and let the user reload the unencrypted wallet. assert(false); } delete pwalletdbEncryption; pwalletdbEncryption = NULL; } Lock(); Unlock(strWalletPassphrase); // if we are not using HD, generate new keypool if(IsHDEnabled()) { TopUpKeyPool(); } else { NewKeyPool(); } Lock(); // Need to completely rewrite the wallet file; if we don't, bdb might keep // bits of the unencrypted private key in slack space in the database file. CDB::Rewrite(strWalletFile); // Update KeePass if necessary if(GetBoolArg("-keepass", false)) { LogPrintf("CWallet::EncryptWallet -- Updating KeePass with new passphrase"); try { keePassInt.updatePassphrase(strWalletPassphrase); } catch (std::exception& e) { LogPrintf("CWallet::EncryptWallet -- could not update passphrase in KeePass: Error: %s\n", e.what()); } } } NotifyStatusChanged(this); return true; } int64_t CWallet::IncOrderPosNext(CWalletDB *pwalletdb) { AssertLockHeld(cs_wallet); // nOrderPosNext int64_t nRet = nOrderPosNext++; if (pwalletdb) { pwalletdb->WriteOrderPosNext(nOrderPosNext); } else { CWalletDB(strWalletFile).WriteOrderPosNext(nOrderPosNext); } return nRet; } void CWallet::MarkDirty() { { LOCK(cs_wallet); BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) item.second.MarkDirty(); } fAnonymizableTallyCached = false; fAnonymizableTallyCachedNonDenom = false; } bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb) { uint256 hash = wtxIn.GetHash(); if (fFromLoadWallet) { mapWallet[hash] = wtxIn; CWalletTx& wtx = mapWallet[hash]; wtx.BindWallet(this); wtxOrdered.insert(make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0))); AddToSpends(hash); BOOST_FOREACH(const CTxIn& txin, wtx.vin) { if (mapWallet.count(txin.prevout.hash)) { CWalletTx& prevtx = mapWallet[txin.prevout.hash]; if (prevtx.nIndex == -1 && !prevtx.hashUnset()) { MarkConflicted(prevtx.hashBlock, wtx.GetHash()); } } } } else { LOCK(cs_wallet); // Inserts only if not already there, returns tx inserted or tx found pair<map<uint256, CWalletTx>::iterator, bool> ret = mapWallet.insert(make_pair(hash, wtxIn)); CWalletTx& wtx = (*ret.first).second; wtx.BindWallet(this); bool fInsertedNew = ret.second; if (fInsertedNew) { wtx.nTimeReceived = GetAdjustedTime(); wtx.nOrderPos = IncOrderPosNext(pwalletdb); wtxOrdered.insert(make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0))); wtx.nTimeSmart = wtx.nTimeReceived; if (!wtxIn.hashUnset()) { if (mapBlockIndex.count(wtxIn.hashBlock)) { int64_t latestNow = wtx.nTimeReceived; int64_t latestEntry = 0; { // Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future int64_t latestTolerated = latestNow + 300; const TxItems & txOrdered = wtxOrdered; for (TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { CWalletTx *const pwtx = (*it).second.first; if (pwtx == &wtx) continue; CAccountingEntry *const pacentry = (*it).second.second; int64_t nSmartTime; if (pwtx) { nSmartTime = pwtx->nTimeSmart; if (!nSmartTime) nSmartTime = pwtx->nTimeReceived; } else nSmartTime = pacentry->nTime; if (nSmartTime <= latestTolerated) { latestEntry = nSmartTime; if (nSmartTime > latestNow) latestNow = nSmartTime; break; } } } int64_t blocktime = mapBlockIndex[wtxIn.hashBlock]->GetBlockTime(); wtx.nTimeSmart = std::max(latestEntry, std::min(blocktime, latestNow)); } else LogPrintf("AddToWallet(): found %s in block %s not in index\n", wtxIn.GetHash().ToString(), wtxIn.hashBlock.ToString()); } AddToSpends(hash); for(int i = 0; i < wtx.vout.size(); ++i) { if (IsMine(wtx.vout[i]) && !IsSpent(hash, i)) { setWalletUTXO.insert(COutPoint(hash, i)); } } } bool fUpdated = false; if (!fInsertedNew) { // Merge if (!wtxIn.hashUnset() && wtxIn.hashBlock != wtx.hashBlock) { wtx.hashBlock = wtxIn.hashBlock; fUpdated = true; } // If no longer abandoned, update if (wtxIn.hashBlock.IsNull() && wtx.isAbandoned()) { wtx.hashBlock = wtxIn.hashBlock; fUpdated = true; } if (wtxIn.nIndex != -1 && (wtxIn.nIndex != wtx.nIndex)) { wtx.nIndex = wtxIn.nIndex; fUpdated = true; } if (wtxIn.fFromMe && wtxIn.fFromMe != wtx.fFromMe) { wtx.fFromMe = wtxIn.fFromMe; fUpdated = true; } } //// debug print LogPrintf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : "")); // Write to disk if (fInsertedNew || fUpdated) if (!wtx.WriteToDisk(pwalletdb)) return false; // Break debit/credit balance caches: wtx.MarkDirty(); // Notify UI of new or updated transaction NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED); // notify an external script when a wallet transaction comes in or is updated std::string strCmd = GetArg("-walletnotify", ""); if ( !strCmd.empty()) { boost::replace_all(strCmd, "%s", wtxIn.GetHash().GetHex()); boost::thread t(runCommand, strCmd); // thread runs free } fAnonymizableTallyCached = false; fAnonymizableTallyCachedNonDenom = false; } return true; } /** * Add a transaction to the wallet, or update it. * pblock is optional, but should be provided if the transaction is known to be in a block. * If fUpdate is true, existing transactions will be updated. */ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { { AssertLockHeld(cs_wallet); if (pblock) { BOOST_FOREACH(const CTxIn& txin, tx.vin) { std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range(txin.prevout); while (range.first != range.second) { if (range.first->second != tx.GetHash()) { LogPrintf("Transaction %s (in block %s) conflicts with wallet transaction %s (both spend %s:%i)\n", tx.GetHash().ToString(), pblock->GetHash().ToString(), range.first->second.ToString(), range.first->first.hash.ToString(), range.first->first.n); MarkConflicted(pblock->GetHash(), range.first->second); } range.first++; } } } bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; if (fExisted || IsMine(tx) || IsFromMe(tx)) { CWalletTx wtx(this,tx); // Get merkle branch if transaction was found in a block if (pblock) wtx.SetMerkleBranch(*pblock); // Do not flush the wallet here for performance reasons // this is safe, as in case of a crash, we rescan the necessary blocks on startup through our SetBestChain-mechanism CWalletDB walletdb(strWalletFile, "r+", false); return AddToWallet(wtx, false, &walletdb); } } return false; } bool CWallet::AbandonTransaction(const uint256& hashTx) { LOCK2(cs_main, cs_wallet); // Do not flush the wallet here for performance reasons CWalletDB walletdb(strWalletFile, "r+", false); std::set<uint256> todo; std::set<uint256> done; // Can't mark abandoned if confirmed or in mempool assert(mapWallet.count(hashTx)); CWalletTx& origtx = mapWallet[hashTx]; if (origtx.GetDepthInMainChain() > 0 || origtx.InMempool()) { return false; } todo.insert(hashTx); while (!todo.empty()) { uint256 now = *todo.begin(); todo.erase(now); done.insert(now); assert(mapWallet.count(now)); CWalletTx& wtx = mapWallet[now]; int currentconfirm = wtx.GetDepthInMainChain(); // If the orig tx was not in block, none of its spends can be assert(currentconfirm <= 0); // if (currentconfirm < 0) {Tx and spends are already conflicted, no need to abandon} if (currentconfirm == 0 && !wtx.isAbandoned()) { // If the orig tx was not in block/mempool, none of its spends can be in mempool assert(!wtx.InMempool()); wtx.nIndex = -1; wtx.setAbandoned(); wtx.MarkDirty(); wtx.WriteToDisk(&walletdb); NotifyTransactionChanged(this, wtx.GetHash(), CT_UPDATED); // Iterate over all its outputs, and mark transactions in the wallet that spend them abandoned too TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(hashTx, 0)); while (iter != mapTxSpends.end() && iter->first.hash == now) { if (!done.count(iter->second)) { todo.insert(iter->second); } iter++; } // If a transaction changes 'conflicted' state, that changes the balance // available of the outputs it spends. So force those to be recomputed BOOST_FOREACH(const CTxIn& txin, wtx.vin) { if (mapWallet.count(txin.prevout.hash)) mapWallet[txin.prevout.hash].MarkDirty(); } } } fAnonymizableTallyCached = false; fAnonymizableTallyCachedNonDenom = false; return true; } void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx) { LOCK2(cs_main, cs_wallet); int conflictconfirms = 0; if (mapBlockIndex.count(hashBlock)) { CBlockIndex* pindex = mapBlockIndex[hashBlock]; if (chainActive.Contains(pindex)) { conflictconfirms = -(chainActive.Height() - pindex->nHeight + 1); } } // If number of conflict confirms cannot be determined, this means // that the block is still unknown or not yet part of the main chain, // for example when loading the wallet during a reindex. Do nothing in that // case. if (conflictconfirms >= 0) return; // Do not flush the wallet here for performance reasons CWalletDB walletdb(strWalletFile, "r+", false); std::set<uint256> todo; std::set<uint256> done; todo.insert(hashTx); while (!todo.empty()) { uint256 now = *todo.begin(); todo.erase(now); done.insert(now); assert(mapWallet.count(now)); CWalletTx& wtx = mapWallet[now]; int currentconfirm = wtx.GetDepthInMainChain(); if (conflictconfirms < currentconfirm) { // Block is 'more conflicted' than current confirm; update. // Mark transaction as conflicted with this block. wtx.nIndex = -1; wtx.hashBlock = hashBlock; wtx.MarkDirty(); wtx.WriteToDisk(&walletdb); // Iterate over all its outputs, and mark transactions in the wallet that spend them conflicted too TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(now, 0)); while (iter != mapTxSpends.end() && iter->first.hash == now) { if (!done.count(iter->second)) { todo.insert(iter->second); } iter++; } // If a transaction changes 'conflicted' state, that changes the balance // available of the outputs it spends. So force those to be recomputed BOOST_FOREACH(const CTxIn& txin, wtx.vin) { if (mapWallet.count(txin.prevout.hash)) mapWallet[txin.prevout.hash].MarkDirty(); } } } fAnonymizableTallyCached = false; fAnonymizableTallyCachedNonDenom = false; } void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock) { LOCK2(cs_main, cs_wallet); if (!AddToWalletIfInvolvingMe(tx, pblock, true)) return; // Not one of ours // If a transaction changes 'conflicted' state, that changes the balance // available of the outputs it spends. So force those to be // recomputed, also: BOOST_FOREACH(const CTxIn& txin, tx.vin) { if (mapWallet.count(txin.prevout.hash)) mapWallet[txin.prevout.hash].MarkDirty(); } fAnonymizableTallyCached = false; fAnonymizableTallyCachedNonDenom = false; } isminetype CWallet::IsMine(const CTxIn &txin) const { { LOCK(cs_wallet); map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(txin.prevout.hash); if (mi != mapWallet.end()) { const CWalletTx& prev = (*mi).second; if (txin.prevout.n < prev.vout.size()) return IsMine(prev.vout[txin.prevout.n]); } } return ISMINE_NO; } CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const { { LOCK(cs_wallet); map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(txin.prevout.hash); if (mi != mapWallet.end()) { const CWalletTx& prev = (*mi).second; if (txin.prevout.n < prev.vout.size()) if (IsMine(prev.vout[txin.prevout.n]) & filter) return prev.vout[txin.prevout.n].nValue; } } return 0; } // Recursively determine the rounds of a given input (How deep is the PrivateSend chain for a given input) int CWallet::GetRealOutpointPrivateSendRounds(const COutPoint& outpoint, int nRounds) const { static std::map<uint256, CMutableTransaction> mDenomWtxes; if(nRounds >= 16) return 15; // 16 rounds max uint256 hash = outpoint.hash; unsigned int nout = outpoint.n; const CWalletTx* wtx = GetWalletTx(hash); if(wtx != NULL) { std::map<uint256, CMutableTransaction>::const_iterator mdwi = mDenomWtxes.find(hash); if (mdwi == mDenomWtxes.end()) { // not known yet, let's add it LogPrint("privatesend", "GetRealOutpointPrivateSendRounds INSERTING %s\n", hash.ToString()); mDenomWtxes[hash] = CMutableTransaction(*wtx); } else if(mDenomWtxes[hash].vout[nout].nRounds != -10) { // found and it's not an initial value, just return it return mDenomWtxes[hash].vout[nout].nRounds; } // bounds check if (nout >= wtx->vout.size()) { // should never actually hit this LogPrint("privatesend", "GetRealOutpointPrivateSendRounds UPDATED %s %3d %3d\n", hash.ToString(), nout, -4); return -4; } if (CPrivateSend::IsCollateralAmount(wtx->vout[nout].nValue)) { mDenomWtxes[hash].vout[nout].nRounds = -3; LogPrint("privatesend", "GetRealOutpointPrivateSendRounds UPDATED %s %3d %3d\n", hash.ToString(), nout, mDenomWtxes[hash].vout[nout].nRounds); return mDenomWtxes[hash].vout[nout].nRounds; } //make sure the final output is non-denominate if (!CPrivateSend::IsDenominatedAmount(wtx->vout[nout].nValue)) { //NOT DENOM mDenomWtxes[hash].vout[nout].nRounds = -2; LogPrint("privatesend", "GetRealOutpointPrivateSendRounds UPDATED %s %3d %3d\n", hash.ToString(), nout, mDenomWtxes[hash].vout[nout].nRounds); return mDenomWtxes[hash].vout[nout].nRounds; } bool fAllDenoms = true; BOOST_FOREACH(CTxOut out, wtx->vout) { fAllDenoms = fAllDenoms && CPrivateSend::IsDenominatedAmount(out.nValue); } // this one is denominated but there is another non-denominated output found in the same tx if (!fAllDenoms) { mDenomWtxes[hash].vout[nout].nRounds = 0; LogPrint("privatesend", "GetRealOutpointPrivateSendRounds UPDATED %s %3d %3d\n", hash.ToString(), nout, mDenomWtxes[hash].vout[nout].nRounds); return mDenomWtxes[hash].vout[nout].nRounds; } int nShortest = -10; // an initial value, should be no way to get this by calculations bool fDenomFound = false; // only denoms here so let's look up BOOST_FOREACH(CTxIn txinNext, wtx->vin) { if (IsMine(txinNext)) { int n = GetRealOutpointPrivateSendRounds(txinNext.prevout, nRounds + 1); // denom found, find the shortest chain or initially assign nShortest with the first found value if(n >= 0 && (n < nShortest || nShortest == -10)) { nShortest = n; fDenomFound = true; } } } mDenomWtxes[hash].vout[nout].nRounds = fDenomFound ? (nShortest >= 15 ? 16 : nShortest + 1) // good, we a +1 to the shortest one but only 16 rounds max allowed : 0; // too bad, we are the fist one in that chain LogPrint("privatesend", "GetRealOutpointPrivateSendRounds UPDATED %s %3d %3d\n", hash.ToString(), nout, mDenomWtxes[hash].vout[nout].nRounds); return mDenomWtxes[hash].vout[nout].nRounds; } return nRounds - 1; } // respect current settings int CWallet::GetOutpointPrivateSendRounds(const COutPoint& outpoint) const { LOCK(cs_wallet); int realPrivateSendRounds = GetRealOutpointPrivateSendRounds(outpoint, 0); return realPrivateSendRounds > privateSendClient.nPrivateSendRounds ? privateSendClient.nPrivateSendRounds : realPrivateSendRounds; } bool CWallet::IsDenominated(const COutPoint& outpoint) const { LOCK(cs_wallet); map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(outpoint.hash); if (mi != mapWallet.end()) { const CWalletTx& prev = (*mi).second; if (outpoint.n < prev.vout.size()) { return CPrivateSend::IsDenominatedAmount(prev.vout[outpoint.n].nValue); } } return false; } isminetype CWallet::IsMine(const CTxOut& txout) const { return ::IsMine(*this, txout.scriptPubKey); } CAmount CWallet::GetCredit(const CTxOut& txout, const isminefilter& filter) const { if (!MoneyRange(txout.nValue)) throw std::runtime_error("CWallet::GetCredit(): value out of range"); return ((IsMine(txout) & filter) ? txout.nValue : 0); } bool CWallet::IsChange(const CTxOut& txout) const { // TODO: fix handling of 'change' outputs. The assumption is that any // payment to a script that is ours, but is not in the address book // is change. That assumption is likely to break when we implement multisignature // wallets that return change back into a multi-signature-protected address; // a better way of identifying which outputs are 'the send' and which are // 'the change' will need to be implemented (maybe extend CWalletTx to remember // which output, if any, was change). if (::IsMine(*this, txout.scriptPubKey)) { CTxDestination address; if (!ExtractDestination(txout.scriptPubKey, address)) return true; LOCK(cs_wallet); if (!mapAddressBook.count(address)) return true; } return false; } CAmount CWallet::GetChange(const CTxOut& txout) const { if (!MoneyRange(txout.nValue)) throw std::runtime_error("CWallet::GetChange(): value out of range"); return (IsChange(txout) ? txout.nValue : 0); } void CWallet::GenerateNewHDChain() { CHDChain newHdChain; std::string strSeed = GetArg("-hdseed", "not hex"); if(mapArgs.count("-hdseed") && IsHex(strSeed)) { std::vector<unsigned char> vchSeed = ParseHex(strSeed); if (!newHdChain.SetSeed(SecureVector(vchSeed.begin(), vchSeed.end()), true)) throw std::runtime_error(std::string(__func__) + ": SetSeed failed"); } else { if (mapArgs.count("-hdseed") && !IsHex(strSeed)) LogPrintf("CWallet::GenerateNewHDChain -- Incorrect seed, generating random one instead\n"); // NOTE: empty mnemonic means "generate a new one for me" std::string strMnemonic = GetArg("-mnemonic", ""); // NOTE: default mnemonic passphrase is an empty string std::string strMnemonicPassphrase = GetArg("-mnemonicpassphrase", ""); SecureVector vchMnemonic(strMnemonic.begin(), strMnemonic.end()); SecureVector vchMnemonicPassphrase(strMnemonicPassphrase.begin(), strMnemonicPassphrase.end()); if (!newHdChain.SetMnemonic(vchMnemonic, vchMnemonicPassphrase, true)) throw std::runtime_error(std::string(__func__) + ": SetMnemonic failed"); } newHdChain.Debug(__func__); if (!SetHDChain(newHdChain, false)) throw std::runtime_error(std::string(__func__) + ": SetHDChain failed"); // clean up mapArgs.erase("-hdseed"); mapArgs.erase("-mnemonic"); mapArgs.erase("-mnemonicpassphrase"); } bool CWallet::SetHDChain(const CHDChain& chain, bool memonly) { LOCK(cs_wallet); if (!CCryptoKeyStore::SetHDChain(chain)) return false; if (!memonly && !CWalletDB(strWalletFile).WriteHDChain(chain)) throw std::runtime_error(std::string(__func__) + ": WriteHDChain failed"); return true; } bool CWallet::SetCryptedHDChain(const CHDChain& chain, bool memonly) { LOCK(cs_wallet); if (!CCryptoKeyStore::SetCryptedHDChain(chain)) return false; if (!memonly) { if (!fFileBacked) return false; if (pwalletdbEncryption) { if (!pwalletdbEncryption->WriteCryptedHDChain(chain)) throw std::runtime_error(std::string(__func__) + ": WriteCryptedHDChain failed"); } else { if (!CWalletDB(strWalletFile).WriteCryptedHDChain(chain)) throw std::runtime_error(std::string(__func__) + ": WriteCryptedHDChain failed"); } } return true; } bool CWallet::GetDecryptedHDChain(CHDChain& hdChainRet) { LOCK(cs_wallet); CHDChain hdChainTmp; if (!GetHDChain(hdChainTmp)) { return false; } if (!DecryptHDChain(hdChainTmp)) return false; // make sure seed matches this chain if (hdChainTmp.GetID() != hdChainTmp.GetSeedHash()) return false; hdChainRet = hdChainTmp; return true; } bool CWallet::IsHDEnabled() { CHDChain hdChainCurrent; return GetHDChain(hdChainCurrent); } bool CWallet::IsMine(const CTransaction& tx) const { BOOST_FOREACH(const CTxOut& txout, tx.vout) if (IsMine(txout)) return true; return false; } bool CWallet::IsFromMe(const CTransaction& tx) const { return (GetDebit(tx, ISMINE_ALL) > 0); } CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) const { CAmount nDebit = 0; BOOST_FOREACH(const CTxIn& txin, tx.vin) { nDebit += GetDebit(txin, filter); if (!MoneyRange(nDebit)) throw std::runtime_error("CWallet::GetDebit(): value out of range"); } return nDebit; } CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) const { CAmount nCredit = 0; BOOST_FOREACH(const CTxOut& txout, tx.vout) { nCredit += GetCredit(txout, filter); if (!MoneyRange(nCredit)) throw std::runtime_error("CWallet::GetCredit(): value out of range"); } return nCredit; } CAmount CWallet::GetChange(const CTransaction& tx) const { CAmount nChange = 0; BOOST_FOREACH(const CTxOut& txout, tx.vout) { nChange += GetChange(txout); if (!MoneyRange(nChange)) throw std::runtime_error("CWallet::GetChange(): value out of range"); } return nChange; } int64_t CWalletTx::GetTxTime() const { int64_t n = nTimeSmart; return n ? n : nTimeReceived; } int CWalletTx::GetRequestCount() const { // Returns -1 if it wasn't being tracked int nRequests = -1; { LOCK(pwallet->cs_wallet); if (IsCoinBase()) { // Generated block if (!hashUnset()) { map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(hashBlock); if (mi != pwallet->mapRequestCount.end()) nRequests = (*mi).second; } } else { // Did anyone request this transaction? map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(GetHash()); if (mi != pwallet->mapRequestCount.end()) { nRequests = (*mi).second; // How about the block it's in? if (nRequests == 0 && !hashUnset()) { map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(hashBlock); if (mi != pwallet->mapRequestCount.end()) nRequests = (*mi).second; else nRequests = 1; // If it's in someone else's block it must have got out } } } } return nRequests; } void CWalletTx::GetAmounts(list<COutputEntry>& listReceived, list<COutputEntry>& listSent, CAmount& nFee, string& strSentAccount, const isminefilter& filter) const { nFee = 0; listReceived.clear(); listSent.clear(); strSentAccount = strFromAccount; // Compute fee: CAmount nDebit = GetDebit(filter); if (nDebit > 0) // debit>0 means we signed/sent this transaction { CAmount nValueOut = GetValueOut(); nFee = nDebit - nValueOut; } // Sent/received. for (unsigned int i = 0; i < vout.size(); ++i) { const CTxOut& txout = vout[i]; isminetype fIsMine = pwallet->IsMine(txout); // Only need to handle txouts if AT LEAST one of these is true: // 1) they debit from us (sent) // 2) the output is to us (received) if (nDebit > 0) { // Don't report 'change' txouts if (pwallet->IsChange(txout)) continue; } else if (!(fIsMine & filter)) continue; // In either case, we need to get the destination address CTxDestination address; if (!ExtractDestination(txout.scriptPubKey, address) && !txout.scriptPubKey.IsUnspendable()) { LogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n", this->GetHash().ToString()); address = CNoDestination(); } COutputEntry output = {address, txout.nValue, (int)i}; // If we are debited by the transaction, add the output as a "sent" entry if (nDebit > 0) listSent.push_back(output); // If we are receiving the output, add it as a "received" entry if (fIsMine & filter) listReceived.push_back(output); } } void CWalletTx::GetAccountAmounts(const string& strAccount, CAmount& nReceived, CAmount& nSent, CAmount& nFee, const isminefilter& filter) const { nReceived = nSent = nFee = 0; CAmount allFee; string strSentAccount; list<COutputEntry> listReceived; list<COutputEntry> listSent; GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); if (strAccount == strSentAccount) { BOOST_FOREACH(const COutputEntry& s, listSent) nSent += s.amount; nFee = allFee; } { LOCK(pwallet->cs_wallet); BOOST_FOREACH(const COutputEntry& r, listReceived) { if (pwallet->mapAddressBook.count(r.destination)) { map<CTxDestination, CAddressBookData>::const_iterator mi = pwallet->mapAddressBook.find(r.destination); if (mi != pwallet->mapAddressBook.end() && (*mi).second.name == strAccount) nReceived += r.amount; } else if (strAccount.empty()) { nReceived += r.amount; } } } } bool CWalletTx::WriteToDisk(CWalletDB *pwalletdb) { return pwalletdb->WriteTx(GetHash(), *this); } /** * Scan the block chain (starting in pindexStart) for transactions * from or to us. If fUpdate is true, found transactions that already * exist in the wallet will be updated. */ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) { int ret = 0; int64_t nNow = GetTime(); const CChainParams& chainParams = Params(); CBlockIndex* pindex = pindexStart; { LOCK2(cs_main, cs_wallet); // no need to read and scan block, if block was created before // our wallet birthday (as adjusted for block time variability) while (pindex && nTimeFirstKey && (pindex->GetBlockTime() < (nTimeFirstKey - 7200))) pindex = chainActive.Next(pindex); ShowProgress(_("Rescanning..."), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup double dProgressStart = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false); double dProgressTip = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip(), false); while (pindex) { if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100)))); CBlock block; ReadBlockFromDisk(block, pindex, Params().GetConsensus()); BOOST_FOREACH(CTransaction& tx, block.vtx) { if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) ret++; } pindex = chainActive.Next(pindex); if (GetTime() >= nNow + 60) { nNow = GetTime(); LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex)); } } ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI } return ret; } void CWallet::ReacceptWalletTransactions() { // If transactions aren't being broadcasted, don't let them into local mempool either if (!fBroadcastTransactions) return; LOCK2(cs_main, cs_wallet); std::map<int64_t, CWalletTx*> mapSorted; // Sort pending wallet transactions based on their initial wallet insertion order BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) { const uint256& wtxid = item.first; CWalletTx& wtx = item.second; assert(wtx.GetHash() == wtxid); int nDepth = wtx.GetDepthInMainChain(); if (!wtx.IsCoinBase() && (nDepth == 0 && !wtx.isAbandoned())) { mapSorted.insert(std::make_pair(wtx.nOrderPos, &wtx)); } } // Try to add wallet transactions to memory pool BOOST_FOREACH(PAIRTYPE(const int64_t, CWalletTx*)& item, mapSorted) { CWalletTx& wtx = *(item.second); LOCK(mempool.cs); wtx.AcceptToMemoryPool(false); } } bool CWalletTx::RelayWalletTransaction(CConnman* connman, std::string strCommand) { assert(pwallet->GetBroadcastTransactions()); if (!IsCoinBase()) { if (GetDepthInMainChain() == 0 && !isAbandoned() && InMempool()) { uint256 hash = GetHash(); LogPrintf("Relaying wtx %s\n", hash.ToString()); if(strCommand == NetMsgType::TXLOCKREQUEST) { instantsend.ProcessTxLockRequest(((CTxLockRequest)*this), *connman); } if (connman) { connman->RelayTransaction((CTransaction)*this); return true; } } } return false; } set<uint256> CWalletTx::GetConflicts() const { set<uint256> result; if (pwallet != NULL) { uint256 myHash = GetHash(); result = pwallet->GetConflicts(myHash); result.erase(myHash); } return result; } CAmount CWalletTx::GetDebit(const isminefilter& filter) const { if (vin.empty()) return 0; CAmount debit = 0; if(filter & ISMINE_SPENDABLE) { if (fDebitCached) debit += nDebitCached; else { nDebitCached = pwallet->GetDebit(*this, ISMINE_SPENDABLE); fDebitCached = true; debit += nDebitCached; } } if(filter & ISMINE_WATCH_ONLY) { if(fWatchDebitCached) debit += nWatchDebitCached; else { nWatchDebitCached = pwallet->GetDebit(*this, ISMINE_WATCH_ONLY); fWatchDebitCached = true; debit += nWatchDebitCached; } } return debit; } CAmount CWalletTx::GetCredit(const isminefilter& filter) const { // Must wait until coinbase is safely deep enough in the chain before valuing it if (IsCoinBase() && GetBlocksToMaturity() > 0) return 0; int64_t credit = 0; if (filter & ISMINE_SPENDABLE) { // GetBalance can assume transactions in mapWallet won't change if (fCreditCached) credit += nCreditCached; else { nCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE); fCreditCached = true; credit += nCreditCached; } } if (filter & ISMINE_WATCH_ONLY) { if (fWatchCreditCached) credit += nWatchCreditCached; else { nWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY); fWatchCreditCached = true; credit += nWatchCreditCached; } } return credit; } CAmount CWalletTx::GetImmatureCredit(bool fUseCache) const { if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain()) { if (fUseCache && fImmatureCreditCached) return nImmatureCreditCached; nImmatureCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE); fImmatureCreditCached = true; return nImmatureCreditCached; } return 0; } CAmount CWalletTx::GetAvailableCredit(bool fUseCache) const { if (pwallet == 0) return 0; // Must wait until coinbase is safely deep enough in the chain before valuing it if (IsCoinBase() && GetBlocksToMaturity() > 0) return 0; if (fUseCache && fAvailableCreditCached) return nAvailableCreditCached; CAmount nCredit = 0; uint256 hashTx = GetHash(); for (unsigned int i = 0; i < vout.size(); i++) { if (!pwallet->IsSpent(hashTx, i)) { const CTxOut &txout = vout[i]; nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE); if (!MoneyRange(nCredit)) throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range"); } } nAvailableCreditCached = nCredit; fAvailableCreditCached = true; return nCredit; } CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool& fUseCache) const { if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain()) { if (fUseCache && fImmatureWatchCreditCached) return nImmatureWatchCreditCached; nImmatureWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY); fImmatureWatchCreditCached = true; return nImmatureWatchCreditCached; } return 0; } CAmount CWalletTx::GetAvailableWatchOnlyCredit(const bool& fUseCache) const { if (pwallet == 0) return 0; // Must wait until coinbase is safely deep enough in the chain before valuing it if (IsCoinBase() && GetBlocksToMaturity() > 0) return 0; if (fUseCache && fAvailableWatchCreditCached) return nAvailableWatchCreditCached; CAmount nCredit = 0; for (unsigned int i = 0; i < vout.size(); i++) { if (!pwallet->IsSpent(GetHash(), i)) { const CTxOut &txout = vout[i]; nCredit += pwallet->GetCredit(txout, ISMINE_WATCH_ONLY); if (!MoneyRange(nCredit)) throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range"); } } nAvailableWatchCreditCached = nCredit; fAvailableWatchCreditCached = true; return nCredit; } CAmount CWalletTx::GetAnonymizedCredit(bool fUseCache) const { if (pwallet == 0) return 0; // Must wait until coinbase is safely deep enough in the chain before valuing it if (IsCoinBase() && GetBlocksToMaturity() > 0) return 0; if (fUseCache && fAnonymizedCreditCached) return nAnonymizedCreditCached; CAmount nCredit = 0; uint256 hashTx = GetHash(); for (unsigned int i = 0; i < vout.size(); i++) { const CTxOut &txout = vout[i]; const COutPoint outpoint = COutPoint(hashTx, i); if(pwallet->IsSpent(hashTx, i) || !pwallet->IsDenominated(outpoint)) continue; const int nRounds = pwallet->GetOutpointPrivateSendRounds(outpoint); if(nRounds >= privateSendClient.nPrivateSendRounds){ nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE); if (!MoneyRange(nCredit)) throw std::runtime_error("CWalletTx::GetAnonymizedCredit() : value out of range"); } } nAnonymizedCreditCached = nCredit; fAnonymizedCreditCached = true; return nCredit; } CAmount CWalletTx::GetDenominatedCredit(bool unconfirmed, bool fUseCache) const { if (pwallet == 0) return 0; // Must wait until coinbase is safely deep enough in the chain before valuing it if (IsCoinBase() && GetBlocksToMaturity() > 0) return 0; int nDepth = GetDepthInMainChain(false); if(nDepth < 0) return 0; bool isUnconfirmed = IsTrusted() && nDepth == 0; if(unconfirmed != isUnconfirmed) return 0; if (fUseCache) { if(unconfirmed && fDenomUnconfCreditCached) return nDenomUnconfCreditCached; else if (!unconfirmed && fDenomConfCreditCached) return nDenomConfCreditCached; } CAmount nCredit = 0; uint256 hashTx = GetHash(); for (unsigned int i = 0; i < vout.size(); i++) { const CTxOut &txout = vout[i]; if(pwallet->IsSpent(hashTx, i) || !CPrivateSend::IsDenominatedAmount(vout[i].nValue)) continue; nCredit += pwallet->GetCredit(txout, ISMINE_SPENDABLE); if (!MoneyRange(nCredit)) throw std::runtime_error("CWalletTx::GetDenominatedCredit() : value out of range"); } if(unconfirmed) { nDenomUnconfCreditCached = nCredit; fDenomUnconfCreditCached = true; } else { nDenomConfCreditCached = nCredit; fDenomConfCreditCached = true; } return nCredit; } CAmount CWalletTx::GetChange() const { if (fChangeCached) return nChangeCached; nChangeCached = pwallet->GetChange(*this); fChangeCached = true; return nChangeCached; } bool CWalletTx::InMempool() const { LOCK(mempool.cs); if (mempool.exists(GetHash())) { return true; } return false; } bool CWalletTx::IsTrusted() const { // Quick answer in most cases if (!CheckFinalTx(*this)) return false; int nDepth = GetDepthInMainChain(); if (nDepth >= 1) return true; if (nDepth < 0) return false; if (!bSpendZeroConfChange || !IsFromMe(ISMINE_ALL)) // using wtx's cached debit return false; // Don't trust unconfirmed transactions from us unless they are in the mempool. if (!InMempool()) return false; // Trusted if all inputs are from us and are in the mempool: BOOST_FOREACH(const CTxIn& txin, vin) { // Transactions not sent by us: not trusted const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash); if (parent == NULL) return false; const CTxOut& parentOut = parent->vout[txin.prevout.n]; if (pwallet->IsMine(parentOut) != ISMINE_SPENDABLE) return false; } return true; } bool CWalletTx::IsEquivalentTo(const CWalletTx& tx) const { CMutableTransaction tx1 = *this; CMutableTransaction tx2 = tx; for (unsigned int i = 0; i < tx1.vin.size(); i++) tx1.vin[i].scriptSig = CScript(); for (unsigned int i = 0; i < tx2.vin.size(); i++) tx2.vin[i].scriptSig = CScript(); return CTransaction(tx1) == CTransaction(tx2); } std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CConnman* connman) { std::vector<uint256> result; LOCK(cs_wallet); // Sort them in chronological order multimap<unsigned int, CWalletTx*> mapSorted; BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) { CWalletTx& wtx = item.second; // Don't rebroadcast if newer than nTime: if (wtx.nTimeReceived > nTime) continue; mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx)); } BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted) { CWalletTx& wtx = *item.second; if (wtx.RelayWalletTransaction(connman)) result.push_back(wtx.GetHash()); } return result; } void CWallet::ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) { // Do this infrequently and randomly to avoid giving away // that these are our transactions. if (GetTime() < nNextResend || !fBroadcastTransactions) return; bool fFirst = (nNextResend == 0); nNextResend = GetTime() + GetRand(30 * 60); if (fFirst) return; // Only do it if there's been a new block since last time if (nBestBlockTime < nLastResend) return; nLastResend = GetTime(); // Rebroadcast unconfirmed txes older than 5 minutes before the last // block was found: std::vector<uint256> relayed = ResendWalletTransactionsBefore(nBestBlockTime-5*60, connman); if (!relayed.empty()) LogPrintf("%s: rebroadcast %u unconfirmed transactions\n", __func__, relayed.size()); } /** @} */ // end of mapWallet /** @defgroup Actions * * @{ */ CAmount CWallet::GetBalance() const { CAmount nTotal = 0; { LOCK2(cs_main, cs_wallet); for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; if (pcoin->IsTrusted()) nTotal += pcoin->GetAvailableCredit(); } } return nTotal; } CAmount CWallet::GetAnonymizableBalance(bool fSkipDenominated, bool fSkipUnconfirmed) const { if(fLiteMode) return 0; std::vector<CompactTallyItem> vecTally; if(!SelectCoinsGrouppedByAddresses(vecTally, fSkipDenominated, true, fSkipUnconfirmed)) return 0; CAmount nTotal = 0; const CAmount nSmallestDenom = CPrivateSend::GetSmallestDenomination(); const CAmount nMixingCollateral = CPrivateSend::GetCollateralAmount(); BOOST_FOREACH(CompactTallyItem& item, vecTally) { bool fIsDenominated = CPrivateSend::IsDenominatedAmount(item.nAmount); if(fSkipDenominated && fIsDenominated) continue; // assume that the fee to create denoms should be mixing collateral at max if(item.nAmount >= nSmallestDenom + (fIsDenominated ? 0 : nMixingCollateral)) nTotal += item.nAmount; } return nTotal; } CAmount CWallet::GetAnonymizedBalance() const { if(fLiteMode) return 0; CAmount nTotal = 0; LOCK2(cs_main, cs_wallet); std::set<uint256> setWalletTxesCounted; for (auto& outpoint : setWalletUTXO) { if (setWalletTxesCounted.find(outpoint.hash) != setWalletTxesCounted.end()) continue; setWalletTxesCounted.insert(outpoint.hash); for (map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash); it != mapWallet.end() && it->first == outpoint.hash; ++it) { if (it->second.IsTrusted()) nTotal += it->second.GetAnonymizedCredit(); } } return nTotal; } // Note: calculated including unconfirmed, // that's ok as long as we use it for informational purposes only float CWallet::GetAverageAnonymizedRounds() const { if(fLiteMode) return 0; int nTotal = 0; int nCount = 0; LOCK2(cs_main, cs_wallet); for (auto& outpoint : setWalletUTXO) { if(!IsDenominated(outpoint)) continue; nTotal += GetOutpointPrivateSendRounds(outpoint); nCount++; } if(nCount == 0) return 0; return (float)nTotal/nCount; } // Note: calculated including unconfirmed, // that's ok as long as we use it for informational purposes only CAmount CWallet::GetNormalizedAnonymizedBalance() const { if(fLiteMode) return 0; CAmount nTotal = 0; LOCK2(cs_main, cs_wallet); for (auto& outpoint : setWalletUTXO) { map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash); if (it == mapWallet.end()) continue; if (!IsDenominated(outpoint)) continue; if (it->second.GetDepthInMainChain() < 0) continue; int nRounds = GetOutpointPrivateSendRounds(outpoint); nTotal += it->second.vout[outpoint.n].nValue * nRounds / privateSendClient.nPrivateSendRounds; } return nTotal; } CAmount CWallet::GetNeedsToBeAnonymizedBalance(CAmount nMinBalance) const { if(fLiteMode) return 0; CAmount nAnonymizedBalance = GetAnonymizedBalance(); CAmount nNeedsToAnonymizeBalance = privateSendClient.nPrivateSendAmount*COIN - nAnonymizedBalance; // try to overshoot target DS balance up to nMinBalance nNeedsToAnonymizeBalance += nMinBalance; CAmount nAnonymizableBalance = GetAnonymizableBalance(); // anonymizable balance is way too small if(nAnonymizableBalance < nMinBalance) return 0; // not enough funds to anonymze amount we want, try the max we can if(nNeedsToAnonymizeBalance > nAnonymizableBalance) nNeedsToAnonymizeBalance = nAnonymizableBalance; // we should never exceed the pool max if (nNeedsToAnonymizeBalance > CPrivateSend::GetMaxPoolAmount()) nNeedsToAnonymizeBalance = CPrivateSend::GetMaxPoolAmount(); return nNeedsToAnonymizeBalance; } CAmount CWallet::GetDenominatedBalance(bool unconfirmed) const { if(fLiteMode) return 0; CAmount nTotal = 0; { LOCK2(cs_main, cs_wallet); for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; nTotal += pcoin->GetDenominatedCredit(unconfirmed); } } return nTotal; } CAmount CWallet::GetUnconfirmedBalance() const { CAmount nTotal = 0; { LOCK2(cs_main, cs_wallet); for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; if (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0 && pcoin->InMempool()) nTotal += pcoin->GetAvailableCredit(); } } return nTotal; } CAmount CWallet::GetImmatureBalance() const { CAmount nTotal = 0; { LOCK2(cs_main, cs_wallet); for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; nTotal += pcoin->GetImmatureCredit(); } } return nTotal; } CAmount CWallet::GetWatchOnlyBalance() const { CAmount nTotal = 0; { LOCK2(cs_main, cs_wallet); for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; if (pcoin->IsTrusted()) nTotal += pcoin->GetAvailableWatchOnlyCredit(); } } return nTotal; } CAmount CWallet::GetUnconfirmedWatchOnlyBalance() const { CAmount nTotal = 0; { LOCK2(cs_main, cs_wallet); for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; if (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0 && pcoin->InMempool()) nTotal += pcoin->GetAvailableWatchOnlyCredit(); } } return nTotal; } CAmount CWallet::GetImmatureWatchOnlyBalance() const { CAmount nTotal = 0; { LOCK2(cs_main, cs_wallet); for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; nTotal += pcoin->GetImmatureWatchOnlyCredit(); } } return nTotal; } void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue, AvailableCoinsType nCoinType, bool fUseInstantSend) const { vCoins.clear(); { LOCK2(cs_main, cs_wallet); for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const uint256& wtxid = it->first; const CWalletTx* pcoin = &(*it).second; if (!CheckFinalTx(*pcoin)) continue; if (fOnlyConfirmed && !pcoin->IsTrusted()) continue; if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) continue; int nDepth = pcoin->GetDepthInMainChain(false); // do not use IX for inputs that have less then INSTANTSEND_CONFIRMATIONS_REQUIRED blockchain confirmations if (fUseInstantSend && nDepth < INSTANTSEND_CONFIRMATIONS_REQUIRED) continue; // We should not consider coins which aren't at least in our mempool // It's possible for these to be conflicted via ancestors which we may never be able to detect if (nDepth == 0 && !pcoin->InMempool()) continue; for (unsigned int i = 0; i < pcoin->vout.size(); i++) { bool found = false; if(nCoinType == ONLY_DENOMINATED) { found = CPrivateSend::IsDenominatedAmount(pcoin->vout[i].nValue); } else if(nCoinType == ONLY_NONDENOMINATED) { if (CPrivateSend::IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts found = !CPrivateSend::IsDenominatedAmount(pcoin->vout[i].nValue); } else if(nCoinType == ONLY_1000) { found = pcoin->vout[i].nValue == 1000*COIN; } else if(nCoinType == ONLY_PRIVATESEND_COLLATERAL) { found = CPrivateSend::IsCollateralAmount(pcoin->vout[i].nValue); } else { found = true; } if(!found) continue; isminetype mine = IsMine(pcoin->vout[i]); if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO && (!IsLockedCoin((*it).first, i) || nCoinType == ONLY_1000) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) && (!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected(COutPoint((*it).first, i)))) vCoins.push_back(COutput(pcoin, i, nDepth, ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO), (mine & (ISMINE_SPENDABLE | ISMINE_WATCH_SOLVABLE)) != ISMINE_NO)); } } } } static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,unsigned int> > >vValue, const CAmount& nTotalLower, const CAmount& nTargetValue, vector<char>& vfBest, CAmount& nBest, bool fUseInstantSend = false, int iterations = 1000) { vector<char> vfIncluded; vfBest.assign(vValue.size(), true); nBest = nTotalLower; seed_insecure_rand(); for (int nRep = 0; nRep < iterations && nBest != nTargetValue; nRep++) { vfIncluded.assign(vValue.size(), false); CAmount nTotal = 0; bool fReachedTarget = false; for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++) { for (unsigned int i = 0; i < vValue.size(); i++) { if (fUseInstantSend && nTotal + vValue[i].first > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) { continue; } //The solver here uses a randomized algorithm, //the randomness serves no real security purpose but is just //needed to prevent degenerate behavior and it is important //that the rng is fast. We do not use a constant random sequence, //because there may be some privacy improvement by making //the selection random. if (nPass == 0 ? insecure_rand()&1 : !vfIncluded[i]) { nTotal += vValue[i].first; vfIncluded[i] = true; if (nTotal >= nTargetValue) { fReachedTarget = true; if (nTotal < nBest) { nBest = nTotal; vfBest = vfIncluded; } nTotal -= vValue[i].first; vfIncluded[i] = false; } } } } } //Reduces the approximate best subset by removing any inputs that are smaller than the surplus of nTotal beyond nTargetValue. for (unsigned int i = 0; i < vValue.size(); i++) { if (vfBest[i] && (nBest - vValue[i].first) >= nTargetValue ) { vfBest[i] = false; nBest -= vValue[i].first; } } } // move denoms down bool less_then_denom (const COutput& out1, const COutput& out2) { const CWalletTx *pcoin1 = out1.tx; const CWalletTx *pcoin2 = out2.tx; bool found1 = false; bool found2 = false; BOOST_FOREACH(CAmount d, CPrivateSend::GetStandardDenominations()) // loop through predefined denoms { if(pcoin1->vout[out1.i].nValue == d) found1 = true; if(pcoin2->vout[out2.i].nValue == d) found2 = true; } return (!found1 && found2); } bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, bool fUseInstantSend) const { setCoinsRet.clear(); nValueRet = 0; // List of values less than target pair<CAmount, pair<const CWalletTx*,unsigned int> > coinLowestLarger; coinLowestLarger.first = fUseInstantSend ? sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN : std::numeric_limits<CAmount>::max(); coinLowestLarger.second.first = NULL; vector<pair<CAmount, pair<const CWalletTx*,unsigned int> > > vValue; CAmount nTotalLower = 0; random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); // move denoms down on the list sort(vCoins.begin(), vCoins.end(), less_then_denom); // try to find nondenom first to prevent unneeded spending of mixed coins for (unsigned int tryDenom = 0; tryDenom < 2; tryDenom++) { LogPrint("selectcoins", "tryDenom: %d\n", tryDenom); vValue.clear(); nTotalLower = 0; BOOST_FOREACH(const COutput &output, vCoins) { if (!output.fSpendable) continue; const CWalletTx *pcoin = output.tx; // if (fDebug) LogPrint("selectcoins", "value %s confirms %d\n", FormatMoney(pcoin->vout[output.i].nValue), output.nDepth); if (output.nDepth < (pcoin->IsFromMe(ISMINE_ALL) ? nConfMine : nConfTheirs)) continue; int i = output.i; CAmount n = pcoin->vout[i].nValue; if (tryDenom == 0 && CPrivateSend::IsDenominatedAmount(n)) continue; // we don't want denom values on first run pair<CAmount,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i)); if (n == nTargetValue) { setCoinsRet.insert(coin.second); nValueRet += coin.first; return true; } else if (n < nTargetValue + MIN_CHANGE) { vValue.push_back(coin); nTotalLower += n; } else if (n < coinLowestLarger.first) { coinLowestLarger = coin; } } if (nTotalLower == nTargetValue) { for (unsigned int i = 0; i < vValue.size(); ++i) { setCoinsRet.insert(vValue[i].second); nValueRet += vValue[i].first; } return true; } if (nTotalLower < nTargetValue) { if (coinLowestLarger.second.first == NULL) // there is no input larger than nTargetValue { if (tryDenom == 0) // we didn't look at denom yet, let's do it continue; else // we looked at everything possible and didn't find anything, no luck return false; } setCoinsRet.insert(coinLowestLarger.second); nValueRet += coinLowestLarger.first; return true; } // nTotalLower > nTargetValue break; } // Solve subset sum by stochastic approximation sort(vValue.rbegin(), vValue.rend(), CompareValueOnly()); vector<char> vfBest; CAmount nBest; ApproximateBestSubset(vValue, nTotalLower, nTargetValue, vfBest, nBest, fUseInstantSend); if (nBest != nTargetValue && nTotalLower >= nTargetValue + MIN_CHANGE) ApproximateBestSubset(vValue, nTotalLower, nTargetValue + MIN_CHANGE, vfBest, nBest, fUseInstantSend); // If we have a bigger coin and (either the stochastic approximation didn't find a good solution, // or the next bigger coin is closer), return the bigger coin if (coinLowestLarger.second.first && ((nBest != nTargetValue && nBest < nTargetValue + MIN_CHANGE) || coinLowestLarger.first <= nBest)) { setCoinsRet.insert(coinLowestLarger.second); nValueRet += coinLowestLarger.first; } else { string s = "CWallet::SelectCoinsMinConf best subset: "; for (unsigned int i = 0; i < vValue.size(); i++) { if (vfBest[i]) { setCoinsRet.insert(vValue[i].second); nValueRet += vValue[i].first; s += FormatMoney(vValue[i].first) + " "; } } LogPrint("selectcoins", "%s - total %s\n", s, FormatMoney(nBest)); } return true; } bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl, AvailableCoinsType nCoinType, bool fUseInstantSend) const { // Note: this function should never be used for "always free" tx types like dstx vector<COutput> vCoins; AvailableCoins(vCoins, true, coinControl, false, nCoinType, fUseInstantSend); // coin control -> return all selected outputs (we want all selected to go into the transaction for sure) if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs) { BOOST_FOREACH(const COutput& out, vCoins) { if(!out.fSpendable) continue; if(nCoinType == ONLY_DENOMINATED) { COutPoint outpoint = COutPoint(out.tx->GetHash(),out.i); int nRounds = GetOutpointPrivateSendRounds(outpoint); // make sure it's actually anonymized if(nRounds < privateSendClient.nPrivateSendRounds) continue; } nValueRet += out.tx->vout[out.i].nValue; setCoinsRet.insert(make_pair(out.tx, out.i)); } return (nValueRet >= nTargetValue); } //if we're doing only denominated, we need to round up to the nearest smallest denomination if(nCoinType == ONLY_DENOMINATED) { std::vector<CAmount> vecPrivateSendDenominations = CPrivateSend::GetStandardDenominations(); CAmount nSmallestDenom = vecPrivateSendDenominations.back(); // Make outputs by looping through denominations, from large to small BOOST_FOREACH(CAmount nDenom, vecPrivateSendDenominations) { BOOST_FOREACH(const COutput& out, vCoins) { //make sure it's the denom we're looking for, round the amount up to smallest denom if(out.tx->vout[out.i].nValue == nDenom && nValueRet + nDenom < nTargetValue + nSmallestDenom) { COutPoint outpoint = COutPoint(out.tx->GetHash(),out.i); int nRounds = GetOutpointPrivateSendRounds(outpoint); // make sure it's actually anonymized if(nRounds < privateSendClient.nPrivateSendRounds) continue; nValueRet += nDenom; setCoinsRet.insert(make_pair(out.tx, out.i)); } } } return (nValueRet >= nTargetValue); } // calculate value from preset inputs and store them set<pair<const CWalletTx*, uint32_t> > setPresetCoins; CAmount nValueFromPresetInputs = 0; std::vector<COutPoint> vPresetInputs; if (coinControl) coinControl->ListSelected(vPresetInputs); BOOST_FOREACH(const COutPoint& outpoint, vPresetInputs) { map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash); if (it != mapWallet.end()) { const CWalletTx* pcoin = &it->second; // Clearly invalid input, fail if (pcoin->vout.size() <= outpoint.n) return false; nValueFromPresetInputs += pcoin->vout[outpoint.n].nValue; setPresetCoins.insert(make_pair(pcoin, outpoint.n)); } else return false; // TODO: Allow non-wallet inputs } // remove preset inputs from vCoins for (vector<COutput>::iterator it = vCoins.begin(); it != vCoins.end() && coinControl && coinControl->HasSelected();) { if (setPresetCoins.count(make_pair(it->tx, it->i))) it = vCoins.erase(it); else ++it; } bool res = nTargetValue <= nValueFromPresetInputs || SelectCoinsMinConf(nTargetValue - nValueFromPresetInputs, 1, 6, vCoins, setCoinsRet, nValueRet, fUseInstantSend) || SelectCoinsMinConf(nTargetValue - nValueFromPresetInputs, 1, 1, vCoins, setCoinsRet, nValueRet, fUseInstantSend) || (bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue - nValueFromPresetInputs, 0, 1, vCoins, setCoinsRet, nValueRet, fUseInstantSend)); // because SelectCoinsMinConf clears the setCoinsRet, we now add the possible inputs to the coinset setCoinsRet.insert(setPresetCoins.begin(), setPresetCoins.end()); // add preset inputs to the total value selected nValueRet += nValueFromPresetInputs; return res; } struct CompareByPriority { bool operator()(const COutput& t1, const COutput& t2) const { return t1.Priority() > t2.Priority(); } }; bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nChangePosRet, std::string& strFailReason, bool includeWatching) { vector<CRecipient> vecSend; // Turn the txout set into a CRecipient vector BOOST_FOREACH(const CTxOut& txOut, tx.vout) { CRecipient recipient = {txOut.scriptPubKey, txOut.nValue, false}; vecSend.push_back(recipient); } CCoinControl coinControl; coinControl.fAllowOtherInputs = true; coinControl.fAllowWatchOnly = includeWatching; BOOST_FOREACH(const CTxIn& txin, tx.vin) coinControl.Select(txin.prevout); CReserveKey reservekey(this); CWalletTx wtx; if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosRet, strFailReason, &coinControl, false)) return false; if (nChangePosRet != -1) tx.vout.insert(tx.vout.begin() + nChangePosRet, wtx.vout[nChangePosRet]); // Add new txins (keeping original txin scriptSig/order) BOOST_FOREACH(const CTxIn& txin, wtx.vin) { if (!coinControl.IsSelected(txin.prevout)) tx.vin.push_back(txin); } return true; } bool CWallet::SelectCoinsByDenominations(int nDenom, CAmount nValueMin, CAmount nValueMax, std::vector<CTxDSIn>& vecTxDSInRet, std::vector<COutput>& vCoinsRet, CAmount& nValueRet, int nPrivateSendRoundsMin, int nPrivateSendRoundsMax) { vecTxDSInRet.clear(); vCoinsRet.clear(); nValueRet = 0; vector<COutput> vCoins; AvailableCoins(vCoins, true, NULL, false, ONLY_DENOMINATED); std::random_shuffle(vCoins.rbegin(), vCoins.rend(), GetRandInt); // ( bit on if present ) // bit 0 - 100DASH+1 // bit 1 - 10DASH+1 // bit 2 - 1DASH+1 // bit 3 - .1DASH+1 std::vector<int> vecBits; if (!CPrivateSend::GetDenominationsBits(nDenom, vecBits)) { return false; } int nDenomResult = 0; std::vector<CAmount> vecPrivateSendDenominations = CPrivateSend::GetStandardDenominations(); InsecureRand insecureRand; BOOST_FOREACH(const COutput& out, vCoins) { // masternode-like input should not be selected by AvailableCoins now anyway //if(out.tx->vout[out.i].nValue == 1000*COIN) continue; if(nValueRet + out.tx->vout[out.i].nValue <= nValueMax){ CTxIn txin = CTxIn(out.tx->GetHash(), out.i); int nRounds = GetOutpointPrivateSendRounds(txin.prevout); if(nRounds >= nPrivateSendRoundsMax) continue; if(nRounds < nPrivateSendRoundsMin) continue; BOOST_FOREACH(int nBit, vecBits) { if(out.tx->vout[out.i].nValue == vecPrivateSendDenominations[nBit]) { if(nValueRet >= nValueMin) { //randomly reduce the max amount we'll submit (for anonymity) nValueMax -= insecureRand(nValueMax/5); //on average use 50% of the inputs or less int r = insecureRand(vCoins.size()); if((int)vecTxDSInRet.size() > r) return true; } nValueRet += out.tx->vout[out.i].nValue; vecTxDSInRet.push_back(CTxDSIn(txin, out.tx->vout[out.i].scriptPubKey)); vCoinsRet.push_back(out); nDenomResult |= 1 << nBit; } } } } return nValueRet >= nValueMin && nDenom == nDenomResult; } struct CompareByAmount { bool operator()(const CompactTallyItem& t1, const CompactTallyItem& t2) const { return t1.nAmount > t2.nAmount; } }; bool CWallet::SelectCoinsGrouppedByAddresses(std::vector<CompactTallyItem>& vecTallyRet, bool fSkipDenominated, bool fAnonymizable, bool fSkipUnconfirmed) const { LOCK2(cs_main, cs_wallet); isminefilter filter = ISMINE_SPENDABLE; // try to use cache for already confirmed anonymizable inputs if(fAnonymizable && fSkipUnconfirmed) { if(fSkipDenominated && fAnonymizableTallyCachedNonDenom) { vecTallyRet = vecAnonymizableTallyCachedNonDenom; LogPrint("selectcoins", "SelectCoinsGrouppedByAddresses - using cache for non-denom inputs %d\n", vecTallyRet.size()); return vecTallyRet.size() > 0; } if(!fSkipDenominated && fAnonymizableTallyCached) { vecTallyRet = vecAnonymizableTallyCached; LogPrint("selectcoins", "SelectCoinsGrouppedByAddresses - using cache for all inputs %d\n", vecTallyRet.size()); return vecTallyRet.size() > 0; } } CAmount nSmallestDenom = CPrivateSend::GetSmallestDenomination(); // Tally map<CTxDestination, CompactTallyItem> mapTally; std::set<uint256> setWalletTxesCounted; for (auto& outpoint : setWalletUTXO) { if (setWalletTxesCounted.find(outpoint.hash) != setWalletTxesCounted.end()) continue; setWalletTxesCounted.insert(outpoint.hash); map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash); if (it == mapWallet.end()) continue; const CWalletTx& wtx = (*it).second; if(wtx.IsCoinBase() && wtx.GetBlocksToMaturity() > 0) continue; if(fSkipUnconfirmed && !wtx.IsTrusted()) continue; for (unsigned int i = 0; i < wtx.vout.size(); i++) { CTxDestination txdest; if (!ExtractDestination(wtx.vout[i].scriptPubKey, txdest)) continue; isminefilter mine = ::IsMine(*this, txdest); if(!(mine & filter)) continue; if(IsSpent(outpoint.hash, i) || IsLockedCoin(outpoint.hash, i)) continue; if(fSkipDenominated && CPrivateSend::IsDenominatedAmount(wtx.vout[i].nValue)) continue; if(fAnonymizable) { // ignore collaterals if(CPrivateSend::IsCollateralAmount(wtx.vout[i].nValue)) continue; if(fMasterNode && wtx.vout[i].nValue == 1000*COIN) continue; // ignore outputs that are 10 times smaller then the smallest denomination // otherwise they will just lead to higher fee / lower priority if(wtx.vout[i].nValue <= nSmallestDenom/10) continue; // ignore anonymized if(GetOutpointPrivateSendRounds(COutPoint(outpoint.hash, i)) >= privateSendClient.nPrivateSendRounds) continue; } CompactTallyItem& item = mapTally[txdest]; item.txdest = txdest; item.nAmount += wtx.vout[i].nValue; item.vecTxIn.push_back(CTxIn(outpoint.hash, i)); } } // construct resulting vector vecTallyRet.clear(); BOOST_FOREACH(const PAIRTYPE(CTxDestination, CompactTallyItem)& item, mapTally) { if(fAnonymizable && item.second.nAmount < nSmallestDenom) continue; vecTallyRet.push_back(item.second); } // order by amounts per address, from smallest to largest sort(vecTallyRet.rbegin(), vecTallyRet.rend(), CompareByAmount()); // cache already confirmed anonymizable entries for later use if(fAnonymizable && fSkipUnconfirmed) { if(fSkipDenominated) { vecAnonymizableTallyCachedNonDenom = vecTallyRet; fAnonymizableTallyCachedNonDenom = true; } else { vecAnonymizableTallyCached = vecTallyRet; fAnonymizableTallyCached = true; } } // debug if (LogAcceptCategory("selectcoins")) { std::string strMessage = "SelectCoinsGrouppedByAddresses - vecTallyRet:\n"; BOOST_FOREACH(CompactTallyItem& item, vecTallyRet) strMessage += strprintf(" %s %f\n", CBitcoinAddress(item.txdest).ToString().c_str(), float(item.nAmount)/COIN); LogPrint("selectcoins", "%s", strMessage); } return vecTallyRet.size() > 0; } bool CWallet::SelectCoinsDark(CAmount nValueMin, CAmount nValueMax, std::vector<CTxIn>& vecTxInRet, CAmount& nValueRet, int nPrivateSendRoundsMin, int nPrivateSendRoundsMax) const { CCoinControl *coinControl=NULL; vecTxInRet.clear(); nValueRet = 0; vector<COutput> vCoins; AvailableCoins(vCoins, true, coinControl, false, nPrivateSendRoundsMin < 0 ? ONLY_NONDENOMINATED : ONLY_DENOMINATED); //order the array so largest nondenom are first, then denominations, then very small inputs. sort(vCoins.rbegin(), vCoins.rend(), CompareByPriority()); BOOST_FOREACH(const COutput& out, vCoins) { //do not allow inputs less than 1/10th of minimum value if(out.tx->vout[out.i].nValue < nValueMin/10) continue; //do not allow collaterals to be selected if(CPrivateSend::IsCollateralAmount(out.tx->vout[out.i].nValue)) continue; if(fMasterNode && out.tx->vout[out.i].nValue == 1000*COIN) continue; //masternode input if(nValueRet + out.tx->vout[out.i].nValue <= nValueMax){ CTxIn txin = CTxIn(out.tx->GetHash(),out.i); int nRounds = GetOutpointPrivateSendRounds(txin.prevout); if(nRounds >= nPrivateSendRoundsMax) continue; if(nRounds < nPrivateSendRoundsMin) continue; nValueRet += out.tx->vout[out.i].nValue; vecTxInRet.push_back(txin); } } return nValueRet >= nValueMin; } bool CWallet::GetCollateralTxDSIn(CTxDSIn& txdsinRet, CAmount& nValueRet) const { vector<COutput> vCoins; AvailableCoins(vCoins); BOOST_FOREACH(const COutput& out, vCoins) { if(CPrivateSend::IsCollateralAmount(out.tx->vout[out.i].nValue)) { txdsinRet = CTxDSIn(CTxIn(out.tx->GetHash(), out.i), out.tx->vout[out.i].scriptPubKey); nValueRet = out.tx->vout[out.i].nValue; return true; } } return false; } bool CWallet::GetMasternodeOutpointAndKeys(COutPoint& outpointRet, CPubKey& pubKeyRet, CKey& keyRet, std::string strTxHash, std::string strOutputIndex) { // wait for reindex and/or import to finish if (fImporting || fReindex) return false; // Find possible candidates std::vector<COutput> vPossibleCoins; AvailableCoins(vPossibleCoins, true, NULL, false, ONLY_1000); if(vPossibleCoins.empty()) { LogPrintf("CWallet::GetMasternodeOutpointAndKeys -- Could not locate any valid masternode vin\n"); return false; } if(strTxHash.empty()) // No output specified, select the first one return GetOutpointAndKeysFromOutput(vPossibleCoins[0], outpointRet, pubKeyRet, keyRet); // Find specific vin uint256 txHash = uint256S(strTxHash); int nOutputIndex = atoi(strOutputIndex.c_str()); BOOST_FOREACH(COutput& out, vPossibleCoins) if(out.tx->GetHash() == txHash && out.i == nOutputIndex) // found it! return GetOutpointAndKeysFromOutput(out, outpointRet, pubKeyRet, keyRet); LogPrintf("CWallet::GetMasternodeOutpointAndKeys -- Could not locate specified masternode vin\n"); return false; } bool CWallet::GetOutpointAndKeysFromOutput(const COutput& out, COutPoint& outpointRet, CPubKey& pubKeyRet, CKey& keyRet) { // wait for reindex and/or import to finish if (fImporting || fReindex) return false; CScript pubScript; outpointRet = COutPoint(out.tx->GetHash(), out.i); pubScript = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey CTxDestination address1; ExtractDestination(pubScript, address1); CBitcoinAddress address2(address1); CKeyID keyID; if (!address2.GetKeyID(keyID)) { LogPrintf("CWallet::GetOutpointAndKeysFromOutput -- Address does not refer to a key\n"); return false; } if (!GetKey(keyID, keyRet)) { LogPrintf ("CWallet::GetOutpointAndKeysFromOutput -- Private key for address is not known\n"); return false; } pubKeyRet = keyRet.GetPubKey(); return true; } int CWallet::CountInputsWithAmount(CAmount nInputAmount) { CAmount nTotal = 0; { LOCK2(cs_main, cs_wallet); for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; if (pcoin->IsTrusted()){ int nDepth = pcoin->GetDepthInMainChain(false); for (unsigned int i = 0; i < pcoin->vout.size(); i++) { COutput out = COutput(pcoin, i, nDepth, true, true); COutPoint outpoint = COutPoint(out.tx->GetHash(), out.i); if(out.tx->vout[out.i].nValue != nInputAmount) continue; if(!CPrivateSend::IsDenominatedAmount(pcoin->vout[i].nValue)) continue; if(IsSpent(out.tx->GetHash(), i) || IsMine(pcoin->vout[i]) != ISMINE_SPENDABLE || !IsDenominated(outpoint)) continue; nTotal++; } } } } return nTotal; } bool CWallet::HasCollateralInputs(bool fOnlyConfirmed) const { vector<COutput> vCoins; AvailableCoins(vCoins, fOnlyConfirmed, NULL, false, ONLY_PRIVATESEND_COLLATERAL); return !vCoins.empty(); } bool CWallet::CreateCollateralTransaction(CMutableTransaction& txCollateral, std::string& strReason) { txCollateral.vin.clear(); txCollateral.vout.clear(); CReserveKey reservekey(this); CAmount nValue = 0; CTxDSIn txdsinCollateral; if (!GetCollateralTxDSIn(txdsinCollateral, nValue)) { strReason = "PrivateSend requires a collateral transaction and could not locate an acceptable input!"; return false; } // make our change address CScript scriptChange; CPubKey vchPubKey; assert(reservekey.GetReservedKey(vchPubKey, true)); // should never fail, as we just unlocked scriptChange = GetScriptForDestination(vchPubKey.GetID()); reservekey.KeepKey(); txCollateral.vin.push_back(txdsinCollateral); //pay collateral charge in fees CTxOut txout = CTxOut(nValue - CPrivateSend::GetCollateralAmount(), scriptChange); txCollateral.vout.push_back(txout); if(!SignSignature(*this, txdsinCollateral.prevPubKey, txCollateral, 0, int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))) { strReason = "Unable to sign collateral transaction!"; return false; } return true; } bool CWallet::GetBudgetSystemCollateralTX(CTransaction& tx, uint256 hash, CAmount amount, bool fUseInstantSend) { CWalletTx wtx; if(GetBudgetSystemCollateralTX(wtx, hash, amount, fUseInstantSend)){ tx = (CTransaction)wtx; return true; } return false; } bool CWallet::GetBudgetSystemCollateralTX(CWalletTx& tx, uint256 hash, CAmount amount, bool fUseInstantSend) { // make our change address CReserveKey reservekey(this); CScript scriptChange; scriptChange << OP_RETURN << ToByteVector(hash); CAmount nFeeRet = 0; int nChangePosRet = -1; std::string strFail = ""; vector< CRecipient > vecSend; vecSend.push_back((CRecipient){scriptChange, amount, false}); CCoinControl *coinControl=NULL; bool success = CreateTransaction(vecSend, tx, reservekey, nFeeRet, nChangePosRet, strFail, coinControl, true, ALL_COINS, fUseInstantSend); if(!success){ LogPrintf("CWallet::GetBudgetSystemCollateralTX -- Error: %s\n", strFail); return false; } return true; } bool CWallet::ConvertList(std::vector<CTxIn> vecTxIn, std::vector<CAmount>& vecAmounts) { BOOST_FOREACH(CTxIn txin, vecTxIn) { if (mapWallet.count(txin.prevout.hash)) { CWalletTx& wtx = mapWallet[txin.prevout.hash]; if(txin.prevout.n < wtx.vout.size()){ vecAmounts.push_back(wtx.vout[txin.prevout.n].nValue); } } else { LogPrintf("CWallet::ConvertList -- Couldn't find transaction\n"); } } return true; } bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, int& nChangePosRet, std::string& strFailReason, const CCoinControl* coinControl, bool sign, AvailableCoinsType nCoinType, bool fUseInstantSend) { CAmount nFeePay = fUseInstantSend ? CTxLockRequest().GetMinFee() : 0; CAmount nValue = 0; unsigned int nSubtractFeeFromAmount = 0; BOOST_FOREACH (const CRecipient& recipient, vecSend) { if (nValue < 0 || recipient.nAmount < 0) { strFailReason = _("Transaction amounts must be positive"); return false; } nValue += recipient.nAmount; if (recipient.fSubtractFeeFromAmount) nSubtractFeeFromAmount++; } if (vecSend.empty() || nValue < 0) { strFailReason = _("Transaction amounts must be positive"); return false; } wtxNew.fTimeReceivedIsTxTime = true; wtxNew.BindWallet(this); CMutableTransaction txNew; // Discourage fee sniping. // // For a large miner the value of the transactions in the best block and // the mempool can exceed the cost of deliberately attempting to mine two // blocks to orphan the current best block. By setting nLockTime such that // only the next block can include the transaction, we discourage this // practice as the height restricted and limited blocksize gives miners // considering fee sniping fewer options for pulling off this attack. // // A simple way to think about this is from the wallet's point of view we // always want the blockchain to move forward. By setting nLockTime this // way we're basically making the statement that we only want this // transaction to appear in the next block; we don't want to potentially // encourage reorgs by allowing transactions to appear at lower heights // than the next block in forks of the best chain. // // Of course, the subsidy is high enough, and transaction volume low // enough, that fee sniping isn't a problem yet, but by implementing a fix // now we ensure code won't be written that makes assumptions about // nLockTime that preclude a fix later. txNew.nLockTime = chainActive.Height(); // Secondly occasionally randomly pick a nLockTime even further back, so // that transactions that are delayed after signing for whatever reason, // e.g. high-latency mix networks and some CoinJoin implementations, have // better privacy. if (GetRandInt(10) == 0) txNew.nLockTime = std::max(0, (int)txNew.nLockTime - GetRandInt(100)); assert(txNew.nLockTime <= (unsigned int)chainActive.Height()); assert(txNew.nLockTime < LOCKTIME_THRESHOLD); { LOCK2(cs_main, cs_wallet); { nFeeRet = 0; if(nFeePay > 0) nFeeRet = nFeePay; // Start with no fee and loop until there is enough fee while (true) { txNew.vin.clear(); txNew.vout.clear(); wtxNew.fFromMe = true; nChangePosRet = -1; bool fFirst = true; CAmount nValueToSelect = nValue; if (nSubtractFeeFromAmount == 0) nValueToSelect += nFeeRet; double dPriority = 0; // vouts to the payees BOOST_FOREACH (const CRecipient& recipient, vecSend) { CTxOut txout(recipient.nAmount, recipient.scriptPubKey); if (recipient.fSubtractFeeFromAmount) { txout.nValue -= nFeeRet / nSubtractFeeFromAmount; // Subtract fee equally from each selected recipient if (fFirst) // first receiver pays the remainder not divisible by output count { fFirst = false; txout.nValue -= nFeeRet % nSubtractFeeFromAmount; } } if (txout.IsDust(::minRelayTxFee)) { if (recipient.fSubtractFeeFromAmount && nFeeRet > 0) { if (txout.nValue < 0) strFailReason = _("The transaction amount is too small to pay the fee"); else strFailReason = _("The transaction amount is too small to send after the fee has been deducted"); } else strFailReason = _("Transaction amount too small"); return false; } txNew.vout.push_back(txout); } // Choose coins to use set<pair<const CWalletTx*,unsigned int> > setCoins; CAmount nValueIn = 0; if (!SelectCoins(nValueToSelect, setCoins, nValueIn, coinControl, nCoinType, fUseInstantSend)) { if (nCoinType == ONLY_NONDENOMINATED) { strFailReason = _("Unable to locate enough PrivateSend non-denominated funds for this transaction."); } else if (nCoinType == ONLY_DENOMINATED) { strFailReason = _("Unable to locate enough PrivateSend denominated funds for this transaction."); strFailReason += " " + _("PrivateSend uses exact denominated amounts to send funds, you might simply need to anonymize some more coins."); } else if (nValueIn < nValueToSelect) { strFailReason = _("Insufficient funds."); if (fUseInstantSend) { // could be not true but most likely that's the reason strFailReason += " " + strprintf(_("InstantSend requires inputs with at least %d confirmations, you might need to wait a few minutes and try again."), INSTANTSEND_CONFIRMATIONS_REQUIRED); } } return false; } if (fUseInstantSend && nValueIn > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) { strFailReason += " " + strprintf(_("InstantSend doesn't support sending values that high yet. Transactions are currently limited to %1 COMMUNITYCOIN."), sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)); return false; } BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) { CAmount nCredit = pcoin.first->vout[pcoin.second].nValue; //The coin age after the next block (depth+1) is used instead of the current, //reflecting an assumption the user would accept a bit more delay for //a chance at a free transaction. //But mempool inputs might still be in the mempool, so their age stays 0 int age = pcoin.first->GetDepthInMainChain(); assert(age >= 0); if (age != 0) age += 1; dPriority += (double)nCredit * age; } const CAmount nChange = nValueIn - nValueToSelect; CTxOut newTxOut; if (nChange > 0) { //over pay for denominated transactions if (nCoinType == ONLY_DENOMINATED) { nFeeRet += nChange; wtxNew.mapValue["DS"] = "1"; // recheck skipped denominations during next mixing privateSendClient.ClearSkippedDenominations(); } else { // Fill a vout to ourself // TODO: pass in scriptChange instead of reservekey so // change transaction isn't always pay-to-communitycoin-address CScript scriptChange; // coin control: send change to custom address if (coinControl && !boost::get<CNoDestination>(&coinControl->destChange)) scriptChange = GetScriptForDestination(coinControl->destChange); // no coin control: send change to newly generated address else { // Note: We use a new key here to keep it from being obvious which side is the change. // The drawback is that by not reusing a previous key, the change may be lost if a // backup is restored, if the backup doesn't have the new private key for the change. // If we reused the old key, it would be possible to add code to look for and // rediscover unknown transactions that were written with keys of ours to recover // post-backup change. // Reserve a new key pair from key pool CPubKey vchPubKey; if (!reservekey.GetReservedKey(vchPubKey, true)) { strFailReason = _("Keypool ran out, please call keypoolrefill first"); return false; } scriptChange = GetScriptForDestination(vchPubKey.GetID()); } newTxOut = CTxOut(nChange, scriptChange); // We do not move dust-change to fees, because the sender would end up paying more than requested. // This would be against the purpose of the all-inclusive feature. // So instead we raise the change and deduct from the recipient. if (nSubtractFeeFromAmount > 0 && newTxOut.IsDust(::minRelayTxFee)) { CAmount nDust = newTxOut.GetDustThreshold(::minRelayTxFee) - newTxOut.nValue; newTxOut.nValue += nDust; // raise change until no more dust for (unsigned int i = 0; i < vecSend.size(); i++) // subtract from first recipient { if (vecSend[i].fSubtractFeeFromAmount) { txNew.vout[i].nValue -= nDust; if (txNew.vout[i].IsDust(::minRelayTxFee)) { strFailReason = _("The transaction amount is too small to send after the fee has been deducted"); return false; } break; } } } // Never create dust outputs; if we would, just // add the dust to the fee. if (newTxOut.IsDust(::minRelayTxFee)) { nFeeRet += nChange; reservekey.ReturnKey(); } else { // Insert change txn at random position: nChangePosRet = GetRandInt(txNew.vout.size()+1); vector<CTxOut>::iterator position = txNew.vout.begin()+nChangePosRet; txNew.vout.insert(position, newTxOut); } } } else reservekey.ReturnKey(); // Fill vin // // Note how the sequence number is set to max()-1 so that the // nLockTime set above actually works. std::vector<CTxDSIn> vecTxDSInTmp; BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins){ CTxIn txin = CTxIn(coin.first->GetHash(),coin.second,CScript(), std::numeric_limits<unsigned int>::max()-1); vecTxDSInTmp.push_back(CTxDSIn(txin, coin.first->vout[coin.second].scriptPubKey)); txNew.vin.push_back(txin); } sort(txNew.vin.begin(), txNew.vin.end(), CompareInputBIP69()); sort(vecTxDSInTmp.begin(), vecTxDSInTmp.end(), CompareInputBIP69()); sort(txNew.vout.begin(), txNew.vout.end(), CompareOutputBIP69()); // If there was change output added before, we must update its position now if (nChangePosRet != -1) { int i = 0; BOOST_FOREACH(const CTxOut& txOut, txNew.vout) { if (txOut == newTxOut) { nChangePosRet = i; break; } i++; } } // Sign int nIn = 0; CTransaction txNewConst(txNew); for (const auto& txdsin : vecTxDSInTmp) { bool signSuccess; const CScript& scriptPubKey = txdsin.prevPubKey; CScript& scriptSigRes = txNew.vin[nIn].scriptSig; if (sign) signSuccess = ProduceSignature(TransactionSignatureCreator(this, &txNewConst, nIn, SIGHASH_ALL), scriptPubKey, scriptSigRes); else signSuccess = ProduceSignature(DummySignatureCreator(this), scriptPubKey, scriptSigRes); if (!signSuccess) { strFailReason = _("Signing transaction failed"); return false; } nIn++; } unsigned int nBytes = ::GetSerializeSize(txNew, SER_NETWORK, PROTOCOL_VERSION); // Remove scriptSigs if we used dummy signatures for fee calculation if (!sign) { BOOST_FOREACH (CTxIn& txin, txNew.vin) txin.scriptSig = CScript(); } // Embed the constructed transaction data in wtxNew. *static_cast<CTransaction*>(&wtxNew) = CTransaction(txNew); // Limit size if (nBytes >= MAX_STANDARD_TX_SIZE) { strFailReason = _("Transaction too large"); return false; } dPriority = wtxNew.ComputePriority(dPriority, nBytes); // Can we complete this as a free transaction? // Note: InstantSend transaction can't be a free one if (!fUseInstantSend && fSendFreeTransactions && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE) { // Not enough fee: enough priority? double dPriorityNeeded = mempool.estimateSmartPriority(nTxConfirmTarget); // Require at least hard-coded AllowFree. if (dPriority >= dPriorityNeeded && AllowFree(dPriority)) break; // Small enough, and priority high enough, to send for free // if (dPriorityNeeded > 0 && dPriority >= dPriorityNeeded) // break; } CAmount nFeeNeeded = max(nFeePay, GetMinimumFee(nBytes, nTxConfirmTarget, mempool)); if (coinControl && nFeeNeeded > 0 && coinControl->nMinimumTotalFee > nFeeNeeded) { nFeeNeeded = coinControl->nMinimumTotalFee; } if(fUseInstantSend) { nFeeNeeded = std::max(nFeeNeeded, CTxLockRequest(txNew).GetMinFee()); } // If we made it here and we aren't even able to meet the relay fee on the next pass, give up // because we must be at the maximum allowed fee. if (nFeeNeeded < ::minRelayTxFee.GetFee(nBytes)) { strFailReason = _("Transaction too large for fee policy"); return false; } if (nFeeRet >= nFeeNeeded) break; // Done, enough fee included. // Include more fee and try again. nFeeRet = nFeeNeeded; continue; } } } return true; } /** * Call after CreateTransaction unless you want to abort */ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CConnman* connman, std::string strCommand) { { LOCK2(cs_main, cs_wallet); LogPrintf("CommitTransaction:\n%s", wtxNew.ToString()); { // This is only to keep the database open to defeat the auto-flush for the // duration of this scope. This is the only place where this optimization // maybe makes sense; please don't do it anywhere else. CWalletDB* pwalletdb = fFileBacked ? new CWalletDB(strWalletFile,"r+") : NULL; // Take key pair from key pool so it won't be used again reservekey.KeepKey(); // Add tx to wallet, because if it has change it's also ours, // otherwise just for transaction history. AddToWallet(wtxNew, false, pwalletdb); // Notify that old coins are spent set<uint256> updated_hahes; BOOST_FOREACH(const CTxIn& txin, wtxNew.vin) { // notify only once if(updated_hahes.find(txin.prevout.hash) != updated_hahes.end()) continue; CWalletTx &coin = mapWallet[txin.prevout.hash]; coin.BindWallet(this); NotifyTransactionChanged(this, txin.prevout.hash, CT_UPDATED); updated_hahes.insert(txin.prevout.hash); } if (fFileBacked) delete pwalletdb; } // Track how many getdata requests our transaction gets mapRequestCount[wtxNew.GetHash()] = 0; if (fBroadcastTransactions) { // Broadcast if (!wtxNew.AcceptToMemoryPool(false)) { // This must not fail. The transaction has already been signed and recorded. LogPrintf("CommitTransaction(): Error: Transaction not valid\n"); return false; } wtxNew.RelayWalletTransaction(connman, strCommand); } } return true; } bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB & pwalletdb) { if (!pwalletdb.WriteAccountingEntry_Backend(acentry)) return false; laccentries.push_back(acentry); CAccountingEntry & entry = laccentries.back(); wtxOrdered.insert(make_pair(entry.nOrderPos, TxPair((CWalletTx*)0, &entry))); return true; } CAmount CWallet::GetRequiredFee(unsigned int nTxBytes) { return std::max(minTxFee.GetFee(nTxBytes), ::minRelayTxFee.GetFee(nTxBytes)); } CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool) { // payTxFee is user-set "I want to pay this much" CAmount nFeeNeeded = payTxFee.GetFee(nTxBytes); // User didn't set: use -txconfirmtarget to estimate... if (nFeeNeeded == 0) { int estimateFoundTarget = nConfirmTarget; nFeeNeeded = pool.estimateSmartFee(nConfirmTarget, &estimateFoundTarget).GetFee(nTxBytes); // ... unless we don't have enough mempool data for estimatefee, then use fallbackFee if (nFeeNeeded == 0) nFeeNeeded = fallbackFee.GetFee(nTxBytes); } // prevent user from paying a fee below minRelayTxFee or minTxFee nFeeNeeded = std::max(nFeeNeeded, GetRequiredFee(nTxBytes)); // But always obey the maximum if (nFeeNeeded > maxTxFee) nFeeNeeded = maxTxFee; return nFeeNeeded; } DBErrors CWallet::LoadWallet(bool& fFirstRunRet) { if (!fFileBacked) return DB_LOAD_OK; fFirstRunRet = false; DBErrors nLoadWalletRet = CWalletDB(strWalletFile,"cr+").LoadWallet(this); if (nLoadWalletRet == DB_NEED_REWRITE) { if (CDB::Rewrite(strWalletFile, "\x04pool")) { LOCK(cs_wallet); setInternalKeyPool.clear(); setExternalKeyPool.clear(); nKeysLeftSinceAutoBackup = 0; // Note: can't top-up keypool here, because wallet is locked. // User will be prompted to unlock wallet the next operation // that requires a new key. } } { LOCK2(cs_main, cs_wallet); for (auto& pair : mapWallet) { for(int i = 0; i < pair.second.vout.size(); ++i) { if (IsMine(pair.second.vout[i]) && !IsSpent(pair.first, i)) { setWalletUTXO.insert(COutPoint(pair.first, i)); } } } } if (nLoadWalletRet != DB_LOAD_OK) return nLoadWalletRet; fFirstRunRet = !vchDefaultKey.IsValid(); uiInterface.LoadWallet(this); return DB_LOAD_OK; } DBErrors CWallet::ZapWalletTx(std::vector<CWalletTx>& vWtx) { if (!fFileBacked) return DB_LOAD_OK; DBErrors nZapWalletTxRet = CWalletDB(strWalletFile,"cr+").ZapWalletTx(this, vWtx); if (nZapWalletTxRet == DB_NEED_REWRITE) { if (CDB::Rewrite(strWalletFile, "\x04pool")) { LOCK(cs_wallet); setInternalKeyPool.clear(); setExternalKeyPool.clear(); nKeysLeftSinceAutoBackup = 0; // Note: can't top-up keypool here, because wallet is locked. // User will be prompted to unlock wallet the next operation // that requires a new key. } } if (nZapWalletTxRet != DB_LOAD_OK) return nZapWalletTxRet; return DB_LOAD_OK; } bool CWallet::SetAddressBook(const CTxDestination& address, const string& strName, const string& strPurpose) { bool fUpdated = false; { LOCK(cs_wallet); // mapAddressBook std::map<CTxDestination, CAddressBookData>::iterator mi = mapAddressBook.find(address); fUpdated = mi != mapAddressBook.end(); mapAddressBook[address].name = strName; if (!strPurpose.empty()) /* update purpose only if requested */ mapAddressBook[address].purpose = strPurpose; } NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address) != ISMINE_NO, strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) ); if (!fFileBacked) return false; if (!strPurpose.empty() && !CWalletDB(strWalletFile).WritePurpose(CBitcoinAddress(address).ToString(), strPurpose)) return false; return CWalletDB(strWalletFile).WriteName(CBitcoinAddress(address).ToString(), strName); } bool CWallet::DelAddressBook(const CTxDestination& address) { { LOCK(cs_wallet); // mapAddressBook if(fFileBacked) { // Delete destdata tuples associated with address std::string strAddress = CBitcoinAddress(address).ToString(); BOOST_FOREACH(const PAIRTYPE(string, string) &item, mapAddressBook[address].destdata) { CWalletDB(strWalletFile).EraseDestData(strAddress, item.first); } } mapAddressBook.erase(address); } NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address) != ISMINE_NO, "", CT_DELETED); if (!fFileBacked) return false; CWalletDB(strWalletFile).ErasePurpose(CBitcoinAddress(address).ToString()); return CWalletDB(strWalletFile).EraseName(CBitcoinAddress(address).ToString()); } bool CWallet::SetDefaultKey(const CPubKey &vchPubKey) { if (fFileBacked) { if (!CWalletDB(strWalletFile).WriteDefaultKey(vchPubKey)) return false; } vchDefaultKey = vchPubKey; return true; } /** * Mark old keypool keys as used, * and generate all new keys */ bool CWallet::NewKeyPool() { { LOCK(cs_wallet); CWalletDB walletdb(strWalletFile); BOOST_FOREACH(int64_t nIndex, setInternalKeyPool) { walletdb.ErasePool(nIndex); } setInternalKeyPool.clear(); BOOST_FOREACH(int64_t nIndex, setExternalKeyPool) { walletdb.ErasePool(nIndex); } setExternalKeyPool.clear(); privateSendClient.fEnablePrivateSend = false; nKeysLeftSinceAutoBackup = 0; if (!TopUpKeyPool()) return false; LogPrintf("CWallet::NewKeyPool rewrote keypool\n"); } return true; } size_t CWallet::KeypoolCountExternalKeys() { AssertLockHeld(cs_wallet); // setExternalKeyPool return setExternalKeyPool.size(); } size_t CWallet::KeypoolCountInternalKeys() { AssertLockHeld(cs_wallet); // setInternalKeyPool return setInternalKeyPool.size(); } bool CWallet::TopUpKeyPool(unsigned int kpSize) { { LOCK(cs_wallet); if (IsLocked(true)) return false; // Top up key pool unsigned int nTargetSize; if (kpSize > 0) nTargetSize = kpSize; else nTargetSize = max(GetArg("-keypool", DEFAULT_KEYPOOL_SIZE), (int64_t) 0); // count amount of available keys (internal, external) // make sure the keypool of external and internal keys fits the user selected target (-keypool) int64_t amountExternal = setExternalKeyPool.size(); int64_t amountInternal = setInternalKeyPool.size(); int64_t missingExternal = std::max(std::max((int64_t) nTargetSize, (int64_t) 1) - amountExternal, (int64_t) 0); int64_t missingInternal = std::max(std::max((int64_t) nTargetSize, (int64_t) 1) - amountInternal, (int64_t) 0); if (!IsHDEnabled()) { // don't create extra internal keys missingInternal = 0; } else { nTargetSize *= 2; } bool fInternal = false; CWalletDB walletdb(strWalletFile); for (int64_t i = missingInternal + missingExternal; i--;) { int64_t nEnd = 1; if (i < missingInternal) { fInternal = true; } if (!setInternalKeyPool.empty()) { nEnd = *(--setInternalKeyPool.end()) + 1; } if (!setExternalKeyPool.empty()) { nEnd = std::max(nEnd, *(--setExternalKeyPool.end()) + 1); } // TODO: implement keypools for all accounts? if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey(0, fInternal), fInternal))) throw runtime_error("TopUpKeyPool(): writing generated key failed"); if (fInternal) { setInternalKeyPool.insert(nEnd); } else { setExternalKeyPool.insert(nEnd); } LogPrintf("keypool added key %d, size=%u, internal=%d\n", nEnd, setInternalKeyPool.size() + setExternalKeyPool.size(), fInternal); double dProgress = 100.f * nEnd / (nTargetSize + 1); std::string strMsg = strprintf(_("Loading wallet... (%3.2f %%)"), dProgress); uiInterface.InitMessage(strMsg); } } return true; } void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fInternal) { nIndex = -1; keypool.vchPubKey = CPubKey(); { LOCK(cs_wallet); if (!IsLocked(true)) TopUpKeyPool(); fInternal = fInternal && IsHDEnabled(); std::set<int64_t>& setKeyPool = fInternal ? setInternalKeyPool : setExternalKeyPool; // Get the oldest key if(setKeyPool.empty()) return; CWalletDB walletdb(strWalletFile); nIndex = *setKeyPool.begin(); setKeyPool.erase(nIndex); if (!walletdb.ReadPool(nIndex, keypool)) { throw std::runtime_error(std::string(__func__) + ": read failed"); } if (!HaveKey(keypool.vchPubKey.GetID())) { throw std::runtime_error(std::string(__func__) + ": unknown key in key pool"); } if (keypool.fInternal != fInternal) { throw std::runtime_error(std::string(__func__) + ": keypool entry misclassified"); } assert(keypool.vchPubKey.IsValid()); LogPrintf("keypool reserve %d\n", nIndex); } } void CWallet::KeepKey(int64_t nIndex) { // Remove from key pool if (fFileBacked) { CWalletDB walletdb(strWalletFile); walletdb.ErasePool(nIndex); nKeysLeftSinceAutoBackup = nWalletBackups ? nKeysLeftSinceAutoBackup - 1 : 0; } LogPrintf("keypool keep %d\n", nIndex); } void CWallet::ReturnKey(int64_t nIndex, bool fInternal) { // Return to key pool { LOCK(cs_wallet); if (fInternal) { setInternalKeyPool.insert(nIndex); } else { setExternalKeyPool.insert(nIndex); } } LogPrintf("keypool return %d\n", nIndex); } bool CWallet::GetKeyFromPool(CPubKey& result, bool fInternal) { int64_t nIndex = 0; CKeyPool keypool; { LOCK(cs_wallet); ReserveKeyFromKeyPool(nIndex, keypool, fInternal); if (nIndex == -1) { if (IsLocked(true)) return false; // TODO: implement keypool for all accouts? result = GenerateNewKey(0, fInternal); return true; } KeepKey(nIndex); result = keypool.vchPubKey; } return true; } static int64_t GetOldestKeyInPool(const std::set<int64_t>& setKeyPool, CWalletDB& walletdb) { CKeyPool keypool; int64_t nIndex = *(setKeyPool.begin()); if (!walletdb.ReadPool(nIndex, keypool)) { throw std::runtime_error(std::string(__func__) + ": read oldest key in keypool failed"); } assert(keypool.vchPubKey.IsValid()); return keypool.nTime; } int64_t CWallet::GetOldestKeyPoolTime() { LOCK(cs_wallet); // if the keypool is empty, return <NOW> if (setExternalKeyPool.empty() && setInternalKeyPool.empty()) return GetTime(); CWalletDB walletdb(strWalletFile); int64_t oldestKey = -1; // load oldest key from keypool, get time and return if (!setInternalKeyPool.empty()) { oldestKey = std::max(GetOldestKeyInPool(setInternalKeyPool, walletdb), oldestKey); } if (!setExternalKeyPool.empty()) { oldestKey = std::max(GetOldestKeyInPool(setExternalKeyPool, walletdb), oldestKey); } return oldestKey; } std::map<CTxDestination, CAmount> CWallet::GetAddressBalances() { map<CTxDestination, CAmount> balances; { LOCK(cs_wallet); BOOST_FOREACH(PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet) { CWalletTx *pcoin = &walletEntry.second; if (!CheckFinalTx(*pcoin) || !pcoin->IsTrusted()) continue; if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) continue; int nDepth = pcoin->GetDepthInMainChain(); if (nDepth < (pcoin->IsFromMe(ISMINE_ALL) ? 0 : 1)) continue; for (unsigned int i = 0; i < pcoin->vout.size(); i++) { CTxDestination addr; if (!IsMine(pcoin->vout[i])) continue; if(!ExtractDestination(pcoin->vout[i].scriptPubKey, addr)) continue; CAmount n = IsSpent(walletEntry.first, i) ? 0 : pcoin->vout[i].nValue; if (!balances.count(addr)) balances[addr] = 0; balances[addr] += n; } } } return balances; } set< set<CTxDestination> > CWallet::GetAddressGroupings() { AssertLockHeld(cs_wallet); // mapWallet set< set<CTxDestination> > groupings; set<CTxDestination> grouping; BOOST_FOREACH(PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet) { CWalletTx *pcoin = &walletEntry.second; if (pcoin->vin.size() > 0) { bool any_mine = false; // group all input addresses with each other BOOST_FOREACH(CTxIn txin, pcoin->vin) { CTxDestination address; if(!IsMine(txin)) /* If this input isn't mine, ignore it */ continue; if(!ExtractDestination(mapWallet[txin.prevout.hash].vout[txin.prevout.n].scriptPubKey, address)) continue; grouping.insert(address); any_mine = true; } // group change with input addresses if (any_mine) { BOOST_FOREACH(CTxOut txout, pcoin->vout) if (IsChange(txout)) { CTxDestination txoutAddr; if(!ExtractDestination(txout.scriptPubKey, txoutAddr)) continue; grouping.insert(txoutAddr); } } if (grouping.size() > 0) { groupings.insert(grouping); grouping.clear(); } } // group lone addrs by themselves for (unsigned int i = 0; i < pcoin->vout.size(); i++) if (IsMine(pcoin->vout[i])) { CTxDestination address; if(!ExtractDestination(pcoin->vout[i].scriptPubKey, address)) continue; grouping.insert(address); groupings.insert(grouping); grouping.clear(); } } set< set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses map< CTxDestination, set<CTxDestination>* > setmap; // map addresses to the unique group containing it BOOST_FOREACH(set<CTxDestination> grouping, groupings) { // make a set of all the groups hit by this new group set< set<CTxDestination>* > hits; map< CTxDestination, set<CTxDestination>* >::iterator it; BOOST_FOREACH(CTxDestination address, grouping) if ((it = setmap.find(address)) != setmap.end()) hits.insert((*it).second); // merge all hit groups into a new single group and delete old groups set<CTxDestination>* merged = new set<CTxDestination>(grouping); BOOST_FOREACH(set<CTxDestination>* hit, hits) { merged->insert(hit->begin(), hit->end()); uniqueGroupings.erase(hit); delete hit; } uniqueGroupings.insert(merged); // update setmap BOOST_FOREACH(CTxDestination element, *merged) setmap[element] = merged; } set< set<CTxDestination> > ret; BOOST_FOREACH(set<CTxDestination>* uniqueGrouping, uniqueGroupings) { ret.insert(*uniqueGrouping); delete uniqueGrouping; } return ret; } std::set<CTxDestination> CWallet::GetAccountAddresses(const std::string& strAccount) const { LOCK(cs_wallet); set<CTxDestination> result; BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, mapAddressBook) { const CTxDestination& address = item.first; const string& strName = item.second.name; if (strName == strAccount) result.insert(address); } return result; } bool CReserveKey::GetReservedKey(CPubKey& pubkey, bool fInternalIn) { if (nIndex == -1) { CKeyPool keypool; pwallet->ReserveKeyFromKeyPool(nIndex, keypool, fInternalIn); if (nIndex != -1) { vchPubKey = keypool.vchPubKey; } else { return false; } fInternal = keypool.fInternal; } assert(vchPubKey.IsValid()); pubkey = vchPubKey; return true; } void CReserveKey::KeepKey() { if (nIndex != -1) { pwallet->KeepKey(nIndex); } nIndex = -1; vchPubKey = CPubKey(); } void CReserveKey::ReturnKey() { if (nIndex != -1) { pwallet->ReturnKey(nIndex, fInternal); } nIndex = -1; vchPubKey = CPubKey(); } static void LoadReserveKeysToSet(std::set<CKeyID>& setAddress, const std::set<int64_t>& setKeyPool, CWalletDB& walletdb) { BOOST_FOREACH(const int64_t& id, setKeyPool) { CKeyPool keypool; if (!walletdb.ReadPool(id, keypool)) throw runtime_error("GetAllReserveKeyHashes(): read failed"); assert(keypool.vchPubKey.IsValid()); CKeyID keyID = keypool.vchPubKey.GetID(); setAddress.insert(keyID); } } void CWallet::GetAllReserveKeys(std::set<CKeyID>& setAddress) const { setAddress.clear(); CWalletDB walletdb(strWalletFile); LOCK2(cs_main, cs_wallet); LoadReserveKeysToSet(setAddress, setInternalKeyPool, walletdb); LoadReserveKeysToSet(setAddress, setExternalKeyPool, walletdb); BOOST_FOREACH (const CKeyID& keyID, setAddress) { if (!HaveKey(keyID)) { throw std::runtime_error(std::string(__func__) + ": unknown key in key pool"); } } } bool CWallet::UpdatedTransaction(const uint256 &hashTx) { { LOCK(cs_wallet); // Only notify UI if this transaction is in this wallet map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(hashTx); if (mi != mapWallet.end()){ NotifyTransactionChanged(this, hashTx, CT_UPDATED); return true; } } return false; } void CWallet::GetScriptForMining(boost::shared_ptr<CReserveScript> &script) { boost::shared_ptr<CReserveKey> rKey(new CReserveKey(this)); CPubKey pubkey; if (!rKey->GetReservedKey(pubkey, false)) return; script = rKey; script->reserveScript = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } void CWallet::LockCoin(COutPoint& output) { AssertLockHeld(cs_wallet); // setLockedCoins setLockedCoins.insert(output); std::map<uint256, CWalletTx>::iterator it = mapWallet.find(output.hash); if (it != mapWallet.end()) it->second.MarkDirty(); // recalculate all credits for this tx fAnonymizableTallyCached = false; fAnonymizableTallyCachedNonDenom = false; } void CWallet::UnlockCoin(COutPoint& output) { AssertLockHeld(cs_wallet); // setLockedCoins setLockedCoins.erase(output); std::map<uint256, CWalletTx>::iterator it = mapWallet.find(output.hash); if (it != mapWallet.end()) it->second.MarkDirty(); // recalculate all credits for this tx fAnonymizableTallyCached = false; fAnonymizableTallyCachedNonDenom = false; } void CWallet::UnlockAllCoins() { AssertLockHeld(cs_wallet); // setLockedCoins setLockedCoins.clear(); } bool CWallet::IsLockedCoin(uint256 hash, unsigned int n) const { AssertLockHeld(cs_wallet); // setLockedCoins COutPoint outpt(hash, n); return (setLockedCoins.count(outpt) > 0); } void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) { AssertLockHeld(cs_wallet); // setLockedCoins for (std::set<COutPoint>::iterator it = setLockedCoins.begin(); it != setLockedCoins.end(); it++) { COutPoint outpt = (*it); vOutpts.push_back(outpt); } } /** @} */ // end of Actions class CAffectedKeysVisitor : public boost::static_visitor<void> { private: const CKeyStore &keystore; std::vector<CKeyID> &vKeys; public: CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector<CKeyID> &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {} void Process(const CScript &script) { txnouttype type; std::vector<CTxDestination> vDest; int nRequired; if (ExtractDestinations(script, type, vDest, nRequired)) { BOOST_FOREACH(const CTxDestination &dest, vDest) boost::apply_visitor(*this, dest); } } void operator()(const CKeyID &keyId) { if (keystore.HaveKey(keyId)) vKeys.push_back(keyId); } void operator()(const CScriptID &scriptId) { CScript script; if (keystore.GetCScript(scriptId, script)) Process(script); } void operator()(const CNoDestination &none) {} }; void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const { AssertLockHeld(cs_wallet); // mapKeyMetadata mapKeyBirth.clear(); // get birth times for keys with metadata for (std::map<CKeyID, CKeyMetadata>::const_iterator it = mapKeyMetadata.begin(); it != mapKeyMetadata.end(); it++) if (it->second.nCreateTime) mapKeyBirth[it->first] = it->second.nCreateTime; // map in which we'll infer heights of other keys CBlockIndex *pindexMax = chainActive[std::max(0, chainActive.Height() - 144)]; // the tip can be reorganised; use a 144-block safety margin std::map<CKeyID, CBlockIndex*> mapKeyFirstBlock; std::set<CKeyID> setKeys; GetKeys(setKeys); BOOST_FOREACH(const CKeyID &keyid, setKeys) { if (mapKeyBirth.count(keyid) == 0) mapKeyFirstBlock[keyid] = pindexMax; } setKeys.clear(); // if there are no such keys, we're done if (mapKeyFirstBlock.empty()) return; // find first block that affects those keys, if there are any left std::vector<CKeyID> vAffected; for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); it++) { // iterate over all wallet transactions... const CWalletTx &wtx = (*it).second; BlockMap::const_iterator blit = mapBlockIndex.find(wtx.hashBlock); if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) { // ... which are already in a block int nHeight = blit->second->nHeight; BOOST_FOREACH(const CTxOut &txout, wtx.vout) { // iterate over all their outputs CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey); BOOST_FOREACH(const CKeyID &keyid, vAffected) { // ... and all their affected keys std::map<CKeyID, CBlockIndex*>::iterator rit = mapKeyFirstBlock.find(keyid); if (rit != mapKeyFirstBlock.end() && nHeight < rit->second->nHeight) rit->second = blit->second; } vAffected.clear(); } } } // Extract block timestamps for those keys for (std::map<CKeyID, CBlockIndex*>::const_iterator it = mapKeyFirstBlock.begin(); it != mapKeyFirstBlock.end(); it++) mapKeyBirth[it->first] = it->second->GetBlockTime() - 7200; // block times can be 2h off } bool CWallet::AddDestData(const CTxDestination &dest, const std::string &key, const std::string &value) { if (boost::get<CNoDestination>(&dest)) return false; mapAddressBook[dest].destdata.insert(std::make_pair(key, value)); if (!fFileBacked) return true; return CWalletDB(strWalletFile).WriteDestData(CBitcoinAddress(dest).ToString(), key, value); } bool CWallet::EraseDestData(const CTxDestination &dest, const std::string &key) { if (!mapAddressBook[dest].destdata.erase(key)) return false; if (!fFileBacked) return true; return CWalletDB(strWalletFile).EraseDestData(CBitcoinAddress(dest).ToString(), key); } bool CWallet::LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value) { mapAddressBook[dest].destdata.insert(std::make_pair(key, value)); return true; } bool CWallet::GetDestData(const CTxDestination &dest, const std::string &key, std::string *value) const { std::map<CTxDestination, CAddressBookData>::const_iterator i = mapAddressBook.find(dest); if(i != mapAddressBook.end()) { CAddressBookData::StringMap::const_iterator j = i->second.destdata.find(key); if(j != i->second.destdata.end()) { if(value) *value = j->second; return true; } } return false; } CKeyPool::CKeyPool() { nTime = GetTime(); fInternal = false; } CKeyPool::CKeyPool(const CPubKey& vchPubKeyIn, bool fInternalIn) { nTime = GetTime(); vchPubKey = vchPubKeyIn; fInternal = fInternalIn; } CWalletKey::CWalletKey(int64_t nExpires) { nTimeCreated = (nExpires ? GetTime() : 0); nTimeExpires = nExpires; } int CMerkleTx::SetMerkleBranch(const CBlock& block) { AssertLockHeld(cs_main); CBlock blockTmp; // Update the tx's hashBlock hashBlock = block.GetHash(); // Locate the transaction for (nIndex = 0; nIndex < (int)block.vtx.size(); nIndex++) if (block.vtx[nIndex] == *(CTransaction*)this) break; if (nIndex == (int)block.vtx.size()) { nIndex = -1; LogPrintf("ERROR: SetMerkleBranch(): couldn't find tx in block\n"); return 0; } // Is the tx in a block that's in the main chain BlockMap::iterator mi = mapBlockIndex.find(hashBlock); if (mi == mapBlockIndex.end()) return 0; const CBlockIndex* pindex = (*mi).second; if (!pindex || !chainActive.Contains(pindex)) return 0; return chainActive.Height() - pindex->nHeight + 1; } int CMerkleTx::GetDepthInMainChain(const CBlockIndex* &pindexRet, bool enableIX) const { int nResult; if (hashUnset()) nResult = 0; else { AssertLockHeld(cs_main); // Find the block it claims to be in BlockMap::iterator mi = mapBlockIndex.find(hashBlock); if (mi == mapBlockIndex.end()) nResult = 0; else { CBlockIndex* pindex = (*mi).second; if (!pindex || !chainActive.Contains(pindex)) nResult = 0; else { pindexRet = pindex; nResult = ((nIndex == -1) ? (-1) : 1) * (chainActive.Height() - pindex->nHeight + 1); if (nResult == 0 && !mempool.exists(GetHash())) return -1; // Not in chain, not in mempool } } } if(enableIX && nResult < 6 && instantsend.IsLockedInstantSendTransaction(GetHash())) return nInstantSendDepth + nResult; return nResult; } int CMerkleTx::GetBlocksToMaturity() const { if (!IsCoinBase()) return 0; return max(0, (COINBASE_MATURITY+1) - GetDepthInMainChain()); } bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree, bool fRejectAbsurdFee) { CValidationState state; return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL, false, fRejectAbsurdFee); }
4643085a9e682d5ff75d92035cbee819aa522174
64bf21e9b4ca104557d05dc90a70e9fc3c3544a4
/tests/pyre.lib/grid/order_access.cc
92adfa0b4a2977a2a5616d33282e33eed63919a0
[ "BSD-3-Clause" ]
permissive
pyre/pyre
e6341a96a532dac03f5710a046c3ebbb79c26395
d741c44ffb3e9e1f726bf492202ac8738bb4aa1c
refs/heads/main
2023-08-08T15:20:30.721308
2023-07-20T07:51:29
2023-07-20T07:51:29
59,451,598
27
13
BSD-3-Clause
2023-07-02T07:14:50
2016-05-23T04:17:24
Python
UTF-8
C++
false
false
1,310
cc
// -*- c++ -*- // // michael a.g. aïvázis <[email protected]> // (c) 1998-2023 all rights reserved // support #include <cassert> // get the grid #include <pyre/grid.h> // type alias using order_t = pyre::grid::order_t<4>; // exercise operator[] int main(int argc, char * argv[]) { // initialize the journal pyre::journal::init(argc, argv); pyre::journal::application("order_access"); // make a channel pyre::journal::debug_t channel("pyre.grid.order"); // make a constexpr index ordering constexpr order_t order_1 { 0, 1, 2, 3 }; // show me channel << "[0,1,2,3]: " << order_1 << pyre::journal::endl(__HERE__); // verify the contents are available at compile time static_assert(order_1[0] == 0); static_assert(order_1[1] == 1); static_assert(order_1[2] == 2); static_assert(order_1[3] == 3); // make a writable one order_t order_2 { 0, 0, 0, 0 }; // set it order_2[0] = 0; order_2[1] = 1; order_2[2] = 2; order_2[3] = 3; // show me channel << "[0,1,2,3]: " << order_2 << pyre::journal::endl(__HERE__); // check it assert((order_2[0] == 0)); assert((order_2[1] == 1)); assert((order_2[2] == 2)); assert((order_2[3] == 3)); // all done return 0; } // end of file
b5b13410c62c4b16824e9948fb5e8ed0f651ec65
3de461274828f91e7997298c496ffd5d49a15e51
/Beam/Include/Beam/ServiceLocator/CachedServiceLocatorDataStore.hpp
0c27cf1aae394c200b9b28964208d4c94ff4339c
[]
no_license
lineCode/beam
aaceffb36510d0e4551c81d67e9b5326bd3c0c94
8cd3d175118a9c9f17feb5ab272472de6ddc0327
refs/heads/master
2022-04-18T22:21:21.483345
2020-04-16T21:57:53
2020-04-16T21:57:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,175
hpp
#ifndef BEAM_CACHEDSERVICELOCATORDATASTORE_HPP #define BEAM_CACHEDSERVICELOCATORDATASTORE_HPP #include <unordered_set> #include "Beam/IO/OpenState.hpp" #include "Beam/Pointers/LocalPtr.hpp" #include "Beam/ServiceLocator/LocalServiceLocatorDataStore.hpp" #include "Beam/ServiceLocator/ServiceLocator.hpp" #include "Beam/ServiceLocator/ServiceLocatorDataStore.hpp" namespace Beam { namespace ServiceLocator { /*! \class CachedServiceLocatorDataStore \brief Caches all data from a ServiceLocatorDataStore. \tparam DataStoreType The type of ServiceLocatorDataStore to cache. */ template<typename DataStoreType> class CachedServiceLocatorDataStore : public ServiceLocatorDataStore { public: //! The type of ServiceLocatorDataStore to cache. using DataStore = GetTryDereferenceType<DataStoreType>; //! Constructs a CachedServiceLocatorDataStore. /*! \param dataStore The ServiceLocatorDataStore to cache. */ template<typename DataStoreForward> CachedServiceLocatorDataStore(DataStoreForward&& dataStore); virtual ~CachedServiceLocatorDataStore() override; virtual std::vector<DirectoryEntry> LoadParents( const DirectoryEntry& entry) override; virtual std::vector<DirectoryEntry> LoadChildren( const DirectoryEntry& directory) override; virtual DirectoryEntry LoadDirectoryEntry(unsigned int id) override; virtual std::vector<DirectoryEntry> LoadAllAccounts() override; virtual std::vector<DirectoryEntry> LoadAllDirectories() override; virtual DirectoryEntry LoadAccount(const std::string& name) override; virtual DirectoryEntry MakeAccount(const std::string& name, const std::string& password, const DirectoryEntry& parent, const boost::posix_time::ptime& registrationTime) override; virtual DirectoryEntry MakeDirectory(const std::string& name, const DirectoryEntry& parent) override; virtual void Delete(const DirectoryEntry& entry) override; virtual bool Associate(const DirectoryEntry& entry, const DirectoryEntry& parent) override; virtual bool Detach(const DirectoryEntry& entry, const DirectoryEntry& parent) override; virtual std::string LoadPassword(const DirectoryEntry& account) override; virtual void SetPassword(const DirectoryEntry& account, const std::string& password) override; virtual Permissions LoadPermissions(const DirectoryEntry& source, const DirectoryEntry& target) override; virtual std::vector<std::tuple<DirectoryEntry, Permissions>> LoadAllPermissions(const DirectoryEntry& account); virtual void SetPermissions(const DirectoryEntry& source, const DirectoryEntry& target, Permissions permissions) override; virtual boost::posix_time::ptime LoadRegistrationTime( const DirectoryEntry& account) override; virtual boost::posix_time::ptime LoadLastLoginTime( const DirectoryEntry& account) override; virtual void StoreLastLoginTime(const DirectoryEntry& account, const boost::posix_time::ptime& loginTime) override; virtual void Rename(const DirectoryEntry& entry, const std::string& name) override; virtual DirectoryEntry Validate(const DirectoryEntry& entry) override; virtual void WithTransaction( const std::function<void ()>& transaction) override; virtual void Open() override; virtual void Close() override; private: GetOptionalLocalPtr<DataStoreType> m_dataStore; std::unordered_set<unsigned int> m_unavailableEntries; LocalServiceLocatorDataStore m_cache; IO::OpenState m_openState; void Shutdown(); bool IsCached(const DirectoryEntry& entry); bool IsCached(unsigned int entry); }; template<typename DataStoreType> template<typename DataStoreForward> CachedServiceLocatorDataStore<DataStoreType>::CachedServiceLocatorDataStore( DataStoreForward&& dataStore) : m_dataStore{std::forward<DataStoreForward>(dataStore)} {} template<typename DataStoreType> CachedServiceLocatorDataStore<DataStoreType>:: ~CachedServiceLocatorDataStore() { Close(); } template<typename DataStoreType> std::vector<DirectoryEntry> CachedServiceLocatorDataStore<DataStoreType>:: LoadParents(const DirectoryEntry& entry) { if(IsCached(entry)) { return m_cache.LoadParents(entry); } return m_dataStore->LoadParents(entry); } template<typename DataStoreType> std::vector<DirectoryEntry> CachedServiceLocatorDataStore<DataStoreType>:: LoadChildren(const DirectoryEntry& directory) { if(IsCached(directory)) { return m_cache.LoadChildren(directory); } return m_dataStore->LoadChildren(directory); } template<typename DataStoreType> DirectoryEntry CachedServiceLocatorDataStore<DataStoreType>:: LoadDirectoryEntry(unsigned int id) { if(IsCached(id)) { return m_cache.LoadDirectoryEntry(id); } return m_dataStore->LoadDirectoryEntry(id); } template<typename DataStoreType> std::vector<DirectoryEntry> CachedServiceLocatorDataStore<DataStoreType>:: LoadAllAccounts() { if(m_unavailableEntries.empty()) { return m_cache.LoadAllAccounts(); } return m_dataStore->LoadAllAccounts(); } template<typename DataStoreType> std::vector<DirectoryEntry> CachedServiceLocatorDataStore<DataStoreType>:: LoadAllDirectories() { if(m_unavailableEntries.empty()) { return m_cache.LoadAllDirectories(); } return m_dataStore->LoadAllDirectories(); } template<typename DataStoreType> DirectoryEntry CachedServiceLocatorDataStore<DataStoreType>::LoadAccount( const std::string& name) { try { return m_cache.LoadAccount(name); } catch(const std::exception&) { return m_dataStore->LoadAccount(name); } } template<typename DataStoreType> DirectoryEntry CachedServiceLocatorDataStore<DataStoreType>::MakeAccount( const std::string& name, const std::string& password, const DirectoryEntry& parent, const boost::posix_time::ptime& registrationTime) { auto account = m_dataStore->MakeAccount(name, password, parent, registrationTime); try { auto cachedPassword = m_dataStore->LoadPassword(account); auto cachedRegistrationTime = m_dataStore->LoadRegistrationTime(account); auto cachedLoginTime = m_dataStore->LoadLastLoginTime(account); auto cachedParents = m_dataStore->LoadParents(account); auto cachedPermissions = m_dataStore->LoadAllPermissions(account); m_cache.Store(account, cachedPassword, cachedRegistrationTime, cachedLoginTime); for(auto& parent : cachedParents) { m_cache.Associate(account, parent); } for(auto& permissions : cachedPermissions) { m_cache.SetPermissions(account, std::get<0>(permissions), std::get<1>(permissions)); } } catch(const std::exception&) { m_unavailableEntries.insert(account.m_id); m_cache.Delete(account); } return account; } template<typename DataStoreType> DirectoryEntry CachedServiceLocatorDataStore<DataStoreType>::MakeDirectory( const std::string& name, const DirectoryEntry& parent) { auto directory = m_dataStore->MakeDirectory(name, parent); try { auto cachedParents = m_dataStore->LoadParents(directory); auto cachedChildren = m_dataStore->LoadChildren(directory); m_cache.Store(directory); for(auto& parent : cachedParents) { m_cache.Associate(directory, parent); } for(auto& child : cachedChildren) { m_cache.Associate(child, directory); } } catch(const std::exception&) { m_unavailableEntries.insert(directory.m_id); m_cache.Delete(directory); } return directory; } template<typename DataStoreType> void CachedServiceLocatorDataStore<DataStoreType>::Delete( const DirectoryEntry& entry) { m_dataStore->Delete(entry); try { m_cache.Delete(entry); m_unavailableEntries.erase(entry.m_id); } catch(const std::exception&) { m_unavailableEntries.insert(entry.m_id); } } template<typename DataStoreType> bool CachedServiceLocatorDataStore<DataStoreType>::Associate( const DirectoryEntry& entry, const DirectoryEntry& parent) { if(IsCached(entry) && IsCached(parent)) { if(m_dataStore->Associate(entry, parent)) { m_cache.Associate(entry, parent); return true; } return false; } m_unavailableEntries.insert(entry.m_id); m_unavailableEntries.insert(parent.m_id); return m_dataStore->Associate(entry, parent); } template<typename DataStoreType> bool CachedServiceLocatorDataStore<DataStoreType>::Detach( const DirectoryEntry& entry, const DirectoryEntry& parent) { if(IsCached(entry) && IsCached(parent)) { if(m_dataStore->Detach(entry, parent)) { m_cache.Detach(entry, parent); return true; } return false; } m_unavailableEntries.insert(entry.m_id); m_unavailableEntries.insert(parent.m_id); return m_dataStore->Detach(entry, parent); } template<typename DataStoreType> std::string CachedServiceLocatorDataStore<DataStoreType>::LoadPassword( const DirectoryEntry& account) { if(IsCached(account)) { return m_cache.LoadPassword(account); } return m_dataStore->LoadPassword(account); } template<typename DataStoreType> void CachedServiceLocatorDataStore<DataStoreType>::SetPassword( const DirectoryEntry& account, const std::string& password) { if(IsCached(account)) { m_dataStore->SetPassword(account, password); m_cache.SetPassword(account, password); } else { m_dataStore->SetPassword(account, password); } } template<typename DataStoreType> Permissions CachedServiceLocatorDataStore<DataStoreType>::LoadPermissions( const DirectoryEntry& source, const DirectoryEntry& target) { if(IsCached(source) && IsCached(target)) { return m_cache.LoadPermissions(source, target); } return m_dataStore->LoadPermissions(source, target); } template<typename DataStoreType> std::vector<std::tuple<DirectoryEntry, Permissions>> CachedServiceLocatorDataStore<DataStoreType>::LoadAllPermissions( const DirectoryEntry& account) { if(IsCached(account)) { return m_cache.LoadAllPermissions(account); } return m_dataStore->LoadAllPermissions(account); } template<typename DataStoreType> void CachedServiceLocatorDataStore<DataStoreType>::SetPermissions( const DirectoryEntry& source, const DirectoryEntry& target, Permissions permissions) { if(IsCached(source) && IsCached(target)) { m_dataStore->SetPermissions(source, target, permissions); m_cache.SetPermissions(source, target, permissions); } else { m_unavailableEntries.insert(source.m_id); m_unavailableEntries.insert(target.m_id); m_dataStore->SetPermissions(source, target, permissions); } } template<typename DataStoreType> boost::posix_time::ptime CachedServiceLocatorDataStore<DataStoreType>:: LoadRegistrationTime(const DirectoryEntry& account) { if(IsCached(account)) { return m_cache.LoadRegistrationTime(account); } return m_dataStore->LoadRegistrationTime(account); } template<typename DataStoreType> boost::posix_time::ptime CachedServiceLocatorDataStore<DataStoreType>:: LoadLastLoginTime(const DirectoryEntry& account) { if(IsCached(account)) { return m_cache.LoadLastLoginTime(account); } return m_dataStore->LoadLastLoginTime(account); } template<typename DataStoreType> void CachedServiceLocatorDataStore<DataStoreType>::StoreLastLoginTime( const DirectoryEntry& account, const boost::posix_time::ptime& loginTime) { if(IsCached(account)) { m_dataStore->StoreLastLoginTime(account, loginTime); m_cache.StoreLastLoginTime(account, loginTime); } else { m_dataStore->StoreLastLoginTime(account, loginTime); } } template<typename DataStoreType> void CachedServiceLocatorDataStore<DataStoreType>::Rename( const DirectoryEntry& entry, const std::string& name) { m_cache.Rename(entry, name); m_dataStore->Rename(entry, name); } template<typename DataStoreType> DirectoryEntry CachedServiceLocatorDataStore<DataStoreType>::Validate( const DirectoryEntry& entry) { if(IsCached(entry)) { return m_cache.Validate(entry); } return m_dataStore->Validate(entry); } template<typename DataStoreType> void CachedServiceLocatorDataStore<DataStoreType>::WithTransaction( const std::function<void ()>& transaction) { m_dataStore->WithTransaction( [&] { m_cache.WithTransaction(transaction); }); } template<typename DataStoreType> void CachedServiceLocatorDataStore<DataStoreType>::Open() { if(m_openState.SetOpening()) { return; } try { m_dataStore->Open(); m_cache.Open(); auto directories = m_dataStore->LoadAllDirectories(); for(auto& directory : directories) { m_cache.Store(directory); } for(auto& directory : directories) { auto parents = m_dataStore->LoadParents(directory); for(auto& parent : parents) { m_cache.Associate(directory, parent); } } auto accounts = m_dataStore->LoadAllAccounts(); for(auto& account : accounts) { auto password = m_dataStore->LoadPassword(account); auto registrationTime = m_dataStore->LoadRegistrationTime(account); auto lastLoginTime = m_dataStore->LoadLastLoginTime(account); m_cache.Store(account, password, registrationTime, lastLoginTime); auto parents = m_dataStore->LoadParents(account); for(auto& parent : parents) { m_cache.Associate(account, parent); } auto permissions = m_dataStore->LoadAllPermissions(account); for(auto& permission : permissions) { m_cache.SetPermissions(account, std::get<0>(permission), std::get<1>(permission)); } } } catch(const std::exception&) { m_openState.SetOpenFailure(); Shutdown(); } m_openState.SetOpen(); } template<typename DataStoreType> void CachedServiceLocatorDataStore<DataStoreType>::Close() { if(m_openState.SetClosing()) { return; } Shutdown(); } template<typename DataStoreType> void CachedServiceLocatorDataStore<DataStoreType>::Shutdown() { m_dataStore->Close(); m_cache.Close(); m_openState.SetClosed(); } template<typename DataStoreType> bool CachedServiceLocatorDataStore<DataStoreType>::IsCached( const DirectoryEntry& entry) { return IsCached(entry.m_id); } template<typename DataStoreType> bool CachedServiceLocatorDataStore<DataStoreType>::IsCached(unsigned int id) { if(m_unavailableEntries.find(id) == m_unavailableEntries.end()) { return true; } return false; } } } #endif
9e32c512c67213fc45adac38481d0aecd734fa8e
798b409c2262078dfe770960586160fc47434fae
/sandbox/sb_event.cpp
26af44d88b01c89ef8e86acd72ee6e034f85d4b5
[]
no_license
andryblack/sandbox
b53fe7b148901442d24d2bcfc411ddce531b7664
6fcffae0e00ecf31052c98d2437dbed242509438
refs/heads/master
2021-01-25T15:52:16.330633
2019-08-26T09:24:00
2019-08-26T09:24:00
2,220,342
5
8
null
2018-06-18T15:41:44
2011-08-17T07:10:54
C++
UTF-8
C++
false
false
703
cpp
#include "sb_event.h" namespace Sandbox { static const sb::string empty_string; void Event::SetString(const sb::string& key,const sb::string& val) { m_strings[key] = val; } const sb::string& Event::GetString(const sb::string& key) const { sb::map<sb::string, sb::string>::const_iterator it = m_strings.find(key); return it == m_strings.end() ? empty_string : it->second; } void Event::SetInt(const sb::string& key,int v) { m_ints[key] = v; } int Event::GetInt(const sb::string& key) const { sb::map<sb::string, int>::const_iterator it = m_ints.find(key); return it == m_ints.end() ? 0 : it->second; } }
01ccc67b40cf52972b54c432350da3cc4a781a22
4ed6886a816c528f46bf3e1ae06729aed2404a81
/service/openproj/workers/scm/remote_repository_job.h
c2a6f3e8b79f6be76a2f872ae9bbc6a4cc83abaf
[]
no_license
kapilpipaliya/todo_drogon_server
0931cc5f9e2a6777c3dc306c0803ad3a2e0f0d28
86e46371785e25a085518232d95f86b880c526c0
refs/heads/caf
2020-09-04T04:05:56.364929
2019-11-05T03:09:43
2019-11-05T03:09:43
219,647,048
3
1
null
2019-11-05T03:14:45
2019-11-05T03:10:39
C++
UTF-8
C++
false
false
3,143
h
#pragma once #include "../application_job.h" #include "caf/all.hpp" // // Provides an asynchronous job to create a managed repository on the filesystem. // Currently, this is run synchronously due to potential issues // with error handling. // We envision a repository management wrapper that covers transactional // creation and deletion of repositories BOTH on the database and filesystem. // Until then, a synchronous process is more failsafe. //#include "net/http" namespace openproj { namespace worker { namespace Scm { class RemoteRepositoryJob: public caf::event_based_actor, public ApplicationJob { public: // attr_reader :repository // // Initialize the job, optionally saving the whole repository object // (use only when not serializing the job.) // As we"re using the jobs majorly synchronously for the time being, it saves a db trip. // When we have error handling for asynchronous tasks, refactor this. // RemoteRepositoryJob(repository, perform_now: false) { // if ( perform_now) { // this->repository = repository // else // this->repository_id = repository.id // } // } protected: // // Submits the request to the configured managed remote as JSON. // void send_request(request) { // uri = repository.class.managed_remote // req = ::Net::HTTP::Post.new(uri, "Content-Type" => "application/json") // req.body = request.to_json // http = Net::HTTP.new(uri.host, uri.port) // http.use_ssl = uri.scheme == "https" // http.verify_mode = configured_verification // response = http.request(req) // info = try_to_parse_response(response.body) // unless response.is_a? ::Net::HTTPSuccess // raise OpenProject::Scm::Exceptions::ScmError.new( // I18n.t("repositories.errors.remote_call_failed", // code: response.code, // message: info["message"] // ) // ) // } // info // } // void try_to_parse_response(body) { // JSON.parse(body) // rescue JSON::JSONError => e // raise OpenProject::Scm::Exceptions::ScmError.new( // I18n.t("repositories.errors.remote_invalid_response") // ) // } void repository_request() { // project = repository.project // { // token: repository.scm.config[:access_token], // identifier: repository.repository_identifier, // vendor: repository.vendor, // scm_type: repository.scm_type, // project: { // id: project.id, // name: project.name, // identifier: project.identifier, // } // } } void repository() { // this->repository ||= Repository.find(this->repository_id) } // // For packager and snakeoil-ssl certificates, we need to provide the user // with an option to skip SSL certificate verification when communicating // with the remote repository manager. // It may be overridden in the +configuration.yml+. void configured_verification() { // insecure = repository.class.scm_config[:insecure] // if ( insecure) { // OpenSSL::SSL::VERIFY_NONE // else // OpenSSL::SSL::VERIFY_PEER // } } }; } } }
2d890fbd255ebe95bffb656b28504634474e8dae
8356f9a6385545e067cbee101c1150dd593b0f60
/Granita/newexpression.h
630a92b78f16dd81ab6fbd5b6d2f08c43c44d304
[]
no_license
EnriqueUR/Compiladores_Granita
eb578730bee65b85b068fff3f4b3d712ca3926ed
33190da89d35ecbef6b6ff8b593bb1bd4672e937
refs/heads/master
2021-01-19T07:25:04.503615
2013-09-24T15:53:19
2013-09-24T15:53:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
211
h
#ifndef NEWEXPRESSION_H #define NEWEXPRESSION_H #include <iostream> using namespace std; class newExpression { public: enum Type {BOOL,INT}; newExpression(); Type tipo; }; #endif // NEWEXPRESSION_H
c1af2d8603cfad8b31e951ed383059f804aeeb28
8f60a3f7e910043a30d95b9103646ec3cb4fc3b7
/ all-my-projects/Архив/Кинжал/firmware/main.cpp
b0e73837dbe5f852de4adb84d32ae7309aaac95c
[]
no_license
Tokifuko/all-my-projects
bf039b649244652e216edaf006cb7e23f0d627e8
b339be47bfdffe5eda4d3689a56aab6f34234ba5
refs/heads/master
2021-01-18T17:17:26.255173
2015-02-14T18:01:13
2015-02-14T18:01:13
34,383,802
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
14,814
cpp
/***************************************************** This program was produced by the CodeWizardAVR V2.03.4 Standard Automatic Program Generator © Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com Project : ATt24_proj Version : 1 Date : 09.01.2009 Author : Company : Comments: Chip type : ATtiny24 Clock frequency : 7,378000 MHz Memory model : Tiny External RAM size : 0 Data Stack size : 32 *****************************************************/ #include <iotiny24.h> #include <intrinsics.h> // error коды #define BAD_MODE 1 #define NO_INPUT_CAPTURE 2 #define BAD_CAP_SENS_STEP 3 #define LED_PWM OCR0B #define MAX_LED_PWM 0x90 // чтоб не перегружать севшие батарейки #define LED_SPEED 512 #define NOMINAL_I 10000 #define I_SENS 50 #define SLEEP_DELAY 20000 // задержка между моментом замыкания гарды и переходом в спящий режим #define NOMINAL_CAP 10000 #define CAP_SENS 30 #define KEY_ON 1 #define KEY_OFF 2 #define LED_ON 3 #define LED_OFF 4 #define PA3 3 unsigned int adc_data; unsigned int delay_count; unsigned int i_sr_cap; unsigned char sleep; unsigned char mode; unsigned char error_code; unsigned char det_count; unsigned char cap_sens_step; unsigned char ch_AC_EN; unsigned char ch_SR_RUN; unsigned char INT0_FLAG; void led_driver(void); void power_down(void); void power_up(void) ; void deb(void); // External Interrupt 0 service routine //Прерывание про падающему фронту от кнопки ВКЛ/ВЫКЛ #pragma vector = INT0_vect __interrupt void INT0_vect_isr (void) { // GIMSK_INT0=0; // выключаем прерывание INT0. // __delay_cycles(32000); // PORTB_PORTB1=~PORTB_PORTB1; // sleep=0; power_up(); // GIMSK_INT0=1; // включаем прерывание по INT0 } // Timer 0 overflow interrupt service routine /*--------------------------------------------- Основное прерывание управляющее горением светодиодов переодически вызывает функцию меняющую яркость В зависимости от режимов прибавляет или выключает яркость ---------------------------------------------------***/ #pragma vector = TIM0_OVF_vect __interrupt void TIM0_OVF_vect_isr(void) { delay_count++; //OCR1A=adc_data; } /*----------------------------------------------------- В зависимости от режимов прибавляет или выключает яркость -------------------------------------------------------*/ void led_driver(void) { switch (mode) { case KEY_ON: // при включении кнопкой if (LED_PWM<MAX_LED_PWM) LED_PWM++; //- медленно зажигаем else { LED_PWM=0; //и резко гасим светодиод mode=LED_OFF; } break; case KEY_OFF: // при выключении кнопкой if (LED_PWM>0) LED_PWM--; // медленно гасим зазженые светодиоды else { power_down(); // и вырубаем питание mode=LED_ON; } break; case LED_ON: // режим включеных светодиодов if (adc_data<(NOMINAL_I-I_SENS)) LED_PWM++; // регулируем ток if (adc_data>(NOMINAL_I+I_SENS)) LED_PWM--; // в заданных пределах if (LED_PWM>MAX_LED_PWM) LED_PWM=0; // чтоб при нарастании не зашкиливал break; case LED_OFF: // режим выкл if (LED_PWM>0) LED_PWM--; // тихонька гасим все break; default : error_code=BAD_MODE; } if (LED_PWM==0) { TCCR0A_COM0B1 =0; TCCR0A_COM0B0=0; DDRA_DDA7=1; PORTA_PORTA7=1; } else { TCCR0A_COM0B1=1; TCCR0A_COM0B0=1; DDRA_DDA7=1; } } void power_down(void)// включаем режим сна; { { /* ADCSRA_ADEN=0; // выкл ADC ADMUX_REFS1=0; // выключаем внутренние опорное напряжение ADMUX_REFS0=1; ACSR_ACD=1; // выключаем компаратор // выкл таймер 0 TCCR0B_CS00=0; TCCR0B_CS01=0; TCCR0B_CS02=0; // выкл таймер 1 TCCR1B_CS10=0; TCCR1B_CS11=0; TCCR1B_CS12=0; */ MCUCR_ISC01=0; // The rising edge of INT0 generates an interrupt request. MCUCR_ISC00=0; GIMSK_INT0=1; // включаем прерывание по INT0 // Sleep Mode= MCUCR_SM0=0; MCUCR_SM1=1; MCUCR_SE=1; // Sleep Mode=ON; asm ("sleep"); } } void power_up(void)// Выходим из режима сна { // MCUCR_SE=0; // Sleep Mode=OFF; GIMSK_INT0=0; // выключаем прерывание по INT0 /* ADCSRA_ADEN=1; // вкл ADC ADMUX_REFS1=1; //вкл внутренние опорное напряжение ADMUX_REFS0=0; ACSR_ACD=0; // включаем компаратор // вкл таймер 0 TCCR0B_CS00=1; TCCR0B_CS01=0; TCCR0B_CS02=0; // вкл таймер 1 TCCR1B_CS10=1; TCCR1B_CS11=0; TCCR1B_CS12=0; */ LED_PWM=0xf0; __delay_cycles(32000); // LED_PWM=0; mode=KEY_ON; sleep=0; } /*--------------------------------------------- Основное прерывание, для измерения емкости. работает в 3 этапа. 1 - заряд конденсатора. 2- разряд конденсатора. Во время отрицательного перепада на компараторе должен автоматически сработать Analog Comparator Input Capture by Timer/Counter 1: On Велечина Input Capturе используется для подсчета емкости 3- пауза между измерениями в зависимости от режима выбирается прескаллер времени паузы --------------------------------------*/ #pragma vector = TIM1_OVF_vect __interrupt void TIM1_OVF_vect_isr(void) // Timer 1 overflow interrupt service routine { //PORTB_PORTB1=~PORTB_PORTB1; switch (cap_sens_step) { case 1: // зарядка емкости //TCCR1B=0x01; //максимальный CLK PORTA_PORTA3=1; // PA3 - выход DDRA_DDA3=1; // еденицу туда TIFR1_ICF1=0; // сбрасываем флаг Input Capture break; case 2 : // разряд емкости TIFR1_ICF1=0; // сбрасываем флаг Input Capture DDRA_DDA3 =0; // PORTB_PORTB1=0; // debug ch_AC_EN=1; break; case 3: // анализ измерений if (ch_AC_EN==1) // если не сработал компаратор вообще { ch_AC_EN=0; error_code=NO_INPUT_CAPTURE; } else ch_SR_RUN=1; // флаг разрешения вобработки результата. break; default: error_code=BAD_CAP_SENS_STEP; }; // тут переводим шаги if (cap_sens_step<3) cap_sens_step++; else cap_sens_step=1; } /*--------------------------------------------- Прерывание компаратора конечно можно воспользываватся системным флагом, но так надежнее... ch_AC_EN - ставится в 1 во время начала разряда конденсатора --------------------------------------*/ // Analog Comparator interrupt service routine #pragma vector = ANA_COMP_vect __interrupt void ANA_COMP_vect_isr(void) { // if (ch_AC_EN==0) return; // чтоб только один раз срабатывал // ch_SR_RUN=1; // флаг разрешения вычисления скользящего среднего. ch_AC_EN=0; // выключаем. теперь он сработает на шаге 2. } /*---------------------------------------------*/ /*--------------------------------------------- Прерывание сомпаратора таймера 1. Позволяет реально увидить среднее значение емкости. --------------------------------------*/ #pragma vector = TIM1_COMPA_vect __interrupt void TIM1_COMPA_vect_isr(void) { //PORTB_PORTB1=1; // для дебага } /*---------------------------------------------*/ #define ADC_VREF_TYPE 0x80 // ADC interrupt service routine #pragma vector = ADC_vect __interrupt void ADC_vect_isr(void) { // Read the AD conversion result adc_data=ADC; // Place your code here } void deb(void) { } void main(void) { // Declare your local variables here unsigned char mask; unsigned int x; unsigned char y; unsigned int sleep_count; // Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTA=0x00; DDRA=0x00; // Port B initialization // Func3=In Func2=Out Func1=In Func0=In // State3=T State2=0 State1=T State0=T PORTB=0x00; DDRB=0x00; DDRB_DDB1=1; PORTB_PORTB1=0; DDRB_DDB2=0; // KEY - как вход PORTB_PORTB2=1; // и пулап вкл error_code=0; // Crystal Oscillator division factor: 1 i_sr_cap=0x7FFF; CLKPR=0x80; CLKPR=0x00; WDTCSR=0x00; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: 7378,000 kHz // Mode: Fast PWM top=FFh // OC0A output: Disconnected // OC0B output:Non-Inverted PWM TCCR0A=0x33; TCCR0B=0x01; // clock clkI/O/(No prescaling) TCNT0=0x00; OCR0A=0x00; OCR0B=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: 7378,000 kHz // Mode: Normal top=FFFFh // OC1A output: Discon. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer 1 Overflow Interrupt: On // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off TCCR1A=0x00; TCCR1B=0x01; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; TCCR1B_ICES1=1; // External Interrupt(s) initialization // INT0: On // INT0 Mode: Falling Edge // Interrupt on any change on pins PCINT0-7: Off // Interrupt on any change on pins PCINT8-11: Off MCUCR=0x00; GIMSK=0; //GIMSK=0x40; //GIMSK_INT0=1; // выкл ИНТ0 //GIMSK_PCIE0=1; // включаем прерывание по пинам 0. GIFR=0x40; //GIFR_PCIF0=1; // и эту херню тоже надо ставить PCMSK1=0x00; PCMSK0=0x00; //PCMSK0_PCINT0=1; // Используем пин PCINT0 // Timer/Counter 0 Interrupt(s) initialization TIMSK0_TOIE0=1; // Timer/Counter 1 Interrupt(s) initialization TIMSK1_TOIE1=1; TIMSK1_OCIE1A=1; // Universal Serial Interface initialization // Mode: Disabled // Clock source: Register & Counter=no clk. // USI Counter Overflow Interrupt: Off USICR=0x00; // Analog Comparator initialization // Analog Comparator: On // Digital input buffers on AIN0: Off, AIN1: Off DIDR0=0x03; // Interrupt on RISE Output Edge // Analog Comparator Input Capture by Timer/Counter 1: On ACSR=0x0F; ADCSRB=0x00; ACSR_ACIC=1; // ADC initialization // ADC Clock frequency: 922,250 kHz // ADC Voltage Reference: 1.1V, AREF discon. // ADC Bipolar Input Mode: Off // ADC Auto Trigger Source: None // Digital input buffers on ADC0: On, ADC1: Off, ADC2: Off, ADC3: Off // ADC4: Off, ADC5: Off, ADC6: Off, ADC7: Off DIDR0=0xFF; ADMUX=0x80;//ADC_VREF_TYPE & 0xff; ADCSRA=0x8B; ADCSRB&=0x70; ADCSRB|=0x10; // Global enable interrupts SREG_I=1; //MCUCR_PUD=1; //all pull up desable mode=LED_ON; i_sr_cap=0; while (1) { ADCSRA_ADSC=1; // старт ADC DDRA_DDA7=1; //DDRB_DDB1=1; //PORTB_PORTB1=sleep; if ((ch_SR_RUN==1) & (sleep==0)) { x=ICR1; // вычисление типа скользящего среднего if (x<i_sr_cap) i_sr_cap-=(i_sr_cap-x)/32; else i_sr_cap+=(x-i_sr_cap)/32; if (i_sr_cap>(NOMINAL_CAP+CAP_SENS)) mode=LED_ON; if (i_sr_cap<(NOMINAL_CAP-CAP_SENS)) mode=LED_OFF; ch_SR_RUN=0; //OCR1A=i_sr_cap; // if (i_sr_cap>1000) PORTB_PORTB1=1; // else PORTB_PORTB1=0; } PORTB_PORTB0=1; // опорное напряжение для компаратора. DDRB_DDB0=1; // управление светодиодами в свободное время if (delay_count>LED_SPEED) { // GIMSK=0; // GIMSK_INT0=0; delay_count=0; led_driver(); //PORTB_PORTB1=~PORTB_PORTB1; //OCR1A=adc_data; } // Считаем таймаут при переходе в спящий режим ( если гарда замкнута на яблоко) if (PINB_PINB2==0) sleep_count++; else sleep_count=0; if (sleep==1) sleep_count=0; if (sleep_count>SLEEP_DELAY) { LED_PWM=MAX_LED_PWM; mode=KEY_OFF; sleep=1; } } }
[ "chezare.manchini@25eb2cad-c9ff-7559-3d04-345b20404641" ]
chezare.manchini@25eb2cad-c9ff-7559-3d04-345b20404641
bd16ad5245629f2894134475a0c22f314b07d51d
4c39ed31fe1268302952bbe5c2cd456c8083281e
/GCJ/09/Qual/B.cpp
acb40e03c7c159afe76129da8154ac13d2e37d51
[]
no_license
Abhay4/Algorithm
37e3b8bd3c9990b896d862f1aa20ad8312f20e75
50b157e027c7f0c085a8a15929422e75851fafc4
refs/heads/master
2020-12-11T01:37:58.200719
2018-01-24T18:24:05
2018-01-24T18:24:05
38,934,843
0
0
null
2015-07-11T17:46:17
2015-07-11T17:46:17
null
UTF-8
C++
false
false
1,770
cpp
#include <iostream> #include <string> #include <map> #include <vector> #include <iterator> #include <algorithm> using namespace std; #define REP(i,n) for(int i=0;i<(n);++i) #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define MAXH 100 #define MAXW 100 int T, H, W; int mat[MAXH + 5][MAXW + 5]; int mm[MAXH + 5][MAXW + 5]; int dir[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}}; char dd[27]; void run() { cin >> H >> W; REP(i,H) { REP(j,W) { cin >> mat[i][j]; } } REP(i,27) dd[i] = '*'; memset(mm, -1, sizeof(mm)); int num = 1; REP(i,H) { REP(j,W) { if (mm[i][j] != -1) continue; vector<pair<int, int> > q; q.push_back(make_pair(i, j)); int ci = i, cj = j; while (true) { int idx = -1, low; REP(d,4) { int ti = ci + dir[d][0], tj = cj + dir[d][1]; if (ti < 0 || ti >= H || tj < 0 || tj >= W) continue; if (mat[ti][tj] >= mat[ci][cj]) continue; if (idx == -1) { idx = d; low = mat[ti][tj]; } else if (mat[ti][tj] < low) { idx = d; low = mat[ti][tj]; } } if (idx == -1) { REP(qi,q.size()) { mm[q[qi].first][q[qi].second] = num; } ++num; break; } int ni = ci + dir[idx][0], nj = cj + dir[idx][1]; if (mm[ni][nj] == -1) { q.push_back(make_pair(ni, nj)); ci = ni, cj = nj; } else { REP(qi,q.size()) { mm[q[qi].first][q[qi].second] = mm[ni][nj]; } break; } } } } char ch = 'a'; REP(i,H) { REP(j,W) { int n = mm[i][j]; if (dd[n] == '*') { dd[n] = ch; ++ch; } } } REP(i,H) { REP(j,W) { if (j) cout << " "; cout << dd[mm[i][j]]; } cout << endl; } } int main() { cin >> T; REP(t,T) { cout << "Case #" << t + 1 << ":" << endl; run(); } return 0; }
03d6ebab2dabcfab987818d13eb5c7f57ff02acd
1867e7945c5b10f556bccd39019364bbf2ced58c
/src/workqueue.hpp
052228efc0beee7ebc5fdfe3e75eb30559d014cd
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
ExpLife0011/qgrep
069f381b27dcc8d5f50dc238596a997b69ab9803
68aff6ccb91321d07cd65a13b79b436b549003d7
refs/heads/master
2020-03-17T03:34:08.501879
2018-05-10T04:58:04
2018-05-10T04:58:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
413
hpp
#pragma once #include <vector> #include <thread> #include <functional> #include "blockingqueue.hpp" class WorkQueue { public: static unsigned int getIdealWorkerCount(); WorkQueue(size_t workerCount, size_t memoryLimit); ~WorkQueue(); void push(std::function<void()> fun, size_t size = 0); private: BlockingQueue<std::function<void()>> queue; std::vector<std::thread> workers; };
659faaccf0b9d492d85d3e21b60c56586aabd269
d0be9a869d4631c58d09ad538b0908554d204e1c
/utf8/lib/client/vengine/src/game/object/fakesystem.cc
ac6a791130b6f7486894a63c783fb782e839c980
[]
no_license
World3D/pap
19ec5610393e429995f9e9b9eb8628fa597be80b
de797075062ba53037c1f68cd80ee6ab3ed55cbe
refs/heads/master
2021-05-27T08:53:38.964500
2014-07-24T08:10:40
2014-07-24T08:10:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
330
cc
#include "vengine/game/object/fakesystem.h" namespace vengine_game { namespace object { VENGINE_KERNEL_IMPLEMENT_VIRTUAL_DYNAMIC( vengine_game::object::FakeSystem, VENGINE_KERNEL_GETCLASS(vengine_kernel::Node, vengine_kernel_Node), vengine_game_object_FakeSystem); } //namespace object } //namespace vengine_game
79f72a0264e7c888820304c191dea312168bda84
f5406c082a9c80cf61ce4ab2992dc11953e1bd9f
/src/main.cpp
711275fb4028dd21ab3ee0e1af5b34110bc9da2c
[ "MIT" ]
permissive
PGZXB/PGJson
5805a4ed421cb8dba69c2b07fde8c6932a5f7c71
248a837d53f0d0dfd69dded3e8e49f8d60f7e122
refs/heads/master
2023-03-20T10:56:38.396017
2021-03-08T13:27:50
2021-03-08T13:27:50
345,839,483
4
0
null
null
null
null
UTF-8
C++
false
false
823
cpp
// // Created by 42025 on 2021/2/26. // #include <PGJson/Node.h> #include <PGJson/StringReadStream.h> #include <PGJson/Document.h> #include <algorithm> #include <iostream> using namespace pg::base::json; int main () { StringReadStream fileStream( "{\n" " \"sites\": [\n" " {\"name\" : \"ZhanSan\", \"age\" : 18, \"Len\" : 19.24},\n" " { \"name\":\"cainiao\" , \"url\": [\"www.runoob.com\", \"www.pp.com\"] },\n" " { \"name\":\"google\" , \"url\":\"www.google.com\" },\n" " ],\n" " \"msg\" : \"I\\tam\\tyour\\tteacher\"\n" "}\n", true ); Document document; document.parse(fileStream); std::cout << document.d().toDebugString() << "\n"; std::string json = document.stringify(); std::cout << json << "\n"; return 0; }
65b92333951de6d8d238a101c28e0eec67ae7af0
4cb935ddcf3bbf0842a51cdef8ceaaeacbc4a57a
/15684.cpp
92802aef0564a02a6a5874c7163320bea064ef9d
[]
no_license
20143104/boj
75facf8d137633709f31f9b55a3199111cf07deb
366e66bc4057ef2a79e640b05aeaae1494daaad1
refs/heads/master
2020-03-25T07:55:11.298992
2019-08-08T08:51:39
2019-08-08T08:51:39
140,717,689
0
0
null
null
null
null
UTF-8
C++
false
false
2,465
cpp
#include <iostream> #include <vector> #include <memory.h> using namespace std; int N, M, H, cnt = 1; int map[31][31], visit[31][31], tmp[31][31]; struct pos{ int x, y; pos(int _x, int _y){ x = _x; y = _y; } }; vector<pos> v; void print(){ for(int i=1; i<=H; i++){ for(int k=1; k<=N; k++){ cout << map[i][k] << " "; } cout << endl; } } void reset_map(){ for(int i=1; i<=H; i++){ for(int k=1; k<=N; k++){ map[i][k] = tmp[i][k]; } } } int see(pos p){ memset(visit, 0, sizeof(visit)); int x = p.x; int y = p.y; while(1){ // cout << x << " " << y << endl; visit[x][y] = 1; if(x == H+1) return y; if(x<=H && y<=N){ if(map[x][y] == 1 && visit[x][y+1] == 0) y+=1; else if(y-1>=1 && map[x][y-1] == 1 && visit[x][y-1] == 0) y-=1; else x+=1; } else return 0; } } int solve(){ for(int i=1; i<=N; i++){ if(see(pos(1, i)) == i) continue; else { return 0; } } return 1; } int func(){ if(solve()) return 0; for(int i=0; i<v.size(); i++){ reset_map(); map[v[i].x][v[i].y] = 1; if(solve()) return 1; } for(int i=0; i<v.size(); i++){ for(int k=i+1; k<v.size(); k++){ reset_map(); map[v[i].x][v[i].y] = 1; map[v[k].x][v[k].y] = 1; if(solve()) return 2; } } for(int i=1; i<v.size(); i++){ for(int j=i+1; j<v.size(); j++){ for(int k=j+1; k<v.size(); k++){ reset_map(); map[v[i].x][v[i].y] = 1; map[v[j].x][v[j].y] = 1; map[v[k].x][v[k].y] = 1; if(solve()) return 3; } } } return -1; } int main() { cin >> N >> M >> H; for(int i=0; i<M; i++){ int a, b; cin >> a >> b; map[a][b] = 1; tmp[a][b] = 1; } for(int i=1; i<=H; i++){ for(int k=1; k<=N; k++){ if(map[i][k] == 0) v.push_back(pos(i, k)); } } // print(); // map[] cout << func(); // print(); // for(int i=1; i<=M; i++) // cout << see(pos(1, i)) << endl; }
3713aaf16f93f064720262a626e7b8af1303391d
bb7645bab64acc5bc93429a6cdf43e1638237980
/Official Windows Platform Sample/Windows 8.1 Store app samples/99866-Windows 8.1 Store app samples/DatagramSocket sample/C++/Shared/Scenario2.xaml.cpp
028e1516d3612dd4f7dd8283105c95ede9098752
[ "MIT" ]
permissive
Violet26/msdn-code-gallery-microsoft
3b1d9cfb494dc06b0bd3d509b6b4762eae2e2312
df0f5129fa839a6de8f0f7f7397a8b290c60ffbb
refs/heads/master
2020-12-02T02:00:48.716941
2020-01-05T22:39:02
2020-01-05T22:39:02
230,851,047
1
0
MIT
2019-12-30T05:06:00
2019-12-30T05:05:59
null
UTF-8
C++
false
false
7,301
cpp
//********************************************************* // // Copyright (c) Microsoft. All rights reserved. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. // //********************************************************* // // Scenario2.xaml.cpp // Implementation of the Scenario2 class // #include "pch.h" #include "Scenario2.xaml.h" using namespace SDKSample; using namespace SDKSample::DatagramSocketSample; using namespace Concurrency; using namespace Platform; using namespace Windows::ApplicationModel::Core; using namespace Windows::Foundation; using namespace Windows::Networking; using namespace Windows::Networking::Sockets; using namespace Windows::Storage::Streams; using namespace Windows::UI::Core; using namespace Windows::UI::Xaml; using namespace Windows::UI::Xaml::Controls; using namespace Windows::UI::Xaml::Navigation; Scenario2::Scenario2() { InitializeComponent(); } /// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> void Scenario2::OnNavigatedTo(NavigationEventArgs^ e) { // A pointer back to the main page. This is needed if you want to call methods in MainPage such // as NotifyUser() rootPage = MainPage::Current; if (CoreApplication::Properties->HasKey("serverAddress")) { Object^ serverAddressObject = CoreApplication::Properties->Lookup("serverAddress"); String^ serverAddress = dynamic_cast<String^>(serverAddressObject); if (serverAddress) { HostNameForConnect->Text = serverAddress; } } } void Scenario2::ConnectSocket_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { if (ServiceNameForConnect->Text == nullptr) { rootPage->NotifyUser("Please provide a service name.", NotifyType::ErrorMessage); return; } // By default 'HostNameForConnect' is disabled and host name validation is not required. When enabling the text // box validating the host name is required since it was received from an untrusted source (user input). // Note that when enabling the text box users may provide names for hosts on the intErnet that require the // "Internet (Client)" capability. HostName^ hostName; try { hostName = ref new HostName(HostNameForConnect->Text); } catch (InvalidArgumentException^ e) { rootPage->NotifyUser("Error: Invalid host name.", NotifyType::ErrorMessage); return; } if (CoreApplication::Properties->HasKey("clientSocket")) { rootPage->NotifyUser( "This step has already been executed. Please move to the next one.", NotifyType::ErrorMessage); return; } DatagramSocket^ socket = ref new DatagramSocket(); if (DontFragment->IsOn) { // Set the IP DF (Don't Fragment) flag. // This won't have any effect when running both client and server on localhost. socket->Control->DontFragment = true; } SocketContext^ socketContext = ref new SocketContext(rootPage, socket); socket->MessageReceived += ref new TypedEventHandler<DatagramSocket^, DatagramSocketMessageReceivedEventArgs^>( socketContext, &SocketContext::OnMessage); // Events cannot be hooked up directly to the ScenarioInput2 object, as the object can fall out-of-scope and be // deleted. This would render any event hooked up to the object ineffective. The SocketContext guarantees that // both the socket and object that serves it's events have the same life time. CoreApplication::Properties->Insert("clientSocket", socketContext); rootPage->NotifyUser("Connecting to: " + HostNameForConnect->Text, NotifyType::StatusMessage); // Connect to the server (in our case the listener we created in previous step). create_task(socket->ConnectAsync(hostName, ServiceNameForConnect->Text)).then( [this, socketContext] (task<void> previousTask) { try { // Try getting an exception. previousTask.get(); rootPage->NotifyUser("Connected", NotifyType::StatusMessage); socketContext->SetConnected(); } catch (Exception^ exception) { rootPage->NotifyUser("Connect failed with error: " + exception->Message, NotifyType::ErrorMessage); } }); } SocketContext::SocketContext(MainPage^ rootPage, DatagramSocket^ socket) { this->rootPage = rootPage; this->socket = socket; this->connected = false; } SocketContext::~SocketContext() { // The socket (data writer) can be closed in two ways: // - explicit: by using delete operator (the socket or the stream used by data writer is closed even if there // are outstanding references to the objects). // - implicit: by removing last reference to it (i.e. falling out-of-scope). // In this case this is the last reference to the socket and data writer so both will yield the same result. delete socket; socket = nullptr; if (writer != nullptr) { delete writer; writer = nullptr; } } void SocketContext::OnMessage(DatagramSocket^ socket, DatagramSocketMessageReceivedEventArgs^ eventArguments) { try { unsigned int stringLength = eventArguments->GetDataReader()->UnconsumedBufferLength; NotifyUserFromAsyncThread( "Receive data from remote peer: \"" + eventArguments->GetDataReader()->ReadString(stringLength) + "\"", NotifyType::StatusMessage); } catch (Exception^ exception) { SocketErrorStatus socketError = SocketError::GetStatus(exception->HResult); if (socketError == SocketErrorStatus::ConnectionResetByPeer) { // This error would indicate that a previous send operation resulted in an ICMP "Port Unreachable" message. NotifyUserFromAsyncThread( "Peer does not listen on the specific port. Please make sure that you run step 1 first " + "or you have a server properly working on a remote server.", NotifyType::ErrorMessage); } else if (socketError != SocketErrorStatus::Unknown) { NotifyUserFromAsyncThread( "Error happened when receiving a datagram: " + socketError.ToString(), NotifyType::ErrorMessage); } else { throw; } } } DataWriter^ SocketContext::GetWriter() { if (writer == nullptr) { writer = ref new DataWriter(socket->OutputStream); } return writer; } boolean SocketContext::IsConnected() { return connected; } void SocketContext::SetConnected() { connected = true; } void SocketContext::NotifyUserFromAsyncThread(String^ message, NotifyType type) { rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, message, type] () { rootPage->NotifyUser(message, type); })); }
42a0fde1e4558fa12e84fc3b5a03970a93c92c73
b7f3edb5b7c62174bed808079c3b21fb9ea51d52
/components/password_manager/core/browser/leak_detection/leak_detection_check.h
6a3a3cd187e89a39840f584a9e7f91f938053111
[ "BSD-3-Clause" ]
permissive
otcshare/chromium-src
26a7372773b53b236784c51677c566dc0ad839e4
64bee65c921db7e78e25d08f1e98da2668b57be5
refs/heads/webml
2023-03-21T03:20:15.377034
2020-11-16T01:40:14
2020-11-16T01:40:14
209,262,645
18
21
BSD-3-Clause
2023-03-23T06:20:07
2019-09-18T08:52:07
null
UTF-8
C++
false
false
1,413
h
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_LEAK_DETECTION_CHECK_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_LEAK_DETECTION_CHECK_H_ #include "base/strings/string16.h" #include "url/gurl.h" namespace password_manager { // The base class for requests for checking if {username, password} pair was // leaked in the internet. class LeakDetectionCheck { public: LeakDetectionCheck() = default; virtual ~LeakDetectionCheck() = default; // Not copyable or movable LeakDetectionCheck(const LeakDetectionCheck&) = delete; LeakDetectionCheck& operator=(const LeakDetectionCheck&) = delete; LeakDetectionCheck(LeakDetectionCheck&&) = delete; LeakDetectionCheck& operator=(LeakDetectionCheck&&) = delete; // Starts checking |username| and |password| pair asynchronously. // |url| is used later for presentation in the UI but not for actual business // logic. The method should be called only once per lifetime of the object. virtual void Start(const GURL& url, base::string16 username, base::string16 password) = 0; }; } // namespace password_manager #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_LEAK_DETECTION_CHECK_H_
84254d4ef138ebcda61d3cb9434173cbb9a5e12c
34d148c4d26d0a70dcb0930a11cc3c8cc175ad21
/MyTask/LoadVirusLib.cpp
b4639b839f6a333df996dc87872cc7396523cd0c
[]
no_license
xiaoxingbobo/MyTask
fecf87a9409d193432a80a6afa07cba22fe5be23
ce0a0807a68fb6685e28cb4dd0a304f3dd2f1c5b
refs/heads/master
2023-05-28T18:25:43.779381
2021-06-17T03:01:05
2021-06-17T03:01:05
null
0
0
null
null
null
null
GB18030
C++
false
false
2,579
cpp
#include "stdafx.h" #include "LoadVirusLib.h" LoadVirusLib::LoadVirusLib() { } LoadVirusLib::~LoadVirusLib() { ClearVirusLibData(); } //读取本地病毒库 DWORD LoadVirusLib::LoadVirusLibData() { HANDLE pFile = nullptr; //打开本地这个.dat的病毒库文件 pFile = CreateFile(GetProgramDir()+ TEXT("VirusLib.dat"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (pFile == (HANDLE)-1)return 0; DWORD nSize = GetFileSize((PHANDLE)pFile, 0); DWORD nReadSize = 0; m_VirusCount = nSize / sizeof(VIRUSINFO); m_VirusLib = new VIRUSINFO[m_VirusCount]; ReadFile(pFile, (LPVOID)m_VirusLib, nSize, &nReadSize,NULL); CloseHandle(pFile); return m_VirusCount; } //取出病毒库信息 VOID LoadVirusLib::GetVirusLib(PVIRUSINFO &nVIRUSINFO) { memcpy_s(nVIRUSINFO, sizeof(VIRUSINFO)*m_VirusCount, m_VirusLib, sizeof(VIRUSINFO)*m_VirusCount); } //打开病毒库 VOID LoadVirusLib::SetVirusLib(PVIRUSINFO &nVIRUSINFO, DWORD nCount) { FILE *pFile = nullptr; fopen_s(&pFile, GetProgramDir() + "VirusLib.dat", "wb"); m_VirusCount = fwrite(nVIRUSINFO, sizeof(VIRUSINFO), nCount, pFile); fclose(pFile); } //关闭病毒库 VOID LoadVirusLib::ClearVirusLibData() { if (m_VirusLib !=nullptr) { delete[] m_VirusLib; } m_VirusLib = nullptr; m_VirusCount = 0; } //读取白名单 DWORD LoadVirusLib::LoadProcessLibData() { HANDLE pFile = nullptr; pFile = CreateFile(GetProgramDir() + TEXT("ProcessLib.dat"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (pFile == (HANDLE)-1)return 0; DWORD nSize = GetFileSize((PHANDLE)pFile, 0); DWORD nReadSize = 0; m_ProcessCount = nSize / sizeof(VIRUSINFO); m_ProcessLib = new VIRUSINFO[m_ProcessCount]; ReadFile(pFile, (LPVOID)m_ProcessLib, nSize, &nReadSize, NULL); CloseHandle(pFile); return m_ProcessCount; } //取出白名单信息 VOID LoadVirusLib::GetProcessLib(PVIRUSINFO &nVIRUSINFO) { memcpy_s(nVIRUSINFO, sizeof(VIRUSINFO)*m_ProcessCount, m_ProcessLib, sizeof(VIRUSINFO)*m_ProcessCount); } //添加进程至白名单 VOID LoadVirusLib::SetProcessLib(PVIRUSINFO &nVIRUSINFO, DWORD nCount) { //打开并写入ProcessLib序列化文件 FILE *pFile = nullptr; fopen_s(&pFile, GetProgramDir() + "ProcessLib.dat", "wb"); m_ProcessCount = fwrite(nVIRUSINFO, sizeof(VIRUSINFO), nCount, pFile); fclose(pFile); } //关闭白名单 VOID LoadVirusLib::ClearProcessLibData() { if (m_ProcessLib != nullptr) { delete[] m_ProcessLib; } m_ProcessLib = nullptr; m_ProcessCount = 0; }
ec2f349f7a0b9d40866d71e9fdd03c2b543c48c6
a2a49e6ec727fac1fd126c699c39a5328b6a6c44
/src/libraries/Volume/SyntheticVolume.cpp
5fd16930f77ff0ecd74ad8901180b21622e104f4
[]
no_license
shugraphics/VRVRVive
f3e9c7180916a3b9a98126b792f43c8b2b923c84
aefb6faf029069a4112aab36b544786e679e9d6e
refs/heads/master
2021-03-01T00:53:28.546284
2018-03-26T21:56:16
2018-03-26T21:56:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
28
cpp
#include "SyntheticVolume.h"
343f9eb2ac9a943d64f9ec59c3962372c037aba9
3b9b4049a8e7d38b49e07bb752780b2f1d792851
/src/net/nqe/network_quality_estimator_unittest.cc
40a28c55e53f7c6b7c6f6b608aa9dabc8df9d546
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
webosce/chromium53
f8e745e91363586aee9620c609aacf15b3261540
9171447efcf0bb393d41d1dc877c7c13c46d8e38
refs/heads/webosce
2020-03-26T23:08:14.416858
2018-08-23T08:35:17
2018-09-20T14:25:18
145,513,343
0
2
Apache-2.0
2019-08-21T22:44:55
2018-08-21T05:52:31
null
UTF-8
C++
false
false
74,569
cc
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "net/nqe/network_quality_estimator.h" #include <stddef.h> #include <stdint.h> #include <limits> #include <map> #include <memory> #include <string> #include <utility> #include <vector> #include "base/files/file_path.h" #include "base/logging.h" #include "base/macros.h" #include "base/metrics/histogram_samples.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/test/histogram_tester.h" #include "base/test/simple_test_tick_clock.h" #include "base/threading/platform_thread.h" #include "base/time/time.h" #include "build/build_config.h" #include "net/base/load_flags.h" #include "net/base/network_change_notifier.h" #include "net/http/http_status_code.h" #include "net/nqe/external_estimate_provider.h" #include "net/nqe/network_quality_observation.h" #include "net/nqe/network_quality_observation_source.h" #include "net/nqe/observation_buffer.h" #include "net/socket/socket_performance_watcher.h" #include "net/socket/socket_performance_watcher_factory.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_response.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" namespace net { namespace { // Helps in setting the current network type and id. class TestNetworkQualityEstimator : public NetworkQualityEstimator { public: TestNetworkQualityEstimator( const std::map<std::string, std::string>& variation_params, std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider) : TestNetworkQualityEstimator(std::move(external_estimate_provider), variation_params, true, true) {} TestNetworkQualityEstimator( std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider, const std::map<std::string, std::string>& variation_params, bool allow_local_host_requests_for_tests, bool allow_smaller_responses_for_tests) : NetworkQualityEstimator(std::move(external_estimate_provider), variation_params, allow_local_host_requests_for_tests, allow_smaller_responses_for_tests), effective_connection_type_set_(false), effective_connection_type_(EFFECTIVE_CONNECTION_TYPE_UNKNOWN), recent_effective_connection_type_set_(false), recent_effective_connection_type_(EFFECTIVE_CONNECTION_TYPE_UNKNOWN), current_network_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN), accuracy_recording_intervals_set_(false), http_rtt_set_(false), recent_http_rtt_set_(false), transport_rtt_set_(false), recent_transport_rtt_set_(false), downlink_throughput_kbps_set_(false), recent_downlink_throughput_kbps_set_(false) { // Set up embedded test server. embedded_test_server_.ServeFilesFromDirectory( base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); EXPECT_TRUE(embedded_test_server_.Start()); embedded_test_server_.RegisterRequestHandler(base::Bind( &TestNetworkQualityEstimator::HandleRequest, base::Unretained(this))); } explicit TestNetworkQualityEstimator( const std::map<std::string, std::string>& variation_params) : TestNetworkQualityEstimator( variation_params, std::unique_ptr<ExternalEstimateProvider>()) {} ~TestNetworkQualityEstimator() override {} // Overrides the current network type and id. // Notifies network quality estimator of change in connection. void SimulateNetworkChangeTo(NetworkChangeNotifier::ConnectionType type, const std::string& network_id) { current_network_type_ = type; current_network_id_ = network_id; OnConnectionTypeChanged(type); } // Called by embedded server when a HTTP request is received. std::unique_ptr<test_server::HttpResponse> HandleRequest( const test_server::HttpRequest& request) { std::unique_ptr<test_server::BasicHttpResponse> http_response( new test_server::BasicHttpResponse()); http_response->set_code(HTTP_OK); http_response->set_content("hello"); http_response->set_content_type("text/plain"); return std::move(http_response); } // Returns a GURL hosted at embedded test server. const GURL GetEchoURL() const { return embedded_test_server_.GetURL("/echo.html"); } void set_effective_connection_type(EffectiveConnectionType type) { effective_connection_type_set_ = true; effective_connection_type_ = type; } // Returns the effective connection type that was set using // |set_effective_connection_type|. If connection type has not been set, then // the base implementation is called. EffectiveConnectionType GetEffectiveConnectionType() const override { if (effective_connection_type_set_) return effective_connection_type_; return NetworkQualityEstimator::GetEffectiveConnectionType(); } void set_recent_effective_connection_type(EffectiveConnectionType type) { recent_effective_connection_type_set_ = true; recent_effective_connection_type_ = type; } // Returns the effective connection type that was set using // |set_effective_connection_type|. If connection type has not been set, then // the base implementation is called. EffectiveConnectionType GetRecentEffectiveConnectionType( const base::TimeTicks& start_time) const override { if (recent_effective_connection_type_set_) return recent_effective_connection_type_; return NetworkQualityEstimator::GetRecentEffectiveConnectionType( start_time); } void set_http_rtt(const base::TimeDelta& http_rtt) { http_rtt_set_ = true; http_rtt_ = http_rtt; } // Returns the HTTP RTT that was set using |set_http_rtt|. If the HTTP RTT has // not been set, then the base implementation is called. bool GetHttpRTTEstimate(base::TimeDelta* rtt) const override { if (http_rtt_set_) { *rtt = http_rtt_; return true; } return NetworkQualityEstimator::GetHttpRTTEstimate(rtt); } void set_recent_http_rtt(const base::TimeDelta& recent_http_rtt) { recent_http_rtt_set_ = true; recent_http_rtt_ = recent_http_rtt; } // Returns the recent HTTP RTT that was set using |set_recent_http_rtt|. If // the recent HTTP RTT has not been set, then the base implementation is // called. bool GetRecentHttpRTTMedian(const base::TimeTicks& start_time, base::TimeDelta* rtt) const override { if (recent_http_rtt_set_) { *rtt = recent_http_rtt_; return true; } return NetworkQualityEstimator::GetRecentHttpRTTMedian(start_time, rtt); } void set_transport_rtt(const base::TimeDelta& transport_rtt) { transport_rtt_set_ = true; transport_rtt_ = transport_rtt; } // Returns the transport RTT that was set using |set_transport_rtt|. If the // transport RTT has not been set, then the base implementation is called. bool GetTransportRTTEstimate(base::TimeDelta* rtt) const override { if (transport_rtt_set_) { *rtt = transport_rtt_; return true; } return NetworkQualityEstimator::GetTransportRTTEstimate(rtt); } void set_recent_transport_rtt(const base::TimeDelta& recent_transport_rtt) { recent_transport_rtt_set_ = true; recent_transport_rtt_ = recent_transport_rtt; } // Returns the recent transport RTT that was set using // |set_recent_transport_rtt|. If the recent transport RTT has not been set, // then the base implementation is called. bool GetRecentTransportRTTMedian(const base::TimeTicks& start_time, base::TimeDelta* rtt) const override { if (recent_transport_rtt_set_) { *rtt = recent_transport_rtt_; return true; } return NetworkQualityEstimator::GetRecentTransportRTTMedian(start_time, rtt); } void set_downlink_throughput_kbps(int32_t downlink_throughput_kbps) { downlink_throughput_kbps_set_ = true; downlink_throughput_kbps_ = downlink_throughput_kbps; } // Returns the downlink throughput that was set using // |set_downlink_throughput_kbps|. If the downlink throughput has not been // set, then the base implementation is called. bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const override { if (downlink_throughput_kbps_set_) { *kbps = downlink_throughput_kbps_; return true; } return NetworkQualityEstimator::GetDownlinkThroughputKbpsEstimate(kbps); } void set_recent_downlink_throughput_kbps( int32_t recent_downlink_throughput_kbps) { recent_downlink_throughput_kbps_set_ = true; recent_downlink_throughput_kbps_ = recent_downlink_throughput_kbps; } // Returns the downlink throughput that was set using // |set_recent_downlink_throughput_kbps|. If the downlink throughput has not // been set, then the base implementation is called. bool GetRecentMedianDownlinkThroughputKbps(const base::TimeTicks& start_time, int32_t* kbps) const override { if (recent_downlink_throughput_kbps_set_) { *kbps = recent_downlink_throughput_kbps_; return true; } return NetworkQualityEstimator::GetRecentMedianDownlinkThroughputKbps( start_time, kbps); } void SetAccuracyRecordingIntervals( const std::vector<base::TimeDelta>& accuracy_recording_intervals) { accuracy_recording_intervals_set_ = true; accuracy_recording_intervals_ = accuracy_recording_intervals; } const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() const override { if (accuracy_recording_intervals_set_) return accuracy_recording_intervals_; return NetworkQualityEstimator::GetAccuracyRecordingIntervals(); } using NetworkQualityEstimator::SetTickClockForTesting; using NetworkQualityEstimator::ReadCachedNetworkQualityEstimate; using NetworkQualityEstimator::OnConnectionTypeChanged; private: // NetworkQualityEstimator implementation that returns the overridden // network // id (instead of invoking platform APIs). NetworkQualityEstimator::NetworkID GetCurrentNetworkID() const override { return NetworkQualityEstimator::NetworkID(current_network_type_, current_network_id_); } bool effective_connection_type_set_; EffectiveConnectionType effective_connection_type_; bool recent_effective_connection_type_set_; EffectiveConnectionType recent_effective_connection_type_; NetworkChangeNotifier::ConnectionType current_network_type_; std::string current_network_id_; bool accuracy_recording_intervals_set_; std::vector<base::TimeDelta> accuracy_recording_intervals_; bool http_rtt_set_; base::TimeDelta http_rtt_; bool recent_http_rtt_set_; base::TimeDelta recent_http_rtt_; bool transport_rtt_set_; base::TimeDelta transport_rtt_; bool recent_transport_rtt_set_; base::TimeDelta recent_transport_rtt_; bool downlink_throughput_kbps_set_; int32_t downlink_throughput_kbps_; bool recent_downlink_throughput_kbps_set_; int32_t recent_downlink_throughput_kbps_; // Embedded server used for testing. EmbeddedTestServer embedded_test_server_; DISALLOW_COPY_AND_ASSIGN(TestNetworkQualityEstimator); }; class TestEffectiveConnectionTypeObserver : public NetworkQualityEstimator::EffectiveConnectionTypeObserver { public: std::vector<NetworkQualityEstimator::EffectiveConnectionType>& effective_connection_types() { return effective_connection_types_; } // EffectiveConnectionTypeObserver implementation: void OnEffectiveConnectionTypeChanged( NetworkQualityEstimator::EffectiveConnectionType type) override { effective_connection_types_.push_back(type); } private: std::vector<NetworkQualityEstimator::EffectiveConnectionType> effective_connection_types_; }; class TestRTTObserver : public NetworkQualityEstimator::RTTObserver { public: struct Observation { Observation(int32_t ms, const base::TimeTicks& ts, NetworkQualityObservationSource src) : rtt_ms(ms), timestamp(ts), source(src) {} int32_t rtt_ms; base::TimeTicks timestamp; NetworkQualityObservationSource source; }; std::vector<Observation>& observations() { return observations_; } // RttObserver implementation: void OnRTTObservation(int32_t rtt_ms, const base::TimeTicks& timestamp, NetworkQualityObservationSource source) override { observations_.push_back(Observation(rtt_ms, timestamp, source)); } private: std::vector<Observation> observations_; }; class TestThroughputObserver : public NetworkQualityEstimator::ThroughputObserver { public: struct Observation { Observation(int32_t kbps, const base::TimeTicks& ts, NetworkQualityObservationSource src) : throughput_kbps(kbps), timestamp(ts), source(src) {} int32_t throughput_kbps; base::TimeTicks timestamp; NetworkQualityObservationSource source; }; std::vector<Observation>& observations() { return observations_; } // ThroughputObserver implementation: void OnThroughputObservation( int32_t throughput_kbps, const base::TimeTicks& timestamp, NetworkQualityObservationSource source) override { observations_.push_back(Observation(throughput_kbps, timestamp, source)); } private: std::vector<Observation> observations_; }; } // namespace TEST(NetworkQualityEstimatorTest, TestKbpsRTTUpdates) { base::HistogramTester histogram_tester; // Enable requests to local host to be used for network quality estimation. std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); base::TimeDelta rtt; int32_t kbps; EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); TestDelegate test_delegate; TestURLRequestContext context(true); context.set_network_quality_estimator(&estimator); context.Init(); std::unique_ptr<URLRequest> request(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); request->Start(); base::RunLoop().Run(); // Both RTT and downstream throughput should be updated. EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt)); // Check UMA histograms. histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 0); histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 0); histogram_tester.ExpectUniqueSample( "NQE.MainFrame.EffectiveConnectionType.Unknown", NetworkQualityEstimator::EffectiveConnectionType:: EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); std::unique_ptr<URLRequest> request2(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME); request2->Start(); base::RunLoop().Run(); histogram_tester.ExpectTotalCount( "NQE.MainFrame.EffectiveConnectionType.Unknown", 2); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.RatioMedianRTT.WiFi", 0); histogram_tester.ExpectTotalCount("NQE.RTT.Percentile0.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.RTT.Percentile10.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.RTT.Percentile50.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.RTT.Percentile90.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.RTT.Percentile100.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 0); EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); // Verify that metrics are logged correctly on main-frame requests. histogram_tester.ExpectTotalCount("NQE.MainFrame.RTT.Percentile50.Unknown", 1); histogram_tester.ExpectTotalCount( "NQE.MainFrame.TransportRTT.Percentile50.Unknown", 0); histogram_tester.ExpectTotalCount("NQE.MainFrame.Kbps.Percentile50.Unknown", 1); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, std::string()); histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1); EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); std::unique_ptr<URLRequest> request3(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request3->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME); request3->Start(); base::RunLoop().Run(); histogram_tester.ExpectUniqueSample( "NQE.MainFrame.EffectiveConnectionType.WiFi", NetworkQualityEstimator::EffectiveConnectionType:: EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); } TEST(NetworkQualityEstimatorTest, StoreObservations) { std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); base::TimeDelta rtt; int32_t kbps; EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); TestDelegate test_delegate; TestURLRequestContext context(true); context.set_network_quality_estimator(&estimator); context.Init(); // Push more observations than the maximum buffer size. const size_t kMaxObservations = 1000; for (size_t i = 0; i < kMaxObservations; ++i) { std::unique_ptr<URLRequest> request(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request->Start(); base::RunLoop().Run(); EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); } // Verify that the stored observations are cleared on network change. estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-2"); EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); } // This test notifies NetworkQualityEstimator of received data. Next, // throughput and RTT percentiles are checked for correctness by doing simple // verifications. TEST(NetworkQualityEstimatorTest, ComputedPercentiles) { std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); std::vector<NetworkQualityObservationSource> disallowed_observation_sources; disallowed_observation_sources.push_back( NETWORK_QUALITY_OBSERVATION_SOURCE_TCP); disallowed_observation_sources.push_back( NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC); EXPECT_EQ(nqe::internal::InvalidRTT(), estimator.GetRTTEstimateInternal(disallowed_observation_sources, base::TimeTicks(), 100)); EXPECT_EQ(nqe::internal::kInvalidThroughput, estimator.GetDownlinkThroughputKbpsEstimateInternal( base::TimeTicks(), 100)); TestDelegate test_delegate; TestURLRequestContext context(true); context.set_network_quality_estimator(&estimator); context.Init(); // Number of observations are more than the maximum buffer size. for (size_t i = 0; i < 1000U; ++i) { std::unique_ptr<URLRequest> request(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request->Start(); base::RunLoop().Run(); } // Verify the percentiles through simple tests. for (int i = 0; i <= 100; ++i) { EXPECT_GT(estimator.GetDownlinkThroughputKbpsEstimateInternal( base::TimeTicks(), i), 0); EXPECT_LT(estimator.GetRTTEstimateInternal(disallowed_observation_sources, base::TimeTicks(), i), base::TimeDelta::Max()); if (i != 0) { // Throughput percentiles are in decreasing order. EXPECT_LE(estimator.GetDownlinkThroughputKbpsEstimateInternal( base::TimeTicks(), i), estimator.GetDownlinkThroughputKbpsEstimateInternal( base::TimeTicks(), i - 1)); // RTT percentiles are in increasing order. EXPECT_GE(estimator.GetRTTEstimateInternal(disallowed_observation_sources, base::TimeTicks(), i), estimator.GetRTTEstimateInternal(disallowed_observation_sources, base::TimeTicks(), i - 1)); } } } TEST(NetworkQualityEstimatorTest, ObtainOperatingParams) { std::map<std::string, std::string> variation_params; variation_params["Unknown.DefaultMedianKbps"] = "100"; variation_params["WiFi.DefaultMedianKbps"] = "200"; variation_params["2G.DefaultMedianKbps"] = "300"; variation_params["Unknown.DefaultMedianRTTMsec"] = "1000"; variation_params["WiFi.DefaultMedianRTTMsec"] = "2000"; // Negative variation value should not be used. variation_params["2G.DefaultMedianRTTMsec"] = "-5"; TestNetworkQualityEstimator estimator(variation_params); base::TimeDelta rtt; EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); int32_t kbps; EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); EXPECT_EQ(100, kbps); EXPECT_EQ(base::TimeDelta::FromMilliseconds(1000), rtt); EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt)); // Simulate network change to Wi-Fi. estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); EXPECT_EQ(200, kbps); EXPECT_EQ(base::TimeDelta::FromMilliseconds(2000), rtt); EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt)); // Peak network quality should not be affected by the network quality // estimator field trial. EXPECT_EQ(nqe::internal::InvalidRTT(), estimator.peak_network_quality_.http_rtt()); EXPECT_EQ(nqe::internal::kInvalidThroughput, estimator.peak_network_quality_.downstream_throughput_kbps()); // Simulate network change to 2G. Only the Kbps default estimate should be // available. estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-2"); EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); EXPECT_EQ(300, kbps); // Simulate network change to 3G. Default estimates should be unavailable. estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-3"); EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); } TEST(NetworkQualityEstimatorTest, ObtainAlgorithmToUseFromParams) { const struct { bool set_variation_param; std::string algorithm; NetworkQualityEstimator::EffectiveConnectionTypeAlgorithm expected_algorithm; } tests[] = { {false, "", NetworkQualityEstimator::EffectiveConnectionTypeAlgorithm:: HTTP_RTT_AND_DOWNSTREAM_THROUGHOUT}, {true, "", NetworkQualityEstimator::EffectiveConnectionTypeAlgorithm:: HTTP_RTT_AND_DOWNSTREAM_THROUGHOUT}, {true, "HttpRTTAndDownstreamThroughput", NetworkQualityEstimator::EffectiveConnectionTypeAlgorithm:: HTTP_RTT_AND_DOWNSTREAM_THROUGHOUT}, }; for (const auto& test : tests) { std::map<std::string, std::string> variation_params; if (test.set_variation_param) variation_params["effective_connection_type_algorithm"] = test.algorithm; TestNetworkQualityEstimator estimator(variation_params); EXPECT_EQ(test.expected_algorithm, estimator.effective_connection_type_algorithm_) << test.algorithm; } } // Tests that |GetEffectiveConnectionType| returns correct connection type when // no variation params are specified. TEST(NetworkQualityEstimatorTest, ObtainThresholdsNone) { std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType // does not return Offline if the device is offline. estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, "test"); const struct { int32_t rtt_msec; NetworkQualityEstimator::EffectiveConnectionType expected_conn_type; } tests[] = { {5000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND}, {20, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND}, }; for (const auto& test : tests) { estimator.set_http_rtt(base::TimeDelta::FromMilliseconds(test.rtt_msec)); estimator.set_recent_http_rtt( base::TimeDelta::FromMilliseconds(test.rtt_msec)); estimator.set_downlink_throughput_kbps(INT32_MAX); estimator.set_recent_downlink_throughput_kbps(INT32_MAX); EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); } } // Tests that |GetEffectiveConnectionType| returns // EFFECTIVE_CONNECTION_TYPE_OFFLINE when the device is currently offline. TEST(NetworkQualityEstimatorTest, Offline) { std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); const struct { NetworkChangeNotifier::ConnectionType connection_type; NetworkQualityEstimator::EffectiveConnectionType expected_connection_type; } tests[] = { {NetworkChangeNotifier::CONNECTION_2G, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_UNKNOWN}, {NetworkChangeNotifier::CONNECTION_NONE, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_OFFLINE}, {NetworkChangeNotifier::CONNECTION_3G, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_UNKNOWN}, }; for (const auto& test : tests) { estimator.SimulateNetworkChangeTo(test.connection_type, "test"); EXPECT_EQ(test.expected_connection_type, estimator.GetEffectiveConnectionType()); } } // Tests that |GetEffectiveConnectionType| returns correct connection type when // only RTT thresholds are specified in the variation params. TEST(NetworkQualityEstimatorTest, ObtainThresholdsOnlyRTT) { std::map<std::string, std::string> variation_params; variation_params["Offline.ThresholdMedianHttpRTTMsec"] = "4000"; variation_params["Slow2G.ThresholdMedianHttpRTTMsec"] = "2000"; variation_params["2G.ThresholdMedianHttpRTTMsec"] = "1000"; variation_params["3G.ThresholdMedianHttpRTTMsec"] = "500"; variation_params["4G.ThresholdMedianHttpRTTMsec"] = "300"; variation_params["Broadband.ThresholdMedianHttpRTTMsec"] = "100"; TestNetworkQualityEstimator estimator(variation_params); // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType // does not return Offline if the device is offline. estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, "test"); const struct { int32_t rtt_msec; NetworkQualityEstimator::EffectiveConnectionType expected_conn_type; } tests[] = { {5000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_OFFLINE}, {4000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_OFFLINE}, {3000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, {2000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, {1500, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G}, {1000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G}, {700, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_3G}, {500, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_3G}, {400, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_4G}, {300, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_4G}, {200, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND}, {100, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND}, {20, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND}, }; for (const auto& test : tests) { estimator.set_http_rtt(base::TimeDelta::FromMilliseconds(test.rtt_msec)); estimator.set_recent_http_rtt( base::TimeDelta::FromMilliseconds(test.rtt_msec)); estimator.set_downlink_throughput_kbps(INT32_MAX); estimator.set_recent_downlink_throughput_kbps(INT32_MAX); EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); } } // Tests that |GetEffectiveConnectionType| returns correct connection type when // both RTT and throughput thresholds are specified in the variation params. TEST(NetworkQualityEstimatorTest, ObtainThresholdsRTTandThroughput) { std::map<std::string, std::string> variation_params; variation_params["Offline.ThresholdMedianHttpRTTMsec"] = "4000"; variation_params["Slow2G.ThresholdMedianHttpRTTMsec"] = "2000"; variation_params["2G.ThresholdMedianHttpRTTMsec"] = "1000"; variation_params["3G.ThresholdMedianHttpRTTMsec"] = "500"; variation_params["4G.ThresholdMedianHttpRTTMsec"] = "300"; variation_params["Broadband.ThresholdMedianHttpRTTMsec"] = "100"; variation_params["Offline.ThresholdMedianKbps"] = "10"; variation_params["Slow2G.ThresholdMedianKbps"] = "100"; variation_params["2G.ThresholdMedianKbps"] = "300"; variation_params["3G.ThresholdMedianKbps"] = "500"; variation_params["4G.ThresholdMedianKbps"] = "1000"; variation_params["Broadband.ThresholdMedianKbps"] = "2000"; TestNetworkQualityEstimator estimator(variation_params); // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType // does not return Offline if the device is offline. estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, "test"); const struct { int32_t rtt_msec; int32_t downlink_throughput_kbps; NetworkQualityEstimator::EffectiveConnectionType expected_conn_type; } tests[] = { // Set RTT to a very low value to observe the effect of throughput. // Throughput is the bottleneck. {1, 5, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_OFFLINE}, {1, 10, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_OFFLINE}, {1, 50, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, {1, 100, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, {1, 150, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G}, {1, 300, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G}, {1, 400, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_3G}, {1, 500, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_3G}, {1, 700, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_4G}, {1, 1000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_4G}, {1, 1500, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND}, {1, 2500, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND}, // Set both RTT and throughput. RTT is the bottleneck. {3000, 25000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, {700, 25000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_3G}, }; for (const auto& test : tests) { estimator.set_http_rtt(base::TimeDelta::FromMilliseconds(test.rtt_msec)); estimator.set_recent_http_rtt( base::TimeDelta::FromMilliseconds(test.rtt_msec)); estimator.set_downlink_throughput_kbps(test.downlink_throughput_kbps); estimator.set_recent_downlink_throughput_kbps( test.downlink_throughput_kbps); EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); } } // Tests if |weight_multiplier_per_second_| is set to correct value for various // values of half life parameter. TEST(NetworkQualityEstimatorTest, HalfLifeParam) { std::map<std::string, std::string> variation_params; const struct { std::string description; std::string variation_params_value; double expected_weight_multiplier; } tests[] = { {"Half life parameter is not set, default value should be used", std::string(), 0.988}, {"Half life parameter is set to negative, default value should be used", "-100", 0.988}, {"Half life parameter is set to zero, default value should be used", "0", 0.988}, {"Half life parameter is set correctly", "10", 0.933}, }; for (const auto& test : tests) { variation_params["HalfLifeSeconds"] = test.variation_params_value; TestNetworkQualityEstimator estimator(variation_params); EXPECT_NEAR(test.expected_weight_multiplier, estimator.weight_multiplier_per_second_, 0.001) << test.description; } } // Test if the network estimates are cached when network change notification // is invoked. TEST(NetworkQualityEstimatorTest, TestCaching) { std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); size_t expected_cache_size = 0; EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); // Cache entry will not be added for (NONE, ""). estimator.downstream_throughput_kbps_observations_.AddObservation( NetworkQualityEstimator::ThroughputObservation( 1, base::TimeTicks::Now(), NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.rtt_observations_.AddObservation( NetworkQualityEstimator::RttObservation( base::TimeDelta::FromMilliseconds(1000), base::TimeTicks::Now(), NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-1"); EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); // Entry will be added for (2G, "test1"). // Also, set the network quality for (2G, "test1") so that it is stored in // the cache. estimator.downstream_throughput_kbps_observations_.AddObservation( NetworkQualityEstimator::ThroughputObservation( 1, base::TimeTicks::Now(), NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.rtt_observations_.AddObservation( NetworkQualityEstimator::RttObservation( base::TimeDelta::FromMilliseconds(1000), base::TimeTicks::Now(), NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-1"); ++expected_cache_size; EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); // Entry will be added for (3G, "test1"). // Also, set the network quality for (3G, "test1") so that it is stored in // the cache. estimator.downstream_throughput_kbps_observations_.AddObservation( NetworkQualityEstimator::ThroughputObservation( 2, base::TimeTicks::Now(), NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.rtt_observations_.AddObservation( NetworkQualityEstimator::RttObservation( base::TimeDelta::FromMilliseconds(500), base::TimeTicks::Now(), NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-2"); ++expected_cache_size; EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); // Entry will not be added for (3G, "test2"). estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-1"); EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); // Read the network quality for (2G, "test-1"). EXPECT_TRUE(estimator.ReadCachedNetworkQualityEstimate()); base::TimeDelta rtt; int32_t kbps; EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); EXPECT_EQ(1, kbps); EXPECT_EQ(base::TimeDelta::FromMilliseconds(1000), rtt); EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt)); // No new entry should be added for (2G, "test-1") since it already exists // in the cache. estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-1"); EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); // Read the network quality for (3G, "test-1"). EXPECT_TRUE(estimator.ReadCachedNetworkQualityEstimate()); EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); EXPECT_EQ(2, kbps); EXPECT_EQ(base::TimeDelta::FromMilliseconds(500), rtt); // No new entry should be added for (3G, "test1") since it already exists // in the cache. estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-2"); EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); // Reading quality of (3G, "test-2") should return false. EXPECT_FALSE(estimator.ReadCachedNetworkQualityEstimate()); // Reading quality of (2G, "test-3") should return false. estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-3"); EXPECT_FALSE(estimator.ReadCachedNetworkQualityEstimate()); } // Tests if the cache size remains bounded. Also, ensure that the cache is // LRU. TEST(NetworkQualityEstimatorTest, TestLRUCacheMaximumSize) { std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, std::string()); EXPECT_EQ(0U, estimator.cached_network_qualities_.size()); // Add 100 more networks than the maximum size of the cache. size_t network_count = NetworkQualityEstimator::kMaximumNetworkQualityCacheSize + 100; base::TimeTicks update_time_of_network_100; for (size_t i = 0; i < network_count; ++i) { estimator.downstream_throughput_kbps_observations_.AddObservation( NetworkQualityEstimator::ThroughputObservation( 2, base::TimeTicks::Now(), NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.rtt_observations_.AddObservation( NetworkQualityEstimator::RttObservation( base::TimeDelta::FromMilliseconds(500), base::TimeTicks::Now(), NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); if (i == 100) update_time_of_network_100 = base::TimeTicks::Now(); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, base::SizeTToString(i)); if (i < NetworkQualityEstimator::kMaximumNetworkQualityCacheSize) EXPECT_EQ(i, estimator.cached_network_qualities_.size()); EXPECT_LE(estimator.cached_network_qualities_.size(), static_cast<size_t>( NetworkQualityEstimator::kMaximumNetworkQualityCacheSize)); } // One more call so that the last network is also written to cache. estimator.downstream_throughput_kbps_observations_.AddObservation( NetworkQualityEstimator::ThroughputObservation( 2, base::TimeTicks::Now(), NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.rtt_observations_.AddObservation( NetworkQualityEstimator::RttObservation( base::TimeDelta::FromMilliseconds(500), base::TimeTicks::Now(), NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, base::SizeTToString(network_count - 1)); EXPECT_EQ(static_cast<size_t>( NetworkQualityEstimator::kMaximumNetworkQualityCacheSize), estimator.cached_network_qualities_.size()); // Test that the cache is LRU by examining its contents. Networks in cache // must all be newer than the 100th network. for (NetworkQualityEstimator::CachedNetworkQualities::iterator it = estimator.cached_network_qualities_.begin(); it != estimator.cached_network_qualities_.end(); ++it) { EXPECT_GE((it->second).last_update_time_, update_time_of_network_100); } } TEST(NetworkQualityEstimatorTest, TestGetMetricsSince) { std::map<std::string, std::string> variation_params; const base::TimeDelta rtt_threshold_4g = base::TimeDelta::FromMilliseconds(30); const base::TimeDelta rtt_threshold_broadband = base::TimeDelta::FromMilliseconds(1); variation_params["4G.ThresholdMedianHttpRTTMsec"] = base::IntToString(rtt_threshold_4g.InMilliseconds()); variation_params["Broadband.ThresholdMedianHttpRTTMsec"] = base::IntToString(rtt_threshold_broadband.InMilliseconds()); variation_params["HalfLifeSeconds"] = "300000"; TestNetworkQualityEstimator estimator(variation_params); base::TimeTicks now = base::TimeTicks::Now(); base::TimeTicks old = now - base::TimeDelta::FromMilliseconds(1); ASSERT_NE(old, now); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test"); const int32_t old_downlink_kbps = 1; const base::TimeDelta old_url_rtt = base::TimeDelta::FromMilliseconds(1); const base::TimeDelta old_tcp_rtt = base::TimeDelta::FromMilliseconds(10); DCHECK_LT(old_url_rtt, rtt_threshold_4g); DCHECK_LT(old_tcp_rtt, rtt_threshold_4g); // First sample has very old timestamp. for (size_t i = 0; i < 2; ++i) { estimator.downstream_throughput_kbps_observations_.AddObservation( NetworkQualityEstimator::ThroughputObservation( old_downlink_kbps, old, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.rtt_observations_.AddObservation( NetworkQualityEstimator::RttObservation( old_url_rtt, old, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.rtt_observations_.AddObservation( NetworkQualityEstimator::RttObservation( old_tcp_rtt, old, NETWORK_QUALITY_OBSERVATION_SOURCE_TCP)); } const int32_t new_downlink_kbps = 100; const base::TimeDelta new_url_rtt = base::TimeDelta::FromMilliseconds(100); const base::TimeDelta new_tcp_rtt = base::TimeDelta::FromMilliseconds(1000); DCHECK_NE(old_downlink_kbps, new_downlink_kbps); DCHECK_NE(old_url_rtt, new_url_rtt); DCHECK_NE(old_tcp_rtt, new_tcp_rtt); DCHECK_GT(new_url_rtt, rtt_threshold_4g); DCHECK_GT(new_tcp_rtt, rtt_threshold_4g); DCHECK_GT(new_url_rtt, rtt_threshold_broadband); DCHECK_GT(new_tcp_rtt, rtt_threshold_broadband); estimator.downstream_throughput_kbps_observations_.AddObservation( NetworkQualityEstimator::ThroughputObservation( new_downlink_kbps, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.rtt_observations_.AddObservation( NetworkQualityEstimator::RttObservation( new_url_rtt, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); estimator.rtt_observations_.AddObservation( NetworkQualityEstimator::RttObservation( new_tcp_rtt, now, NETWORK_QUALITY_OBSERVATION_SOURCE_TCP)); const struct { base::TimeTicks start_timestamp; bool expect_network_quality_available; base::TimeDelta expected_http_rtt; base::TimeDelta expected_transport_rtt; int32_t expected_downstream_throughput; NetworkQualityEstimator::EffectiveConnectionType expected_effective_connection_type; } tests[] = { {now + base::TimeDelta::FromSeconds(10), false, base::TimeDelta::FromMilliseconds(0), base::TimeDelta::FromMilliseconds(0), 0, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND}, {now, true, new_url_rtt, new_tcp_rtt, new_downlink_kbps, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_4G}, {old - base::TimeDelta::FromMicroseconds(500), true, old_url_rtt, old_tcp_rtt, old_downlink_kbps, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND}, }; for (const auto& test : tests) { base::TimeDelta http_rtt; base::TimeDelta transport_rtt; int32_t downstream_throughput_kbps; EXPECT_EQ( test.expect_network_quality_available, estimator.GetRecentHttpRTTMedian(test.start_timestamp, &http_rtt)); EXPECT_EQ(test.expect_network_quality_available, estimator.GetRecentTransportRTTMedian(test.start_timestamp, &transport_rtt)); EXPECT_EQ(test.expect_network_quality_available, estimator.GetRecentMedianDownlinkThroughputKbps( test.start_timestamp, &downstream_throughput_kbps)); if (test.expect_network_quality_available) { EXPECT_EQ(test.expected_http_rtt, http_rtt); EXPECT_EQ(test.expected_transport_rtt, transport_rtt); EXPECT_EQ(test.expected_downstream_throughput, downstream_throughput_kbps); EXPECT_EQ( test.expected_effective_connection_type, estimator.GetRecentEffectiveConnectionType(test.start_timestamp)); } } } // An external estimate provider that does not have a valid RTT or throughput // estimate. class InvalidExternalEstimateProvider : public ExternalEstimateProvider { public: InvalidExternalEstimateProvider() : update_count_(0) {} ~InvalidExternalEstimateProvider() override {} bool GetRTT(base::TimeDelta* rtt) const override { DCHECK(rtt); return false; } bool GetDownstreamThroughputKbps( int32_t* downstream_throughput_kbps) const override { DCHECK(downstream_throughput_kbps); return false; } bool GetUpstreamThroughputKbps( int32_t* upstream_throughput_kbps) const override { // NetworkQualityEstimator does not support upstream throughput. ADD_FAILURE(); return false; } bool GetTimeSinceLastUpdate( base::TimeDelta* time_since_last_update) const override { NOTREACHED(); return false; } void SetUpdatedEstimateDelegate(UpdatedEstimateDelegate* delegate) override {} void Update() const override { update_count_++; } size_t update_count() const { return update_count_; } private: mutable size_t update_count_; DISALLOW_COPY_AND_ASSIGN(InvalidExternalEstimateProvider); }; // Tests if the RTT value from external estimate provider is discarded if the // external estimate provider is invalid. TEST(NetworkQualityEstimatorTest, InvalidExternalEstimateProvider) { base::HistogramTester histogram_tester; InvalidExternalEstimateProvider* invalid_external_estimate_provider = new InvalidExternalEstimateProvider(); std::unique_ptr<ExternalEstimateProvider> external_estimate_provider( invalid_external_estimate_provider); TestNetworkQualityEstimator estimator(std::map<std::string, std::string>(), std::move(external_estimate_provider)); estimator.SimulateNetworkChangeTo(net::NetworkChangeNotifier::CONNECTION_WIFI, "test"); base::TimeDelta rtt; int32_t kbps; EXPECT_EQ(1U, invalid_external_estimate_provider->update_count()); EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 2); histogram_tester.ExpectBucketCount( "NQE.ExternalEstimateProviderStatus", 1 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE */, 1); histogram_tester.ExpectBucketCount( "NQE.ExternalEstimateProviderStatus", 2 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED */, 1); histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProvider.RTT", 0); histogram_tester.ExpectTotalCount( "NQE.ExternalEstimateProvider.DownlinkBandwidth", 0); } class TestExternalEstimateProvider : public ExternalEstimateProvider { public: TestExternalEstimateProvider(base::TimeDelta rtt, int32_t downstream_throughput_kbps) : delegate_(nullptr), should_notify_delegate_(true), rtt_(rtt), downstream_throughput_kbps_(downstream_throughput_kbps), update_count_(0) {} ~TestExternalEstimateProvider() override {} bool GetRTT(base::TimeDelta* rtt) const override { NOTREACHED(); return true; } bool GetDownstreamThroughputKbps( int32_t* downstream_throughput_kbps) const override { NOTREACHED(); return true; } bool GetUpstreamThroughputKbps( int32_t* upstream_throughput_kbps) const override { NOTREACHED(); return false; } bool GetTimeSinceLastUpdate( base::TimeDelta* time_since_last_update) const override { NOTREACHED(); return true; } void SetUpdatedEstimateDelegate(UpdatedEstimateDelegate* delegate) override { delegate_ = delegate; } void set_should_notify_delegate(bool should_notify_delegate) { should_notify_delegate_ = should_notify_delegate; } void Update() const override { update_count_++; if (!should_notify_delegate_) return; delegate_->OnUpdatedEstimateAvailable(rtt_, downstream_throughput_kbps_, -1); } size_t update_count() const { return update_count_; } private: UpdatedEstimateDelegate* delegate_; bool should_notify_delegate_; // RTT and downstream throughput estimates. const base::TimeDelta rtt_; const int32_t downstream_throughput_kbps_; mutable size_t update_count_; DISALLOW_COPY_AND_ASSIGN(TestExternalEstimateProvider); }; // Tests if the external estimate provider is called in the constructor and // on network change notification. TEST(NetworkQualityEstimatorTest, TestExternalEstimateProvider) { base::HistogramTester histogram_tester; const base::TimeDelta external_estimate_provider_rtt = base::TimeDelta::FromMilliseconds(1); const int32_t external_estimate_provider_downstream_throughput = 100; TestExternalEstimateProvider* test_external_estimate_provider = new TestExternalEstimateProvider( external_estimate_provider_rtt, external_estimate_provider_downstream_throughput); std::unique_ptr<ExternalEstimateProvider> external_estimate_provider( test_external_estimate_provider); std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params, std::move(external_estimate_provider)); estimator.SimulateNetworkChangeTo(net::NetworkChangeNotifier::CONNECTION_WIFI, "test"); base::TimeDelta rtt; int32_t kbps; EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt)); EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 5); histogram_tester.ExpectBucketCount( "NQE.ExternalEstimateProviderStatus", 1 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE */, 1); histogram_tester.ExpectBucketCount( "NQE.ExternalEstimateProviderStatus", 2 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED */, 1); histogram_tester.ExpectBucketCount( "NQE.ExternalEstimateProviderStatus", 4 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK */, 1); histogram_tester.ExpectBucketCount( "NQE.ExternalEstimateProviderStatus", 5 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE */, 1); histogram_tester.ExpectBucketCount( "NQE.ExternalEstimateProviderStatus", 6 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE */, 1); histogram_tester.ExpectUniqueSample("NQE.ExternalEstimateProvider.RTT", 1, 1); histogram_tester.ExpectUniqueSample( "NQE.ExternalEstimateProvider.DownlinkBandwidth", 100, 1); EXPECT_EQ(1U, test_external_estimate_provider->update_count()); // Change network type to WiFi. Number of queries to External estimate // provider must increment. estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); EXPECT_EQ(2U, test_external_estimate_provider->update_count()); test_external_estimate_provider->set_should_notify_delegate(false); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-2"); EXPECT_EQ(3U, test_external_estimate_provider->update_count()); // Estimates are unavailable because external estimate provider never // notifies network quality estimator of the updated estimates. EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); } // Tests if the estimate from the external estimate provider is merged with the // observations collected from the HTTP requests. TEST(NetworkQualityEstimatorTest, TestExternalEstimateProviderMergeEstimates) { const base::TimeDelta external_estimate_provider_rtt = base::TimeDelta::FromMilliseconds(10 * 1000); const int32_t external_estimate_provider_downstream_throughput = 100 * 1000; TestExternalEstimateProvider* test_external_estimate_provider = new TestExternalEstimateProvider( external_estimate_provider_rtt, external_estimate_provider_downstream_throughput); std::unique_ptr<ExternalEstimateProvider> external_estimate_provider( test_external_estimate_provider); std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params, std::move(external_estimate_provider)); estimator.SimulateNetworkChangeTo(net::NetworkChangeNotifier::CONNECTION_WIFI, "test"); base::TimeDelta rtt; // Estimate provided by network quality estimator should match the estimate // provided by external estimate provider. EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_EQ(external_estimate_provider_rtt, rtt); int32_t kbps; EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); EXPECT_EQ(external_estimate_provider_downstream_throughput, kbps); TestDelegate test_delegate; TestURLRequestContext context(true); context.set_network_quality_estimator(&estimator); context.Init(); std::unique_ptr<URLRequest> request(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request->Start(); base::RunLoop().Run(); EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_NE(external_estimate_provider_rtt, rtt); EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); EXPECT_NE(external_estimate_provider_downstream_throughput, kbps); } // Tests if the throughput observation is taken correctly when local and network // requests do not overlap. TEST(NetworkQualityEstimatorTest, TestThroughputNoRequestOverlap) { base::HistogramTester histogram_tester; std::map<std::string, std::string> variation_params; static const struct { bool allow_small_localhost_requests; } tests[] = { { false, }, { true, }, }; for (const auto& test : tests) { TestNetworkQualityEstimator estimator( std::unique_ptr<net::ExternalEstimateProvider>(), variation_params, test.allow_small_localhost_requests, test.allow_small_localhost_requests); base::TimeDelta rtt; EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); int32_t kbps; EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); TestDelegate test_delegate; TestURLRequestContext context(true); context.set_network_quality_estimator(&estimator); context.Init(); std::unique_ptr<URLRequest> request(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); request->Start(); base::RunLoop().Run(); EXPECT_EQ(test.allow_small_localhost_requests, estimator.GetHttpRTTEstimate(&rtt)); EXPECT_EQ(test.allow_small_localhost_requests, estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); } } // Tests that the effective connection type is computed at the specified // interval, and that the observers are notified of any change. TEST(NetworkQualityEstimatorTest, TestEffectiveConnectionTypeObserver) { base::HistogramTester histogram_tester; std::unique_ptr<base::SimpleTestTickClock> tick_clock( new base::SimpleTestTickClock()); base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get(); TestEffectiveConnectionTypeObserver observer; std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); estimator.AddEffectiveConnectionTypeObserver(&observer); estimator.SetTickClockForTesting(std::move(tick_clock)); TestDelegate test_delegate; TestURLRequestContext context(true); context.set_network_quality_estimator(&estimator); context.Init(); EXPECT_EQ(0U, observer.effective_connection_types().size()); estimator.set_effective_connection_type( NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G); tick_clock_ptr->Advance(base::TimeDelta::FromMinutes(60)); std::unique_ptr<URLRequest> request(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); request->Start(); base::RunLoop().Run(); EXPECT_EQ(1U, observer.effective_connection_types().size()); histogram_tester.ExpectUniqueSample( "NQE.MainFrame.EffectiveConnectionType.Unknown", NetworkQualityEstimator::EffectiveConnectionType:: EFFECTIVE_CONNECTION_TYPE_2G, 1); // Next request should not trigger recomputation of effective connection type // since there has been no change in the clock. std::unique_ptr<URLRequest> request2(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request2->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); request2->Start(); base::RunLoop().Run(); EXPECT_EQ(1U, observer.effective_connection_types().size()); // Change in connection type should send out notification to the observers. estimator.set_effective_connection_type( NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_3G); estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, "test"); EXPECT_EQ(2U, observer.effective_connection_types().size()); // A change in effective connection type does not trigger notification to the // observers, since it is not accompanied by any new observation or a network // change event. estimator.set_effective_connection_type( NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_3G); EXPECT_EQ(2U, observer.effective_connection_types().size()); } TEST(NetworkQualityEstimatorTest, TestRttThroughputObservers) { TestRTTObserver rtt_observer; TestThroughputObserver throughput_observer; std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); estimator.AddRTTObserver(&rtt_observer); estimator.AddThroughputObserver(&throughput_observer); TestDelegate test_delegate; TestURLRequestContext context(true); context.set_network_quality_estimator(&estimator); context.Init(); EXPECT_EQ(0U, rtt_observer.observations().size()); EXPECT_EQ(0U, throughput_observer.observations().size()); base::TimeTicks then = base::TimeTicks::Now(); std::unique_ptr<URLRequest> request(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); request->Start(); base::RunLoop().Run(); std::unique_ptr<URLRequest> request2(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request2->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); request2->Start(); base::RunLoop().Run(); // Both RTT and downstream throughput should be updated. base::TimeDelta rtt; EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); int32_t throughput; EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&throughput)); EXPECT_EQ(2U, rtt_observer.observations().size()); EXPECT_EQ(2U, throughput_observer.observations().size()); for (const auto& observation : rtt_observer.observations()) { EXPECT_LE(0, observation.rtt_ms); EXPECT_LE(0, (observation.timestamp - then).InMilliseconds()); EXPECT_EQ(NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST, observation.source); } for (const auto& observation : throughput_observer.observations()) { EXPECT_LE(0, observation.throughput_kbps); EXPECT_LE(0, (observation.timestamp - then).InMilliseconds()); EXPECT_EQ(NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST, observation.source); } EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt)); // Verify that observations from TCP and QUIC are passed on to the observers. base::TimeDelta tcp_rtt(base::TimeDelta::FromMilliseconds(1)); base::TimeDelta quic_rtt(base::TimeDelta::FromMilliseconds(2)); std::unique_ptr<SocketPerformanceWatcher> tcp_watcher = estimator.GetSocketPerformanceWatcherFactory() ->CreateSocketPerformanceWatcher( SocketPerformanceWatcherFactory::PROTOCOL_TCP); std::unique_ptr<SocketPerformanceWatcher> quic_watcher = estimator.GetSocketPerformanceWatcherFactory() ->CreateSocketPerformanceWatcher( SocketPerformanceWatcherFactory::PROTOCOL_QUIC); tcp_watcher->OnUpdatedRTTAvailable(tcp_rtt); quic_watcher->OnUpdatedRTTAvailable(quic_rtt); base::RunLoop().RunUntilIdle(); EXPECT_EQ(4U, rtt_observer.observations().size()); EXPECT_EQ(2U, throughput_observer.observations().size()); EXPECT_EQ(tcp_rtt.InMilliseconds(), rtt_observer.observations().at(2).rtt_ms); EXPECT_EQ(quic_rtt.InMilliseconds(), rtt_observer.observations().at(3).rtt_ms); EXPECT_TRUE(estimator.GetTransportRTTEstimate(&rtt)); } // TestTCPSocketRTT requires kernel support for tcp_info struct, and so it is // enabled only on certain platforms. #if defined(TCP_INFO) || defined(OS_LINUX) #define MAYBE_TestTCPSocketRTT TestTCPSocketRTT #else #define MAYBE_TestTCPSocketRTT DISABLED_TestTCPSocketRTT #endif // Tests that the TCP socket notifies the Network Quality Estimator of TCP RTTs, // which in turn notifies registered RTT observers. TEST(NetworkQualityEstimatorTest, MAYBE_TestTCPSocketRTT) { base::HistogramTester histogram_tester; TestRTTObserver rtt_observer; std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); estimator.AddRTTObserver(&rtt_observer); TestDelegate test_delegate; TestURLRequestContext context(true); context.set_network_quality_estimator(&estimator); std::unique_ptr<HttpNetworkSession::Params> params( new HttpNetworkSession::Params); // |estimator| should be notified of TCP RTT observations. params->socket_performance_watcher_factory = estimator.GetSocketPerformanceWatcherFactory(); context.set_http_network_session_params(std::move(params)); context.Init(); EXPECT_EQ(0U, rtt_observer.observations().size()); base::TimeDelta rtt; EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt)); // Send two requests. Verify that the completion of each request generates at // least one TCP RTT observation. const size_t num_requests = 2; for (size_t i = 0; i < num_requests; ++i) { size_t before_count_tcp_rtt_observations = 0; for (const auto& observation : rtt_observer.observations()) { if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP) ++before_count_tcp_rtt_observations; } std::unique_ptr<URLRequest> request(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); request->Start(); base::RunLoop().Run(); size_t after_count_tcp_rtt_observations = 0; for (const auto& observation : rtt_observer.observations()) { if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP) ++after_count_tcp_rtt_observations; } // At least one notification should be received per socket performance // watcher. EXPECT_LE(1U, after_count_tcp_rtt_observations - before_count_tcp_rtt_observations) << i; } EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); EXPECT_TRUE(estimator.GetTransportRTTEstimate(&rtt)); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.Unknown", rtt.InMilliseconds(), 1); histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.Unknown", 1); histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.Unknown", 1); // Verify that metrics are logged correctly on main-frame requests. histogram_tester.ExpectTotalCount( "NQE.MainFrame.TransportRTT.Percentile50.Unknown", num_requests); histogram_tester.ExpectTotalCount( "NQE.MainFrame.EffectiveConnectionType.Unknown", num_requests); histogram_tester.ExpectBucketCount( "NQE.MainFrame.EffectiveConnectionType.Unknown", NetworkQualityEstimator::EffectiveConnectionType:: EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); } #if defined(OS_IOS) // Flaky on iOS when |accuracy_recording_delay| is non-zero. #define MAYBE_RecordAccuracy DISABLED_RecordAccuracy #else #define MAYBE_RecordAccuracy RecordAccuracy #endif // Tests if the NQE accuracy metrics are recorded properly. TEST(NetworkQualityEstimatorTest, MAYBE_RecordAccuracy) { const int expected_rtt_msec = 100; const int expected_downstream_throughput_kbps = 200; const base::TimeDelta accuracy_recording_delays[] = { base::TimeDelta::FromSeconds(0), base::TimeDelta::FromSeconds(1), }; const struct { base::TimeDelta rtt; base::TimeDelta recent_rtt; int32_t downstream_throughput_kbps; int32_t recent_downstream_throughput_kbps; NetworkQualityEstimator::EffectiveConnectionType effective_connection_type; NetworkQualityEstimator::EffectiveConnectionType recent_effective_connection_type; } tests[] = { {base::TimeDelta::FromMilliseconds(expected_rtt_msec), base::TimeDelta::FromMilliseconds(expected_rtt_msec), expected_downstream_throughput_kbps, expected_downstream_throughput_kbps, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G}, { base::TimeDelta::FromMilliseconds(expected_rtt_msec + 1), base::TimeDelta::FromMilliseconds(expected_rtt_msec), expected_downstream_throughput_kbps + 1, expected_downstream_throughput_kbps, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_3G, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G, }, { base::TimeDelta::FromMilliseconds(expected_rtt_msec - 1), base::TimeDelta::FromMilliseconds(expected_rtt_msec), expected_downstream_throughput_kbps - 1, expected_downstream_throughput_kbps, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G, }, }; for (const auto& accuracy_recording_delay : accuracy_recording_delays) { for (const auto& test : tests) { std::unique_ptr<base::SimpleTestTickClock> tick_clock( new base::SimpleTestTickClock()); base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get(); tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1)); std::map<std::string, std::string> variation_params; TestNetworkQualityEstimator estimator(variation_params); estimator.SetTickClockForTesting(std::move(tick_clock)); estimator.SimulateNetworkChangeTo( NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1)); std::vector<base::TimeDelta> accuracy_recording_intervals; accuracy_recording_intervals.push_back(accuracy_recording_delay); estimator.SetAccuracyRecordingIntervals(accuracy_recording_intervals); // RTT is higher than threshold. Network is slow. // Network was predicted to be slow and actually was slow. estimator.set_http_rtt(test.rtt); estimator.set_recent_http_rtt(test.recent_rtt); estimator.set_transport_rtt(test.rtt); estimator.set_recent_transport_rtt(test.recent_rtt); estimator.set_downlink_throughput_kbps(test.downstream_throughput_kbps); estimator.set_recent_downlink_throughput_kbps( test.recent_downstream_throughput_kbps); estimator.set_effective_connection_type(test.effective_connection_type); estimator.set_recent_effective_connection_type( test.recent_effective_connection_type); base::HistogramTester histogram_tester; TestDelegate test_delegate; TestURLRequestContext context(true); context.set_network_quality_estimator(&estimator); context.Init(); // Start a main-frame request which should cause network quality estimator // to record accuracy UMA. std::unique_ptr<URLRequest> request(context.CreateRequest( estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); request->Start(); base::RunLoop().Run(); if (accuracy_recording_delay != base::TimeDelta()) { tick_clock_ptr->Advance(accuracy_recording_delay); // Sleep for some time to ensure that the delayed task is posted. base::PlatformThread::Sleep(accuracy_recording_delay * 2); base::RunLoop().RunUntilIdle(); } const int diff = std::abs(test.rtt.InMilliseconds() - test.recent_rtt.InMilliseconds()); const std::string sign_suffix_with_one_sample = test.rtt.InMilliseconds() - test.recent_rtt.InMilliseconds() >= 0 ? "Positive" : "Negative"; const std::string sign_suffix_with_zero_samples = test.rtt.InMilliseconds() - test.recent_rtt.InMilliseconds() >= 0 ? "Negative" : "Positive"; const std::string interval_value = base::IntToString(accuracy_recording_delay.InSeconds()); histogram_tester.ExpectUniqueSample( "NQE.Accuracy.DownstreamThroughputKbps.EstimatedObservedDiff." + sign_suffix_with_one_sample + "." + interval_value + ".140_300", diff, 1); histogram_tester.ExpectTotalCount( "NQE.Accuracy.DownstreamThroughputKbps.EstimatedObservedDiff." + sign_suffix_with_zero_samples + "." + interval_value + ".140_300", 0); histogram_tester.ExpectUniqueSample( "NQE.Accuracy.EffectiveConnectionType.EstimatedObservedDiff." + sign_suffix_with_one_sample + "." + interval_value + ".2G", diff, 1); histogram_tester.ExpectTotalCount( "NQE.Accuracy.EffectiveConnectionType.EstimatedObservedDiff." + sign_suffix_with_zero_samples + "." + interval_value + ".2G", 0); histogram_tester.ExpectUniqueSample( "NQE.Accuracy.HttpRTT.EstimatedObservedDiff." + sign_suffix_with_one_sample + "." + interval_value + ".60_140", diff, 1); histogram_tester.ExpectTotalCount( "NQE.Accuracy.HttpRTT.EstimatedObservedDiff." + sign_suffix_with_zero_samples + "." + interval_value + ".60_140", 0); histogram_tester.ExpectUniqueSample( "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." + sign_suffix_with_one_sample + "." + interval_value + ".60_140", diff, 1); histogram_tester.ExpectTotalCount( "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." + sign_suffix_with_zero_samples + "." + interval_value + ".60_140", 0); } } } // Tests that the effective connection type is converted correctly to a // descriptive string name, and vice-versa. TEST(NetworkQualityEstimatorTest, NameConnectionTypeConversion) { for (size_t i = 0; i < NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_LAST; ++i) { const NetworkQualityEstimator::EffectiveConnectionType effective_connection_type = static_cast<NetworkQualityEstimator::EffectiveConnectionType>(i); std::string connection_type_name = std::string(NetworkQualityEstimator::GetNameForEffectiveConnectionType( effective_connection_type)); EXPECT_FALSE(connection_type_name.empty()); EXPECT_EQ(effective_connection_type, NetworkQualityEstimator::GetEffectiveConnectionTypeForName( connection_type_name)); } } } // namespace net
3c1cb3f0ecba932d0d1614b86266ad5d95588d19
2465d5aac8230436d3a08383a722d6437e97ac40
/SDK/PUBG_P_MotoAccel_Dirt_BP_classes.hpp
19716f73cce4cd361a144523649bf141f447925f
[]
no_license
xuhao1/PUBG-SDK
9684baf0471678eaf366de3b3ca5f933ace357ab
5f0041ef5ad7f16111361316fa8dff1ad4647993
refs/heads/master
2021-08-14T13:32:37.783490
2017-11-15T20:56:12
2017-11-15T20:56:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
957
hpp
#pragma once // PlayerUnknown's Battlegrounds SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif namespace Classes { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass P_MotoAccel_Dirt_BP.P_MotoAccel_Dirt_BP_C // 0x0008 (0x0400 - 0x03F8) class AP_MotoAccel_Dirt_BP_C : public ATslParticle { public: struct FPointerToUberGraphFrame UberGraphFrame; // 0x03F8(0x0008) (CPF_ZeroConstructor, CPF_Transient, CPF_DuplicateTransient) static UClass* StaticClass() { static UClass* ptr = nullptr; if (!ptr) ptr = UObject::FindClass(0xed36d819); return ptr; } void UserConstructionScript(); void OnParameterUpdated(); void ExecuteUbergraph_P_MotoAccel_Dirt_BP(int EntryPoint); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
a6155d5c8b688131950fbe6295aaeb48fe6d29f6
5b0ed16ae612cbe0c3415bb98e930a4751472a80
/OpenGL_2/Midtern/Enemy/Syabon.cpp
bfa3e861f48cc5b40152e48e6ac3bd1487e33b31
[]
no_license
scream870102/OpenGL_HW
f3dd2d61b555bb17d98695bc4843e21df7b601d1
a8decf57e9250001f5653f2e66aaee09c3728527
refs/heads/master
2020-09-08T21:01:09.327519
2019-12-01T09:34:52
2019-12-01T09:34:52
221,236,204
0
0
null
null
null
null
UTF-8
C++
false
false
13,361
cpp
#include "Syabon.h" void Syabon::Update(float delta) { Enemy::Update(delta); this->transform->rotation.z = move->GetDegree() - 90.0f; this->transform->position = move->GetNextPos(delta); if (shootTimer->IsFinished()) { shootTimer->Reset(); vec3 direction = Angel::normalize(pPlayer->transform->position - transform->position); BulletPool::GetInstance()->Fire(ENEMY, transform->position, direction, BULLET_SPEED, damage); } } Syabon::Syabon(Player* player, int damage, int health, vec3 initPos, mat4& matModelView, mat4& matProjection, GLuint shaderHandle) :Enemy(player, ENEMY, damage, health) { _points[0] = point4(0.0f, -28.0f, 0.0f, 1.0f); _points[1] = point4(-10.0f, -16.0f, 0.0f, 1.0f); _points[2] = point4(0.0f, -18.0f, 0.0f, 1.0f); _points[3] = point4(-27.0f, -7.0f, 0.0f, 1.0f); _points[4] = point4(-17.0f, -2.0f, 0.0f, 1.0f); _points[5] = point4(-27.0f, 8.0f, 0.0f, 1.0f); _points[6] = point4(0.0f, -28.0f, 0.0f, 1.0f); _points[7] = point4(-17.0f, -22.0f, 0.0f, 1.0f); _points[8] = point4(-10.0f, -16.0f, 0.0f, 1.0f); _points[9] = point4(-17.0f, -22.0f, 0.0f, 1.0f); _points[10] = point4(-27.0f, -7.0f, 0.0f, 1.0f); _points[11] = point4(-17.0f, -2.0f, 0.0f, 1.0f); _points[12] = point4(-17.0f, -22.0f, 0.0f, 1.0f); _points[13] = point4(-17.0f, -2.0f, 0.0f, 1.0f); _points[14] = point4(-10.0f, -16.0f, 0.0f, 1.0f); _points[15] = point4(-17.0f, -2.0f, 0.0f, 1.0f); _points[16] = point4(-27.0f, 8.0f, 0.0f, 1.0f); _points[17] = point4(-17.0f, 3.0f, 0.0f, 1.0f); _points[18] = point4(-17.0f, 3.0f, 0.0f, 1.0f); _points[19] = point4(-17.0f, 20.0f, 0.0f, 1.0f); _points[20] = point4(-10.0f, 14.0f, 0.0f, 1.0f); _points[21] = point4(-10.0f, 14.0f, 0.0f, 1.0f); _points[22] = point4(-17.0f, 20.0f, 0.0f, 1.0f); _points[23] = point4(0.0f, 28.0f, 0.0f, 1.0f); _points[24] = point4(-27.0f, 8.0f, 0.0f, 1.0f); _points[25] = point4(-17.0f, 20.0f, 0.0f, 1.0f); _points[26] = point4(-17.0f, 3.0f, 0.0f, 1.0f); _points[27] = point4(10.0f, 14.0f, 0.0f, 1.0f); _points[28] = point4(0.0f, 19.0f, 0.0f, 1.0f); _points[29] = point4(0.0f, 28.0f, 0.0f, 1.0f); _points[30] = point4(0.0f, 19.0f, 0.0f, 1.0f); _points[31] = point4(-10.0f, 14.0f, 0.0f, 1.0f); _points[32] = point4(0.0f, 28.0f, 0.0f, 1.0f); _points[33] = point4(10.0f, 14.0f, 0.0f, 1.0f); _points[34] = point4(0.0f, 28.0f, 0.0f, 1.0f); _points[35] = point4(17.0f, 20.0f, 0.0f, 1.0f); _points[36] = point4(20.0f, 5.0f, 0.0f, 1.0f); _points[37] = point4(10.0f, 14.0f, 0.0f, 1.0f); _points[38] = point4(27.0f, 8.0f, 0.0f, 1.0f); _points[39] = point4(10.0f, 14.0f, 0.0f, 1.0f); _points[40] = point4(17.0f, 20.0f, 0.0f, 1.0f); _points[41] = point4(27.0f, 8.0f, 0.0f, 1.0f); _points[42] = point4(17.0f, -7.0f, 0.0f, 1.0f); _points[43] = point4(-17.0f, -2.0f, 0.0f, 1.0f); _points[44] = point4(28.0f, -2.0f, 0.0f, 1.0f); _points[45] = point4(-15.0f, -7.0f, 0.0f, 1.0f); _points[46] = point4(-17.0f, -2.0f, 0.0f, 1.0f); _points[47] = point4(17.0f, -7.0f, 0.0f, 1.0f); _points[48] = point4(17.0f, -22.0f, 0.0f, 1.0f); _points[49] = point4(17.0f, -7.0f, 0.0f, 1.0f); _points[50] = point4(28.0f, -2.0f, 0.0f, 1.0f); _points[51] = point4(11.0f, -16.0f, 0.0f, 1.0f); _points[52] = point4(17.0f, -7.0f, 0.0f, 1.0f); _points[53] = point4(17.0f, -22.0f, 0.0f, 1.0f); _points[54] = point4(0.0f, -18.0f, 0.0f, 1.0f); _points[55] = point4(11.0f, -16.0f, 0.0f, 1.0f); _points[56] = point4(17.0f, -22.0f, 0.0f, 1.0f); _points[57] = point4(0.0f, -18.0f, 0.0f, 1.0f); _points[58] = point4(17.0f, -22.0f, 0.0f, 1.0f); _points[59] = point4(0.0f, -28.0f, 0.0f, 1.0f); _colors[0] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[1] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[2] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[3] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[4] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[5] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[6] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[7] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[8] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[9] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[10] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[11] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[12] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[13] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[14] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[15] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[16] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[17] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[18] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[19] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[20] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[21] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[22] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[23] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[24] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[25] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[26] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[27] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[28] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[29] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[30] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[31] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[32] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[33] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[34] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[35] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[36] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[37] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[38] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[39] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[40] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[41] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[42] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[43] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[44] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[45] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[46] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[47] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[48] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[49] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[50] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[51] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[52] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[53] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[54] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[55] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[56] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[57] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[58] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _colors[59] = color4(0.11372549019607843f, 0.7137254901960784f, 0.9058823529411765f, 1.0f); _points[60] = point4(23.0f, -31.0f, 0.0f, 1.0f); _points[61] = point4(18.0f, -37.0f, 0.0f, 1.0f); _points[62] = point4(6.0f, -36.0f, 0.0f, 1.0f); _points[63] = point4(14.0f, -34.0f, 0.0f, 1.0f); _points[64] = point4(6.0f, -36.0f, 0.0f, 1.0f); _points[65] = point4(-17.0f, -17.0f, 0.0f, 1.0f); _points[66] = point4(-4.0f, -24.0f, 0.0f, 1.0f); _points[67] = point4(-17.0f, -17.0f, 0.0f, 1.0f); _points[68] = point4(-30.0f, 15.0f, 0.0f, 1.0f); _points[69] = point4(-22.0f, 30.0f, 0.0f, 1.0f); _points[70] = point4(-25.0f, 12.0f, 0.0f, 1.0f); _points[71] = point4(-30.0f, 15.0f, 0.0f, 1.0f); _points[72] = point4(20.0f, -32.0f, 0.0f, 1.0f); _points[73] = point4(23.0f, -24.0f, 0.0f, 1.0f); _points[74] = point4(23.0f, -31.0f, 0.0f, 1.0f); _points[75] = point4(-23.0f, 25.0f, 0.0f, 1.0f); _points[76] = point4(-22.0f, 30.0f, 0.0f, 1.0f); _points[77] = point4(-4.0f, 24.0f, 0.0f, 1.0f); _points[78] = point4(-17.0f, -4.0f, 0.0f, 1.0f); _points[79] = point4(-25.0f, 12.0f, 0.0f, 1.0f); _points[80] = point4(-30.0f, 15.0f, 0.0f, 1.0f); _colors[60] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[61] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[62] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[63] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[64] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[65] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[66] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[67] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[68] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[69] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[70] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[71] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[72] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[73] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[74] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[75] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[76] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[77] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[78] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[79] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); _colors[80] = color4(0.9372549019607843f, 0.7019607843137254f, 0.03137254901960784f, 1.0f); transform = new Transform(); transform->Init(_points, _colors, SYABON_NUM, matModelView, matProjection, shaderHandle); transform->position = initPos; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //MUST SET ORIGINAL COLORS originColor = std::vector<color4>(_colors, _colors + (int)(sizeof(_colors) / sizeof(_colors[0]))); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! move = new TraceMove(transform, SYABON_MOVE_SPEED, pPlayer->transform); collider = new CircleCollider(SYABON_RADIUS, this->transform->position); shootTimer = new CountDownTimer(SHOOT_CD); } Syabon::~Syabon() { if (move != NULL)delete move; } Syabon::Syabon(const Syabon& h) :Enemy(h) { memcpy(_points, h._points, sizeof(h._points)); memcpy(_colors, h._colors, sizeof(h._colors)); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //TOFIX:CHECK IF THIS RIGHT WAY move = new TraceMove(*h.move); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } Syabon& Syabon::operator=(const Syabon h) { if (&h != this) { if (move != NULL)delete move; memcpy(_points, h._points, sizeof(h._points)); memcpy(_colors, h._colors, sizeof(h._colors)); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //TOFIX:CHECK IF THIS RIGHT WAY move = new TraceMove(*h.move); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } return *this; }
4a1db8d333220f7bfca9fbb8e4e11e2231f6cbd6
c85c83f9bf77406e94da4c586cbb142eb8851799
/ProjectTempus 0.01/ContactListener.cpp
ae5b9bc28e211d3ecc770eabbe8bc786a5d36462
[]
no_license
RoughCookiexx/ActionPlatformerGame
684f0c27e5514b1140961681d3d07a9fc2ebffcd
4a550c16fb3c56b3207be19a95beb9b9a30a2fbf
refs/heads/master
2021-01-13T02:16:51.679757
2013-01-20T03:56:57
2013-01-20T03:56:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,017
cpp
#include "ContactListener.h" #include "SFML\System.hpp" #include "AnimatedSprite.h" ContactListener::ContactListener() : b2ContactListener() { /* ContactListener::numFootContacts = 0; jumpTimer = 0; */ } void ContactListener::BeginContact(b2Contact* contact) { void* bodyUserDataA = contact->GetFixtureA()->GetBody()->GetUserData(); void* bodyUserDataB = contact->GetFixtureB()->GetBody()->GetUserData(); if(bodyUserDataA && bodyUserDataB) { SpriteType typeA = static_cast<AnimatedSprite*>( bodyUserDataA )->getSpriteType(); SpriteType typeB = static_cast<AnimatedSprite*>( bodyUserDataB )->getSpriteType(); if( typeA == GOOD_BULLET && typeB == BADGUY) static_cast<AnimatedSprite*>( bodyUserDataB )->hurt(); if( typeB == GOOD_BULLET && typeA == BADGUY) static_cast<AnimatedSprite*>( bodyUserDataA )->hurt(); } /* //check if fixture A was the foot sensor void* fixtureUserData = contact->GetFixtureA()->GetUserData(); if ( (int)fixtureUserData == 3 ) numFootContacts++; //check if fixture B was the foot sensor fixtureUserData = contact->GetFixtureB()->GetUserData(); if ( (int)fixtureUserData == 3 ) numFootContacts++; */ } void ContactListener::EndContact(b2Contact* contact) { /* //check if fixture A was the foot sensor void* fixtureUserData = contact->GetFixtureA()->GetUserData(); if ( (int)fixtureUserData == 3 ) numFootContacts--; else if( (int)fixtureUserData == 0 ) ;//ignore //check if fixture B was the foot sensor fixtureUserData = contact->GetFixtureB()->GetUserData(); if ( (int)fixtureUserData == 3 ) numFootContacts--; else if( (int)fixtureUserData == 0 ) ;//ignore*/ } /* float ContactListener::getJumpTimer() { if ((TIME_BETWEEN_JUMPS + jumpTimer) < clock() ) jumpTimer = 0; return jumpTimer; }*/
4bf1f1dd8c382edb171a6a0852142d4a4a4cc277
1e461dda04106dd0cd033d8e41b43fa4e97d6ec8
/mesh.cpp
0699485c36a92583361616d79687f5cafd95a1ed
[]
no_license
Ave700/GeometryProcessing
79812bf7632047c8c8aa98d5cca860dd394192fe
462ce340d9d2106b0653f51fbe38416ba0304d0a
refs/heads/main
2023-01-11T04:40:47.877349
2020-11-17T18:37:27
2020-11-17T18:37:27
301,458,324
0
0
null
null
null
null
UTF-8
C++
false
false
23,183
cpp
#include "mesh.h" #include "Camera.h" #include <iterator> #include <omp.h> clock_t start, end; double cpu_time_used; Mesh::MeshEntry::MeshEntry() { VB = INVALID_OGL_VALUE; IB = INVALID_OGL_VALUE; NumIndices = 0; MaterialIndex = INVALID_MATERIAL; }; Mesh::MeshEntry::~MeshEntry() { if (VB != INVALID_OGL_VALUE) { glDeleteBuffers(1, &VB); } if (IB != INVALID_OGL_VALUE) { glDeleteBuffers(1, &IB); } } void Mesh::MeshEntry::Init(const std::vector<Vertex>& Vertices, const std::vector<unsigned int>& Indices) { NumIndices = Indices.size(); glGenBuffers(1, &VB); glBindBuffer(GL_ARRAY_BUFFER, VB); glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * Vertices.size(), &Vertices[0], GL_STATIC_DRAW); glGenBuffers(1, &IB); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IB); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * NumIndices, &Indices[0], GL_STATIC_DRAW); } Mesh::Mesh() { } Mesh::~Mesh() { Clear(); } void Mesh::Clear() { for (unsigned int i = 0; i < m_Textures.size(); i++) { SAFE_DELETE(m_Textures[i]); } } bool Mesh::LoadMesh(const std::string& Filename) { //Get rid of previous mesh Clear(); bool Ret = false; Assimp::Importer Importer; start = clock(); const aiScene* pScene = Importer.ReadFile(Filename.c_str(), aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_JoinIdenticalVertices); end = clock(); cpu_time_used = ((double)(end-start)/CLOCKS_PER_SEC); qInfo("Mesh loaded from file in: %lfs", cpu_time_used); if (pScene) { Ret = InitFromScene(pScene, Filename); } else { fprintf(stderr, "Error parsing '%s' : '%s'\n", Filename.c_str(), Importer.GetErrorString()); } return Ret; } bool Mesh::InitFromScene(const aiScene* pScene, const std::string& Filename) { //reallocating vectors to new size m_Entries.resize(pScene->mNumMeshes); m_Textures.resize(pScene->mNumMaterials); for (unsigned int i = 0; i < m_Entries.size(); i++) { const aiMesh* paiMesh = pScene->mMeshes[i]; start = clock(); InitMesh(i, paiMesh); end = clock(); cpu_time_used = ((double)(end-start)/CLOCKS_PER_SEC); qInfo("Mesh processed in: %lfs", cpu_time_used); InitBBox(paiMesh); //may not need to happen here //InitBSphere(paiMesh); } return true; //return InitMaterials(pScene, Filename); } //Built around triangle meshes void Mesh::InitMesh(unsigned int Index, const aiMesh* paiMesh) { //Mesh attribute checks if(!paiMesh->HasNormals()){ qInfo("Mesh does not contain normals"); } if(!paiMesh->HasTangentsAndBitangents()){ qInfo("Mesh has tangents and bittangets"); } if(paiMesh->HasBones()){ qInfo("Mesh contains bones"); } m_Mesh = paiMesh; m_Entries[Index].MaterialIndex = paiMesh->mMaterialIndex; const aiVector3D Zero3D(0.0f, 0.0f, 0.0f); //adding vertices to arrays start = clock(); for (unsigned int i = 0; i < paiMesh->mNumVertices; i++) { const aiVector3D* pPos = &(paiMesh->mVertices[i]); const aiVector3D* pNormal = &(paiMesh->mNormals[i]); //qInfo("x: %f\t y: %f\t z: %f", paiMesh->mNormals[i].x, paiMesh->mNormals[i].y, paiMesh->mNormals[i].z); const aiVector3D* pTexCoord = paiMesh->HasTextureCoords(0) ? &(paiMesh->mTextureCoords[0][i]) : &Zero3D; Vertex v(QVector3D(pPos->x, pPos->y, pPos->z), QVector2D(pTexCoord->x, pTexCoord->y), QVector3D(pNormal->x, pNormal->y, pNormal->z).normalized()); m_Vertices.push_back(v); } end = clock(); cpu_time_used = ((double)(end-start)/CLOCKS_PER_SEC); qInfo("Vertices pushed in: %lfs", cpu_time_used); //adding indices, edges, and faces to respective arrays -- This is convuluted so i tried to include a lot of comments for (uint i = 0; i < paiMesh->mNumFaces; i++) { //printf("Processing face %d\n", i); const aiFace& aiFace = paiMesh->mFaces[i]; std::vector<int> thisFaceIndices; assert(aiFace.mNumIndices == 3); //I find it easier to have these values in vector vs array for (int k = 0; k < 3; k++) { thisFaceIndices.push_back(aiFace.mIndices[k]); } //creation of first edges Im sad to do this but it should fix the for loop Face newFace; if (i == 0) { Edge newE01; newE01.relatedVertIndices.push_back(thisFaceIndices[0]); newE01.relatedVertIndices.push_back(thisFaceIndices[1]); newE01.relatedFaceIndices.push_back(m_Faces.size()); newFace.relatedEdgeIndices.push_back(m_Edges.size()); m_Edges.push_back(newE01); //create new edge for 0 - 2 Edge newE02; newE02.relatedVertIndices.push_back(thisFaceIndices[0]); newE02.relatedVertIndices.push_back(thisFaceIndices[2]); newE02.relatedFaceIndices.push_back(m_Faces.size()); newFace.relatedEdgeIndices.push_back(m_Edges.size()); m_Edges.push_back(newE02); // Edge newE12; newE12.relatedVertIndices.push_back(thisFaceIndices[1]); newE12.relatedVertIndices.push_back(thisFaceIndices[2]); newE12.relatedFaceIndices.push_back(m_Faces.size()); newFace.relatedEdgeIndices.push_back(m_Edges.size()); m_Edges.push_back(newE12); } //Start new face //Face newFace; for (auto currentInd : thisFaceIndices) { m_Indices.push_back(currentInd); newFace.relatedVertIndices.push_back(currentInd); } //newFace.FindNormal(); std::sort(thisFaceIndices.begin(), thisFaceIndices.end()); int curEdgesSize = m_Edges.size(); bool e01 = false, e02 = false, e12 = false; //dont make edges each loop dumbo for (int i = 0; i < curEdgesSize; i++) { //printf("size of edges %d\n", m_Edges.size()); if (m_Edges[i].relatedVertIndices[0] == thisFaceIndices[0] && m_Edges[i].relatedVertIndices[1] == thisFaceIndices[1]) { m_Edges[i].relatedFaceIndices.push_back(m_Faces.size()); newFace.relatedEdgeIndices.push_back(i); e01 = true; //printf("found existing edge\n"); } if (m_Edges[i].relatedVertIndices[0] == thisFaceIndices[0] && m_Edges[i].relatedVertIndices[1] == thisFaceIndices[2]) { m_Edges[i].relatedFaceIndices.push_back(m_Faces.size()); newFace.relatedEdgeIndices.push_back(i); e02 = true; //printf("found existing edge\n"); } if (m_Edges[i].relatedVertIndices[0] == thisFaceIndices[1] && m_Edges[i].relatedVertIndices[1] == thisFaceIndices[2]) { m_Edges[i].relatedFaceIndices.push_back(m_Faces.size()); newFace.relatedEdgeIndices.push_back(i); //printf("found existing edge\n"); e12 = true; } } if (i != 0) { if (!e01) { //create new edge for 0 - 1 Edge newE01; newE01.relatedVertIndices.push_back(thisFaceIndices[0]); newE01.relatedVertIndices.push_back(thisFaceIndices[1]); newE01.relatedFaceIndices.push_back(m_Faces.size()); newFace.relatedEdgeIndices.push_back(m_Edges.size()); m_Edges.push_back(newE01); } if (!e02) { //create new edge for 0 - 2 Edge newE02; newE02.relatedVertIndices.push_back(thisFaceIndices[0]); newE02.relatedVertIndices.push_back(thisFaceIndices[2]); newE02.relatedFaceIndices.push_back(m_Faces.size()); newFace.relatedEdgeIndices.push_back(m_Edges.size()); m_Edges.push_back(newE02); } if (!e12) { //create new edge for 1 - 2 Edge newE12; newE12.relatedVertIndices.push_back(thisFaceIndices[1]); newE12.relatedVertIndices.push_back(thisFaceIndices[2]); newE12.relatedFaceIndices.push_back(m_Faces.size()); newFace.relatedEdgeIndices.push_back(m_Edges.size()); m_Edges.push_back(newE12); } } m_Faces.push_back(newFace); //end new face } FindAllFaceNormals(); FindAllFacePositions(); m_Entries[Index].Init(m_Vertices, m_Indices); qInfo("Vertices: %d", m_Vertices.size()); qInfo("Faces: %d", m_Faces.size()); } bool Mesh::InitMaterials(const aiScene* pScene, const std::string& Filename) { //Filepath modification/translation //return true; std::string::size_type SlashIndex = Filename.find_last_of("/"); std::string Dir; if (SlashIndex == std::string::npos) { Dir = "."; } else if (SlashIndex == 0) { Dir = "/"; } else { Dir = Filename.substr(0, SlashIndex); } bool Ret = true; // Initialize the materials for (unsigned int i = 0; i < pScene->mNumMaterials; i++) { const aiMaterial* pMaterial = pScene->mMaterials[i]; m_Textures[i] = NULL; if (pMaterial->GetTextureCount(aiTextureType_DIFFUSE) > 0) { aiString Path; if (pMaterial->GetTexture(aiTextureType_DIFFUSE, 0, &Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) { std::string FullPath = Dir + "/" + Path.data; m_Textures[i] = new Texture(GL_TEXTURE_2D, FullPath.c_str()); if (!m_Textures[i]->Load()) { printf("Error loading texture '%s'\n", FullPath.c_str()); delete m_Textures[i]; m_Textures[i] = NULL; Ret = false; } else { printf("Loaded texture '%s'\n", FullPath.c_str()); } } } // Load a white texture in case the model does not include its own texture if (!m_Textures[i]) { m_Textures[i] = new Texture(GL_TEXTURE_2D, "../../Models/white.png"); Ret = m_Textures[i]->Load(); } } return Ret; } void Mesh::InitBSphere(const aiMesh* paiMesh){ //Implementation of Ritters bounding sphere const aiVector3D* firstVertex = &(paiMesh->mVertices[0]); QVector3D startPoint = QVector3D(firstVertex->x, firstVertex->y, firstVertex->z); float maxDis = std::numeric_limits<float>::min(); //pick a point x on the model QVector3D pointX = startPoint; QVector3D pointY; //search for point y that is largest distance from point x for(unsigned int i = 1; i < paiMesh->mNumVertices; i++){ const aiVector3D* secondVertex = &(paiMesh->mVertices[i]); QVector3D temp_pointY = QVector3D(secondVertex->x, secondVertex->y, secondVertex->z); float disXtoY =pointX.distanceToPoint(temp_pointY); if( disXtoY > maxDis){ pointY = temp_pointY; maxDis = disXtoY; } } //reset maxdis maxDis = std::numeric_limits<float>::min(); //find point z which has largest distance from y QVector3D pointZ; for(unsigned int i = 0; i < paiMesh->mNumVertices; i++){ const aiVector3D* thirdVertex = &(paiMesh->mVertices[i]); QVector3D temp_pointZ = QVector3D(thirdVertex->x, thirdVertex->y, thirdVertex->z); float disYtoZ =pointY.distanceToPoint(temp_pointZ); if( disYtoZ > maxDis){ pointZ = temp_pointZ; maxDis = disYtoZ; } } //Setup initial ball with center at midpoint of y and z, and radius half dis between y and z. m_BoundingSphere.center = QVector3D((pointY.x()+pointZ.x())/2.0f, (pointY.y()+pointZ.y())/2.0f, (pointY.z()+pointZ.z())/2.0f); m_BoundingSphere.radius = maxDis/2.0f; bool pointOutside = true; while(pointOutside) { pointOutside = false; for(unsigned int i = 0; i < paiMesh->mNumVertices; i++){ const aiVector3D* secondVertex = &(paiMesh->mVertices[i]); QVector3D temp_point = QVector3D(secondVertex->x, secondVertex->y, secondVertex->z); if(m_BoundingSphere.center.distanceToPoint(temp_point) > m_BoundingSphere.radius){ startPoint = temp_point; qInfo("point outside sphere"); i = paiMesh->mNumVertices; //killing loop } } } float disCenterToCenter = m_BoundingSphere.center.distanceToPoint(QVector3D(0.0f,0.0f,0.0f)); qInfo("Distance to center: %f", disCenterToCenter); scaleBestFit = TARGETSCALE / disCenterToCenter; qInfo("Best fit scale: %f", scaleBestFit); m_BoundingSphere.center = -scaleBestFit * m_BoundingSphere.center; } void Mesh::InitBBox(const aiMesh* paiMesh) { //go through every vertices and find max and min x, y and z values //set min to max and max to min so anything smaller or greater will be saved. otherwise it will always be smallest float min = std::numeric_limits<float>::max(); float max = std::numeric_limits<float>::min(); float minX = min, minY = min, minZ = min; float maxX = max, maxY = max, maxZ = max; //seems good for parralellization //finding the smallest and greates x y and z values for (unsigned int i = 0; i < paiMesh->mNumVertices; i++) { const aiVector3D* curVertex = &(paiMesh->mVertices[i]); if (curVertex->x < minX){ minX = curVertex->x; } else if (curVertex->x > maxX) { maxX = curVertex->x; } if (curVertex->y < minY) { minY = curVertex->y; } else if (curVertex->y > maxY) { maxY = curVertex->y; } if (curVertex->z < minZ) { minZ = curVertex->z; } else if (curVertex->z > maxZ) { maxZ = curVertex->z; } } //To find best fit scale divide bestfit by current avg dim //Result is the scale needed float avgDim = pow(maxX,2)+pow(minX,2) + pow(maxY,2) + pow(minY,2)+ pow(maxZ,2)+ pow(minZ,2); avgDim = sqrt(avgDim); scaleBestFit = TARGETSCALE / avgDim; //qInfo("Best fit scale: %f", scaleBestFit); //Building the actual bounding box dimensions //defined at minx,miny,minz then moving around the face where y = min then moving to face y = max myBox.Vertices[0] = QVector3D(minX, minY, minZ); myBox.Vertices[1] = QVector3D(maxX, minY, minZ); myBox.Vertices[2] = QVector3D(maxX, minY, maxZ); myBox.Vertices[3] = QVector3D(minX, minY, maxZ); myBox.Vertices[4] = QVector3D(minX, maxY, minZ); myBox.Vertices[5] = QVector3D(maxX, maxY, minZ); myBox.Vertices[6] = QVector3D(maxX, maxY, maxZ); myBox.Vertices[7] = QVector3D(minX, maxY, maxZ); FindCenterBBox(); //finally calling center } //Finds average of all x, y, and z points from bounding box. void Mesh::FindCenterBBox() { float sumX = 0, sumY = 0, sumZ = 0; for (int i = 0; i < 8; i++) { sumX += myBox.Vertices[i].x(); sumY += myBox.Vertices[i].y(); sumZ += myBox.Vertices[i].z(); } //negates the adjusted center and times it by 2 to move to the models center instead of its base. //must be multiplied by scalar BBoxCenter = -QVector3D(sumX/8,sumY / 8,sumZ / 8); //Scaling bboxcenter vector to proper scale BBoxCenter = scaleBestFit * BBoxCenter; } void Mesh::DrawBBox() { glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_LINE_LOOP); for (int i = 0; i < 4; i++) { glVertex3f(myBox.Vertices[i].x(), myBox.Vertices[i].y(), myBox.Vertices[i].z()); } glEnd(); glBegin(GL_LINE_LOOP); for (int i = 4; i < 8; i++) { glVertex3f(myBox.Vertices[i].x(), myBox.Vertices[i].y(), myBox.Vertices[i].z()); } glEnd(); //crossing through center glBegin(GL_LINE_LOOP); glVertex3f(myBox.Vertices[1].x(), myBox.Vertices[1].y(), myBox.Vertices[1].z()); glVertex3f(myBox.Vertices[7].x(), myBox.Vertices[7].y(), myBox.Vertices[7].z()); glEnd(); glBegin(GL_LINE_LOOP); glVertex3f(myBox.Vertices[0].x(), myBox.Vertices[0].y(), myBox.Vertices[0].z()); glVertex3f(myBox.Vertices[6].x(), myBox.Vertices[6].y(), myBox.Vertices[6].z()); glEnd(); glBegin(GL_LINE_LOOP); glVertex3f(myBox.Vertices[2].x(), myBox.Vertices[2].y(), myBox.Vertices[2].z()); glVertex3f(myBox.Vertices[4].x(), myBox.Vertices[4].y(), myBox.Vertices[4].z()); glEnd(); glBegin(GL_LINE_LOOP); glVertex3f(myBox.Vertices[3].x(), myBox.Vertices[3].y(), myBox.Vertices[3].z()); glVertex3f(myBox.Vertices[5].x(), myBox.Vertices[5].y(), myBox.Vertices[5].z()); glEnd(); } void Mesh::Render() { glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); for (unsigned int i = 0; i < m_Entries.size(); i++) { glBindBuffer(GL_ARRAY_BUFFER, m_Entries[i].VB); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)12); glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid*)20); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_Entries[i].IB); glDrawElements(GL_TRIANGLES, m_Entries[i].NumIndices, GL_UNSIGNED_INT, 0); } glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glDisableVertexAttribArray(2); } void Mesh::RenderWireFrame(){ //Scale up slightly to avoid weak looking lines when not hollow float scaleFact = 1.0001; for(uint i = 0 ;i < m_Faces.size() ; i++){ glBegin(GL_LINE_LOOP); for(uint j = 0; j < m_Faces[i].relatedVertIndices.size(); j++){ Vertex* temp_v = &m_Vertices[m_Faces[i].relatedVertIndices[j]]; glVertex3f(temp_v->m_pos.x()*scaleFact,temp_v->m_pos.y()*scaleFact,temp_v->m_pos.z()*scaleFact); } glEnd(); } } void Mesh::FindAllFaceNormals() { //To find normal of surface with 3 points first find vector from one point (start) //to one of the remaining points (end1), and then again from start to the other point(end2) for (uint i = 0; i < m_Faces.size(); i++) { QVector3D Vec01 = m_Vertices[m_Faces[i].relatedVertIndices[0]].m_pos - m_Vertices[m_Faces[i].relatedVertIndices[1]].m_pos; QVector3D Vec02 = m_Vertices[m_Faces[i].relatedVertIndices[0]].m_pos - m_Vertices[m_Faces[i].relatedVertIndices[2]].m_pos; //Then find the cross product of these two vectors that lie in the plan, ez m_Faces[i].f_Normal = QVector3D::crossProduct(Vec01, Vec02); } } //Should work for higher order polygons void Mesh::FindAllFacePositions() { //For all faces sum the values of all related vertices for (uint i = 0; i < m_Faces.size(); i ++) { QVector3D sumVector(.0f, .0f, .0f); //summing vector for (auto curFaceVert : m_Faces[i].relatedVertIndices) { sumVector = sumVector + m_Vertices[curFaceVert].m_pos; } //divide results by number of related vertices m_Faces[i].f_CenterPos = sumVector / (float)m_Faces[i].relatedVertIndices.size(); //qInfo("FacePos1 X: %f\tY: %f\tZ: %f\n", curFace.x(), curFace.y(), curFace.z() ); } } void Mesh::FindCurrentContourEdges(QMatrix4x4 WVP, QVector3D CameraPos) { //First wipe all previous contour edges m_ContourEdges.clear(); //Must find all edges where one surface normal points towards camera and other points away for (uint i = 0; i < m_Edges.size(); i++) { //printf("loading contour"); //qInfo("Edge %d has %d faces attached\n", i,m_Edges[i].relatedFaceIndices.size() ); if (m_Edges[i].relatedFaceIndices.size() > 1) { if (m_Edges[i].relatedFaceIndices.size() > 2) { //qInfo("Error edge %d has %d faces attached\n", i,m_Edges[i].relatedFaceIndices.size()); } //Using the center of the faces to roughly determine viewpoint vector QVector4D facePos0 = WVP * QVector4D(m_Faces[m_Edges[i].relatedFaceIndices[0]].f_CenterPos,1); //qInfo("Face0 Center X: %f\tY: %f\tZ: %f\n", m_Faces[m_Edges[i].relatedFaceIndices[1]].f_CenterPos.x(), m_Faces[m_Edges[i].relatedFaceIndices[0]].f_CenterPos.y(), m_Faces[m_Edges[i].relatedFaceIndices[0]].f_CenterPos.z() ); QVector4D facePos1 = WVP * QVector4D(m_Faces[m_Edges[i].relatedFaceIndices[1]].f_CenterPos,1); //find vector from face center to viewer QVector3D face0toViewer = QVector3D(-(CameraPos) - QVector3D(facePos0.x(), facePos0.y(), facePos0.z())); face0toViewer.normalize(); QVector3D face1toViewer = QVector3D(-(CameraPos) - QVector3D(facePos1.x(), facePos1.y(), facePos1.z())); face0toViewer.normalize(); //qInfo("Face2View1 X: %f\tY: %f\tZ: %f\n", face0toViewer.x(), face0toViewer.y(), face0toViewer.z() ); //qInfo("Face2View2 X: %f\tY: %f\tZ: %f\n", face1toViewer.x(), face1toViewer.y(), face1toViewer.z() ); //find dot of cur face norm with vector from face to viewer float dotNorm1 = QVector3D::dotProduct(m_Faces[m_Edges[i].relatedFaceIndices[0]].CurNormal(WVP), face0toViewer); float dotNorm2 = QVector3D::dotProduct(m_Faces[m_Edges[i].relatedFaceIndices[1]].CurNormal(WVP), face1toViewer); if (dotNorm1 >= 0) { if (dotNorm2 <= 0) { //printf("found Contour\n"); m_ContourEdges.push_back(&m_Edges[i]); } } else if (dotNorm1 <= 0) { if (dotNorm2 >= 0) { //printf("found Contour\n"); m_ContourEdges.push_back(&m_Edges[i]); } } } else { //This happens if the edge only has 1 face attached, therefor either assignment is wrong or this is a contour edge m_ContourEdges.push_back(&m_Edges[i]); } } } void Mesh::FindCurrentContourVertices(QMatrix4x4 WVP, QVector3D CameraPos) { float zeroTolerance = .1f; //First wipe all current vertices m_ControurVertices.clear(); for (auto curVert : m_Vertices) { //rotate vector by world transforml QVector4D vertexPos = WVP * QVector4D(curVert.m_pos, 1); //find the vector from this vertex to the camera // QVector3D vertexToCam = QVector3D(((-1.0f*(CameraPos)) - QVector3D(vertexPos.x(), vertexPos.y(), vertexPos.z()))).normalized(); QVector3D vertexToCam = QVector3D(((-1.0f*(CameraPos)) - QVector3D(vertexPos.x(), vertexPos.y(), vertexPos.z()))); vertexToCam.normalize(); //qInfo("Vert to cam: x:%f\t y: %f\t z: %f", vertexToCam.x(), vertexToCam.y(), vertexToCam.z()); //Need to rotate the current vertex normal by the world view matrix QVector4D rotatedNorm4D = WVP * QVector4D(curVert.m_normal, 1); QVector3D rotatedNorm = QVector3D(rotatedNorm4D.x(),rotatedNorm4D.y(),rotatedNorm4D.z()).normalized() ; //qInfo("RotNorm x:%f\t y: %f\t z: %f", rotatedNorm.x(),rotatedNorm.y(), rotatedNorm.z() ); //find dot product of normal dot camera view float nDotv = QVector3D::dotProduct(rotatedNorm, vertexToCam); //printf("ndot value:%f\n", nDotv); if (nDotv < zeroTolerance && nDotv > (-1.0*zeroTolerance)) { m_ControurVertices.push_back(curVert); //printf("found contour Vertex\n"); } } //printf("found %d contour verts\n", m_ControurVertices.size()); } void Mesh::DrawContourByObjSpace(QMatrix4x4 WVP, QVector3D CameraTarget) { FindCurrentContourEdges(WVP, CameraTarget); //set color black glColor3f(0.0f,0.0f,0.0f); glBegin(GL_LINES); //printf("size of contour %d\n ", m_ContourEdges.size()); for (uint i = 0; i < m_ContourEdges.size(); i++) { float scaleFact = 1.01f; glVertex3f(m_Vertices[m_ContourEdges[i]->relatedVertIndices[0]].m_pos.x() * scaleFact, m_Vertices[m_ContourEdges[i]->relatedVertIndices[0]].m_pos.y() * scaleFact, m_Vertices[m_ContourEdges[i]->relatedVertIndices[0]].m_pos.z() * scaleFact); glVertex3f(m_Vertices[m_ContourEdges[i]->relatedVertIndices[1]].m_pos.x() * scaleFact, m_Vertices[m_ContourEdges[i]->relatedVertIndices[1]].m_pos.y() * scaleFact, m_Vertices[m_ContourEdges[i]->relatedVertIndices[1]].m_pos.z() * scaleFact); } glEnd(); } void Mesh::DrawContourByVertex(QMatrix4x4 WVP, QVector3D CameraTarget) { FindCurrentContourVertices(WVP, CameraTarget); glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_POINTS); for (auto curVert : m_ControurVertices) { glVertex3f(curVert.m_pos.x(), curVert.m_pos.y(), curVert.m_pos.z()); } glEnd(); }
8b12c36b29ad8908d594f2856a011fe59c1aaa3c
1906f0b18216a17525839ff332c715fbdec3b6af
/WORKSPACES/libraries/HCDotMatrix/HCDotMatrix.h
e835eea423b57e3e63fea958f9a1a0550b8de90f
[]
no_license
javiermartinalonso/ARDUINO
55595e2b045569a8f3bbaf72f3aa2bacc8ab7088
8f95eb1b9f3c88877ad4a14ee4bc48ed3fbb02d6
refs/heads/master
2021-01-17T14:55:34.323618
2018-01-04T13:03:45
2018-01-04T13:03:45
99,203,726
1
0
null
null
null
null
UTF-8
C++
false
false
7,502
h
/* FILE: HCDotMatrix.h DATE: 19/03/13 VERSION: 0.1 AUTHOR: Andrew Davies Library header for 8x8 dot matrix LED displays You may copy, alter and reuse this code in any way you like, but please leave reference to HobbyComponents.com in your comments if you redistribute this code. This software may not be used directly for the purpose of selling products that directly compete with Hobby Components Ltd's own range of products. THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER. */ #ifndef HCDotMatrix_h #define HCDotMatrix_h #include "Arduino.h" /* Font bitmap */ const int Char_Set[95][8] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Char ( ) {0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // Char (!) {0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00}, // Char (") {0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00}, // Char (#) {0x18, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0x18, 0x00}, // Char ($) {0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00}, // Char (%) {0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00}, // Char (&) {0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00}, // Char (') {0x0C, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00}, // Char (() {0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00}, // Char ()) {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // Char (*) {0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00}, // Char (+) {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30}, // Char (,) {0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00}, // Char (-) {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00}, // Char (.) {0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00}, // Char (/) {0x38, 0x6C, 0xC6, 0xD6, 0xC6, 0x6C, 0x38, 0x00}, // Char (0) {0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00}, // Char (1) {0x7C, 0xC6, 0x06, 0x1C, 0x30, 0x66, 0xFE, 0x00}, // Char (2) {0x7C, 0xC6, 0x06, 0x3C, 0x06, 0xC6, 0x7C, 0x00}, // Char (3) {0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00}, // Char (4) {0xFE, 0xC0, 0xC0, 0xFC, 0x06, 0xC6, 0x7C, 0x00}, // Char (5) {0x38, 0x60, 0xC0, 0xFC, 0xC6, 0xC6, 0x7C, 0x00}, // Char (6) {0xFE, 0xC6, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00}, // Char (7) {0x7C, 0xC6, 0xC6, 0x7C, 0xC6, 0xC6, 0x7C, 0x00}, // Char (8) {0x7C, 0xC6, 0xC6, 0x7E, 0x06, 0x0C, 0x78, 0x00}, // Char (9) {0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00}, // Char (:) {0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30}, // Char (;) {0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // Char (<) {0x00, 0x00, 0x7E, 0x00, 0x00, 0x7E, 0x00, 0x00}, // Char (=) {0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00}, // Char (>) {0x7C, 0xC6, 0x0C, 0x18, 0x18, 0x00, 0x18, 0x00}, // Char (?) {0x7C, 0xC6, 0xDE, 0xDE, 0xDE, 0xC0, 0x78, 0x00}, // Char (@) {0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x00}, // Char (A) {0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00}, // Char (B) {0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00}, // Char (C) {0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00}, // Char (D) {0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00}, // Char (E) {0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00}, // Char (F) {0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3A, 0x00}, // Char (G) {0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x00}, // Char (H) {0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00}, // Char (I) {0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00}, // Char (J) {0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00}, // Char (K) {0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00}, // Char (L) {0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00}, // Char (M) {0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00}, // Char (N) {0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00}, // Char (O) {0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00}, // Char (P) {0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xCE, 0x7C, 0x0E}, // Char (Q) {0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00}, // Char (R) {0x3C, 0x66, 0x30, 0x18, 0x0C, 0x66, 0x3C, 0x00}, // Char (S) {0x7E, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x3C, 0x00}, // Char (T) {0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00}, // Char (U) {0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00}, // Char (V) {0xC6, 0xC6, 0xC6, 0xD6, 0xD6, 0xFE, 0x6C, 0x00}, // Char (W) {0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 0x00}, // Char (X) {0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x3C, 0x00}, // Char (Y) {0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00}, // Char (Z) {0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00}, // Char ([) {0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00}, // Char (\) {0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00}, // Char (]) {0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00}, // Char (^) {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // Char (_) {0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00}, // Char (`) {0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00}, // Char (a) {0xE0, 0x60, 0x7C, 0x66, 0x66, 0x66, 0xDC, 0x00}, // Char (b) {0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC6, 0x7C, 0x00}, // Char (c) {0x1C, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00}, // Char (d) {0x00, 0x00, 0x7C, 0xC6, 0xFE, 0xC0, 0x7C, 0x00}, // Char (e) {0x3C, 0x66, 0x60, 0xF8, 0x60, 0x60, 0xF0, 0x00}, // Char (f) {0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8}, // Char (g) {0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00}, // Char (h) {0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00}, // Char (i) {0x06, 0x00, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3C}, // Char (j) {0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00}, // Char (k) {0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00}, // Char (l) {0x00, 0x00, 0xEC, 0xFE, 0xD6, 0xD6, 0xD6, 0x00}, // Char (m) {0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x00}, // Char (n) {0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00}, // Char (o) {0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0}, // Char (p) {0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E}, // Char (q) {0x00, 0x00, 0xDC, 0x76, 0x60, 0x60, 0xF0, 0x00}, // Char (r) {0x00, 0x00, 0x7E, 0xC0, 0x7C, 0x06, 0xFC, 0x00}, // Char (s) {0x30, 0x30, 0xFC, 0x30, 0x30, 0x36, 0x1C, 0x00}, // Char (t) {0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00}, // Char (u) {0x00, 0x00, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00}, // Char (v) {0x00, 0x00, 0xC6, 0xD6, 0xD6, 0xFE, 0x6C, 0x00}, // Char (w) {0x00, 0x00, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0xFC}, // Char (y) {0x00, 0x00, 0x7E, 0x4C, 0x18, 0x32, 0x7E, 0x00}, // Char (z) {0x0E, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0E, 0x00}, // Char ({) {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00}, // Char (|) {0x70, 0x18, 0x18, 0x0E, 0x18, 0x18, 0x70, 0x00}, // Char (}) {0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Char (~) }; class HCDotMatrix { public: HCDotMatrix(byte R0,byte R1,byte R2,byte R3,byte R4,byte R5,byte R6,byte R7, byte C0,byte C1,byte C2,byte C3,byte C4,byte C5,byte C6,byte C7); void UpdateMatrix(void); void print(char TextString[], unsigned int xoffset); private: byte _PinOut_Row[8]; byte _PinOut_Col[8]; byte _Cur_Row; byte _Cur_Col; byte _CurentBitmap[8]; int _FirstCharIndex; byte _FirstCharColOffset; byte _FirstCharLength; byte _SecondCharLength; byte _RowIndex; byte _ColIndex; byte _Bufferindex; int _StringLength; }; #endif
7db1076ebab02c90039f71422216cb0c7e8d994d
b70bc321184644a45ed964ed6692f98258a52890
/Principles of programming/HW2/6/6c.cpp
8d12dfacd51903dccfa8887c6910cf5e674d4c38
[]
no_license
mmaghajani/courses
e244cc14d1f874941d6a7f03180bcb4383f2bf06
4844527bea68b4fc2e271d9c2a1e2c4ea28a53f5
refs/heads/master
2021-03-27T20:43:15.497222
2018-07-22T19:26:55
2018-07-22T19:26:55
89,038,279
11
0
null
null
null
null
UTF-8
C++
false
false
510
cpp
#include <iostream> #include <math.h> using namespace std; double fact( int ) ; int main() { int n ; double e = 1 , x ; cout <<"Pls enter estimate level :" ; cin >> n ; cout <<"Pls enter X :" ; cin >> x ; for( int i = 1 ; i <= n ; i++ ) e += pow(x,i-1) / fact( i ) ; cout << e << endl ; return 0 ; } //**************** factorial ************** double fact( int x ) { int product = 1 ; for( int i = 1 ; i <= x ; i++ ) product *= i ; return product ; }
9eff46d59f478d01bade665b1c7b0ee16ae702a7
00ef8d964caf4abef549bbeff81a744c282c8c16
/content/browser/cache_storage/cache_storage_blob_to_disk_cache_unittest.cc
71a6e0888764a8997d3e5cc4c120fb295fcaa6b1
[ "BSD-3-Clause" ]
permissive
czhang03/browser-android-tabs
8295f466465e89d89109659cff74d6bb9adb8633
0277ceb50f9a90a2195c02e0d96da7b157f3b192
refs/heads/master
2023-02-16T23:55:29.149602
2018-09-14T07:46:16
2018-09-14T07:46:16
149,174,398
1
0
null
null
null
null
UTF-8
C++
false
false
8,484
cc
// Copyright 2015 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/browser/cache_storage/cache_storage_blob_to_disk_cache.h" #include <string> #include <utility> #include "base/files/file_path.h" #include "base/macros.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/test/null_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "content/browser/blob_storage/chrome_blob_storage_context.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/storage_partition.h" #include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_thread_bundle.h" #include "net/disk_cache/disk_cache.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_job_factory_impl.h" #include "storage/browser/blob/blob_data_builder.h" #include "storage/browser/blob/blob_impl.h" #include "storage/browser/blob/blob_storage_context.h" #include "storage/browser/blob/blob_url_request_job_factory.h" #include "testing/gtest/include/gtest/gtest.h" namespace content { namespace { const char kTestData[] = "Hello World"; const char kEntryKey[] = "FooEntry"; const int kCacheEntryIndex = 1; class NullURLRequestContextGetter : public net::URLRequestContextGetter { public: NullURLRequestContextGetter() : null_task_runner_(new base::NullTaskRunner) {} net::URLRequestContext* GetURLRequestContext() override { return nullptr; } scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const override { return null_task_runner_; } private: ~NullURLRequestContextGetter() override {} scoped_refptr<base::SingleThreadTaskRunner> null_task_runner_; }; // Returns a BlobProtocolHandler that uses |blob_storage_context|. Caller owns // the memory. std::unique_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( storage::BlobStorageContext* blob_storage_context) { return std::make_unique<storage::BlobProtocolHandler>(blob_storage_context); } // A CacheStorageBlobToDiskCache that can delay reading from blobs. class TestCacheStorageBlobToDiskCache : public CacheStorageBlobToDiskCache { public: TestCacheStorageBlobToDiskCache() {} ~TestCacheStorageBlobToDiskCache() override {} void ContinueReadFromBlob() { CacheStorageBlobToDiskCache::ReadFromBlob(); } void set_delay_blob_reads(bool delay) { delay_blob_reads_ = delay; } protected: void ReadFromBlob() override { if (delay_blob_reads_) return; ContinueReadFromBlob(); } private: bool delay_blob_reads_ = false; DISALLOW_COPY_AND_ASSIGN(TestCacheStorageBlobToDiskCache); }; class CacheStorageBlobToDiskCacheTest : public testing::Test { protected: CacheStorageBlobToDiskCacheTest() : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), browser_context_(new TestBrowserContext()), url_request_context_getter_( BrowserContext::GetDefaultStoragePartition(browser_context_.get())-> GetURLRequestContext()), cache_storage_blob_to_disk_cache_( new TestCacheStorageBlobToDiskCache()), data_(kTestData), callback_success_(false), callback_called_(false) {} void SetUp() override { InitBlobStorage(); InitURLRequestJobFactory(); InitBlob(); InitCache(); } void InitBlobStorage() { ChromeBlobStorageContext* blob_storage_context = ChromeBlobStorageContext::GetFor(browser_context_.get()); base::RunLoop().RunUntilIdle(); blob_storage_context_ = blob_storage_context->context(); } void InitURLRequestJobFactory() { url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); url_request_job_factory_->SetProtocolHandler( "blob", CreateMockBlobProtocolHandler(blob_storage_context_)); net::URLRequestContext* url_request_context = url_request_context_getter_->GetURLRequestContext(); url_request_context->set_job_factory(url_request_job_factory_.get()); } void InitBlob() { auto blob_data = std::make_unique<storage::BlobDataBuilder>("blob-id:myblob"); blob_data->AppendData(data_); blob_handle_ = blob_storage_context_->AddFinishedBlob(std::move(blob_data)); } void InitCache() { int rv = CreateCacheBackend( net::MEMORY_CACHE, net::CACHE_BACKEND_DEFAULT, base::FilePath(), (CacheStorageBlobToDiskCache::kBufferSize * 100) /* max bytes */, false /* force */, nullptr /* net log */, &cache_backend_, base::DoNothing()); // The memory cache runs synchronously. EXPECT_EQ(net::OK, rv); EXPECT_TRUE(cache_backend_); std::unique_ptr<disk_cache::Entry*> entry(new disk_cache::Entry*()); disk_cache::Entry** entry_ptr = entry.get(); rv = cache_backend_->CreateEntry(kEntryKey, entry_ptr, base::DoNothing()); EXPECT_EQ(net::OK, rv); disk_cache_entry_.reset(*entry); } std::string ReadCacheContent() { int bytes_to_read = disk_cache_entry_->GetDataSize(kCacheEntryIndex); scoped_refptr<net::IOBufferWithSize> buffer( new net::IOBufferWithSize(bytes_to_read)); int rv = disk_cache_entry_->ReadData(kCacheEntryIndex, 0 /* offset */, buffer.get(), buffer->size(), base::DoNothing()); EXPECT_EQ(bytes_to_read, rv); return std::string(buffer->data(), bytes_to_read); } bool Stream() { blink::mojom::BlobPtr blob_ptr; storage::BlobImpl::Create( std::make_unique<storage::BlobDataHandle>(*blob_handle_), MakeRequest(&blob_ptr)); cache_storage_blob_to_disk_cache_->StreamBlobToCache( std::move(disk_cache_entry_), kCacheEntryIndex, std::move(blob_ptr), base::BindOnce(&CacheStorageBlobToDiskCacheTest::StreamCallback, base::Unretained(this))); base::RunLoop().RunUntilIdle(); return callback_called_ && callback_success_; } void StreamCallback(disk_cache::ScopedEntryPtr entry_ptr, bool success) { disk_cache_entry_ = std::move(entry_ptr); callback_success_ = success; callback_called_ = true; } TestBrowserThreadBundle browser_thread_bundle_; std::unique_ptr<TestBrowserContext> browser_context_; std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; storage::BlobStorageContext* blob_storage_context_; scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; std::unique_ptr<storage::BlobDataHandle> blob_handle_; std::unique_ptr<disk_cache::Backend> cache_backend_; disk_cache::ScopedEntryPtr disk_cache_entry_; std::unique_ptr<TestCacheStorageBlobToDiskCache> cache_storage_blob_to_disk_cache_; std::string data_; bool callback_success_; bool callback_called_; }; TEST_F(CacheStorageBlobToDiskCacheTest, Stream) { EXPECT_TRUE(Stream()); EXPECT_STREQ(data_.c_str(), ReadCacheContent().c_str()); } TEST_F(CacheStorageBlobToDiskCacheTest, StreamLarge) { blob_handle_.reset(); base::RunLoop().RunUntilIdle(); data_ = std::string(CacheStorageBlobToDiskCache::kBufferSize * 4, '.'); InitBlob(); EXPECT_TRUE(Stream()); EXPECT_STREQ(data_.c_str(), ReadCacheContent().c_str()); } TEST_F(CacheStorageBlobToDiskCacheTest, TestDelayMidStream) { cache_storage_blob_to_disk_cache_->set_delay_blob_reads(true); // The operation should stall while reading from the blob. EXPECT_FALSE(Stream()); EXPECT_FALSE(callback_called_); // Verify that continuing results in a completed operation. cache_storage_blob_to_disk_cache_->set_delay_blob_reads(false); cache_storage_blob_to_disk_cache_->ContinueReadFromBlob(); base::RunLoop().RunUntilIdle(); EXPECT_TRUE(callback_called_); EXPECT_TRUE(callback_success_); } TEST_F(CacheStorageBlobToDiskCacheTest, DeleteMidStream) { cache_storage_blob_to_disk_cache_->set_delay_blob_reads(true); // The operation should stall while reading from the blob. EXPECT_FALSE(Stream()); // Deleting the BlobToDiskCache mid-stream shouldn't cause a crash. cache_storage_blob_to_disk_cache_.reset(); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(callback_called_); } } // namespace } // namespace content
781ca13e7b4de4edfdfa03926fa710e27a7228a5
2a7e77565c33e6b5d92ce6702b4a5fd96f80d7d0
/fuzzedpackages/Bayesrel/src/LowBoundsCpp.cpp
de6b9175f890c2c1ddb28c8586d746ceeff0a13f
[]
no_license
akhikolla/testpackages
62ccaeed866e2194652b65e7360987b3b20df7e7
01259c3543febc89955ea5b79f3a08d3afe57e95
refs/heads/master
2023-02-18T03:50:28.288006
2021-01-18T13:23:32
2021-01-18T13:23:32
329,981,898
7
1
null
null
null
null
UTF-8
C++
false
false
1,082
cpp
#include <RcppArmadillo.h> //[[Rcpp::depends(RcppArmadillo)]] //[[Rcpp::export]] double alphaArma(const arma::mat& X) { double k = X.n_cols; double out = k / (k - 1.0) * (1.0 - arma::trace(X) / arma::accu(X)); return out; } //[[Rcpp::export]] double l2Arma(const arma::mat& X) { double k = X.n_cols, s = 0.0, s2 = 0.0; for (unsigned int i = 0; i < X.n_cols - 1; i++) for (unsigned int j = i + 1; j < X.n_rows; j++) { s += 2.0 * X(i, j); s2 += 2.0 * X(i, j) * X(i, j); } double s3 = s + arma::accu(X.diag()); double out = (s + std::sqrt(k / (k - 1) * s2)) / s3; return out; } //[[Rcpp::export]] double l6Arma(const arma::mat& X) { // correlation matrix from covariance matrix: arma::vec sds = 1/arma::sqrt(X.diag()); arma::mat Xcor = arma::diagmat(sds) * X * arma::diagmat(sds); Xcor.diag().ones(); arma::mat XCorInv = arma::inv_sympd(Xcor); arma::vec smc = 1 - 1 / XCorInv.diag(); double out = 1 - arma::accu(1 - smc) / arma::accu(Xcor); return out; }
2eabb0cc5d02ce90748d4b6714086fde75536fe0
625cc2d9c1b87a06c88d2ec056a004b19c1e6b9c
/include/elk/object_extensions/framebuffer_quad.h
28f4155ac30e4912460f0b08ffa30d8ec7a0a848
[ "MIT" ]
permissive
leoking01/ElkEngine
07b3bf40f4a223359bbd93ad2af02ceb7cd8e1d5
ba16e94eaf44567d8947dbf1025f23241808ff37
refs/heads/master
2022-01-17T07:10:33.993794
2019-02-25T06:10:12
2019-02-25T06:10:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,597
h
#pragma once #include "elk/core/object_3d.h" #include "elk/core/mesh.h" #include "elk/core/texture.h" #include "elk/core/frame_buffer_object.h" #include "elk/core/render_buffer_object.h" #include "elk/core/texture_unit.h" #include <vector> #include <memory> namespace elk { namespace core { class FrameBufferQuad { public: // Texture, attachment, name using RenderTexture = std::tuple<std::shared_ptr<Texture>, GLenum, std::string>; using RenderTextureInfo = std::tuple<int, std::string>; enum class UseDepthBuffer { YES, NO }; FrameBufferQuad( int width, int height, std::vector<RenderTexture> render_textures, UseDepthBuffer depth_buffer = UseDepthBuffer::NO); ~FrameBufferQuad(); void bindTextures(); // Binds the texture units indexed by render_textures and removes usage of // all other texture units in use. Using the string provided in render_texture_info // as sampler name instead of the one specified for the actual render texture. void bindTextures(const std::vector<RenderTextureInfo>& render_texture_info); void generateMipMaps(); void freeTextureUnits(); void render(); void bindFBO(); inline void unbindFBO() { _fbo.unbind(); }; inline int width() { return _width; }; inline int height() { return _height; }; private: int _width, _height; std::shared_ptr<Mesh> _quad; FrameBufferObject _fbo; std::vector<RenderTexture> _render_textures; std::unique_ptr<RenderBufferObject> _depth_buffer; std::vector<TextureUnit> _texture_units_in_use; // Cached color attachments std::vector<GLenum> _color_attachments; }; } }
af8805d5d465ed0b4a1dd138eabc68505f98a836
dc596e0cfd467cf7077e699f7fd8434765ab217c
/graph_app/color/coloring_max.cpp
5924680b5be2ba56baaa3b7c693df79c55fe0d7e
[]
no_license
powerjg/pannotia
41293bc793de3a78131888e930d22fa35a5de4e6
050425129cb8ccc07b3394f6c52559a63d11160a
refs/heads/master
2021-01-01T16:28:34.427969
2017-07-20T21:20:59
2017-07-20T21:20:59
97,841,453
1
0
null
2017-07-20T13:56:37
2017-07-20T13:56:37
null
UTF-8
C++
false
false
19,824
cpp
/************************************************************************************\ * * * Copyright © 2014 Advanced Micro Devices, Inc. * * All rights reserved. * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted provided that the following are met: * * * * You must reproduce the above copyright notice. * * * * Neither the name of the copyright holder nor the names of its contributors * * may be used to endorse or promote products derived from this software * * without specific, prior, written permission from at least the copyright holder. * * * * You must include the following terms in your license and/or other materials * * provided with the software. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * * IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, AND FITNESS FOR A * * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * * OF SUCH DAMAGE. * * * * Without limiting the foregoing, the software may implement third party * * technologies for which you must obtain licenses from parties other than AMD. * * You agree that AMD has not obtained or conveyed to you, and that you shall * * be responsible for obtaining the rights to use and/or distribute the applicable * * underlying intellectual property rights related to the third party technologies. * * These third party technologies are not licensed hereunder. * * * * If you use the software (in whole or in part), you shall adhere to all * * applicable U.S., European, and other export laws, including but not limited to * * the U.S. Export Administration Regulations ("EAR") (15 C.F.R Sections 730-774), * * and E.U. Council Regulation (EC) No 428/2009 of 5 May 2009. Further, pursuant * * to Section 740.6 of the EAR, you hereby certify that, except pursuant to a * * license granted by the United States Department of Commerce Bureau of Industry * * and Security or as otherwise permitted pursuant to a License Exception under * * the U.S. Export Administration Regulations ("EAR"), you will not (1) export, * * re-export or release to a national of a country in Country Groups D:1, E:1 or * * E:2 any restricted technology, software, or source code you receive hereunder, * * or (2) export to Country Groups D:1, E:1 or E:2 the direct product of such * * technology or software, if such foreign produced direct product is subject to * * national security controls as identified on the Commerce Control List (currently * * found in Supplement 1 to Part 774 of EAR). For the most current Country Group * * listings, or for additional information about the EAR or your obligations under * * those regulations, please refer to the U.S. Bureau of Industry and Security's * * website at http://www.bis.doc.gov/. * * * \************************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #include <CL/cl.h> #include "../../graph_parser/parse.h" #include "../../graph_parser/util.h" int initialize(int use_gpu); int shutdown(); void print_vector(int *vector, int num); // OpenCL variables static cl_context context; static cl_command_queue cmd_queue; static cl_device_type device_type; static cl_device_id * device_list; static cl_int num_devices; int main(int argc, char **argv){ char *tmpchar; char *filechar; int num_nodes; int num_edges; int use_gpu = 1; int file_format = 1; bool directed = 0; cl_int err = 0; if(argc == 4){ tmpchar = argv[1]; //graph inputfile filechar = argv[2]; //kernel file file_format = atoi(argv[3]); //graph format } else{ fprintf(stderr, "You did something wrong!\n"); exit(1); } srand(7); //allocate the CSR structure csr_array *csr = (csr_array *)malloc(sizeof(csr_array)); if (!csr) fprintf(stderr, "csr array malloc failed\n"); //parse graph file and store into a CSR format if (file_format == 1) csr = parseMetis(tmpchar, &num_nodes, &num_edges, directed); else if (file_format == 0) csr = parseCOO(tmpchar, &num_nodes, &num_edges, directed); else{ printf("reserve for future"); exit(1); } //alloate the vertex value array float *node_value = (float *)malloc(num_nodes * sizeof(float)); if(!node_value) fprintf(stderr, "node_value malloc failed\n"); //allocate the color array int *color = (int *)malloc(num_nodes * sizeof(int)); if(!color) fprintf(stderr, "color malloc failed\n"); //initialize all the colors to -1 //randomize the value for each vertex for(int i = 0; i < num_nodes; i++){ color[i] = -1; node_value[i] = rand()/(float)RAND_MAX; } //load the OpenCL kernel file int sourcesize = 1024*1024; char * source = (char *)calloc(sourcesize, sizeof(char)); if(!source) { fprintf(stderr, "ERROR: calloc(%d) failed\n", sourcesize); return -1; } FILE * fp = fopen(filechar, "rb"); if(!fp) { printf("ERROR: unable to open '%s'\n", filechar); return -1; } fread(source + strlen(source), sourcesize, 1, fp); fclose(fp); // OpenCL initialization if(initialize(use_gpu)) return -1; //create the OpenCL program const char * slist[2] = { source, 0 }; cl_program prog = clCreateProgramWithSource(context, 1, slist, NULL, &err); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clCreateProgramWithSource() => %d\n", err); return -1; } err = clBuildProgram(prog, 0, NULL, NULL, NULL, NULL); { // show warnings/errors static char log[65536]; memset(log, 0, sizeof(log)); cl_device_id device_id = 0; err = clGetContextInfo(context, CL_CONTEXT_DEVICES, sizeof(device_id), &device_id, NULL); clGetProgramBuildInfo(prog, device_id, CL_PROGRAM_BUILD_LOG, sizeof(log)-1, log, NULL); if(err || strstr(log,"warning:") || strstr(log, "error:")) printf("<<<<\n%s\n>>>>\n", log); } if(err != CL_SUCCESS) { printf("ERROR: clBuildProgram() => %d\n", err); return -1; } // create kernel files cl_kernel kernel1, kernel2; char * kernelpr1 = "color"; char * kernelpr2 = "color2"; kernel1 = clCreateKernel(prog, kernelpr1, &err); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clCreateKernel() 1 => %d\n", err); return -1; } kernel2 = clCreateKernel(prog, kernelpr2, &err); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clCreateKernel() 2 => %d\n", err); return -1; } clReleaseProgram(prog); cl_mem row_d; cl_mem col_d; cl_mem max_d; cl_mem color_d; cl_mem node_value_d; cl_mem stop_d; //create device-side buffers for the graph row_d = clCreateBuffer(context, CL_MEM_READ_WRITE, num_nodes * sizeof(int), NULL, &err ); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clCreateBuffer row_d (size:%d) => %d\n", num_nodes , err); return -1;} col_d = clCreateBuffer(context, CL_MEM_READ_WRITE, num_edges * sizeof(int), NULL, &err ); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clCreateBuffer col_d (size:%d) => %d\n", num_edges , err); return -1;} //termination variable stop_d = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int), NULL, &err ); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clCreateBuffer stop_d (size:%d) => %d\n", 1 , err); return -1;} //create device-side buffers for color color_d = clCreateBuffer(context,CL_MEM_READ_WRITE, num_nodes * sizeof(int), NULL, &err ); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clCreateBuffer color_d (size:%d) => %d\n", num_nodes , err); return -1;} node_value_d = clCreateBuffer(context,CL_MEM_READ_WRITE, num_nodes * sizeof(float), NULL, &err ); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clCreateBuffer node_value_d (size:%d) => %d\n", num_nodes , err); return -1;} max_d = clCreateBuffer(context, CL_MEM_READ_WRITE, num_nodes * sizeof(float), NULL, &err ); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clCreateBuffer max_d (size:%d) => %d\n", num_nodes , err); return -1;} //copy data to device-side buffers double timer1=gettime(); err = clEnqueueWriteBuffer(cmd_queue, color_d, 1, 0, num_nodes * sizeof(int), color, 0, 0, 0); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clEnqueueWriteBuffer color_d (size:%d) => %d\n", num_nodes, err); return -1; } err = clEnqueueWriteBuffer(cmd_queue, max_d, 1, 0, num_nodes * sizeof(int), color, 0, 0, 0); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clEnqueueWriteBuffer max_d (size:%d) => %d\n", num_nodes, err); return -1; } err = clEnqueueWriteBuffer(cmd_queue, row_d, 1, 0, num_nodes * sizeof(int), csr->row_array, 0, 0, 0); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clEnqueueWriteBuffer row_d (size:%d) => %d\n", num_nodes, err); return -1; } err = clEnqueueWriteBuffer(cmd_queue, col_d, 1, 0, num_edges * sizeof(int), csr->col_array, 0, 0, 0); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clEnqueueWriteBuffer col_d (size:%d) => %d\n", num_nodes, err); return -1; } err = clEnqueueWriteBuffer(cmd_queue, node_value_d, 1, 0, num_nodes * sizeof(float), node_value, 0, 0, 0); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: clEnqueueWriteBuffer node_value_d (size:%d) => %d\n", num_nodes, err); return -1; } int block_size = 256; int global_size = (num_nodes%block_size == 0)? num_nodes: (num_nodes/block_size + 1) * block_size; //set up kernel dimensions size_t local_work[3] = { block_size, 1, 1}; size_t global_work[3] = { global_size, 1, 1 }; int stop = 1; int graph_color = 1; //set up kernel args //kernel 1 clSetKernelArg(kernel1, 0, sizeof(void *), (void*) &row_d); clSetKernelArg(kernel1, 1, sizeof(void *), (void*) &col_d); clSetKernelArg(kernel1, 2, sizeof(void *), (void*) &node_value_d); clSetKernelArg(kernel1, 3, sizeof(void *), (void*) &color_d); clSetKernelArg(kernel1, 4, sizeof(void *), (void*) &stop_d); clSetKernelArg(kernel1, 5, sizeof(void *), (void*) &max_d); clSetKernelArg(kernel1, 7, sizeof(cl_int), (void*) &num_nodes); clSetKernelArg(kernel1, 8, sizeof(cl_int), (void*) &num_edges); //kernel 2 clSetKernelArg(kernel2, 0, sizeof(void *), (void*) &node_value_d); clSetKernelArg(kernel2, 1, sizeof(void *), (void*) &color_d); clSetKernelArg(kernel2, 2, sizeof(void *), (void*) &max_d); clSetKernelArg(kernel2, 4, sizeof(cl_int), (void*) &num_nodes); clSetKernelArg(kernel2, 5, sizeof(cl_int), (void*) &num_edges); //main computation loop double timer3=gettime(); while(stop){ stop = 0; //copy the termination variable to the device err = clEnqueueWriteBuffer(cmd_queue, stop_d, 1, 0, sizeof(int), &stop, 0, 0, 0); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: write stop_d\n", err);} clSetKernelArg(kernel1, 6, sizeof(cl_int), (void*) &graph_color); clSetKernelArg(kernel2, 3, sizeof(cl_int), (void*) &graph_color); //launch the color kernel 1 err = clEnqueueNDRangeKernel(cmd_queue, kernel1, 1, NULL, global_work, local_work, 0, 0, 0); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: kernel1 (%d)\n", err); return -1; } //launch the color kernel 2 err = clEnqueueNDRangeKernel(cmd_queue, kernel2, 1, NULL, global_work, local_work, 0, 0, 0); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: kernel2 (%d)\n", err); return -1; } err = clEnqueueReadBuffer(cmd_queue, stop_d, 1, 0, sizeof(int), &stop, 0, 0, 0); if(err != CL_SUCCESS) { fprintf(stderr, "ERROR: read stop_d\n", err);} //increment the color for the next iter graph_color++; } clFinish(cmd_queue); double timer4=gettime(); //copy back the color array err = clEnqueueReadBuffer(cmd_queue, color_d, 1, 0, num_nodes * sizeof(int), color, 0, 0, 0); if(err != CL_SUCCESS) { printf("ERROR: clEnqueueReadBuffer()=>%d failed\n", err); return -1; } double timer2=gettime(); //print out color and timing statistics printf("total number of colors used: %d\n", graph_color); printf("kernel time = %lf ms\n",(timer4-timer3)*1000); printf("kernel + memcpy time = %lf ms\n",(timer2-timer1)*1000); #if 1 //dump the color array into an output file print_vector(color, num_nodes); #endif //free host-side buffers free(node_value); free(color); csr->freeArrays(); free(csr); //free OpenCL buffers clReleaseMemObject(row_d); clReleaseMemObject(col_d); clReleaseMemObject(max_d); clReleaseMemObject(color_d); clReleaseMemObject(node_value_d); clReleaseMemObject(stop_d); //cleanup OpenCL variables shutdown(); return 0; } void print_vector(int *vector, int num){ FILE * fp = fopen("result.out", "w"); if(!fp) { printf("ERROR: unable to open result.txt\n");} for(int i = 0; i < num; i++) fprintf(fp, "%d: %d\n", i + 1, vector[i]); fclose(fp); } int initialize(int use_gpu) { cl_int result; size_t size; // create OpenCL context cl_platform_id platform_id; if (clGetPlatformIDs(1, &platform_id, NULL) != CL_SUCCESS) { printf("ERROR: clGetPlatformIDs(1,*,0) failed\n"); return -1; } cl_context_properties ctxprop[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platform_id, 0}; device_type = use_gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU; context = clCreateContextFromType( ctxprop, device_type, NULL, NULL, NULL ); if( !context ) { fprintf(stderr, "ERROR: clCreateContextFromType(%s) failed\n", use_gpu ? "GPU" : "CPU"); return -1; } // get the list of GPUs result = clGetContextInfo( context, CL_CONTEXT_DEVICES, 0, NULL, &size ); num_devices = (int) (size / sizeof(cl_device_id)); printf("num_devices = %d\n", num_devices); if( result != CL_SUCCESS || num_devices < 1 ) { fprintf(stderr, "ERROR: clGetContextInfo() failed\n"); return -1; } device_list = new cl_device_id[num_devices]; if( !device_list ) { fprintf(stderr, "ERROR: new cl_device_id[] failed\n"); return -1; } result = clGetContextInfo( context, CL_CONTEXT_DEVICES, size, device_list, NULL ); if( result != CL_SUCCESS ) { fprintf(stderr, "ERROR: clGetContextInfo() failed\n"); return -1; } // create command queue for the first device cmd_queue = clCreateCommandQueue( context, device_list[0], 0, NULL ); if( !cmd_queue ) { fprintf(stderr, "ERROR: clCreateCommandQueue() failed\n"); return -1; } return 0; } int shutdown() { // release resources if( cmd_queue ) clReleaseCommandQueue( cmd_queue ); if( context ) clReleaseContext( context ); if( device_list ) delete device_list; // reset all variables cmd_queue = 0; context = 0; device_list = 0; num_devices = 0; device_type = 0; return 0; }
b298754d8bcd54562c626b1b25d247482b0a1036
c21c8cba94f4f73aa23de98e555ef77bcab494f0
/GeeksforGeeks/Random-problems/number of groups with two or three nums sum div by 3.cpp
083359bc63f90ccea5bf9c9ea490dfa9b3f095f0
[]
no_license
hoatd/Ds-Algos-
fc3ed0c8c1b285fb558f53eeeaea2632e0ed03ae
1e74995433685f32ce75a036cd82460605024c49
refs/heads/master
2023-03-19T05:48:42.595330
2019-04-29T06:20:43
2019-04-29T06:20:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
567
cpp
#include<bits/stdc++.h> using namespace std; int a[100005]; const int mod = 1000000007; int main() { int t; cin>>t; int rem[3]; int n; while(t--) { memset(rem, 0, sizeof(rem)); cin>>n; for(int i=0; i<n; i++) { cin>>a[i]; rem[a[i]%3]++; } int ans = (rem[0]*(rem[0]-1))/2 + (rem[1]*rem[2]); ans += (rem[0]*(rem[0]-1)*(rem[0]-2))/6 + (rem[1]*(rem[1]-1)*(rem[1]-2))/6 + (rem[2]*(rem[2]-1)*(rem[2]-2))/6 + (rem[0]*rem[1]*rem[2]); cout<<ans<<endl; } return 0; }
4041c23f3e039b286e1a336dbde271677268cabd
046b675cb8529d1585a688f21563eb0209c94f19
/src/Control2012/libreoffice/com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp
ace8573360413b5c29d4684cc294120d1a0d5d42
[]
no_license
yoshi5534/schorsch-the-robot
a2a4bd35668600451e53bd8d7f879df90dcb9994
77eb8dcabaad5da3908d6b4b78a05985323f9ba4
refs/heads/master
2021-03-12T19:41:35.524173
2013-04-17T20:00:29
2013-04-17T20:00:29
32,867,962
0
0
null
null
null
null
UTF-8
C++
false
false
1,754
hpp
#ifndef INCLUDED_COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPER_HPP #define INCLUDED_COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPER_HPP #include "sal/config.h" #include "com/sun/star/xml/crypto/sax/XSAXEventKeeper.hdl" #include "com/sun/star/uno/XInterface.hpp" #include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/xml/wrapper/XXMLElementWrapper.hpp" #include "com/sun/star/xml/sax/XDocumentHandler.hpp" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/Type.hxx" #include "cppu/unotype.hxx" #include "osl/mutex.hxx" #include "rtl/ustring.hxx" #include "sal/types.h" namespace com { namespace sun { namespace star { namespace xml { namespace crypto { namespace sax { inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(::com::sun::star::xml::crypto::sax::XSAXEventKeeper const *) { static typelib_TypeDescriptionReference * the_type = 0; if ( !the_type ) { typelib_static_mi_interface_type_init( &the_type, "com.sun.star.xml.crypto.sax.XSAXEventKeeper", 0, 0 ); } return * reinterpret_cast< ::com::sun::star::uno::Type * >( &the_type ); } } } } } } } inline ::com::sun::star::uno::Type const & SAL_CALL getCppuType(::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::sax::XSAXEventKeeper > const *) SAL_THROW(()) { return ::cppu::UnoType< ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::sax::XSAXEventKeeper > >::get(); } ::com::sun::star::uno::Type const & ::com::sun::star::xml::crypto::sax::XSAXEventKeeper::static_type(void *) { return ::getCppuType(static_cast< ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::sax::XSAXEventKeeper > * >(0)); } #endif // INCLUDED_COM_SUN_STAR_XML_CRYPTO_SAX_XSAXEVENTKEEPER_HPP
[ "schorsch@localhost" ]
schorsch@localhost
a939f159e0bcd240d179fa0de188e4f53325e856
a41865ced08b9b9c155b4dfee10a9e75d7812ec6
/src/tlistporo/tad18.cpp
f171b1863199d7f13426d78615d5f20f22853520
[ "MIT" ]
permissive
carlosarismendi/data_structures
83b91b5c8d4650d8bc1fdf252731903c8dee28f3
38b9297f3e128a45963c5a2b62ab913596c7360b
refs/heads/main
2023-06-27T16:46:30.428601
2021-07-23T06:53:41
2021-07-23T06:53:41
374,985,206
0
0
null
null
null
null
UTF-8
C++
false
false
488
cpp
#include <iostream> using namespace std; #include "tporo.h" #include "dlist.h" int main(void) { TPoro a(1, 1, 1, (char *)"rojo"); TPoro b(2, 2, 2, (char *)"verde"); TPoro c(3, 3, 3, (char *)"azul"); TPoro d(4, 4, 4, (char *)"marron"); TPoro e(5, 5, 5, (char *)"gris"); dlist<TPoro> v; v.push_back(a); v.push_back(b); v.push_back(c); v.push_back(d); v.push_back(e); cout << v[1] << endl; v[1] = TPoro(9, 9, 9, (char *)"violeta"); cout << v[1] << endl; }
dee1129a8873f9d1e70acd049d40589e677b7a95
70c1d93fd809d767e7a10611a83425234d1f7a77
/Study/CP3/ch1/10141_2.cc
9fd63028909093daad2e4f6e854aae10c0e078ef
[]
no_license
BlinkingStar7/Problem_Solving
1e52348d3f013ab1849697894d7e30cf540697f8
9f115c831ffb70cd3dfedf6fbee782fba4cfc11a
refs/heads/master
2021-01-21T04:27:40.184818
2016-08-26T09:24:40
2016-08-26T09:24:40
51,363,595
0
0
null
null
null
null
UTF-8
C++
false
false
1,790
cc
// @BEGIN_OF_SOURCE_CODE #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string> #include <cctype> #include <stack> #include <queue> #include <list> #include <vector> #include <map> #include <sstream> #include <cmath> #include <bitset> #include <utility> #include <set> #include <ctime> #define Inf 2147483647 #define Pi acos(-1.0) #define N 1000000 #define LL long long #define F(i, n) for( int i = (0); i < (n); i++ ) #define Fs(i, sz) for( size_t i = 0; i < sz.size (); i++ ) #define Set(a, s) memset(a, s, sizeof (a)) inline LL Power(int b, int p) { LL r = 1; for ( int i = 1; i <= p; i++ ) r *= b; return r; } using namespace std; struct node { char companyName [80 + 20]; int compliance; int price; int r; } a [10000]; bool cmp(node p, node q) { // greater compliance should come first if (p.compliance > q.compliance) return true; if (p.compliance == q.compliance) { // lower price should come first if (p.price < q.price) return true; } return false; } int main () { int n; int p; bool blank = false; int cases = 0; while ( scanf ("%d %d", &n, &p) != EOF ) { getchar(); if ( n == 0 && p == 0 ) break; char itemName [80 + 20]; // don't need this input data F(i, n) { gets(itemName); } double price; F(i, p) { gets(a [i].companyName); scanf ("%lf %d", &price, &a [i].r); // keeping the price integer a [i].price = (int) (price * 100); getchar(); // keeping the compliance integer a [i].compliance = (a [i].r * N) / n; // don't need this input data F(j, a [i].r) { gets(itemName); } } sort(a, a + p, cmp); if (blank) printf ("\n"); blank = true; printf ("RFP #%d\n%s\n", ++cases, a [0].companyName); } return 0; } // @END_OF_SOURCE_CODE
94dfb13ab0992419b45fa1af31bd714db6117c8f
7f1fe71fe35d77f491f81bdb19f45c7d23a4ff23
/Cpp implementations/largest.cpp
c4a39aad0f93cded4fedb673580176d1ad74de51
[]
no_license
deepakshisud/Competitive-Coding
f796ef2a18a5c566d99b7e0c10fe34aa0795dc48
ed36afc433b0d2d20266721d13f9a0fdf076556c
refs/heads/main
2023-04-02T08:24:39.923931
2021-04-08T09:34:44
2021-04-08T09:34:44
305,584,845
0
0
null
null
null
null
UTF-8
C++
false
false
328
cpp
#include<iostream> using namespace std; int main() { cout<<"Enter the size of array"<<endl; int n; cin>>n; int a[n]; for(int i=0;i<n;i++) { cin>>a[i]; } int largest = INT_MIN; //INT_MIN = -infinity for(int i=0;i<n;i++){ if(a[i]>largest){ largest = a[i]; } } cout<<"The largest number "<<largest<<endl; }
f88c8a655bab43f94cc900d7cc468288501438c2
7881f25a43bf4d21555b6e8b5bf05e3260ee5e65
/zlibrary/ui/src/win32/w32widgets/W32DialogPanel.cpp
7bb9ec0615034b9676e60e815c4d80f984a8a67f
[]
no_license
euroelessar/FBReader
6340b2f6d47081182ef09249f06d3645f1af24b3
bf1d1154b381e1f42716ceb205717cec4b14dd6d
refs/heads/master
2021-01-16T18:53:28.430814
2014-01-28T02:22:56
2014-01-28T02:22:56
2,273,820
2
0
null
null
null
null
UTF-8
C++
false
false
7,569
cpp
/* * Copyright (C) 2007-2013 Geometer Plus <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ #include <ZLibrary.h> #include <ZLLanguageUtil.h> #include <ZLUnicodeUtil.h> #include "W32DialogPanel.h" #include "W32Control.h" #include "../../../../core/src/win32/util/W32WCHARUtil.h" #undef max static const int FirstControlId = 2001; std::map<HWND,W32DialogPanel*> W32DialogPanel::ourPanels; const std::string W32DialogPanel::PANEL_SELECTED_EVENT = "Dialog Panel: Selected"; const std::string W32DialogPanel::APPLY_BUTTON_PRESSED_EVENT = "Dialog Panel: Apply Button Pressed"; UINT W32DialogPanel::LAYOUT_MESSAGE = 0; static void allocateString(WORD *&p, const std::string &text) { ZLUnicodeUtil::Ucs2String ucs2Str; ::createNTWCHARString(ucs2Str, text); memcpy(p, ::wchar(ucs2Str), 2 * ucs2Str.size()); p += ucs2Str.size(); } W32DialogPanel::W32DialogPanel(HWND mainWindow, const std::string &caption) : W32ControlCollection(FirstControlId), myMainWindow(mainWindow), myCaption(caption), myAddress(0), myPanelWindow(0) { if (LAYOUT_MESSAGE == 0) { LAYOUT_MESSAGE = RegisterWindowMessageA("layout"); } } W32DialogPanel::~W32DialogPanel() { if (myAddress != 0) { delete[] myAddress; } if (myPanelWindow != 0) { ourPanels.erase(myPanelWindow); } } void W32DialogPanel::init(HWND dialogWindow) { myPanelWindow = dialogWindow; ShowScrollBar(myPanelWindow, SB_BOTH, false); ourPanels[myPanelWindow] = this; myElement->init(dialogWindow, this); } void W32DialogPanel::calculateSize() { myMinimumSize = myElement->minimumSize(); mySize = myMinimumSize; } W32Widget::Size W32DialogPanel::size() const { return mySize; } void W32DialogPanel::setSize(W32Widget::Size size) { mySize = size; myRealSize = size; } void W32DialogPanel::updateElementSize() { myElement->setPosition(0, 0, mySize); } DWORD W32DialogPanel::style() const { return DS_SHELLFONT | DS_CENTER | DS_MODALFRAME | WS_POPUPWINDOW | WS_CAPTION | WS_VSCROLL | WS_HSCROLL; } DLGTEMPLATE *W32DialogPanel::dialogTemplate() { if (myAddress != 0) { delete[] myAddress; } if ((mySize.Width == 0) && (mySize.Height == 0)) { calculateSize(); } updateElementSize(); const std::string fontName = "MS Shell Dlg"; int size = 14 + ZLUnicodeUtil::utf8Length(myCaption) + ZLUnicodeUtil::utf8Length(fontName) + myElement->allocationSize(); size += size % 2; myAddress = new WORD[size]; static const DWORD extendedStyle = ZLLanguageUtil::isRTLLanguage(ZLibrary::Language()) ? WS_EX_LAYOUTRTL : 0; WORD *p = myAddress; *p++ = LOWORD(style()); *p++ = HIWORD(style()); *p++ = LOWORD(extendedStyle); *p++ = HIWORD(extendedStyle); *p++ = myElement->controlNumber(); *p++ = 0; // X *p++ = 0; // Y *p++ = mySize.Width; *p++ = mySize.Height; *p++ = 0; *p++ = 0; allocateString(p, myCaption); *p++ = 8; // FONT SIZE -- should be always 8? allocateString(p, fontName); if ((p - myAddress) % 2 == 1) { p++; } short id = FirstControlId; myElement->allocate(p, id); return (DLGTEMPLATE*)myAddress; } void W32DialogPanel::setElement(W32WidgetPtr element) { myElement = element; } bool W32DialogPanel::commandCallback(WPARAM wParam) { W32Control *control = (*this)[LOWORD(wParam)]; if (control != 0) { control->commandCallback(HIWORD(wParam)); return true; } return false; } bool W32DialogPanel::notificationCallback(WPARAM wParam, LPARAM lParam) { W32Control *control = (*this)[LOWORD(wParam)]; if (control != 0) { control->notificationCallback(lParam); } return false; } bool W32DialogPanel::drawItemCallback(WPARAM wParam, DRAWITEMSTRUCT &di) { W32Control *control = (*this)[LOWORD(wParam)]; if (control != 0) { control->drawItemCallback(di); return true; } return false; } void W32DialogPanel::invalidate() { if (myPanelWindow != 0) { PostMessage(myPanelWindow, LAYOUT_MESSAGE, 0, 0); myDoLayout = true; } } void W32DialogPanel::layout() { if (myDoLayout) { calculateSize(); if (myRealSize.Width != 0) { mySize.Width = std::max(mySize.Width, myRealSize.Width); } if (myPanelWindow != 0) { RECT rectangle; rectangle.left = 0; rectangle.top = 0; rectangle.right = mySize.Width; rectangle.bottom = mySize.Height; MapDialogRect(myPanelWindow, &rectangle); RECT realRectangle; GetClientRect(myPanelWindow, &realRectangle); bool hOversized = rectangle.right > realRectangle.right + 1; bool vOversized = rectangle.bottom > realRectangle.bottom + 1; int rightBound = realRectangle.right; int bottomBound = realRectangle.bottom; if (hOversized != vOversized) { SCROLLBARINFO info; info.cbSize = sizeof(info); if (hOversized) { GetScrollBarInfo(myPanelWindow, OBJID_HSCROLL, &info); vOversized = rectangle.bottom >= info.rcScrollBar.top; if (vOversized) { bottomBound = info.rcScrollBar.top - 1; } } else { GetScrollBarInfo(myPanelWindow, OBJID_VSCROLL, &info); hOversized = rectangle.right >= info.rcScrollBar.left; if (hOversized) { rightBound = info.rcScrollBar.left - 1; } } } ShowScrollBar(myPanelWindow, SB_HORZ, hOversized); if (hOversized) { SCROLLINFO info; info.cbSize = sizeof(info); info.fMask = SIF_RANGE | SIF_PAGE; info.nMin = 0; info.nMax = rectangle.right; info.nPage = rightBound; SetScrollInfo(myPanelWindow, SB_HORZ, &info, true); } ShowScrollBar(myPanelWindow, SB_VERT, vOversized); if (vOversized) { SCROLLINFO info; info.cbSize = sizeof(info); info.fMask = SIF_RANGE | SIF_PAGE; info.nMin = 0; info.nMax = rectangle.bottom; info.nPage = bottomBound; SetScrollInfo(myPanelWindow, SB_VERT, &info, true); } } updateElementSize(); myDoLayout = false; } } const std::string &W32DialogPanel::caption() const { return myCaption; } void W32DialogPanel::scroll(WORD command, int direction) { SCROLLINFO info; info.cbSize = sizeof(info); info.fMask = SIF_ALL; GetScrollInfo(myPanelWindow, direction, &info); int position = info.nPos; switch (command) { case SB_LEFT: // == SB_TOP info.nPos = info.nMin; break; case SB_RIGHT: // == SB_BOTTOM info.nPos = info.nMax; break; case SB_LINELEFT: // == SB_LINEUP info.nPos -= 1; break; case SB_LINERIGHT: // == SB_LINEDOWN info.nPos += 1; break; case SB_PAGELEFT: // == SB_PAGEUP info.nPos -= info.nPage; break; case SB_PAGERIGHT: // == SB_PAGEDOWN info.nPos += info.nPage; break; case SB_THUMBTRACK: info.nPos = info.nTrackPos; break; } info.fMask = SIF_POS; SetScrollInfo(myPanelWindow, direction, &info, true); GetScrollInfo(myPanelWindow, direction, &info); if (info.nPos != position) { if (direction == SB_HORZ) { ScrollWindow(myPanelWindow, position - info.nPos, 0, 0, 0); } else { ScrollWindow(myPanelWindow, 0, position - info.nPos, 0, 0); } UpdateWindow(myPanelWindow); } }
75ee655041d44aa17c40a622c1dfe61a8a781b20
ed4a025ad78e859fd0b6aae5f4ea9072a304b8ca
/comp15/lab5/sol6/sequenceL.h
4d3839470314081edf77fedd9a5f4a2e157122e6
[]
no_license
trankmichael/intro
3fc92aee012d125069e70bd14ae1d8e6e3259f7f
0e4f5f46f204da6db2c05826c598e5a537cc63d9
refs/heads/master
2021-01-20T11:26:25.607143
2015-01-15T20:28:57
2015-01-15T20:28:57
24,669,269
0
2
null
null
null
null
UTF-8
C++
false
false
1,774
h
#include <iostream> using namespace std; typedef char ElementType; struct Node { ElementType value; Node * next; }; class SequenceL { public: //This is the default constructor //and it creates an empty sequence SequenceL(); //This is a constructor that takes //a char, creates an empty sequence, //and sets the char as the first element SequenceL(ElementType data); //isEmpty takes in no parameters and returns //a bool with either true for an empty sequence //and false for a non-empty sequence by checking //if the private seqSize is 0 bool isEmpty(); //size takes in no parameters and returns the //size of the sequence which is stored in a //private integer called seqSize int Size(); //concatenate reads in a a pointer to another //sequence and attaches it to the end of the first sequence void concatenate(SequenceL *seqptr); //print will go through the sequence //and print every character leaving spaces in between void print (); //first returns the first character in the sequence ElementType first(); //rest returns a pointer to a new sequence that is //an exact copy of the sequence without the first character SequenceL * rest(); private: int seqSize; //stores the number of characters in the sequence Node * head; //pointer to the first Node in linked list that //stores the sequence //the copy function makes a copy of a linked list and returns //a pointer to its head. It is slightly different depending //on whether it's called for rest of from concatenate. //See function comments in the .cpp file Node * copy(SequenceL *seqptr,string function); };
b96d5449c697f29a408908b255675620a08382a8
33d57f8f003942df7d8e595371fa8321de6068aa
/RoomChatServer/RoomManager.cpp
185a418e53a26350bac1da4ee9c4980e9a6ebfc8
[]
no_license
rnsk1243/MealServer
cbadd6424a5f5ef82fc905f8e0078005e381ca72
d55969f3658b03d2ad832ceecc223ca06e3009cd
refs/heads/master
2021-01-23T02:06:06.179881
2017-09-10T08:33:28
2017-09-10T08:33:28
102,429,043
0
0
null
2017-09-14T19:51:08
2017-09-05T03:21:53
C++
UHC
C++
false
false
4,846
cpp
#include "RoomManager.h" #include"ErrorHandler.h" CRoomManager::CRoomManager():newRoomNumber(StartRoomNum) { } CRoomManager::~CRoomManager() { } RoomListIt CRoomManager::GetMyRoomIter(int ChannelNum, int roomNum) { RoomListIt iterBegin = mRooms.begin(); RoomListIt iterEnd = mRooms.end(); for (; iterBegin != iterEnd; ++iterBegin) { // 채널이 같은지 확인 if (ChannelNum == (*iterBegin)->GetChannelNum()) { // 채널이 같고 룸번호 까지 같은지 확인 if (roomNum == (*iterBegin)->GetRoomNum()) { return iterBegin; } } } cout << roomNum << "번 방이 없습니다." << endl; ErrorHandStatic->ErrorHandler(ERROR_GET_ROOM); //RoomListIt* error = nullptr; return iterBegin; // iterBegin == iterEnd 이면 방이없다. } void CRoomManager::PushRoom(const RoomPtr & shared_newRoom) { ScopeLock<MUTEX> MU(mRAII_RoomManagerMUTEX); mRooms.push_back(shared_newRoom); ++newRoomNumber; } RoomListIt CRoomManager::EraseRoom(RoomListIt deleteTargetRoomIter) { ScopeLock<MUTEX> MU(mRAII_RoomManagerMUTEX); RoomListIt delRoom = mRooms.erase(deleteTargetRoomIter); return delRoom; } RoomListIt CRoomManager::ExitRoom(const LinkPtr & shared_clientInfo) { CLink* client = shared_clientInfo.get(); if (nullptr == client) return mRooms.end(); RoomListIt myRoomIter = GetMyRoomIter(client->GetMyChannelNum(), client->GetMyRoomNum()); if (mRooms.end() != myRoomIter) { string outClientName(shared_clientInfo.get()->GetMyName() + " 님이 방에서 나가셨습니다."); (*myRoomIter).get()->Talk(shared_clientInfo, outClientName); client->SetMyRoomNum(NoneRoom); client->InitBetting(); // 베팅 초기화 시킴 if (true == (*myRoomIter)->IsGame()) // 게임중에 나갔나? { client->LostWillMoney((*myRoomIter)->GetBattingMoney()); // 벌금 부과 client->SaveCalculateMoney(); // 갈땐 가더라도 정산은..해야지 (*myRoomIter)->AllInitBetting(); // 룸에 들어있는 사람 준비 초기화 } (*myRoomIter).get()->EraseClient(shared_clientInfo); return myRoomIter; } return mRooms.end(); } int CRoomManager::MakeRoom(const LinkPtr & shared_clientInfo, const string& roomName, const int& battingMoney) { CLink* client = shared_clientInfo.get(); if (client->GetMyMoney() >= battingMoney && battingMoney >= 0) { RoomPtr newRoom(new CRoom(newRoomNumber, client->GetMyChannelNum(), roomName, battingMoney)); int makedRoomNumber = newRoomNumber; // PushRoom을 호출하면 newRoomNumber가 1 증가하기때문에 PushRoom(newRoom); return makedRoomNumber; } else { client->SendnMine("베팅에 필요한 돈이 부족하여 방을 만들 수 없습니다."); ErrorHandStatic->ErrorHandler(ERROR_ROOM_ENTRER_BATTING_MONEY); return -1; } } bool CRoomManager::EnterRoom(const LinkPtr & shared_clientInfo, int targetRoomNumBer) { CLink* client = shared_clientInfo.get(); if (nullptr == client) return false; if (true == client->IsRoomEnterState()) // 이미 방에 있는지 확인 return false; RoomListIt targetRoomIter = GetMyRoomIter(client->GetMyChannelNum(), targetRoomNumBer); if (EnterRoomPeopleLimit <= (*targetRoomIter).get()->GetAmountPeople()) { shared_clientInfo.get()->SendnMine(DialogEnterRoomPeopleLimit); return false; } if (mRooms.end() != targetRoomIter) { int BattingMoney = (*targetRoomIter)->GetBattingMoney(); if (BattingMoney <= client->GetMyMoney()) { (*targetRoomIter)->PushClient(shared_clientInfo, targetRoomNumBer); return true; } else { shared_clientInfo.get()->SendnMine(EnterRoomMoneyLack); ErrorHandStatic->ErrorHandler(ERROR_ROOM_ENTRER_BATTING_MONEY, shared_clientInfo); } } return false; } bool CRoomManager::IsAllReadyGame(const LinkPtr & shared_clientInfo) { CLink* client = shared_clientInfo.get(); if (nullptr == client) return false; RoomListIt targetRoomIter = GetMyRoomIter(client->GetMyChannelNum(), client->GetMyRoomNum()); if (mRooms.end() != targetRoomIter) { client->SetReadyGame((*targetRoomIter).get()->GetBattingMoney()); return ((*targetRoomIter)->IsAllReady()); } return false; } void CRoomManager::Broadcast(const LinkPtr & shared_clientInfo, const string & message, int flags) { CLink* client = shared_clientInfo.get(); if (nullptr == client) return; RoomListIt myRoomIter = GetMyRoomIter(client->GetMyChannelNum(), client->GetMyRoomNum()); if (mRooms.end() != myRoomIter) { (*myRoomIter).get()->Broadcast(message, flags); } } void CRoomManager::Talk(const LinkPtr & shared_clientInfo, const string & message, int flags) { CLink* client = shared_clientInfo.get(); if (nullptr == client) return; RoomListIt myRoomIter = GetMyRoomIter(client->GetMyChannelNum(), client->GetMyRoomNum()); if (mRooms.end() != myRoomIter) { (*myRoomIter).get()->Talk(shared_clientInfo, message, flags); } }
a0833c62270fcd48e64122dd30cf332ef306cb90
6726a7057a8885f1d421ec1a615cd912b34c58a8
/AirLib/DataStructures/AirSkinning.h
c9559a2d8414311df057712ce8d7c2e87802c5e4
[]
no_license
immagery/air
a199cdee53b4092fa9033024384958813c330ed8
0da8d2288d0e37de2cb8062af6be074fe84b54aa
refs/heads/master
2021-05-28T17:02:29.589663
2014-08-04T07:57:53
2014-08-04T07:57:53
12,705,567
2
0
null
null
null
null
UTF-8
C++
false
false
1,039
h
#ifndef AIR_SKINNING_H #define AIR_SKINNING_H #include <DataStructures/Skinning.h> #include <Computation\BulgeDeformer.h> #include <vector> using namespace std; class AirRig; class AirSkinning : public Skinning { public: AirSkinning() : Skinning() { useSecondaryWeights = false; } ~AirSkinning(); virtual void loadBindingForModel(Modelo *m, AirRig* rig); //virtual void saveBindingToFile (string path); // For update linking: initialization void cacheSkinning(); void getDeformerRestPositions(AirRig* rig); // Compute deformations over the deformed model taking the original model, // and the skinning cached virtual void computeDeformations(AirRig* rig); virtual void computeDeformationsWithSW(AirRig* rig); virtual void resetDeformations(); // Reference to rigg deformers map< int, joint* > deformersRestPosition; map< int, joint* > deformersPosition; vector<BulgeDeformer> bulge; }; void saveAirBinding(binding* bd, string fileName); void loadAirBinding(binding* bd, string fileName); #endif // AIR_SKINNING_H
6d115c9ff48a9b04953c61fdd16f2e5946664f0b
7252ca0228705a1cfd47c6437fa45eec9b19565e
/kimug2145/10451/10451.cpp14.cpp
e7ac016bbbab9a099644c0337d93a9902a087d3b
[]
no_license
seungjae-yu/Algorithm-Solving-BOJ
1acf12668dc803413af28f8c0dc61f923d6e2e17
e294d631b2808fdcfc80317bd2b0bccccc7fc065
refs/heads/main
2023-08-19T00:30:13.832180
2021-10-06T14:49:12
2021-10-06T14:49:12
414,241,010
0
0
null
null
null
null
UTF-8
C++
false
false
640
cpp
#include <iostream> #include <cstring> using namespace std; int tc, n, inp[1005], m[1005][1005], cnt; bool chk[1005]; int start; void DFS(int st,int val) { if (m[st][val] == true) { cnt++; return; } chk[st] = true; for (int i = 1; i <= n; i++) { if (m[st][i] && !chk[i]) { DFS(i, val); } } } int main() { scanf("%d", &tc); while (tc--) { cnt = 0; memset(chk, 0, sizeof(chk)), memset(m, 0, sizeof(m)); scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &inp[i]), m[i][inp[i]] = true; for (int i = 1; i <= n; i++) if (!chk[i]) DFS(i, i); printf("%d\n", cnt); } }
0c146572b9de87b1e30a5be364434df76d6872da
e1496ce925b10d09fd2b30648f4f964fe31de423
/HRD/HRDgame/rank.h
9c7fb04b60b091dd40721103316c3b5202cab7d4
[]
no_license
459893719/Summer-term1
512ed4c83dc11f2daad6ace684414b9dba988b25
0062292ba47bfd5e13ccc6a59dd0507c949f5132
refs/heads/master
2020-04-03T06:43:40.418785
2018-10-28T14:54:28
2018-10-28T14:54:28
155,082,538
0
0
null
null
null
null
UTF-8
C++
false
false
516
h
#ifndef RANK_H #define RANK_H #include <QMainWindow> #include<QFile> #include<QList> #include<QString> #include <QStandardItemModel> #include "client.h" namespace Ui { class rank; } class rank : public QMainWindow { Q_OBJECT public: explicit rank(Client* client, QWidget *parent = 0); ~rank(); void showRank(); private slots: void on_btn_return_clicked(); signals: void sendsignal(); private: Ui::rank *ui; QStandardItemModel* model; Client* client; }; #endif // RANK_H
dc89d65b20a7958b97677250bfa7c0e088444d50
31182f668eed4c4ca40b1de445591747c584a9e3
/externals/browser/externals/browser/externals/libjsoncpp/jsoncpp/json.hpp
6be66914eae949b6ad06ca722fa62b8f9675489f
[ "BSD-2-Clause" ]
permissive
HanochZhu/vts-browser-unity-plugin
62666b98da055a06458b00efcbe43fb7ef7e4e14
32a22d41e21b95fb015326f95e401d87756d0374
refs/heads/main
2023-07-24T22:33:39.358166
2021-09-10T04:03:57
2021-09-10T04:03:57
402,318,471
1
0
null
null
null
null
UTF-8
C++
false
false
1,734
hpp
/** * Copyright (c) 2017 Melown Technologies SE * * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /** * @file jsoncpp/as.hpp * @author Vaclav Blazek <[email protected]> * * Convenience as<Type>(json-value) "cast" operator. */ #ifndef jsoncpp_json_hpp_included_ #define jsoncpp_json_hpp_included_ #include <json/json.h> namespace Json { /** For compatibility. */ typedef Exception Error; } // namespace Json #endif // jsoncpp_json_hpp_included_
2dcf767ef66f4c2bcf8fcea014bfed7490bc9eb1
9593216e8d48b5656a4b439e06ce0573d57ce715
/practice/03/bai4.cpp
b525da1c5771ce8ad9d672882e51118088547963
[]
no_license
trandattin/ky-thuat-lap-trinh
aa18911d297444e1b3ad0415697acfe3a2053e42
42e70229789f463632b940a769a94e6c61bd060e
refs/heads/master
2023-06-29T01:24:58.888784
2021-08-06T11:24:30
2021-08-06T11:24:30
346,017,452
0
0
null
null
null
null
UTF-8
C++
false
false
672
cpp
//Bài 4: Viết thuật toán nhập số thực x, và số thực nguyên dương n, tính giá trị A = x^n / n! (Dùng vòng lặp FOR). #include "stdio.h" double exP(double x, double n); int facT(int n); int main() { int n; float x; printf("Input real value x: "); scanf("%f",&x); printf("Input positive value n: "); scanf("%d",&n); printf("The result is: %f",exP(x,n)/facT(n)); } double exP(double x, double n){ double result = 1; for (int i=1; i<=n; i++) { result *= x; } return result; } int facT(int n) { int result = 1; for (int i=1; i<=n; i++) { result *= i; } return result; }
c8f7da0373c06051a16a2334a9ef202b8c3d6571
cead57e8749b61c62b2f5f17316ba03dd91ea6bf
/rconclient.cc
beba31d44b5879277e05eecb868f0f672771613c
[ "MIT" ]
permissive
rhololkeolke/ssl-autoref
f57f759380e663bdd0ba42045616ade42348eb59
51db01fd611cd23a50dd9880b0f0d9e47cc63fca
refs/heads/master
2020-12-31T04:06:26.023520
2016-06-14T03:34:37
2016-06-15T04:13:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,329
cc
#include <netdb.h> #include <unistd.h> #include <cctype> #include <cerrno> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <string> #include <unordered_map> #include <unordered_set> #include <arpa/inet.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/ip.h> #include <sys/socket.h> #include <sys/types.h> #include "rcon.pb.h" // TODO set last id field #include "rconclient.h" bool RemoteClient::recvFully(void *buffer, std::size_t length) { char *ptr = static_cast<char *>(buffer); while (length != 0) { ssize_t ret = recv(sock, ptr, length, 0); if (ret < 0) { std::cerr << std::strerror(errno) << '\n'; return false; } if (!ret) { std::cerr << "Socket closed by remote peer.\n"; return false; } ptr += ret; length -= ret; } return true; } bool RemoteClient::sendFully(const void *buffer, std::size_t length) { const char *ptr = static_cast<const char *>(buffer); while (length != 0) { ssize_t ret = send(sock, ptr, length, 0); if (ret < 0) { std::cerr << std::strerror(errno) << '\n'; return false; } ptr += ret; length -= ret; } return true; } SSL_RefereeRemoteControlRequest RemoteClient::createMessage() { SSL_RefereeRemoteControlRequest request; request.set_message_id(nextMessageID++); return request; } void RemoteClient::sendRequest(const SSL_RefereeRemoteControlRequest &request) { // send request { const std::string &message = request.SerializeAsString(); uint32_t messageLength = htonl(static_cast<uint32_t>(message.size())); // std::cout << "Send " << (sizeof(messageLength) + message.size()) << " bytes: "; // std::cout.flush(); if (request.has_command()) { std::cout << "Sending command: " << SSL_Referee::Command_Name(request.command()) << ".\n"; } if (request.has_stage()) { std::cout << "Sending stage: " << SSL_Referee::Stage_Name(request.stage()) << ".\n"; } sendFully(&messageLength, sizeof(messageLength)); sendFully(message.data(), message.size()); // std::cout << "OK\n"; } // wait for response SSL_RefereeRemoteControlReply reply; { // std::cout << "Receive reply: "; // std::cout.flush(); uint32_t replyLength; recvFully(&replyLength, sizeof(replyLength)); replyLength = ntohl(replyLength); if (replyLength > MAX_REPLY_LENGTH) { std::cerr << "Got reply length " << replyLength << " which is greater than limit " << MAX_REPLY_LENGTH << ".\n"; } std::vector<char> buffer(replyLength); recvFully(&buffer[0], replyLength); // std::cout << (4 + replyLength) << " bytes OK.\n"; reply.ParseFromArray(&buffer[0], replyLength); } if (reply.message_id() != request.message_id()) { std::cerr << "Reply message ID " << reply.message_id() << " does not match request message ID " << request.message_id() << ".\n"; } std::cout << "Command result is: " << SSL_RefereeRemoteControlReply::Outcome_Name(reply.outcome()) << ".\n"; } bool RemoteClient::open(const char *hostname, int port) { // Parse target address. struct addrinfo *refboxAddresses; { struct addrinfo hints; hints.ai_flags = 0; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; int err = getaddrinfo(hostname, nullptr, &hints, &refboxAddresses); if (err != 0) { std::cerr << gai_strerror(err) << '\n'; } } // Try to connect to the returned addresses until one of them succeeds. sock = -1; for (const addrinfo *i = refboxAddresses; i; i = i->ai_next) { char host_buf[256], port_buf[32]; (reinterpret_cast<struct sockaddr_in *>(i->ai_addr))->sin_port = htons(port); int err = getnameinfo(i->ai_addr, i->ai_addrlen, host_buf, sizeof(host_buf), port_buf, sizeof(port_buf), NI_NUMERICHOST | NI_NUMERICSERV); if (err != 0) { std::cerr << gai_strerror(err) << '\n'; return false; } std::cout << "Trying host " << host_buf << " port " << port_buf << ": "; std::cout.flush(); sock = socket(i->ai_family, i->ai_socktype, i->ai_protocol); if (sock < 0) { std::cout << std::strerror(errno) << '\n'; continue; } if (connect(sock, i->ai_addr, i->ai_addrlen) < 0) { std::cout << std::strerror(errno) << '\n'; close(sock); sock = -1; continue; } std::cout << "OK\n"; return true; } return false; } void RemoteClient::sendCard(SSL_RefereeRemoteControlRequest::CardInfo::CardType color, SSL_RefereeRemoteControlRequest::CardInfo::CardTeam team) { SSL_RefereeRemoteControlRequest request = createMessage(); request.mutable_card()->set_type(color); request.mutable_card()->set_team(team); sendRequest(request); } void RemoteClient::sendStage(SSL_Referee::Stage stage) { SSL_RefereeRemoteControlRequest request = createMessage(); request.set_stage(stage); sendRequest(request); } void RemoteClient::sendCommand(SSL_Referee::Command command) { SSL_RefereeRemoteControlRequest request = createMessage(); request.set_command(command); sendRequest(request); }
678c8a4f2469dfa8e33e9dfc68a6632e8d505c71
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/76/b02e61050721ce/main.cpp
27fa200228c3e940cdb6cc43ee170121ee7f0977
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
420
cpp
#include <iostream> #include <vector> #include <string> #include <thread> #include <chrono> #include <future> using namespace std; string GetUrl(string url){ string result="Data"+url; this_thread::sleep_for(chrono::milliseconds(100)); return result; } int main(){ auto fun::std async(GetUrl,"MMMMMMMM"); string example=future.get(); cout<<example<<endl; return 0; }
[ "francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df" ]
francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df
d37d6f6781633b9b3eef2bd6b79bcf758435e2e7
b62e304c3e528cdc65d7b34b065f52f5eca91971
/OOP/babel/include/IAudio.hpp
b80d091e182e4a80c31a1b7cad89bcf0cf9c9e30
[]
no_license
Jean-MichelGRONDIN/EPITECH_Tek3_Projects
9dbe1b7ddd82c8f5087179f88e624f0a6f76e519
071824a15e8f037c9ea64f07b25331ab1033bf76
refs/heads/master
2023-03-19T22:13:12.451411
2021-03-16T11:28:47
2021-03-16T11:28:47
330,875,578
1
0
null
null
null
null
UTF-8
C++
false
false
471
hpp
/* ** EPITECH PROJECT, 2020 ** opus_test ** File description: ** Audio */ #ifndef AUDIO_HPP_ #define AUDIO_HPP_ #include <QObject> class IAudio: public QObject { public: virtual bool CreateStreams(void) = 0; virtual bool StartStreams(void) = 0; virtual void DestroyStreams(void) = 0; virtual void StopStreams(void) = 0; virtual void setToPlay(QByteArray toAdd) = 0; protected: private: }; #endif /* !AUDIO_HPP_ */
1d0e772ab8c4bb48fdf8400cb9bc81de7af248eb
496065734362b1ab786e5587c08664d81368c3c6
/Knights' Reader and Writer/src/Reader.h
71bb629082bc1f5e2aefc55c2800d2dd2507f654
[]
no_license
ilyusha71/ExitSpace
ee2a3871887af922e302494de185e26b8921fdf6
162164e5efa9f05f95aad66492b102b1442887ec
refs/heads/master
2021-07-04T21:46:22.569316
2021-04-29T08:51:30
2021-04-29T08:51:30
233,370,535
0
0
null
null
null
null
UTF-8
C++
false
false
2,796
h
#define READER_h #define stringify(name) #name enum PassMode { Counting, // 計數密鑰 Pass ==> Type C Specify, // 指定密鑰 Pass ==> Type V OR, // 擇一密鑰 Pass ==> Type R AND, // 多重密鑰 Pass ==> Type A Wakaka, // 萬用密鑰 Pass ==> Type W Special, // 針對單一Reader額外配置 ==> Type X }; #define SIZE_OF_ARRAY(ary) sizeof(ary) / sizeof(*ary) class READER { public: String modeName[6] = {"[Counting]", "[Specify]", "[OR]", "[And]", "[Wakaka]", "[Special]"}; PassMode mode = Wakaka; int countKeys; RFID *specificKey; RFID *passKeys[]; // RFID *rfid; READER() {} void Initialize(int count) { mode = Counting; countKeys = count; Show(); } void Initialize(RFID &key) { mode = Specify; specificKey = &key; Show(); } // 2020/04/20 新方法 void AddPassKey(RFID &key, int index) { passKeys[index] = &key; } // OR Mode AND Mode template <typename T, size_t N> void Initialize(PassMode mode, T (&keys)[N]) { this->mode = mode; countKeys = N; for (int i = 0; i < countKeys; i++) { passKeys[i] = keys[i]; } Show(); } void Initialize(PassMode mode, int count) { this->mode = mode; countKeys = count; Show(); } void Show() { Serial.print(F(" * Mode ==> ")); Serial.println(modeName[mode]); switch (mode) { case Counting: Serial.print(F(" * Target ==> x")); Serial.println(countKeys); break; case Specify: Serial.print(F(" * Target ==> ")); specificKey->ShowRubyName(); Serial.print(F(" in ")); specificKey->ShowRubyBlock(); Serial.println(); break; case OR: for (int i = 0; i < countKeys; i++) { Serial.print(F(" * Target ==> ")); passKeys[i]->ShowRubyName(); Serial.print(F(" in ")); passKeys[i]->ShowRubyBlock(); Serial.println(); } break; case AND: for (int i = 0; i < countKeys; i++) { Serial.print(F(" * Target ==> ")); passKeys[i]->ShowRubyName(); Serial.print(F(" in ")); passKeys[i]->ShowRubyBlock(); Serial.println(); } break; case Wakaka: // Serial.println(); break; case Special: // Serial.println(); break; default: break; } } private: };
e54819c6bb6488ba1f271366b18b57f0d617faa9
7bf02590e136f2a8063c3695eedbc2320f30f0c9
/Parallel/MPI/Sorting/Code/quicksort.cpp
8acfe2433f1713e2bf05d2b2e6ea8817ddd25514
[]
no_license
asciimike/smorgasbord
0e206e81af2c302a30f48f65cd80d460b54784f9
f8af3d778668ee9207d6aded4a00f60819a8b512
refs/heads/master
2021-05-29T01:07:40.221466
2014-09-03T00:13:49
2014-09-03T00:13:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,304
cpp
#include<iostream> #include<mpi.h> #include<math.h> #include<fstream> #include<sstream> #include<vector> #include<stdlib.h> //I compile with mpic++ quicksort.cpp-o quicksorts //#define DEBUG //Uncomment if you want my debug information (or want some randomly ordered strings) #define MPI_DEBUG //MPI barrier debug statements /* * Perform parallel quicksort transposition sort on a given CSV file, return another CSV file with the sorted list. * Number of processors must be a power of two. * Mike McDonald * CSSE 335 HW 9 * 5/17/2013 */ using namespace std; //read a sequence from fname. Reserve memory and put it in A, which is an int*, put the number of elements read in n. //Shamelessly copied from Dr. Eicholz... void cdf_intreader(char* fname,int** A, int* n){ ifstream F(fname); stringstream buf; buf<< F.rdbuf(); string S(buf.str()); int lastidx=-1; int nextidx=string::npos+1; int nread=0; string toinsert; vector<int> Av; int i=0; while (nextidx!=string::npos){ nextidx=S.find(',',lastidx+1); if (nextidx!=string::npos){ toinsert=S.substr(lastidx+1,nextidx-lastidx-1); lastidx=nextidx; }else{ toinsert=S.substr(lastidx+1,S.length()-lastidx-1); } Av.push_back(atoi(toinsert.c_str())); i++; } *n=Av.size(); *A=new int[Av.size()]; for (i=0;i<Av.size();i++){ (*A)[i]=Av[i]; } } //Write seq, which has length n, to fname. //Also hamelessly copied from Dr. Eicholz... void cdf_write_seq(char* fname, int* seq, int n){ ofstream F(fname); for (int i=0;i<n-1;i++){ F<<seq[i]<<","; } F<<seq[n-1]<<endl; } //Perform a quicksort in place on a. Give it the right bounds (0, length-1) to begin with. void quicksort(int* a, int l, int r) { int i = l; int j = r; int t; int pivot = a[(l + r) / 2]; //partition while (i <= j) { while (a[i] < pivot) i++; while (a[j] > pivot) j--; if (i <= j) { //swap values t = a[i]; a[i] = a[j]; a[j] = t; i++; j--; } }; //recurse down a level if (l < j) quicksort(a, l, j); if (i < r) quicksort(a, i, r); } //Main code to perform odd even sort int main(int argc,char** argv){ //MPI boilerplate int size,rank; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&size); MPI_Comm_rank(MPI_COMM_WORLD,&rank); MPI_Status status; //input and output file checking char* in_file=argv[1]; char* out_file=argv[2]; //do some input argument checking (make sure that both files are specified...) if(rank == 0){ if(argc < 3){ cerr << "Please provide input and output filenames\n"; abort(); } } //check if P will form a perfect tree if(rank == 0){ if(exp2(floor(log2(size)))!=size){ cerr << "Please select P to be a power of 2^i, so as to form a perfect tree structure\n"; abort(); } } int* myData; //list of integers to be sorted int* keepData; int* sendData; int n; //size of the list of integers //read in the file to one processor if(rank == 0){ cdf_intreader(argv[1],&myData,&n); } //print out the input file if the length isn't absurd if(rank == 0){ if(n < 20){ cout << "Input list is: "; for(int i = 0; i < n-1; i++){ cout << myData[i] << ","; } cout << myData[n-1] << endl; } } //what is the size of my array int mySize; if(rank == 0){ mySize = n; }else{ mySize = 0; } //Spread data around to each processor for(int l = 1; l <= (int) log2(size); l++){ int pivot; int sendSize; //pivoting occurs if you're going to send if(rank < floor(exp2(l-1))){ if(mySize > 1){ #ifdef DEBUG cout << "Processor " << rank << " is pivoting and arranging data on level " << l << endl; #endif //Pick a pivot pivot = myData[0]; //Arrange data into low and high halves int left, right, temp = 0, keepSize = 0; for(left = 1, right = mySize-1; left < right; ) { if(myData[left] > pivot && myData[right] <= pivot) { temp = myData[left]; myData[left] = myData[right]; myData[right] = temp; } if(myData[left] <= pivot) left++; if(myData[right] > pivot) right--; } keepSize = 0; for(int n = 0; n < mySize; n++){ if(myData[n] < pivot){ keepSize++; } } sendSize = mySize - keepSize - 1; //subtract off the pivot //create arrays to keep and send if(keepSize <= sendSize){ keepSize++; keepData = new int[keepSize]; if(keepSize > 1){ for(int j = 0; j < keepSize-1; j++){ keepData[j] = myData[j+1]; } keepData[keepSize-1] = pivot; }else{ keepData[0] = pivot; } sendData = new int[sendSize]; for(int j = 0; j < sendSize; j++){ sendData[j] = myData[keepSize+j]; } } if(keepSize > sendSize){ keepData = new int[keepSize]; for(int j = 0; j < keepSize; j++){ keepData[j] = myData[j+1]; } sendSize = sendSize++; sendData = new int[sendSize]; for(int j = 0; j < sendSize; j++){ sendData[j+1] = myData[keepSize+j+1]; } sendData[0] = pivot; } #ifdef DEBUG cout << "Keep size " << keepSize << " send size " << sendSize << " on level " << l << endl; #endif mySize = keepSize; myData = new int[mySize]; myData = keepData; #ifdef DEBUG cout << "Procesor " << rank << " keeping data on level " << l << " : "; for(int i = 0; i < mySize-1; i++){ cout << myData[i] << ","; } cout << myData[mySize-1] << endl; #endif //If I have no data to send }else{ sendSize = 0; } } #ifdef MPI_DEBUG MPI_Barrier(MPI_COMM_WORLD); #endif //Sending if(rank < floor(exp2(l-1))){ MPI_Send(&sendSize, 1, MPI_INT, rank + floor(exp2(l-1)), 0, MPI_COMM_WORLD); if(sendSize > 0){ #ifdef DEBUG cout << "Procesor " << rank << " sending data on level " << l << " : "; for(int i = 0; i < sendSize-1; i++){ cout << sendData[i] << ","; } cout << sendData[sendSize-1] << endl; #endif MPI_Send(sendData, sendSize, MPI_INT, rank + floor(exp2(l-1)), 0, MPI_COMM_WORLD); #ifdef DEBUG cout << "Processor " << rank << " sending size " << sendSize << " to processor " << rank + floor(exp2(l-1)) << " on level " << l << endl; #endif } //Recieving }else if(rank < floor(exp2(l))){ MPI_Recv(&mySize, 1, MPI_INT, rank - floor(exp2(l-1)), MPI_ANY_TAG, MPI_COMM_WORLD, &status); if(mySize > 0){ myData = new int[mySize]; MPI_Recv(myData, mySize, MPI_INT, rank - floor(exp2(l-1)), MPI_ANY_TAG, MPI_COMM_WORLD, &status); #ifdef DEBUG cout << "Processor " << rank << " recieved size " << mySize << " from processor " << rank - floor(exp2(l-1)) << " on level " << l << endl; #endif #ifdef DEBUG cout << "Just Revieved : "; for(int i = 0; i < mySize-1; i++){ cout << myData[i] << ","; } cout << myData[mySize-1] << endl; #endif } //doing nothing }else{ #ifdef DEBUG cout << "Processor " << rank << " is doing nothing on level " << l << endl; #endif } #ifdef MPI_DEBUG MPI_Barrier(MPI_COMM_WORLD); #endif } //run a serial quicksort as the base case #ifdef DEBUG cout << "Processor " << rank << " is running a serial quicksort as the base case\n"; #endif if(mySize > 1){ quicksort(myData,0,mySize-1); } #ifdef DEBUG cout << "After sorting on rank " << rank << " : "; for(int i = 0; i < mySize-1; i++){ cout << myData[i] << ","; } cout << myData[mySize-1] << endl; #endif #ifdef MPI_DEBUG MPI_Barrier(MPI_COMM_WORLD); #endif //collect the data and merge it //do a for loop in the opposite direction as above, merging along the way for(int l = (int) log2(size); l >= 1; l--){ int rxSize; int* rxData; if(rank >= floor(exp2(l-1)) && rank < floor(exp2(l))){ MPI_Send(&mySize, 1, MPI_INT, rank - floor(exp2(l-1)), 0, MPI_COMM_WORLD); if(mySize > 0){ #ifdef DEBUG cout << "Sending : "; for(int i = 0; i < mySize-1; i++){ cout << myData[i] << ","; } cout << myData[mySize-1] << endl; #endif #ifdef DEBUG cout << "Processor " << rank << " sending size " << mySize << " to processor " << rank - floor(exp2(l-1)) << " on gather level " << l << endl; #endif MPI_Send(myData, mySize, MPI_INT, rank - floor(exp2(l-1)), 0, MPI_COMM_WORLD); } }else if(rank < floor(exp2(l-1))){ MPI_Recv(&rxSize, 1, MPI_INT, rank + floor(exp2(l-1)), MPI_ANY_TAG, MPI_COMM_WORLD, &status); if(rxSize > 0){ #ifdef DEBUG cout << "Processor " << rank << " recieved size " << rxSize << " from processor " << rank + floor(exp2(l-1)) << " on gather level " << l << endl; #endif rxData = new int[rxSize]; MPI_Recv(rxData, rxSize, MPI_INT, rank + floor(exp2(l-1)), MPI_ANY_TAG, MPI_COMM_WORLD, &status); #ifdef DEBUG cout << "Just Recieved : "; for(int i = 0; i < rxSize-1; i++){ cout << rxData[i] << ","; } cout << rxData[rxSize-1] << endl; #endif } int tempSize = mySize + rxSize; //Append it to the end of the current array int* tempData = new int[tempSize]; for(int t = 0; t < mySize; t++){ tempData[t] = myData[t]; } for(int t = mySize; t < tempSize; t++){ tempData[t] = rxData[t-mySize]; } #ifdef DEBUG cout << "Merged array : "; for(int i = 0; i < tempSize-1; i++){ cout << tempData[i] << ","; } cout << tempData[tempSize-1] << endl; #endif mySize += rxSize; myData = tempData; } } //Deal with file I/O and other junk if(rank == 0){ //print it out if it's a reasonable length if(n < 20){ cout << "Sorted list is: "; for(int i = 0; i < mySize-1; i++){ cout << myData[i] << ","; } cout << myData[mySize-1] << endl; } //write it to a file cdf_write_seq(out_file,myData,mySize); } //Clean up. MPI_Finalize(); }
c251a97f12880fe26af67e60725da5fccb442073
b1f7a2309825dbe6d5953f6582d7f442d1d40422
/lc-cn/剑指offer/机器人运动范围.cpp
2921e082440eddfdd4d58b49a1f6d94dd4dc345e
[]
no_license
helloMickey/Algorithm
cbb8aea2a4279b2d76002592a658c54475977ff0
d0923a9e14e288def11b0a8191097b5fd7a85f46
refs/heads/master
2023-07-03T00:58:05.754471
2021-08-09T14:42:49
2021-08-09T14:42:49
201,753,017
1
0
null
null
null
null
UTF-8
C++
false
false
1,855
cpp
// https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/ /* 同时这道题还有一个隐藏的优化: 我们在搜索的过程中搜索方向可以缩减为向右和向下,而不必再向上和向左进行搜索。 */ class Solution { // BFS // 计算 x 的数位之和 int get(int x) { int res=0; for (; x; x /= 10) { res += x % 10; } return res; } public: int movingCount(int m, int n, int k) { if (!k) return 1; queue<pair<int,int> > Q; // 向右和向下的方向数组 int dx[2] = {0, 1}; int dy[2] = {1, 0}; vector<vector<int> > vis(m, vector<int>(n, 0)); Q.push(make_pair(0, 0)); vis[0][0] = 1; int ans = 1; while (!Q.empty()) { auto [x, y] = Q.front(); Q.pop(); for (int i = 0; i < 2; ++i) { int tx = dx[i] + x; int ty = dy[i] + y; if (tx < 0 || tx >= m || ty < 0 || ty >= n || vis[tx][ty] || get(tx) + get(ty) > k) continue; Q.push(make_pair(tx, ty)); vis[tx][ty] = 1; ans++; } } return ans; } }; class Solution { // DFS public: int vis[101][101]={0}; int movingCount(int m, int n, int k) { return dfs(0,0,m,n,k); } int dfs(int x,int y,int m,int n,int k){ if(x<0||y<0||x>=m||y>=n||vis[x][y]||sum(x,y)>k) return 0; vis[x][y]=1; return dfs(x-1,y,m,n,k)+dfs(x,y-1,m,n,k)+dfs(x+1,y,m,n,k)+dfs(x,y+1,m,n,k)+1; // 可以优化,左和上的方向不用走 } int sum(int x,int y){ int res=0; while(x){ res+=x%10; x/=10; } while(y){ res+=y%10; y/=10; } return res; } };
ce23e73bf8cabc8b1671e2466a263a74017f4ebe
ca0fe4f52587955e56c8af7e8eb5205f7f4b5002
/mqtt_esp8266.ino
f56e0f66ca5e6306932cfd89fd805bef625ee26a
[]
no_license
rainfeng/mqtt_esp8266
38c4988a3136c64fb88a44887993fb29e3a100ec
23521a20a93aa4bc87b64ed406b8388565d02d66
refs/heads/master
2021-01-22T21:12:38.716453
2017-03-18T14:01:12
2017-03-18T14:01:12
85,404,033
0
0
null
null
null
null
UTF-8
C++
false
false
7,227
ino
/* Basic ESP8266 MQTT example This sketch demonstrates the capabilities of the pubsub library in combination with the ESP8266 board/library. It connects to an MQTT server then: - publishes "hello world" to the topic "outTopic" every two seconds - subscribes to the topic "inTopic", printing out any messages it receives. NB - it assumes the received payloads are strings not binary - If the first character of the topic "inTopic" is an 1, switch ON the ESP Led, else switch it off It will reconnect to the server if the connection is lost using a blocking reconnect function. See the 'mqtt_reconnect_nonblocking' example for how to achieve the same result without blocking the main loop. To install the ESP8266 board, (using Arduino 1.6.4+): - Add the following 3rd party board manager under "File -> Preferences -> Additional Boards Manager URLs": http://arduino.esp8266.com/stable/package_esp8266com_index.json - Open the "Tools -> Board -> Board Manager" and click install for the ESP8266" - Select your ESP8266 in "Tools -> Board" */ #include <ESP8266WiFi.h> #include <PubSubClient.h> #include "dht11.h" const int LM35 = 0;//LM35 pin dht11 DHT11; #define DHT11PIN 5 #define BEEPPIN 15 #define LEDB 14 #define LEDR 12 #define LEDG 13 // Update these with values suitable for your network. const char* ssid = "NETGEAR66"; const char* password = "strongbanana453"; const char* mqtt_server = "link.tlink.io"; WiFiClient espClient; PubSubClient client(espClient); long lastMsg = 0; char msg[200]; char msg1[100]; int value = 0; byte gbvalue = 0; byte gbrgb = 0; void setup_beep(){ pinMode(BEEPPIN, OUTPUT); } void setup_led(){ pinMode(LEDB, OUTPUT); pinMode(LEDR, OUTPUT); pinMode(LEDG, OUTPUT); } void setup_wifi() { delay(10); // We start by connecting to a WiFi network Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } randomSeed(micros()); Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); } void callback(char* topic, byte* payload, unsigned int length) { Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); for (int i = 0; i < length; i++) { Serial.print((char)payload[i]); } Serial.println(); // Switch on the LED if an 1 was received as first character if ((char)payload[0] == '1') { digitalWrite(BUILTIN_LED, LOW); // Turn the LED on (Note that LOW is the voltage level // but actually the LED is on; this is because // it is acive low on the ESP-01) } else { digitalWrite(BUILTIN_LED, HIGH); // Turn the LED off by making the voltage HIGH //digitalWrite(6, HIGH); } } void reconnect() { // Loop until we're reconnected while (!client.connected()) { Serial.print("Attempting MQTT connection..."); // Create a random client ID String clientId = "8UWQ4C60QC69GOQMZXW"; //clientId += String(random(0xffff), HEX); // Attempt to connect if (client.connect(clientId.c_str(),"[email protected]","1234,abcdEFG")) { // Serial.println("connected"); // Once connected, publish an announcement... client.publish("8UWQ4C60QC69GOQM", "hello world"); // ... and resubscribe client.subscribe("8XD8Z4QRPVPD8OWF"); //8XD8Z4QRPVPD8OWF } else { Serial.print("failed, rc="); Serial.print(client.state()); Serial.println(" try again in 5 seconds"); // Wait 5 seconds before retrying delay(5000); } } } void setup() { pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output Serial.begin(115200); setup_wifi(); client.setServer(mqtt_server, 1883); client.setCallback(callback); //setup_beep(); setup_led(); } void loop() { if (!client.connected()) { reconnect(); } client.loop(); int iIndex = 0; if(Serial.available()){ size_t len = Serial.available(); //uint8_t sbuf[len]; Serial.readBytes(msg1, len); msg1[len] = '\0'; if( len > 0 ) { snprintf (msg, 75, "{\"sensorDatas\":[{\"sensorsID\":200017105,\"value\":\"%s\"}]}", msg1); Serial.println(msg); client.publish("8XD8Z4QRPVPD8OWF", msg); } else { //Serial.println("serial no data !!!"); } } long now = millis(); if (now - lastMsg > 2000) { //snprintf( msg, 30, " now=%d, lastMsg=%d", now, lastMsg ); //Serial.println(msg); lastMsg = now; gbrgb = gbrgb + 1; if( gbrgb > 3 ) { gbrgb = 0; } if( gbrgb == 0 ) { digitalWrite( LEDB, HIGH ); digitalWrite( LEDR, LOW ); digitalWrite( LEDG, LOW ); } else if( gbrgb == 1 ) { digitalWrite( LEDB, LOW ); digitalWrite( LEDR, HIGH ); digitalWrite( LEDG, LOW ); } else if( gbrgb == 2 ) { digitalWrite( LEDB, LOW ); digitalWrite( LEDR, LOW ); digitalWrite( LEDG, HIGH ); } else { digitalWrite( LEDB, HIGH ); digitalWrite( LEDR, HIGH ); digitalWrite( LEDG, HIGH ); } if( gbvalue == 0 ) { //digitalWrite(32, HIGH); //digitalWrite(35,HIGH); //digitalWrite( LEDB, HIGH ); //digitalWrite( LEDR, LOW ); //digitalWrite( LEDG, HIGH ); gbvalue=1; } else { //digitalWrite(32,LOW); //digitalWrite(35,LOW); //digitalWrite( LEDB, LOW ); //digitalWrite( LEDR, HIGH ); //digitalWrite( LEDG, LOW ); gbvalue=0; } //! 读取温度和湿度传感器 int chk = DHT11.read(DHT11PIN); //Serial.print("Read sensor: "); switch (chk) { case DHTLIB_OK: //Serial.println("OK"); break; case DHTLIB_ERROR_CHECKSUM: Serial.println("Checksum error"); break; case DHTLIB_ERROR_TIMEOUT: Serial.println("Time out error"); break; default: Serial.println("Unknown error"); break; } //Serial.print("Humidity (%): "); //Serial.println((float)DHT11.humidity, 2); //Serial.print("Temperature (°C): "); //Serial.println((float)DHT11.temperature, 2); //200001787 //snprintf (msg, 180, "{\"sensorDatas\":[{\"sensorsID\":200016327,\"value\":\"%ld\"},{\"sensorsID\":200016440,\"value\":\"%ld\"}]}", DHT11.temperature,DHT11.humidity); //snprintf (msg, 75, "{\"sensorDatas\":[{\"sensorsID\":200016327,\"value\":\"%ld\"}]}", value); snprintf (msg, 180, "{\"sensorDatas\":[{\"sensorsID\":200016440,\"value\":\"%ld\"},{\"sensorsID\":200016327,\"value\":\"%ld\"}]}", DHT11.temperature,DHT11.humidity); //Serial.print("Publish message: "); //Serial.println(msg); if( gbvalue == 1 ) { snprintf (msg, 75, "{\"sensorDatas\":[{\"sensorsID\":200016327,\"value\":\"%ld\"}]}", DHT11.temperature); client.publish("8UWQ4C60QC69GOQM", msg); } else { snprintf (msg, 75, "{\"sensorDatas\":[{\"sensorsID\":200016441,\"value\":\"%ld\"}]}", DHT11.humidity); client.publish("2BPUB77AE336611B", msg); } } }
76f55b18b86b3d2f2cffee4ba0fa702f5b7ab7da
9698524c8e4aade8db7b3a9be0614f32f4cfe22a
/apps/Pong/pong/src/Renderer/SpriteBGRenderer.h
4ecb17e03f8742a495b62f24a5eaeaeb3f75676b
[ "MIT" ]
permissive
KAZOOSH/Pong
b8e3fbcdc1a6885d0db505ce2c22fabc5d09b48f
31854c96c6d443f02fabac8374ae333d26f86ee7
refs/heads/master
2020-05-22T04:28:05.740656
2018-02-05T13:26:03
2018-02-05T13:26:03
65,826,411
0
0
null
2017-04-28T11:48:32
2016-08-16T14:20:50
C++
UTF-8
C++
false
false
833
h
/* * GifBGRenderer.h * PONG * * KAZOOSH! - open platform for interactive installations - http://kazoosh.com * * created by Brian Eschrich - 2016 */ #ifndef _SpriteBGRenderer #define _SpriteBGRenderer #include "BasicPlaymode.h" class Sprite{ public: Sprite(ofImage img, int nFrames, int framesPerLine); void drawFrame(int frameNumber,int x, int y, int width, int height); ofImage img; int nFrames; int framesPerLine; int frameHeight; int frameWidth; }; class SpriteBGRenderer : public BasicPlaymode{ public: SpriteBGRenderer(GameElements* gameElements, string name = "Movie"); virtual void begin(); virtual void render(); protected: void getValuesFromXml(); private: vector<Sprite*> scenes; int currentScene; }; #endif