blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 986
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 23
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 145
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 122
values | content
stringlengths 3
10.4M
| authors
listlengths 1
1
| author_id
stringlengths 0
158
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
207591805fbe04f1e889e91229a26c65cb0ee77d
|
c5f58c0df0b6f92efb23088f48de4203352a5192
|
/Sharpmake.FunctionalTests/NoAllFastBuildProjectFunctionalTest/codebase/TestsA/TestsA.cpp
|
bfe50947019795ffb5408c2c4b9af42a152fd358
|
[
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] |
permissive
|
ubisoft/Sharpmake
|
4de76391183feed4779a1357b33b759178bb05a8
|
3df5efb9110daedaf474e35d81836ee4d97b859a
|
refs/heads/main
| 2023-09-03T14:38:54.752161
| 2023-09-01T13:51:34
| 2023-09-01T13:51:34
| 104,522,068
| 354
| 104
|
Apache-2.0
| 2023-09-04T17:23:15
| 2017-09-22T21:57:10
|
C#
|
UTF-8
|
C++
| false
| false
| 208
|
cpp
|
#include "LibA.h"
int main(int /*argc*/, char* /*argv*/[])
{
const auto t1 = fcnA(3) == 1;
const auto t2 = fcnA(0) == -2;
const auto t3 = fcnA(-8) == -10;
return (t1 && t2 && t3) ? 0 : 1;
}
|
[
"laefy22@gmail.com"
] |
laefy22@gmail.com
|
3a1ab7243013dd9b4cf364ce06d458dee117c5b4
|
0342a1af47bcf8a425fac59815e2b768bf8027cb
|
/Comparator.h
|
1d12d6b0fc801726857a7473ebf510dce0383700
|
[] |
no_license
|
orizitzer365/Project2
|
35039f4ad402fe70f2b0d1a1e7103a3de05b8340
|
a580ea677881f4cc8e4d0055fd79d3d47332ed7c
|
refs/heads/master
| 2020-04-15T11:54:47.225399
| 2019-01-16T22:19:03
| 2019-01-16T22:19:03
| 164,650,510
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 257
|
h
|
//
// Created by nadav on 1/15/19.
//
#ifndef PRO2_COMPARATOR_H
#define PRO2_COMPARATOR_H
template <class Comparable>
class Comparator{
public:
bool operator()(Comparable c1,Comparable c2){
return c1 < c2;
}
};
#endif //PRO2_COMPARATOR_H
|
[
"noreply@github.com"
] |
orizitzer365.noreply@github.com
|
86137477f892d399483cb3e25ba688d6d5443bb6
|
fda015cc078e877754e4cd5a48e970f0a1159ada
|
/src/scenario_config.h
|
12ccb8d9950a9f98c562502767da0321315cf8b8
|
[] |
no_license
|
cran/liquidSVM
|
886e0487104a434d3854120a774ebe120e1ddeae
|
35b8af219f5d52df5513789793c1e5cf07d310b8
|
refs/heads/master
| 2020-04-06T04:12:26.063387
| 2019-09-14T17:20:02
| 2019-09-14T17:20:02
| 83,014,436
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,138
|
h
|
// Copyright 2015-2017 Philipp Thomann
//
// This file is part of liquidSVM.
//
// liquidSVM is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// liquidSVM 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 Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with liquidSVM. If not, see <http://www.gnu.org/licenses/>.
#ifndef BINDINGS_COMMON_SCENARIO_CONFIG_H_
#define BINDINGS_COMMON_SCENARIO_CONFIG_H_
//#include "liquidSVM.h"
#include <string>
#include <map>
#include <vector>
using namespace std;
enum SCENARIO { MC_SVM, LS_SVM, NPL_SVM, ROC_SVM, QT_SVM, EX_SVM, BS_SVM, SCENARIO_MAX };
class Tconfig {
public:
Tconfig();
void read_from_file(FILE* fpread);
void write_to_file(FILE* fpwrite) const;
string VOTE_METHOD;
void set_scenario(int scenario, string param);
void set_grid(int grid);
void set(const char* name, string value);
void set(const char* name, double value);
void set(const char* name, int value);
string get(const char* name);
string get(const char* name, string defaultValue);
int getI(const char* name);
double getD(const char* name);
int getI(const char* name, int defaultValue);
double getD(const char* name, double defaultValue);
bool has(const char* name);
string getPrefixed(const char* name, string prefix);
void clear();
const string config_line(int stage);
private:
map<string, string> _config;
};
extern "C" {
void liquid_svm_set_param(int cookie, const char* name, const char* value);
char* liquid_svm_get_param(int cookie, const char* name);
char* liquid_svm_get_config_line(int cookie, int stage);
}
#ifndef COMPILE_SEPERATELY__
#include "./scenario_config.cpp"
#endif
#endif /* BINDINGS_COMMON_SCENARIO_CONFIG_H_ */
|
[
"csardi.gabor+cran@gmail.com"
] |
csardi.gabor+cran@gmail.com
|
daa0b0a9147347909c0fff6ce8dc742f2cb0afd7
|
1104498744ff98f7104da6e86ea8bd4ae27b6969
|
/Cpp/DuConfig.h
|
bf8235aeda9a8502c932dc41c36a831ed39bd828
|
[] |
no_license
|
snowymo/DuAlgorithm
|
42fc12fa681966dacb5a3bab1dd00d2ab11cb41d
|
1f1f23d8fab4b2dad2304c957748c09885f887ab
|
refs/heads/master
| 2021-07-11T15:53:46.579569
| 2020-10-11T21:48:01
| 2020-10-11T21:48:01
| 205,976,393
| 0
| 0
| null | 2019-09-03T02:52:04
| 2019-09-03T02:52:04
| null |
UTF-8
|
C++
| false
| false
| 1,424
|
h
|
#pragma once
#include "common.h"
#include "DuUtils.h"
#include <chrono>
#include <ctime>
class DuConfig
{
public:
static std::string DefaultName;
std::string m_name;
public:
DuConfig();
DuConfig(std::string filename);
bool Load(std::string filename);
void SetErrorIfNameNotFound(bool error) { m_bErrorIfNameNotFound = error; }
std::string GetString(const std::string &name) const;
std::wstring GetWString(const std::string &name) const;
bool GetBool(const std::string &name) const;
int GetInt(const std::string &name) const;
float GetFloat(const std::string &name) const;
double GetDouble(const std::string &name) const;
std::string GetName() const;
public:
std::vector<std::string> GetKeyList() const;
bool HasKey(const std::string &name) const; //presence of key
public:
std::string GetStringWithDefault(const std::string &name, const std::string& defaultValue) const;
std::wstring GetWStringWithDefault(const std::string &name, const std::wstring& defaultValue) const;
bool GetBoolWithDefault(const std::string &name, bool defaultValue) const;
int GetIntWithDefault(const std::string &name, int defaultValue) const;
float GetFloatWithDefault(const std::string &name, float defaultValue) const;
double GetDoubleWithDefault(const std::string &name, double defaultValue) const;
protected:
std::map<std::string, std::string> m_mEntries;
bool m_bErrorIfNameNotFound;
};
|
[
"xiaoxinghai@gmail.com"
] |
xiaoxinghai@gmail.com
|
e60541a6a0467e0bd93e259973d9009ae5e8fbc9
|
3347d16ca419ff2192fcc55906a88b29f70887d3
|
/ALL CODES/code jam/problem B.cpp
|
5d4e6344a434513cc60cf41e2cb08faaa7b3d6a7
|
[] |
no_license
|
Ayesha049/all_contest_codes
|
47533b388514704595a32367ede97bfdca10a4b0
|
d7cfd3bfa63668b19eb1c5a64dc0a527908534a0
|
refs/heads/master
| 2021-07-12T07:10:57.548063
| 2017-10-16T22:56:35
| 2017-10-16T22:56:35
| 107,188,843
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 726
|
cpp
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
freopen("B-large.in","r",stdin);
freopen("B-large.out","w",stdout);
int t;
cin>>t;
for(int tt=1; tt<=t; tt++)
{
int n;
cin>>n;
double arr[2*n];
for(int i=0; i<(2*n); i++)
{
cin>>arr[i];
}
sort(arr,arr+(2*n));
double mxarr[n];
for(int i=0; i<n; i++)
{
mxarr[i]=arr[i]*arr[(2*n)-1-i];
mxarr[i]=1-mxarr[i];
}
double ans=1.0;
for(int i=0; i<n; i++)
{
ans*=mxarr[i];
}
cout<<"Case #"<<tt<<": ";
printf("%.6lf\n",ans);
}
}
|
[
"1405049as@gmail.com"
] |
1405049as@gmail.com
|
1c8f6e174cbaacb8a6479b630ca97a52a50f9979
|
91c63b2ec9025d68260e2544801ca72e892ae716
|
/src/Mark.cpp
|
4909d59892244d14993b8a2ffa72648b37175bb3
|
[
"MIT"
] |
permissive
|
cieslarmichal/rpg
|
90a06b0cd05025ce5b8cf535931b9bfad0dee4a6
|
c99418b15045f11b0a2916c81c73a97fbf305dcd
|
refs/heads/master
| 2023-01-04T07:37:29.805616
| 2020-11-07T11:04:37
| 2020-11-07T11:04:37
| 162,345,879
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,180
|
cpp
|
#include "Mark.h"
void Mark::markTarget(int key, std::unique_ptr<Wrapper> & player, vectorOfCharacters & enemies, sf::RenderWindow & window)
{
if (key == (int)InputKeys::MOUSELEFT)
{
sf::Vector2i windowCoordinates = sf::Mouse::getPosition(window);
sf::Vector2f worldCoordinates = window.mapPixelToCoords(windowCoordinates);
for (auto & enemy : enemies)
{
enemy.first->rect->character->setMarked(false);
}
for (auto & enemy : enemies)
{
int x = (int)enemy.first->sprite->getPosition().x;
int dx = x + enemy.first->sprite->getSpriteX();
int y = (int)enemy.first->sprite->getPosition().y;
int dy = y + enemy.first->sprite->getSpriteY();
if (worldCoordinates.x >= x && worldCoordinates.x <= dx && worldCoordinates.y >= y && worldCoordinates.y <= dy)
{
enemy.first->rect->character->setMarked(true);
}
}
}
else if (key == (int)InputKeys::MOUSERIGHT)
{
sf::Vector2i windowCoordinates = sf::Mouse::getPosition(window);
sf::Vector2f worldCoordinates = window.mapPixelToCoords(windowCoordinates);
player->rect->character->setTargetPosition(sf::Vector2i{ ((int)worldCoordinates.x - 20) ,((int)worldCoordinates.y - 20) });
}
}
|
[
"michalovskyyy@gmail.com"
] |
michalovskyyy@gmail.com
|
ea68b33f8bfc4d4066d0ee3f983aa8cb649970ce
|
a4c6d21b10eed3e0a1626dfb5ad296625a6fe2a6
|
/Samples_SE/modulator_vhpi/src/VHPI/utilities.cpp
|
99025c28a0a417272209b0b7bf056ef553a44fa2
|
[] |
no_license
|
brennanmcfarland/logic-design
|
1f833bd71b643d4f99471a64ae916945172beec9
|
2bbcf8eded315e12ac039bdb564349b06c3eb21e
|
refs/heads/master
| 2021-03-22T03:52:41.596060
| 2016-10-19T03:17:17
| 2016-10-19T03:17:17
| 71,314,171
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 35,834
|
cpp
|
/*
//--------------------------------------------------------------------------------------------------
//
// Title : utilities
// Design : modulator_vhpi
// Author : Aldec
// Company : Aldec
//
//----------------------------------------------------------------------------
// VHPI Language Interface - (C) Copyright 2004 by Aldec, Inc.
//
// File : utilities.cpp
// Generated : 3:23:32 PM Monday, August 08, 2005
// By : VHPI Wizard ver. 2.0
//
//----------------------------------------------------------------------------
//
// Description : Utility functions definitions
//
//----------------------------------------------------------------------------
*/
#include "utilities.h"
#include <stdio.h>
#include <math.h>
#include <memory.h>
#include <stdlib.h>
#include <string>
// this function adds new object to structure
TValObjPtrs* addValObj( vhpiHandleT _hNewHandle, TValObjPtrs* _pActualPointer, int _nActualSize )
{
TValObjPtrs hNewHandle;
hNewHandle.hHdl = _hNewHandle;
hNewHandle.vValue = getFieldValue( _hNewHandle );
hNewHandle.nIndex = _nActualSize;
hNewHandle.nType = 0;
for ( int i = 0; i < 10; i++ )
{
hNewHandle.enumOnes[i] = -1;
hNewHandle.enumZeros[i] = -1;
}
hNewHandle.enumMin = 2147483647;
hNewHandle.enumMax = 0;
hNewHandle.szName = strdup( (char*)vhpi_get_str( vhpiNameP, _hNewHandle ) );
hNewHandle.pBoolVar = new bool;
hNewHandle.pIntVar = new int;
hNewHandle.pRealVar = new double;
hNewHandle.pUserVars = NULL;
if ( _hNewHandle )
{
if ( ( hNewHandle.vValue->format >= vhpiEnumVecVal ) && ( hNewHandle.vValue->format <= vhpiRealVecVal ) )
{
// if array type ports, when numElems is defined
hNewHandle.pBoolVecVar = new bool [hNewHandle.vValue->numElems];
hNewHandle.pIntVecVar = new int [hNewHandle.vValue->numElems];
hNewHandle.pRealVecVar = new double [hNewHandle.vValue->numElems];
}
else
{
hNewHandle.pBoolVecVar = new bool;
hNewHandle.pIntVecVar = new int;
hNewHandle.pRealVecVar = new double;
}
// detect binary logic enum types to enable numerical conversions
if ( ( hNewHandle.vValue->format == vhpiEnumVal ) || ( hNewHandle.vValue->format == vhpiEnumVecVal ) )
{
vhpiHandleT hLiteralIt = NULL;
vhpiHandleT hLiteralHdl = NULL;
vhpiHandleT hTypeHdl = NULL;
int nTypeIndex = 0;
int nOnesIndex = 0;
int nZerosIndex = 0;
// get handle to object type
hTypeHdl = vhpi_handle( vhpiBaseType, _hNewHandle );
// iterate on all literals of scalar type
if (( hLiteralIt = vhpi_iterator( vhpiEnumLiterals, hTypeHdl ) ));
// iterate on all literals of array's element type
else (( hLiteralIt = vhpi_iterator( vhpiEnumLiterals, vhpi_handle( vhpiElemSubtype, hTypeHdl ) ) ));
if ( hLiteralIt )
while (( hLiteralHdl = vhpi_scan( hLiteralIt ) ))
{
// get literal string value
char* szStrVal;
szStrVal = strdup( (char*)vhpi_get_str( vhpiStrValP, hLiteralHdl ) );
// get its position (index) in enum type
nTypeIndex = vhpi_get( vhpiPositionP, hLiteralHdl );
// set the limits of indexes in enum type
if ( nTypeIndex > hNewHandle.enumMax )
hNewHandle.enumMax = nTypeIndex;
if ( nTypeIndex < hNewHandle.enumMin )
hNewHandle.enumMin = nTypeIndex;
// check if literal string value belongs to binary logic values set
if ( ( strcmp( szStrVal, "1" ) == 0 ) || ( strcmp( szStrVal, "H" ) == 0 ) )
// store indexes of literals treated as one in numeric calculations
hNewHandle.enumOnes[nOnesIndex++] = nTypeIndex;
else if ( ( strcmp( szStrVal, "0" ) == 0 ) || ( strcmp( szStrVal, "L" ) == 0 ) )
// store indexes of literals treated as zero in numeric calculations
hNewHandle.enumZeros[nZerosIndex++] = nTypeIndex;
free( szStrVal );
}
else
vhpi_printf( "addVAlObj(): No enum literals found.\n" );
// if type contains one and zero literals
if ( ( nZerosIndex != 0 ) && ( nOnesIndex != 0 ) )
hNewHandle.nType = 1;
// release handles
vhpi_release_handle( hTypeHdl );
vhpi_release_handle( hLiteralHdl );
}
}
// reallocate array appended with new structure
TValObjPtrs* hTempHandle;
int index;
// allocate memory for copy of actual handles array
hTempHandle = new TValObjPtrs [_nActualSize+1];
// copy array contents
for ( index = 0; index < _nActualSize; index++ )
{
hTempHandle[index] = _pActualPointer[index];
}
// append array with new object handle
hTempHandle[index++] = hNewHandle;
// remove actual array from memory
delete [] _pActualPointer ;
// allocate memory for new actual array
_pActualPointer = new TValObjPtrs [_nActualSize+1];
// copy array contents from temp array
for ( index = 0; index < _nActualSize + 1; index++ )
{
_pActualPointer[index] = hTempHandle[index];
}
// remove temp array
delete [] hTempHandle;
return _pActualPointer;
}
TValObjPtrs* addValObj( TUserVars* _pUserVars, TValObjPtrs* _pActualPointer, int _nActualSize )
{
TValObjPtrs hNewHandle;
hNewHandle.hHdl = NULL;
hNewHandle.vValue = NULL;
hNewHandle.nIndex = _nActualSize;
hNewHandle.nType = 0;
hNewHandle.szName = "UserVars";
hNewHandle.pBoolVar = NULL;
hNewHandle.pIntVar = NULL;
hNewHandle.pRealVar = NULL;
hNewHandle.pBoolVecVar = NULL;
hNewHandle.pIntVecVar = NULL;
hNewHandle.pRealVecVar = NULL;
hNewHandle.pUserVars = _pUserVars;
// reallocate array appended with new structure
TValObjPtrs* hTempHandle;
int index;
// allocate memory for copy of actual handles array
hTempHandle = new TValObjPtrs [_nActualSize+1];
// copy array contents
for ( index = 0; index < _nActualSize; index++ )
{
hTempHandle[index] = _pActualPointer[index];
}
// append array with new object handle
hTempHandle[index++] = hNewHandle;
// remove actual array from memory
delete [] _pActualPointer;
// allocate memory for new actual array
_pActualPointer = new TValObjPtrs [_nActualSize+1];
// copy array contents from temp array
for ( index = 0; index < _nActualSize + 1; index++ )
{
_pActualPointer[index] = hTempHandle[index];
}
// remove temp array
delete [] hTempHandle;
return _pActualPointer;
}
void cleanValObj( TValObjPtrs* _pValObjs )
{
int j = -1;
// iterate on all structures in table, untill the last element with NULL object handle is reached
while ( _pValObjs[++j].hHdl != NULL )
{
// release memory allocated for handle
vhpi_release_handle( _pValObjs[j].hHdl );
free( _pValObjs[j].szName );
// release memory allocated for vector objects in value structure
switch ( _pValObjs[j].vValue->format )
{
case vhpiEnumVecVal:
delete [] (_pValObjs[j].vValue->value.enumvs);
break;
case vhpiIntVecVal:
delete [] (_pValObjs[j].vValue->value.intgs);
break;
case vhpiRealVecVal:
delete [] (_pValObjs[j].vValue->value.reals);
break;
}
// release memory allocated for value structure
delete (_pValObjs[j].vValue);
// delete pointers
delete ( _pValObjs[j].pBoolVar );
delete ( _pValObjs[j].pIntVar );
delete ( _pValObjs[j].pRealVar );
delete [] ( _pValObjs[j].pBoolVecVar );
delete [] ( _pValObjs[j].pIntVecVar );
delete [] ( _pValObjs[j].pRealVecVar );
}
// delete whole array
delete [] _pValObjs;
}
// this function adjusts clock delays and checks if they are valid
void adjustClock( signed int _nUnit, unsigned int _nPeriod, double _rDuty, vhpiTimeT* _tHighDelay, vhpiTimeT* _tLowDelay )
{
vhpiPhysT tTimeUnit;
// get simulation time unit
tTimeUnit = vhpi_get_phys( vhpiSimTimeUnitP, NULL );
// check if integer value corresponding to unit is correct
if ( ( _nUnit != -15 ) && ( _nUnit != -12 ) && ( _nUnit != -9 ) && ( _nUnit != -6 ) && ( _nUnit != -3 ) && ( _nUnit != 0 ) )
{
// if not, set to ns and report problem
vhpi_printf( "adjustClock(): Selected clock unit is illegal. Setting unit to ns.\n" );
_nUnit = -9;
}
// check if real value corresponding to duty cycle is correct
if ( ( _rDuty < 0.01 ) || ( _rDuty > 0.99 ) )
{
// if not, set to 0.50 and report problem
vhpi_printf( "Selected clock duty cycle is out of legal range. Setting duty cycle to 50%.\n" );
_rDuty = 0.50;
}
// express clock period in simulation units
double rPeriod = _nPeriod * pow( 10, abs( tTimeUnit.low ) + _nUnit ); // clock period in simulation units
unsigned int nLowTime = (unsigned int)( rPeriod * ( 1 - _rDuty ) ); // clock low state duration in simulation units
unsigned int nHighTime = (unsigned int)( rPeriod * _rDuty ); // clock high state duration in simulation units
// check if period to simulation unit ratio is greater or equal than 100
if ( rPeriod < 100 )
{
vhpi_assert( (vhpiSeverityT)vhpiFailure, "Selected clock period requires greater simulation resolution.");
vhpi_sim_control( vhpiFinish );
}
_tHighDelay->low = nHighTime;
_tLowDelay->low = nLowTime;
}
// this function converts C integer to VHDL std_logic_vector
PLI_VOID int2stdlv( signed _nVal, vhpiValueT* _vValueP )
{
for ( int i = _vValueP->numElems; i > 0; i-- )
{
_vValueP->value.enumvs[i-1] = ( _nVal%2 == 1 ) ? vhpi1 : vhpi0 ;
( _nVal > 0 ) ? _nVal >>= 1 : ( _nVal-- ) >> 1;
}
}
// this function converts C integer to VHDL bit_vector
PLI_VOID int2bitv( signed _nVal, vhpiValueT* _vValueP )
{
for ( int i = _vValueP->numElems; i > 0; i-- )
{
_vValueP->value.enumvs[i-1] = ( _nVal%2 == 1 ) ? vhpibit1 : vhpibit0;
( _nVal > 0 ) ? _nVal >>= 1 : ( _nVal-- ) >> 1;
}
}
// this function converts C integer to VHDL logic enum vector
PLI_VOID int2logicv( TValObjPtrs _sStruct )
{
signed nVal = *(_sStruct.pIntVar);
for ( int i = _sStruct.vValue->numElems; i > 0; i-- )
{
_sStruct.vValue->value.enumvs[i-1] = ( nVal%2 == 1 ) ? _sStruct.enumOnes[0] : _sStruct.enumZeros[0];
( nVal > 0 ) ? nVal >>= 1 : ( nVal-- ) >> 1;
}
}
// this function converts VHDL logic enum vector to C integer
PLI_VOID logicv2int( TValObjPtrs _sStruct )
{
signed nVal = 0;
vhpiValueT* _vValueP = _sStruct.vValue;
int nSize = _vValueP->numElems;
// iterate on all vector elements
for ( int i = 0; i < nSize; i++ )
{
nVal <<= 1;
int j = 0;
// scan enumOnes[] and enumZeros[] tables to determine logic value of enum object
while ( j < 10 )
{
if ( (signed int)_vValueP->value.enumvs[i] == _sStruct.enumOnes[j] )
{
// if enum value found in enumZeros[] table
nVal++;
break;
}
if ( (signed int)_vValueP->value.enumvs[i] == _sStruct.enumZeros[j] )
// if enum value found in enumOnes[] table
break;
j++;
}
if ( j == 10 )
vhpi_printf( "logicv2int(): Logic metavalue detected, treated as zero in all conversions to integer type\n" );
}
// update pointer to integer in structure
*(_sStruct.pIntVar) = nVal;
}
bool logic2bool( TValObjPtrs _sStruct, vhpiEnumT _enumv)
{
int j = 0;
bool bVar;
// scan enumZeros[] and enumOnes[] tables to determine logic value of enum object
while ( j < 10 )
{
if ( (signed int)_enumv == _sStruct.enumZeros[j] )
{
// if enum value found in enumZeros[] table
bVar = false;
break;
}
else if ( (signed int)_enumv == _sStruct.enumOnes[j] )
{
// if enum value found in enumOnes[] table
bVar = true;
break;
}
j++;
}
if ( j == 10 )
{
// if enum value is neither one nor zero
bVar = false;
vhpi_printf( "varUpdate(): Logic metavalue detected, treated as zero in all conversions to bool type.\n" );
}
return bVar;
}
// this function converts VHDL std_logic_vector to C integer
vhpiIntT stdlv2int( vhpiValueT* _vValueP )
{
signed nVal = 0;
int nSize;
nSize = _vValueP->numElems;
for ( int i = 0; i < nSize; i++ )
{
nVal <<= 1;
if ( ( _vValueP->value.enumvs[i] == vhpi1 ) || ( _vValueP->value.enumvs[i] == vhpiH ) )
nVal++;
else if ( ( _vValueP->value.enumvs[i] == vhpiU ) || ( _vValueP->value.enumvs[i] == vhpiX ) || ( _vValueP->value.enumvs[i] == vhpiW ) || ( _vValueP->value.enumvs[i] == vhpiZ ) || ( _vValueP->value.enumvs[i] == vhpiDontCare ) )
vhpi_printf( "stdlv2int(): STD_LOGIC metavalue (UXWZ-) detected, treated as zero in all conversions to integer type\n" );
}
return nVal;
}
// this function converts VHDL std_logic_vector to C integer
vhpiIntT bv2int( vhpiValueT* _vValueP )
{
signed nVal = 0;
int nSize;
nSize = _vValueP->numElems;
for ( int i = 0; i < nSize; i++ )
{
nVal <<= 1;
if ( ( _vValueP->value.enumvs[i] == vhpibit1 ) )
nVal++;
}
return nVal;
}
// this function updates object's value of index in in information table
bool objUpdateMain( int i , TValObjPtrs* _pValObjs, void* _pVar, int _bVarType)
{
if ( ( (_pValObjs[i].vValue)->format == vhpiEnumVal ) && ( ( _bVarType == typeIntVar ) || ( ( _pValObjs[i].nType == 0 ) && ( _bVarType == typeDefaultVar ) ) ) )
{
// if scalar enum object and int variable (default for scalar objects of non-logic enum type)
if (( _pVar ))
// if user variable specified, copies it to port structure
*(_pValObjs[i].pIntVar) = *(int*)_pVar;
// updates value structure with variable value
(_pValObjs[i].vValue)->value.enumv = *(_pValObjs[i].pIntVar);
if ( ( *(_pValObjs[i].pIntVar) > _pValObjs[i].enumMax ) || ( *(_pValObjs[i].pIntVar) < _pValObjs[i].enumMin ) )
vhpi_printf( "objUpdate(): Variable value %d exceeds %s type's range.\n", *(_pValObjs[i].pIntVar), _pValObjs[i].szName );
}
else if ( ( (_pValObjs[i].vValue)->format == vhpiEnumVal ) && ( ( _bVarType == typeBoolVar ) || ( ( _pValObjs[i].nType == 1 ) && ( _bVarType == typeDefaultVar ) ) ) )
{
// if scalar enum object and bool variable (default for scalar objects of logic enum type)
if (( _pVar )) // if user variable specified, copies it to port structure
*(_pValObjs[i].pBoolVar) = *(bool*)_pVar;
// updates value structure with variable value
if ( _pValObjs[i].nType == 0 )
// if non-logic enum type
(_pValObjs[i].vValue)->value.enumv = *(_pValObjs[i].pBoolVar) ? 1 : 0;
if ( _pValObjs[i].nType == 1 )
// if logic enum type
(_pValObjs[i].vValue)->value.enumv = *(_pValObjs[i].pBoolVar) ? _pValObjs[i].enumOnes[0] : _pValObjs[i].enumZeros[0];
}
else if ( ( (_pValObjs[i].vValue)->format == vhpiEnumVecVal ) && ( ( _bVarType == typeIntVecVar ) || ( ( _pValObjs[i].nType == 0 ) && ( _bVarType == typeDefaultVar ) ) ) )
{
// if vector of enum object and int[n] variable (default for vector objects of non-logic enum type)
if (( _pVar ))
// if user variable specified, copies it to port structure
memcpy( _pValObjs[i].pIntVecVar, _pVar, _pValObjs[i].vValue->bufSize );
// updates value structure with variable value
for ( int j = 0; j < _pValObjs[i].vValue->numElems; j++ )
{
// check if integer value fits the object type range
if ( ( _pValObjs[i].pIntVecVar[j] <= _pValObjs[i].enumMax ) && ( _pValObjs[i].pIntVecVar[j] >= _pValObjs[i].enumMin ) )
(_pValObjs[i].vValue)->value.enumvs[j] = _pValObjs[i].pIntVecVar[j];
else
{
// if integer value exceeds the object type range
vhpi_printf( "objUpdate(): Variable value %d exceeds %s type range. Object value set to the leftmost value in type\n", _pValObjs[i].pIntVecVar[j], _pValObjs[i].szName );
(_pValObjs[i].vValue)->value.enumvs[j] = _pValObjs[i].enumMin;
}
}
}
else if ( ( (_pValObjs[i].vValue)->format == vhpiEnumVecVal ) && ( _bVarType == typeBoolVecVar ) )
{
// if vector of enum object and bool[n] variable
if (( _pVar ))
// if user variable specified, copies it to port structure
memcpy( _pValObjs[i].pBoolVecVar, _pVar, _pValObjs[i].vValue->bufSize );
// updates value structure with variable value
if ( _pValObjs[i].nType == 0 )
// if non-logic type
for ( int j = 0; j < _pValObjs[i].vValue->numElems; j++ )
(_pValObjs[i].vValue)->value.enumvs[j] = _pValObjs[i].pBoolVecVar[j] ? _pValObjs[i].enumMin + 1 : _pValObjs[i].enumMin;
if ( _pValObjs[i].nType == 1 )
// if logic type
for ( int j = 0; j < _pValObjs[i].vValue->numElems; j++ )
(_pValObjs[i].vValue)->value.enumvs[j] = _pValObjs[i].pBoolVecVar[j] ? _pValObjs[i].enumOnes[0] : _pValObjs[i].enumZeros[0];
}
else if ( ( (_pValObjs[i].vValue)->format == vhpiEnumVecVal ) && ( _pValObjs[i].nType == 1 ) && ( ( _bVarType == typeIntVar ) || ( _bVarType == typeDefaultVar ) ) )
{
// if vector of enum object and int variable (default for vector objects of logic enum type)
if (( _pVar ))
// if user variable specified, copies it to port structure
memcpy( _pValObjs[i].pIntVar, _pVar, _pValObjs[i].vValue->bufSize );
// updates value structure with variable value
int2logicv( _pValObjs[i] );
}
else if ( ( (_pValObjs[i].vValue)->format == vhpiIntVal ) && ( ( _bVarType == typeIntVar ) || ( _bVarType == typeDefaultVar ) ) )
{
// if integer port and int variable (default for integer ports)
if (( _pVar ))
// if user variable specified, copies it to port structure
*(_pValObjs[i].pIntVar) = *(int*)_pVar;
// updates value structure with variable value
(_pValObjs[i].vValue)->value.intg = *(_pValObjs[i].pIntVar);
}
else if ( ( (_pValObjs[i].vValue)->format == vhpiIntVecVal ) && ( ( _bVarType == typeIntVecVar ) || ( _bVarType == typeDefaultVar ) ) )
{
// if array of integer port and int[n] variable (default for array of integer port)
if (( _pVar ))
// if user variable specified, copies it to port structure
memcpy( _pValObjs[i].pIntVecVar, _pVar, _pValObjs[i].vValue->bufSize );
// updates value structure with variable value
for ( int j = 0; j < _pValObjs[i].vValue->numElems; j++ )
(_pValObjs[i].vValue)->value.intgs[j] = _pValObjs[i].pIntVecVar[j];
}
else if ( ( (_pValObjs[i].vValue)->format == vhpiRealVal ) && ( ( _bVarType == typeRealVar ) || ( _bVarType == typeDefaultVar ) ) )
{
// if real port and double variable (default for real port)
if (( _pVar ))
// if user variable specified, copies it to port structure
*(_pValObjs[i].pRealVar) = *(double*)_pVar;
// updates value structure with variable value
(_pValObjs[i].vValue)->value.real = *(_pValObjs[i].pRealVar);
}
else if ( ( (_pValObjs[i].vValue)->format == vhpiRealVecVal ) && ( ( _bVarType == typeRealVecVar ) || ( _bVarType == typeDefaultVar ) ) )
{
// if array of real port and double[n] variable (default for array of real port)
if (( _pVar ))
// if user variable specified, copies it to port structure
memcpy( _pValObjs[i].pRealVecVar, _pVar, _pValObjs[i].vValue->bufSize );
// updates value structure with variable value
for ( int j = 0; j < _pValObjs[i].vValue->numElems; j++ )
(_pValObjs[i].vValue)->value.reals[j] = _pValObjs[i].pRealVecVar[j];
}
else
{
vhpi_printf( "objUpdate(): Object %s type is not supported\n", _pValObjs[i].szName );
return false;
}
vhpiErrorInfoT errInf;
if ( ( vhpi_put_value( _pValObjs[i].hHdl, _pValObjs[i].vValue, vhpiDepositPropagate ) ) == 0 )
{
// vhpi_printf("Signal value update succeeded\n");
return true;
}
else
{
vhpi_printf( "objUpdate(): Object %s value update failed\n", _pValObjs[i].szName );
// check error info from vhpi_put_value()
if ( vhpi_check_error( &errInf ) )
vhpi_printf( "objUpdate(): vhpi_check_error() message: \n", errInf.message );
else
vhpi_printf( "objUpdate(): No vhpi_check_error() message...\n" );
return false;
}
}
// this function updates object's value
bool objUpdate( vhpiHandleT _hPortHdl, TValObjPtrs* _pValObjs, void* _pVar, int _bVarType )
{
int i = getId( _hPortHdl, _pValObjs );
if ( i == -1 )
{
vhpi_printf( "objUpdate(): getId() has returned -1. No object found\n" );
return false;
}
return objUpdateMain( i , _pValObjs, _pVar, _bVarType );
}
// this function updates object's value
bool objUpdate( char* _szPortName, TValObjPtrs* _pValObjs, void* _pVar, int _bVarType )
{
int i = getId( _szPortName, _pValObjs );
if ( i == -1 )
{
vhpi_printf( "objUpdate(): getId() has returned -1. No object found\n" );
return false;
}
return objUpdateMain( i , _pValObjs, _pVar, _bVarType );
}
// this function updates user's variable value
bool varUpdateMain( int i, TValObjPtrs* _pValObjs, void* _pVar, int _bVarType )
{
if ( vhpi_get_value( _pValObjs[i].hHdl, _pValObjs[i].vValue ) == 0 )
// check port type
switch ( _pValObjs[i].vValue->format )
{
case vhpiEnumVal: // scalar enum object
// copies port value to boolean variable in port map
if ( _pValObjs[i].nType == 1 )
{
// if logic object (i.e. representing numerical value in binary logic)
*(_pValObjs[i].pBoolVar) = logic2bool( _pValObjs[i], _pValObjs[i].vValue->value.enumv );
}
else if ( _pValObjs[i].nType == 0 )
// if non-logic object
if ( ( (_pValObjs[i].vValue)->value.enumv != 0 ) )
*(_pValObjs[i].pBoolVar) = true;
else
*(_pValObjs[i].pBoolVar) = false;
else
{
vhpi_printf( "varUpdate(): Object type is not supported\n" );
return false;
}
// copies port value to integer variable in port structure
*(_pValObjs[i].pIntVar) = (_pValObjs[i].vValue)->value.enumv ;
if ( _pVar )
// if user variable specified, copies value from port structure
if ( ( _bVarType == typeBoolVar ) || ( ( _bVarType == typeDefaultVar ) && ( _pValObjs[i].nType == 1 ) ) ) // boolean variable
*(bool*)_pVar = *(_pValObjs[i].pBoolVar);
else if ( ( _bVarType == typeIntVar ) || ( ( _bVarType == typeDefaultVar ) && ( _pValObjs[i].nType == 0 ) ) ) // integer variable
*(int*)_pVar = *(_pValObjs[i].pIntVar);
else
vhpi_printf( "varUpdate(): Variable type not supported\n" );
return true;
break;
case vhpiEnumVecVal: // vector port
// copies port value to integer variable in port map
if ( _pValObjs[i].nType == 1 )
logicv2int( _pValObjs[i] );
// copies port value to integer[n] variable in port map
for ( int j = 0; j < (_pValObjs[i].vValue)->numElems; j++ )
_pValObjs[i].pIntVecVar[j] = (_pValObjs[i].vValue)->value.enumvs[j];
// copies port value to boolean[n] variable in port map
for ( int j = 0; j < (_pValObjs[i].vValue)->numElems; j++ )
{
if ( _pValObjs[i].nType == 1 )
// if logic object (i.e. representing numerical value in binary logic)
_pValObjs[i].pBoolVecVar[j] = logic2bool( _pValObjs[i], (_pValObjs[i].vValue)->value.enumvs[j] );
if ( _pValObjs[i].nType == 0 )
// if non-logic object
_pValObjs[i].pBoolVecVar[j] = ( (_pValObjs[i].vValue)->value.enumvs[j] == 0 ) ? false : true ;
}
if ( _pVar )
// if user variable specified, copies value from port structure
if ( ( _pValObjs[i].nType == 1 ) && ( ( _bVarType == typeIntVar ) || ( _bVarType == typeDefaultVar ) ) ) // integer variable
*(int*)_pVar = *(_pValObjs[i].pIntVar);
else if ( _bVarType == typeBoolVecVar ) // boolean[n] variable
memcpy( _pVar, _pValObjs[i].pBoolVecVar, _pValObjs[i].vValue->bufSize );
else if ( ( _bVarType == typeIntVecVar ) || ( ( _bVarType == typeDefaultVar ) && ( _pValObjs[i].nType == 0 ) ) ) // integer[n] variable
memcpy( _pVar, _pValObjs[i].pIntVecVar, _pValObjs[i].vValue->bufSize );
else
vhpi_printf( "varUpdate(): Variable type not supported\n" );
return true;
break;
case vhpiRealVal: // real port
// copies port value to real variable in port map
*(_pValObjs[i].pRealVar) = (_pValObjs[i].vValue)->value.real;
if ( _pVar )
// if user variable specified, copies value from port structure
*(double*)_pVar = *(_pValObjs[i].pRealVar);
return true;
break;
case vhpiRealVecVal: // real port
// copies port value to real[n] variable in port map
for ( int j = 0; j < (_pValObjs[i].vValue)->numElems; j++ )
_pValObjs[i].pRealVecVar[j] = (_pValObjs[i].vValue)->value.reals[j];
if ( _pVar )
// if user variable specified, copies value from port structure
memcpy( _pVar, _pValObjs[i].pRealVecVar, _pValObjs[i].vValue->bufSize );
return true;
break;
case vhpiIntVal: // integer port
// copies port value to integer variable in port map
*(_pValObjs[i].pIntVar) = (_pValObjs[i].vValue)->value.intg;
if ( _pVar )
// if user variable specified, copies value from port structure
*(int*)_pVar = *(_pValObjs[i].pIntVar);
return true;
break;
case vhpiIntVecVal: // integer[n] port
// copies port value to integer[n] variable in port map
for ( int j = 0; j < (_pValObjs[i].vValue)->numElems; j++ )
_pValObjs[i].pIntVecVar[j] = (_pValObjs[i].vValue)->value.intgs[j];
if ( _pVar )
// if user variable specified, copies value from port structure
memcpy( _pVar, _pValObjs[i].pIntVecVar, _pValObjs[i].vValue->bufSize );
return true;
break;
default:
vhpi_printf( "varUpdate(): Object type is not supported yet\n" );
return false;
break;
}
else
{
vhpiErrorInfoT errInf;
vhpi_printf( "varUpdate(): Call to vhpi_get_value() failed\n" );
// check error info from vhpi_get_value()
if ( vhpi_check_error( &errInf ) )
vhpi_printf( "varUpdate(): vhpi_check_error() message: \n", errInf.message );
else
vhpi_printf( "varUpdate(): No vhpi_check_error() message...\n" );
return false;
}
}
// this function updates user's variable value
bool varUpdate( char* _szName, TValObjPtrs* _pValObjs, void* _pVar, int _bVarType )
{
// get index of searched object
int i = getId( _szName, _pValObjs );
if ( i == -1 )
{
vhpi_printf( "varUpdate(): getId() has returned -1. No object found\n" );
return false;
}
return varUpdateMain( i, _pValObjs, _pVar, _bVarType );
}
// this function updates user's variable value
bool varUpdate( vhpiHandleT _hHdl, TValObjPtrs* _pValObjs, void* _pVar, int _bVarType )
{
// get index of searched object
int i = getId( _hHdl, _pValObjs );
if ( i == -1 )
{
vhpi_printf( "varUpdate(): getId() has returned -1. No object found\n" );
return false;
}
return varUpdateMain( i, _pValObjs, _pVar, _bVarType );
}
// this function updates value returned by function/procedure
bool retUpdate( vhpiValueT* _vValue, unsigned* _pVar, int _vhdlType )
{
switch ( _vValue->format )
{
case vhpiEnumVal:
if ( ( _vhdlType == 0 ) && ( *_pVar >= vhpiU ) && ( *_pVar <= vhpiDontCare ) )
_vValue->value.enumv = *_pVar;
else if ( ( _vhdlType == 1 ) && ( *_pVar >= vhpibit0 ) && ( *_pVar <= vhpibit1 ) )
_vValue->value.enumv = *_pVar;
else
{
vhpi_printf( "retUpdate(): Int value exceeds logic type range\n" );
_vValue->value.enumv = 0;
return false;
}
break;
case vhpiIntVal:
_vValue->value.intg = *_pVar;
break;
case vhpiIntVecVal:
// _vValue->value.intgs = (vhpiIntT*) malloc( _vValue->bufSize );
_vValue->value.intgs = new vhpiIntT [_vValue->bufSize];
for ( int j = 0; j < _vValue->numElems; j++ )
_vValue->value.intgs[j] = _pVar[j];
break;
case vhpiEnumVecVal:
// _vValue->value.enumvs = (vhpiEnumT*) malloc( _vValue->bufSize );
_vValue->value.enumvs = new vhpiEnumT [_vValue->bufSize];
if ( _vhdlType == 0 )
int2stdlv( *_pVar, _vValue );
else if ( _vhdlType == 1 )
int2bitv( *_pVar, _vValue );
else
{
vhpi_printf( "retUpdate(): Type mismatch\n" );
*_pVar = 0;
return false;
}
break;
default:
vhpi_printf( "retUpdate(): Type mismatch\n" );
*_pVar = 0;
return false;
}
return true;
}
bool retUpdate( vhpiValueT* _vValue, double* _pVar, int _vhdlType )
{
switch ( _vValue->format )
{
case vhpiRealVal:
_vValue->value.real = *_pVar;
break;
case vhpiRealVecVal:
// _vValue->value.reals = (vhpiRealT*) malloc( _vValue->bufSize );
_vValue->value.reals = new vhpiRealT [_vValue->bufSize];
for ( int j = 0; j < _vValue->numElems; j++ )
_vValue->value.reals[j] = _pVar[j];
break;
default:
vhpi_printf( "retUpdate(): Type mismatch\n" );
*_pVar = 0;
return false;
}
return true;
}
// this function gets index of object in objects table for given object name
int getId( char* _szName, TValObjPtrs* _pValObjs )
{
int i = -1;
// search structures table for object name
while ( _pValObjs[++i].szName )
{
if ( stricmp( _szName, _pValObjs[i].szName ) == 0 )
{
return i;
break;
}
}
vhpi_printf( "getId(): i = %d, Object Name: %s \n", i, _szName );
vhpi_assert( (vhpiSeverityT)vhpiFailure, "getId(): Object not found");
return -1;
}
// this function gets index of object in objects table for given object handle
int getId( vhpiHandleT _hHdl, TValObjPtrs* _pValObjs )
{
int i = -1;
while ( _pValObjs[++i].hHdl )
if ( vhpi_compare_handles( _pValObjs[i].hHdl, _hHdl ) == 1 )
{
return i;
break;
}
vhpi_printf( "getId(): i = %d, Object Handle: %d \n", i, _hHdl );
vhpi_assert( (vhpiSeverityT)vhpiFailure, "getId(): Object not found");
return -1;
}
// this function gets index of user variables structure pointer in objects table
int getUserId( TValObjPtrs* _pValObjs )
{
int i = -1;
while ( _pValObjs[++i].hHdl != NULL );
if ( _pValObjs[i].pUserVars != NULL )
return i;
else
{
return -1;
vhpi_assert( (vhpiSeverityT)vhpiFailure, "getUserId(): Pointer to user variables structure not found");
}
}
// this function creates and allocates proper object for value of passed signal
vhpiValueT* getFieldValue( vhpiHandleT _hSigHdl )
{
vhpiValueT* vValue = NULL;
if ( _hSigHdl )
{
// allocates memory for vhpiValueT structure
// vValue = (vhpiValueT*) malloc( sizeof( vhpiValueT ) );
vValue = new vhpiValueT;
memset( vValue, '\x0', sizeof(vhpiValueT) );
// reads format from object (e.g. enum or int etc.)
vValue->format = vhpiObjTypeVal;
// if object size is greater than allocated value structure
// i.e. object has more than one element e.g. is a vector
// then allocate additional memory according to number of elements
if ( vhpi_get_value( _hSigHdl, vValue ) > 0)
{
switch ( vValue->format )
{
case vhpiEnumVecVal:
// read number of elements read by vhpi_get_value
vValue->bufSize = vValue->numElems * sizeof( vhpiEnumT );
// allocate memory
vValue->value.enumvs = new vhpiEnumT [vValue->bufSize];
break;
case vhpiIntVecVal:
vValue->bufSize = vValue->numElems * sizeof( vhpiIntT );
vValue->value.intgs = new vhpiIntT [vValue->bufSize];
break;
case vhpiRealVecVal:
vValue->bufSize = vValue->numElems * sizeof( vhpiRealT );
vValue->value.reals = new vhpiRealT [vValue->bufSize];
break;
}
}
}
return vValue;
}
// this function converts integer vhpiModeP property values to strings
// its only purpose is to display the mode on console during getting handles
char* conv_mode( int mode )
{
switch ( mode )
{
case 1001:
return "vhpiInMode";
break;
case 1002:
return "vhpiOutMode";
break;
case 1003:
return "vhpiInoutMode";
break;
case 1004:
return "vhpiBufferMode";
break;
case 1005:
return "vhpiLinkageMode";
break;
default:
return "Illegal Mode Value";
break;
}
}
// this function gets handle to signal of specified hierarchical name
vhpiHandleT getHandle( char* _szSigName )
{
vhpiHandleT hSigHdl,hHdl,hSubItr,hSubHdl;
// get handle to root instance
if ( ( hHdl = vhpi_handle( vhpiRootInst, NULL ) ) )
{
// get handle to signal - try root instance first
if ( !( hSigHdl = vhpi_handle_by_name( _szSigName, hHdl ) ) )
{
// if failed, iterate internal regions
if (( hSubItr = vhpi_iterator( vhpiInternalRegions, hHdl ) ))
{
while (( hSubHdl = vhpi_scan( hSubItr ) ))
if ( !( hSigHdl = vhpi_handle_by_name( _szSigName, hSubHdl ) ) )
{
// if failed, print info
vhpi_printf( "getHandle(): No signals found searching root and internal regions or ambiguous signal name\n" );
return NULL;
}
}
else
{
vhpi_printf( "getHandle(): No internal regions found\n" );
return NULL;
}
}
// if getting handle succeeded, print information on console...
if ( strcmp( vhpi_get_str( vhpiKindStrP, hSigHdl ), "vhpiPortDeclK" ) == 0 )
// ...with mode in case of port
vhpi_printf( "getHandle(): Port %s found: kind %s, mode %s\n",vhpi_get_str( vhpiFullNameP, hSigHdl ), vhpi_get_str( vhpiKindStrP, hSigHdl ), conv_mode( vhpi_get( vhpiModeP, hSigHdl ) ) );
else
// ...without mode in case of other object
vhpi_printf( "getHandle(): Object %s found: kind %s\n", vhpi_get_str( vhpiFullNameP, hSigHdl ), vhpi_get_str( vhpiKindStrP, hSigHdl ) );
return hSigHdl;
}
else
{
vhpi_printf( "getHandle(): No root instance found\n" );
return NULL;
}
}
// this function registers callback for vhpiCbValueChange reason
// arguments: handles to signal and to user data
bool isRegisteredCbValueChange( PLI_VOID( *cb_rtn_name ) (const struct vhpiCbDataS *), vhpiHandleT _hSigHdl, PLI_VOID* _hUserData )
{
vhpiCbDataT cbData;
vhpiHandleT cbData_Hdl;
vhpiErrorInfoT errInf;
cbData.cb_rtn = cb_rtn_name;
cbData.reason = vhpiCbValueChange;
cbData.obj = _hSigHdl;
cbData.value = getFieldValue( cbData.obj );
cbData.time = NULL;
cbData.user_data = _hUserData; // pass user data handle to callback
vhpi_register_cb( &cbData, vhpiReturnCb );
if ( ( cbData_Hdl = vhpi_register_cb( &cbData, vhpiReturnCb ) ) )
return true;
else
{
// check error message and print failure info
vhpi_printf( "isRegisteredCbValueChange(): Callback on vhpiCbValueChange reason for signal: %s NOT registered \n", vhpi_get_str( vhpiFullNameP, _hSigHdl ) );
if ( vhpi_check_error( &errInf ) )
vhpi_printf( errInf.message );
else
vhpi_printf( "isRegisteredCbValueChange(): No vhpi_check_error() message...\n" );
return false;
}
}
// this function registers callback for vhpiCbEndOfSimulation reason
// arguments: callback routine name
bool isRegisteredCbEndOfSimulation( PLI_VOID(*cb_rtn_name) (const struct vhpiCbDataS *), PLI_VOID* _hUserData )
{
vhpiCbDataT cbData;
vhpiHandleT cbData_Hdl;
vhpiErrorInfoT errInf;
cbData.reason = vhpiCbEndOfSimulation ;
cbData.cb_rtn = cb_rtn_name;
cbData.obj = NULL;
cbData.time = NULL;
cbData.value = NULL;
cbData.user_data = _hUserData;
if ( ( cbData_Hdl = vhpi_register_cb( &cbData, vhpiReturnCb ) ) )
return true;
else
{
// check error message and print failure info
vhpi_printf( "isRegisteredCbEndOfSimulation(): Callback on vhpiCbEndOfSimulation reason NOT registered \n" );
if ( vhpi_check_error( &errInf ) )
vhpi_printf( errInf.message );
else
vhpi_printf( "isRegisteredCbEndOfSimulation(): No vhpi_check_error() message...\n" );
return false;
}
}
// this function registers callback for vhpiCbAfterDelay reason
// arguments: callback routine name, delay in simulation resolution units
vhpiHandleT registerCbAfterDelay( PLI_VOID(*cb_rtn_name) (const struct vhpiCbDataS *), vhpiTimeT _tTime, PLI_VOID* _hUserData )
{
vhpiCbDataT cbData;
vhpiHandleT cbData_Hdl;
vhpiErrorInfoT errInf;
cbData.reason = vhpiCbAfterDelay;
cbData.cb_rtn = cb_rtn_name;
cbData.obj = NULL;
cbData.time = &_tTime;
cbData.value = NULL;
cbData.user_data = _hUserData;
if ( ( cbData_Hdl = vhpi_register_cb( &cbData, vhpiReturnCb ) ) )
return cbData_Hdl;
else
{
// check error message and print failure info
vhpi_printf( "isRegisteredCbAfterDelay(): Callback on vhpiCbAfterDelay reason NOT registered \n" );
if ( vhpi_check_error( &errInf ) )
vhpi_printf( errInf.message );
else
vhpi_printf( "isRegisteredCbAfterDelay(): No vhpi_check_error() message...\n" );
return NULL;
}
}
|
[
"bfm21@case.edu"
] |
bfm21@case.edu
|
5172032073a99ae5c7146b88a9f65d6fb01c6138
|
68a140266a7ed4de625f9632efbb3a958fb7be65
|
/proj3/proj3/main.cpp
|
c64cc8af6acaad153abf31d425f8391ed0887d56
|
[] |
no_license
|
harrynp/ICS45c_Programming_in_C
|
28303e1f81d76a94834e08bdfaa6774de5b46fbb
|
fffc947bdd249a80d4d898a0f0415214eb409ba1
|
refs/heads/master
| 2016-09-05T11:42:18.222384
| 2015-01-30T00:45:31
| 2015-01-30T00:45:58
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 86
|
cpp
|
//Harry Pham 79422112
#include "UI.hpp"
int main(){
UI ui = UI();
ui.input();
}
|
[
"harrynp12@gmail.com"
] |
harrynp12@gmail.com
|
68e558211315cd645dfeacdd53bc18c1a8e4f8f5
|
e873a7d3603f0d926d3a1f09e8ce8e0129a43fe5
|
/FEM_remote_pedal.ino
|
43e87b92ca1ce0ecacb061d897f26bf48c1e3402
|
[] |
no_license
|
travuga77/FEM_remote_pedal
|
a2a0b1c7c7f51bc7153faeaabfdc99a739a03c00
|
dd399328dcd08785c85d990ee4b9c664ca524338
|
refs/heads/master
| 2020-03-21T08:03:39.028628
| 2019-05-29T10:29:52
| 2019-05-29T10:29:52
| 138,317,212
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,606
|
ino
|
#include <mcp_can.h>
#include <SPI.h>
#define CAN0_INT 2 // Set INT to pin 2
MCP_CAN CAN0(10); // Set CS to pin 10
int lSensorData, rSensorData, lSensorConv, rSensorConv;
byte data[8] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
const byte lSensorPin = 1;
const byte rSensorPin = 6;
unsigned long timer = 0;
int errCode;
void CanMsgSend(int value, int err)
{
byte sndStat;
data[0] = value%256;
data[1]= value>>8;
sndStat = CAN0.sendMsgBuf(0x150, 0, 2, data);
// Serial.print(value);
if (millis()-timer>1000)
{
data[0] = err%256;
data[1]= err>>8;
sndStat = CAN0.sendMsgBuf(0x151, 0, 2, data);
timer = millis();
Serial.println(err);
}
/*if(sndStat == CAN_OK){
Serial.println("Message Sent Successfully!");
} else {
Serial.println("Error Sending Message...");
}*/
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
if (CAN0.begin(MCP_ANY, CAN_250KBPS, MCP_8MHZ) == CAN_OK)
Serial.println("MCP2515 Initialized Successfully!");
else
Serial.println("Error Initializing MCP2515...");
CAN0.setMode(MCP_NORMAL); // Set operation mode to normal so the MCP2515 sends acks to received data.
pinMode(CAN0_INT, INPUT); // Configuring pin for /INT input
pinMode(A6, INPUT);
digitalWrite(A6, LOW);
pinMode(A1, INPUT);
digitalWrite(A1, LOW);
//Serial.println("MCP2515 Library Receive Example...");
}
void loop() {
// put your main code here, to run repeatedly:
delay(45);
//timer = millis();
lSensorData = 1023-analogRead(lSensorPin);
rSensorData = 1023-analogRead(rSensorPin);
/*if (rSensorData>100&&rSensorData<900&&lSensorData>100&&lSensorData<900)
{
errCode = 0;
// CanMsgSend(0, 601);
// return;
}
if (rSensorData<100&&lSensorData>100&&lSensorData<900)
{
errCode = 601;
CanMsgSend(0, 601);
return;
}
if (lSensorData<1&&rSensorData>100&&rSensorData<900)
{
errCode = 602;
CanMsgSend(0, 602);
return;
}
if (lSensorData<100&&rSensorData<100)
{
errCode = 603;
CanMsgSend(0, 603);
return;
}
if (rSensorData>900&&lSensorData>100&&lSensorData<900)
{
errCode = 611;
CanMsgSend(0, 611);
return;
}
if (lSensorData>900&&rSensorData>100&&rSensorData<900)
{
errCode = 612;
CanMsgSend(0, 612);
return;
}
if (lSensorData>900&&rSensorData>900)
{
errCode = 613;
CanMsgSend(0, 613);
return;
}
if (lSensorData>900&&rSensorData<100)
{
errCode = 607;
CanMsgSend(0, 607);
return;
}
if (lSensorData<100&&rSensorData>900)
{
errCode = 606;
CanMsgSend(0, 606);
return;
}
*/
lSensorConv = map(lSensorData, 0, 1023, 0, 4095);
rSensorConv = map(rSensorData, 0, 1023, 0, 4095);
lSensorConv = constrain(lSensorConv, 0, 4095);
rSensorConv = constrain(rSensorConv,0, 4095);
int minim;
if (lSensorConv<rSensorConv) minim=lSensorConv; else minim=rSensorConv;
if(abs(lSensorConv-rSensorConv)>820)
{
CanMsgSend(0, 604);
minim = 0;
return;
}
CanMsgSend(minim, 0);
String debug;
debug = String(minim) + ";" + String(lSensorData) + ";" + String(rSensorData) + ";" + String(lSensorConv) + ";" + String(rSensorConv);
Serial.println(debug);
debug = "";
//Serial.println();
//data[0] = minim%256;
//data[1]=minim>>8;
//data = analogRead(rSensorPin);
//sndStat = CAN0.sendMsgBuf(0x100, 0, 2, data);
//Serial.println(rSensorData);
//Serial.println(lSensorData);
}
|
[
"travuga@yandex.ru"
] |
travuga@yandex.ru
|
e8ec1ba0738990c4a94989908ca49ccbd9cab98e
|
95a43c10c75b16595c30bdf6db4a1c2af2e4765d
|
/codecrawler/_code/hdu1121/16207850.cpp
|
a473d5bc6fba9f259f8384d81fafaf53b4a7d8b0
|
[] |
no_license
|
kunhuicho/crawl-tools
|
945e8c40261dfa51fb13088163f0a7bece85fc9d
|
8eb8c4192d39919c64b84e0a817c65da0effad2d
|
refs/heads/master
| 2021-01-21T01:05:54.638395
| 2016-08-28T17:01:37
| 2016-08-28T17:01:37
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,423
|
cpp
|
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long a[105][105];
bool cha(int i,int s)
{
for(int j=0;j<s-i;j++)
if(a[i][j]!=a[i][0])
return false;
return true;
}
int main()
{
int kase;
cin>>kase;
while(kase--)
{
memset(a,0,sizeof(a));
int s,c;
cin>>s>>c;
for(int j=0;j<s;j++)
scanf("%lld",&a[0][j]);
int degree=0;
int i=0,j=0;
while(true)
{
i++;
for(int j=0;j<s-i;j++)
a[i][j]=a[i-1][j+1]-a[i-1][j];
if(cha(i,s))
{
break;
}
}
int t=i;
/*for(int i=0;i<=t;i++)
{
for(int j=0;j<s-i;j++)
cout<<a[i][j]<<' ';
cout<<endl;
}*/
/*
1 2 7 19
1 5 12
4 7
3
*/
for(int j=0;j<s+c;j++)
a[s+c-1][j]=a[s+c-1][0];
for(int i=s+c-2;i>=0;i--)
for(int j=1;j<s+c;j++)
a[i][j]=a[i][j-1]+a[i+1][j-1];
/*for(int i=0;i<=t;i++)
{
for(int j=0;j<s+c;j++)
cout<<a[i][j]<<' ';
cout<<endl;
}*/
/*
1 2 7 19 41 76 127
1 5 12 22 35 51 70
4 7 10 13 16 19 22
3 3 3 3 3 3 3
*/
printf("%lld",a[0][s]);
for(int j=s+1;j<s+c;j++)
printf(" %lld",a[0][j]);
printf("\n");
}
return 0;
}
|
[
"zhouhai02@meituan.com"
] |
zhouhai02@meituan.com
|
4fbc08d716c4f908865faeb88c49ee0ec91098ef
|
baf852cc795ffaf6c44aa73a36e230920dd09571
|
/Minimax/Minimax.cpp
|
b254b65505d1d1786f6bc2bd4345acecdc2e7087
|
[] |
no_license
|
vduckute1812/AI
|
e9ef0cb57d4cf885b1d646a904a5c8b18bbe09b2
|
a3d47d7423c44148ce3a5498e8970bad3c463b30
|
refs/heads/master
| 2020-03-23T14:49:27.907520
| 2019-09-14T13:23:33
| 2019-09-14T13:23:33
| 141,701,943
| 0
| 0
| null | 2019-03-28T01:24:33
| 2018-07-20T11:04:30
|
C++
|
UTF-8
|
C++
| false
| false
| 11,629
|
cpp
|
#include <time.h>
#include <QTextStream>
#include "Minimax.h"
#include "BoardUntils.h"
#include "GUI/BoardGameWnd.h"
#include "Controller/Move.h"
#include "Controller/BoardController.h"
const static double MAX_VALUE = 1e4;
const static double MIN_VALUE = -1e4;
void Minimax::Init()
{
m_boardEvaluated = 0;
m_quiescenceCount = 0;
m_searchDepth = 1; //default value
m_boardEvaluator = StandardBoardEvaluator::GetInstance();
}
Move *Minimax::execute(BoardConfig board)
{
BoardGameWnd::GetInstance()->Lock(true);
double currentValue;
// int freqTableIndex = 0;
clock_t start, end;
start = clock();
Move* bestMove = nullptr;
double hightestSeenValue = MIN_VALUE;
double lowestSeenValue = MAX_VALUE;
BoardController* boardController = BoardGameWnd::GetInstance()->GetEditModeController();
MoveCollection moves = boardController->GetMoveCollections(board,board.playerTurn);
std::sort(moves.begin(), moves.end(), [](const Move* A, const Move* B){ return BoardUntils::mvvlva(A) > BoardUntils::mvvlva(B); });
MoveCollection candidateMoves;
if(moves.size() < 20)
{
candidateMoves = moves;
}
else
{
candidateMoves = MoveCollection(moves.begin() , moves.begin()+10);
}
for (Move* move: candidateMoves)
{
BoardConfig transitionBoard = move->Execute();
m_quiescenceCount = 0;
currentValue = transitionBoard.playerTurn == Alliance::WHITE ?
min(transitionBoard, m_searchDepth - 1, hightestSeenValue, lowestSeenValue):
max(transitionBoard, m_searchDepth - 1, hightestSeenValue, lowestSeenValue);
if(board.playerTurn == Alliance::WHITE && currentValue > hightestSeenValue)
{
hightestSeenValue = currentValue;
bestMove = move;
if(boardController->IsCheckMate(transitionBoard, Alliance::BLACK))
{
break;
}
}
else if(board.playerTurn == Alliance::BLACK && currentValue < lowestSeenValue)
{
lowestSeenValue = currentValue;
bestMove = move;
if(boardController->IsCheckMate(transitionBoard, Alliance::WHITE))
{
break;
}
}
BoardConfig undoBoard = move->UndoExecute();
}
/* Do the work. */
end = clock();
m_executeTime = static_cast<float>((end-start)/ float(CLOCKS_PER_SEC));
QTextStream out(stdout);
out << QChar(board.playerTurn) << " IS THINKING with depth " << m_searchDepth << ", EXECUTED TIME: " << QString::number(m_executeTime) << endl;
BoardGameWnd::GetInstance()->Lock(false);
for (Move* move: moves)
{
if(move!=bestMove)
delete move;
}
return bestMove;
}
double Minimax::min(BoardConfig board, u32 depth, double highest, double lowest)
{
if(depth == 0|| IsEndgame(board))
{
if(depth == 0)
{
m_boardEvaluated++;
}
return m_boardEvaluator->evaluate(board, depth);
}
double currentLowest = lowest;
BoardController* boardController = BoardGameWnd::GetInstance()->GetEditModeController();
// boardController->PrintBoard(board);
if(boardController->IsKingThreat(board, BoardUntils::OpponentPlayer(board.playerTurn)))
{
return m_boardEvaluator->evaluate(board, depth);
}
MoveCollection moves = boardController->GetMoveCollections(board,board.playerTurn);
std::sort(moves.begin(), moves.end(), [](const Move* A, const Move* B){ return BoardUntils::mvvlva(A) > BoardUntils::mvvlva(B); });
MoveCollection candidateMoves;
if(moves.size() < 20)
{
candidateMoves = moves;
}
else
{
candidateMoves = MoveCollection(moves.begin() , moves.begin()+10);
}
for (Move* move: candidateMoves)
{
if(move->IsPromoteMove())
continue;
BoardConfig transitionBoard = move->Execute();
// boardController->PrintBoard(transitionBoard);
currentLowest = std::min(currentLowest, max(transitionBoard, /*CalculateQuiescenceDepth(move, depth)*/ depth - 1, highest, currentLowest));
BoardConfig undoBoard = move->UndoExecute();
// boardController->PrintBoard(undoBoard);
if(currentLowest <= highest)
{
for (Move* move: moves)
{
// release memory
delete move;
}
return highest;
}
}
for (Move* move: moves)
{
// release memory
delete move;
}
return currentLowest;
}
double Minimax::max(BoardConfig board, u32 depth, double highest, double lowest)
{
if(depth == 0|| IsEndgame(board))
{
if(depth == 0)
{
m_boardEvaluated++;
}
return m_boardEvaluator->evaluate(board, depth);
}
double currentHighest = highest;
BoardController* boardController = BoardGameWnd::GetInstance()->GetEditModeController();
// boardController->PrintBoard(board);
if(boardController->IsKingThreat(board, BoardUntils::OpponentPlayer(board.playerTurn)))
{
return m_boardEvaluator->evaluate(board, depth);
}
MoveCollection moves = boardController->GetMoveCollections(board,board.playerTurn);
std::sort(moves.begin(), moves.end(), [](const Move* A, const Move* B){ return BoardUntils::mvvlva(A) > BoardUntils::mvvlva(B); });
MoveCollection candidateMoves;
if(moves.size() < 20)
{
candidateMoves = moves;
}
else
{
candidateMoves = MoveCollection(moves.begin() , moves.begin()+10);
}
for (Move* move: candidateMoves)
{
if(move->IsPromoteMove())
continue;
BoardConfig transitionBoard = move->Execute();
// boardController->PrintBoard(transitionBoard);
currentHighest = std::max(currentHighest, min(transitionBoard, /*CalculateQuiescenceDepth(move, depth)*/ depth - 1, currentHighest, lowest));
BoardConfig undoBoard = move->UndoExecute(); // return old board
// boardController->PrintBoard(undoBoard);
if(currentHighest >= lowest)
{
for (Move* move: moves)
{
// release memory
delete move;
}
return lowest;
}
}
for (Move* move: moves)
{
// release memory
delete move;
}
moves.clear();
return currentHighest;
}
void Minimax::SetDepth(u32 depth)
{
m_searchDepth = depth;
}
bool Minimax::SortMoveFollowValue(std::vector<Move *> moves)
{
return false;
}
bool Minimax::IsEndgame(BoardConfig board)
{
return false;
}
u32 Minimax::CalculateQuiescenceDepth(const Move *moveTransition, int depth)
{
return depth - 1;
}
BoardEvaluator::BoardEvaluator()
{
}
BoardEvaluator::~BoardEvaluator()
{
}
void StandardBoardEvaluator::Init()
{
}
int StandardBoardEvaluator::evaluate(const BoardConfig board, int depth)
{
return scorePlayer(board, Alliance::WHITE, depth) - scorePlayer(board, Alliance::BLACK, depth);
}
int StandardBoardEvaluator::scorePlayer(const BoardConfig board, const Alliance alliance, int depth)
{
return pieceValue(board, alliance) + mobilityRatio(board, alliance)
+ check(board, alliance) + kingThreats(board, alliance, depth) + attacks(board, alliance);
}
int StandardBoardEvaluator::mobility(const BoardConfig board, const Alliance alliance)
{
return MOBILITY_MULTIPLIER * mobilityRatio(board, alliance);
}
int StandardBoardEvaluator::mobilityRatio(const BoardConfig board, const Alliance alliance)
{
Alliance opponentAlliance = alliance == Alliance::WHITE ? Alliance::BLACK : Alliance::WHITE;
BoardController* boardController = BoardGameWnd::GetInstance()->GetEditModeController();
return static_cast<int>(boardController->GetMoveCollections(board, alliance).size() * 100 / boardController->GetMoveCollections(board, opponentAlliance).size());
}
int StandardBoardEvaluator::check(const BoardConfig board, const Alliance alliance)
{
bool isChecked = false;
BoardController* boardController = BoardGameWnd::GetInstance()->GetEditModeController();
Alliance opponentAlliance = alliance == Alliance::WHITE ? Alliance::BLACK : Alliance::WHITE;
u32 kingPosition = boardController->GetKingPosition(board, opponentAlliance);
MoveCollection moves = boardController->GetMoveCollections(board, alliance);
for (Move* move: moves)
{
if(move->GetDestCoordinate() == kingPosition)
{
isChecked = true;
break;
}
}
return isChecked ? CHECK_BONUS : 0;
}
int StandardBoardEvaluator::kingThreats(const BoardConfig board, const Alliance alliance, int depth)
{
BoardController* boardController = BoardGameWnd::GetInstance()->GetEditModeController();
CollectPieces pieces = boardController->GetPiecesOnBoard(board, alliance);
MoveCollection moves = boardController->GetMoveCollections(board, alliance);
bool hasEscapeMove = false;
for (Move* move: moves)
{
if(move->IsLegalMove())
{
hasEscapeMove = true;
break;
}
}
return hasEscapeMove ? CHECK_MATE_BONUS * depthBonus(depth) : check(board, alliance);
}
int StandardBoardEvaluator::depthBonus(int depth)
{
return depth == 0 ? 1 : DEPTH_BONUS * depth;
}
int StandardBoardEvaluator::pieceValue(const BoardConfig board, const Alliance alliance)
{
int pieceValueScore = 0;
PiecePositions boardConfig = board.pieceData;
for (unsigned int pieceIdx = 0; pieceIdx < boardConfig.size(); ++pieceIdx)
{
Piece* piece = boardConfig.at(pieceIdx);
if(piece)
{
if(BoardUntils::IsSameAlliance(piece->GetAlliance(), alliance))
{
pieceValueScore += piece->GetPieceValue();
}
}
}
return pieceValueScore;
}
int StandardBoardEvaluator::attacks(const BoardConfig board, const Alliance alliance)
{
int attackScore = 0;
BoardController* boardController = BoardGameWnd::GetInstance()->GetEditModeController();
MoveCollection moves = boardController->GetMoveCollections(board, alliance);
for(Move* move : moves)
{
if(move->IsAttackMove())
{
u32 movePieceCoord = move->GetMoveCoordinate();
const Piece* movedPiece = boardController->GetPieceOnBoard(board, movePieceCoord);
u32 attackPieceCoord = move->GetDestCoordinate();
const Piece* attackPiece = boardController->GetPieceOnBoard(board, attackPieceCoord);
if(movedPiece->GetPieceValue() < attackPiece->GetPieceValue())
{
attackScore ++;
}
}
}
return attackScore * ATTACK_MULTIPLIER;
}
int StandardBoardEvaluator::kingSafety(const BoardConfig board, const Alliance alliance)
{
return 0;
}
int StandardBoardEvaluator::pieceEvaluations(const BoardConfig board, const Alliance alliance)
{
int pieceValuationScore = 0;
int numBishops = 0;
BoardController* boardController = BoardGameWnd::GetInstance()->GetEditModeController();
for (const Piece* piece : boardController->GetPiecesOnBoard(board, alliance))
{
pieceValuationScore += piece->GetPieceValue() + piece->locationBonus();
if(piece->GetPieceType() == PieceType::BISHOP) {
numBishops++;
}
}
return pieceValuationScore + (numBishops == 2 ? TWO_BISHOPS_BONUS : 0);
}
|
[
"ducbkdn95@gmail.com"
] |
ducbkdn95@gmail.com
|
008b789790f7466cc775de1cc02272a076af8224
|
93e8d75b94de07533c8bf716790acd0792a03f5e
|
/src/bin/tpl/whereami/whereami.cpp
|
1ad61f79ed7c3100ef9425f568dc703ff5d56234
|
[
"BSD-3-Clause"
] |
permissive
|
mfkiwl/lfortran
|
44ccedd36f146537a6740dcfc4b06259c29d811b
|
94bf06129614f418cbccbca71f1a07eafbb1d77b
|
refs/heads/master
| 2023-08-06T10:24:20.930448
| 2021-09-29T14:51:05
| 2021-09-29T14:51:05
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,749
|
cpp
|
// (‑●‑●)> dual licensed under the WTFPL v2 and MIT licenses
// without any warranty.
// by Gregory Pakosz (@gpakosz)
// https://github.com/gpakosz/whereami
// in case you want to #include "whereami.c" in a larger compilation unit
#if !defined(WHEREAMI_H)
#include "whereami.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(WAI_MALLOC) || !defined(WAI_FREE) || !defined(WAI_REALLOC)
#include <stdlib.h>
#endif
#if !defined(WAI_MALLOC)
#define WAI_MALLOC(size) malloc(size)
#endif
#if !defined(WAI_FREE)
#define WAI_FREE(p) free(p)
#endif
#if !defined(WAI_REALLOC)
#define WAI_REALLOC(p, size) realloc(p, size)
#endif
#ifndef WAI_NOINLINE
#if defined(_MSC_VER)
#define WAI_NOINLINE __declspec(noinline)
#elif defined(__GNUC__)
#define WAI_NOINLINE __attribute__((noinline))
#else
#error unsupported compiler
#endif
#endif
#if defined(_MSC_VER)
#define WAI_RETURN_ADDRESS() _ReturnAddress()
#elif defined(__GNUC__)
#define WAI_RETURN_ADDRESS() __builtin_extract_return_addr(__builtin_return_address(0))
#else
#error unsupported compiler
#endif
#if defined(_WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#if defined(_MSC_VER)
#pragma warning(push, 3)
#endif
#include <windows.h>
#include <intrin.h>
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
static int WAI_PREFIX(getModulePath_)(HMODULE module, char* out, int capacity, int* dirname_length)
{
wchar_t buffer1[MAX_PATH];
wchar_t buffer2[MAX_PATH];
wchar_t* path = NULL;
int length = -1;
for (;;)
{
DWORD size;
int length_, length__;
size = GetModuleFileNameW(module, buffer1, sizeof(buffer1) / sizeof(buffer1[0]));
if (size == 0)
break;
else if (size == (DWORD)(sizeof(buffer1) / sizeof(buffer1[0])))
{
DWORD size_ = size;
do
{
wchar_t* path_;
path_ = (wchar_t*)WAI_REALLOC(path, sizeof(wchar_t) * size_ * 2);
if (!path_)
break;
size_ *= 2;
path = path_;
size = GetModuleFileNameW(module, path, size_);
}
while (size == size_);
if (size == size_)
break;
}
else
path = buffer1;
if (!_wfullpath(buffer2, path, MAX_PATH))
break;
length_ = (int)wcslen(buffer2);
length__ = WideCharToMultiByte(CP_UTF8, 0, buffer2, length_ , out, capacity, NULL, NULL);
if (length__ == 0)
length__ = WideCharToMultiByte(CP_UTF8, 0, buffer2, length_, NULL, 0, NULL, NULL);
if (length__ == 0)
break;
if (length__ <= capacity && dirname_length)
{
int i;
for (i = length__ - 1; i >= 0; --i)
{
if (out[i] == '\\')
{
*dirname_length = i;
break;
}
}
}
length = length__;
break;
}
if (path != buffer1)
WAI_FREE(path);
return length;
}
WAI_NOINLINE WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
return WAI_PREFIX(getModulePath_)(NULL, out, capacity, dirname_length);
}
WAI_NOINLINE WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
HMODULE module;
int length = -1;
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4054)
#endif
if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)WAI_RETURN_ADDRESS(), &module))
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
{
length = WAI_PREFIX(getModulePath_)(module, out, capacity, dirname_length);
}
return length;
}
#elif defined(__linux__) || defined(__CYGWIN__) || defined(__sun) || defined(WAI_USE_PROC_SELF_EXE)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(__linux__)
//#include <linux/limits.h>
#define PATH_MAX 16384
#else
#include <limits.h>
#endif
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
#if !defined(WAI_PROC_SELF_EXE)
#if defined(__sun)
#define WAI_PROC_SELF_EXE "/proc/self/path/a.out"
#else
#define WAI_PROC_SELF_EXE "/proc/self/exe"
#endif
#endif
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
char buffer[PATH_MAX];
char* resolved = NULL;
int length = -1;
for (;;)
{
resolved = realpath(WAI_PROC_SELF_EXE, buffer);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
break;
}
return length;
}
#if !defined(WAI_PROC_SELF_MAPS_RETRY)
#define WAI_PROC_SELF_MAPS_RETRY 5
#endif
#if !defined(WAI_PROC_SELF_MAPS)
#if defined(__sun)
#define WAI_PROC_SELF_MAPS "/proc/self/map"
#else
#define WAI_PROC_SELF_MAPS "/proc/self/maps"
#endif
#endif
#if defined(__ANDROID__) || defined(ANDROID)
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#endif
WAI_NOINLINE WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
int length = -1;
FILE* maps = NULL;
for (int r = 0; r < WAI_PROC_SELF_MAPS_RETRY; ++r)
{
maps = fopen(WAI_PROC_SELF_MAPS, "r");
if (!maps)
break;
for (;;)
{
char buffer[PATH_MAX < 1024 ? 1024 : PATH_MAX];
uint64_t low, high;
char perms[5];
uint64_t offset;
uint32_t major, minor;
char path[PATH_MAX];
uint32_t inode;
if (!fgets(buffer, sizeof(buffer), maps))
break;
if (sscanf(buffer, "%" PRIx64 "-%" PRIx64 " %s %" PRIx64 " %x:%x %u %s\n", &low, &high, perms, &offset, &major, &minor, &inode, path) == 8)
{
uint64_t addr = (uintptr_t)WAI_RETURN_ADDRESS();
if (low <= addr && addr <= high)
{
char* resolved;
resolved = realpath(path, buffer);
if (!resolved)
break;
length = (int)strlen(resolved);
#if defined(__ANDROID__) || defined(ANDROID)
if (length > 4
&&buffer[length - 1] == 'k'
&&buffer[length - 2] == 'p'
&&buffer[length - 3] == 'a'
&&buffer[length - 4] == '.')
{
int fd = open(path, O_RDONLY);
if (fd == -1)
{
length = -1; // retry
break;
}
char* begin = (char*)mmap(0, offset, PROT_READ, MAP_SHARED, fd, 0);
if (begin == MAP_FAILED)
{
close(fd);
length = -1; // retry
break;
}
char* p = begin + offset - 30; // minimum size of local file header
while (p >= begin) // scan backwards
{
if (*((uint32_t*)p) == 0x04034b50UL) // local file header signature found
{
uint16_t length_ = *((uint16_t*)(p + 26));
if (length + 2 + length_ < (int)sizeof(buffer))
{
memcpy(&buffer[length], "!/", 2);
memcpy(&buffer[length + 2], p + 30, length_);
length += 2 + length_;
}
break;
}
--p;
}
munmap(begin, offset);
close(fd);
}
#endif
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
break;
}
}
}
fclose(maps);
maps = NULL;
if (length != -1)
break;
}
if (maps)
fclose(maps);
return length;
}
#elif defined(__APPLE__)
#define _DARWIN_BETTER_REALPATH
#include <mach-o/dyld.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
char buffer1[PATH_MAX];
char buffer2[PATH_MAX];
char* path = buffer1;
char* resolved = NULL;
int length = -1;
for (;;)
{
uint32_t size = (uint32_t)sizeof(buffer1);
if (_NSGetExecutablePath(path, &size) == -1)
{
path = (char*)WAI_MALLOC(size);
if (!_NSGetExecutablePath(path, &size))
break;
}
resolved = realpath(path, buffer2);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
break;
}
if (path != buffer1)
WAI_FREE(path);
return length;
}
WAI_NOINLINE WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
char buffer[PATH_MAX];
char* resolved = NULL;
int length = -1;
for(;;)
{
Dl_info info;
if (dladdr(WAI_RETURN_ADDRESS(), &info))
{
resolved = realpath(info.dli_fname, buffer);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
break;
}
return length;
}
#elif defined(__QNXNTO__)
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#if !defined(WAI_PROC_SELF_EXE)
#define WAI_PROC_SELF_EXE "/proc/self/exefile"
#endif
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
char buffer1[PATH_MAX];
char buffer2[PATH_MAX];
char* resolved = NULL;
FILE* self_exe = NULL;
int length = -1;
for (;;)
{
self_exe = fopen(WAI_PROC_SELF_EXE, "r");
if (!self_exe)
break;
if (!fgets(buffer1, sizeof(buffer1), self_exe))
break;
resolved = realpath(buffer1, buffer2);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
break;
}
fclose(self_exe);
return length;
}
WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
char buffer[PATH_MAX];
char* resolved = NULL;
int length = -1;
for(;;)
{
Dl_info info;
if (dladdr(WAI_RETURN_ADDRESS(), &info))
{
resolved = realpath(info.dli_fname, buffer);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
break;
}
return length;
}
#elif defined(__DragonFly__) || defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || defined(__NetBSD__)
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <dlfcn.h>
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
char buffer1[PATH_MAX];
char buffer2[PATH_MAX];
char* path = buffer1;
char* resolved = NULL;
int length = -1;
for (;;)
{
#if defined(__NetBSD__)
int mib[4] = { CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME };
#else
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
#endif
size_t size = sizeof(buffer1);
if (sysctl(mib, (u_int)(sizeof(mib) / sizeof(mib[0])), path, &size, NULL, 0) != 0)
break;
resolved = realpath(path, buffer2);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
break;
}
if (path != buffer1)
WAI_FREE(path);
return length;
}
WAI_NOINLINE WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
{
char buffer[PATH_MAX];
char* resolved = NULL;
int length = -1;
for(;;)
{
Dl_info info;
if (dladdr(WAI_RETURN_ADDRESS(), &info))
{
resolved = realpath(info.dli_fname, buffer);
if (!resolved)
break;
length = (int)strlen(resolved);
if (length <= capacity)
{
memcpy(out, resolved, length);
if (dirname_length)
{
int i;
for (i = length - 1; i >= 0; --i)
{
if (out[i] == '/')
{
*dirname_length = i;
break;
}
}
}
}
}
break;
}
return length;
}
#else
#error unsupported platform
#endif
#ifdef __cplusplus
}
#endif
|
[
"ondrej@certik.us"
] |
ondrej@certik.us
|
d4806712f816e9d1dc1618a48d859a4b9ce11334
|
8a99964693089e32389e2b3dec68ac50657d3f2e
|
/src/CrossWindow/Cocoa/CocoaWindow.h
|
77d8d7fb6afae90812a08b8b5a3e8222d0a78afd
|
[
"MIT",
"Apache-2.0"
] |
permissive
|
asdlei99/CrossWindow
|
1bf502543a8e3301745a220e312e675471cb37d4
|
47d93a33539ddc86c10359bf7d14f19bc890e4cd
|
refs/heads/master
| 2023-08-21T00:40:52.807558
| 2021-10-19T17:54:14
| 2021-10-19T17:54:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,339
|
h
|
#pragma once
#include "../Common/EventQueue.h"
#include "../Common/Init.h"
#include "../Common/WindowDesc.h"
#include <vector>
namespace xwin
{
/**
* Wrapper Window for a NSWindow and it's various children.
*/
class Window
{
public:
Window();
~Window();
// Initialize this window with the Cocoa API.
bool create(const WindowDesc& desc, EventQueue& eventQueue);
// Get this Window's descriptor object.
xwin::WindowDesc getDesc();
// Request that this window be closed.
void close();
// Set the mouse position in display space.
void setMousePosition(unsigned x, unsigned y);
// Get the size of the current display this window is in.
UVec2 getCurrentDisplaySize();
// MacOS Only Functions:
enum class LayerType
{
Metal,
OpenGL,
LayerTypeMax
};
// Set the type of this window's view layer
void setLayer(LayerType type);
protected:
// NSString*
void* mTitle;
WindowDesc mDesc;
// XWinWindow*
void* window;
// XWinView*
void* view;
// Any Layer Type
void* layer;
/**
* MacOS Keycodes:
* https://stackoverflow.com/questions/3202629/where-can-i-find-a-list-of-mac-virtual-key-codes
*/
typedef Key MacKeycodeToDigitalInputMap[1 << (8 * sizeof(unsigned char))];
};
}
|
[
"hi@alain.xyz"
] |
hi@alain.xyz
|
0b6175d3f23d49c734f134a41932948d8104462c
|
c10a49b8476597c4e2c1e48f3755ed29b9103530
|
/Zombie.h
|
14f599a54f177faa8de831b7fb9c59bd27a57f99
|
[] |
no_license
|
StudentJoshua/HumansVsZombies
|
9e10897e50845fd9fb0426441bc7369db28181d4
|
895f266a13492e33c6f4ddc1cc34542e10ce21c0
|
refs/heads/master
| 2021-08-23T22:39:24.431800
| 2017-12-06T22:53:45
| 2017-12-06T22:53:45
| 113,215,849
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 482
|
h
|
//
// Created by inet2005 on 12/4/17.
//
#ifndef HUMANSVSZOMBIES_ZOMBIE_H
#define HUMANSVSZOMBIES_ZOMBIE_H
#include "Organism.h"
class Zombie : public Organism {
private:
int hunger = 0;
int conversion = 0;
World *world;
public:
Zombie();
Zombie(World *world, int xPos, int yPos);
virtual ~Zombie();
virtual speciesType getSpecies();
virtual void move();
virtual void convert();
bool isStarved();
};
#endif //HUMANSVSZOMBIES_ZOMBIE_H
|
[
"joshuabowersco@gmail.com"
] |
joshuabowersco@gmail.com
|
9e9da917b381c767e7dc9ecc73b8d4e8feb5507b
|
8a937b6f6ece834134c3987ae0903c6d7be447dd
|
/dataStructure/MasteringDataStructure/intro1/strucAsParameter.cpp
|
0f63e518d21742f716332af00538e12d4d54ba5f
|
[] |
no_license
|
sandesvitor/code-lessons
|
b7434b09dd26fa25e7c126e55567ec80d1457293
|
366f4a5c60729e86c802e974e9bec45c9ce7f526
|
refs/heads/master
| 2023-03-16T13:56:14.506986
| 2021-03-04T21:32:58
| 2021-03-04T21:32:58
| 302,512,269
| 0
| 0
| null | 2021-01-07T18:46:37
| 2020-10-09T02:27:06
|
HTML
|
UTF-8
|
C++
| false
| false
| 713
|
cpp
|
#include <stdio.h>
typedef struct Rectangle
{
int length;
int width;
} Rectangle;
int areaByValue(Rectangle r1)
{
return r1.length * r1.width;
}
int areaByReferemce(Rectangle &r1)
{
return r1.length * r1.width;
}
int changeDimensionsByAddress(Rectangle *p, int newLength, int newWidth)
{
p->length = newLength;
p->width = newWidth;
}
int main()
{
Rectangle rec1 = {10, 5};
printf("Area of Rectangle = %dm2\n", areaByValue(rec1));
Rectangle rec2 = {100, 50};
printf("Area of Rectangle = %dm2\n", areaByReferemce(rec2));
changeDimensionsByAddress(&rec1, 43, 78);
printf("Rec1 new dimensions:\nLength = %d\nWidth = %d", rec1.length, rec1.width);
return 0;
}
|
[
"sandesvitor@gmail.com"
] |
sandesvitor@gmail.com
|
0e21ce495fee42b477f4884d14bd5fe608943147
|
09b76bcc101a5499275ed4a2ae08d3c934ae2758
|
/Object.hpp
|
1ee2b78f54304f9cb198dab30f1828e57d7c9a6c
|
[] |
no_license
|
brzeszczot/thegame
|
a4939f929b30b1376f70e879c4fd9c293d4d0266
|
ea0b2c32f856bc62368e3c65040cb7d34a7647ee
|
refs/heads/master
| 2016-09-10T01:04:02.378061
| 2014-01-04T19:40:18
| 2014-01-04T19:40:18
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,447
|
hpp
|
#ifndef OBJECT_HPP_INCLUDED
#define OBJECT_HPP_INCLUDED
#define MIN_SPEED 50
#define LOW_SPEED 100
#define MEDIUM_SPEED 150
#define HIGH_SPEED 200
#define MAX_SPEED 300
#define MAX_VISIBLE 300
#define MEDIUM_VISIBLE 200
#define MIN_VISIBLE 100
#define ZERO_VISIBLE 10
#define NEAR_SHOT 100
#define MEDIUM_SHOT 200
#define FAR_SHOT 300
#include <iostream>
#include <SFML/Graphics.hpp>
#include "Imgs.hpp"
#include "AniSprite.hpp"
#include "WObject.hpp"
#include "Bullet.hpp"
enum e_stat {READY, MOVING, M_AVOID, DEAD};
class Object: public AniSprite
{
public:
enum gun_type {BASIC, STONE, FIREBALL, LASER};
struct gun
{
gun_type gun;
vector<Bullet*> shots;
int ammo;
int damage;
sf::Clock clock; // zegar do odmierzania czasu miedzy strzalami
float shot_clock;
float shot_time_allowed;
};
struct parameters
{
int life; // zycie
int gold; // zloto :)
int visible_dist; // na jaka odleglosc objekt potrafi widziec
int move_speed; // szybkosc poruszania sie
int shot_dist; // jak daleko strzela
unsigned int active_gun; // aktywna bron
vector<gun*> guns; // plecak z bronia
};
Imgs::obj_types type; // typ obiektu
parameters *params; // parametry bohatera
e_stat status; // MOVING status
sf::Vector2f last_position; // przy ustawianiu kazdej nowej wspolzednej najpierw zapisz ostatnia pozycje
sf::Vector2f last_contact; // wsp glownego bohatera w momencie ostatniego kontaktu wzrokowego
unsigned int lldirection;
size_t last_direction; // LAST 1-8 zaczynajac od gory jak wskazowki zegara
size_t move_direction; // 1-8 zaczynajac od gory jak wskazowki zegara
WObject *w_inside; // jesli jestesmy w srodku wobject - wez wskaznik do tego wobject
bool show; // widac obiekt na mapie lub nie widac :)
Object(Imgs *imgs, sf::Vector2f *wsp = NULL, enum Imgs::ImgName en = Imgs::IMG_MAIN1);
void MoveByDirection(size_t direction, float speed_unit);
size_t MoveDirectionReverse(size_t direction);
void AddGun(enum gun_type gt = BASIC);
~Object();
};
#endif // OBJECT_HPP_INCLUDED
|
[
"brzeszczot@gmail.com"
] |
brzeszczot@gmail.com
|
a0afeb4669fc66c9ca79a6b6d620539a386f59fd
|
eff1406457708e4fd638e029944e9cd07d0e70e3
|
/src/pq.cpp
|
8cfc8ba0a48c694e18f127b6857517ee430d9260
|
[] |
no_license
|
b166er-droid/CPP-Data-Structure-Cheat-Sheet
|
838c1627c812a0039d6bf8c21a0010bb8e328435
|
c3f17507e34b29b76d419d7d2948c9a5dadc0661
|
refs/heads/master
| 2021-09-03T05:43:48.521788
| 2018-01-06T01:12:05
| 2018-01-06T01:12:05
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,939
|
cpp
|
// Copyright srcmake.com 2017.
///////////////////////////////////////////////////////
////////// PRIORITY QUEUE ////////////////////////////////////
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main()
{
cout << "\nC++ Priority Queue Code" << endl;
/* Priority queues are good for inserting an item into a data structure when you need the DS to stay sorted. */
// Create a priority queue of integers. (Larger numbers go on top.)
priority_queue<int> pq;
// One trick for getting smaller numbers to go on top (be prioritized first) is to make the numbers negative.
// Otherwise, you can use the following to initialize such a priority queue:
//priority_queue<int, vector<int>, greater<int> > pq
// Add some numbers to our priority queue.
pq.push(4);
pq.push(2);
pq.push(2);
pq.push(6);
pq.push(5);
pq.push(3);
pq.push(1);
// pq = { 6, 5, 4, 3, 2, 2, 1 }
// Print each number and remove it from the priority queue.
cout << "Printed priority queue: " << endl;
while(pq.empty() == false) // While it's false that our pq is empty.,,
{
int topnum = pq.top();
cout << topnum << " ";
pq.pop();
}
cout << endl;
// Now let's create a priority queue of nodes, so that we can have many data types.
struct Food
{
// The three variables we care about.
bool tastesGood;
int quantity;
string name;
// Constructor for this node.
Food(bool taste, int quant, string n)
{
tastesGood = taste;
quantity = quant;
name = n;
}
// Default constructor if no info is given.
Food(): tastesGood(false), quantity(0), name("Air") {}
};
/* Node initialization is as such
Food* myFood = new Food(true, 100, "chicken");
cout << myFood->name << endl;
*/
// Create the comparison operator so that smaller quantities go on top
struct SmallerQuant
{
bool operator()(const Food* a, const Food* b) const
{
// Returns true if a is bigger than b, meaning smaller numbers are prioritized
return a->quantity > b->quantity;
}
};
// Create our priority queue of foods.
priority_queue<Food*, vector<Food*>, SmallerQuant> foodpq;
// Add some nodes to this queue.
foodpq.push(new Food(false, 1, "Apple"));
foodpq.push(new Food(true, 2, "Banana"));
foodpq.push(new Food(true, 5, "Eclair"));
foodpq.push(new Food(true, 3, "Chocolate"));
foodpq.push(new Food(true, 4, "French Fries"));
// Print each food in our pq.
cout << endl << "Printed Food priority queue: " << endl;
int counter = 0;
while(foodpq.empty() == false)
{
counter += 1;
Food* food = foodpq.top();
foodpq.pop();
cout << "Food number " << counter << " has " << food->quantity << " of " << food->name << " and it ";
if(food->tastesGood == true)
{
cout << "tastes good!" << endl;
}
else
{
cout << "tastes bad!" << endl;
}
}
return 0;
}
///////////////////////////////////////////////////////
|
[
"github@srcmake.com"
] |
github@srcmake.com
|
b0c579f85d47a43b6b796b5180b585b4371aa4a4
|
cf8ddfc720bf6451c4ef4fa01684327431db1919
|
/SDK/ARKSurvivalEvolved_EngramEntry_LargeWall_Stone_classes.hpp
|
2095a6fbe8380e859fdf521e43236bf891839b8f
|
[
"MIT"
] |
permissive
|
git-Charlie/ARK-SDK
|
75337684b11e7b9f668da1f15e8054052a3b600f
|
c38ca9925309516b2093ad8c3a70ed9489e1d573
|
refs/heads/master
| 2023-06-20T06:30:33.550123
| 2021-07-11T13:41:45
| 2021-07-11T13:41:45
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 836
|
hpp
|
#pragma once
// ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_EngramEntry_LargeWall_Stone_structs.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass EngramEntry_LargeWall_Stone.EngramEntry_LargeWall_Stone_C
// 0x0000 (0x0090 - 0x0090)
class UEngramEntry_LargeWall_Stone_C : public UPrimalEngramEntry
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass EngramEntry_LargeWall_Stone.EngramEntry_LargeWall_Stone_C");
return ptr;
}
void ExecuteUbergraph_EngramEntry_LargeWall_Stone(int EntryPoint);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
[
"sergey.2bite@gmail.com"
] |
sergey.2bite@gmail.com
|
6a80565ab63ff97648cd39415b45a6ba97bf50b2
|
7a4cfcd3873b3da3989cfccf7092fc038b51020b
|
/Ex.07.14.CPP
|
7b1a762ffe853636523ab0ed8c69815932f0eb78
|
[] |
no_license
|
201816040316/Assignment_02
|
0e59c014ec02f639be9ba98d836cc0d90d6b8a6a
|
7e244cf38eddac84bad926b4a475ea88539c6e56
|
refs/heads/master
| 2020-08-27T09:12:56.859349
| 2019-10-25T16:02:23
| 2019-10-25T16:02:23
| 217,313,147
| 0
| 0
| null | 2019-10-24T14:00:27
| 2019-10-24T14:00:25
| null |
UTF-8
|
C++
| false
| false
| 585
|
cpp
|
#include <iostream>
#include<iomainp>
#include<vector>
#include<stdexcept>
using namespace std;
int main()
{
int number, i;
vector<int>num(20);//20-element vector<int>
for(i = 0 ; i < 20; i++)
{
cin>>number;
if((number <= 100)&&(number>=10))
for(i =0; i < 20 ; i++)
{
if(number =! number[i])
{
num.push_back(number);
cout<<num[i]<,endl;
}
else
{
num[i]=0;
}
}
}
return 0;
}
|
[
"noreply@github.com"
] |
201816040316.noreply@github.com
|
e0d14665cf72ed5572c0449ee518300014ab478d
|
89176f53f324e233e514dbc999724e9e257881bd
|
/LinerSoftmax/ScaleAndShift.h
|
5e503d538cf2e59226aa8549aebcdd2d51c39133
|
[] |
no_license
|
FeiiYin/LowPrecision
|
6bd565c477a2878d3fd8ada2183ee3ac11d5a24f
|
ed0638766813671c14c76b7da6e292e166fbaf1b
|
refs/heads/master
| 2022-03-29T06:17:30.998182
| 2019-07-09T14:01:41
| 2019-07-09T14:01:41
| 165,354,614
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,679
|
h
|
/* NiuTrans.Tensor - an open-source tensor library
* Copyright (C) 2017, Natural Language Processing Lab, Northestern University.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Created by: XIAO Tong (email: xiaotong@mail.neu.edu.cn) 2018-04-24
*/
#ifndef __SCALEANDSHIFT_H__
#define __SCALEANDSHIFT_H__
#include "../../XTensor.h"
namespace nts{ // namespace nts(NiuTrans.Tensor)
#define _Linear _ScaleAndShift
#define _LinearMe _ScaleAndShiftMe
#define Linear ScaleAndShift
/*
scale and shift all tensor entires
b = a * scale + shift
*/
void _ScaleAndShift(const XTensor * a, XTensor * b, DTYPE scale, DTYPE shift = 0);
/*
scale and shift all tensor entires
keep the result in the input tensor a and return nothing
a = a * scale + shift
*/
void _ScaleAndShiftMe(XTensor * a, DTYPE scale, DTYPE shift = 0);
/*
scale and shift all tensor entires
make a new tensor to keep the result and return it
b = a * scale + shift
*/
XTensor ScaleAndShift(const XTensor &a, DTYPE scale, DTYPE shift = 0);
XTensor ScaleAndShiftINT(const XTensor &a, int scale, int shift = 0);
} // namespace nts(NiuTrans.Tensor)
#endif // __SCALEANDSHIFT_H__
|
[
"noreply@github.com"
] |
FeiiYin.noreply@github.com
|
ad8221f2a870952e9ecff124b538925d1b46bcc4
|
99f2de41fa71b584d5fd190d8392153e7f2ad573
|
/gfx/angle/src/tests/compiler_tests/QualificationOrderESSL31_test.cpp
|
dd3aa9a6574530941b167541a705f5912f818407
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
amoghbl1/tor-browser
|
e7533c926b02cbb5e070ec19bfc0476a12af84a2
|
ab02a23e9f880e560b418bbc629f9f6e140121e8
|
refs/heads/orfox-tor-browser-52.3.0esr-7.0-1
| 2022-11-10T04:26:17.607800
| 2017-08-01T21:16:48
| 2017-08-11T14:08:33
| 35,913,941
| 49
| 23
|
NOASSERTION
| 2022-11-04T19:04:23
| 2015-05-19T23:21:14
| null |
UTF-8
|
C++
| false
| false
| 6,132
|
cpp
|
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// QualificationOrderESSL31_test.cpp:
// OpenGL ES 3.1 removes the strict order of qualifiers imposed by the grammar.
// This file contains tests for invalid order and usage of qualifiers in GLSL ES 3.10.
#include "gtest/gtest.h"
#include "angle_gl.h"
#include "compiler/translator/TranslatorESSL.h"
#include "GLSLANG/ShaderLang.h"
#include "tests/test_utils/compiler_test.h"
using namespace sh;
class QualificationVertexShaderTestESSL31 : public testing::Test
{
public:
QualificationVertexShaderTestESSL31() {}
protected:
virtual void SetUp()
{
ShBuiltInResources resources;
InitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_VERTEX_SHADER, SH_GLES3_1_SPEC);
ASSERT_TRUE(mTranslator->Init(resources));
}
virtual void TearDown() { delete mTranslator; }
// Return true when compilation succeeds
bool compile(const std::string &shaderString)
{
const char *shaderStrings[] = {shaderString.c_str()};
mASTRoot = mTranslator->compileTreeForTesting(shaderStrings, 1,
SH_INTERMEDIATE_TREE | SH_VARIABLES);
TInfoSink &infoSink = mTranslator->getInfoSink();
mInfoLog = infoSink.info.c_str();
return mASTRoot != nullptr;
}
const TIntermSymbol *findSymbolInAST(const TString &symbolName, TBasicType basicType)
{
return FindSymbolNode(mASTRoot, symbolName, basicType);
}
protected:
TranslatorESSL *mTranslator;
TIntermNode *mASTRoot;
std::string mInfoLog;
};
// GLSL ES 3.10 has relaxed checks on qualifier order. Any order is correct.
TEST_F(QualificationVertexShaderTestESSL31, CentroidOut)
{
const std::string &shaderString =
"#version 310 es\n"
"precision lowp float;\n"
"out centroid float something;\n"
"void main(){\n"
" something = 1.0;\n"
"}\n";
if (!compile(shaderString))
{
FAIL() << "Shader compilation failed, expecting success" << mInfoLog;
}
else
{
const TIntermSymbol *node = findSymbolInAST("something", EbtFloat);
ASSERT_NE(nullptr, node);
const TType &type = node->getType();
EXPECT_EQ(EvqCentroidOut, type.getQualifier());
}
}
// GLSL ES 3.10 has relaxed checks on qualifier order. Any order is correct.
TEST_F(QualificationVertexShaderTestESSL31, AllQualifiersMixed)
{
const std::string &shaderString =
"#version 310 es\n"
"precision lowp float;\n"
"highp out invariant centroid flat vec4 something;\n"
"void main(){\n"
"}\n";
if (!compile(shaderString))
{
FAIL() << "Shader compilation failed, expecting success" << mInfoLog;
}
else
{
const TIntermSymbol *node = findSymbolInAST("something", EbtFloat);
ASSERT_NE(nullptr, node);
const TType &type = node->getType();
EXPECT_TRUE(type.isInvariant());
EXPECT_EQ(EvqFlatOut, type.getQualifier());
EXPECT_EQ(EbpHigh, type.getPrecision());
}
}
// GLSL ES 3.10 allows multiple layout qualifiers to be specified.
TEST_F(QualificationVertexShaderTestESSL31, MultipleLayouts)
{
const std::string &shaderString =
"#version 310 es\n"
"precision lowp float;\n"
"in layout(location=1) layout(location=2) vec4 something;\n"
"void main(){\n"
"}\n";
if (!compile(shaderString))
{
FAIL() << "Shader compilation failed, expecting success" << mInfoLog;
}
else
{
const TIntermSymbol *node = findSymbolInAST("something", EbtFloat);
ASSERT_NE(nullptr, node);
const TType &type = node->getType();
EXPECT_EQ(EvqVertexIn, type.getQualifier());
EXPECT_EQ(2, type.getLayoutQualifier().location);
}
}
// The test checks layout qualifier overriding when multiple layouts are specified.
TEST_F(QualificationVertexShaderTestESSL31, MultipleLayoutsInterfaceBlock)
{
const std::string &shaderString =
"#version 310 es\n"
"precision lowp float;\n"
"out float someValue;\n"
"layout(shared) layout(std140) layout(column_major) uniform MyInterface\n"
"{ vec4 something; } MyInterfaceName;\n"
"void main(){\n"
" someValue = MyInterfaceName.something.r;\n"
"}\n";
if (!compile(shaderString))
{
FAIL() << "Shader compilation failed, expecting success" << mInfoLog;
}
else
{
const TIntermSymbol *node = findSymbolInAST("MyInterfaceName", EbtInterfaceBlock);
ASSERT_NE(nullptr, node);
const TType &type = node->getType();
TLayoutQualifier layoutQualifier = type.getLayoutQualifier();
EXPECT_EQ(EbsStd140, layoutQualifier.blockStorage);
EXPECT_EQ(EmpColumnMajor, layoutQualifier.matrixPacking);
}
}
// The test checks layout qualifier overriding when multiple layouts are specified.
TEST_F(QualificationVertexShaderTestESSL31, MultipleLayoutsInterfaceBlock2)
{
const std::string &shaderString =
"#version 310 es\n"
"precision lowp float;\n"
"out float someValue;\n"
"layout(row_major) layout(std140) layout(shared) uniform MyInterface\n"
"{ vec4 something; } MyInterfaceName;\n"
"void main(){\n"
" someValue = MyInterfaceName.something.r;\n"
"}\n";
if (!compile(shaderString))
{
FAIL() << "Shader compilation failed, expecting success" << mInfoLog;
}
else
{
const TIntermSymbol *node = findSymbolInAST("MyInterfaceName", EbtInterfaceBlock);
ASSERT_NE(nullptr, node);
const TType &type = node->getType();
TLayoutQualifier layoutQualifier = type.getLayoutQualifier();
EXPECT_EQ(EbsShared, layoutQualifier.blockStorage);
EXPECT_EQ(EmpRowMajor, layoutQualifier.matrixPacking);
}
}
|
[
"ethlin@mozilla.com"
] |
ethlin@mozilla.com
|
4e7dc8e9c9eec62f3c30c6f7e09bad3dbc708abb
|
5e38b75fd11552c1a515c334bd36785e3f6962d1
|
/src-cpp/crypt.h
|
817810a76df9d304e3d445c803b0b62c712f659c
|
[] |
no_license
|
viq854/balaur
|
658cf231ac2bd9916a7b8c7efd80947f0caa17f9
|
929c4275ab36da2a5f2ffb8fd9e1b26f25009019
|
refs/heads/master
| 2020-12-14T09:48:23.270262
| 2017-09-28T00:03:07
| 2017-09-28T00:03:07
| 15,265,771
| 9
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 973
|
h
|
#include "index.h"
seq_t get_global_cipher_pos(const int bin_id, const kmer_cipher_t cipher, const seq_t offset,
const std::vector<kmer_cipher_t>& precomp_ref_hashes, const uint64 key1, const uint64 key2, bool vanilla);
void generate_sha1_ciphers(kmer_cipher_t* ciphers, const char* seq, const seq_t seq_len, const std::vector<bool>& repeat_mask, bool rev_mask);
void generate_vanilla_ciphers(kmer_cipher_t* ciphers, const char* seq, const seq_t seq_len);
void apply_keys(kmer_cipher_t* ciphers, const int n_ciphers, const uint64 key1, const uint64 key2);
void mask_repeats(kmer_cipher_t* ciphers, const int n_ciphers);
void lookup_sha1_ciphers(kmer_cipher_t* ciphers, const bool any_repeats, const seq_t offset, const seq_t len, const std::vector<kmer_cipher_t>& precomp_ref_hashes, const std::vector<uint16_t>& repeat_info);
void lookup_vanilla_ciphers(kmer_cipher_t* ciphers, const seq_t offset, const seq_t len, const std::vector<kmer_cipher_t>& precomp_ref_hashes);
|
[
"viq@stanford.edu"
] |
viq@stanford.edu
|
92b5f8e3ead73ededc5fc3f6a9534729a5789781
|
ef91f0c61520391ad25692c6adebff4aebe8dd09
|
/XML/Sources/VLocalizationXMLHandler.h
|
c7e4877e6dee94089b80485e08d22a634ffc4e2d
|
[] |
no_license
|
StephaneH/core-XToolbox
|
77462b758dfae86f86aafb8a9c9e5b34215259c7
|
c166b76bbd1dfba27c7863f203b158212028222e
|
refs/heads/master
| 2021-01-19T06:52:37.703070
| 2014-11-17T13:35:24
| 2014-11-17T13:35:24
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,493
|
h
|
/*
* This file is part of Wakanda software, licensed by 4D under
* (i) the GNU General Public License version 3 (GNU GPL v3), or
* (ii) the Affero General Public License version 3 (AGPL v3) or
* (iii) a commercial license.
* This file remains the exclusive property of 4D and/or its licensors
* and is protected by national and international legislations.
* In any event, Licensee's compliance with the terms and conditions
* of the applicable license constitutes a prerequisite to any use of this file.
* Except as otherwise expressly stated in the applicable license,
* such license does not include any other license or rights on this file,
* 4D's and/or its licensors' trademarks and/or other proprietary rights.
* Consequently, no title, copyright or other proprietary rights
* other than those specified in the applicable license is granted.
*/
#ifndef __VLOCALIZATIONXMLHANDLER__
#define __VLOCALIZATIONXMLHANDLER__
#include <stack>
#include "XML/Sources/XMLSaxHandler.h"
#include "XML/Sources/VLocalizationManager.h"
#include "IXMLHandler.h"
BEGIN_TOOLBOX_NAMESPACE
class XTOOLBOX_API VLocalizationXMLHandler : public VObject, public IXMLHandler
{
public:
VLocalizationXMLHandler(VLocalizationManager* localizationManager);
virtual IXMLHandler* StartElement( const VString& inElementName);
virtual void SetAttribute( const VString& inName, const VString& inValue);
virtual void SetText( const VString& inText);
void SetAvoidLanguageChecking(bool inAvoidLanguageChecking);
private:
VLocalizationManager* fLocalizationManager;
bool fXLIFFFileLanguageIsValid;
bool fShouldOverwriteAnyExistentLocalizationValue;
VString fElementName;
bool fAvoidLanguageChecking;
};
class VLocalizationGroupHandler : public VObject, public IXMLHandler
{
public:
VLocalizationGroupHandler(bool inShouldOverwriteAnyExistentLocalizationValue, VLocalizationManager* inLocalizationManager);
virtual ~VLocalizationGroupHandler();
virtual IXMLHandler* StartElement( const VString& inElementName);
virtual void EndElement( const VString& inElementName);
virtual void SetAttribute( const VString& inName, const VString& inValue);
virtual void SetText( const VString& inText);
private:
VLocalizationManager* fLocalizationManager;
bool fShouldOverwriteAnyExistentLocalizationValue;
sLONG fGroupID;
std::stack<VString> fGroupResnamesStack;
VValueBag* fGroupBag; // non null if a menu group is being parsed
VString fGroupRestype;
};
class VLocalizationTransUnitHandler : public VObject, public IXMLHandler
{
public:
// parsing trans-unit at top level
VLocalizationTransUnitHandler( bool inShouldOverwriteAnyExistentLocalizationValue, VLocalizationManager* localizationManager);
// parsing trans-units in a group
VLocalizationTransUnitHandler( uLONG groupID, const std::stack<XBOX::VString>& inGroupResnamesStack, VValueBag *ioTransUnitBag, bool inShouldOverwriteAnyExistentLocalizationValue, VLocalizationManager* localizationManager);
virtual ~VLocalizationTransUnitHandler();
virtual IXMLHandler* StartElement( const VString& inElementName);
virtual void EndElement( const VString& inElementName);
virtual void SetAttribute( const VString& inName, const VString& inValue);
virtual void SetText( const VString& inText);
private:
void CheckPlatformTag( const VString& inTags, bool inIncludeIfTag, bool *ioExcluded);
VLocalizationManager* fLocalizationManager;
VString fElementName;
sLONG fGroupID;
VValueBag* fGroupBag; // non null if a menu group is being parsed
VValueBag* fTransUnitBag; // non null if a menu group is being parsed
uLONG fStringID;
VString fResName;
VString fSource; // content of <source> element
VString fTarget; // content of <target> element
bool fIsEntryRecorded;
bool fShouldOverwriteAnyExistentLocalizationValue;
bool fExcluded;
std::stack<VString> fGroupResnamesStack;
};
class VLocalizationAltTransHandler : public VObject, public IXMLHandler
{
public:
// parsing trans-unit at top level
VLocalizationAltTransHandler( bool inShouldOverwriteAnyExistentLocalizationValue, VLocalizationManager* localizationManager);
// parsing trans-units in a group
VLocalizationAltTransHandler( uLONG groupID, const std::stack<XBOX::VString>& inGroupResnamesStack, VValueBag *ioTransUnitBag, bool inShouldOverwriteAnyExistentLocalizationValue, VLocalizationManager* localizationManager);
virtual ~VLocalizationAltTransHandler();
virtual IXMLHandler* StartElement( const VString& inElementName);
virtual void EndElement( const VString& inElementName);
virtual void SetAttribute( const VString& inName, const VString& inValue);
virtual void SetText( const VString& inText);
private:
void CheckPlatformTag( const VString& inTags, bool inIncludeIfTag, bool *ioExcluded);
//VLocalizationManager* fLocalizationManager;
VString fElementName;
//sLONG fGroupID;
VValueBag* fTransUnitBag; // non null if a menu group is being parsed
VValueBag* fAltTransBag; // non null if a menu group is being parsed
uLONG fStringID;
VString fResName;
VString fSource; // content of <source> element
VString fTarget; // content of <target> element
//bool fIsEntryRecorded;
//bool fShouldOverwriteAnyExistentLocalizationValue;
bool fExcluded;
std::stack<VString> fGroupResnamesStack;
};
END_TOOLBOX_NAMESPACE
#endif
|
[
"stephane.hamel@4d.com"
] |
stephane.hamel@4d.com
|
9d77d12a91e68ce3f132dd192149995c537bb3d6
|
72fb2ca1dd9116d0796e45ee3743fd245fe2b6c4
|
/cell_test.cpp
|
b8a0bf1f7852b3714d0a63eedb0efba146b166f8
|
[] |
no_license
|
77k/Cell
|
9342386cb07ceabb94fda9859c58d46c44c3b3a6
|
7500a00ad23b3dbdf08f0d828461f3c2bea2ea64
|
refs/heads/master
| 2021-06-30T07:28:22.444925
| 2017-09-19T17:06:12
| 2017-09-19T17:06:12
| 104,082,407
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,368
|
cpp
|
/**
* snaske@77k.eu
*/
#include <boost/asio.hpp>
#include <boost/regex.hpp>
#include <string>
#include <stack>
#include <boost/array.hpp>
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/logic/tribool.hpp>
#include <signal.h>
#include <fstream>
#include <sstream>
#include <string>
#include <chrono>
#include <boost/lexical_cast.hpp>
#include "spaces.h"
#include "cubical_complex.h"
//#include "electrodynamics.h"
typedef CubicalSpaceCompressed< 4, SimpleEuklidianMetricFuint32 > Space4;
typedef Space4::Cube Cube4;
typedef Space4::PointT Point4;
int main(int argc, char* argv[])
{
try
{
if (argc != 2)
{
std::cerr << "Usage: cell_test <netlist>" << std::endl;
throw(std::runtime_error("Not enough arguments!"));
}
static const auto buffer_size = 128 * 1024;
std::ifstream is(argv[1], std::ios::in | std::ios:: binary);
if(!is) throw(std::runtime_error("Error opening file! "));
BLIFParser p(argv[1]);
p << is;
}
catch (std::exception& e)
{
std::cerr << "exception: " << e.what() << std::endl;
return 1;
}
catch (...)
{
std::cerr << "He's Dead Jim" << std::endl;
}
return 0;
}
|
[
"sn00n@77k.eu"
] |
sn00n@77k.eu
|
4689f0edda21e2dc7913e74335fbad168da186c5
|
8f6c1679a7e39d75d929ada14ef2c1197f9fb8bb
|
/easy/linked_list_cycle_141.cpp
|
84029929e2d0c4c2b338429a22f6207870bd6caa
|
[] |
no_license
|
lhdgriver/leetcode
|
6446c237eff4d78bdaeabdf6f1c12b965e48eaad
|
ba11bdfbd7de9bcd0f42ffe4990ade7232804fe0
|
refs/heads/master
| 2020-12-25T14:57:35.161667
| 2016-08-28T14:30:28
| 2016-08-28T14:30:28
| 66,192,957
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 408
|
cpp
|
class Solution {
public:
bool hasCycle(ListNode *head) {
if (head == NULL) return false;
if (head->next == NULL) return false;
ListNode* step_1 = head;
ListNode* step_2 = head->next;
while(true) {
if (step_1 == step_2) return true;
if (step_2->next == NULL) break;
if (step_2->next->next ==NULL) break;
step_2 = step_2->next->next;
step_1 = step_1->next;
}
return false;
}
};
|
[
"lhdgriver@gmail.com"
] |
lhdgriver@gmail.com
|
c32d3b47a9f0742b394d4bd147250ed6ecdb2785
|
232ebae2b4032a8be513fa40641acb1cb87f8ef2
|
/libraries/TimerOne/TimerOne.cpp
|
f1d082235969bc30895c5b545ee001c7d2b9d08d
|
[] |
no_license
|
amr-spring-2015/amr-project
|
ac6747b0f860b5101e3a8525f6ccefaf4b43e830
|
745d7d2127e916a982b5ec1f50aae23019899c18
|
refs/heads/master
| 2020-06-04T22:47:18.918131
| 2015-05-02T23:02:29
| 2015-05-02T23:02:29
| 32,772,804
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,842
|
cpp
|
/*
* Interrupt and PWM utilities for 16 bit Timer1 on ATmega168/328
* Original code by Jesse Tane for http://labs.ideo.com August 2008
* Modified March 2009 by Jérôme Despatis and Jesse Tane for ATmega328 support
* Modified June 2009 by Michael Polli and Jesse Tane to fix a bug in setPeriod() which caused the timer to stop
* Modified June 2011 by Lex Talionis to add a function to read the timer
* Modified Oct 2011 by Andrew Richards to avoid certain problems:
* - Add (long) assignments and casts to TimerOne::read() to ensure calculations involving tmp, ICR1 and TCNT1 aren't truncated
* - Ensure 16 bit registers accesses are atomic - run with interrupts disabled when accessing
* - Remove global enable of interrupts (sei())- could be running within an interrupt routine)
* - Disable interrupts whilst TCTN1 == 0. Datasheet vague on this, but experiment shows that overflow interrupt
* flag gets set whilst TCNT1 == 0, resulting in a phantom interrupt. Could just set to 1, but gets inaccurate
* at very short durations
* - startBottom() added to start counter at 0 and handle all interrupt enabling.
* - start() amended to enable interrupts
* - restart() amended to point at startBottom()
* Modiied 7:26 PM Sunday, October 09, 2011 by Lex Talionis
* - renamed start() to resume() to reflect it's actual role
* - renamed startBottom() to start(). This breaks some old code that expects start to continue counting where it left off
*
* 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/>.
*
* See Google Code project http://code.google.com/p/arduino-timerone/ for latest
*/
#ifndef TIMERONE_cpp
#define TIMERONE_cpp
#include "TimerOne.h"
TimerOne Timer1; // preinstatiate
ISR(TIMER1_OVF_vect) // interrupt service routine that wraps a user defined function supplied by attachInterrupt
{
Timer1.isrCallback();
}
void TimerOne::initialize(long microseconds)
{
TCCR1A = 0; // clear control register A
TCCR1B = _BV(WGM13); // set mode 8: phase and frequency correct pwm, stop the timer
setPeriod(microseconds);
}
void TimerOne::setPeriod(long cycles) // AR modified for atomic access
{
if(cycles < RESOLUTION) clockSelectBits = _BV(CS10); // no prescale, full xtal
else if((cycles >>= 3) < RESOLUTION) clockSelectBits = _BV(CS11); // prescale by /8
else if((cycles >>= 3) < RESOLUTION) clockSelectBits = _BV(CS11) | _BV(CS10); // prescale by /64
else if((cycles >>= 2) < RESOLUTION) clockSelectBits = _BV(CS12); // prescale by /256
else if((cycles >>= 2) < RESOLUTION) clockSelectBits = _BV(CS12) | _BV(CS10); // prescale by /1024
else cycles = RESOLUTION - 1, clockSelectBits = _BV(CS12) | _BV(CS10); // request was out of bounds, set as maximum
oldSREG = SREG;
cli(); // Disable interrupts for 16 bit register access
ICR1 = pwmPeriod = cycles; // ICR1 is TOP in p & f correct pwm mode
SREG = oldSREG;
TCCR1B &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12));
TCCR1B |= clockSelectBits; // reset clock select register, and starts the clock
}
void TimerOne::setPwmDuty(char pin, int duty)
{
unsigned long dutyCycle = pwmPeriod;
dutyCycle *= duty;
dutyCycle >>= 10;
oldSREG = SREG;
cli();
if(pin == 1 || pin == 9) OCR1A = dutyCycle;
else if(pin == 2 || pin == 10) OCR1B = dutyCycle;
SREG = oldSREG;
}
void TimerOne::pwm(char pin, int duty, long microseconds) // expects duty cycle to be 10 bit (1024)
{
if(microseconds > 0) setPeriod(microseconds);
if(pin == 1 || pin == 9) {
DDRB |= _BV(PORTB1); // sets data direction register for pwm output pin
TCCR1A |= _BV(COM1A1); // activates the output pin
}
else if(pin == 2 || pin == 10) {
DDRB |= _BV(PORTB2);
TCCR1A |= _BV(COM1B1);
}
setPwmDuty(pin, duty);
resume(); // Lex - make sure the clock is running. We don't want to restart the count, in case we are starting the second WGM
// and the first one is in the middle of a cycle
}
void TimerOne::disablePwm(char pin)
{
if(pin == 1 || pin == 9) TCCR1A &= ~_BV(COM1A1); // clear the bit that enables pwm on PB1
else if(pin == 2 || pin == 10) TCCR1A &= ~_BV(COM1B1); // clear the bit that enables pwm on PB2
}
void TimerOne::attachInterrupt(void (*isr)(), long microseconds)
{
if(microseconds > 0) setPeriod(microseconds);
isrCallback = isr; // register the user's callback with the real ISR
TIMSK1 = _BV(TOIE1); // sets the timer overflow interrupt enable bit
// might be running with interrupts disabled (eg inside an ISR), so don't touch the global state
// sei();
resume();
}
void TimerOne::detachInterrupt()
{
TIMSK1 &= ~_BV(TOIE1); // clears the timer overflow interrupt enable bit
// timer continues to count without calling the isr
}
void TimerOne::resume() // AR suggested
{
TCCR1B |= clockSelectBits;
}
void TimerOne::restart() // Depricated - Public interface to start at zero - Lex 10/9/2011
{
start();
}
void TimerOne::start() // AR addition, renamed by Lex to reflect it's actual role
{
unsigned int tcnt1;
TIMSK1 &= ~_BV(TOIE1); // AR added
GTCCR |= _BV(PSRSYNC); // AR added - reset prescaler (NB: shared with all 16 bit timers);
oldSREG = SREG; // AR - save status register
cli(); // AR - Disable interrupts
TCNT1 = 0;
SREG = oldSREG; // AR - Restore status register
resume();
do { // Nothing -- wait until timer moved on from zero - otherwise get a phantom interrupt
oldSREG = SREG;
cli();
tcnt1 = TCNT1;
SREG = oldSREG;
} while (tcnt1==0);
// TIFR1 = 0xff; // AR - Clear interrupt flags
// TIMSK1 = _BV(TOIE1); // sets the timer overflow interrupt enable bit
}
void TimerOne::stop()
{
TCCR1B &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12)); // clears all clock selects bits
}
unsigned long TimerOne::read() //returns the value of the timer in microseconds
{ //rember! phase and freq correct mode counts up to then down again
unsigned long tmp; // AR amended to hold more than 65536 (could be nearly double this)
unsigned int tcnt1; // AR added
oldSREG= SREG;
cli();
tmp=TCNT1;
SREG = oldSREG;
char scale=0;
switch (clockSelectBits)
{
case 1:// no prescalse
scale=0;
break;
case 2:// x8 prescale
scale=3;
break;
case 3:// x64
scale=6;
break;
case 4:// x256
scale=8;
break;
case 5:// x1024
scale=10;
break;
}
do { // Nothing -- max delay here is ~1023 cycles. AR modified
oldSREG = SREG;
cli();
tcnt1 = TCNT1;
SREG = oldSREG;
} while (tcnt1==tmp); //if the timer has not ticked yet
//if we are counting down add the top value to how far we have counted down
tmp = ( (tcnt1>tmp) ? (tmp) : (long)(ICR1-tcnt1)+(long)ICR1 ); // AR amended to add casts and reuse previous TCNT1
return ((tmp*1000L)/(F_CPU /1000L))<<scale;
}
#endif
|
[
"jakedostal@gmail.com"
] |
jakedostal@gmail.com
|
80c1643547f8afc666e8c5405a838f70c90a81be
|
d702c8436228106b384d17eb01c9d8bbb18fddbc
|
/leetcode/232-implement-queue-using-stacks/solution.h
|
0962e10fd8e67f2a13c270e516494fae6c907781
|
[] |
no_license
|
caelumcao/ds_algo
|
fedd7d7cd4877dc687e85dbbdad6dd1a666e9e5b
|
a860da9ac72bec9bbd1af0e669f099a48c253eb6
|
refs/heads/main
| 2023-05-06T23:36:08.810473
| 2021-05-26T09:49:48
| 2021-05-26T09:49:48
| 314,447,227
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,278
|
h
|
/*
* @lc app=leetcode.cn id=232 lang=cpp
*
* [232] 用栈实现队列
*/
#include <stack>
using namespace std;
// @lc code=start
class MyQueue
{
public:
stack<int> pushStk;
stack<int> popStk;
/** Initialize your data structure here. */
MyQueue()
{
}
/** Push element x to the back of queue. */
void push(int x)
{
pushStk.push(x);
}
void migrate()
{
if (popStk.empty())
{
while (!pushStk.empty())
{
popStk.push(pushStk.top());
pushStk.pop();
}
}
}
/** Removes the element from in front of queue and returns that element. */
int pop()
{
migrate();
int val = popStk.top();
popStk.pop();
return val;
}
/** Get the front element. */
int peek()
{
migrate();
return popStk.top();
}
/** Returns whether the queue is empty. */
bool empty()
{
return pushStk.empty() && popStk.empty();
}
};
/**
* Your MyQueue object will be instantiated and called as such:
* MyQueue* obj = new MyQueue();
* obj->push(x);
* int param_2 = obj->pop();
* int param_3 = obj->peek();
* bool param_4 = obj->empty();
*/
// @lc code=end
|
[
"caelumcao@tencent.com"
] |
caelumcao@tencent.com
|
3a6f1fbe4ecf454d010a5f086921493df839c499
|
a0ff445e18410e03ed017e40ad86822ee5d2b337
|
/Pawn.cpp
|
b680e183aee1031d91076f9057c107dd274791eb
|
[] |
no_license
|
juancarlosfarah/chess
|
5e3b55421d85ea0ef2d57a5ffa2870ad969ea746
|
d22ff27dbca526b466704360ec34ba7e7f9c002a
|
refs/heads/master
| 2021-01-03T03:15:05.001039
| 2020-02-12T01:04:30
| 2020-02-12T01:04:30
| 239,898,367
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,342
|
cpp
|
// ==========================================
// File: Pawn.cpp
// Author: Juan Carlos Farah
// Email: juancarlos.farah14@imperial.ac.uk
// ==========================================
#include <iostream>
using namespace std;
#include "Pawn.hpp"
#include "Settings.hpp"
// Constructor: Default
// ====================
Pawn::Pawn() : ChessPiece() {}
// Constructor:
// ============
// This constructor takes a Color and creates a Pawn of that Color.
Pawn::Pawn(Color color) : ChessPiece(color) {
this->name = PAWN_NAME;
this->initSymbol(color);
}
// Constructor:
// ============
// This constructor takes a Color and a ChessSquare and
// constructs a Pawn of that Color, setting its square
// property to point to the given ChessSquare.
Pawn::Pawn(Color c, const ChessSquare& cs) : ChessPiece(c, cs) {
this->name = PAWN_NAME;
this->initSymbol(c);
}
// Destructor:
// ===========
Pawn::~Pawn() {}
// Public Method: isPossibleMove
// =============================
// This method takes a ChessSquare and a pointer to the ChessPiece
// in that ChessSquare (or nullptr if its empty), and returns a
// pair of booleans. The first bool indicates if the move is
// possible given the rules of movement of the Pawn. The second
// bool is true if the move requires the Pawn to go through one
// or more squares. This indicates if the move needs to be checked
// further by the ChessBoard for any potential obstructions.
// This method is inherited from the ChessPiece superclass.
pair<bool, bool> Pawn::isPossibleMove(ChessSquare& square,
ChessPiece* piece) const {
// Initialise return value.
pair<bool, bool> rvalue(false, false);
// Ensure validity at the ChessPiece level.
if (!ChessPiece::isPossibleMove(square, piece).first) return rvalue;
// Ensure validity at the Pawn level.
switch (this->color) {
case White:
// These moves require that the destination square is empty.
if (piece == nullptr) {
// Destination is directly above this square. Return
// (true, false) pair indicating that the move is valid
// and it doesn't require validation for potential block.
if (this->square->isDirectlyAbove(square)) {
rvalue.first = true;
return rvalue;
}
// On white pawn's first move, two squares above is valid.
// Return (true, true) pair indicating that the move is
// valid, but it requires validation for potential block.
if ((this->square->getRank() == WHITE_PAWNS) &&
(square.getRank() == WHITE_PAWNS + 2) &&
(this->square->getFile() == square.getFile())) {
rvalue.first = true;
rvalue.second = true;
return rvalue;
}
} else {
// One step in superior diagonal is valid when attacking.
// Return (true, false) pair indicating that the move is
// valid and it doesn't require validation for blocks.
if (this->square->isDirectlyAboveDiagonally(square)) {
rvalue.first = true;
return rvalue;
}
}
break;
case Black:
// These moves require that the destination square is empty.
if (piece == nullptr) {
// Destination is directly below this square. Return
// (true, false) pair indicating that the move is valid
// and it doesn't require validation for potential block.
if (this->square->isDirectlyBelow(square)) {
rvalue.first = true;
return rvalue;
}
// On black pawn's first move, two squares below is valid.
// Return (true, true) pair indicating that the move is
// valid, but it requires validation for potential block.
if ((this->square->getRank() == BLACK_PAWNS) &&
(square.getRank() == BLACK_PAWNS - 2) &&
(this->square->getFile() == square.getFile())) {
rvalue.first = true;
rvalue.second = true;
return rvalue;
}
} else {
// One step in inferior diagonal is valid when attacking.
// Return (true, false) pair indicating that the move is
// valid and it doesn't require validation for blocks.
if (this->square->isDirectlyBelowDiagonally(square)) {
rvalue.first = true;
return rvalue;
}
}
break;
}
return rvalue;
}
// Private Method: initSymbol
// ==========================
// This method initialises the symbol
// property of the Pawn given its Color.
void Pawn::initSymbol(Color color) {
this->symbol = (color == White) ? WHITE_PAWN : BLACK_PAWN;
}
// Friend Operator: <<
// ===================
// Outputs the symbol property of the Pawn operand.
ostream& operator<<(ostream& os, const Pawn& pawn) {
os << pawn.getSymbol();
return os;
}
|
[
"farah.juancarlos@gmail.com"
] |
farah.juancarlos@gmail.com
|
895fa42c179f02a8679427767c5ff56294f81279
|
1369880eabe83b33094cd09fa6d4e7e96e412221
|
/AABB.CPP
|
c74bfbf16d00128d7c9195b929473b88e326aad3
|
[] |
no_license
|
Taaqif/LaseWorld
|
2cdd6d081509684841bbb768a11da1118627ec7d
|
f09a50ef21d0b477329a70c7a401f6a277268ad0
|
refs/heads/master
| 2020-07-31T10:33:26.311211
| 2016-11-13T07:12:42
| 2016-11-13T07:12:42
| 73,600,878
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 818
|
cpp
|
// AABB.cpp
//
// Implementation file for AABB Class
// Defines all the methods declared, but not defined, in AABB.h
//
// Shay Leary, March 2005
//--------------------------------------------------------------------------------------
#include <iostream>
#include "AABB.h"
//--------------------------------------------------------------------------------------
void AABB::SetNoBoundingBoxes(const int & tempSize)
{
m_BBox = new BoundingBox[tempSize];
m_NoOfBoxes = tempSize;
}
//--------------------------------------------------------------------------------------
void AABB::ClearBB(BoundingBox* &tempArray)
{
tempArray = NULL;
if (tempArray == NULL)
{
delete [] tempArray;
}
}
//--------------------------------------------------------------------------------------
|
[
"noreply@github.com"
] |
Taaqif.noreply@github.com
|
4d270e3bba9c66f198e60bbec3a14077b15a76b0
|
137946bff2f27e0dbc272daae448791eda536839
|
/DirectX/GameObject/GameObjectFactory.h
|
4b21ef49ed21e791efbe7d4292f3be2186728f11
|
[] |
no_license
|
soelusoelu/20_10_kojin
|
71d494330fa9b260d08fbd0c6b21f44158c2d505
|
051ee216288134e43f5f17f6505d9fccd8a53ef7
|
refs/heads/master
| 2023-01-30T20:25:10.147749
| 2020-12-07T01:29:18
| 2020-12-07T01:29:18
| 306,239,246
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,309
|
h
|
#pragma once
#include "../Math/Math.h"
#include <rapidjson/document.h>
#include <functional>
#include <memory>
#include <string>
#include <unordered_map>
class GameObject;
class GameObjectFactory {
using ComponentFunc = std::function<void(GameObject&, const std::string&, const rapidjson::Value&)>;
public:
GameObjectFactory();
~GameObjectFactory();
//ファイルからゲームオブジェクト生成
std::shared_ptr<GameObject> createGameObjectFromFile(const std::string& type, const std::string& directoryPath = "Assets\\Data\\");
private:
GameObjectFactory(const GameObjectFactory&) = delete;
GameObjectFactory& operator=(const GameObjectFactory&) = delete;
//ゲームオブジェクトを生成する
std::shared_ptr<GameObject> createGameObject(const rapidjson::Document& inDocument, const std::string& type, const std::string& directoryPath);
//ゲームオブジェクトのタグを取得する
std::string loadTag(const rapidjson::Document& inDocument);
//ゲームオブジェクトプロパティの読み込み
void loadGameObjectProperties(GameObject& gameObject, const rapidjson::Document& inDocument);
//継承コンポーネントの読み込み
void loadPrototypeComponents(GameObject& gameObject, const rapidjson::Document& inDocument, const std::string& directoryPath) const;
//コンポーネントの読み込み
void loadComponents(GameObject& gameObject, const rapidjson::Document& inDocument) const;
//各コンポーネントの読み込み
void loadComponent(GameObject& gameObject, const rapidjson::Value& component) const;
//有効な型か
bool isValidType(std::string& outType, const rapidjson::Value& inObj) const;
private:
std::unordered_map<std::string, ComponentFunc> mComponents;
static inline bool mInstantiated = false;
};
class GameObjectCreater {
public:
static void initialize();
static void finalize();
static std::shared_ptr<GameObject> create(const std::string& type);
private:
GameObjectCreater() = delete;
~GameObjectCreater() = delete;
GameObjectCreater(const GameObjectCreater&) = delete;
GameObjectCreater& operator=(const GameObjectCreater&) = delete;
private:
static inline GameObjectFactory* mFactory = nullptr;
};
|
[
"llmn.0419@gmail.com"
] |
llmn.0419@gmail.com
|
28c6c26f7e424f792ed481b8f09c7f3a30484cdf
|
458bea59fb53d1a0d23eb193b309b5d106e84755
|
/src/CharacterTaskRegistry.cpp
|
5bf2ddc9f32201bd92a5bdd9371e4ca98fbc06ef
|
[
"Apache-2.0"
] |
permissive
|
Naftoreiclag/VS7C
|
89b40170a0c8e0c5a1dae02575cedecaf1f5eb38
|
5b736a0550969752514433fb0fd9d9680fa46bdd
|
refs/heads/master
| 2020-12-30T10:50:01.794671
| 2015-12-23T02:55:29
| 2015-12-23T02:55:29
| 35,711,693
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 777
|
cpp
|
/* Copyright (c) 2015 "Naftoreiclag" https://github.com/Naftoreiclag
*
* Distributed under the Apache License Version 2.0 (http://www.apache.org/licenses/)
* See accompanying file LICENSE
*/
#include "CharacterTaskRegistry.h"
#include "easylogging++.h"
namespace CharacterTaskRegistry {
std::vector<CharacterTask*> knownTasks;
void addTask(CharacterTask* task) {
knownTasks.push_back(task);
}
std::vector<CharacterTask*> getTasks(const CharacterTaskCondition* fulfillThis) {
std::vector<CharacterTask*> retVal;
for(std::vector<CharacterTask*>::iterator it = knownTasks.begin(); it != knownTasks.end(); ++ it) {
CharacterTask* task = *it;
if(task->fulfills(fulfillThis)) {
retVal.push_back(task);
}
}
return retVal;
}
};
|
[
"naftoreiclag@gmail.com"
] |
naftoreiclag@gmail.com
|
4616e8310a7ebd9549860ed36af7a023c8bc6513
|
8b191d8eb25af95c679f14b09a32f72764ae2bba
|
/백준/17480- 개구쟁이 준석이.cpp
|
38b0e4ffcfae88f6b6c087fcec855bbd6e94c1a9
|
[] |
no_license
|
cocobisc/PS
|
08cd56b57ba95f4384ecbcaec3682263eeb6730f
|
11ca5540632715a3c56eaee389a1946bf935ea0e
|
refs/heads/master
| 2020-12-15T20:43:49.231103
| 2020-11-08T10:09:20
| 2020-11-08T10:09:20
| 235,249,407
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,121
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
map<char, int> ma, matemp;
set<string> ans;
int len;
string get_rev(string s) {
reverse(s.begin(), s.end());
return s;
}
void go(string &s, int le, int ri) {
if (ri - le == 1) {
ans.insert(s);
return;
}
int l = ri - le >> 1;
int mid = le + ri >> 1;
string a = s.substr(le, l);
string b = s.substr(mid, l);
if ((le + ri) % 2) {
b = s.substr(mid, l + 1);
s.replace(le, l, get_rev(a));
go(s, mid, ri);
s.replace(le, l, a);
s.replace(mid, l + 1, get_rev(b));
go(s, le, mid);
s.replace(mid, l + 1, b);
mid++;
a = s.substr(le, l + 1);
b = s.substr(mid, l);
s.replace(le, l + 1, get_rev(a));
go(s, mid, ri);
s.replace(le, l + 1, a);
s.replace(mid, l, get_rev(b));
go(s, le, mid);
s.replace(mid, l, b);
} else {
s.replace(le, l, get_rev(a));
go(s, mid, ri);
s.replace(le, l, a);
s.replace(mid, l, get_rev(b));
go(s, le, mid);
s.replace(mid, l, b);
}
}
int main() {
int n;
string s, num;
vector<char> alpha_list;
getline(cin, s);
n = stoi(s);
getline(cin, s);
char t = 0;
for (char c : s) {
if (c == ' ') continue;
if (c >= 'a' && c <= 'z') {
if (num.size()) {
ma[t] = stoi(num);
len += stoi(num);
}
alpha_list.push_back(c);
t = c;
num = "";
} else
num += c;
}
ma[t] = stoi(num);
len += stoi(num);
cin >> s;
for (int i = 0; i <= s.size() - len; i++) {
matemp.clear();
string word;
for (int j = i; j < i + len; j++) {
matemp[s[j]]++;
word += s[j];
}
bool flag = 1;
for (char c : alpha_list) {
if (ma[c] != matemp[c]) {
flag = 0;
break;
}
}
if (flag)
go(word, 0, len);
}
cout << ans.size();
}
|
[
"xmfhs99@gmail.com"
] |
xmfhs99@gmail.com
|
1d11ad6f70510c37f32521502101d33c8f78cf20
|
b8d3c2478cb9e26a1ae9f2413e7dac2e78e8f0d3
|
/Unmanaged/HVisionSystem/include/Utility/MemDC.h
|
3123a44e284573f3859bce869e9ac9c72c11ba7e
|
[
"MS-PL",
"BSD-3-Clause",
"MIT",
"Apache-2.0"
] |
permissive
|
wiseants/Varins
|
4281ddf31f3cff6b8dc5e62530186d3795e844c7
|
8b9153bc46c669c572f2e56fe313a92cb546c5ae
|
refs/heads/master
| 2022-12-09T20:25:58.574485
| 2020-11-10T07:38:10
| 2020-11-10T07:38:10
| 242,623,978
| 0
| 0
|
NOASSERTION
| 2022-12-08T02:14:40
| 2020-02-24T01:50:05
|
C++
|
UTF-8
|
C++
| false
| false
| 3,464
|
h
|
#if !defined(AFX_MEMDC_H__CA1D3541_7235_11D1_ABBA_00A0243D1382__INCLUDED_)
#define AFX_MEMDC_H__CA1D3541_7235_11D1_ABBA_00A0243D1382__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// UMemDC.h : header file
//
//////////////////////////////////////////////////
// CUMemDC - memory DC
//
// Author: Keith Rule
// Email: keithr@europa.com
// Copyright 1996-1997, Keith Rule
//
// You may freely use or modify this code provided this
// Copyright is included in all derived versions.
//
// History - 10/3/97 Fixed scrolling bug.
// Added print support.
// 25 feb 98 - fixed minor assertion bug
//
// This class implements a memory Device Context
class CUMemDC : public CDC
{
public:
// constructor sets up the memory DC
CUMemDC(CDC* pDC) : CDC()
{
ASSERT(pDC != NULL);
m_pDC = pDC;
m_pOldBitmap = NULL;
#ifndef WCE_NO_PRINTING
m_bMemDC = !pDC->IsPrinting();
#else
m_bMemDC = FALSE;
#endif
if (m_bMemDC) // Create a Memory DC
{
pDC->GetClipBox(&m_rect);
CreateCompatibleDC(pDC);
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
m_pOldBitmap = SelectObject(&m_bitmap);
#ifndef _WIN32_WCE
SetWindowOrg(m_rect.left, m_rect.top);
#endif
// EFW - Bug fix - Fill background in case the user has overridden
// WM_ERASEBKGND. We end up with garbage otherwise.
// CJM - moved to fix a bug in the fix.
//FillSolidRect(m_rect, pDC->GetBkColor());
}
else // Make a copy of the relevent parts of the current DC for printing
{
#if !defined(_WIN32_WCE) || ((_WIN32_WCE > 201) && !defined(WCE_NO_PRINTING))
m_bPrinting = pDC->m_bPrinting;
#endif
m_hDC = pDC->m_hDC;
m_hAttribDC = pDC->m_hAttribDC;
}
}
// Destructor copies the contents of the mem DC to the original DC
~CUMemDC()
{
if (m_bMemDC)
{
// Copy the offscreen bitmap onto the screen.
m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
this, m_rect.left, m_rect.top, SRCCOPY);
//Swap back the original bitmap.
SelectObject(m_pOldBitmap);
} else {
// All we need to do is replace the DC with an illegal value,
// this keeps us from accidently deleting the handles associated with
// the CDC that was passed to the constructor.
m_hDC = m_hAttribDC = NULL;
}
DeleteDC();
if (m_bMemDC)
m_bitmap.DeleteObject();
}
// Allow usage as a pointer
CUMemDC* operator->() { return this; }
// Allow usage as a pointer
operator CUMemDC*() { return this; }
private:
CBitmap m_bitmap; // Offscreen bitmap
CBitmap* m_pOldBitmap; // bitmap originally found in CUMemDC
CDC* m_pDC; // Saves CDC passed in constructor
CRect m_rect; // Rectangle of drawing area.
BOOL m_bMemDC; // TRUE if CDC really is a Memory DC.
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MEMDC_H__CA1D3541_7235_11D1_ABBA_00A0243D1382__INCLUDED_)
|
[
"wiseants@nate.com"
] |
wiseants@nate.com
|
a1027150038879fb4a8e175637d14d1bd4e2aa11
|
bff324f8a27794bc5f4c42a4394852d1f39c7682
|
/Documents/data_scource-master/modbus/mainwindow.h
|
66c3f491bb38236da3a2b4bfdfc3b557f226eccc
|
[] |
no_license
|
zslswlw/data_scource
|
aea8231743d5c72187485c8a5dcb248b9f5c76d7
|
72f4bc48ffb5eb87614485592879a0d78eeff3ea
|
refs/heads/master
| 2023-01-27T11:03:45.359727
| 2020-12-01T16:40:54
| 2020-12-01T16:40:54
| 316,115,604
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 723
|
h
|
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPushButton>
#include "mythread.h"
#include <QTreeWidget>
#include <QSpinBox>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
struct timeval
{
uint32_t tv_sec;
uint32_t tv_usec;
};
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
QPushButton *pbRtu;
QPushButton *pbTcp;
QPushButton *pbRun;
QPushButton *pbStop;
private slots:
void doRtuQuery();
void doTcpQuery();
void slot_up_value(float reg_value);
void slot_close_done();
private:
Ui::MainWindow *ui;
MyThread mythread;
};
#endif // MAINWINDOW_H
|
[
"153805385@qq.com"
] |
153805385@qq.com
|
e9cbb7c5742a52c3ef014891942249d94c2ef8c0
|
c8a04cea9afde109e8f7ffce09bde1c616c1bb2e
|
/design-hashmap/design-hashmap.cpp
|
38dfb4d49cb140db3fb02c6517e4ef2edee3dd0b
|
[
"MIT"
] |
permissive
|
JanaSabuj/Leetcode-solutions
|
956fea8538b3d87b999d0c65ef158ad8500b61c7
|
68464fc54c18ec6d7d72e862c1c75e8309314198
|
refs/heads/master
| 2022-09-12T13:32:13.884649
| 2022-08-15T06:21:34
| 2022-08-15T06:21:34
| 165,518,391
| 17
| 5
| null | 2020-04-17T13:26:01
| 2019-01-13T14:59:56
|
C++
|
UTF-8
|
C++
| false
| false
| 816
|
cpp
|
#define N 1000007
class MyHashMap {
vector<int> vec;
public:
/** Initialize your data structure here. */
MyHashMap() {
vec.assign(N, -1);
}
/** value will always be non-negative. */
void put(int key, int value) {
vec[key] = value;
}
/** Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key */
int get(int key) {
return vec[key];
}
/** Removes the mapping of the specified value key if this map contains a mapping for the key */
void remove(int key) {
vec[key] = -1;
}
};
/**
* Your MyHashMap object will be instantiated and called as such:
* MyHashMap* obj = new MyHashMap();
* obj->put(key,value);
* int param_2 = obj->get(key);
* obj->remove(key);
*/
|
[
"sabujlovescoding@gmail.com"
] |
sabujlovescoding@gmail.com
|
fbf88d788fe09237901e026d842f7cbb7d1bef5e
|
bd63a879ee50d98f2bcf8fb7780c6c295f9ac07c
|
/learn/curl_example/curl_test/voice.cpp
|
bb0dcf57eb953cd92c28022cec73f4cedffc6173
|
[] |
no_license
|
lijiansong/.trash
|
2c56b5effc2136a08e272e145e01e1bb54218bb3
|
da5307e086a31ec335385d1c533af3cbd6653a64
|
refs/heads/master
| 2021-06-21T06:31:25.170024
| 2017-08-13T05:22:46
| 2017-08-13T05:22:46
| 67,503,889
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,543
|
cpp
|
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include "curl/curl.h"
#include "curl/easy.h"
#include "json/json.h"
#define MAX_BUFFER_SIZE 512
#define MAX_BODY_SIZE 1000000
using namespace std;
static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
static inline bool is_base64(unsigned char c)
{
return (isalnum(c) || (c == '+') || (c == '/'));
}
string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len)
{
std::string ret;
int i = 0;
int j = 0;
unsigned char char_array_3[3];
unsigned char char_array_4[4];
while (in_len--)
{
char_array_3[i++] = *(bytes_to_encode++);
if (i == 3)
{
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
char_array_4[3] = char_array_3[2] & 0x3f;
for (i = 0; (i <4); i++)
ret += base64_chars[char_array_4[i]];
i = 0;
}
}
if (i)
{
for (j = i; j < 3; j++)
char_array_3[j] = '\0';
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
char_array_4[3] = char_array_3[2] & 0x3f;
for (j = 0; (j < i + 1); j++)
ret += base64_chars[char_array_4[j]];
while ((i++ < 3))
ret += '=';
}
return ret;
}
string base64_decode(std::string const& encoded_string)
{
int in_len = encoded_string.size();
int i = 0;
int j = 0;
int in_ = 0;
unsigned char char_array_4[4], char_array_3[3];
std::string ret;
while (in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_]))
{
char_array_4[i++] = encoded_string[in_]; in_++;
if (i == 4)
{
for (i = 0; i <4; i++)
char_array_4[i] = base64_chars.find(char_array_4[i]);
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
for (i = 0; (i < 3); i++)
ret += char_array_3[i];
i = 0;
}
}
if (i)
{
for (j = i; j <4; j++)
char_array_4[j] = 0;
for (j = 0; j <4; j++)
char_array_4[j] = base64_chars.find(char_array_4[j]);
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
}
return ret;
}
//»Øµ÷º¯Êý
static size_t writefunc(void *ptr, size_t size, size_t nmemb, char **result)
{
size_t result_len = size * nmemb;
*result = (char *)realloc(*result, result_len + 1);
if (*result == NULL)
{
printf("realloc failure!\n");
return 1;
}
memcpy(*result, ptr, result_len);
(*result)[result_len] = '\0';
cout<<"Json data get from baidu server:"<<*result<<endl;
/*Json::Reader reader;
Json::Value root;
if(reader.parse(result,root))
{
string res = root["result"].asString();
cout <<"parse result: "<< res << endl;
}*/
return result_len;
}
int main()
{
freopen("out.txt", "w", stdout);
int json_file_size;
FILE *pFile = NULL;
char *audio_data;
pFile = fopen("test.pcm", "r");
if (pFile == NULL)
{
perror("Open file error!\n");
}
else
{
fseek(pFile, 0, SEEK_END);
int file_size = ftell(pFile);
cout << "file size: " << file_size << " bytes" << endl;
fseek(pFile, 0, SEEK_SET);
audio_data = (char *)malloc(sizeof(char)*file_size);
fread(audio_data, file_size, sizeof(char), pFile);
//mac of machine
char *cuid = "56:84:7a:fe:97:99";
char *api_key = "6yFhYifMjXc8QmubiICXBQgi";
char *secret_key = "nZn45o3X0LGx42qovumYy2mjpOiOup2E";
char host[MAX_BUFFER_SIZE];
snprintf(host, sizeof(host),
"https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials&client_id=%s&client_secret=%s",
api_key, secret_key);
cout << "curl -s param host: " << host << endl;
FILE *p = NULL;
char cmd[MAX_BUFFER_SIZE];
//curl -s return result
char *result = (char*)malloc(MAX_BUFFER_SIZE);
char *curl_cmd = "curl -s ";
char *yinhao = "\"";
strcpy(cmd, curl_cmd);
strcat(cmd, yinhao);
strcat(cmd, host);
strcat(cmd, yinhao);
p = popen(cmd, "r");
fgets(result, MAX_BUFFER_SIZE, p);
cout << "curl -s result : " << result << endl;
pclose(p);
string access_token;
//parse the json data from baidu server to get the access_token
if (result != NULL)
{
Json::Reader reader;
Json::Value root;
if (reader.parse(result, root, false))
{
access_token = root.get("access_token", "").asString();
cout << "access_token: " << access_token << endl;
}
}
else
{
cout<<"Result is null"<<endl;
}
//²ÉÈ¡ÒþÊœ·¢Ë͵ķœÊœžø·þÎñÆ÷·¢ËÍjsonžñÊœµÄÊýŸÝ
char body[MAX_BODY_SIZE];
memset(body, 0, sizeof(body));
string decode_data = base64_encode((const unsigned char *)audio_data, file_size);
if (0 == decode_data.length())
{
cout << "Error!base64 encoded data is empty!";
return 1;
}
else
{
Json::Value buffer;
Json::FastWriter buf_writer;
buffer["format"] = "pcm";
buffer["rate"] = 8000;
buffer["channel"] = 1;
buffer["token"] = access_token.c_str();
buffer["cuid"] = cuid;
buffer["speech"] = decode_data;
buffer["len"] = file_size;
//ʵŒÊjsonžñÊœÊýŸÝµÄ³€¶È
json_file_size = buf_writer.write(buffer).length();
cout << "Json file size:" << json_file_size << " bytes" << endl;
memcpy(body, buf_writer.write(buffer).c_str(), json_file_size);
CURL *curl;
CURLcode res;//·þÎñÆ÷µÄÏìÓŠœá¹û
char *result_buffer = NULL;
struct curl_slist *http_header = NULL;
char temp[MAX_BUFFER_SIZE];
memset(temp, 0, sizeof(temp));
snprintf(temp, sizeof(temp), "%s", "Content-Type: application/json; charset=utf-8");
http_header = curl_slist_append(http_header, temp);
snprintf(temp, sizeof(temp), "Content-Length: %d", json_file_size);
http_header = curl_slist_append(http_header, temp);
memset(host, 0, sizeof(host));
snprintf(host, sizeof(host), "%s", "http://vop.baidu.com/server_api");
cout << "server host: " << host << endl;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, host);//ÉèÖ÷ÃÎʵÄURL
curl_easy_setopt(curl, CURLOPT_POST, 1);//1±íÊŸ³£¹æµÄhttp postÇëÇó
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30);//ÉèÖÃÑÓʱ
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, http_header);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, json_file_size);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);//ÉèÖûص÷º¯Êý
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &result_buffer);
res = curl_easy_perform(curl);
if (res != CURLE_OK)
{
printf("perform curl error:%d.\n", res);
return 1;
}
curl_slist_free_all(http_header);
curl_easy_cleanup(curl);
free(audio_data);
}
}
fclose(pFile);
return 0;
}
|
[
"jiansongli426@gmail.com"
] |
jiansongli426@gmail.com
|
ff68779093bbe01e5372d11d6883c9dd1c139062
|
16048566baf377b970e5231f265f9fec3747febc
|
/src/spaceobj.h
|
62bd96979f1b97af48f5a727537b8cbe36f6db7d
|
[] |
no_license
|
nihilocrat/yarrwars
|
b3fb82921de4071b072522d29bea9807e8d376cc
|
5c81785f6ed3816bce94a2979ece16eed3746674
|
refs/heads/master
| 2021-01-16T18:20:35.251875
| 2012-08-28T20:49:24
| 2012-08-28T20:49:24
| 5,591,811
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,808
|
h
|
#ifndef SPACEOBJ_INCLUDED
#define SPACEOBJ_INCLUDED
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "spaceinc.h"
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
/********************************************************************************************************/
/* a few globals */
/********************************************************************************************************/
#define G_default_parts 100 // default number of particles in spaceEmitters
/********************************************************************************************************/
/* some extra math functions */
/********************************************************************************************************/
// degree and radian conversion.... using ratios is quicker!
// I would macro these if I didn't hate macros
SPfloat radians(SPfloat degrees);
SPfloat degrees(SPfloat radians);
SPfloat wrap(SPfloat angle);
/********************************************************************************************************/
/* Attribute Objects (Point, Vector, etc.) */
/********************************************************************************************************/
typedef enum spaceDirection
{
NEUTRAL,
LEFT,
RIGHT
};
class spacePoint
{
public:
SPfloat x, y; // FIXME : make these proctected eventually
spacePoint(SPfloat nx=0, SPfloat ny=0);
// operator overrides
bool operator== (spacePoint p2);
spacePoint spacePoint :: operator+ (spacePoint p2);
spacePoint spacePoint :: operator- (spacePoint p2);
/* for STL
spacePoint(pair<SPfloat, SPfloat>)
{
x = nx;
y = ny;
};
*/
// find the heading to another object
SPfloat angleto(spacePoint obj2);
// find the distance to another object
SPfloat dist(spacePoint obj2);
};
// colors!
class spaceColor
{
public:
SPfloat r, g, b;
spaceColor(SPfloat nr = 1.0, SPfloat ng = 1.0, SPfloat nb = 1.0);
};
/********************************************************************************************************/
/* Basic Objects (spaceObj, spaceShip) */
/********************************************************************************************************/
class spaceBit
{
/// in between a spacePoint and a spaceObj
/// a point with various other attributes that
/// make it handy for particle systems
spaceBit(){};
~spaceBit(){};
bool alive;
unsigned int life;
spaceColor color;
};
class spaceObj
{
public:
//Basic immobile game object
spaceObj();
~spaceObj(){};
// defined in render functions
virtual void draw();
void drawlabel();
// handle various developer-defined stuff
virtual void handle(){};
//protected:
spacePoint pos;
spacePoint vel;
SPfloat heading;
SPfloat maxvel;
SPfloat size;
spaceColor color;
bool alive;
unsigned int life;
unsigned int maxlife;
string name;
};
class spaceGroup : public vector<spaceObj*>
{
public:
void append(spaceObj* newguy);
void remove(spaceObj* oldguy);
void calc_avg_heading();
void redistribute();
unsigned int id;
spaceColor color;
spaceObj* leader;
bool alive;
SPfloat avg_heading;
};
class spacePlanet : public spaceObj
{
/// Big, immobile things!
public:
spacePlanet(string nname = "Strongbadia", spacePoint npos = spacePoint(), SPfloat nsize=200,
spaceColor ncolor=spaceColor());
void draw();
void overview_draw();
};
class spaceShip : public spaceObj
{
///Basic mobile game object
/// a class for any sort of mobile object that can turn, thrust, and so on
public:
spaceShip();
spaceShip(string newname, spacePoint npos, SPfloat nheading, SPfloat nturnspeed, SPfloat nimpulse, SPfloat nmaxvel,
spaceColor ncolor, spaceColor nscolor);
void move();
void friction(SPfloat amount);
void push(SPfloat theta, SPfloat magnitude);
void thrust();
void limitvel();
void turn(spaceDirection direction);
void turn(SPfloat maxturn);
void handle_health();
bool collide(spaceObj* other);
virtual void draw(); //FIXME : move to render header
virtual void overview_draw();
//protected:
SPfloat impulse, turnspeed;
spaceColor scolor;
unsigned int team_id;
spaceShip *attacker; // HACK : thing for telling AI when we're hit
spaceShip *enemy; // HACK : thing for telling AI who we're targetting
spaceShip *parent;
// HACK : this is to get spacesector to cooperate
unsigned int grog, maxgrog;
unsigned int fame;
spaceGroup *group;
};
class spaceEmitter : public spaceObj
{
public:
/// something that emits particles of some sort
spaceEmitter(){};
spaceEmitter(unsigned int nmax_life, unsigned int nmax_recharge,
spaceColor ncolor);
~spaceEmitter();
void fire();
void tick(unsigned int numticks = 1);
void move(spacePoint newpos);
void draw();
// functions to be overloaded by child classes
virtual void particle_draw(spaceObj *p_part) {}
virtual void emit(spaceObj *bit) {}
unsigned int max_parts; // number of particles POSSIBLE
unsigned int num_parts; // CURRENT number of particles
//spacePoint part[G_default_parts];
//unsigned int part_life[G_default_parts];
// array of particles
vector<spaceObj> part;
unsigned int max_life; // maximum particle lifetime FIXME yadda yadda
unsigned int recharge, max_recharge; // limits the rate of particle emission
spaceColor pcolor; // primary color (FIXME make this dynamic)
SPfloat psize; // particle size (FIXME make this dynamic)
spaceObj *parent;
};
/*
// non-STL
class spaceEmitter : public spaceObj
{
public:
// something that emits particles of some sort
spaceEmitter(unsigned int nmax_parts = G_default_parts, spaceColor ncolor = spaceColor(0,0,0));
~spaceEmitter();
void fire();
void tick(unsigned int numticks = 1);
void move(spacePoint newpos);
void draw();
// functions to be overloaded by child classes
virtual void particle_draw(unsigned int i){};
virtual void emit(spacePoint *bit){};
unsigned int max_parts; // number of particles POSSIBLE
unsigned int num_parts; // CURRENT number of particles
// array of particles
vector<spaceObj> part;
unsigned int max_life; // maximum particle lifetime FIXME yadda yadda
unsigned int recharge, max_recharge; // limits the rate of particle emission
spaceColor pcolor; // primary color (FIXME make this dynamic)
SPfloat psize; // particle size (FIXME make this dynamic)
};
*/
class spaceBullet : public spaceShip
{
///''' Projectile object '''
/// FIXME : might want to derive this from a simpler class for performance boost (?)
public:
virtual void draw();
virtual void overview_draw();
spaceShip *owner;
};
/********************************************************************************************************/
/* Advanced Objects (spaceCraft, spaceTurret) */
/********************************************************************************************************/
// we're not using a templateized spaceEmitter because, apparently,
// using templates craps stuff up down the line
class spaceWeapon : public spaceObj
{
public:
/// something that emits particles of some sort
spaceWeapon(){};
spaceWeapon(unsigned int nmax_life, unsigned int nmax_recharge,
SPfloat nbulletspeed, SPfloat nscatter, spaceColor ncolor);
~spaceWeapon();
void bind(spaceShip *nparent, spacePoint noffset);
void fire();
void tick(unsigned int numticks = 1);
void move(spacePoint newpos);
void draw();
void overview_draw();
// functions to be overloaded by child classes
//virtual void particle_draw(unsigned int i){};
virtual void emit(spaceBullet *bit);
// FIXME : use a better collide function! PLEASE!
void collide_list(spaceObj* list[], unsigned int listsize);
void damage(spaceBullet *bullet_i, spaceShip *victim);
unsigned int max_parts; // number of particles POSSIBLE
unsigned int num_parts; // CURRENT number of particles
vector<spaceBullet> part; // particle objects
// make iterators so I don't have to keep defining them later on
//vector<spaceBullet>::iterator part_i;
unsigned int max_life; // maximum particle lifetime FIXME yadda yadda
unsigned int recharge, max_recharge; // limits the rate of particle emission
spaceColor pcolor; // primary color (FIXME make this dynamic)
SPfloat psize; // particle size (FIXME make this dynamic)
spaceShip* parent;
spacePoint offset;
SPfloat bulletspeed, damage_amt;
SPfloat scatter;
};
class spaceTurret : public spaceShip
{
public:
spaceTurret(){ parent = NULL; };
spaceTurret(SPfloat turnrate, SPfloat size, spaceWeapon ngun);
virtual ~spaceTurret(){};
void bind(spaceShip *nparent, spacePoint noffset);
//void fire()
//{
// for weapon in _.weapons:
// weapon.fire()
//}
void move();
void turn(spaceDirection direction);
void track(spacePoint target);
void fire();
virtual void draw();
//spaceShip *parent; // pointer to the parent object
spacePoint offset;
SPfloat rotation; // how much the turret is rotation in comparison to its parent
spaceWeapon gun; // FIXME : for now, only one gun
};
#endif
|
[
"kenneth.backus@gmail.com"
] |
kenneth.backus@gmail.com
|
fbaadd562e30401aad2e39e4a58a74c3227ed516
|
3d8255a21f0061fab4a2e0b19c257200562f2ab8
|
/file_size/file_size.cpp
|
56b2955140f875a24366bed4556e7ee3aec19372
|
[] |
no_license
|
taklist/cppChallenges
|
7efd77fd466b4419d90a8faa5eced5c55d27466a
|
63e0e2899e60722065a0fb53511a4b22a5057c80
|
refs/heads/master
| 2021-05-02T18:10:17.569367
| 2016-10-31T08:12:53
| 2016-10-31T08:12:53
| 72,416,058
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 389
|
cpp
|
#include <fstream>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]){
if (argc != 2)
cout << "Usage: " << argv[0] << " filename\n";
ifstream file (argv[1], ios::binary | ios::ate);
if (!file){
cout << "Could not open " << argv[1] << ", try another file.\n";
return 1;
}
cout << "File size: " << file.tellg() << " bytes\n";
return 0;
}
|
[
"bjorn.janson.94@gmail.com"
] |
bjorn.janson.94@gmail.com
|
27e9e72b835770ca19aacbd1f29ae18d017d5321
|
67998e1fd6234045115c2d52b5ea39864671c617
|
/Week 6/Goblin/Arena.cpp
|
d524ad9893b4b4b9b8f45f8dd4d8d8b8f782f40b
|
[] |
no_license
|
jtoth955/CS-162
|
35f298a353eb86128b840e70c75bdf15cceb17f8
|
1641f203c8e9b6498806f0af03e3238dcd997f7d
|
refs/heads/master
| 2021-01-10T09:29:30.198827
| 2015-10-12T18:21:04
| 2015-10-12T18:21:04
| 44,125,791
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,222
|
cpp
|
/***********************************************************************************
*Filename: Arena.cpp
*Name: John R Toth
*Date: 5/4/15
*Description:
*Input:
*Output:
***********************************************************************************/
#include "Arena.hpp"
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
//default constructor
Arena::Arena() {
newNumFaces = 6;
newNumDice = 2;
defend = 0;
attack = 0;
goblinFact = false;
}
//number of die loop
int Arena::Roll() const {
int total = 0;
for (int i = 0; i < newNumDice; i++)
{
total = total+rand()%newNumFaces+1;
}
return total;
}
//member variable newNumFace gets changed to input param, faces
void Arena::setNumFaces(int faces) {
newNumFaces = faces;
}
//member variable newNumDice gets changed to input param, dice
void Arena::setNumDice(int dice) {
newNumDice = dice;
}
void Arena::setAttackRoll(int a) {
attack = a;
}
void Arena::setDefendRoll(int d) {
defend = d;
}
void Arena::setGoblinFactor(bool g) {
goblinFact = g;
}
bool Arena::getGoblinFactor() {
return goblinFact;
}
int Arena::deathBlow(){
int damage;
if(getGoblinFactor() == false)
{
cout <<"The Defender fought with a value of: "<< defend << endl;
if(attack > defend)
{
damage = attack - defend;
}
if(attack == defend)
{
cout << "The attack value equaled the defense value! " << endl;
damage = 0;
}
if(defend > attack)
{
cout << "The defender overpowered the attacker on that strike! " << endl;
damage = 0;
}
}
else if(getGoblinFactor() == true)
{
cout << "The defender's achilles has been cut! " << endl;
cout <<"The Defender fought with a value of: "<< defend << endl;
defend *= .5;
cout << "New defend value: " << defend << endl;
if(attack > defend)
{
damage = attack - defend;
}
if(attack == defend)
{
cout << "The attack value equaled the defense value! " << endl;
damage = 0;
}
if(defend > attack)
{
cout << "The defender overpowered the attacker on that strike! " << endl;
damage = 0;
}
}
return damage;
}
|
[
"tothj@oregonstate.edu"
] |
tothj@oregonstate.edu
|
9e111d9fde36c9aa8b376e875a1e66c2d4a4c697
|
263643760687758fbd9ecef30082026402ef4067
|
/sp_lab_02/tutorials/set.cpp
|
45344426054d512607c4ad8d8e79667766eee7c1
|
[] |
no_license
|
mr-ilin/sp
|
b4e796090edde917ac551c9eb48d97e3b39abda1
|
39f60f89897254d9ed213a65981545f4331c8a90
|
refs/heads/main
| 2023-08-22T04:34:48.909244
| 2021-09-17T11:12:36
| 2021-09-17T11:12:36
| 371,035,824
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 281
|
cpp
|
//set.cpp
#include "mlisp.h"
extern double a;
double g(double x, double a);
double a = 7.;
double g(double x, double a){
a = 5.;
return x + a;
}
int main(){
display(g(1., 0.));newline();
display(a);newline();
a = 8.;
display(a);newline();
std::cin.get();
return 0;
}
|
[
"mr.ilin14@gmail.com"
] |
mr.ilin14@gmail.com
|
e6247250923432d487595f8424c0bff199e6f4dc
|
86cdfffa208f59ec1020d87c20d2fce5a639ea77
|
/myframe.h
|
d616b7170904f2f456f42d8f18c17c6349b15ee5
|
[] |
no_license
|
tybitsfox/FrameWnd
|
0c415e37b8a741ac3c1dafb1ace863a0f6cc3fd1
|
5ac52d3be2c7c6a069cec4590bc7d3d53c5e30b7
|
refs/heads/master
| 2021-01-19T13:33:40.917861
| 2013-06-22T16:45:44
| 2013-06-22T16:45:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 400
|
h
|
#ifndef DEFAULT_MY_VIEW_ONE
#include"myview.h"
#endif
#ifndef IDI_ICON1
#include"resource.h"
#endif
class myframe:public CFrameWnd
{
public:
myview mview;
myframe();
~myframe();
int OnCreate(LPCREATESTRUCT lpcreatestruct);
BOOL PreCreateWindow(CREATESTRUCT &cs);
void OnSetFocus(CWnd *pwnd);
BOOL OnCmdMsg(UINT uint,int ncode,void *pextra,AFX_CMDHANDLERINFO *pinfo);
DECLARE_MESSAGE_MAP()
};
|
[
"tybitsfox@163.com"
] |
tybitsfox@163.com
|
ff79716b17deac3a8ffc710810f3ff21919cb43f
|
233676e340835a58e8041bdc82c313e599af415c
|
/Schweizer-Messer/sm_kinematics/src/Transformation.cpp
|
ba12982ae7705c76135f50c0bf5615879a434a96
|
[
"BSD-3-Clause"
] |
permissive
|
ethz-asl/kalibr
|
9213daa87ed191ce1e05fba9f7424204c2d9734c
|
94bb8437a72a0d97a491097a7085bf3db4f93bba
|
refs/heads/master
| 2023-08-29T17:04:47.774244
| 2023-08-14T02:08:46
| 2023-08-14T02:08:46
| 20,293,077
| 3,744
| 1,341
|
NOASSERTION
| 2023-09-10T02:18:47
| 2014-05-29T12:31:48
|
C++
|
UTF-8
|
C++
| false
| false
| 7,824
|
cpp
|
#include <sm/kinematics/Transformation.hpp>
#include <sm/kinematics/quaternion_algebra.hpp>
#include <sm/kinematics/rotations.hpp>
#include <sm/random.hpp>
#include <sm/kinematics/UncertainHomogeneousPoint.hpp>
#include <sm/kinematics/UncertainTransformation.hpp>
#include <sm/kinematics/transformations.hpp>
#include <sm/serialization_macros.hpp>
namespace sm {
namespace kinematics {
double * Transformation::qptr() { return &_q_a_b[0]; }
double * Transformation::tptr() { return &_t_a_b_a[0]; }
Transformation::Transformation() :
_q_a_b(quatIdentity()), _t_a_b_a(0.0, 0.0, 0.0)
{
}
Transformation::Transformation(Eigen::Matrix4d const & T_a_b) :
_q_a_b( r2quat(T_a_b.topLeftCorner<3,3>()) ),
_t_a_b_a( T_a_b.topRightCorner<3,1>() )
{
}
Transformation::Transformation(const Eigen::Vector4d & q_a_b, const Eigen::Vector3d & t_a_b_a) :
_q_a_b(q_a_b), _t_a_b_a(t_a_b_a)
{
_q_a_b.normalize();
}
Transformation::~Transformation(){}
/// @return the rotation matrix
Eigen::Matrix3d Transformation::C() const
{
return quat2r(_q_a_b);
}
/// @return the translation vector
const Eigen::Vector3d & Transformation::t() const
{
return _t_a_b_a;
}
const Eigen::Vector4d & Transformation::q() const
{
return _q_a_b;
}
void Transformation::set( const Eigen::Matrix4d & T_a_b )
{
_q_a_b = r2quat(T_a_b.topLeftCorner<3,3>());
_t_a_b_a = T_a_b.topRightCorner<3,1>();
}
Eigen::Matrix4d Transformation::T() const
{
Eigen::Matrix4d T_a_b;
// \todo...make this do less copying.
T_a_b.topLeftCorner<3,3>() = quat2r(_q_a_b);
T_a_b.topRightCorner<3,1>() = _t_a_b_a;
T_a_b.bottomLeftCorner<1,3>().setZero();
T_a_b(3,3) = 1.0;
return T_a_b;
}
Eigen::Matrix<double, 3, 4> Transformation::T3x4() const
{
Eigen::Matrix<double, 3, 4> T3x4;
// \todo...make this do less copying.
T3x4.topLeftCorner<3,3>() = quat2r(_q_a_b);
T3x4.topRightCorner<3,1>() = _t_a_b_a;
return T3x4;
}
Transformation Transformation::inverse() const
{
// \todo Make this do less copying.
return Transformation(quatInv(_q_a_b), quatRotate(quatInv(_q_a_b), -_t_a_b_a));
}
void Transformation::checkTransformationIsValid( void ) const
{
// \todo.
}
Transformation Transformation::operator*(const Transformation & rhs) const
{
return Transformation(qplus(_q_a_b, rhs._q_a_b), quatRotate(_q_a_b, rhs._t_a_b_a) + _t_a_b_a);
}
Eigen::Vector3d Transformation::operator*(const Eigen::Vector3d & rhs) const
{
return quatRotate(_q_a_b, rhs) + _t_a_b_a;
}
Eigen::Vector4d Transformation::operator*(const Eigen::Vector4d & rhs) const
{
Eigen::Vector4d rval;
rval.head<3>() = quatRotate(_q_a_b, rhs.head<3>()) + rhs[3] * _t_a_b_a;
rval[3] = rhs[3];
return rval;
}
HomogeneousPoint Transformation::operator*(const HomogeneousPoint & rhs) const
{
Eigen::Vector4d rval = rhs.toHomogeneous();
rval.head<3>() = (quatRotate(_q_a_b, rhs.toHomogeneous().head<3>()) + rval[3] * _t_a_b_a).eval();
return HomogeneousPoint(rval);
}
void Transformation::setRandom()
{
_q_a_b = quatRandom();
_t_a_b_a = (Eigen::Vector3d::Random().array() - 0.5) * 100.0;
}
bool Transformation::isBinaryEqual(const Transformation & rhs) const
{
return SM_CHECKMEMBERSSAME(rhs, _q_a_b) && SM_CHECKMEMBERSSAME(rhs, _t_a_b_a);
}
/// \brief The update step for this transformation from a minimal update.
void Transformation::oplus(const Eigen::Matrix<double,6,1> & dt)
{
_q_a_b = updateQuat( _q_a_b, dt.tail<3>() );
_t_a_b_a += dt.head<3>();
}
Eigen::Matrix<double,6,6> Transformation::S() const
{
Eigen::Matrix<double,6,6> S;
S.setIdentity();
S.topRightCorner<3,3>() = -crossMx(_t_a_b_a);
return S;
}
void Transformation::setIdentity()
{
_q_a_b = quatIdentity();
_t_a_b_a.setZero();
}
/// \brief Set this to a random transformation.
void Transformation::setRandom( double translationMaxMeters, double rotationMaxRadians)
{
// Create a random unit-length axis.
Eigen::Vector3d axis = Eigen::Vector3d::Random().array() - 0.5;
// Create a random rotation angle in radians.
double angle = sm::random::randLU(0.0, rotationMaxRadians);
// Now a random axis/angle.cp
axis.array() *= angle/axis.norm();
Eigen::Vector3d t;
t.setRandom();
t.array() -= 0.5;
t.array() *= sm::random::randLU(0.0, translationMaxMeters)/t.norm();
_q_a_b = axisAngle2quat(axis);
_t_a_b_a = t;
}
UncertainTransformation Transformation::operator*(const UncertainTransformation & UT_b_c) const
{
const Transformation & T_a_b = *this;
const Transformation & T_b_c = UT_b_c;
Transformation T_a_c = T_a_b * T_b_c;
UncertainTransformation::covariance_t T_a_b_boxtimes = boxTimes(T_a_b.T());
UncertainTransformation::covariance_t U_a_c = T_a_b_boxtimes * UT_b_c.U() * T_a_b_boxtimes.transpose();
return UncertainTransformation(T_a_c, U_a_c);
}
UncertainHomogeneousPoint Transformation::operator*(const UncertainHomogeneousPoint & p_1) const
{
const Transformation & T_0_1 = *this;
Eigen::Vector4d p_0 = T_0_1 * p_1.toHomogeneous();
Eigen::Matrix4d T01 = T_0_1.T();
UncertainHomogeneousPoint::covariance_t U = T01 * p_1.U4() * T01.transpose();
return UncertainHomogeneousPoint(p_0,U);
}
/// \brief rotate a point (do not translate)
Eigen::Vector3d Transformation::rotate(const Eigen::Vector3d & p) const
{
return quatRotate(_q_a_b, p);
}
/// \brief rotate a point (do not translate)
Eigen::Vector4d Transformation::rotate(const Eigen::Vector4d & p) const
{
Eigen::Vector4d rval = p;
rval.head<3>() = quatRotate(_q_a_b, rval.head<3>());
return rval;
}
UncertainVector3 Transformation::rotate(const UncertainVector3 & p) const
{
Eigen::Vector3d mean = rotate(p.mean());
Eigen::Matrix3d R = C();
Eigen::Matrix3d P = R * p.covariance() * R.transpose();
return UncertainVector3(mean, P);
}
// Interpolate the transformation at time si between T0 (at time s0) and T1 (at time s1)
Transformation interpolateTransformations(const Transformation & T0, double s0,
const Transformation & T1, double s1,
double si)
{
if( s0 > s1 )
{
return interpolateTransformations( T1, s1, T0, s0, si );
}
// The time span of interpolation. Make sure this is greater than zero.
double ds = std::max(1e-14, s1 - s0);
// The place of si on this timespan 0.0 --> s0, 1.0 -> s1
double di = (si - s0) / ds;
return slerpTransformations(T0, T1, di);
}
/// brief linear interpolate between T0 and T1 as si moves from 0.0 to 1.0
Transformation slerpTransformations(const Transformation & T0,
const Transformation & T1,
double si)
{
// lazy. interpolate separately.
return Transformation( qslerp( T0.q(), T1.q(), si), lerp( T0.t(), T1.t(), si) );
}
} // namespace kinematics
} // namespace sm
|
[
"schneith@ethz.ch"
] |
schneith@ethz.ch
|
6380c103f1bafb1f725bc090b60fd64d4b206be2
|
147365ef78fc26380b6edfd0a3ca704e90a372c6
|
/src/HT16K33.cpp
|
4bc7c7231fd95fe3353ea3e1ae87655b306ad1da
|
[] |
no_license
|
Strooom/HT16K33
|
f7e9e3f6f3d4134059c31ac3933c022bfeaccce9
|
4b208fa9fe67638e400cf9790092adb424f0e2db
|
refs/heads/master
| 2020-03-16T01:23:23.908429
| 2018-05-12T20:02:59
| 2018-05-12T20:02:59
| 132,438,962
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,286
|
cpp
|
#include <Wire.h>
#include "HT16K33.h"
HT16K33::HT16K33(uint8_t theI2CAddress = 0x70, uint8_t theBrightness = 8) : brightness(theBrightness), I2CAddress(theI2CAddress)
{
clearDisplay(); // set displayRAM to all zeroes, blanks display
}
HT16K33::~HT16K33()
{
}
void HT16K33::initialize(void)
{
Wire.beginTransmission(I2CAddress);
Wire.write((uint8_t) HT16K33Command::SystemOscillatorOn);
Wire.endTransmission();
Wire.beginTransmission(I2CAddress);
Wire.write((uint8_t)HT16K33Command::DisplayOn); // Default is BlinkOff
Wire.endTransmission();
Wire.beginTransmission(I2CAddress);
Wire.write((uint8_t)HT16K33Command::SetBrightness | brightness); // Brightness to max
Wire.endTransmission();
}
void HT16K33::refreshDisplay(void)
{
Wire.beginTransmission(I2CAddress); // First send the I2C address
Wire.write((uint8_t)0x00); // Then set HT16K33 displayRam address to 0
for (uint8_t i = 0; i < 8; i++) // iterate over all uint16 in displayRAM
{
Wire.write(displayRAM[i] & 0xFF); // write LSB first
Wire.write(displayRAM[i] >> 8); // then write MSB
}
Wire.endTransmission();
}
void HT16K33::setColon(boolean On)
{
if (On)
{
displayRAM[2] = 0x2;
}
else
{
displayRAM[2] = 0;
}
}
void HT16K33::showNumber(uint16_t theNmbr)
{
displayRAM[4] = HT16K33Number[theNmbr % 10];
if (theNmbr >= 10)
{
displayRAM[3] = HT16K33Number[(theNmbr / 10) % 10];
}
else
{
displayRAM[3] = 0;
}
if (theNmbr >= 100)
{
displayRAM[1] = HT16K33Number[(theNmbr / 100) % 10];
}
else
{
displayRAM[1] = 0;
}
if (theNmbr >= 1000)
{
displayRAM[0] = HT16K33Number[(theNmbr / 1000) % 10];
}
else
{
displayRAM[0] = 0;
}
}
void HT16K33::showNumber(uint8_t left2Digits, uint8_t right2Digits)
{
displayRAM[4] = HT16K33Number[right2Digits % 10];
displayRAM[3] = HT16K33Number[(right2Digits / 10) % 10];
displayRAM[1] = HT16K33Number[left2Digits % 10];
displayRAM[0] = HT16K33Number[(left2Digits / 10) % 10];
}
void HT16K33::showNumber(float theNmbr)
{
uint32_t intNmbr;
if (theNmbr >= 0)
{
intNmbr = (uint32_t)theNmbr;
if (intNmbr >= 10000)
{
// Overflow - display '....'
displayRAM[0] = 0x80;
displayRAM[1] = 0x80;
displayRAM[3] = 0x80;
displayRAM[4] = 0x80;
}
else if (intNmbr >= 1000)
{
// 4 digits needed, so no decimal point and fractional digits
displayRAM[0] = HT16K33Number[(intNmbr / 1000)];
displayRAM[1] = HT16K33Number[(intNmbr / 100) % 10];
displayRAM[3] = HT16K33Number[(intNmbr / 10) % 10];
displayRAM[4] = HT16K33Number[intNmbr % 10];
}
else if (intNmbr >= 100)
{
// 3 digits needed, so decimal point and 1 fractional digit
intNmbr = (uint32_t)(theNmbr * 10);
displayRAM[0] = HT16K33Number[(intNmbr / 1000)];
displayRAM[1] = HT16K33Number[(intNmbr / 100) % 10];
displayRAM[3] = HT16K33Number[(intNmbr / 10) % 10] | 0x80;
displayRAM[4] = HT16K33Number[intNmbr % 10];
}
else if (intNmbr >= 10)
{
// 2 digits needed, so decimal point and 2 fractional digits
intNmbr = (uint32_t)(theNmbr * 100);
displayRAM[0] = HT16K33Number[(intNmbr / 1000)];
displayRAM[1] = HT16K33Number[(intNmbr / 100) % 10] | 0x80;
displayRAM[3] = HT16K33Number[(intNmbr / 10) % 10];
displayRAM[4] = HT16K33Number[intNmbr % 10];
}
else
{
// 1 digit needed, so decimal point and 3 fractional digits
intNmbr = (uint32_t)(theNmbr * 1000);
displayRAM[0] = HT16K33Number[(intNmbr / 1000)] | 0x80;
displayRAM[1] = HT16K33Number[(intNmbr / 100) % 10];
displayRAM[3] = HT16K33Number[(intNmbr / 10) % 10];
displayRAM[4] = HT16K33Number[intNmbr % 10];
}
}
else
{
intNmbr = (uint32_t)(-1 * theNmbr);
if (intNmbr >= 1000)
{
// Overflow - display '-....'
displayRAM[0] = 0xC0;
displayRAM[1] = 0x80;
displayRAM[3] = 0x80;
displayRAM[4] = 0x80;
}
else if (intNmbr >= 100)
{
// '-'sign and 3 digits needed, so no decimal point and fractional digits
displayRAM[0] = 0x40; // '-' sign on first digit
displayRAM[1] = HT16K33Number[(intNmbr / 100)];
displayRAM[3] = HT16K33Number[(intNmbr / 10) % 10] | 0x80;
displayRAM[4] = HT16K33Number[intNmbr % 10];
}
else if (intNmbr >= 10)
{
// '-'sign and 2 digits needed, so decimal point and 1 fractional digit
intNmbr = (uint32_t)(theNmbr * -10);
displayRAM[0] = 0x40; // '-' sign on first digit
displayRAM[1] = HT16K33Number[(intNmbr / 100)] | 0x80;
displayRAM[3] = HT16K33Number[(intNmbr / 10) % 10];
displayRAM[4] = HT16K33Number[intNmbr % 10];
}
else
{
// '-'sign and 1 digit needed, so decimal point and 2 fractional digits
intNmbr = (uint32_t)(theNmbr * -100);
displayRAM[0] = 0xC0; // '-' sign on first digit
displayRAM[1] = HT16K33Number[(intNmbr / 100)];
displayRAM[3] = HT16K33Number[(intNmbr / 10) % 10];
displayRAM[4] = HT16K33Number[intNmbr % 10];
}
}
}
void HT16K33::clearDisplay(void)
{
for (uint8_t i = 0; i < 8; i++) // iterate over all uint16 in displayRAM...
{
displayRAM[i] = 0; // ... and initialize it to 0
}
}
void HT16K33::testDisplay(void)
{
displayRAM[0] = 0xFF;
displayRAM[1] = 0xFF;
displayRAM[2] = 0xFF;
displayRAM[3] = 0xFF;
displayRAM[4] = 0xFF;
}
|
[
"pascal.roobrouck@gmail.com"
] |
pascal.roobrouck@gmail.com
|
9deacca2ec14605863816ae5d897ffda6f952b68
|
e80d888d060abd23238d10ebeb4221022035a493
|
/Euclidean_algorithm.cpp
|
f89b6695ee5c03ee805735c147b16a1da1e0be68
|
[] |
no_license
|
ssun-g/study
|
7d4bf4fc81527d0a1cde165c63cf2829950bd0f0
|
c286beacb333616ba838b9486ddf3437962677c9
|
refs/heads/master
| 2022-12-04T18:17:35.601361
| 2020-08-17T12:05:45
| 2020-08-17T12:05:45
| 288,169,491
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 485
|
cpp
|
#include<stdio.h>
int GCD(int, int);
int main(void) {
int num1, num2;
scanf("%d%d", &num1, &num2);
if (num1 > num2)
printf("%d\n", GCD(num1, num2));
else if (num2 > num1)
printf("%d\n", GCD(num2, num1));
return 0;
}
int GCD(int a, int b) { // main문에서 a>b가 되도록 값을 넣어준다.
if (b == 0)
return a; // else문에 의해 작은 값이 0이 되면 a값을 return한다.
else
return GCD(b, a%b); // 유클리드 알고리즘(재귀적 호출방법)
}
|
[
"goflrkqk@naver.com"
] |
goflrkqk@naver.com
|
911ded2a15e08ae8a29c1439ef083694ae42e4d8
|
d3affeadad9619cda35d5cd8674e503be203ac29
|
/finalproject/src/hw_soln/fire_module/solution1/syn/systemc/FIFO_fire2_matrix_e3x3_stream_o_54_V.h
|
af3561d5b7245103badbf5e9fe2e818377be8569
|
[] |
no_license
|
chl218/FPGA-for-Computer-Vision
|
800c98ebf6df4d8ec1818698d401f88dd448fe79
|
9ccad894bf7ac59d9f4c33afcd385ea3f47bf938
|
refs/heads/master
| 2021-01-20T02:42:47.126346
| 2017-05-02T05:07:10
| 2017-05-02T05:07:10
| 89,445,626
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,829
|
h
|
// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2015.4
// Copyright (C) 2015 Xilinx Inc. All rights reserved.
//
// ==============================================================
#ifndef FIFO_fire2_matrix_e3x3_stream_o_54_V_HH_
#define FIFO_fire2_matrix_e3x3_stream_o_54_V_HH_
#include <systemc>
using namespace std;
SC_MODULE(FIFO_fire2_matrix_e3x3_stream_o_54_V) {
static const unsigned int DATA_WIDTH = 32;
static const unsigned int ADDR_WIDTH = 1;
static const unsigned int FIFO_fire2_matrix_e3x3_stream_o_54_V_depth = 2;
sc_core::sc_in_clk clk;
sc_core::sc_in< sc_dt::sc_logic > reset;
sc_core::sc_out< sc_dt::sc_logic > if_empty_n;
sc_core::sc_in< sc_dt::sc_logic > if_read_ce;
sc_core::sc_in< sc_dt::sc_logic > if_read;
sc_core::sc_out< sc_dt::sc_lv<DATA_WIDTH> > if_dout;
sc_core::sc_out< sc_dt::sc_logic > if_full_n;
sc_core::sc_in< sc_dt::sc_logic > if_write_ce;
sc_core::sc_in< sc_dt::sc_logic > if_write;
sc_core::sc_in< sc_dt::sc_lv<DATA_WIDTH> > if_din;
sc_core::sc_signal< sc_dt::sc_logic > internal_empty_n;
sc_core::sc_signal< sc_dt::sc_logic > internal_full_n;
sc_core::sc_signal< sc_dt::sc_lv<DATA_WIDTH> > mStorage[FIFO_fire2_matrix_e3x3_stream_o_54_V_depth];
sc_core::sc_signal< sc_dt::sc_uint<ADDR_WIDTH> > mInPtr;
sc_core::sc_signal< sc_dt::sc_uint<ADDR_WIDTH> > mOutPtr;
sc_core::sc_signal< sc_dt::sc_uint<1> > mFlag_nEF_hint;
sc_core::sc_trace_file* mTrace;
SC_CTOR(FIFO_fire2_matrix_e3x3_stream_o_54_V) : mTrace(0) {
const char* dump_vcd = std::getenv("AP_WRITE_VCD");
if (dump_vcd && string(dump_vcd) == "1") {
std::string tracefn = "sc_trace_" + std::string(name());
mTrace = sc_core::sc_create_vcd_trace_file( tracefn.c_str());
sc_trace(mTrace, clk, "(port)clk");
sc_trace(mTrace, reset, "(port)reset");
sc_trace(mTrace, if_full_n, "(port)if_full_n");
sc_trace(mTrace, if_write_ce, "(port)if_write_ce");
sc_trace(mTrace, if_write, "(port)if_write");
sc_trace(mTrace, if_din, "(port)if_din");
sc_trace(mTrace, if_empty_n, "(port)if_empty_n");
sc_trace(mTrace, if_read_ce, "(port)if_read_ce");
sc_trace(mTrace, if_read, "(port)if_read");
sc_trace(mTrace, if_dout, "(port)if_dout");
sc_trace(mTrace, mInPtr, "mInPtr");
sc_trace(mTrace, mOutPtr, "mOutPtr");
sc_trace(mTrace, mFlag_nEF_hint, "mFlag_nEF_hint");
}
mInPtr = 0;
mOutPtr = 0;
mFlag_nEF_hint = 0;
SC_METHOD(proc_read_write);
sensitive << clk.pos();
SC_METHOD(proc_dout);
sensitive << mOutPtr;
for (unsigned i = 0; i < FIFO_fire2_matrix_e3x3_stream_o_54_V_depth; i++) {
sensitive << mStorage[i];
}
SC_METHOD(proc_ptr);
sensitive << mInPtr << mOutPtr<< mFlag_nEF_hint;
SC_METHOD(proc_status);
sensitive << internal_empty_n << internal_full_n;
}
~FIFO_fire2_matrix_e3x3_stream_o_54_V() {
if (mTrace) sc_core::sc_close_vcd_trace_file(mTrace);
}
void proc_status() {
if_empty_n.write(internal_empty_n.read());
if_full_n.write(internal_full_n.read());
}
void proc_read_write() {
if (reset.read() == sc_dt::SC_LOGIC_1) {
mInPtr.write(0);
mOutPtr.write(0);
mFlag_nEF_hint.write(0);
}
else {
if (if_read_ce.read() == sc_dt::SC_LOGIC_1
&& if_read.read() == sc_dt::SC_LOGIC_1
&& internal_empty_n.read() == sc_dt::SC_LOGIC_1) {
sc_dt::sc_uint<ADDR_WIDTH> ptr;
if (mOutPtr.read().to_uint() == (FIFO_fire2_matrix_e3x3_stream_o_54_V_depth-1)) {
ptr = 0;
mFlag_nEF_hint.write(~mFlag_nEF_hint.read());
}
else {
ptr = mOutPtr.read();
ptr++;
}
assert(ptr.to_uint() < FIFO_fire2_matrix_e3x3_stream_o_54_V_depth);
mOutPtr.write(ptr);
}
if (if_write_ce.read() == sc_dt::SC_LOGIC_1
&& if_write.read() == sc_dt::SC_LOGIC_1
&& internal_full_n.read() == sc_dt::SC_LOGIC_1) {
sc_dt::sc_uint<ADDR_WIDTH> ptr;
ptr = mInPtr.read();
mStorage[ptr.to_uint()].write(if_din.read());
if (ptr.to_uint() == (FIFO_fire2_matrix_e3x3_stream_o_54_V_depth-1)) {
ptr = 0;
mFlag_nEF_hint.write(~mFlag_nEF_hint.read());
} else {
ptr++;
assert(ptr.to_uint() < FIFO_fire2_matrix_e3x3_stream_o_54_V_depth);
}
mInPtr.write(ptr);
}
}
}
void proc_dout() {
sc_dt::sc_uint<ADDR_WIDTH> ptr = mOutPtr.read();
if (ptr.to_uint() > FIFO_fire2_matrix_e3x3_stream_o_54_V_depth) {
if_dout.write(sc_dt::sc_lv<DATA_WIDTH>());
}
else {
if_dout.write(mStorage[ptr.to_uint()]);
}
}
void proc_ptr() {
if (mInPtr.read() == mOutPtr.read() && mFlag_nEF_hint.read().to_uint()==0) {
internal_empty_n.write(sc_dt::SC_LOGIC_0);
}
else {
internal_empty_n.write(sc_dt::SC_LOGIC_1);
}
if (mInPtr.read() == mOutPtr.read() && mFlag_nEF_hint.read().to_uint()==1) {
internal_full_n.write(sc_dt::SC_LOGIC_0);
}
else {
internal_full_n.write(sc_dt::SC_LOGIC_1);
}
}
};
#endif //FIFO_fire2_matrix_e3x3_stream_o_54_V_HH_
|
[
"chl218@eng.ucsd.edu"
] |
chl218@eng.ucsd.edu
|
a78185d6a8c124620a35be27d603d67514a8f261
|
cef5bef0b7bf5114d1f93f8090870ac6c4707683
|
/HMC_Type_Namelist.inc
|
ba3c6f6a0957a67b08e9dd8722488acb8661235d
|
[] |
no_license
|
vbasso/hmc_v207
|
7cc53817cd7f1b1c73af976054328a01a0edd30e
|
12cd95d94d28d29d38880eb06acb96dd0884423f
|
refs/heads/vbasso_hmc
| 2020-03-08T03:14:20.667658
| 2019-04-01T09:54:50
| 2019-04-01T09:54:50
| 127,884,763
| 0
| 0
| null | 2018-09-24T14:34:12
| 2018-04-03T09:32:53
|
Fortran
|
UTF-8
|
C++
| false
| false
| 5,284
|
inc
|
TYPE HMC_Type_Namelist
! Init
integer(kind = 4) :: iFlagDebugSet, iFlagDebugLevel
integer(kind = 4) :: iFlagOs
integer(kind = 4) :: iFlagTypeData_Static
integer(kind = 4) :: iFlagTypeData_Forcing_Gridded, iFlagTypeData_Forcing_Point, iFlagTypeData_Forcing_TimeSeries
integer(kind = 4) :: iFlagTypeData_Updating_Gridded
integer(kind = 4) :: iFlagTypeData_Output_Gridded, iFlagTypeData_Output_Point, iFlagTypeData_Output_TimeSeries
integer(kind = 4) :: iFlagTypeData_State_Gridded, iFlagTypeData_State_Point
integer(kind = 4) :: iFlagTypeData_Restart_Gridded, iFlagTypeData_Restart_Point
integer(kind = 4) :: iFlagRestart, iFlagFlowDeep
integer(kind = 4) :: iFlagVarDtPhysConv
integer(kind = 4) :: iFlagReleaseMass
integer(kind = 4) :: iFlagLAI, iFlagAlbedo, iFlagCH
integer(kind = 4) :: iFlagSnow, iFlagSnowAssim, iFlagSMAssim
integer(kind = 4) :: iFlagCoeffRes, iFlagWS
integer(kind = 4) :: iFlagGrid
logical :: bGridCheck
integer(kind = 4) :: iSimLength, iDtModel
integer(kind = 4) :: iDtData_Forcing
integer(kind = 4) :: iDtData_Updating
integer(kind = 4) :: iDtData_Output_Gridded, iDtData_Output_Point
integer(kind = 4) :: iDtData_State_Gridded, iDtData_State_Point
integer(kind = 4) :: iDtPhysConv, iDtPhysConvPrevious
integer(kind = 4) :: iDtPhysMethod
integer(kind = 4) :: iScaleFactor, iTcMax, iTc
integer(kind = 4) :: iRowsL, iColsL
real(kind = 4) :: dXLLCornerL, dYLLCornerL, dXCellSizeL, dYCellSizeL, dNoDataL
integer(kind = 4) :: iRowsF, iColsF
real(kind = 4) :: dXLLCornerF, dYLLCornerF, dXCellSizeF, dYCellSizeF, dNoDataF
integer(kind = 4) :: iNSection
integer(kind = 4) :: iNLake, iNDam, iNPlant, iNJoint, iNCatch, iNRelease
integer(kind = 4) :: iDaySteps, iTMarkedSteps
integer(kind = 4) :: iGlacierValue
real(kind = 4) :: dRhoSnowMax, dRhoSnowFresh, dSnowQualityThr
real(kind = 4) :: dMeltingTRef
integer(kind = 4) :: iTdeepShift, iNTime, iEtime
integer(kind = 4) :: iNData
real(kind = 4) :: dRateMin, dBc
real(kind = 4) :: dTRef, dEpsS, dSigma, dBFMin, dBFMax
real(kind = 4) :: dZRef, dG, dCp, dRd, dRhoS, dRhoW, dCpS, dCpW
real(kind = 4) :: dKq, dKw, dKo, dPorS, dFqS
real(kind = 4) :: dWTableHMin, dWTableHUSoil, dWTableHUChannel, dWTableSlopeBM, dWTableHOBedRock
real(kind = 4) :: dTV, dDamSpillH
real(kind = 4) :: dSMGain
character(len = 19) :: sTimeStart
character(len = 19) :: sTimeRestart
!character(len = 19) :: sTimeStatus
integer(kind = 4), allocatable, dimension(:) :: a1iDimsForcing
real(kind = 4), allocatable, dimension(:) :: a1dGeoForcing
real(kind = 4), allocatable, dimension(:) :: a1dResForcing
real(kind = 4), allocatable, dimension(:) :: a1dArctUp
real(kind = 4), allocatable, dimension(:) :: a1dExpRhoLow
real(kind = 4), allocatable, dimension(:) :: a1dExpRhoHigh
real(kind = 4), allocatable, dimension(:) :: a1dAltRange
real(kind = 4), allocatable, dimension(:) :: a1dAlbedoMonthly
real(kind = 4), allocatable, dimension(:) :: a1dLAIMonthly
real(kind = 4), allocatable, dimension(:) :: a1dCHMonthly
real(kind = 4), allocatable, dimension(:) :: a1dDemStep
real(kind = 4), allocatable, dimension(:) :: a1dIntStep
real(kind = 4), allocatable, dimension(:) :: a1dDtStep
real(kind = 4), allocatable, dimension(:) :: a1dDtRatioStep
character(len = 256) :: sPathData_Static_Gridded
character(len = 256) :: sPathData_Static_Point
character(len = 256) :: sPathData_Forcing_Gridded
character(len = 256) :: sPathData_Forcing_Point
character(len = 256) :: sPathData_Forcing_TimeSeries
character(len = 256) :: sPathData_Updating_Gridded
character(len = 256) :: sPathData_Output_Gridded
character(len = 256) :: sPathData_Output_Point
character(len = 256) :: sPathData_Output_TimeSeries
character(len = 256) :: sPathData_State_Gridded
character(len = 256) :: sPathData_State_Point
character(len = 256) :: sPathData_Restart_Gridded
character(len = 256) :: sPathData_Restart_Point
character(len = 1) :: sPathBar
character(len = 700) :: sCommandUnzipFile
character(len = 700) :: sCommandZipFile
character(len = 700) :: sCommandRemoveFile
character(len = 700) :: sCommandCreateFolder
character(len = 10) :: sReleaseDate
character(len = 700) :: sAuthorNames
character(len = 5) :: sReleaseVersion
real(kind = 4) :: dUc, dUh, dCt, dCf, dCPI, dWTableHbr, dKSatRatio, dSlopeMax
character(len = 256) :: sDomainName
END TYPE HMC_Type_Namelist
|
[
"fabio.delogu@cimafoundation.org"
] |
fabio.delogu@cimafoundation.org
|
2e69576b685670220917c997a0ab35a74f322973
|
305d59b84e676bc75cd21f9ece048d4588348f55
|
/AEDA1617Parte2_2MIEIC1_E/Código/Trabalho AEDA/Transactions.h
|
d4e3a587f3a37fd0206a1e6f3c56828af137d039
|
[] |
no_license
|
literallysofia/feup-aeda
|
14e5eab4c0bef7cd8abbf97607baa03f4fa79954
|
ba21051b57eac6e0d4bfb731cc251c8d95e3e2f6
|
refs/heads/master
| 2021-01-19T21:29:48.790510
| 2017-04-03T19:42:36
| 2017-04-03T19:42:36
| 71,155,566
| 2
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,617
|
h
|
#pragma once
/** @defgroup Transaction Transaction
* @{
*
* Transaction class declaration
*/
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include "Date.h"
using namespace std;
class Transaction
{
private:
/** @name Transaction data-members*/
/**@{
*
*/
int id;
Date date;
float value;
/** @} end of Transaction data-members */
public:
/**
* @brief Transaction default constructor
*/
Transaction();
/**
* @brief Transaction constructor from individual parameters
*
* @param id to set
* @param Date to set
* @param value year to set
*/
Transaction (int id, Date date, float value);
/** @name Basic Class Functions*/
/**@{
*
* Functions that perform basic class functionality
*/
/**
* @brief Retrieves object's ID
*
* @return int id
*/
int GetId() const;
/**
* @brief Retrieves object's Date
*
* @return Date date
*/
Date GetDate() const;
/**
* @brief Retrieves object's value
*
* @return float value
*/
float GetValue() const;
/** @} end of Basic Class Functions */
/**
* @brief Writes object's information into file
*
* @param out ofstream type variable initialized to the location of the file to be written too
*/
void save(ofstream & out) const;
/** @name Transaction Operators Functions*/
/**@{
*
* Basic Operators of the class
*/
/**
* @brief Writes to ostream the information of a object of class Transaction
*
* @param Transaction object of which we want to print the information for
*/
friend ostream& operator<<(ostream & out, const Transaction & t);
/** @} end of Transaction Operators Functions */
};
|
[
"up201505628@fe.up.pt"
] |
up201505628@fe.up.pt
|
7e92b091ee4dda13596855096ff1d71208b83d47
|
f92b42b1f183870d1685c1b8514d0be002fd79a7
|
/USACO Training/Chapter1/Section 1.5/PPRIME.CPP
|
405c1fa291c00c1a68e5587f690b2ce2133050d6
|
[] |
no_license
|
reiniermujica/algorithms-and-contests
|
7075f17b2d8e62c0bec5571bc394b5587552e8f2
|
7ce665cb26d7b97d99789a0704dd98fcfd3acf3c
|
refs/heads/master
| 2020-03-21T11:43:42.073645
| 2018-07-27T21:19:43
| 2018-07-27T21:19:43
| 138,519,203
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 977
|
cpp
|
/*
ID: reywork2
PROG: pprime
LANG: C++
*/
#include <cstdio>
#include <cmath>
using namespace std;
const int
MAXN = 15;
int A, B, sA, sB;
int i;
int num[MAXN];
bool prime( int x ) {
if ( x % 2 == 0 ) return false;
for ( int i = 3; i * i <= x; i += 2 )
if ( x % i == 0 ) return false;
return true;
}
void check( int len ) {
int res = 0;
for ( int i = 1; i <= len; i++ )
res = ( res * 10 ) + num[i];
if ( res >= A && res <= B && prime( res ) )
printf( "%d\n", res );
}
void comb( int lo, int hi ) {
if ( lo > hi ) {
check( i );
return ;
}
for ( int i = 0; i <= 9; i++ ) {
num[lo] = num[hi] = i;
comb( lo + 1, hi - 1 );
}
num[lo] = num[hi] = 0;
}
int main() {
freopen( "pprime.in", "r", stdin );
freopen( "pprime.out", "w", stdout );
scanf( "%d %d", &A, &B );
sA = (int)log10( A ) + 1;
sB = (int)log10( B ) + 1;
for ( i = sA; i <= sB; i++ )
comb( 1, i );
fflush( stdout );
return 0;
}
|
[
"reinier.mujica@gmail.com"
] |
reinier.mujica@gmail.com
|
baeb935b6924cc2f5cdc76984fee0de97e704fb5
|
4c31ccf6939c82bf01816a3152e2924d759f1197
|
/src/qt/recentrequeststablemodel.h
|
c837109d4fc70addc9f85dedfd8a31f26ec508ff
|
[
"MIT"
] |
permissive
|
MichaelHDesigns/HodlCash
|
da5393e3f3aa8ff4ee0774dc35cbb3aa27d0df7a
|
c3ca85c436ba40afadfda11db207068a16527379
|
refs/heads/main
| 2023-05-06T22:20:15.208883
| 2021-05-28T21:08:11
| 2021-05-28T21:08:11
| 360,015,879
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,381
|
h
|
// Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2017-2019 The HodlCash developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
#define BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
#include "walletmodel.h"
#include <QAbstractTableModel>
#include <QDateTime>
#include <QStringList>
class CWallet;
class RecentRequestEntry
{
public:
RecentRequestEntry() : nVersion(RecentRequestEntry::CURRENT_VERSION), id(0) {}
static const int CURRENT_VERSION = 1;
int nVersion;
int64_t id;
QDateTime date;
SendCoinsRecipient recipient;
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{
unsigned int nDate = date.toTime_t();
READWRITE(this->nVersion);
nVersion = this->nVersion;
READWRITE(id);
READWRITE(nDate);
READWRITE(recipient);
if (ser_action.ForRead())
date = QDateTime::fromTime_t(nDate);
}
};
class RecentRequestEntryLessThan
{
public:
RecentRequestEntryLessThan(int nColumn, Qt::SortOrder fOrder) : column(nColumn), order(fOrder) {}
bool operator()(RecentRequestEntry& left, RecentRequestEntry& right) const;
private:
int column;
Qt::SortOrder order;
};
/** Model for list of recently generated payment requests / hodlcash: URIs.
* Part of wallet model.
*/
class RecentRequestsTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit RecentRequestsTableModel(CWallet* wallet, WalletModel* parent);
~RecentRequestsTableModel();
enum ColumnIndex {
Date = 0,
Label = 1,
Address = 2,
Message = 3,
Amount = 4,
NUMBER_OF_COLUMNS
};
/** @name Methods overridden from QAbstractTableModel
@{*/
int rowCount(const QModelIndex& parent) const;
int columnCount(const QModelIndex& parent) const;
QVariant data(const QModelIndex& index, int role) const;
bool setData(const QModelIndex& index, const QVariant& value, int role);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex& parent) const;
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
Qt::ItemFlags flags(const QModelIndex& index) const;
/*@}*/
const RecentRequestEntry& entry(int row) const { return list[row]; }
void addNewRequest(const SendCoinsRecipient& recipient);
void addNewRequest(const std::string& recipient);
void addNewRequest(RecentRequestEntry& recipient);
public slots:
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
void updateDisplayUnit();
private:
WalletModel* walletModel;
QStringList columns;
QList<RecentRequestEntry> list;
int64_t nReceiveRequestsMaxId;
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
void updateAmountColumnTitle();
/** Gets title for amount column including current display unit if optionsModel reference available. */
QString getAmountTitle();
};
#endif // BITCOIN_QT_RECENTREQUESTSTABLEMODEL_H
|
[
"devilking6105@gmail.com"
] |
devilking6105@gmail.com
|
84726a94dc2489e9019b1053e3a9bc21c79591d1
|
3377792eb7eef610aa8f91c8cd69c182f61ed0ce
|
/src/main_sph_high_1.0e+05.cc
|
fe26564c30becae2f3ad5283186a3ec0e59e1020
|
[] |
no_license
|
mepa/p2-migration
|
7c9241205bbe60dcac994dd40c68034043b0e20a
|
030a2c366b395120acc730ee2f1867f0d52616c2
|
refs/heads/master
| 2021-01-10T06:29:29.369862
| 2016-01-13T18:57:58
| 2016-01-13T18:57:58
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 21,963
|
cc
|
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <fstream>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include "function.hh"
#include <gsl/gsl_errno.h>
#include <gsl/gsl_odeiv.h>
#include <gsl/gsl_sf.h>
using namespace std;
inline double sq(double x) { return x * x; }
inline double cub(double x) { return x * x * x; }
const double pc = 3.0e18;
const double kpc = 1.0e3 * pc;
const double M_sun = 2.0e33;
const double G = 6.67e-8;
const double yr = 3.14e7;
const double two_pi = 2.0 * M_PI;
const double four_pi = 4.0 * M_PI;
const double R_e = 500.0 * pc;
const double n = 1.5;
const double mass = 1.0e+09 * M_sun;
const double r_min = 1.0 * pc;
const double r_max = 50.0 * kpc;
const double mass_halo = 1.0e+10 * M_sun;
const double concentration = 3.5;
const double r_vir = 10.0 * kpc;
const double M_min = 100.0 * M_sun;
const double M_max = 1.0e+05 * M_sun;
size_t N = 1000;
size_t num_pts = 100;
size_t step = N / num_pts;
struct NFW
{
double mass, r_vir, c, r_s, rho_s;
NFW(double _mass, double _r_vir, double _c) :
mass(_mass), r_vir(_r_vir), c(_c), r_s(r_vir / c),
rho_s(mass * cub(c) * (1.0 + c) / (4.0 * M_PI * cub(r_vir) * ((1.0 + c) * log(1.0 + c) - c))) { }
double rho(double r) const { return rho_s / ((r / r_s) * sq(1.0 + r / r_s)); }
double M(double r) const
{
return four_pi * rho_s * cub(r_s) * (- log(r_s) * r - log(r_s) * r_s - r + log(r + r_s) * r_s + log(r + r_s) * r) / (r + r_s);
}
};
struct Model
{
Model(double _R_e, double _n, double _mass) :
R_e(_R_e), n(_n), inverse_n(1.0 / n), mass(_mass) // Take p(1.5) ~ 2/3
{
p = 2.0 / 3.0; // for n = 1.5: p = 1.0 - 0.6097 * inverse_n + 0.05463 * sq(inverse_n) ~ 0.617813;
half_p = 1.0 / 3.0;
a = (3.0 - p) * n;
gamma_fcn = gsl_sf_gamma(a);
normalization = mass / ( four_pi * cub(R_e) * n * gamma_fcn );
if (a <= 0)
{
cout << "gamma function undefined" << endl;
abort();
}
}
double R_e; // R_e actually means R_0 here
double n;
double inverse_n;
double mass;
double normalization;
double p;
double half_p;
double a;
double gamma_fcn;
double rho(double r) const
{
double x = r / R_e;
return normalization * pow(x, -p) * exp(- pow(x, inverse_n) );
}
double M(double r) const
{
double x = r / R_e;
//const double gamma_inc_lower = gamma_fcn - gsl_sf_gamma_inc(a, pow(x, inverse_n));
const double approx_gamma_inc_lower
= (-20 * x - 8 * x * pow(x, p) - 30 * pow(x, half_p)) / (8.0 * exp(pow(x, p)))
+ 15 * sqrt(M_PI) * erf(pow(x, half_p)) / 8.0;
return four_pi * normalization * cub(R_e) * n * approx_gamma_inc_lower;
}
};
vector<double> Project(const vector<double> & r, const vector<double> & rho)
{
vector<double> Sigma(r.size(), 0.0);
for(size_t i = 0; i < r.size(); i ++)
{
Sigma[i] += 2.0 * sqrt(r[i + 1] * r[i + 1] - r[i] * r[i]) * 0.5 * (rho[i + 1] + rho[i]);
for(size_t j = i + 1; j < r.size() - 1; j ++)
{
const double r1 = r[j];
const double r2 = r[j + 1];
const double int_1 = rho[j] * 2.0 * r1 / sqrt(r1 * r1 - r[i] * r[i]);
const double int_2 = rho[j + 1] * 2.0 * r2 / sqrt(r2 * r2 - r[i] * r[i]);
Sigma[i] += 0.5 * (r2 - r1) * (int_1 + int_2);
}
}
return Sigma;
}
struct Profile
{
Model model;
NFW nfw;
vector<double> r, Sigma_baryon, rho_baryon, mass_baryon, Sigma_NFW, rho_NFW, rho_total, mass_total;
double mass_nucleus;
vector<double> evolving_mass_profile;
Profile(const Model & _model, const NFW & _nfw,
double r_min, double r_max, size_t c) :
model(_model), nfw(_nfw), r(c), Sigma_baryon(c), rho_baryon(c), mass_baryon(c), Sigma_NFW(c), rho_NFW(c), rho_total(c), mass_total(c),
mass_nucleus(0.0), evolving_mass_profile(c, 0.0)
{
for(size_t i = 0; i < c; i ++)
{
r[i] = r_min * exp(double(i) * log(r_max / r_min) / double(c - 1));
rho_baryon[i] = model.rho(r[i]);
rho_NFW[i] = nfw.rho(r[i]);
rho_total[i] = rho_baryon[i] + rho_NFW[i];
}
Sigma_baryon = Project(r, rho_baryon);
Sigma_NFW = Project(r, rho_NFW);
const double r0 = r.front();
const double central_mass_baryon = model.M(r0);
const double central_mass_nfw = nfw.M(r0);
cout << "# central_mass_baryon, central_mass_nfw: " << central_mass_baryon / M_sun << " "
<< central_mass_nfw / M_sun << endl;
for(size_t i = 0; i < c; i ++)
{
mass_baryon[i] = model.M(r[i]);
mass_total[i] = mass_baryon[i] + nfw.M(r[i]);
}
}
size_t size() const { return r.size(); }
double randomRadius() const
{
const double partial_mass = drand48() * (mass_baryon.back() - mass_baryon.front()) + mass_baryon.front();
double r_min = r.front();
double r_max = r.back();
const double tiny_delta_r = 1.0e-6 * r_min;
while(r_max - r_min > tiny_delta_r)
{
const double r_middle = 0.5 * (r_min + r_max);
if(partial_mass < model.M(r_middle)) r_max = r_middle;
else r_min = r_middle;
}
return 0.5 * (r_min + r_max);
}
double getMassBaryon() const { return mass_baryon.back(); }
double getMassTotal() const { return mass_total.back(); }
};
const Model model(R_e, n, mass);
const NFW nfw(mass_halo, r_vir, concentration);
const Profile profile(model, nfw, r_min, r_max, N);
ostream & operator<< (ostream & out, const Profile & profile)
{
for(size_t i = 0; i < profile.size(); i ++)
{
out << profile.r[i] << " " << profile.Sigma_baryon[i] << " " << profile.Sigma_NFW[i] << " " << profile.rho_baryon[i] << " " << profile.rho_NFW[i] << " " << profile.mass_baryon[i] << " " << profile.mass_total[i] << endl;
}
return out;
}
double timeMigration(double cluster_mass, double r, const Profile & profile)
{
const double R = max<double> (r, profile.r.front());
const double ln_Lambda = 5.0;
const size_t i = size_t(floor(double(profile.r.size()) * log(R / profile.r.front()) / log(profile.r.back() / profile.r.front())));
const double evolving_mass = profile.evolving_mass_profile[i] +
(profile.evolving_mass_profile[i + 1] - profile.evolving_mass_profile[i]) * (R - profile.r[i]) / (profile.r[i + 1] - profile.r[i]);
const double evolving_density = ((profile.evolving_mass_profile[i + 1] - profile.evolving_mass_profile[i])
/ (profile.r[i + 1] - profile.r[i])) / (four_pi * sq(R));
const double mass = profile.nfw.M(r) + profile.mass_nucleus + max<double> (profile.model.M(r), evolving_mass);
const double rho = profile.nfw.rho(r) + max<double> (profile.model.rho(R), evolving_density);
return 0.5 * sqrt(mass) * pow(R, 1.5) / (cluster_mass * ln_Lambda * sqrt(G)) + 0.125 * pow(mass, 1.5) / (cluster_mass * ln_Lambda * pow(r, 1.5) * sqrt(G) * M_PI * rho);
}
double timeDisruption(double cluster_mass, double r, const Profile & profile)
{
const double radius_factor = 1.0; // circular orbit?
const double f_dis = 0.2;
const double gamma = 0.62;
const double radius_pericenter = max<double> (radius_factor * r, profile.r.front());
if(radius_pericenter < profile.r.front() || radius_pericenter >= profile.r.back())
{
cout << "out of range: " << radius_pericenter << endl;
abort();
}
const size_t i = size_t(floor(double(profile.r.size()) * log(radius_pericenter / profile.r.front()) / log(profile.r.back() / profile.r.front())));
const double evolving_mass = profile.evolving_mass_profile[i] +
(profile.evolving_mass_profile[i + 1] - profile.evolving_mass_profile[i]) * (radius_pericenter - profile.r[i]) / (profile.r[i + 1] - profile.r[i]);
const double evolving_density = ((profile.evolving_mass_profile[i + 1] - profile.evolving_mass_profile[i])
/ (profile.r[i + 1] - profile.r[i])) / (four_pi * sq(radius_pericenter));
const double mass = max<double> (evolving_mass, profile.model.M(radius_pericenter)) + profile.nfw.M(radius_pericenter) + profile.mass_nucleus;
const double rho = max<double> (profile.model.rho(radius_pericenter), evolving_density) + profile.nfw.rho(radius_pericenter);
const double Omega = sqrt(G * mass / cub(radius_pericenter));
// // OLD
// const double t_0 = f_dis / Omega;
// const double t_4 = 1.355 * yr * pow(10.0, 4.0 * gamma) * (1.0 / gamma) * pow(t_0 / yr, 0.967);
// const double t_dis = t_4 * pow(cluster_mass / (1.0e4 * M_sun), gamma);
// NEW
const double dOmega = - 1.5 * Omega / r + 0.5 * Omega * four_pi * sq(r) * rho / mass;
const double t_0 = f_dis / abs(r * dOmega);
const double t_dis = t_0 * pow(cluster_mass / M_sun, gamma);
return t_dis;
}
int func (double t, const double y[], double f[],
void *params)
{
const pair<double, Profile const *> & data =
* static_cast<pair<double, Profile const *> *> (params);
const double r = y[0];
const double mass = y[1];
if (isnan(r) || r < 0.0)
{
return GSL_FAILURE;
}
const double t_mig = timeMigration(mass, r, * data.second);
const double t_dis = timeDisruption(mass, r, * data.second);
f[0] = - y[0] / t_mig;
f[1] = - y[1] / t_dis;
return GSL_SUCCESS;
}
struct Element
{
double mass, r, dM_dr;
Element(double _mass, double _r, double _dM_dr) : mass(_mass), r(_r), dM_dr(_dM_dr) { }
};
struct DepositedMass : public vector<Element>
{
double disrupt_radius, disrupt_mass, center_mass, time;
DepositedMass() : vector<Element> (), disrupt_radius(0.0), disrupt_mass(0.0), center_mass(0.0), time(0.0) { }
};
void decayOrbit(double cluster_mass_init, double r_init, const Profile & profile, DepositedMass & dM_dr)
{
dM_dr.clear();
const gsl_odeiv_step_type * T = gsl_odeiv_step_rk4;
gsl_odeiv_step * s = gsl_odeiv_step_alloc (T, 2);
const pair<double, Profile const *> data(cluster_mass_init, &profile);
gsl_odeiv_system sys = {func, 0, 2, const_cast<pair<double, const Profile *> *> (&data)};
double t = 0.0;
double h = yr;
double y[2] = { r_init, cluster_mass_init }, y_err[1];
double dydt_in[2], dydt_out[2];
GSL_ODEIV_FN_EVAL(&sys, t, y, dydt_in);
dM_dr.push_back(Element(cluster_mass_init, r_init, dydt_in[1] / dydt_in[0]));
while (true)
{
const double y_save[2] = { y[0], y[1] };
int status;
do
{
status = gsl_odeiv_step_apply (s, t, h,
y, y_err,
dydt_in,
dydt_out,
&sys);
if (status != GSL_SUCCESS)
{
h *= 0.5;
y[0] = y_save[0];
y[1] = y_save[1];
}
}
while (status != GSL_SUCCESS);
dydt_in[0] = dydt_out[0];
dydt_in[1] = dydt_out[1];
t += h;
const double epsilon_step = 0.01;
h = min<double> (- epsilon_step * y[0] / dydt_in[0], - epsilon_step * y[1] / dydt_in[1]);
const double r = y[0];
const double cluster_mass = y[1];
dM_dr.push_back(Element(cluster_mass, r, dydt_out[1] / dydt_out[0]));
if(r < profile.r.front())
{
dM_dr.disrupt_radius = r;
dM_dr.center_mass = cluster_mass;
dM_dr.time = t;
break;
}
if(cluster_mass < 100.0 * M_sun)
{
dM_dr.disrupt_radius = r;
dM_dr.disrupt_mass = cluster_mass;
dM_dr.time = t;
break;
}
}
gsl_odeiv_step_free (s);
}
struct Cluster
{
double mass, r;
Cluster(double _mass, double _r) : mass(_mass), r(_r) { }
};
ostream & operator<< (ostream & out, const Cluster & cluster)
{
out << cluster.mass << " " << cluster.r;
return out;
}
struct Clusters : public vector<Cluster>
{
Clusters(double M_min, double M_max, double slope, const Profile & profile)
{
double sum_mass = 0.0;
while(sum_mass < profile.getMassBaryon())
{
const Cluster cluster(genMass(M_min, M_max, slope), profile.randomRadius());
sum_mass += cluster.mass;
push_back(cluster);
}
const double factor = profile.getMassBaryon() / sum_mass;
for(vector<Cluster>::iterator i = begin(); i != end(); i ++)
{
i->mass *= factor;
}
}
double genMass(double M_min, double M_max, double slope)
{
const double x = drand48();
if(slope != 2.0) return pow(pow(M_min, 2.0 - slope)
- pow(M_min, 2.0 - slope) * x
+ pow(M_max, 2.0 - slope) * x, 1.0 / (2.0 - slope));
else return M_min * exp(x * log(M_max / M_min));
}
double mass() const
{
double sum = 0.0;
for(vector<Cluster>::const_iterator i = begin(); i != end(); i ++) sum += i->mass;
return sum;
}
};
bool operator< (const Cluster & cluster_1, const Cluster & cluster_2)
{
return timeMigration(cluster_1.mass, cluster_1.r, profile) < timeMigration(cluster_2.mass, cluster_2.r, profile);
}
struct Center
{
vector<double> mass, mass_excess, mass_excess_actual, time, time_actual;
};
int main()
{
cout << "# R_e, n, mass, r_min, r_max, mass_halo, concentration, r_vir, M_min, M_max, N, num_pts: "
<< R_e / pc << ", "
<< n << ", "
<< mass / M_sun << ", "
<< r_min / pc << ", "
<< r_max / pc << ", "
<< mass_halo / M_sun << ", "
<< concentration << ", "
<< r_vir / pc << " "
<< M_min / M_sun << ", "
<< M_max / M_sun << ", "
<< N << ", " << num_pts << endl;
// ofstream profile_out("profile.dat");
// profile_out << profile;
// const double M_cl_min = 1.0e1 * M_sun;
// const double M_cl_max = 1.0e4 * M_sun;
// vector<double> M_cl(100);
// for (size_t i = 0; i < M_cl.size(); i ++)
// {
// M_cl[i] = M_cl_min * exp(double(i) * log(M_cl_max / M_cl_min) / double(100 - 1));
// double time_dissociation = timeDisruption(M_cl[i], 5.0 * pc, profile);
// cout << M_cl[i] / M_sun << " " << time_dissociation / yr << endl;
// }
// abort();
//cout << time_dissociation / yr << endl;
Clusters clusters(M_min, M_max, 2.0, profile);
sort(clusters.begin(), clusters.end());
vector<double> time_mig(clusters.size(), 0.0);
for(size_t i = 0; i < clusters.size(); i ++)
{
time_mig[i] = timeMigration(clusters[i].mass, clusters[i].r, profile);
}
cout << "# generated " << clusters.size() << " clusters" << " "
<< "with total mass " << clusters.mass() / M_sun << endl;
// ofstream cluster_out("cluster.out");
// copy(clusters.begin(), clusters.end(), ostream_iterator<Cluster> (cluster_out, "\n"));
vector<double> initial_mass(profile.r.size(), 0.0), final_mass(profile.r.size(), 0.0), final_mass_disrupt(profile.r.size(), 0.0);
vector<double> mass_center(clusters.size(), 0.0), mass_center_excess(clusters.size(), 0.0), mass_center_excess_actual(clusters.size(), 0.0);
double mass_disrupted = 0.0, mass_deposited = 0.0, mass_nucleus = 0.0;
double time_total = 0.0;
const double radius_center = 10.0 * pc;
double time_center_total = 0.0;
Center center;
ofstream center_yes_out("data/script/center_yes_sph_1.0e+05_high_z.out");
ofstream center_no_out("data/script/center_no_sph_1.0e+05_high_z.out");
for(size_t i = 0; i < clusters.size(); i ++)
{
const double r_cluster = clusters[i].r;
for(size_t j = 0; j < profile.r.size(); j ++)
if (profile.r[j] > r_cluster)
{
initial_mass[j] += clusters[i].mass;
}
DepositedMass dM_dr;
decayOrbit(clusters[i].mass, clusters[i].r, profile, dM_dr);
if (dM_dr.disrupt_radius < profile.r.front()) center_yes_out << clusters[i].mass << " " << clusters[i].r << " " << dM_dr.center_mass << " " << dM_dr.disrupt_radius << " " << dM_dr.time << endl;
else center_no_out << clusters[i].mass << " " << clusters[i].r << " " << dM_dr.disrupt_mass << " " << dM_dr.disrupt_radius << " " << dM_dr.time << endl;
reverse(dM_dr.begin(), dM_dr.end());
for(size_t j = 1; j < dM_dr.size(); j ++)
{
const double r = 0.5 * (dM_dr[j - 1].r + dM_dr[j].r);
const double delta_mass = (dM_dr[j].r - dM_dr[j - 1].r) * 0.5 * (dM_dr[j].dM_dr + dM_dr[j - 1].dM_dr);
for(size_t k = 0; k < profile.r.size(); k ++)
if (profile.r[k] > r)
{
final_mass[k] += delta_mass;
}
mass_deposited += delta_mass;
}
for(size_t j = 0; j < profile.r.size(); j ++)
if (profile.r[j] > dM_dr.disrupt_radius)
{
final_mass_disrupt[j] += dM_dr.disrupt_mass; //doesn't include mass if radii equal
}
mass_nucleus += dM_dr.center_mass;
mass_disrupted += dM_dr.disrupt_mass;
const_cast<Profile &> (profile).mass_nucleus = mass_nucleus;
transform(final_mass.begin(), final_mass.end(), final_mass_disrupt.begin(), const_cast<Profile &> (profile).evolving_mass_profile.begin(), plus<double> ());
if (dM_dr.disrupt_radius < radius_center)
{
for(size_t j = 0; j < profile.r.size(); j ++)
if (profile.r[j] < radius_center)
{
mass_center[i] = profile.mass_nucleus + profile.evolving_mass_profile[j];
mass_center_excess[i] = mass_center[i] - profile.model.M(profile.r[j]);
mass_center_excess_actual[i] = mass_center[i] - initial_mass[j];
}
if (dM_dr.time > time_center_total) time_center_total = dM_dr.time;
center.mass.push_back(mass_center[i]);
center.mass_excess.push_back(mass_center_excess[i]);
center.mass_excess_actual.push_back(mass_center_excess_actual[i]);
center.time.push_back(time_mig[i]);
center.time_actual.push_back(dM_dr.time);
}
if (dM_dr.time > time_total) time_total = dM_dr.time;
}
// ofstream center_out("center.out");
// for (size_t i = 0; i < center.mass.size(); i ++)
// center_out << center.time[i] << " "
// << center.time_actual[i] << " "
// << center.mass[i] << " "
// << center.mass_excess[i] << " "
// << center.mass_excess_actual[i] << endl;
cout << "# mass_nucleus " << mass_nucleus / M_sun << " " << mass_nucleus / clusters.mass() << endl;
cout << "# mass_disrupted " << mass_disrupted / M_sun << " " << mass_disrupted / clusters.mass() << endl;
cout << "# mass_deposited " << mass_deposited / M_sun << " " << mass_deposited / clusters.mass() << endl;
cout << "# before after difference relative "
<< clusters.mass() / M_sun << " "
<< (mass_nucleus + mass_disrupted + mass_deposited) / M_sun << " "
<< fabs(mass_nucleus + mass_disrupted + mass_deposited - clusters.mass()) / M_sun << " "
<< fabs(mass_nucleus + mass_disrupted + mass_deposited - clusters.mass()) / clusters.mass() << " "
<< endl;
vector<double> final_mass_total(profile.r.size(), 0.0);
for(size_t i = 0; i < profile.r.size(); i ++)
{
final_mass_total[i] = mass_nucleus + final_mass_disrupt[i] + final_mass[i];
}
vector<double> initial_rho(profile.r.size()), final_rho(profile.r.size()), final_rho_disrupt(profile.r.size());
for(size_t i = 1; i < final_mass_total.size() - 1; i += 1)
{
initial_rho[i] = ((initial_mass[i + 1] - initial_mass[i - 1]) / (profile.r[i + 1] - profile.r[i - 1])) / (four_pi * sq(0.5 * (profile.r[i + 1] + profile.r[i - 1])));
final_rho[i] = ((final_mass_total[i + 1] - final_mass_total[i - 1]) / (profile.r[i + 1] - profile.r[i - 1])) / (four_pi * sq(0.5 * (profile.r[i + 1] + profile.r[i - 1])));
final_rho_disrupt[i] = ((final_mass_disrupt[i + 1] - final_mass_disrupt[i - 1]) / (profile.r[i + 1] - profile.r[i - 1])) / (four_pi * sq(0.5 * (profile.r[i + 1] + profile.r[i - 1])));
}
initial_rho[0] = initial_rho[1];
initial_rho[profile.r.size() - 1] = initial_rho[profile.r.size() - (2 * 1)];
final_rho[0] = final_rho[1];
final_rho[profile.r.size() - 1] = final_rho[profile.r.size() - (2 * 1)];
final_rho_disrupt[0] = final_rho_disrupt[1];
final_rho_disrupt[profile.r.size() - 1] = final_rho_disrupt[profile.r.size() - (2 * 1)];
const vector<double> initial_Sigma = Project(profile.r, initial_rho);
const vector<double> final_Sigma = Project(profile.r, final_rho);
const vector<double> final_Sigma_disrupt = Project(profile.r, final_rho_disrupt);
vector<double> final_Sigma_nuc(final_mass_total.size(), 0.0);
const double r_nucleus = 2.0 * pc;
for(size_t i = 0; i < final_mass_total.size(); i ++)
{
final_Sigma_nuc[i] += 0.5 * mass_nucleus * r_nucleus / (M_PI * pow(sq(r_nucleus) + sq(profile.r[i]), 1.5));
}
vector<double> final_Sigma_total(final_mass_total.size(), 0.0);
for(size_t i = 0; i < final_mass_total.size(); i ++)
{
final_Sigma_total[i] = final_Sigma[i] + final_Sigma_nuc[i];
}
double actual_time = 0.0;
for(size_t i = 0; i < center.time_actual.size(); i ++)
if (center.time_actual[i] > actual_time) actual_time = center.time_actual[i];
cout << "# (in central " << radius_center / pc << " pc) mass, mass_excess, time, time_actual: " << center.mass.back() / M_sun << " " << center.mass_excess.back() / M_sun << " " << center.time.back() / yr << " " << actual_time / yr << endl;
double radius_upturn = 0.0;
double mass_upturn = 0.0;
double mass_upturn_excess = 0.0;
double mass_upturn_excess_actual = 0.0;
size_t index = 0;
while(final_Sigma_total[index] - profile.Sigma_baryon[index] > 0.0)
{
radius_upturn = profile.r[index];
mass_upturn = final_mass_total[index];
mass_upturn_excess = final_mass_total[index] - profile.model.M(profile.r[index]);
mass_upturn_excess_actual = final_mass_total[index] - initial_mass[index];
index ++;
}
cout << "# (at upturn) radius, mass, mass_excess, mass_excess_actual: " << radius_upturn / pc << " "
<< mass_upturn / M_sun << " " << mass_upturn_excess / M_sun << " " << mass_upturn_excess_actual / M_sun << endl;
cout << "# time_total, time_center_total: " << time_total / yr << " " << time_center_total / yr << endl;
for(size_t i = 0; i < final_mass_total.size(); i += step)
{
cout << profile.r[i] << " "
<< profile.Sigma_NFW[i] << " "
<< profile.Sigma_baryon[i] << " "
<< initial_Sigma[i] << " "
<< final_Sigma_total[i] << " "
<< final_Sigma_nuc[i] << " "
<< final_Sigma_disrupt[i] << " "
<< final_Sigma[i] << endl;
}
return 0;
}
|
[
"meg@meghannpalmer.com"
] |
meg@meghannpalmer.com
|
5fa8a332481c28d36d4ac4ebb503f16e2d4d7e9a
|
d732c881b57ef5e3c8f8d105b2f2e09b86bcc3fe
|
/src/module-wx/VType_wxGraphicsRenderer.cpp
|
59af80f65822a25751c30ceb76ba6ad74222bd86
|
[] |
no_license
|
gura-lang/gurax
|
9180861394848fd0be1f8e60322b65a92c4c604d
|
d9fedbc6e10f38af62c53c1bb8a4734118d14ce4
|
refs/heads/master
| 2023-09-01T09:15:36.548730
| 2023-09-01T08:49:33
| 2023-09-01T08:49:33
| 160,017,455
| 10
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 21,272
|
cpp
|
//==============================================================================
// VType_wxGraphicsRenderer.cpp
// Don't edit this file since it's been generated by Generate.gura.
//==============================================================================
#include "stdafx.h"
Gurax_BeginModuleScope(wx)
//------------------------------------------------------------------------------
// Help
//------------------------------------------------------------------------------
static const char* g_docHelp_en = u8R"""(
# Overview
# Predefined Variable
${help.ComposePropertyHelp(wx.GraphicsRenderer, `en)}
# Operator
# Cast Operation
${help.ComposeConstructorHelp(wx.GraphicsRenderer, `en)}
${help.ComposeMethodHelp(wx.GraphicsRenderer, `en)}
)""";
static const char* g_docHelp_ja = u8R"""(
# 概要
# 定数
${help.ComposePropertyHelp(wx.GraphicsRenderer, `ja)}
# オペレータ
# キャスト
${help.ComposeConstructorHelp(wx.GraphicsRenderer, `ja)}
${help.ComposeMethodHelp(wx.GraphicsRenderer, `ja)}
)""";
//------------------------------------------------------------------------------
// Implementation of constructor
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Implementation of method
//-----------------------------------------------------------------------------
// wx.GraphicsRenderer#CreateBitmapFromImage(image as wx.Image) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateBitmapFromImage_gurax, "CreateBitmapFromImage")
{
Declare(VTYPE_wxGraphicsBitmap, Flag::None);
DeclareArg("image", VTYPE_wxImage, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateBitmapFromImage_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
Value_wxImage& value_image = args_gurax.Pick<Value_wxImage>();
const wxImage& image = value_image.GetEntity();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsBitmap(
pEntity_gurax->CreateBitmapFromImage(image)));
}
// wx.GraphicsRenderer#CreateImageFromBitmap(bmp as wx.GraphicsBitmap) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateImageFromBitmap_gurax, "CreateImageFromBitmap")
{
Declare(VTYPE_wxImage, Flag::None);
DeclareArg("bmp", VTYPE_wxGraphicsBitmap, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateImageFromBitmap_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
Value_wxGraphicsBitmap& value_bmp = args_gurax.Pick<Value_wxGraphicsBitmap>();
const wxGraphicsBitmap& bmp = value_bmp.GetEntity();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxImage(
pEntity_gurax->CreateImageFromBitmap(bmp)));
}
// wx.GraphicsRenderer#CreateBitmapFromNativeBitmap(bitmap as Pointer) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateBitmapFromNativeBitmap_gurax, "CreateBitmapFromNativeBitmap")
{
Declare(VTYPE_wxGraphicsBitmap, Flag::None);
DeclareArg("bitmap", VTYPE_Pointer, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateBitmapFromNativeBitmap_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
void* bitmap = args_gurax.Pick<Gurax::Value_Pointer>().GetPointer().GetWritablePointerC<void>();
if (!bitmap) {
Error::Issue(ErrorType::MemoryError, "the pointer is not writable");
return Value::nil();
}
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsBitmap(
pEntity_gurax->CreateBitmapFromNativeBitmap(bitmap)));
}
// wx.GraphicsRenderer#CreateContext(window as wx.Window) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateContext_gurax, "CreateContext")
{
Declare(VTYPE_wxGraphicsContext, Flag::None);
DeclareArg("window", VTYPE_wxWindow, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateContext_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
Value_wxWindow& value_window = args_gurax.Pick<Value_wxWindow>();
wxWindow* window = value_window.GetEntityPtr();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsContext(
*pEntity_gurax->CreateContext(window)));
}
// wx.GraphicsRenderer#CreateContextFromImage(image as wx.Image) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateContextFromImage_gurax, "CreateContextFromImage")
{
Declare(VTYPE_wxGraphicsContext, Flag::None);
DeclareArg("image", VTYPE_wxImage, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateContextFromImage_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
Value_wxImage& value_image = args_gurax.Pick<Value_wxImage>();
wxImage& image = value_image.GetEntity();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsContext(
*pEntity_gurax->CreateContextFromImage(image)));
}
// wx.GraphicsRenderer#CreateBrush(brush as wx.Brush) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateBrush_gurax, "CreateBrush")
{
Declare(VTYPE_wxGraphicsBrush, Flag::None);
DeclareArg("brush", VTYPE_wxBrush, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateBrush_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
Value_wxBrush& value_brush = args_gurax.Pick<Value_wxBrush>();
const wxBrush& brush = value_brush.GetEntity();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsBrush(
pEntity_gurax->CreateBrush(brush)));
}
// wx.GraphicsRenderer#CreateContextFromNativeContext(context as Pointer) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateContextFromNativeContext_gurax, "CreateContextFromNativeContext")
{
Declare(VTYPE_wxGraphicsContext, Flag::None);
DeclareArg("context", VTYPE_Pointer, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateContextFromNativeContext_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
void* context = args_gurax.Pick<Gurax::Value_Pointer>().GetPointer().GetWritablePointerC<void>();
if (!context) {
Error::Issue(ErrorType::MemoryError, "the pointer is not writable");
return Value::nil();
}
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsContext(
*pEntity_gurax->CreateContextFromNativeContext(context)));
}
// wx.GraphicsRenderer#CreateContextFromNativeWindow(window as Pointer) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateContextFromNativeWindow_gurax, "CreateContextFromNativeWindow")
{
Declare(VTYPE_wxGraphicsContext, Flag::None);
DeclareArg("window", VTYPE_Pointer, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateContextFromNativeWindow_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
void* window = args_gurax.Pick<Gurax::Value_Pointer>().GetPointer().GetWritablePointerC<void>();
if (!window) {
Error::Issue(ErrorType::MemoryError, "the pointer is not writable");
return Value::nil();
}
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsContext(
*pEntity_gurax->CreateContextFromNativeWindow(window)));
}
// wx.GraphicsRenderer#CreateMeasuringContext() {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateMeasuringContext_gurax, "CreateMeasuringContext")
{
Declare(VTYPE_wxGraphicsContext, Flag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateMeasuringContext_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsContext(
*pEntity_gurax->CreateMeasuringContext()));
}
// wx.GraphicsRenderer#CreateFont(font as wx.Font, col? as wx.Colour) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateFont_gurax, "CreateFont")
{
Declare(VTYPE_wxGraphicsFont, Flag::None);
DeclareArg("font", VTYPE_wxFont, ArgOccur::Once, ArgFlag::None);
DeclareArg("col", VTYPE_wxColour, ArgOccur::ZeroOrOnce, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateFont_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
Value_wxFont& value_font = args_gurax.Pick<Value_wxFont>();
const wxFont& font = value_font.GetEntity();
const wxColour& col = args_gurax.IsValid()? args_gurax.Pick<Value_wxColour>().GetEntity() : *wxBLACK;
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsFont(
pEntity_gurax->CreateFont(font, col)));
}
// wx.GraphicsRenderer#CreateLinearGradientBrush(x1 as Number, y1 as Number, x2 as Number, y2 as Number, stops as wx.GraphicsGradientStops) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateLinearGradientBrush_gurax, "CreateLinearGradientBrush")
{
Declare(VTYPE_wxGraphicsBrush, Flag::None);
DeclareArg("x1", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("y1", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("x2", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("y2", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("stops", VTYPE_wxGraphicsGradientStops, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateLinearGradientBrush_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
Double x1 = args_gurax.PickNumber<Double>();
Double y1 = args_gurax.PickNumber<Double>();
Double x2 = args_gurax.PickNumber<Double>();
Double y2 = args_gurax.PickNumber<Double>();
Value_wxGraphicsGradientStops& value_stops = args_gurax.Pick<Value_wxGraphicsGradientStops>();
const wxGraphicsGradientStops& stops = value_stops.GetEntity();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsBrush(
pEntity_gurax->CreateLinearGradientBrush(x1, y1, x2, y2, stops)));
}
// wx.GraphicsRenderer#CreateMatrix(a? as Number, b? as Number, c? as Number, d? as Number, tx? as Number, ty? as Number) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateMatrix_gurax, "CreateMatrix")
{
Declare(VTYPE_wxGraphicsMatrix, Flag::None);
DeclareArg("a", VTYPE_Number, ArgOccur::ZeroOrOnce, ArgFlag::None);
DeclareArg("b", VTYPE_Number, ArgOccur::ZeroOrOnce, ArgFlag::None);
DeclareArg("c", VTYPE_Number, ArgOccur::ZeroOrOnce, ArgFlag::None);
DeclareArg("d", VTYPE_Number, ArgOccur::ZeroOrOnce, ArgFlag::None);
DeclareArg("tx", VTYPE_Number, ArgOccur::ZeroOrOnce, ArgFlag::None);
DeclareArg("ty", VTYPE_Number, ArgOccur::ZeroOrOnce, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateMatrix_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
bool a_validFlag = args_gurax.IsValid();
Double a = a_validFlag? args_gurax.PickNumber<Double>() : 1.0;
bool b_validFlag = args_gurax.IsValid();
Double b = b_validFlag? args_gurax.PickNumber<Double>() : 0.0;
bool c_validFlag = args_gurax.IsValid();
Double c = c_validFlag? args_gurax.PickNumber<Double>() : 0.0;
bool d_validFlag = args_gurax.IsValid();
Double d = d_validFlag? args_gurax.PickNumber<Double>() : 1.0;
bool tx_validFlag = args_gurax.IsValid();
Double tx = tx_validFlag? args_gurax.PickNumber<Double>() : 0.0;
bool ty_validFlag = args_gurax.IsValid();
Double ty = ty_validFlag? args_gurax.PickNumber<Double>() : 0.0;
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsMatrix(
pEntity_gurax->CreateMatrix(a, b, c, d, tx, ty)));
}
// wx.GraphicsRenderer#CreatePath() {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreatePath_gurax, "CreatePath")
{
Declare(VTYPE_wxGraphicsPath, Flag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreatePath_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsPath(
pEntity_gurax->CreatePath()));
}
// wx.GraphicsRenderer#CreateRadialGradientBrush(xo as Number, yo as Number, xc as Number, yc as Number, radius as Number, stops as wx.GraphicsGradientStops) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateRadialGradientBrush_gurax, "CreateRadialGradientBrush")
{
Declare(VTYPE_wxGraphicsBrush, Flag::None);
DeclareArg("xo", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("yo", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("xc", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("yc", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("radius", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("stops", VTYPE_wxGraphicsGradientStops, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateRadialGradientBrush_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
Double xo = args_gurax.PickNumber<Double>();
Double yo = args_gurax.PickNumber<Double>();
Double xc = args_gurax.PickNumber<Double>();
Double yc = args_gurax.PickNumber<Double>();
Double radius = args_gurax.PickNumber<Double>();
Value_wxGraphicsGradientStops& value_stops = args_gurax.Pick<Value_wxGraphicsGradientStops>();
const wxGraphicsGradientStops& stops = value_stops.GetEntity();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsBrush(
pEntity_gurax->CreateRadialGradientBrush(xo, yo, xc, yc, radius, stops)));
}
// wx.GraphicsRenderer#CreateSubBitmap(bitmap as wx.GraphicsBitmap, x as Number, y as Number, w as Number, h as Number) {block?}
Gurax_DeclareMethodAlias(wxGraphicsRenderer, CreateSubBitmap_gurax, "CreateSubBitmap")
{
Declare(VTYPE_wxGraphicsBitmap, Flag::None);
DeclareArg("bitmap", VTYPE_wxGraphicsBitmap, ArgOccur::Once, ArgFlag::None);
DeclareArg("x", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("y", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("w", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareArg("h", VTYPE_Number, ArgOccur::Once, ArgFlag::None);
DeclareBlock(BlkOccur::ZeroOrOnce);
}
Gurax_ImplementMethodEx(wxGraphicsRenderer, CreateSubBitmap_gurax, processor_gurax, argument_gurax)
{
// Target
auto& valueThis_gurax = GetValueThis(argument_gurax);
auto pEntity_gurax = valueThis_gurax.GetEntityPtr();
if (!pEntity_gurax) return Value::nil();
// Arguments
Gurax::ArgPicker args_gurax(argument_gurax);
Value_wxGraphicsBitmap& value_bitmap = args_gurax.Pick<Value_wxGraphicsBitmap>();
const wxGraphicsBitmap& bitmap = value_bitmap.GetEntity();
Double x = args_gurax.PickNumber<Double>();
Double y = args_gurax.PickNumber<Double>();
Double w = args_gurax.PickNumber<Double>();
Double h = args_gurax.PickNumber<Double>();
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsBitmap(
pEntity_gurax->CreateSubBitmap(bitmap, x, y, w, h)));
}
// wx.GraphicsRenderer.GetDefaultRenderer() {block?}
Gurax_DeclareClassMethodAlias(wxGraphicsRenderer, GetDefaultRenderer_gurax, "GetDefaultRenderer")
{
Declare(VTYPE_wxGraphicsRenderer, Flag::None);
}
Gurax_ImplementClassMethodEx(wxGraphicsRenderer, GetDefaultRenderer_gurax, processor_gurax, argument_gurax)
{
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsRenderer(
wxGraphicsRenderer::GetDefaultRenderer()));
}
// wx.GraphicsRenderer.GetCairoRenderer() {block?}
Gurax_DeclareClassMethodAlias(wxGraphicsRenderer, GetCairoRenderer_gurax, "GetCairoRenderer")
{
Declare(VTYPE_wxGraphicsRenderer, Flag::None);
}
Gurax_ImplementClassMethodEx(wxGraphicsRenderer, GetCairoRenderer_gurax, processor_gurax, argument_gurax)
{
// Function body
return argument_gurax.ReturnValue(processor_gurax, new Value_wxGraphicsRenderer(
wxGraphicsRenderer::GetCairoRenderer()));
}
//-----------------------------------------------------------------------------
// Implementation of property
//-----------------------------------------------------------------------------
//------------------------------------------------------------------------------
// VType_wxGraphicsRenderer
//------------------------------------------------------------------------------
VType_wxGraphicsRenderer VTYPE_wxGraphicsRenderer("GraphicsRenderer");
void VType_wxGraphicsRenderer::DoPrepare(Frame& frameOuter)
{
// Add help
AddHelp(Gurax_Symbol(en), g_docHelp_en);
AddHelp(Gurax_Symbol(ja), g_docHelp_ja);
// Declaration of VType
Declare(VTYPE_Object, Flag::Mutable);
// Assignment of method
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateBitmapFromImage_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateImageFromBitmap_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateBitmapFromNativeBitmap_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateContext_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateContextFromImage_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateBrush_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateContextFromNativeContext_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateContextFromNativeWindow_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateMeasuringContext_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateFont_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateLinearGradientBrush_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateMatrix_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreatePath_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateRadialGradientBrush_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, CreateSubBitmap_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, GetDefaultRenderer_gurax));
Assign(Gurax_CreateMethod(wxGraphicsRenderer, GetCairoRenderer_gurax));
}
//------------------------------------------------------------------------------
// Value_wxGraphicsRenderer
//------------------------------------------------------------------------------
VType& Value_wxGraphicsRenderer::vtype = VTYPE_wxGraphicsRenderer;
String Value_wxGraphicsRenderer::ToString(const StringStyle& ss) const
{
return ToStringGeneric(ss, "wx.GraphicsRenderer");
}
Gurax_EndModuleScope(wx)
|
[
"ypsitau@nifty.com"
] |
ypsitau@nifty.com
|
fc9fa8c9e77b1eae9706659a8b1303b84a79ded8
|
593356f8ce31e76678393148d87af6adc58c3dbb
|
/tests/process.cpp
|
0241f3becb1fd718359e129cf740bc410707ae5c
|
[
"MIT"
] |
permissive
|
hjw21century/not-enough-standards
|
acc4a0e6904a2f9ab5ecce8bfd5a4460fa79f5c1
|
5419ce7e8a65116040b7fe80c4981838325a67c1
|
refs/heads/master
| 2023-04-29T11:37:15.099808
| 2021-05-14T17:41:42
| 2021-05-14T17:41:42
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,508
|
cpp
|
#include <iostream>
#include <thread>
#include <mutex>
#include <shared_mutex>
#include <iterator>
#include <iomanip>
#include <array>
#include <cassert>
#include <random>
#include <nes/pipe.hpp>
#include <nes/shared_library.hpp>
#include <nes/process.hpp>
#include <nes/shared_memory.hpp>
#include <nes/named_mutex.hpp>
#include <nes/semaphore.hpp>
#include <nes/named_semaphore.hpp>
#include <nes/thread_pool.hpp>
#if defined(NES_WIN32_PROCESS)
constexpr const char* other_path{"not_enough_standards_test_other.exe"};
constexpr const char* lib_path{"not_enough_standards_test_lib.dll"};
#elif defined(NES_POSIX_PROCESS)
constexpr const char* other_path{"not_enough_standards_test_other"};
constexpr const char* lib_path{"not_enough_standards_test_lib.so"};
#endif
std::int32_t pow(std::int32_t value, std::uint32_t exponent);
static void shared_library_test()
{
nes::shared_library lib{lib_path};
auto func = lib.load<std::int32_t()>("nes_lib_func");
assert(func);
assert(func() == 42);
}
enum class data_type : std::uint32_t
{
uint32 = 1,
float64,
string
};
static void a_thread(nes::basic_pipe_istream<char>& is) noexcept
{
data_type type{};
std::uint32_t uint_value{};
double float_value{};
std::string str_value{};
std::uint64_t str_size{};
is.read(reinterpret_cast<char*>(&type), sizeof(data_type));
assert(type == data_type::uint32);
is.read(reinterpret_cast<char*>(&uint_value), sizeof(std::uint32_t));
assert(uint_value == 42);
is.read(reinterpret_cast<char*>(&type), sizeof(data_type));
assert(type == data_type::float64);
is.read(reinterpret_cast<char*>(&float_value), sizeof(double));
assert(float_value > 3.13 && float_value < 3.15);
is.read(reinterpret_cast<char*>(&type), sizeof(data_type));
assert(type == data_type::string);
is.read(reinterpret_cast<char*>(&str_size), sizeof(std::uint64_t));
str_value.resize(str_size);
is.read(std::data(str_value), static_cast<std::streamsize>(str_size));
assert(str_value == "Hello world!");
}
static void pipe_test()
{
auto [is, os] = nes::make_anonymous_pipe();
std::thread thread{a_thread, std::ref(is)};
const data_type uint_type {data_type::uint32};
const std::uint32_t uint_value{42};
os.write(reinterpret_cast<const char*>(&uint_type), sizeof(data_type));
os.write(reinterpret_cast<const char*>(&uint_value), sizeof(std::uint32_t));
const data_type float_type {data_type::float64};
const double float_value{3.14};
os.write(reinterpret_cast<const char*>(&float_type), sizeof(data_type));
os.write(reinterpret_cast<const char*>(&float_value), sizeof(double));
const data_type str_type {data_type::string};
const std::string str_value{"Hello world!"};
const std::uint64_t size_size{std::size(str_value)};
os.write(reinterpret_cast<const char*>(&str_type), sizeof(data_type));
os.write(reinterpret_cast<const char*>(&size_size), sizeof(std::uint64_t));
os.write(std::data(str_value), static_cast<std::streamsize>(size_size));
os.close();
if(thread.joinable())
thread.join();
}
static void another_thread(const std::array<std::uint32_t, 8>& data, nes::semaphore& semaphore)
{
for(std::uint32_t i{}; i < 8; ++i)
{
semaphore.acquire();
assert(data[i] == i);
}
}
static void semaphore_test()
{
std::array<std::uint32_t, 8> data{0, 1};
nes::semaphore semaphore{2};
std::thread thread{another_thread, std::cref(data), std::ref(semaphore)};
for(std::uint32_t i{2}; i < 8; ++i)
{
data[i] = i;
semaphore.release();
}
if(thread.joinable())
thread.join();
}
static void named_pipe_test()
{
nes::process other{other_path, std::vector<std::string>{"named pipe"}, nes::process_options::grab_stdout};
nes::pipe_ostream os{"nes_test_pipe"};
if(!os)
throw std::runtime_error{"Failed to open pipe."};
const data_type uint_type {data_type::uint32};
const std::uint32_t uint_value{42};
os.write(reinterpret_cast<const char*>(&uint_type), sizeof(data_type));
os.write(reinterpret_cast<const char*>(&uint_value), sizeof(std::uint32_t));
const data_type float_type {data_type::float64};
const double float_value{3.14};
os.write(reinterpret_cast<const char*>(&float_type), sizeof(data_type));
os.write(reinterpret_cast<const char*>(&float_value), sizeof(double));
const data_type str_type {data_type::string};
const std::string str_value{"Hello world!"};
const std::uint64_t size_size{std::size(str_value)};
os.write(reinterpret_cast<const char*>(&str_type), sizeof(data_type));
os.write(reinterpret_cast<const char*>(&size_size), sizeof(std::uint64_t));
os.write(std::data(str_value), static_cast<std::streamsize>(size_size));
os.close();
if(other.joinable())
other.join();
assert(other.return_code() == 0);
}
static void process_test()
{
std::cout << "Current process has id " << nes::this_process::get_id() << " and its current directory is \"" << nes::this_process::working_directory() << "\"" << std::endl;
nes::process other{other_path, {"Hey!", "\\\"12\"\"\\\\\\", "\\42\\", "It's \"me\"!"}, nes::process_options::grab_stdout};
std::cout << other.stdout_stream().rdbuf() << std::endl;
if(other.joinable())
other.join();
assert(other.return_code() == 0);
}
static void process_kill_test()
{
nes::process other{other_path, std::vector<std::string>{"process kill"}, nes::process_options::grab_stdout};
std::this_thread::sleep_for(std::chrono::seconds{3});
other.kill();
std::cout << other.stdout_stream().rdbuf() << std::endl;
assert(other.return_code() != 0);
}
static void shared_memory_test()
{
nes::shared_memory memory{"nes_test_shared_memory", sizeof(std::uint64_t)};
auto value{memory.map<std::uint64_t>(0)};
assert(value);
*value = 42;
assert(*value == 42);
nes::process other{other_path, std::vector<std::string>{"shared memory"}, nes::process_options::grab_stdout};
std::cout << other.stdout_stream().rdbuf() << std::endl;
if(other.joinable())
other.join();
assert(other.return_code() == 0);
assert(*value == 16777216);
}
static void named_mutex_test()
{
nes::named_mutex mutex{"nes_test_named_mutex"};
std::unique_lock lock{mutex};
nes::process other{other_path, std::vector<std::string>{"named mutex"}, nes::process_options::grab_stdout};
std::this_thread::sleep_for(std::chrono::milliseconds{500});
lock.unlock();
std::cout << other.stdout_stream().rdbuf() << std::endl;
if(other.joinable())
other.join();
}
static void timed_named_mutex_test()
{
nes::timed_named_mutex mutex{"nes_test_timed_named_mutex"};
std::unique_lock lock{mutex};
nes::process other{other_path, std::vector<std::string>{"timed named mutex"}, nes::process_options::grab_stdout};
std::this_thread::sleep_for(std::chrono::milliseconds{1000});
lock.unlock();
std::cout << other.stdout_stream().rdbuf() << std::endl;
if(other.joinable())
other.join();
}
static void named_semaphore_test()
{
nes::named_semaphore semaphore{"nes_test_named_semaphore"};
nes::process other{other_path, std::vector<std::string>{"named semaphore"}, nes::process_options::grab_stdout};
for(std::size_t i{}; i < 8; ++i)
{
std::this_thread::sleep_for(std::chrono::milliseconds{100});
semaphore.release();
}
std::cout << other.stdout_stream().rdbuf() << std::endl;
if(other.joinable())
other.join();
}
static void thread_pool_test()
{
static constexpr std::size_t buffer_size{32};
//Some buffers
std::array<std::uint32_t, buffer_size> input{};
std::array<std::uint32_t, buffer_size> temp{};
std::array<std::uint32_t, buffer_size> output{};
const auto print_buffers = [&input, &temp, &output]()
{
const auto print_buffer = [](const std::array<std::uint32_t, buffer_size>& buffer)
{
for(auto value : buffer)
{
std::cout << value << ",";
}
};
std::cout << "input: ";
print_buffer(input);
std::cout << "\ntemp: ";
print_buffer(temp);
std::cout << "\noutput: ";
print_buffer(output);
std::cout << std::endl;
};
//Fill the buffer with random values
std::mt19937 rng{std::random_device{}()};
std::uniform_int_distribution<std::uint32_t> dist{1, 9};
for(auto& input_value : input)
{
input_value = dist(rng);
}
//The task builder
nes::task_builder builder{};
builder.dispatch(buffer_size, 1, 1, [&input, &temp](std::uint32_t x, std::uint32_t y [[maybe_unused]], std::uint32_t z [[maybe_unused]])
{
temp[x] = input[x] * 2u;
});
nes::task_checkpoint checkpoint{builder.checkpoint()};
nes::task_fence fence{builder.fence()};
builder.dispatch(buffer_size, 1, 1, [&input, &temp, &output](std::uint32_t x, std::uint32_t y [[maybe_unused]], std::uint32_t z [[maybe_unused]])
{
for(auto value : temp)
{
output[x] += (value + input[x]);
}
});
//Create a thread pool to run our task list.
nes::thread_pool thread_pool{};
std::cout << "Initial state:" << std::endl;
print_buffers();
std::cout << "Launching first the work..." << std::endl;
std::future<nes::task_list> future{thread_pool.push(builder.build())};
std::cout << "Work started..." << std::endl;
checkpoint.wait();
std::cout << "First dispatch done:" << std::endl;
print_buffers();
std::cout << "Launching second dispatch..." << std::endl;
fence.signal();
std::cout << "Second dispatch started..." << std::endl;
future.wait();
std::cout << "Second dispatch done:" << std::endl;
print_buffers();
}
int main()
{
try
{
shared_library_test();
pipe_test();
semaphore_test();
process_test();
process_kill_test();
named_pipe_test();
shared_memory_test();
named_mutex_test();
timed_named_mutex_test();
named_semaphore_test();
thread_pool_test();
std::cout << "Tests passed succesfully." << std::endl;
}
catch(const std::exception& e)
{
std::cout << e.what() << std::endl;
}
}
|
[
"alexy.pellegrini@laposte.net"
] |
alexy.pellegrini@laposte.net
|
48899f4425b5b1bb85a3cce360bff6d90d0bd9a5
|
3c24f9f2138006dbcf4c89ba73e2ea4c752b3312
|
/include/kindynamic_path_planner/common.h
|
a142288f82bac9f43f9ecf4e3b88ee4e10db1717
|
[] |
no_license
|
Forrest-Z/kindynamic_path_planner
|
0caaba0388cf624468931ddcf6bf5de7043cb602
|
a46a4b0132a7e7d51e4d7b0925a6b824d8674572
|
refs/heads/main
| 2023-02-14T23:12:20.939629
| 2021-01-07T07:21:12
| 2021-01-07T07:21:12
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,740
|
h
|
#ifndef KINDYNAMIC_PATH_PLANNER_COMMON_H_
#define KINDYNAMIC_PATH_PLANNER_COMMON_H_
#include <math.h>
#include <boost/math/constants/constants.hpp>
namespace kindynamic_path_planner {
namespace common {
static const double pi = boost::math::constants::pi<double>();
static const double twopi = 2. * pi;
static const double zero = 10 * std::numeric_limits<double>::epsilon();
static const double inf = std::numeric_limits<double>::infinity();
inline double mod2pi(double x) {
double v = fmod(x, twopi);
if (v < -pi)
v += twopi;
else if (v > pi)
v -= twopi;
return v;
}
static const bool reverse = false;
// vehecle param
static const double wheelDistance = 1.868;
static const double maxSteerAngle = 0.6; // rad
static const double maxRadius = wheelDistance / tan(maxSteerAngle);
// steerAngle 0 0.2 0.4 0.6(max steer angle) L sqrt(2)
// Forward Motion Primitives trajectory for collision check
// trajctory x
static const double traX[7][20] = {
{0.00000000, 0.07443229, 0.14886459, 0.22329688, 0.29772917, 0.37216146, 0.44659376, 0.52102605, 0.59545834, 0.66989063,
0.74432293, 0.81875522, 0.89318751, 0.96761981, 1.04205210, 1.11648439, 1.19091668, 1.26534898, 1.33978127, 1.41421356}, // 0 rad
{0.00000000, 0.07443169, 0.14885973, 0.22328049, 0.29769032, 0.37208558, 0.44646262, 0.52081781, 0.59514748, 0.66944798,
0.74371568, 0.81794690, 0.89213799, 0.96628530, 1.04038515, 1.11443387, 1.18842780, 1.26236325, 1.33623654, 1.41004398}, // 0.2 rad
{0.00000000, 0.07442965, 0.14884346, 0.22322557, 0.29756013, 0.37183125, 0.44602303, 0.52011955, 0.59410484, 0.66796289,
0.74167766, 0.81523306, 0.88861291, 0.96180099, 1.03478103, 1.10753664, 1.18005137, 1.25230870, 1.32429197, 1.39598446}, // 0.2 rad
{0.00000000, 0.07442538, 0.14880926, 0.22311012, 0.29728635, 0.37129621, 0.44509784, 0.51864914, 0.59190781, 0.66483126,
0.73737656, 0.80950044, 0.88115921, 0.95230872, 1.02290429, 1.09290072, 1.16225217, 1.23091212, 1.29883335, 1.36596781}, // 0.6 rad
{0.00000000, 0.07443169, 0.14885973, 0.22328049, 0.29769032, 0.37208558, 0.44646262, 0.52081781, 0.59514748, 0.66944798,
0.74371568, 0.81794690, 0.89213799, 0.96628530, 1.04038515, 1.11443387, 1.18842780, 1.26236325, 1.33623654, 1.41004398}, // -0.2 rad
{0.00000000, 0.07442965, 0.14884346, 0.22322557, 0.29756013, 0.37183125, 0.44602303, 0.52011955, 0.59410484, 0.66796289,
0.74167766, 0.81523306, 0.88861291, 0.96180099, 1.03478103, 1.10753664, 1.18005137, 1.25230870, 1.32429197, 1.39598446}, // -0.2 rad
{0.00000000, 0.07442538, 0.14880926, 0.22311012, 0.29728635, 0.37129621, 0.44509784, 0.51864914, 0.59190781, 0.66483126,
0.73737656, 0.80950044, 0.88115921, 0.95230872, 1.02290429, 1.09290072, 1.16225217, 1.23091212, 1.29883335, 1.36596781} // -0.6 rad
};
// trajectory y
static const double traY[7][20] = {
{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000,
0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}, // 0 rad
{0.00000000, 0.00030060, 0.00120241, 0.00270541, 0.00480962, 0.00751504, 0.01082165, 0.01472947, 0.01923850, 0.02434872,
0.03006015, 0.03637278, 0.04328662, 0.05080166, 0.05891790, 0.06763534, 0.07695399, 0.08687384, 0.09739489, 0.10851715}, // 0.2 rad
{0.00000000, 0.00062697, 0.00250786, 0.00564269, 0.01003145, 0.01567415, 0.02257077, 0.03072133, 0.04012582, 0.05078424,
0.06269659, 0.07586288, 0.09028309, 0.10595724, 0.12288532, 0.14106733, 0.16050328, 0.18119315, 0.20313696, 0.22633470}, // 0.4 rad
{0.00000000, 0.00101452, 0.00405806, 0.00913064, 0.01623226, 0.02536290, 0.03652257, 0.04971128, 0.06492902, 0.08217579,
0.10145160, 0.12275643, 0.14609030, 0.17145320, 0.19884513, 0.22826609, 0.25971609, 0.29319511, 0.32870317, 0.36624026}, // 0.6 rad
{-0.00000000, -0.00030060, -0.00120241, -0.00270541, -0.00480962, -0.00751504, -0.01082165, -0.01472947, -0.01923850, -0.02434872,
-0.03006015, -0.03637278, -0.04328662, -0.05080166, -0.05891790, -0.06763534, -0.07695399, -0.08687384, -0.09739489, -0.10851715}, // -0.2 rad
{-0.00000000, -0.00062697, -0.00250786, -0.00564269, -0.01003145, -0.01567415, -0.02257077, -0.03072133, -0.04012582, -0.05078424,
-0.06269659, -0.07586288, -0.09028309, -0.10595724, -0.12288532, -0.14106733, -0.16050328, -0.18119315, -0.20313696, -0.22633470}, // -0.4 rad
{-0.00000000, -0.00101452, -0.00405806, -0.00913064, -0.01623226, -0.02536290, -0.03652257, -0.04971128, -0.06492902, -0.08217579,
-0.10145160, -0.12275643, -0.14609030, -0.17145320, -0.19884513, -0.22826609, -0.25971609, -0.29319511, -0.32870317, -0.36624026} // -0.6 rad
};
// trajectory theta
static const double traT[7][20] = {
{0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000,
0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000}, // 0 rad
{0.00000000, 0.00807720, 0.01615454, 0.02423213, 0.03231013, 0.04038865, 0.04846783, 0.05654780, 0.06462869, 0.07271064,
0.08079378, 0.08887823, 0.09696414, 0.10505164, 0.11314086, 0.12123193, 0.12932499, 0.13742017, 0.14551760, 0.15361743}, // 0.2 rad
{0.00000000, 0.01684681, 0.03369482, 0.05054521, 0.06739920, 0.08425798, 0.10112274, 0.11799471, 0.13487509, 0.15176510,
0.16866596, 0.18557890, 0.20250517, 0.21944600, 0.23640265, 0.25337639, 0.27036851, 0.28738028, 0.30441301, 0.32146803}, // 0.4 rad
{0.00000000, 0.02726095, 0.05452696, 0.08180311, 0.10909450, 0.13640624, 0.16374348, 0.19111142, 0.21851530, 0.24596044,
0.27345221, 0.30099608, 0.32859760, 0.35626242, 0.38399632, 0.41180518, 0.43969505, 0.46767210, 0.49574269, 0.52391336}, // -0.2 rad
{-0.00000000, -0.00807720, -0.01615454, -0.02423213, -0.03231013, -0.04038865, -0.04846783, -0.05654780, -0.06462869, -0.07271064,
-0.08079378, -0.08887823, -0.09696414, -0.10505164, -0.11314086, -0.12123193, -0.12932499, -0.13742017, -0.14551760, -0.15361743}, // 0.2 rad
{-0.00000000, -0.01684681, -0.03369482, -0.05054521, -0.06739920, -0.08425798, -0.10112274, -0.11799471, -0.13487509, -0.15176510,
-0.16866596, -0.18557890, -0.20250517, -0.21944600, -0.23640265, -0.25337639, -0.27036851, -0.28738028, -0.30441301, -0.3214680}, // 0.4 rad
{-0.00000000, -0.02726095, -0.05452696, -0.08180311, -0.10909450, -0.13640624, -0.16374348, -0.19111142, -0.21851530, -0.24596044,
-0.27345221, -0.30099608, -0.32859760, -0.35626242, -0.38399632, -0.41180518, -0.43969505, -0.46767210, -0.49574269, -0.52391336}, // -0.2 rad
};
// dx dy dt
static const double dx[7] = {1.41421356, 1.41004398, 1.39598446, 1.36596781, 1.41004398, 1.39598446, 1.36596781};
static const double dy[7] = {0.0, 0.10851715, 0.22633470, 0.36624026, -0.10851715, -0.22633470, -0.36624026};
static const double dt[7] = {0.0, 0.15361743, 0.32146803, 0.52391336, -0.15361743, -0.32146803, -0.52391336};
// the number of successor node or possible direction
static const int dir = 14;
// penalize function
// chord length
static const double chordLength[7] = {1.41421356, 1.41560510, 1.42032146, 1.43051820, 1.41560510, 1.42032146, 1.43051820};
static const double steerAngle[7] = {.0, .2, .4, .6, -.2, -.4, -.6};
// revers penalty
static const double penaltyReverse = 2.0;
// turn angle penalty
static const double penaltyTurnAngle = 1.05;
// change steer angle penalty
static const double penaltyChangeSteerAngle = 1.05;
// change direction penalty
static const double penaltyChangeDirection = 2.0;
} // namespace common
} // namespace kindynamic_path_planner
#endif
|
[
"1319418395@qq.com"
] |
1319418395@qq.com
|
0e8648490a02fe766d84aa169a7f9ff0f5226ee3
|
7883e367a19b2b0229ad39aa824fca628879d600
|
/Assignment 3/IT Project_BackUpThisFolder_ButDontShipItWithYourGame/il2cppOutput/UnityEngine.AIModule.cpp
|
cf5dfb7ee233697c8dc1abdd6aa7f490b8fb9cb2
|
[] |
no_license
|
Rachael-Balaz/IS-TU-830-Technical-Techies
|
b86997eaa61022d210d1947f83b7d1fe2a654bda
|
f6a9e1acfc760e973e694d5444a0bd13423ed0c1
|
refs/heads/master
| 2022-12-30T00:55:32.502330
| 2020-10-21T05:09:12
| 2020-10-21T05:09:12
| 284,192,125
| 3
| 0
| null | 2020-08-15T04:49:49
| 2020-08-01T05:15:07
|
CSS
|
UTF-8
|
C++
| false
| false
| 42,379
|
cpp
|
#include "pch-cpp.hpp"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <limits>
#include <stdint.h>
struct VirtActionInvoker0
{
typedef void (*Action)(void*, const RuntimeMethod*);
static inline void Invoke (Il2CppMethodSlot slot, RuntimeObject* obj)
{
const VirtualInvokeData& invokeData = il2cpp_codegen_get_virtual_invoke_data(slot, obj);
((Action)invokeData.methodPtr)(obj, invokeData.method);
}
};
struct GenericVirtActionInvoker0
{
typedef void (*Action)(void*, const RuntimeMethod*);
static inline void Invoke (const RuntimeMethod* method, RuntimeObject* obj)
{
VirtualInvokeData invokeData;
il2cpp_codegen_get_generic_virtual_invoke_data(method, obj, &invokeData);
((Action)invokeData.methodPtr)(obj, invokeData.method);
}
};
struct InterfaceActionInvoker0
{
typedef void (*Action)(void*, const RuntimeMethod*);
static inline void Invoke (Il2CppMethodSlot slot, RuntimeClass* declaringInterface, RuntimeObject* obj)
{
const VirtualInvokeData& invokeData = il2cpp_codegen_get_interface_invoke_data(slot, obj, declaringInterface);
((Action)invokeData.methodPtr)(obj, invokeData.method);
}
};
struct GenericInterfaceActionInvoker0
{
typedef void (*Action)(void*, const RuntimeMethod*);
static inline void Invoke (const RuntimeMethod* method, RuntimeObject* obj)
{
VirtualInvokeData invokeData;
il2cpp_codegen_get_generic_interface_invoke_data(method, obj, &invokeData);
((Action)invokeData.methodPtr)(obj, invokeData.method);
}
};
// System.Delegate
struct Delegate_t;
// System.DelegateData
struct DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288;
// System.Reflection.MethodInfo
struct MethodInfo_t;
// UnityEngine.AI.NavMeshAgent
struct NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B;
// System.String
struct String_t;
// System.Void
struct Void_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5;
// UnityEngine.AI.NavMesh/OnNavMeshPreUpdate
struct OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572;
// System.AsyncCallback
struct AsyncCallback_tA7921BEF974919C46FF8F9D9867C567B200BB0EA;
// System.Delegate[]
struct DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8;
// System.IAsyncResult
struct IAsyncResult_tC9F97BF36FCF122D29D3101D80642278297BF370;
IL2CPP_EXTERN_C RuntimeClass* NavMesh_t6A9D1EE380DAD7B40A82058C6956154300CC7D92_il2cpp_TypeInfo_var;
IL2CPP_EXTERN_C const uint32_t NavMesh_Internal_CallOnNavMeshPreUpdate_m5C0CEF0AEF92B6BE0368AA5ABC02B4CCDEFA9AD5_MetadataUsageId;
struct Delegate_t_marshaled_com;
struct Delegate_t_marshaled_pinvoke;
struct DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8;
IL2CPP_EXTERN_C_BEGIN
IL2CPP_EXTERN_C_END
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// <Module>
struct U3CModuleU3E_t5DC9681BD1ACB43AC4E834362F4E6CBF34AF0FEF
{
public:
public:
};
// System.Object
struct Il2CppArrayBounds;
// System.Array
// System.ValueType
struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52 : public RuntimeObject
{
public:
public:
};
// Native definition for P/Invoke marshalling of System.ValueType
struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.ValueType
struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52_marshaled_com
{
};
// UnityEngine.AI.NavMesh
struct NavMesh_t6A9D1EE380DAD7B40A82058C6956154300CC7D92 : public RuntimeObject
{
public:
public:
};
struct NavMesh_t6A9D1EE380DAD7B40A82058C6956154300CC7D92_StaticFields
{
public:
// UnityEngine.AI.NavMesh_OnNavMeshPreUpdate UnityEngine.AI.NavMesh::onPreUpdate
OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * ___onPreUpdate_0;
public:
inline static int32_t get_offset_of_onPreUpdate_0() { return static_cast<int32_t>(offsetof(NavMesh_t6A9D1EE380DAD7B40A82058C6956154300CC7D92_StaticFields, ___onPreUpdate_0)); }
inline OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * get_onPreUpdate_0() const { return ___onPreUpdate_0; }
inline OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 ** get_address_of_onPreUpdate_0() { return &___onPreUpdate_0; }
inline void set_onPreUpdate_0(OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * value)
{
___onPreUpdate_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___onPreUpdate_0), (void*)value);
}
};
// System.Boolean
struct Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37
{
public:
// System.Boolean System.Boolean::m_value
bool ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37, ___m_value_0)); }
inline bool get_m_value_0() const { return ___m_value_0; }
inline bool* get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(bool value)
{
___m_value_0 = value;
}
};
struct Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37_StaticFields
{
public:
// System.String System.Boolean::TrueString
String_t* ___TrueString_5;
// System.String System.Boolean::FalseString
String_t* ___FalseString_6;
public:
inline static int32_t get_offset_of_TrueString_5() { return static_cast<int32_t>(offsetof(Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37_StaticFields, ___TrueString_5)); }
inline String_t* get_TrueString_5() const { return ___TrueString_5; }
inline String_t** get_address_of_TrueString_5() { return &___TrueString_5; }
inline void set_TrueString_5(String_t* value)
{
___TrueString_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&___TrueString_5), (void*)value);
}
inline static int32_t get_offset_of_FalseString_6() { return static_cast<int32_t>(offsetof(Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37_StaticFields, ___FalseString_6)); }
inline String_t* get_FalseString_6() const { return ___FalseString_6; }
inline String_t** get_address_of_FalseString_6() { return &___FalseString_6; }
inline void set_FalseString_6(String_t* value)
{
___FalseString_6 = value;
Il2CppCodeGenWriteBarrier((void**)(&___FalseString_6), (void*)value);
}
};
// System.IntPtr
struct IntPtr_t
{
public:
// System.Void* System.IntPtr::m_value
void* ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(IntPtr_t, ___m_value_0)); }
inline void* get_m_value_0() const { return ___m_value_0; }
inline void** get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(void* value)
{
___m_value_0 = value;
}
};
struct IntPtr_t_StaticFields
{
public:
// System.IntPtr System.IntPtr::Zero
intptr_t ___Zero_1;
public:
inline static int32_t get_offset_of_Zero_1() { return static_cast<int32_t>(offsetof(IntPtr_t_StaticFields, ___Zero_1)); }
inline intptr_t get_Zero_1() const { return ___Zero_1; }
inline intptr_t* get_address_of_Zero_1() { return &___Zero_1; }
inline void set_Zero_1(intptr_t value)
{
___Zero_1 = value;
}
};
// System.Single
struct Single_tE07797BA3C98D4CA9B5A19413C19A76688AB899E
{
public:
// System.Single System.Single::m_value
float ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Single_tE07797BA3C98D4CA9B5A19413C19A76688AB899E, ___m_value_0)); }
inline float get_m_value_0() const { return ___m_value_0; }
inline float* get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(float value)
{
___m_value_0 = value;
}
};
// System.Void
struct Void_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5
{
public:
union
{
struct
{
};
uint8_t Void_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5__padding[1];
};
public:
};
// UnityEngine.Vector3
struct Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E
{
public:
// System.Single UnityEngine.Vector3::x
float ___x_2;
// System.Single UnityEngine.Vector3::y
float ___y_3;
// System.Single UnityEngine.Vector3::z
float ___z_4;
public:
inline static int32_t get_offset_of_x_2() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E, ___x_2)); }
inline float get_x_2() const { return ___x_2; }
inline float* get_address_of_x_2() { return &___x_2; }
inline void set_x_2(float value)
{
___x_2 = value;
}
inline static int32_t get_offset_of_y_3() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E, ___y_3)); }
inline float get_y_3() const { return ___y_3; }
inline float* get_address_of_y_3() { return &___y_3; }
inline void set_y_3(float value)
{
___y_3 = value;
}
inline static int32_t get_offset_of_z_4() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E, ___z_4)); }
inline float get_z_4() const { return ___z_4; }
inline float* get_address_of_z_4() { return &___z_4; }
inline void set_z_4(float value)
{
___z_4 = value;
}
};
struct Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields
{
public:
// UnityEngine.Vector3 UnityEngine.Vector3::zeroVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___zeroVector_5;
// UnityEngine.Vector3 UnityEngine.Vector3::oneVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___oneVector_6;
// UnityEngine.Vector3 UnityEngine.Vector3::upVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___upVector_7;
// UnityEngine.Vector3 UnityEngine.Vector3::downVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___downVector_8;
// UnityEngine.Vector3 UnityEngine.Vector3::leftVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___leftVector_9;
// UnityEngine.Vector3 UnityEngine.Vector3::rightVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___rightVector_10;
// UnityEngine.Vector3 UnityEngine.Vector3::forwardVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___forwardVector_11;
// UnityEngine.Vector3 UnityEngine.Vector3::backVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___backVector_12;
// UnityEngine.Vector3 UnityEngine.Vector3::positiveInfinityVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___positiveInfinityVector_13;
// UnityEngine.Vector3 UnityEngine.Vector3::negativeInfinityVector
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___negativeInfinityVector_14;
public:
inline static int32_t get_offset_of_zeroVector_5() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___zeroVector_5)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_zeroVector_5() const { return ___zeroVector_5; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_zeroVector_5() { return &___zeroVector_5; }
inline void set_zeroVector_5(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___zeroVector_5 = value;
}
inline static int32_t get_offset_of_oneVector_6() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___oneVector_6)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_oneVector_6() const { return ___oneVector_6; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_oneVector_6() { return &___oneVector_6; }
inline void set_oneVector_6(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___oneVector_6 = value;
}
inline static int32_t get_offset_of_upVector_7() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___upVector_7)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_upVector_7() const { return ___upVector_7; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_upVector_7() { return &___upVector_7; }
inline void set_upVector_7(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___upVector_7 = value;
}
inline static int32_t get_offset_of_downVector_8() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___downVector_8)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_downVector_8() const { return ___downVector_8; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_downVector_8() { return &___downVector_8; }
inline void set_downVector_8(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___downVector_8 = value;
}
inline static int32_t get_offset_of_leftVector_9() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___leftVector_9)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_leftVector_9() const { return ___leftVector_9; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_leftVector_9() { return &___leftVector_9; }
inline void set_leftVector_9(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___leftVector_9 = value;
}
inline static int32_t get_offset_of_rightVector_10() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___rightVector_10)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_rightVector_10() const { return ___rightVector_10; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_rightVector_10() { return &___rightVector_10; }
inline void set_rightVector_10(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___rightVector_10 = value;
}
inline static int32_t get_offset_of_forwardVector_11() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___forwardVector_11)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_forwardVector_11() const { return ___forwardVector_11; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_forwardVector_11() { return &___forwardVector_11; }
inline void set_forwardVector_11(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___forwardVector_11 = value;
}
inline static int32_t get_offset_of_backVector_12() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___backVector_12)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_backVector_12() const { return ___backVector_12; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_backVector_12() { return &___backVector_12; }
inline void set_backVector_12(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___backVector_12 = value;
}
inline static int32_t get_offset_of_positiveInfinityVector_13() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___positiveInfinityVector_13)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_positiveInfinityVector_13() const { return ___positiveInfinityVector_13; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_positiveInfinityVector_13() { return &___positiveInfinityVector_13; }
inline void set_positiveInfinityVector_13(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___positiveInfinityVector_13 = value;
}
inline static int32_t get_offset_of_negativeInfinityVector_14() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___negativeInfinityVector_14)); }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_negativeInfinityVector_14() const { return ___negativeInfinityVector_14; }
inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_negativeInfinityVector_14() { return &___negativeInfinityVector_14; }
inline void set_negativeInfinityVector_14(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value)
{
___negativeInfinityVector_14 = value;
}
};
// System.Delegate
struct Delegate_t : public RuntimeObject
{
public:
// System.IntPtr System.Delegate::method_ptr
Il2CppMethodPointer ___method_ptr_0;
// System.IntPtr System.Delegate::invoke_impl
intptr_t ___invoke_impl_1;
// System.Object System.Delegate::m_target
RuntimeObject * ___m_target_2;
// System.IntPtr System.Delegate::method
intptr_t ___method_3;
// System.IntPtr System.Delegate::delegate_trampoline
intptr_t ___delegate_trampoline_4;
// System.IntPtr System.Delegate::extra_arg
intptr_t ___extra_arg_5;
// System.IntPtr System.Delegate::method_code
intptr_t ___method_code_6;
// System.Reflection.MethodInfo System.Delegate::method_info
MethodInfo_t * ___method_info_7;
// System.Reflection.MethodInfo System.Delegate::original_method_info
MethodInfo_t * ___original_method_info_8;
// System.DelegateData System.Delegate::data
DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 * ___data_9;
// System.Boolean System.Delegate::method_is_virtual
bool ___method_is_virtual_10;
public:
inline static int32_t get_offset_of_method_ptr_0() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_ptr_0)); }
inline Il2CppMethodPointer get_method_ptr_0() const { return ___method_ptr_0; }
inline Il2CppMethodPointer* get_address_of_method_ptr_0() { return &___method_ptr_0; }
inline void set_method_ptr_0(Il2CppMethodPointer value)
{
___method_ptr_0 = value;
}
inline static int32_t get_offset_of_invoke_impl_1() { return static_cast<int32_t>(offsetof(Delegate_t, ___invoke_impl_1)); }
inline intptr_t get_invoke_impl_1() const { return ___invoke_impl_1; }
inline intptr_t* get_address_of_invoke_impl_1() { return &___invoke_impl_1; }
inline void set_invoke_impl_1(intptr_t value)
{
___invoke_impl_1 = value;
}
inline static int32_t get_offset_of_m_target_2() { return static_cast<int32_t>(offsetof(Delegate_t, ___m_target_2)); }
inline RuntimeObject * get_m_target_2() const { return ___m_target_2; }
inline RuntimeObject ** get_address_of_m_target_2() { return &___m_target_2; }
inline void set_m_target_2(RuntimeObject * value)
{
___m_target_2 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_target_2), (void*)value);
}
inline static int32_t get_offset_of_method_3() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_3)); }
inline intptr_t get_method_3() const { return ___method_3; }
inline intptr_t* get_address_of_method_3() { return &___method_3; }
inline void set_method_3(intptr_t value)
{
___method_3 = value;
}
inline static int32_t get_offset_of_delegate_trampoline_4() { return static_cast<int32_t>(offsetof(Delegate_t, ___delegate_trampoline_4)); }
inline intptr_t get_delegate_trampoline_4() const { return ___delegate_trampoline_4; }
inline intptr_t* get_address_of_delegate_trampoline_4() { return &___delegate_trampoline_4; }
inline void set_delegate_trampoline_4(intptr_t value)
{
___delegate_trampoline_4 = value;
}
inline static int32_t get_offset_of_extra_arg_5() { return static_cast<int32_t>(offsetof(Delegate_t, ___extra_arg_5)); }
inline intptr_t get_extra_arg_5() const { return ___extra_arg_5; }
inline intptr_t* get_address_of_extra_arg_5() { return &___extra_arg_5; }
inline void set_extra_arg_5(intptr_t value)
{
___extra_arg_5 = value;
}
inline static int32_t get_offset_of_method_code_6() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_code_6)); }
inline intptr_t get_method_code_6() const { return ___method_code_6; }
inline intptr_t* get_address_of_method_code_6() { return &___method_code_6; }
inline void set_method_code_6(intptr_t value)
{
___method_code_6 = value;
}
inline static int32_t get_offset_of_method_info_7() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_info_7)); }
inline MethodInfo_t * get_method_info_7() const { return ___method_info_7; }
inline MethodInfo_t ** get_address_of_method_info_7() { return &___method_info_7; }
inline void set_method_info_7(MethodInfo_t * value)
{
___method_info_7 = value;
Il2CppCodeGenWriteBarrier((void**)(&___method_info_7), (void*)value);
}
inline static int32_t get_offset_of_original_method_info_8() { return static_cast<int32_t>(offsetof(Delegate_t, ___original_method_info_8)); }
inline MethodInfo_t * get_original_method_info_8() const { return ___original_method_info_8; }
inline MethodInfo_t ** get_address_of_original_method_info_8() { return &___original_method_info_8; }
inline void set_original_method_info_8(MethodInfo_t * value)
{
___original_method_info_8 = value;
Il2CppCodeGenWriteBarrier((void**)(&___original_method_info_8), (void*)value);
}
inline static int32_t get_offset_of_data_9() { return static_cast<int32_t>(offsetof(Delegate_t, ___data_9)); }
inline DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 * get_data_9() const { return ___data_9; }
inline DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 ** get_address_of_data_9() { return &___data_9; }
inline void set_data_9(DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 * value)
{
___data_9 = value;
Il2CppCodeGenWriteBarrier((void**)(&___data_9), (void*)value);
}
inline static int32_t get_offset_of_method_is_virtual_10() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_is_virtual_10)); }
inline bool get_method_is_virtual_10() const { return ___method_is_virtual_10; }
inline bool* get_address_of_method_is_virtual_10() { return &___method_is_virtual_10; }
inline void set_method_is_virtual_10(bool value)
{
___method_is_virtual_10 = value;
}
};
// Native definition for P/Invoke marshalling of System.Delegate
struct Delegate_t_marshaled_pinvoke
{
intptr_t ___method_ptr_0;
intptr_t ___invoke_impl_1;
Il2CppIUnknown* ___m_target_2;
intptr_t ___method_3;
intptr_t ___delegate_trampoline_4;
intptr_t ___extra_arg_5;
intptr_t ___method_code_6;
MethodInfo_t * ___method_info_7;
MethodInfo_t * ___original_method_info_8;
DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 * ___data_9;
int32_t ___method_is_virtual_10;
};
// Native definition for COM marshalling of System.Delegate
struct Delegate_t_marshaled_com
{
intptr_t ___method_ptr_0;
intptr_t ___invoke_impl_1;
Il2CppIUnknown* ___m_target_2;
intptr_t ___method_3;
intptr_t ___delegate_trampoline_4;
intptr_t ___extra_arg_5;
intptr_t ___method_code_6;
MethodInfo_t * ___method_info_7;
MethodInfo_t * ___original_method_info_8;
DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 * ___data_9;
int32_t ___method_is_virtual_10;
};
// UnityEngine.Object
struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A : public RuntimeObject
{
public:
// System.IntPtr UnityEngine.Object::m_CachedPtr
intptr_t ___m_CachedPtr_0;
public:
inline static int32_t get_offset_of_m_CachedPtr_0() { return static_cast<int32_t>(offsetof(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A, ___m_CachedPtr_0)); }
inline intptr_t get_m_CachedPtr_0() const { return ___m_CachedPtr_0; }
inline intptr_t* get_address_of_m_CachedPtr_0() { return &___m_CachedPtr_0; }
inline void set_m_CachedPtr_0(intptr_t value)
{
___m_CachedPtr_0 = value;
}
};
struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_StaticFields
{
public:
// System.Int32 UnityEngine.Object::OffsetOfInstanceIDInCPlusPlusObject
int32_t ___OffsetOfInstanceIDInCPlusPlusObject_1;
public:
inline static int32_t get_offset_of_OffsetOfInstanceIDInCPlusPlusObject_1() { return static_cast<int32_t>(offsetof(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_StaticFields, ___OffsetOfInstanceIDInCPlusPlusObject_1)); }
inline int32_t get_OffsetOfInstanceIDInCPlusPlusObject_1() const { return ___OffsetOfInstanceIDInCPlusPlusObject_1; }
inline int32_t* get_address_of_OffsetOfInstanceIDInCPlusPlusObject_1() { return &___OffsetOfInstanceIDInCPlusPlusObject_1; }
inline void set_OffsetOfInstanceIDInCPlusPlusObject_1(int32_t value)
{
___OffsetOfInstanceIDInCPlusPlusObject_1 = value;
}
};
// Native definition for P/Invoke marshalling of UnityEngine.Object
struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_marshaled_pinvoke
{
intptr_t ___m_CachedPtr_0;
};
// Native definition for COM marshalling of UnityEngine.Object
struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_marshaled_com
{
intptr_t ___m_CachedPtr_0;
};
// System.MulticastDelegate
struct MulticastDelegate_t : public Delegate_t
{
public:
// System.Delegate[] System.MulticastDelegate::delegates
DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8* ___delegates_11;
public:
inline static int32_t get_offset_of_delegates_11() { return static_cast<int32_t>(offsetof(MulticastDelegate_t, ___delegates_11)); }
inline DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8* get_delegates_11() const { return ___delegates_11; }
inline DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8** get_address_of_delegates_11() { return &___delegates_11; }
inline void set_delegates_11(DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8* value)
{
___delegates_11 = value;
Il2CppCodeGenWriteBarrier((void**)(&___delegates_11), (void*)value);
}
};
// Native definition for P/Invoke marshalling of System.MulticastDelegate
struct MulticastDelegate_t_marshaled_pinvoke : public Delegate_t_marshaled_pinvoke
{
Delegate_t_marshaled_pinvoke** ___delegates_11;
};
// Native definition for COM marshalling of System.MulticastDelegate
struct MulticastDelegate_t_marshaled_com : public Delegate_t_marshaled_com
{
Delegate_t_marshaled_com** ___delegates_11;
};
// UnityEngine.AI.NavMeshData
struct NavMeshData_t4A718E7F2CF47C3E1190DCAADCA989CBA91BDDF6 : public Object_tF2F3778131EFF286AF62B7B013A170F95A91571A
{
public:
public:
};
// UnityEngine.Component
struct Component_t62FBC8D2420DA4BE9037AFE430740F6B3EECA684 : public Object_tF2F3778131EFF286AF62B7B013A170F95A91571A
{
public:
public:
};
// System.AsyncCallback
struct AsyncCallback_tA7921BEF974919C46FF8F9D9867C567B200BB0EA : public MulticastDelegate_t
{
public:
public:
};
// UnityEngine.AI.NavMesh_OnNavMeshPreUpdate
struct OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 : public MulticastDelegate_t
{
public:
public:
};
// UnityEngine.Behaviour
struct Behaviour_t1A3DDDCF73B4627928FBFE02ED52B7251777DBD9 : public Component_t62FBC8D2420DA4BE9037AFE430740F6B3EECA684
{
public:
public:
};
// UnityEngine.AI.NavMeshAgent
struct NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B : public Behaviour_t1A3DDDCF73B4627928FBFE02ED52B7251777DBD9
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// System.Delegate[]
struct DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8 : public RuntimeArray
{
public:
ALIGN_FIELD (8) Delegate_t * m_Items[1];
public:
inline Delegate_t * GetAt(il2cpp_array_size_t index) const
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items[index];
}
inline Delegate_t ** GetAddressAt(il2cpp_array_size_t index)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items + index;
}
inline void SetAt(il2cpp_array_size_t index, Delegate_t * value)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
m_Items[index] = value;
Il2CppCodeGenWriteBarrier((void**)m_Items + index, (void*)value);
}
inline Delegate_t * GetAtUnchecked(il2cpp_array_size_t index) const
{
return m_Items[index];
}
inline Delegate_t ** GetAddressAtUnchecked(il2cpp_array_size_t index)
{
return m_Items + index;
}
inline void SetAtUnchecked(il2cpp_array_size_t index, Delegate_t * value)
{
m_Items[index] = value;
Il2CppCodeGenWriteBarrier((void**)m_Items + index, (void*)value);
}
};
// System.Void UnityEngine.AI.NavMesh/OnNavMeshPreUpdate::Invoke()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void OnNavMeshPreUpdate_Invoke_m8950FEDFD3E07B272ED469FD1911AA98C60FC28D (OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * __this, const RuntimeMethod* method);
// System.Void UnityEngine.AI.NavMeshAgent::set_destination_Injected(UnityEngine.Vector3&)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NavMeshAgent_set_destination_Injected_m440F39AC542ABA6D46FCC250DAAA944A88357D4A (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * ___value0, const RuntimeMethod* method);
// System.Void UnityEngine.AI.NavMeshAgent::get_velocity_Injected(UnityEngine.Vector3&)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NavMeshAgent_get_velocity_Injected_m64CD1C3DAE418314D44A1194F014CEC159CDDAA8 (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * ___ret0, const RuntimeMethod* method);
// System.Boolean UnityEngine.AI.NavMeshAgent::Warp_Injected(UnityEngine.Vector3&)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR bool NavMeshAgent_Warp_Injected_m861204DF82547182B4A36A41C36BEE8AFD3CE01B (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * ___newPosition0, const RuntimeMethod* method);
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void UnityEngine.AI.NavMesh::Internal_CallOnNavMeshPreUpdate()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NavMesh_Internal_CallOnNavMeshPreUpdate_m5C0CEF0AEF92B6BE0368AA5ABC02B4CCDEFA9AD5 (const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (NavMesh_Internal_CallOnNavMeshPreUpdate_m5C0CEF0AEF92B6BE0368AA5ABC02B4CCDEFA9AD5_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
bool V_0 = false;
{
OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * L_0 = ((NavMesh_t6A9D1EE380DAD7B40A82058C6956154300CC7D92_StaticFields*)il2cpp_codegen_static_fields_for(NavMesh_t6A9D1EE380DAD7B40A82058C6956154300CC7D92_il2cpp_TypeInfo_var))->get_onPreUpdate_0();
V_0 = (bool)((!(((RuntimeObject*)(OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 *)L_0) <= ((RuntimeObject*)(RuntimeObject *)NULL)))? 1 : 0);
bool L_1 = V_0;
if (!L_1)
{
goto IL_0018;
}
}
{
OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * L_2 = ((NavMesh_t6A9D1EE380DAD7B40A82058C6956154300CC7D92_StaticFields*)il2cpp_codegen_static_fields_for(NavMesh_t6A9D1EE380DAD7B40A82058C6956154300CC7D92_il2cpp_TypeInfo_var))->get_onPreUpdate_0();
NullCheck(L_2);
OnNavMeshPreUpdate_Invoke_m8950FEDFD3E07B272ED469FD1911AA98C60FC28D(L_2, /*hidden argument*/NULL);
}
IL_0018:
{
return;
}
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void UnityEngine.AI.NavMeshAgent::set_destination(UnityEngine.Vector3)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NavMeshAgent_set_destination_m0EC1C668AD85AC1B26AABF54337D7D0849F760E7 (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___value0, const RuntimeMethod* method)
{
{
NavMeshAgent_set_destination_Injected_m440F39AC542ABA6D46FCC250DAAA944A88357D4A(__this, (Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E *)(&___value0), /*hidden argument*/NULL);
return;
}
}
// UnityEngine.Vector3 UnityEngine.AI.NavMeshAgent::get_velocity()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E NavMeshAgent_get_velocity_mA6F25F6B38D5092BBE6DECD77F8FDB93D5C515C9 (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, const RuntimeMethod* method)
{
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E V_0;
memset((&V_0), 0, sizeof(V_0));
{
NavMeshAgent_get_velocity_Injected_m64CD1C3DAE418314D44A1194F014CEC159CDDAA8(__this, (Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E *)(&V_0), /*hidden argument*/NULL);
Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_0 = V_0;
return L_0;
}
}
// System.Boolean UnityEngine.AI.NavMeshAgent::Warp(UnityEngine.Vector3)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR bool NavMeshAgent_Warp_mE6417B4AA745066309AD7B833D2BB698F244541E (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___newPosition0, const RuntimeMethod* method)
{
{
bool L_0 = NavMeshAgent_Warp_Injected_m861204DF82547182B4A36A41C36BEE8AFD3CE01B(__this, (Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E *)(&___newPosition0), /*hidden argument*/NULL);
return L_0;
}
}
// System.Void UnityEngine.AI.NavMeshAgent::set_isStopped(System.Boolean)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NavMeshAgent_set_isStopped_m3258581121A85B9F8BC02FCC2111B15506A26896 (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, bool ___value0, const RuntimeMethod* method)
{
typedef void (*NavMeshAgent_set_isStopped_m3258581121A85B9F8BC02FCC2111B15506A26896_ftn) (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B *, bool);
static NavMeshAgent_set_isStopped_m3258581121A85B9F8BC02FCC2111B15506A26896_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (NavMeshAgent_set_isStopped_m3258581121A85B9F8BC02FCC2111B15506A26896_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.AI.NavMeshAgent::set_isStopped(System.Boolean)");
_il2cpp_icall_func(__this, ___value0);
}
// System.Void UnityEngine.AI.NavMeshAgent::set_speed(System.Single)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NavMeshAgent_set_speed_mE71CB504B0CC1E977293722F9BA81B7060A99E14 (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, float ___value0, const RuntimeMethod* method)
{
typedef void (*NavMeshAgent_set_speed_mE71CB504B0CC1E977293722F9BA81B7060A99E14_ftn) (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B *, float);
static NavMeshAgent_set_speed_mE71CB504B0CC1E977293722F9BA81B7060A99E14_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (NavMeshAgent_set_speed_mE71CB504B0CC1E977293722F9BA81B7060A99E14_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.AI.NavMeshAgent::set_speed(System.Single)");
_il2cpp_icall_func(__this, ___value0);
}
// System.Void UnityEngine.AI.NavMeshAgent::set_destination_Injected(UnityEngine.Vector3&)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NavMeshAgent_set_destination_Injected_m440F39AC542ABA6D46FCC250DAAA944A88357D4A (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * ___value0, const RuntimeMethod* method)
{
typedef void (*NavMeshAgent_set_destination_Injected_m440F39AC542ABA6D46FCC250DAAA944A88357D4A_ftn) (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B *, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E *);
static NavMeshAgent_set_destination_Injected_m440F39AC542ABA6D46FCC250DAAA944A88357D4A_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (NavMeshAgent_set_destination_Injected_m440F39AC542ABA6D46FCC250DAAA944A88357D4A_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.AI.NavMeshAgent::set_destination_Injected(UnityEngine.Vector3&)");
_il2cpp_icall_func(__this, ___value0);
}
// System.Void UnityEngine.AI.NavMeshAgent::get_velocity_Injected(UnityEngine.Vector3&)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NavMeshAgent_get_velocity_Injected_m64CD1C3DAE418314D44A1194F014CEC159CDDAA8 (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * ___ret0, const RuntimeMethod* method)
{
typedef void (*NavMeshAgent_get_velocity_Injected_m64CD1C3DAE418314D44A1194F014CEC159CDDAA8_ftn) (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B *, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E *);
static NavMeshAgent_get_velocity_Injected_m64CD1C3DAE418314D44A1194F014CEC159CDDAA8_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (NavMeshAgent_get_velocity_Injected_m64CD1C3DAE418314D44A1194F014CEC159CDDAA8_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.AI.NavMeshAgent::get_velocity_Injected(UnityEngine.Vector3&)");
_il2cpp_icall_func(__this, ___ret0);
}
// System.Boolean UnityEngine.AI.NavMeshAgent::Warp_Injected(UnityEngine.Vector3&)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR bool NavMeshAgent_Warp_Injected_m861204DF82547182B4A36A41C36BEE8AFD3CE01B (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B * __this, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * ___newPosition0, const RuntimeMethod* method)
{
typedef bool (*NavMeshAgent_Warp_Injected_m861204DF82547182B4A36A41C36BEE8AFD3CE01B_ftn) (NavMeshAgent_tB9746B6C38013341DB63973CA7ED657494EFB41B *, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E *);
static NavMeshAgent_Warp_Injected_m861204DF82547182B4A36A41C36BEE8AFD3CE01B_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (NavMeshAgent_Warp_Injected_m861204DF82547182B4A36A41C36BEE8AFD3CE01B_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.AI.NavMeshAgent::Warp_Injected(UnityEngine.Vector3&)");
bool retVal = _il2cpp_icall_func(__this, ___newPosition0);
return retVal;
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
IL2CPP_EXTERN_C void DelegatePInvokeWrapper_OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 (OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * __this, const RuntimeMethod* method)
{
typedef void (DEFAULT_CALL *PInvokeFunc)();
PInvokeFunc il2cppPInvokeFunc = reinterpret_cast<PInvokeFunc>(il2cpp_codegen_get_method_pointer(((RuntimeDelegate*)__this)->method));
// Native function invocation
il2cppPInvokeFunc();
}
// System.Void UnityEngine.AI.NavMesh_OnNavMeshPreUpdate::.ctor(System.Object,System.IntPtr)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void OnNavMeshPreUpdate__ctor_mDBB85480C3EA968112EB3B356486B9C9FF387BD4 (OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * __this, RuntimeObject * ___object0, intptr_t ___method1, const RuntimeMethod* method)
{
__this->set_method_ptr_0(il2cpp_codegen_get_method_pointer((RuntimeMethod*)___method1));
__this->set_method_3(___method1);
__this->set_m_target_2(___object0);
}
// System.Void UnityEngine.AI.NavMesh_OnNavMeshPreUpdate::Invoke()
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void OnNavMeshPreUpdate_Invoke_m8950FEDFD3E07B272ED469FD1911AA98C60FC28D (OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * __this, const RuntimeMethod* method)
{
DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8* delegateArrayToInvoke = __this->get_delegates_11();
Delegate_t** delegatesToInvoke;
il2cpp_array_size_t length;
if (delegateArrayToInvoke != NULL)
{
length = delegateArrayToInvoke->max_length;
delegatesToInvoke = reinterpret_cast<Delegate_t**>(delegateArrayToInvoke->GetAddressAtUnchecked(0));
}
else
{
length = 1;
delegatesToInvoke = reinterpret_cast<Delegate_t**>(&__this);
}
for (il2cpp_array_size_t i = 0; i < length; i++)
{
Delegate_t* currentDelegate = delegatesToInvoke[i];
Il2CppMethodPointer targetMethodPointer = currentDelegate->get_method_ptr_0();
RuntimeObject* targetThis = currentDelegate->get_m_target_2();
RuntimeMethod* targetMethod = (RuntimeMethod*)(currentDelegate->get_method_3());
if (!il2cpp_codegen_method_is_virtual(targetMethod))
{
il2cpp_codegen_raise_execution_engine_exception_if_method_is_not_found(targetMethod);
}
bool ___methodIsStatic = MethodIsStatic(targetMethod);
int ___parameterCount = il2cpp_codegen_method_parameter_count(targetMethod);
if (___methodIsStatic)
{
if (___parameterCount == 0)
{
// open
typedef void (*FunctionPointerType) (const RuntimeMethod*);
((FunctionPointerType)targetMethodPointer)(targetMethod);
}
else
{
// closed
typedef void (*FunctionPointerType) (void*, const RuntimeMethod*);
((FunctionPointerType)targetMethodPointer)(targetThis, targetMethod);
}
}
else
{
// closed
if (targetThis != NULL && il2cpp_codegen_method_is_virtual(targetMethod) && !il2cpp_codegen_object_is_of_sealed_type(targetThis) && il2cpp_codegen_delegate_has_invoker((Il2CppDelegate*)__this))
{
if (il2cpp_codegen_method_is_generic_instance(targetMethod))
{
if (il2cpp_codegen_method_is_interface_method(targetMethod))
GenericInterfaceActionInvoker0::Invoke(targetMethod, targetThis);
else
GenericVirtActionInvoker0::Invoke(targetMethod, targetThis);
}
else
{
if (il2cpp_codegen_method_is_interface_method(targetMethod))
InterfaceActionInvoker0::Invoke(il2cpp_codegen_method_get_slot(targetMethod), il2cpp_codegen_method_get_declaring_type(targetMethod), targetThis);
else
VirtActionInvoker0::Invoke(il2cpp_codegen_method_get_slot(targetMethod), targetThis);
}
}
else
{
typedef void (*FunctionPointerType) (void*, const RuntimeMethod*);
((FunctionPointerType)targetMethodPointer)(targetThis, targetMethod);
}
}
}
}
// System.IAsyncResult UnityEngine.AI.NavMesh_OnNavMeshPreUpdate::BeginInvoke(System.AsyncCallback,System.Object)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR RuntimeObject* OnNavMeshPreUpdate_BeginInvoke_m8B7FF1B745E38190A2B744775602508E77B291FA (OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * __this, AsyncCallback_tA7921BEF974919C46FF8F9D9867C567B200BB0EA * ___callback0, RuntimeObject * ___object1, const RuntimeMethod* method)
{
void *__d_args[1] = {0};
return (RuntimeObject*)il2cpp_codegen_delegate_begin_invoke((RuntimeDelegate*)__this, __d_args, (RuntimeDelegate*)___callback0, (RuntimeObject*)___object1);
}
// System.Void UnityEngine.AI.NavMesh_OnNavMeshPreUpdate::EndInvoke(System.IAsyncResult)
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void OnNavMeshPreUpdate_EndInvoke_mA263F64ADF01540E24327DDB24BD334539B1B4D2 (OnNavMeshPreUpdate_t5E34F761F39A1F6B898F0E729B36C0782B92D572 * __this, RuntimeObject* ___result0, const RuntimeMethod* method)
{
il2cpp_codegen_delegate_end_invoke((Il2CppAsyncResult*) ___result0, 0);
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
|
[
"30692436+LongNguyen99@users.noreply.github.com"
] |
30692436+LongNguyen99@users.noreply.github.com
|
3f42462208a13184fb1533a81ca85c4b78cfc500
|
1ba46d45a09abc75aea3f6fe5a078b4245fe00e1
|
/Duibrowser/src/duibrowser/DirectUI/UICombo.h
|
9f3baaa66da8f85dcddd4fbf8c2eeb7ba65e2a1d
|
[] |
no_license
|
visi/DuiBrowser
|
a81bace2b8a3ebb665d349f56fba4ed1201d5f7f
|
03db25634fe8696ee060e1c01bff8fa0911fcba8
|
refs/heads/master
| 2020-06-04T22:10:13.882734
| 2014-08-17T00:12:40
| 2014-08-17T00:12:40
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,035
|
h
|
//
//
// DirectUI - UI Library
//
// Written by Bjarke Viksoe (bjarke@viksoe.dk)
// Copyright (c) 2006-2007 Bjarke Viksoe.
//
// This code may be used in compiled form in any way you desire. These
// source files may be redistributed by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name is included.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to you or your
// computer whatsoever. It's free, so don't hassle me about it.
//
////
// Acknowledgements :
// Bjarke Viksoe (http://www.viksoe.dk/code/windowless1.htm)
//
//
//
// Beware of bugs.
//
//
//
////////////////////////////////////////////////////////
#ifndef __UICOMBO_H__
#define __UICOMBO_H__
#ifdef _MSC_VER
#pragma once
#endif
#include "UICommonControls.h"
namespace DuiLib {
/////////////////////////////////////////////////////////////////////////////////////
//
class CComboWnd;
class CEditWnd;
class UILIB_API CComboUI : public CContainerUI, public IEditUI, public IListOwnerUI
{
friend CComboWnd;
public:
typedef enum enumComboDropType
{
COMBODROP_SIMPLE = 1,
COMBODROP_DOWN = 2,
COMBODROP_LIST = 3
};
enum eDropBoxAlign
{
DROPBOXALIGN_LEFT = 0x00000001,
DROPBOXALIGN_RIGHT = 0x00000002,
DROPBOXALIGN_TOP = 0x00000004,
DROPBOXALIGN_BOTTOM = 0x00000008,
};
CComboUI();
~CComboUI();
LPCTSTR GetClass() const;
LPVOID GetInterface(LPCTSTR pstrName);
void DoInit();
UINT GetControlFlags() const;
void SetEnabled(bool bEnable = true);
CStdString GetDropBoxAttributeList();
void SetDropBoxAttributeList(LPCTSTR pstrList);
SIZE GetDropBoxSize() const;
void SetDropBoxSize(SIZE szDropBox);
UINT GetDropType() const;
void SetDropType(UINT uDropType);
bool SetItemIndex(CControlUI* pControl, int iIndex);
bool Add(CControlUI* pControl);
bool AddAt(CControlUI* pControl, int iIndex);
bool Remove(CControlUI* pControl);
bool RemoveAt(int iIndex);
void RemoveAll();
bool ActivateDropWnd();
UINT GetDropBoxAlign() const;
void SetDropBoxAlign(UINT align);
RECT GetTextPadding() const;
void SetTextPadding(RECT rc);
LPCTSTR GetNormalImage() const;
void SetNormalImage(LPCTSTR pStrImage);
LPCTSTR GetHotImage() const;
void SetHotImage(LPCTSTR pStrImage);
LPCTSTR GetPushedImage() const;
void SetPushedImage(LPCTSTR pStrImage);
LPCTSTR GetFocusedImage() const;
void SetFocusedImage(LPCTSTR pStrImage);
LPCTSTR GetDisabledImage() const;
void SetDisabledImage(LPCTSTR pStrImage);
LPCTSTR GetDropBtnImage() const;
void SetDropBtnImage(LPCTSTR pStrImage);
void SetItemFont(int index);
void SetItemTextStyle(UINT uStyle);
RECT GetItemTextPadding() const;
void SetItemTextPadding(RECT rc);
DWORD GetItemTextColor() const;
void SetItemTextColor(DWORD dwTextColor);
DWORD GetItemBkColor() const;
void SetItemBkColor(DWORD dwBkColor);
LPCTSTR GetItemImage() const;
void SetItemImage(LPCTSTR pStrImage);
DWORD GetSelectedItemTextColor() const;
void SetSelectedItemTextColor(DWORD dwTextColor);
DWORD GetSelectedItemBkColor() const;
void SetSelectedItemBkColor(DWORD dwBkColor);
LPCTSTR GetSelectedItemImage() const;
void SetSelectedItemImage(LPCTSTR pStrImage);
DWORD GetHotItemTextColor() const;
void SetHotItemTextColor(DWORD dwTextColor);
DWORD GetHotItemBkColor() const;
void SetHotItemBkColor(DWORD dwBkColor);
LPCTSTR GetHotItemImage() const;
void SetHotItemImage(LPCTSTR pStrImage);
DWORD GetDisabledItemTextColor() const;
void SetDisabledItemTextColor(DWORD dwTextColor);
DWORD GetDisabledItemBkColor() const;
void SetDisabledItemBkColor(DWORD dwBkColor);
LPCTSTR GetDisabledItemImage() const;
void SetDisabledItemImage(LPCTSTR pStrImage);
DWORD GetItemLineColor() const;
void SetItemLineColor(DWORD dwLineColor);
bool IsItemShowHtml();
void SetItemShowHtml(bool bShowHtml = true);
SIZE EstimateSize(SIZE szAvailable);
void SetPos(RECT rc);
void DoEvent(TEventUI& event);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
void DoPaint(void* ctx, const RECT& rcPaint);
void PaintText(void* ctx);
void PaintStatusImage(void* ctx);
void PaintBorder(void* ctx);
void PaintDropdownButton(void* ctx);
//Parent IEditUI
virtual CControlUI* const GetHostedControl();
virtual LPCTSTR GetEditClass() const;
virtual CRect GetEditPos();
virtual RECT GetEditTextPadding() const;
virtual DWORD GetEditTextColor();
virtual bool IsPasswordMode() const;
virtual TCHAR GetPasswordChar() const;
virtual CPaintManagerUI* GetManager() const;
virtual UINT GetMaxChar();
virtual CStdString GetText() const;
virtual void SetText(LPCTSTR pstrText);
virtual bool IsEnabled() const;
virtual bool IsReadOnly() const;
virtual CStdString GetName() const;
virtual void SetEidtWndNull();
virtual bool IsMultiLine() const;
#if(WINVER >= 0x0400)
virtual bool IsDigitalNumber() const;
#endif
virtual DWORD GetBkColor() const;
//Parent IListOwnerUI
virtual TListInfoUI* GetListInfo();
virtual int GetCurSel() const;
virtual bool SelectItem(int iIndex, bool bSendNofitied = true);
virtual bool Activate();
protected:
CComboWnd* m_pWindow;
CEditWnd* m_pEditWnd;
UINT m_uDropBoxAlign;
UINT m_uDropType;
int m_iCurSel;
RECT m_rcTextPadding;
CStdString m_sDropBoxAttributes;
SIZE m_szDropBox;
RECT m_rcDropBtn;
UINT m_uButtonState;
CStdString m_sNormalImage;
CStdString m_sHotImage;
CStdString m_sPushedImage;
CStdString m_sFocusedImage;
CStdString m_sDisabledImage;
CStdString m_sDropBtnImage;
TListInfoUI m_ListInfo;
};
} // namespace DuiLib
#endif // __UICOMBO_H__
|
[
"achellies@163.com"
] |
achellies@163.com
|
865cbd85f217bc3345d200e279eff04577d70a9d
|
6b40e9cba1dd06cd31a289adff90e9ea622387ac
|
/Develop/Server/GameServerOck/main/GBuff.cpp
|
4c34150ec711810dce8be301deb7af28ca4656a7
|
[] |
no_license
|
AmesianX/SHZPublicDev
|
c70a84f9170438256bc9b2a4d397d22c9c0e1fb9
|
0f53e3b94a34cef1bc32a06c80730b0d8afaef7d
|
refs/heads/master
| 2022-02-09T07:34:44.339038
| 2014-06-09T09:20:04
| 2014-06-09T09:20:04
| null | 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 9,822
|
cpp
|
#include "StdAfx.h"
#include "GBuff.h"
#include "GEntityPlayer.h"
#include "GBuffInfo.h"
#include "CCommandTable.h"
#include "GPartySystem.h"
#include "GGlobal.h"
#include "GCommand.h"
#include "GBuffReleaser.h"
#include "GBuffInstantApplier.h"
#include "GBuffModifierApplier.h"
#include "GBuffTriggerApplier.h"
#include "GBuffRouter.h"
#include "GEFfectTimingChecker.h"
#include "GUseCostMgr.h"
#include "GBuffStack.h"
#include "GBuffScript.h"
#include "GBuffPaletteChanger.h"
#include "GBuffEquipmentChanger.h"
GBuff::GBuff( GEntitySync* pOwner, GBuffInfo* pBuffInfo, float fDurationTime, float fPeriodTime, GTalentInfo* pTalentInfo/*=NULL*/, MUID uidUser/*=MUID::Invalid()*/ )
: m_pOwner(pOwner)
, m_pInfo(pBuffInfo)
, m_pTalentInfo(pTalentInfo)
, m_uidUser(uidUser)
, m_bInifinity(false)
, m_nDestroyType(DESTROY_NONE)
, m_pInstantApplyer(NULL)
, m_pModifierApplyer(NULL)
, m_pTriggerApplyer(NULL)
, m_pRouter(NULL)
, m_pStack(NULL)
, m_bGainEffectOccured(false)
, m_pPaletteChanger(NULL)
, m_pEquipmentChanger(NULL)
{
DCHECK(pOwner);
DCHECK(pBuffInfo);
m_pReleaser = new GBuffReleaser(this);
m_pEffectTimingChecker = new GEFfectTimingChecker();
m_pBuffScript = new GBuffScript();
if (m_pOwner->IsActor())
{
GEntityActor* pOwnerActor = ToEntityActor(m_pOwner);
pOwnerActor->AttachObserver(m_pReleaser);
pOwnerActor->AttachObserver(m_pEffectTimingChecker);
}
UpdateBuffTime(fDurationTime, fPeriodTime);
m_pInstantApplyer = new GBuffInstantApplier(this);
m_pModifierApplyer = new GBuffModifierApplier(this);
m_pTriggerApplyer = new GBuffTriggerApplier(this);
m_pEffectTimingChecker->AddListener(m_pInfo->m_Condition.nEffectConditionType, m_pInstantApplyer);
m_pEffectTimingChecker->AddListener(m_pInfo->m_Condition.nEffectConditionType, m_pModifierApplyer);
m_pEffectTimingChecker->AddListener(m_pInfo->m_TriggeredBuff.nTiming, m_pTriggerApplyer);
m_pEffectTimingChecker->AddListener(TC_BUFF_DUPLICATED, m_pModifierApplyer); // 중복 버프 처리를 위한 구독
AttachObserver(m_pEffectTimingChecker);
AttachObserver(m_pBuffScript);
if (pOwner->IsPlayer())
{
if (pBuffInfo->m_bUseChangePalette)
{
m_pPaletteChanger = new GBuffPaletteChanger();
AttachObserver(m_pPaletteChanger);
}
if (pBuffInfo->m_bUseChangeEquipmentSlot)
{
m_pEquipmentChanger = new GBuffEquipmentChanger();
AttachObserver(m_pEquipmentChanger);
}
}
if (IsStackable())
{
m_pStack = new GBuffStack(this);
m_pStack->Increase(fDurationTime);
m_pEffectTimingChecker->AddListener(TC_BUFF_STACKED, m_pModifierApplyer); // 중복 버프 처리를 위한 구독
}
m_pRouter = new GBuffRouter(this);
}
GBuff::~GBuff(void)
{
if (m_pOwner->IsActor())
{
GEntityActor* pOwnerActor = ToEntityActor(m_pOwner);
pOwnerActor->DetachObserver(m_pReleaser);
pOwnerActor->DetachObserver(m_pEffectTimingChecker);
}
DetachObserver(m_pEffectTimingChecker);
SAFE_DELETE(m_pEffectTimingChecker);
SAFE_DELETE(m_pReleaser);
SAFE_DELETE(m_pInstantApplyer);
SAFE_DELETE(m_pModifierApplyer);
SAFE_DELETE(m_pTriggerApplyer);
SAFE_DELETE(m_pRouter);
SAFE_DELETE(m_pStack);
SAFE_DELETE(m_pBuffScript);
SAFE_DELETE(m_pPaletteChanger);
SAFE_DELETE(m_pEquipmentChanger);
}
bool GBuff::Start()
{
// 타이머 작동
m_rgrExpire.Start();
m_rgrPeriod.Start();
m_rgrTickCost.Start();
if (!m_pOwner)
return false; // Owner 없음
if (!m_pOwner->GetField())
return false; // 필드 없음
return OnGain();
}
bool GBuff::Finish(bool bRoute)
{
return OnLost(bRoute);
}
void GBuff::PreUpdate( float fDelta )
{
m_pReleaser->Update(fDelta);
}
bool GBuff::Update( float fDelta )
{
PFI_BLOCK_THISFUNC(6611); // test
if (!m_bGainEffectOccured)
{
OnGain();
}
// 유지비용 처리
Update_Maintenance(fDelta);
// 주기적인 효과
if (Update_Period(fDelta))
return true; // 소유자가 죽음, 이미 this는 삭제되었으므로 완료처리는 하지 않음
// 만료 처리
Update_Expired(fDelta);
return false;
}
void GBuff::CancelForced()
{
m_nDestroyType = DESTROY_CANCELLED;
}
void GBuff::Cancel()
{
if (m_pStack)
{
m_pStack->Decrease();
if (!m_pStack->IsExpired())
return; // 스택이 남아있음
}
CancelForced();
}
void GBuff::Dispel()
{
if (m_pStack)
{
m_pStack->Decrease();
if (!m_pStack->IsExpired())
return; // 스택이 남아있음
}
m_nDestroyType = DESTROY_DISPELLED;
}
int GBuff::GetBuffID()
{
VALID_RET(m_pInfo, false);
return m_pInfo->m_nID;
}
MUID GBuff::GetUserUID()
{
return m_uidUser;
}
GTalentInfo* GBuff::GetUserTalentInfo()
{
return m_pTalentInfo;
}
bool GBuff::HasPeriodEffect()
{
return m_rgrPeriod.GetTickTime() > 0.0f;
}
bool GBuff::IsInfinite() const
{
return m_bInifinity;
}
int GBuff::GetBuffStackSlot()
{
VALID_RET(m_pInfo, false);
return m_pInfo->m_nStackSlot;
}
int GBuff::GetBuffStackPower()
{
VALID_RET(m_pInfo, false);
return m_pInfo->m_nStackPower;
}
float GBuff::GetDurationTime()
{
return m_rgrExpire.GetTickTime();
}
float GBuff::GetRemainTime()
{
return m_rgrExpire.GetTickTime() - m_rgrExpire.GetElapsedTime();
}
float GBuff::GetPeriodTime()
{
return m_rgrPeriod.GetTickTime();
}
float GBuff::GetRemainNextPeriodTime()
{
return m_rgrPeriod.GetTickTime() - m_rgrPeriod.GetElapsedTime();
}
void GBuff::UpdateBuffTime(float fDurationTime, float fPeriodTime)
{
m_bInifinity = (fDurationTime == BUFF_DURATION_INFINITY);
if (!m_bInifinity &&
fDurationTime < fPeriodTime)
{
fDurationTime = fPeriodTime;
}
m_rgrExpire.SetElapsedTime(0.0f);
m_rgrExpire.SetTickTime(fDurationTime);
m_rgrPeriod.SetTickTime(fPeriodTime);
m_rgrTickCost.SetTickTime(1.0f); // 유지비용은 초단위로 지불함
}
bool GBuff::IsGone() const
{
return GetDestroyType() != DESTROY_NONE;
}
bool GBuff::OnGain()
{
VALID_RET(m_pOwner, false);
VALID_RET(m_pInfo, false);
if (m_bGainEffectOccured)
return false; // 중복 적용됨
m_bGainEffectOccured = true;
if (m_pOwner->IsDead())
return false;
// 버프 얻음 이벤트 호출
if (m_pOwner->IsActor())
{
ToEntityActor(m_pOwner)->OnGainBuff(m_pInfo->m_nID);
}
__super::OnGain(m_uidUser, m_pOwner, m_pInfo);
return false;
}
bool GBuff::OnLost(bool bRoute)
{
VALID_RET(m_pOwner, false);
VALID_RET(m_pInfo, false);
__super::OnLost(m_uidUser, m_pOwner, m_pInfo, bRoute);
// 버프 제거 이벤트 호출
if (m_pOwner->IsActor())
{
ToEntityActor(m_pOwner)->OnLostBuff(m_pInfo->m_nID);
}
return false;
}
void GBuff::OnDestry()
{
switch (GetDestroyType())
{
case DESTROY_EXPIRED: { OnExpired(m_uidUser, m_pOwner, m_pInfo); }break;
case DESTROY_CANCELLED: { OnCancelled(); }break;
case DESTROY_DISPELLED: { OnDispelled(); }break;
}
}
bool GBuff::OnPeriod()
{
VALID_RET(m_pOwner, false);
VALID_RET(m_pInfo, false);
if (m_pOwner->IsDead())
return false;
// 처리 못했던 틱효과 일괄 처리
int nTickCounter = m_rgrPeriod.GetTickCounter();
for (int i=0; i<nTickCounter; i++)
{
__super::OnPeriod();
}
return false;
}
void GBuff::OnStacked( float fDurationTime, float fPeriodTime )
{
VALID(m_pStack);
UpdateBuffTime(fDurationTime, fPeriodTime);
m_pStack->Increase(fDurationTime);
__super::OnStacked(fDurationTime, fPeriodTime);
if (GetStackCount() >= GetInfo()->m_nStackMaxCount)
{
__super::OnMaxStacked();
}
}
void GBuff::OnDuplicated( float fDurationTime, float fPeriodTime, MUID uidUser )
{
m_uidUser = uidUser;
UpdateBuffTime(fDurationTime, fPeriodTime);
__super::OnDuplicated(m_uidUser, m_pOwner, m_pInfo);
}
bool GBuff::CheckEvent(TALENT_CONDITION nCondition)
{
return (m_pInfo->m_Condition.nEffectConditionType == nCondition);
}
void GBuff::Update_Maintenance( float fDelta )
{
if (!m_pOwner->IsActor())
return; // 액터가 아니면 유지비용 계산하지 않음
if (!m_rgrTickCost.IsReady(fDelta))
return; // 틱 대기
// 틱 비용을 지불하기 위한 객체
GUseCostMgr UseCostMgr;
bool bPaid =
UseCostMgr.Pay_BuffMaintenanceCost(ToEntityActor(m_pOwner), m_pInfo, m_rgrTickCost.GetTickCounter());
if (!bPaid)
{
// 비용을 지불하지 못하면 만료
m_nDestroyType = DESTROY_EXPIRED;
}
}
bool GBuff::Update_Period( float fDelta )
{
if (!HasPeriodEffect())
return false; // 주기 효과 없음
if (!m_rgrPeriod.IsReady(fDelta))
return false; // 틱 대기
return OnPeriod();
}
void GBuff::Update_Expired( float fDelta )
{
if (!IsInfinite())
{
if (m_pStack)
{
m_pStack->Update_Expired(fDelta);
if (m_pStack->IsExpired())
{
m_nDestroyType = DESTROY_EXPIRED;
return;
}
}
if (m_rgrExpire.IsReady(fDelta))
{
// 만료시간 지남
m_nDestroyType = DESTROY_EXPIRED;
return;
}
}
}
GBuff::DESTROY_TYPE GBuff::GetDestroyType() const
{
return m_nDestroyType;
}
bool GBuff::IsDebuff() const
{
return (GetInfo()->IsDebuff());
}
bool GBuff::IsStackable() const
{
return (GetInfo()->m_nStackType != BUFFSTACK_NONE);
}
int GBuff::GetStackCount() const
{
if (!m_pStack)
return 1; // 스택이 없는 것은 1개짜리 버프
return m_pStack->GetCount();
}
bool GBuff::IsEchant() const
{
if (!GetInfo())
return false;
return GetInfo()->IsEnchant();
}
bool GBuff::IsChangeEquipment() const
{
if (!GetInfo())
return false;
if (GetInfo()->m_bUseChangeEquipmentSlot)
return true;
if (GetInfo()->m_bUseChangePalette)
return true;
return false;
}
|
[
"shzdev@8fd9ef21-cdc5-48af-8625-ea2f38c673c4"
] |
shzdev@8fd9ef21-cdc5-48af-8625-ea2f38c673c4
|
97cbf82fa0efd79f454caaaf388fe2ff93406d95
|
4cb98b7fe0654a928deea9ead312eb0861e4e73c
|
/VS/Il2CppOutputProject/Source/il2cppOutput/Il2CppReversePInvokeWrapperTable.cpp
|
6ce051e89d0028d36a89ae4cf1c1c354db3ba8ec
|
[] |
no_license
|
Tuan-Mai/ComputingInAR-FinalProject
|
3e78feb6b9deda1512d01b924b790811cd0c2197
|
930c6b1fccbf1e2c7a0d2257abaff8acd4cbf97e
|
refs/heads/master
| 2020-04-08T12:52:16.130981
| 2018-12-10T17:31:31
| 2018-12-10T17:31:31
| 159,365,065
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,763
|
cpp
|
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include "il2cpp-class-internals.h"
#include "codegen/il2cpp-codegen.h"
#include "il2cpp-object-internals.h"
// System.Char[]
struct CharU5BU5D_t3528271667;
// System.String
struct String_t;
// System.Void
struct Void_t1185182177;
struct InteractionSourceState_t3425813774 ;
struct unitytls_errorstate_t2875872539 ;
struct unitytls_key_ref_t1942754627 ;
struct unitytls_tlsctx_t2030371563 ;
struct unitytls_x509list_ref_t2029050115 ;
struct unitytls_x509name_t1095957490 ;
#ifndef RUNTIMEOBJECT_H
#define RUNTIMEOBJECT_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Object
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RUNTIMEOBJECT_H
#ifndef VALUETYPE_T3640485471_H
#define VALUETYPE_T3640485471_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.ValueType
struct ValueType_t3640485471 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.ValueType
struct ValueType_t3640485471_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.ValueType
struct ValueType_t3640485471_marshaled_com
{
};
#endif // VALUETYPE_T3640485471_H
#ifndef UNITYTLS_X509LIST_REF_T2029050115_H
#define UNITYTLS_X509LIST_REF_T2029050115_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// Mono.Unity.UnityTls/unitytls_x509list_ref
struct unitytls_x509list_ref_t2029050115
{
public:
// System.UInt64 Mono.Unity.UnityTls/unitytls_x509list_ref::handle
uint64_t ___handle_0;
public:
inline static int32_t get_offset_of_handle_0() { return static_cast<int32_t>(offsetof(unitytls_x509list_ref_t2029050115, ___handle_0)); }
inline uint64_t get_handle_0() const { return ___handle_0; }
inline uint64_t* get_address_of_handle_0() { return &___handle_0; }
inline void set_handle_0(uint64_t value)
{
___handle_0 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UNITYTLS_X509LIST_REF_T2029050115_H
#ifndef ENUM_T4135868527_H
#define ENUM_T4135868527_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Enum
struct Enum_t4135868527 : public ValueType_t3640485471
{
public:
public:
};
struct Enum_t4135868527_StaticFields
{
public:
// System.Char[] System.Enum::enumSeperatorCharArray
CharU5BU5D_t3528271667* ___enumSeperatorCharArray_0;
public:
inline static int32_t get_offset_of_enumSeperatorCharArray_0() { return static_cast<int32_t>(offsetof(Enum_t4135868527_StaticFields, ___enumSeperatorCharArray_0)); }
inline CharU5BU5D_t3528271667* get_enumSeperatorCharArray_0() const { return ___enumSeperatorCharArray_0; }
inline CharU5BU5D_t3528271667** get_address_of_enumSeperatorCharArray_0() { return &___enumSeperatorCharArray_0; }
inline void set_enumSeperatorCharArray_0(CharU5BU5D_t3528271667* value)
{
___enumSeperatorCharArray_0 = value;
Il2CppCodeGenWriteBarrier((&___enumSeperatorCharArray_0), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.Enum
struct Enum_t4135868527_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.Enum
struct Enum_t4135868527_marshaled_com
{
};
#endif // ENUM_T4135868527_H
#ifndef INTPTR_T_H
#define INTPTR_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.IntPtr
struct IntPtr_t
{
public:
// System.Void* System.IntPtr::m_value
void* ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(IntPtr_t, ___m_value_0)); }
inline void* get_m_value_0() const { return ___m_value_0; }
inline void** get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(void* value)
{
___m_value_0 = value;
}
};
struct IntPtr_t_StaticFields
{
public:
// System.IntPtr System.IntPtr::Zero
intptr_t ___Zero_1;
public:
inline static int32_t get_offset_of_Zero_1() { return static_cast<int32_t>(offsetof(IntPtr_t_StaticFields, ___Zero_1)); }
inline intptr_t get_Zero_1() const { return ___Zero_1; }
inline intptr_t* get_address_of_Zero_1() { return &___Zero_1; }
inline void set_Zero_1(intptr_t value)
{
___Zero_1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INTPTR_T_H
#ifndef VOID_T1185182177_H
#define VOID_T1185182177_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void
struct Void_t1185182177
{
public:
union
{
struct
{
};
uint8_t Void_t1185182177__padding[1];
};
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // VOID_T1185182177_H
#ifndef SSLSTATUS_T191981556_H
#define SSLSTATUS_T191981556_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// Mono.AppleTls.SslStatus
struct SslStatus_t191981556
{
public:
// System.Int32 Mono.AppleTls.SslStatus::value__
int32_t ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(SslStatus_t191981556, ___value___2)); }
inline int32_t get_value___2() const { return ___value___2; }
inline int32_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(int32_t value)
{
___value___2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SSLSTATUS_T191981556_H
#ifndef UNITYTLS_X509VERIFY_RESULT_T846480546_H
#define UNITYTLS_X509VERIFY_RESULT_T846480546_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// Mono.Unity.UnityTls/unitytls_x509verify_result
struct unitytls_x509verify_result_t846480546
{
public:
// System.UInt32 Mono.Unity.UnityTls/unitytls_x509verify_result::value__
uint32_t ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(unitytls_x509verify_result_t846480546, ___value___2)); }
inline uint32_t get_value___2() const { return ___value___2; }
inline uint32_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(uint32_t value)
{
___value___2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // UNITYTLS_X509VERIFY_RESULT_T846480546_H
#ifndef EVENTTYPE_T857394641_H
#define EVENTTYPE_T857394641_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.XR.WSA.Input.InteractionManager/EventType
struct EventType_t857394641
{
public:
// System.Int32 UnityEngine.XR.WSA.Input.InteractionManager/EventType::value__
int32_t ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(EventType_t857394641, ___value___2)); }
inline int32_t get_value___2() const { return ___value___2; }
inline int32_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(int32_t value)
{
___value___2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // EVENTTYPE_T857394641_H
#ifndef INTERACTIONSOURCEPRESSTYPE_T876504354_H
#define INTERACTIONSOURCEPRESSTYPE_T876504354_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.XR.WSA.Input.InteractionSourcePressType
struct InteractionSourcePressType_t876504354
{
public:
// System.Int32 UnityEngine.XR.WSA.Input.InteractionSourcePressType::value__
int32_t ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(InteractionSourcePressType_t876504354, ___value___2)); }
inline int32_t get_value___2() const { return ___value___2; }
inline int32_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(int32_t value)
{
___value___2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INTERACTIONSOURCEPRESSTYPE_T876504354_H
extern "C" int32_t DEFAULT_CALL ReversePInvokeWrapper_AppleTlsContext_NativeReadCallback_m2315213031(intptr_t ___ptr0, intptr_t ___data1, intptr_t* ___dataLength2);
extern "C" int32_t DEFAULT_CALL ReversePInvokeWrapper_AppleTlsContext_NativeWriteCallback_m2714148351(intptr_t ___ptr0, intptr_t ___data1, intptr_t* ___dataLength2);
extern "C" intptr_t CDECL ReversePInvokeWrapper_UnityTlsContext_WriteCallback_m574372540(void* ___userData0, uint8_t* ___data1, intptr_t ___bufferLen2, unitytls_errorstate_t2875872539 * ___errorState3);
extern "C" intptr_t CDECL ReversePInvokeWrapper_UnityTlsContext_ReadCallback_m3273793046(void* ___userData0, uint8_t* ___buffer1, intptr_t ___bufferLen2, unitytls_errorstate_t2875872539 * ___errorState3);
extern "C" uint32_t CDECL ReversePInvokeWrapper_UnityTlsContext_VerifyCallback_m2272716052(void* ___userData0, unitytls_x509list_ref_t2029050115 ___chain1, unitytls_errorstate_t2875872539 * ___errorState2);
extern "C" void CDECL ReversePInvokeWrapper_UnityTlsContext_CertificateCallback_m3892869084(void* ___userData0, unitytls_tlsctx_t2030371563 * ___ctx1, uint8_t* ___cn2, intptr_t ___cnLen3, unitytls_x509name_t1095957490 * ___caList4, intptr_t ___caListLen5, unitytls_x509list_ref_t2029050115 * ___chain6, unitytls_key_ref_t1942754627 * ___key7, unitytls_errorstate_t2875872539 * ___errorState8);
extern "C" int32_t CDECL ReversePInvokeWrapper_DeflateStreamNative_UnmanagedRead_m255710264(intptr_t ___buffer0, int32_t ___length1, intptr_t ___data2);
extern "C" int32_t CDECL ReversePInvokeWrapper_DeflateStreamNative_UnmanagedWrite_m232731864(intptr_t ___buffer0, int32_t ___length1, intptr_t ___data2);
extern "C" void DEFAULT_CALL ReversePInvokeWrapper_InteractionManager_OnSourceEvent_m1799627704(int32_t ___eventType0, InteractionSourceState_t3425813774 * ___state1, int32_t ___pressType2);
extern const Il2CppMethodPointer g_ReversePInvokeWrapperPointers[9] =
{
reinterpret_cast<Il2CppMethodPointer>(ReversePInvokeWrapper_AppleTlsContext_NativeReadCallback_m2315213031),
reinterpret_cast<Il2CppMethodPointer>(ReversePInvokeWrapper_AppleTlsContext_NativeWriteCallback_m2714148351),
reinterpret_cast<Il2CppMethodPointer>(ReversePInvokeWrapper_UnityTlsContext_WriteCallback_m574372540),
reinterpret_cast<Il2CppMethodPointer>(ReversePInvokeWrapper_UnityTlsContext_ReadCallback_m3273793046),
reinterpret_cast<Il2CppMethodPointer>(ReversePInvokeWrapper_UnityTlsContext_VerifyCallback_m2272716052),
reinterpret_cast<Il2CppMethodPointer>(ReversePInvokeWrapper_UnityTlsContext_CertificateCallback_m3892869084),
reinterpret_cast<Il2CppMethodPointer>(ReversePInvokeWrapper_DeflateStreamNative_UnmanagedRead_m255710264),
reinterpret_cast<Il2CppMethodPointer>(ReversePInvokeWrapper_DeflateStreamNative_UnmanagedWrite_m232731864),
reinterpret_cast<Il2CppMethodPointer>(ReversePInvokeWrapper_InteractionManager_OnSourceEvent_m1799627704),
};
|
[
"tuandinhmai@gmail.com"
] |
tuandinhmai@gmail.com
|
85d6c5b4d4a09fac67d01fa397719b688a5c5099
|
64c2b93afcfda11aefcccfb3604145fa00f5abb8
|
/serialconnector.h
|
bdc32b6374fc9c0b77c84a47a8e9dfa056fc9008
|
[] |
no_license
|
tamasstummer/ratlab_8_qt
|
91a6768fab6fe330bd7349f5d08312430dcf2640
|
b4fba46ca7a1658a0370e167da6132acbbe5a7e0
|
refs/heads/master
| 2021-05-20T09:45:47.484493
| 2020-04-01T16:37:46
| 2020-04-01T16:37:46
| 252,231,291
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 629
|
h
|
#ifndef SERIALCONNECTOR_H
#define SERIALCONNECTOR_H
#include <QObject>
#include <QVariant>
#include "serialsimulator.h"
class SerialConnector : public QObject
{
Q_OBJECT
public:
explicit SerialConnector(QObject *parent = nullptr);
SerialSimulator *serialsimulator;
QByteArray *buffer;
bool connectSerial();
bool disconnectSerial();
private:
void getMessage();
void decodeMessage(QString);
signals:
void tempChanged(QVariant);
void tiltChanged(QVariant);
void alarmChanged(QVariant);
private slots:
void serial_data_available_from_simulator();
};
#endif // SERIALCONNECTOR_H
|
[
"tamas.stummer@gmail.com"
] |
tamas.stummer@gmail.com
|
5ecbc5752a165a0b19298ec48f091f6bc85d2a17
|
6325638953353358c7243c6f292bbc55f6427d8d
|
/CodeChef/Beginner/ARRROT.cpp
|
7cd9a068228f57f34ebba5d0277728c4a8bb3e0c
|
[] |
no_license
|
bashu22tiwari/BashuTiwari-CP
|
60fc93488569c4e0cbc217f53aecd1bf38cc486f
|
99c1d9ea4ce7cb6114508683635d62f04dbd64b8
|
refs/heads/main
| 2023-08-13T04:43:24.578329
| 2021-09-27T20:37:53
| 2021-09-27T20:37:53
| 340,102,191
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 331
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int arr[n];
for(int i=0 ; i<n i ++){
cin >> arr[i];
}
int sum = 0;
for(int i=0 ; i<n ; i++){
sum+=arr[i];
}
int q;
cin >> q;
for(int i=0 ; i<q ; i++){
sum*=2;
}
cout << sum;
}
|
[
"55925918+bashu22tiwari@users.noreply.github.com"
] |
55925918+bashu22tiwari@users.noreply.github.com
|
49ce4487ba686c73b924075a52a96960fe69a6fa
|
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
|
/app/src/main/cpp/dir7941/dir22441/dir22442/dir22443/dir22444/dir22869/dir22870/dir22871/file23039.cpp
|
a5a028bd6e1ca81910ce78c7bbb060c65c4170e8
|
[] |
no_license
|
tgeng/HugeProject
|
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
|
4488d3b765e8827636ce5e878baacdf388710ef2
|
refs/heads/master
| 2022-08-21T16:58:54.161627
| 2020-05-28T01:54:03
| 2020-05-28T01:54:03
| 267,468,475
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 115
|
cpp
|
#ifndef file23039
#error "macro file23039 must be defined"
#endif
static const char* file23039String = "file23039";
|
[
"tgeng@google.com"
] |
tgeng@google.com
|
af82470453808e06295b6d25d3e64a99fc473d1d
|
60d985c94433c0a341571e3639140124f5800faa
|
/src/shaders/StaticShader.h
|
178d5f0b6fc2e0a5636fc1446c4df377ac6faecd
|
[] |
no_license
|
raulgrell/Vumod
|
a9676c8592d310eae8e456414c994ac2c0600990
|
10ca6dab8346549ae119c21dc519ad8e420bdfe4
|
refs/heads/master
| 2022-06-08T17:48:32.813281
| 2022-05-05T20:56:31
| 2022-05-05T20:56:31
| 191,601,735
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,308
|
h
|
#pragma once
#include "ShaderGL.h"
#include <light/Light.h>
#include <camera/Camera.h>
#include <vector>
class Camera;
class StaticShader: public ShaderGL
{
public:
StaticShader();
void BindAttributes() override;
void GetUniformLocations() override;
void LoadShineVariables(float damper, float reflectivity);
void LoadTransformationMatrix(const Mat4 *matrix);
void LoadLights(std::vector<Light> &lights);
void LoadProjectionMatrix(Mat4& matrix);
void LoadViewMatrix(Camera &camera);
void LoadFakeLightingVariable(bool useFakeLighting);
void LoadSkyColor(float r, float g, float b);
void LoadFogVariables(float density, float gradient);
void LoadNumberOfRows(int numberOfRows);
void LoadTextureOffset(float x, float y);
void LoadClipPlane(Vec4& vec);
private:
static constexpr int MAX_LIGHTS = 4;
int location_transformationMatrix{};
int location_projectionMatrix{};
int location_viewMatrix{};
int location_lightPosition[MAX_LIGHTS]{};
int location_lightColor[MAX_LIGHTS]{};
int location_attenuation[MAX_LIGHTS]{};
int location_shineDamper{};
int location_reflectivity{};
int location_useFakeLighting{};
int location_skyColor{};
int location_fogDensity{};
int location_fogGradient{};
int location_numberOfRows{};
int location_textureOffset{};
int location_clipPlane{};
};
|
[
"raulgrell@gmail.com"
] |
raulgrell@gmail.com
|
ff373fbf1896a6742b28afcfdfafebe616470479
|
bfd0f52a7454b10a54dec4098c3234d6efd0523e
|
/热题100/树/538.把二叉搜索树转换为累加树.cpp
|
d6944d7389a5e37e147174c45430940195dd7abe
|
[] |
no_license
|
sherry3255/cooooode
|
ddde959068b0a9850e9982e8b65976caa36c5323
|
5de2c08c2dc4001a905b83c5efd30cf93f746a30
|
refs/heads/main
| 2023-05-04T08:14:34.667978
| 2021-05-23T16:42:31
| 2021-05-23T16:42:31
| 322,979,762
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 966
|
cpp
|
/*
* @lc app=leetcode.cn id=538 lang=cpp
*
* [538] 把二叉搜索树转换为累加树
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution {
public:
// 反序中序遍历二叉树,即为一个递减序列,先加和,再赋值给root
int sum = 0;
TreeNode* convertBST(TreeNode* root) {
if(root!=nullptr){
convertBST(root->right);
sum += root->val;
root->val = sum;
convertBST(root->left);
}
return root;
}
};
// 递归过程中有栈的开销,平均情况为O(nlogn),最坏的情况下,树为链状,为O(n).
// @lc code=end
|
[
"zhoubh@deepblueai.com"
] |
zhoubh@deepblueai.com
|
6ef124486aa992dc03fc0cf7d772504f91dc6f27
|
6a19da73cf8dadac5aa65a48e1fa5c47f40dc07f
|
/converter/linux/my_application.cc
|
bc5bfdd95cf52e2ab84f0c09eaacc909d9fb44db
|
[] |
no_license
|
sinaziaee/flutter_bootcamp
|
9fdce5da0947fdb40733d90db1b91bb57499f37b
|
855defe85be755424911141e0deac9fa6dc82e79
|
refs/heads/master
| 2023-08-15T12:07:03.511580
| 2021-09-15T07:28:57
| 2021-09-15T07:28:57
| 389,382,229
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,722
|
cc
|
#include "my_application.h"
#include <flutter_linux/flutter_linux.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include "flutter/generated_plugin_registrant.h"
struct _MyApplication {
GtkApplication parent_instance;
char** dart_entrypoint_arguments;
};
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
// Implements GApplication::activate.
static void my_application_activate(GApplication* application) {
MyApplication* self = MY_APPLICATION(application);
GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
// Use a header bar when running in GNOME as this is the common style used
// by applications and is the setup most users will be using (e.g. Ubuntu
// desktop).
// If running on X and not using GNOME then just use a traditional title bar
// in case the window manager does more exotic layout, e.g. tiling.
// If running on Wayland assume the header bar will work (may need changing
// if future cases occur).
gboolean use_header_bar = TRUE;
#ifdef GDK_WINDOWING_X11
GdkScreen *screen = gtk_window_get_screen(window);
if (GDK_IS_X11_SCREEN(screen)) {
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
use_header_bar = FALSE;
}
}
#endif
if (use_header_bar) {
GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "converter");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
}
else {
gtk_window_set_title(window, "converter");
}
gtk_window_set_default_size(window, 1280, 720);
gtk_widget_show(GTK_WIDGET(window));
g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
FlView* view = fl_view_new(project);
gtk_widget_show(GTK_WIDGET(view));
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
gtk_widget_grab_focus(GTK_WIDGET(view));
}
// Implements GApplication::local_command_line.
static gboolean my_application_local_command_line(GApplication* application, gchar ***arguments, int *exit_status) {
MyApplication* self = MY_APPLICATION(application);
// Strip out the first argument as it is the binary name.
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
g_autoptr(GError) error = nullptr;
if (!g_application_register(application, nullptr, &error)) {
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
}
g_application_activate(application);
*exit_status = 0;
return TRUE;
}
// Implements GObject::dispose.
static void my_application_dispose(GObject *object) {
MyApplication* self = MY_APPLICATION(object);
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
}
static void my_application_class_init(MyApplicationClass* klass) {
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
}
static void my_application_init(MyApplication* self) {}
MyApplication* my_application_new() {
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID,
"flags", G_APPLICATION_NON_UNIQUE,
nullptr));
}
|
[
"sinaziaee99@gmail.com"
] |
sinaziaee99@gmail.com
|
8469aad41f5fe1acfaed2a99322b6c34fc80deaa
|
e4960ccc6b4a81c906a8311e5282d54f3a869ef1
|
/Project/Phase4/sockets_phase4/Connection.h
|
e2a4154d91f27eb7ce9eebdca3100269d3dd315e
|
[] |
no_license
|
katerinachinnappan/CMPS-109
|
3f53bd72b30ae5caf5bad698c0c19a17f5771045
|
221c219106d37286682d86343a401fbc6345552f
|
refs/heads/master
| 2021-01-18T16:26:51.465923
| 2017-03-30T20:28:22
| 2017-03-30T20:28:22
| 86,744,797
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 918
|
h
|
#ifndef CONNECTION_H_INCLUDED
#define CONNECTION_H_INCLUDED
#include "TCPSocket.h"
#include "Thread.h"
#include "SRIMain.h"
#include "Thread.h"
#include "TCPSocket.h"
// A class representing a single connection form a client
class Connection : public Thread //Inherit from Thread
{
private:
TCPSocket * tcpSocket; // TCP Socket for communication with client
Connection * next_connection; // A way to build a linked list of connections for the
garbage collector to be able to track them
public:
Connection(TCPSocket * p_tcpSocket); // Constructor: Set client connected TCP socket
void * threadMainBody (void * arg); // Main thread body that serves the connection
void setNextConnection(Connection * connection); // Set the next pointer: used by the
Garbage Collector
Connection * getNextConnection (); // Get a pointer to the next connection
~Connection(); // Destructor
};
#endif // CONNECTION_H_INCLUDED
|
[
"katiachinnap@gmail.com"
] |
katiachinnap@gmail.com
|
92066db2d6bfbcee59d24a7fcc3c36ec964f3f64
|
6d72a386a7bbf7488d569e11216d3c6c6c073674
|
/leetcode/cpp/preimageSizeFZF/main.cpp
|
eab538d7472ed2fef6cf47c07b34510d72ea6bc0
|
[] |
no_license
|
Alwaysproblem/simplecode
|
aea5c5a910c357263be1a071bc555e2dab20e332
|
b1ee0ad390c9e1193109b97b8c66351aaa6f6b8b
|
refs/heads/master
| 2023-07-22T16:00:14.859769
| 2023-07-22T14:59:23
| 2023-07-22T14:59:23
| 165,994,898
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,479
|
cpp
|
/*
* @lc app=leetcode.cn id=793 lang=cpp
*
* [793] 阶乘函数后 K 个零
*/
#include <fmt/format.h>
#include <fmt/ranges.h>
#include <climits>
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
// @lc code=start
class Solution {
public:
long trailingZeroes(long n) {
long res = 0;
for (long d = n; d / 5 > 0; d = d / 5) {
res += d / 5;
}
return res;
}
long left_bound(int target) {
long lo = 0, hi = LONG_MAX - 1, mid = 0;
while (lo <= hi) {
mid = lo + (hi - lo) / 2;
if (trailingZeroes(mid) == target) {
hi = mid - 1;
} else if (trailingZeroes(mid) < target) {
lo = mid + 1;
} else if (trailingZeroes(mid) > target) {
hi = mid - 1;
}
}
return lo;
}
long right_bound(int target) {
long lo = 0, hi = LONG_MAX - 1, mid = 0;
while (lo <= hi) {
mid = lo + (hi - lo) / 2;
if (trailingZeroes(mid) == target) {
lo = mid + 1;
} else if (trailingZeroes(mid) < target) {
lo = mid + 1;
} else if (trailingZeroes(mid) > target) {
hi = mid - 1;
}
}
return hi;
}
int preimageSizeFZF(int K) {
// fmt::print("{}\n", right_bound(K));
// fmt::print("{}\n", left_bound(K));
return (int)(right_bound(K) - left_bound(K) + 1);
}
};
// @lc code=end
int main() {
int k = 0;
Solution sol;
int v = sol.preimageSizeFZF(k);
fmt::print("{}\n", v);
return 0;
}
|
[
"reganyang0415@gmail.com"
] |
reganyang0415@gmail.com
|
2b28f6e27b1cd96377bc9b642b821dae702de4d5
|
175dd1c18e2231c639509696a154a2f26be2a29f
|
/rysm-server/arduino/arduino.ino
|
bb04af099b2dc9927ab20f5fd42816252917843f
|
[] |
no_license
|
ADavidLiu/smart-cart
|
570d94248243f99331fb0971527f8efc166508b9
|
e5c612648b9bac65f79b71754f2c51174e9373b1
|
refs/heads/master
| 2020-03-18T15:30:05.271801
| 2018-06-20T03:52:53
| 2018-06-20T03:52:53
| 134,911,883
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 726
|
ino
|
#include <SPI.h>
#include <RFID.h>
#include "HX711.h"
#define SS_PIN 10
#define RST_PIN 9
#define DOUT A1
#define CLK A0
HX711 balanza(DOUT, CLK);
RFID rfid(SS_PIN,RST_PIN);
String id = "";
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.init();
balanza.read();
balanza.set_scale(439430.25);
balanza.tare(20);
}
void loop() {
float kg = balanza.get_units(20);
float gr = kg*1000;
if(rfid.isCard()) {
if(rfid.readCardSerial()) {
id = (String) rfid.serNum[0] + (String) rfid.serNum[1]
+ (String) rfid.serNum[2] + (String) rfid.serNum[3] + (String) rfid.serNum[4];
Serial.print(";" + id + ";" + ":" + (String) gr + ":");
}
}
delay(1000);
rfid.halt();
}
|
[
"adavidliuf@gmail.com"
] |
adavidliuf@gmail.com
|
33e09383359cc3100c13ba1f53c5f4625528aceb
|
0758066960d0990bd4ce76805f93d9bc7c2b9b0f
|
/CS Class work/CS 1700 Homework problems/P362A102.cpp
|
13444a80933420f76ea2bd4c53c838a037932845
|
[] |
no_license
|
mrsalt/USU
|
4acf7ecf84663491582a834f31f69cfd17938d58
|
49cbc7bbc597f6780338f11bf341c86579bb3c02
|
refs/heads/master
| 2020-08-26T22:39:36.728764
| 2019-10-24T00:50:08
| 2019-10-24T02:18:11
| 217,167,673
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 818
|
cpp
|
// 362
// marks
// Mark Salisbury
// P362A102.cpp
//Template functions must be implemented prior to their use, therefore, place the code for your
// template functions before main.
//A102. (template functions) (min) Read section 3.21 then do problem 3.58 from your text.
#include <iostream.h>
template <class T>
T min(T val1, T val2){
if (val1 < val2)
return val1;
else
return val2;
}
void main(void){
int a, b;
char c, d;
float e, f;
cout << "Enter two integers: ";
cin >> a >> b;
cout << "The smaller of the two is: " << min(a, b) << endl;
cout << "Enter two characters: ";
cin >> c >> d;
cout << "The smaller of the two is: " << min(c, d) << endl;
cout << "Enter two floats: ";
cin >> e >> f;
cout << "The smaller of the two is: " << min(e, f) << endl;
}
|
[
"fmark.salisbury@gmail.com"
] |
fmark.salisbury@gmail.com
|
8ce20ff55d21a3694d8cfd66cbbdafe663817893
|
304c4e10eb4290eb172085358555f22d91cc41a7
|
/examples/01_backend/LCDML_010_simpleThread/LCDML_010_simpleThread.ino
|
9459c57664b300bbfa13e57a160c3b9d681c49e0
|
[
"MIT"
] |
permissive
|
Ludy87/LCDMenuLib2
|
f975b71959bee5dc05b1e3b1e535f5d1af4b6210
|
8412024188c4fe6b2b7f2003528587f9df0380ca
|
refs/heads/master
| 2020-04-02T03:52:24.770213
| 2018-10-21T08:51:54
| 2018-10-21T08:51:54
| 153,989,031
| 0
| 0
|
MIT
| 2018-10-21T08:46:15
| 2018-10-21T08:46:15
| null |
UTF-8
|
C++
| false
| false
| 13,104
|
ino
|
// ============================================================
// Example: LCDML_simpleThread example
// ============================================================
// Description:
// This example includes the complete functionality over some
// tabs. All Tabs which are started with "LCDML_display_.."
// generates an output on the display / console / ....
// This example is for the author to test the complete functionality
//
// The simpleThread Library provides a method to to run more then
// one loop function. The loop functions are called with a priority
// and a time interval. The lib is not using interrupts.
// When a function is called it runs until the function end is reached.
//
// Download simple thread:
// https://github.com/Jomelo/simpleThread
//
// documentation (german):
// https://forum.arduino.cc/index.php?topic=165552.0
//
// ============================================================
// *********************************************************************
// includes
// *********************************************************************
#include <LCDMenuLib2.h>
#include <simpleThread.h>
// *********************************************************************
// LCDML display settings
// *********************************************************************
// settings for LCD
#define _LCDML_DISP_cols 20
#define _LCDML_DISP_rows 4
// *********************************************************************
// Prototypes
// *********************************************************************
void lcdml_menu_display();
void lcdml_menu_clear();
void lcdml_menu_control();
// *********************************************************************
// Objects
// *********************************************************************
LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL); // root menu element (do not change)
LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control);
// *********************************************************************
// LCDML MENU/DISP
// *********************************************************************
// LCDML_0 => layer 0
// LCDML_0_X => layer 1
// LCDML_0_X_X => layer 2
// LCDML_0_X_X_X => layer 3
// LCDML_0_... => layer ...
// *********************************************************************
// LCDML MENU/DISP
// *********************************************************************
// LCDML_0 => layer 0
// LCDML_0_X => layer 1
// LCDML_0_X_X => layer 2
// LCDML_0_X_X_X => layer 3
// LCDML_0_... => layer ...
// For beginners
// LCDML_add(id, prev_layer, new_num, lang_char_array, callback_function)
LCDML_add (0 , LCDML_0 , 1 , "Information" , mFunc_information); // this menu function can be found on "LCDML_display_menuFunction" tab
LCDML_add (1 , LCDML_0 , 2 , "Time info" , mFunc_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab
LCDML_add (2 , LCDML_0 , 3 , "Program" , NULL); // NULL = no menu function
LCDML_add (3 , LCDML_0_3 , 1 , "Blink Thread" , NULL); // NULL = no menu function
LCDML_add (4 , LCDML_0_3_1 , 1 , "Start Thread" , mFunc_thread_start); // Thread control (start)
LCDML_add (5 , LCDML_0_3_1 , 2 , "Stop Thread" , mFunc_thread_stop); // Thread control (stop)
LCDML_add (6 , LCDML_0_3_1_2 , 1 , "Warm" , NULL); // NULL = no menu function
LCDML_add (7 , LCDML_0_3_1_2 , 2 , "Cold" , NULL); // NULL = no menu function
LCDML_add (8 , LCDML_0_3_1_2 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab
LCDML_add (9 , LCDML_0_3_1 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab
LCDML_add (10 , LCDML_0_3 , 2 , "Program 2" , mFunc_p2); // this menu function can be found on "LCDML_display_menuFunction" tab
LCDML_add (11 , LCDML_0_3 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab
LCDML_add (12 , LCDML_0 , 4 , "Special" , NULL); // NULL = no menu function
LCDML_add (13 , LCDML_0_4 , 1 , "Go to Root" , mFunc_goToRootMenu); // this menu function can be found on "LCDML_display_menuFunction" tab
LCDML_add (14 , LCDML_0_4 , 2 , "Jump to Time info", mFunc_jumpTo_timer_info); // this menu function can be found on "LCDML_display_menuFunction" tab
LCDML_add (15 , LCDML_0_4 , 3 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab
// Advanced menu (for profit) part with more settings
// Example for one function and different parameters
// It is recommend to use parameters for switching settings like, (small drink, medium drink, big drink) or (200ml, 400ml, 600ml, 800ml) ...
// the parameter change can also be released with dynParams on the next example
// LCDMenuLib_add(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type )
LCDML_addAdvanced (16 , LCDML_0 , 5 , NULL, "Parameter" , NULL, 0, _LCDML_TYPE_default); // NULL = no menu function
LCDML_addAdvanced (17 , LCDML_0_5 , 1 , NULL, "Parameter 1" , mFunc_para, 10, _LCDML_TYPE_default); // NULL = no menu function
LCDML_addAdvanced (18 , LCDML_0_5 , 2 , NULL, "Parameter 2" , mFunc_para, 20, _LCDML_TYPE_default); // NULL = no menu function
LCDML_addAdvanced (19 , LCDML_0_5 , 3 , NULL, "Parameter 3" , mFunc_para, 30, _LCDML_TYPE_default); // NULL = no menu function
LCDML_add (20 , LCDML_0_5 , 4 , "Back" , mFunc_back); // this menu function can be found on "LCDML_display_menuFunction" tab
// Example for dynamic content
// 1. set the string to ""
// 2. use type _LCDML_TYPE_dynParam instead of _LCDML_TYPE_default
// this function type can not be used in combination with different parameters
// LCDMenuLib_add(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type )
LCDML_addAdvanced (21 , LCDML_0 , 6 , NULL, "" , mDyn_para, 0, _LCDML_TYPE_dynParam); // NULL = no menu function
// Example for conditions (for example for a screensaver)
// 1. define a condition as a function of a boolean type -> return false = not displayed, return true = displayed
// 2. set the function name as callback (remove the braces '()' it gives bad errors)
// LCDMenuLib_add(id, prev_layer, new_num, condition, lang_char_array, callback_function, parameter (0-255), menu function type )
LCDML_addAdvanced (22 , LCDML_0 , 7 , COND_hide, "screensaver" , mFunc_screensaver, 0, _LCDML_TYPE_default); // this menu function can be found on "LCDML_display_menuFunction" tab
// ***TIP*** Try to update _LCDML_DISP_cnt when you add a menu element.
// menu element count - last element id
// this value must be the same as the last menu element
#define _LCDML_DISP_cnt 22
// create menu
LCDML_createMenu(_LCDML_DISP_cnt);
// *********************************************************************
// Simple Thread configuration
// *********************************************************************
// define the thread number _sT_cnt_1 => 1, _sT_cnt_2 => 2, ....
#define _sT_cnt _sT_cnt_3
// initialisation
simpleThread_init(_sT_cnt);
/* create a new thread
* - params for "timebased_static" and "timebased_dynamic" (dynamic: the runtime can be changed)
* param 1: priority (unique id) (the first is "_sT_P1", next one "_sT_P2", ...)
* param 2: time mode: "_sT_millis" or "_sT_micros"
* param 3: waittime as unsigned long ( 50UL or something else with UL at the end)
* param 4: the current state of a thread "_sT_start" or "_sT_stop" or "_sT_stable"
* ("_sT_stable" => a stable state function is called)
* param 5: callback function name
*
* - params for "eventbased"
* param 1: param 1: priority (unique id) (the first is "_sT_P1", next one "_sT_P2", ...)
* param 2: callback function name
*/
simpleThread_new_timebased_static (_sT_P1 , _sT_micros, 0 , _sT_start , Thread_input_check);
simpleThread_new_timebased_static (_sT_P2 , _sT_millis, 1000UL , _sT_stop , Thread_Serial_Blink_Example);
simpleThread_new_timebased_static (_sT_P3 , _sT_millis, 100UL , _sT_start , Thread_LCDMenuLib);
/* simple thread control makros reference
* initialisation:
* ===============
* void simpleThread_init( number of threads )
* void simpleThread_new_timebased_static(unique_id, time_mode, wait_time, current_state, callback_function)
* void simpleThread_new_timebased_dynamic(unique_id, time_mode, wait_time, current_state, callback_function)
* void simpleThread_new_eventbased(unique_id, callback_function)
*
* setup initialisation:
* ===============
* void simpleThread_initSetup(_sT_cnt); // do no change something here
*
* loop initialisation:
* ===============
* void simpleThread_run(_sT_priority);
* or
* void simpleThread_run(_sT_no_priority); // the return value of simpleThread_loop is set to true
*
* create a thread function:
* ===============
* void simpleThread_setup(callback_function)
* boolean simpleThread_loop(callback_function) // return true => go to the next function (use this when the
* wait_time is 0 to call the other threads
* // return false => go to the begin of the thread list
* void simpleThread_stable(callback_function)
*
* thread handling:
* ===============
* void simpleThread_start(callback_function)
* void simpleThread_stop(callback_function)
* void simpleThread_reset(callback_function) // setup function is called on the next start
* void simpleThread_restart(callback_function) // reset and start
*
* void simpleThread_event_start(callback_function)
* void simpleThread_event_reset(callback_function) // setup function is called on the next start
* void simpleThread_event_restart(callback_function) // reset and start
*
* call a thread directly:
* ===============
* void simpleThread_call(callback_function)
*
* call a part of a thread directly
* ===============
* void simpleThread_call_setup(callback_function)
* boolean simpleThread_call_loop(callback_function)
* void simpleThread_call_stable(callback_function)
*
*/
// *********************************************************************
// SETUP
// *********************************************************************
void setup()
{
// serial init; only be needed if serial control is used
Serial.begin(9600); // start serial
Serial.println(F(_LCDML_VERSION)); // only for examples
simpleThread_initSetup(_sT_cnt);
// LCDMenuLib Setup
LCDML_setup(_LCDML_DISP_cnt);
// Some settings which can be used
// Enable Menu Rollover
//LCDML.MENU_enRollover();
// Enable Screensaver (screensaver menu function, time to activate in ms)
LCDML.SCREEN_enable(mFunc_screensaver, 10000); // set to 10 seconds
//LCDML.SCREEN_disable();
// Some needful methods
// You can jump to a menu function from anywhere with
//LCDML.OTHER_jumpToFunc(mFunc_p2); // the parameter is the function name
}
// *********************************************************************
// LOOP
// *********************************************************************
void loop()
{
simpleThread_run(_sT_priority);
}
// *********************************************************************
// check some errors - do not change here anything
// *********************************************************************
# if(_LCDML_DISP_rows > _LCDML_DISP_cfg_max_rows)
# error change value of _LCDML_DISP_cfg_max_rows in LCDMenuLib2.h
# endif
|
[
"nilsfeld@gmail.com"
] |
nilsfeld@gmail.com
|
433cb2c6f45d78a2087a5bce8c00bd2ab38b1f57
|
c0a9cc835e9e4566e18c867dbbec63de40dd3404
|
/cs165/assignments/asteroids/rocks.cpp
|
21d6198d4b7c866522dda883ee32bc5239a86f70
|
[] |
no_license
|
tatianachetina/BYU-I
|
cb347999e89a1886d1f4ca5cbda3ad533a81eca5
|
5e1b0607bc53cba29d86753295b49f088fd617f7
|
refs/heads/master
| 2020-03-23T04:28:28.355573
| 2018-07-03T02:22:44
| 2018-07-03T02:22:44
| 141,085,653
| 1
| 0
| null | 2018-07-16T04:17:28
| 2018-07-16T04:17:28
| null |
UTF-8
|
C++
| false
| false
| 70
|
cpp
|
#include "rocks.h"
// Put your Rock methods here
Rock :: Rock()
{
}
|
[
"scottcurrell@gmail.com"
] |
scottcurrell@gmail.com
|
f24cf2a07b41e319baf931ba699fecc02b59e8d4
|
293d62b2afbcfe0ca3f06f21320022afd802cafe
|
/RenderCore/render/wtf/Deque.h
|
c7b4089c8d8888caba05235b624ee86595412414
|
[
"Apache-2.0"
] |
permissive
|
pouloghost/weexuikit
|
9b2e911a3cc34f3b8ab9cf0b3c9e57d245583a4e
|
2eaf54e4c1f4a1c94398b0990ad9767e3ffb9213
|
refs/heads/master
| 2022-02-20T05:49:23.025281
| 2019-08-14T03:17:52
| 2019-08-14T03:17:52
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 19,489
|
h
|
/*
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2009 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WEEX_UIKIT_WTF_DEQUE_H_
#define WEEX_UIKIT_WTF_DEQUE_H_
// FIXME: Could move what Vector and Deque share into a separate file.
// Deque doesn't actually use Vector.
#include <iterator>
#include "render/wtf/PassTraits.h"
#include "render/wtf/Vector.h"
namespace WTF {
template <typename T, size_t inlineCapacity, typename Allocator>
class DequeIteratorBase;
template <typename T, size_t inlineCapacity, typename Allocator>
class DequeIterator;
template <typename T, size_t inlineCapacity, typename Allocator>
class DequeConstIterator;
template <typename T,
size_t inlineCapacity = 0,
typename Allocator = DefaultAllocator>
class Deque : public VectorDestructorBase<Deque<T, inlineCapacity, Allocator>,
T,
(inlineCapacity > 0),
Allocator::isGarbageCollected> {
WTF_USE_ALLOCATOR(Deque, Allocator);
public:
typedef DequeIterator<T, inlineCapacity, Allocator> iterator;
typedef DequeConstIterator<T, inlineCapacity, Allocator> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef PassTraits<T> Pass;
typedef typename PassTraits<T>::PassType PassType;
Deque();
Deque(const Deque<T, inlineCapacity, Allocator>&);
// FIXME: Doesn't work if there is an inline buffer, due to crbug.com/360572
Deque<T, 0, Allocator>& operator=(const Deque&);
void finalize();
// We hard wire the inlineCapacity to zero here, due to crbug.com/360572
void swap(Deque<T, 0, Allocator>&);
size_t size() const {
return m_start <= m_end ? m_end - m_start
: m_end + m_buffer.capacity() - m_start;
}
bool isEmpty() const { return m_start == m_end; }
iterator begin() { return iterator(this, m_start); }
iterator end() { return iterator(this, m_end); }
const_iterator begin() const { return const_iterator(this, m_start); }
const_iterator end() const { return const_iterator(this, m_end); }
reverse_iterator rbegin() { return reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rbegin() const {
return const_reverse_iterator(end());
}
const_reverse_iterator rend() const {
return const_reverse_iterator(begin());
}
T& first() {
ASSERT(m_start != m_end);
return m_buffer.buffer()[m_start];
}
const T& first() const {
ASSERT(m_start != m_end);
return m_buffer.buffer()[m_start];
}
PassType takeFirst();
T& last() {
ASSERT(m_start != m_end);
return *(--end());
}
const T& last() const {
ASSERT(m_start != m_end);
return *(--end());
}
PassType takeLast();
T& at(size_t i) {
RELEASE_ASSERT(i < size());
size_t right = m_buffer.capacity() - m_start;
return i < right ? m_buffer.buffer()[m_start + i]
: m_buffer.buffer()[i - right];
}
const T& at(size_t i) const {
RELEASE_ASSERT(i < size());
size_t right = m_buffer.capacity() - m_start;
return i < right ? m_buffer.buffer()[m_start + i]
: m_buffer.buffer()[i - right];
}
T& operator[](size_t i) { return at(i); }
const T& operator[](size_t i) const { return at(i); }
template <typename U>
void append(const U&);
template <typename U>
void prepend(const U&);
void removeFirst();
void removeLast();
void remove(iterator&);
void remove(const_iterator&);
void clear();
template <typename Predicate>
iterator findIf(Predicate&);
private:
friend class DequeIteratorBase<T, inlineCapacity, Allocator>;
typedef VectorBuffer<T, inlineCapacity, Allocator> Buffer;
typedef VectorTypeOperations<T> TypeOperations;
typedef DequeIteratorBase<T, inlineCapacity, Allocator> IteratorBase;
void remove(size_t position);
void destroyAll();
void expandCapacityIfNeeded();
void expandCapacity();
Buffer m_buffer;
unsigned m_start;
unsigned m_end;
};
template <typename T, size_t inlineCapacity, typename Allocator>
class DequeIteratorBase {
protected:
DequeIteratorBase();
DequeIteratorBase(const Deque<T, inlineCapacity, Allocator>*, size_t);
DequeIteratorBase(const DequeIteratorBase&);
DequeIteratorBase<T, 0, Allocator>& operator=(
const DequeIteratorBase<T, 0, Allocator>&);
~DequeIteratorBase();
void assign(const DequeIteratorBase& other) { *this = other; }
void increment();
void decrement();
T* before() const;
T* after() const;
bool isEqual(const DequeIteratorBase&) const;
private:
Deque<T, inlineCapacity, Allocator>* m_deque;
unsigned m_index;
friend class Deque<T, inlineCapacity, Allocator>;
};
template <typename T,
size_t inlineCapacity = 0,
typename Allocator = DefaultAllocator>
class DequeIterator : public DequeIteratorBase<T, inlineCapacity, Allocator> {
private:
typedef DequeIteratorBase<T, inlineCapacity, Allocator> Base;
typedef DequeIterator<T, inlineCapacity, Allocator> Iterator;
public:
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T* pointer;
typedef T& reference;
typedef std::bidirectional_iterator_tag iterator_category;
DequeIterator(Deque<T, inlineCapacity, Allocator>* deque, size_t index)
: Base(deque, index) {}
DequeIterator(const Iterator& other) : Base(other) {}
DequeIterator& operator=(const Iterator& other) {
Base::assign(other);
return *this;
}
T& operator*() const { return *Base::after(); }
T* operator->() const { return Base::after(); }
bool operator==(const Iterator& other) const { return Base::isEqual(other); }
bool operator!=(const Iterator& other) const { return !Base::isEqual(other); }
Iterator& operator++() {
Base::increment();
return *this;
}
// postfix ++ intentionally omitted
Iterator& operator--() {
Base::decrement();
return *this;
}
// postfix -- intentionally omitted
};
template <typename T,
size_t inlineCapacity = 0,
typename Allocator = DefaultAllocator>
class DequeConstIterator
: public DequeIteratorBase<T, inlineCapacity, Allocator> {
private:
typedef DequeIteratorBase<T, inlineCapacity, Allocator> Base;
typedef DequeConstIterator<T, inlineCapacity, Allocator> Iterator;
typedef DequeIterator<T, inlineCapacity, Allocator> NonConstIterator;
public:
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef const T* pointer;
typedef const T& reference;
typedef std::bidirectional_iterator_tag iterator_category;
DequeConstIterator(const Deque<T, inlineCapacity, Allocator>* deque,
size_t index)
: Base(deque, index) {}
DequeConstIterator(const Iterator& other) : Base(other) {}
DequeConstIterator(const NonConstIterator& other) : Base(other) {}
DequeConstIterator& operator=(const Iterator& other) {
Base::assign(other);
return *this;
}
DequeConstIterator& operator=(const NonConstIterator& other) {
Base::assign(other);
return *this;
}
const T& operator*() const { return *Base::after(); }
const T* operator->() const { return Base::after(); }
bool operator==(const Iterator& other) const { return Base::isEqual(other); }
bool operator!=(const Iterator& other) const { return !Base::isEqual(other); }
Iterator& operator++() {
Base::increment();
return *this;
}
// postfix ++ intentionally omitted
Iterator& operator--() {
Base::decrement();
return *this;
}
// postfix -- intentionally omitted
};
template <typename T, size_t inlineCapacity, typename Allocator>
inline Deque<T, inlineCapacity, Allocator>::Deque() : m_start(0), m_end(0) {}
template <typename T, size_t inlineCapacity, typename Allocator>
inline Deque<T, inlineCapacity, Allocator>::Deque(
const Deque<T, inlineCapacity, Allocator>& other)
: m_buffer(other.m_buffer.capacity()),
m_start(other.m_start),
m_end(other.m_end) {
const T* otherBuffer = other.m_buffer.buffer();
if (m_start <= m_end)
TypeOperations::uninitializedCopy(otherBuffer + m_start,
otherBuffer + m_end,
m_buffer.buffer() + m_start);
else {
TypeOperations::uninitializedCopy(otherBuffer, otherBuffer + m_end,
m_buffer.buffer());
TypeOperations::uninitializedCopy(otherBuffer + m_start,
otherBuffer + m_buffer.capacity(),
m_buffer.buffer() + m_start);
}
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline Deque<T, 0, Allocator>& Deque<T, inlineCapacity, Allocator>::operator=(
const Deque& other) {
Deque<T> copy(other);
swap(copy);
return *this;
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::destroyAll() {
if (m_start <= m_end) {
TypeOperations::destruct(m_buffer.buffer() + m_start,
m_buffer.buffer() + m_end);
} else {
TypeOperations::destruct(m_buffer.buffer(), m_buffer.buffer() + m_end);
TypeOperations::destruct(m_buffer.buffer() + m_start,
m_buffer.buffer() + m_buffer.capacity());
}
}
// Off-GC-heap deques: Destructor should be called.
// On-GC-heap deques: Destructor should be called for inline buffers
// (if any) but destructor shouldn't be called for vector backing since
// it is managed by the traced GC heap.
template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::finalize() {
if (!inlineCapacity && !m_buffer.buffer())
return;
if (!isEmpty() &&
!(Allocator::isGarbageCollected && m_buffer.hasOutOfLineBuffer()))
destroyAll();
m_buffer.destruct();
}
// FIXME: Doesn't work if there is an inline buffer, due to crbug.com/360572
template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::swap(
Deque<T, 0, Allocator>& other) {
std::swap(m_start, other.m_start);
std::swap(m_end, other.m_end);
m_buffer.swapVectorBuffer(other.m_buffer);
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::clear() {
destroyAll();
m_start = 0;
m_end = 0;
m_buffer.deallocateBuffer(m_buffer.buffer());
m_buffer.resetBufferPointer();
}
template <typename T, size_t inlineCapacity, typename Allocator>
template <typename Predicate>
inline DequeIterator<T, inlineCapacity, Allocator>
Deque<T, inlineCapacity, Allocator>::findIf(Predicate& predicate) {
iterator end_iterator = end();
for (iterator it = begin(); it != end_iterator; ++it) {
if (predicate(*it))
return it;
}
return end_iterator;
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::expandCapacityIfNeeded() {
if (m_start) {
if (m_end + 1 != m_start)
return;
} else if (m_end) {
if (m_end != m_buffer.capacity() - 1)
return;
} else if (m_buffer.capacity())
return;
expandCapacity();
}
template <typename T, size_t inlineCapacity, typename Allocator>
void Deque<T, inlineCapacity, Allocator>::expandCapacity() {
size_t oldCapacity = m_buffer.capacity();
T* oldBuffer = m_buffer.buffer();
m_buffer.allocateBuffer(
std::max(static_cast<size_t>(16), oldCapacity + oldCapacity / 4 + 1));
if (m_start <= m_end)
TypeOperations::move(oldBuffer + m_start, oldBuffer + m_end,
m_buffer.buffer() + m_start);
else {
TypeOperations::move(oldBuffer, oldBuffer + m_end, m_buffer.buffer());
size_t newStart = m_buffer.capacity() - (oldCapacity - m_start);
TypeOperations::move(oldBuffer + m_start, oldBuffer + oldCapacity,
m_buffer.buffer() + newStart);
m_start = newStart;
}
m_buffer.deallocateBuffer(oldBuffer);
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline typename Deque<T, inlineCapacity, Allocator>::PassType
Deque<T, inlineCapacity, Allocator>::takeFirst() {
T oldFirst = Pass::transfer(first());
removeFirst();
return Pass::transfer(oldFirst);
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline typename Deque<T, inlineCapacity, Allocator>::PassType
Deque<T, inlineCapacity, Allocator>::takeLast() {
T oldLast = Pass::transfer(last());
removeLast();
return Pass::transfer(oldLast);
}
template <typename T, size_t inlineCapacity, typename Allocator>
template <typename U>
inline void Deque<T, inlineCapacity, Allocator>::append(const U& value) {
expandCapacityIfNeeded();
new (NotNull, &m_buffer.buffer()[m_end]) T(value);
if (m_end == m_buffer.capacity() - 1)
m_end = 0;
else
++m_end;
}
template <typename T, size_t inlineCapacity, typename Allocator>
template <typename U>
inline void Deque<T, inlineCapacity, Allocator>::prepend(const U& value) {
expandCapacityIfNeeded();
if (!m_start)
m_start = m_buffer.capacity() - 1;
else
--m_start;
new (NotNull, &m_buffer.buffer()[m_start]) T(value);
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::removeFirst() {
ASSERT(!isEmpty());
TypeOperations::destruct(&m_buffer.buffer()[m_start],
&m_buffer.buffer()[m_start + 1]);
if (m_start == m_buffer.capacity() - 1)
m_start = 0;
else
++m_start;
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::removeLast() {
ASSERT(!isEmpty());
if (!m_end)
m_end = m_buffer.capacity() - 1;
else
--m_end;
TypeOperations::destruct(&m_buffer.buffer()[m_end],
&m_buffer.buffer()[m_end + 1]);
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::remove(iterator& it) {
remove(it.m_index);
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::remove(const_iterator& it) {
remove(it.m_index);
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::remove(size_t position) {
if (position == m_end)
return;
T* buffer = m_buffer.buffer();
TypeOperations::destruct(&buffer[position], &buffer[position + 1]);
// Find which segment of the circular buffer contained the remove element, and
// only move elements in that part.
if (position >= m_start) {
TypeOperations::moveOverlapping(buffer + m_start, buffer + position,
buffer + m_start + 1);
m_start = (m_start + 1) % m_buffer.capacity();
} else {
TypeOperations::moveOverlapping(buffer + position + 1, buffer + m_end,
buffer + position);
m_end = (m_end - 1 + m_buffer.capacity()) % m_buffer.capacity();
}
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline DequeIteratorBase<T, inlineCapacity, Allocator>::DequeIteratorBase()
: m_deque(0) {}
template <typename T, size_t inlineCapacity, typename Allocator>
inline DequeIteratorBase<T, inlineCapacity, Allocator>::DequeIteratorBase(
const Deque<T, inlineCapacity, Allocator>* deque,
size_t index)
: m_deque(const_cast<Deque<T, inlineCapacity, Allocator>*>(deque)),
m_index(index) {}
template <typename T, size_t inlineCapacity, typename Allocator>
inline DequeIteratorBase<T, inlineCapacity, Allocator>::DequeIteratorBase(
const DequeIteratorBase& other)
: m_deque(other.m_deque), m_index(other.m_index) {}
template <typename T, size_t inlineCapacity, typename Allocator>
inline DequeIteratorBase<T, 0, Allocator>&
DequeIteratorBase<T, inlineCapacity, Allocator>::operator=(
const DequeIteratorBase<T, 0, Allocator>& other) {
m_deque = other.m_deque;
m_index = other.m_index;
return *this;
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline DequeIteratorBase<T, inlineCapacity, Allocator>::~DequeIteratorBase() {}
template <typename T, size_t inlineCapacity, typename Allocator>
inline bool DequeIteratorBase<T, inlineCapacity, Allocator>::isEqual(
const DequeIteratorBase& other) const {
return m_index == other.m_index;
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void DequeIteratorBase<T, inlineCapacity, Allocator>::increment() {
ASSERT(m_index != m_deque->m_end);
ASSERT(m_deque->m_buffer.capacity());
if (m_index == m_deque->m_buffer.capacity() - 1)
m_index = 0;
else
++m_index;
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void DequeIteratorBase<T, inlineCapacity, Allocator>::decrement() {
ASSERT(m_index != m_deque->m_start);
ASSERT(m_deque->m_buffer.capacity());
if (!m_index)
m_index = m_deque->m_buffer.capacity() - 1;
else
--m_index;
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::after() const {
ASSERT(m_index != m_deque->m_end);
return &m_deque->m_buffer.buffer()[m_index];
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline T* DequeIteratorBase<T, inlineCapacity, Allocator>::before() const {
ASSERT(m_index != m_deque->m_start);
if (!m_index)
return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1];
return &m_deque->m_buffer.buffer()[m_index - 1];
}
template <typename T, size_t inlineCapacity, typename Allocator>
inline void swap(Deque<T, inlineCapacity, Allocator>& a,
Deque<T, inlineCapacity, Allocator>& b) {
a.swap(b);
}
} // namespace WTF
using WTF::Deque;
#endif // WEEX_UIKIT_WTF_DEQUE_H_
|
[
"jianbai.gbj@taobao.com"
] |
jianbai.gbj@taobao.com
|
1f27cd124866893af8d17fab898b4ad4ca84fb17
|
11652dfbaccc4f7928cd0d0c37e4fc476ec7bc58
|
/Engine/Components/ModelComponent.hpp
|
d7905dc7e64787d869ab3bba3268b0a4e8e7137d
|
[
"MIT"
] |
permissive
|
FeikoJoosten/GameEngineFramework
|
8ebbbd5e4a40c798348edc2cb8a379c73b2563b7
|
09017f92270db6d0fc649949a2960f9a14d5db0e
|
refs/heads/master
| 2022-12-21T01:57:04.274895
| 2019-09-28T21:43:43
| 2019-09-28T21:43:43
| 163,863,606
| 7
| 0
|
MIT
| 2019-01-08T13:37:15
| 2019-01-02T16:20:23
|
C++
|
UTF-8
|
C++
| false
| false
| 2,546
|
hpp
|
#pragma once
#include "Engine/api.hpp"
#include "Engine/Model/Model.hpp"
#include "Engine/Components/Component.hpp"
namespace Engine
{
class TransformComponent;
/// <summary>
/// This component is used to keep track of the meshes and textures to render. NOTE: only the Entity class is allowed to create this component.
/// </summary>
class ENGINE_API ModelComponent : public Component
{
private:
friend class Entity;
ModelComponent() = default;
/// <summary>
/// Create a model component with the give Model.
/// </summary>
explicit ModelComponent(eastl::shared_ptr<Model> newModel) noexcept;
/// <summary>
/// Create a model component with the given path.
/// </summary>
/// <param name="path">This path value is used to load the default mesh for this model component.</param>
/// <returns></returns>
explicit ModelComponent(eastl::string path) noexcept;
/// <summary>
/// This method is used to initialize your component in. This method is called after the setting of the owner.
/// </summary>
void InitializeComponent() override;
public:
virtual ~ModelComponent();
/// <summary>
/// This method allows you to change the model to render of this model component.
/// </summary>
/// <param name="newModel">The new model to use.</param>
void SetModel(eastl::shared_ptr<Model> newModel);
/// <summary>
/// This method allows you to change the model to render of this model component.
/// </summary>
/// <param name="path">The path of the new model to use.</param>
void SetModel(const eastl::string& path);
/// <summary>
/// This method will return the current model of this model component.
/// </summary>
/// <returns></returns>
eastl::weak_ptr<Model> GetModel() const;
/// <summary>
/// Saves the data of this component to a archive
/// </summary>
/// <param name="ar"> the archive that you want to save to </param>
template <typename archive>
void SaveComponent(archive ar);
/// <summary>
/// loads the data from the archive to this component
/// </summary>
/// <param name="ar"> the archive that you want to load from </param>
template<typename archive>
void LoadComponent(archive ar);
private:
void Update() override;
void Render();
void OnComponentAdded(eastl::weak_ptr<Component> addedComponent) override;
void OnComponentRemoved(eastl::weak_ptr<Component> removedComponent) override;
eastl::weak_ptr<Model> model;
eastl::weak_ptr<TransformComponent> transformComponent;
eastl::string path;
};
} //namespace Engine
|
[
"feiko_joosten@hotmail.com"
] |
feiko_joosten@hotmail.com
|
aee546c3e337c99c1f8351685237b64e4d052b9d
|
fed8f16e93f9a63d5bc350fbf6b2086c21b4843f
|
/Miscellaneous/Debugging Templates.cpp
|
d570226f5ff11b3f3836771da46814bcfa8a233b
|
[] |
no_license
|
marksman2op/cp
|
199faabccd7cc7764c81e93a15ef88fef16f8414
|
bda1bf982f4fbc8498579d4d9b30b43ef0f80b5d
|
refs/heads/master
| 2023-08-17T10:16:13.123785
| 2021-10-04T07:59:39
| 2021-10-04T07:59:39
| 244,225,646
| 1
| 0
| null | 2020-07-23T19:02:22
| 2020-03-01T21:21:42
|
C++
|
UTF-8
|
C++
| false
| false
| 8,996
|
cpp
|
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
// #define int long long
/*
char array n * m
# sand
. empty
array of size m
a[i] = num of sands in column m
*/
// DEBUGGING TEMPLATES
/*
Alternative for g++ -D LOCAL filenmae.cpp
Codeforces defines an ONLINE_JUDGE macro for C/C++ programs. Therefore it is possible to
write a template where the debugging output works on a local machine, and turns into nothing
on Codeforces. A very simple implementation:
#ifndef ONLINE_JUDGE
# define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
# define LOG(x) 0
#endif
Then just write LOG(i); in the program.
*/
/*
// https://codeforces.com/blog/entry/68809
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ", "; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? ", " : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
*/
/*
// neal
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html
template<class Fun> class y_combinator_result {
Fun fun_;
public:
template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}
template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); }
};
template<class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifdef ONLINE_JUDGE
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
*/
/*
// https://codeforces.com/blog/entry/91347
#define SFINAE(x, ...) \
template <class, class = void> \
struct x : std::false_type {}; \
template <class T> \
struct x<T, std::void_t<__VA_ARGS__>> : std::true_type {}
SFINAE(DefaultIO, decltype(std::cout << std::declval<T &>()));
SFINAE(IsTuple, typename std::tuple_size<T>::type);
SFINAE(Iterable, decltype(std::begin(std::declval<T>())));
template <class T>
constexpr char Space(const T &) {
return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' ';
}
template <auto &os>
struct Writer {
template <class T>
void Impl(T const &t) const {
if constexpr (DefaultIO<T>::value) os << t;
else if constexpr (Iterable<T>::value) {
int i = 0;
for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x));
} else if constexpr (IsTuple<T>::value)
std::apply([this](auto const &... args) {
int i = 0;
(((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);
}, t);
else static_assert(IsTuple<T>::value, "No matching type for print");
}
template <class F, class... Ts>
auto &operator()(F const &f, Ts const &... ts) const {
return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this;
}
};
#ifndef ONLINE_JUDGE
#define debug(args...) \
{ \
std::string _s = #args; \
std::replace(_s.begin(), _s.end(), ',', ' '); \
std::stringstream _ss(_s); \
std::istream_iterator<std::string> _it(_ss); \
std::cerr << "Line " << __LINE__ << "\n"; \
err(_it, args); \
}
void err(std::istream_iterator<std::string> it) {
std::ignore = it;
}
template <typename T, typename... Args>
void err(std::istream_iterator<std::string> it, T a, Args... args) {
std::cerr << *it << " = ";
Writer<std::cerr>{}(a);
err(++it, args...);
}
#define ASSERT(...) \
if (not(__VA_ARGS__)) throw runtime_error(#__VA_ARGS__)
#else
#define debug(...) 0
#define ASSERT(...) 0
#endif
*/
/*
// Errichto
// https://codeforces.com/blog/entry/67830
// https://github.com/Errichto/youtube/blob/master/reply_code_warsaw_kodziaki.cpp
// Usage
// debug() << imie(c * 2) imie(min(a, b)) imie(a != b);
// debug() << "add" imie(i) imie(A) imie(diff);
// debug() << imie(V); // V is a vector
// debug() << imie(a) imie(h1) imie(h2) imie(my_dist) imie(path) imie(vertices); // int a,h1,h2; vector path;
// debug() << "Zlaczacz::Ogarnij(" imie(a) imie(b) ") = " << res; // pair<vector<int>, vector<int>> res; int a,b;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
*/
/*
// tourist
// https://codeforces.com/blog/entry/65311
// https://codeforces.com/blog/entry/76087
string to_string(string s) {
return '"' + s + '"';
}
string to_string(const char* s) {
return to_string((string) s);
}
string to_string(bool b) {
return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
*/
/*
// tnowak
// https://codeforces.com/blog/entry/67830
// To debug, you'll overload cout
// For eg. to debug vector from(n + 1, vector<tuple<int, int, int>>(10, {-1, -1, -1}));
// ostream& operator<<(ostream &o, tuple<int, int, int> &t) {
// return o << vector{get<0>(t), get<1>(t), get<2>(t)};
// }
template<class A, class B> auto& operator<<(ostream &o, pair<A, B> p) {
return o << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &o, T x) -> decltype(x.end(), o) {
o << '{'; int i = 0; for(auto e : x) o << (", ")+2*!i++ << e; return o << '}';
}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n'
#else
#define debug(...) {}
#endif
*/
void run_case() {
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int T = 1;
// cin >> T;
for (int t = 1; t <= T; t++) {
// cout << "Case #" << t << ": ";
run_case();
}
return 0;
}
|
[
"noreply@github.com"
] |
marksman2op.noreply@github.com
|
8cd7c592fc0128902e0fc4b975d29e21c89f9b96
|
d33cbc96bfb7d793c63ea586aece6edfa893c073
|
/src/util.cpp
|
eab82230d0abb3e70e0c2b9299c3e29138c43823
|
[
"MIT"
] |
permissive
|
IntergalacticAvenger/uwucoin
|
dccf9622fd24d15bae0351dbcb267686a45c7967
|
5299ef565d55297f20bc9687b76396b020088510
|
refs/heads/master
| 2023-04-21T17:21:46.075588
| 2021-04-23T22:08:23
| 2021-04-23T22:08:23
| 338,735,929
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 43,205
|
cpp
|
// Copyright (c) 2009-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.
#ifndef WIN32
// for posix_fallocate
#ifdef __linux__
#define _POSIX_C_SOURCE 200112L
#endif
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/resource.h>
#endif
#include "util.h"
#include "sync.h"
#include "version.h"
#include "ui_interface.h"
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
// Work around clang compilation problem in Boost 1.46:
// /usr/include/boost/program_options/detail/config_file.hpp:163:17: error: call to function 'to_internal' that is neither visible in the template definition nor found by argument-dependent lookup
// See also: http://stackoverflow.com/questions/10020179/compilation-fail-in-boost-librairies-program-options
// http://clang.debian.net/status.php?version=3.0&key=CANNOT_FIND_FUNCTION
namespace boost {
namespace program_options {
std::string to_internal(const std::string&);
}
}
#include <boost/program_options/detail/config_file.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/foreach.hpp>
#include <boost/thread.hpp>
#include <openssl/crypto.h>
#include <openssl/rand.h>
#include <stdarg.h>
#ifdef WIN32
#ifdef _MSC_VER
#pragma warning(disable:4786)
#pragma warning(disable:4804)
#pragma warning(disable:4805)
#pragma warning(disable:4717)
#endif
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0501
#ifdef _WIN32_IE
#undef _WIN32_IE
#endif
#define _WIN32_IE 0x0501
#define WIN32_LEAN_AND_MEAN 1
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <io.h> /* for _commit */
#include "shlobj.h"
#elif defined(__linux__)
# include <sys/prctl.h>
#endif
using namespace std;
map<string, string> mapArgs;
map<string, vector<string> > mapMultiArgs;
bool fDebug = false;
bool fDebugNet = false;
bool fPrintToConsole = false;
bool fPrintToDebugger = false;
bool fDaemon = false;
bool fServer = false;
bool fCommandLine = false;
string strMiscWarning;
bool fTestNet = false;
bool fBloomFilters = true;
bool fNoListen = false;
bool fLogTimestamps = false;
CMedianFilter<int64> vTimeOffsets(200,0);
volatile bool fReopenDebugLog = false;
bool fCachedPath[2] = {false, false};
// Init OpenSSL library multithreading support
static CCriticalSection** ppmutexOpenSSL;
void locking_callback(int mode, int i, const char* file, int line)
{
if (mode & CRYPTO_LOCK) {
ENTER_CRITICAL_SECTION(*ppmutexOpenSSL[i]);
} else {
LEAVE_CRITICAL_SECTION(*ppmutexOpenSSL[i]);
}
}
LockedPageManager LockedPageManager::instance;
// Init
class CInit
{
public:
CInit()
{
// Init OpenSSL library multithreading support
ppmutexOpenSSL = (CCriticalSection**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(CCriticalSection*));
for (int i = 0; i < CRYPTO_num_locks(); i++)
ppmutexOpenSSL[i] = new CCriticalSection();
CRYPTO_set_locking_callback(locking_callback);
#ifdef WIN32
// Seed random number generator with screen scrape and other hardware sources
RAND_screen();
#endif
// Seed random number generator with performance counter
RandAddSeed();
}
~CInit()
{
// Shutdown OpenSSL library multithreading support
CRYPTO_set_locking_callback(NULL);
for (int i = 0; i < CRYPTO_num_locks(); i++)
delete ppmutexOpenSSL[i];
OPENSSL_free(ppmutexOpenSSL);
}
}
instance_of_cinit;
void RandAddSeed()
{
// Seed with CPU performance counter
int64 nCounter = GetPerformanceCounter();
RAND_add(&nCounter, sizeof(nCounter), 1.5);
memset(&nCounter, 0, sizeof(nCounter));
}
void RandAddSeedPerfmon()
{
RandAddSeed();
// This can take up to 2 seconds, so only do it every 10 minutes
static int64 nLastPerfmon;
if (GetTime() < nLastPerfmon + 10 * 60)
return;
nLastPerfmon = GetTime();
#ifdef WIN32
// Don't need this on Linux, OpenSSL automatically uses /dev/urandom
// Seed with the entire set of perfmon data
unsigned char pdata[250000];
memset(pdata, 0, sizeof(pdata));
unsigned long nSize = sizeof(pdata);
long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize);
RegCloseKey(HKEY_PERFORMANCE_DATA);
if (ret == ERROR_SUCCESS)
{
RAND_add(pdata, nSize, nSize/100.0);
OPENSSL_cleanse(pdata, nSize);
printf("RandAddSeed() %lu bytes\n", nSize);
}
#endif
}
uint64 GetRand(uint64 nMax)
{
if (nMax == 0)
return 0;
// The range of the random source must be a multiple of the modulus
// to give every possible output value an equal possibility
uint64 nRange = (std::numeric_limits<uint64>::max() / nMax) * nMax;
uint64 nRand = 0;
do
RAND_bytes((unsigned char*)&nRand, sizeof(nRand));
while (nRand >= nRange);
return (nRand % nMax);
}
int GetRandInt(int nMax)
{
return GetRand(nMax);
}
uint256 GetRandHash()
{
uint256 hash;
RAND_bytes((unsigned char*)&hash, sizeof(hash));
return hash;
}
//
// OutputDebugStringF (aka printf -- there is a #define that we really
// should get rid of one day) has been broken a couple of times now
// by well-meaning people adding mutexes in the most straightforward way.
// It breaks because it may be called by global destructors during shutdown.
// Since the order of destruction of static/global objects is undefined,
// defining a mutex as a global object doesn't work (the mutex gets
// destroyed, and then some later destructor calls OutputDebugStringF,
// maybe indirectly, and you get a core dump at shutdown trying to lock
// the mutex).
static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT;
// We use boost::call_once() to make sure these are initialized in
// in a thread-safe manner the first time it is called:
static FILE* fileout = NULL;
static boost::mutex* mutexDebugLog = NULL;
static void DebugPrintInit()
{
assert(fileout == NULL);
assert(mutexDebugLog == NULL);
boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
fileout = fopen(pathDebug.string().c_str(), "a");
if (fileout) setbuf(fileout, NULL); // unbuffered
mutexDebugLog = new boost::mutex();
}
int OutputDebugStringF(const char* pszFormat, ...)
{
int ret = 0; // Returns total number of characters written
if (fPrintToConsole)
{
// print to console
va_list arg_ptr;
va_start(arg_ptr, pszFormat);
ret += vprintf(pszFormat, arg_ptr);
va_end(arg_ptr);
}
else if (!fPrintToDebugger)
{
static bool fStartedNewLine = true;
boost::call_once(&DebugPrintInit, debugPrintInitFlag);
if (fileout == NULL)
return ret;
boost::mutex::scoped_lock scoped_lock(*mutexDebugLog);
// reopen the log file, if requested
if (fReopenDebugLog) {
fReopenDebugLog = false;
boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
if (freopen(pathDebug.string().c_str(),"a",fileout) != NULL)
setbuf(fileout, NULL); // unbuffered
}
// Debug print useful for profiling
if (fLogTimestamps && fStartedNewLine)
ret += fprintf(fileout, "%s ", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str());
if (pszFormat[strlen(pszFormat) - 1] == '\n')
fStartedNewLine = true;
else
fStartedNewLine = false;
va_list arg_ptr;
va_start(arg_ptr, pszFormat);
ret += vfprintf(fileout, pszFormat, arg_ptr);
va_end(arg_ptr);
}
#ifdef WIN32
if (fPrintToDebugger)
{
static CCriticalSection cs_OutputDebugStringF;
// accumulate and output a line at a time
{
LOCK(cs_OutputDebugStringF);
static std::string buffer;
va_list arg_ptr;
va_start(arg_ptr, pszFormat);
buffer += vstrprintf(pszFormat, arg_ptr);
va_end(arg_ptr);
int line_start = 0, line_end;
while((line_end = buffer.find('\n', line_start)) != -1)
{
OutputDebugStringA(buffer.substr(line_start, line_end - line_start).c_str());
line_start = line_end + 1;
ret += line_end-line_start;
}
buffer.erase(0, line_start);
}
}
#endif
return ret;
}
string vstrprintf(const char *format, va_list ap)
{
char buffer[50000];
char* p = buffer;
int limit = sizeof(buffer);
int ret;
loop
{
va_list arg_ptr;
va_copy(arg_ptr, ap);
#ifdef WIN32
ret = _vsnprintf(p, limit, format, arg_ptr);
#else
ret = vsnprintf(p, limit, format, arg_ptr);
#endif
va_end(arg_ptr);
if (ret >= 0 && ret < limit)
break;
if (p != buffer)
delete[] p;
limit *= 2;
p = new char[limit];
if (p == NULL)
throw std::bad_alloc();
}
string str(p, p+ret);
if (p != buffer)
delete[] p;
return str;
}
string real_strprintf(const char *format, int dummy, ...)
{
va_list arg_ptr;
va_start(arg_ptr, dummy);
string str = vstrprintf(format, arg_ptr);
va_end(arg_ptr);
return str;
}
string real_strprintf(const std::string &format, int dummy, ...)
{
va_list arg_ptr;
va_start(arg_ptr, dummy);
string str = vstrprintf(format.c_str(), arg_ptr);
va_end(arg_ptr);
return str;
}
bool error(const char *format, ...)
{
va_list arg_ptr;
va_start(arg_ptr, format);
std::string str = vstrprintf(format, arg_ptr);
va_end(arg_ptr);
printf("ERROR: %s\n", str.c_str());
return false;
}
void ParseString(const string& str, char c, vector<string>& v)
{
if (str.empty())
return;
string::size_type i1 = 0;
string::size_type i2;
loop
{
i2 = str.find(c, i1);
if (i2 == str.npos)
{
v.push_back(str.substr(i1));
return;
}
v.push_back(str.substr(i1, i2-i1));
i1 = i2+1;
}
}
string FormatMoney(int64 n, bool fPlus)
{
// Note: not using straight sprintf here because we do NOT want
// localized number formatting.
int64 n_abs = (n > 0 ? n : -n);
int64 quotient = n_abs/COIN;
int64 remainder = n_abs%COIN;
string str = strprintf("%"PRI64d".%08"PRI64d, quotient, remainder);
// Right-trim excess zeros before the decimal point:
int nTrim = 0;
for (int i = str.size()-1; (str[i] == '0' && isdigit(str[i-2])); --i)
++nTrim;
if (nTrim)
str.erase(str.size()-nTrim, nTrim);
if (n < 0)
str.insert((unsigned int)0, 1, '-');
else if (fPlus && n > 0)
str.insert((unsigned int)0, 1, '+');
return str;
}
bool ParseMoney(const string& str, int64& nRet)
{
return ParseMoney(str.c_str(), nRet);
}
bool ParseMoney(const char* pszIn, int64& nRet)
{
string strWhole;
int64 nUnits = 0;
const char* p = pszIn;
while (isspace(*p))
p++;
for (; *p; p++)
{
if (*p == '.')
{
p++;
int64 nMult = CENT*10;
while (isdigit(*p) && (nMult > 0))
{
nUnits += nMult * (*p++ - '0');
nMult /= 10;
}
break;
}
if (isspace(*p))
break;
if (!isdigit(*p))
return false;
strWhole.insert(strWhole.end(), *p);
}
for (; *p; p++)
if (!isspace(*p))
return false;
if (strWhole.size() > 10) // guard against 63 bit overflow
return false;
if (nUnits < 0 || nUnits > COIN)
return false;
int64 nWhole = atoi64(strWhole);
int64 nValue = nWhole*COIN + nUnits;
nRet = nValue;
return true;
}
// safeChars chosen to allow simple messages/URLs/email addresses, but avoid anything
// even possibly remotely dangerous like & or >
static string safeChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 .,;_/:?@");
string SanitizeString(const string& str)
{
string strResult;
for (std::string::size_type i = 0; i < str.size(); i++)
{
if (safeChars.find(str[i]) != std::string::npos)
strResult.push_back(str[i]);
}
return strResult;
}
static const signed char phexdigit[256] =
{ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,
-1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, };
bool IsHex(const string& str)
{
BOOST_FOREACH(unsigned char c, str)
{
if (phexdigit[c] < 0)
return false;
}
return (str.size() > 0) && (str.size()%2 == 0);
}
vector<unsigned char> ParseHex(const char* psz)
{
// convert hex dump to vector
vector<unsigned char> vch;
loop
{
while (isspace(*psz))
psz++;
signed char c = phexdigit[(unsigned char)*psz++];
if (c == (signed char)-1)
break;
unsigned char n = (c << 4);
c = phexdigit[(unsigned char)*psz++];
if (c == (signed char)-1)
break;
n |= c;
vch.push_back(n);
}
return vch;
}
vector<unsigned char> ParseHex(const string& str)
{
return ParseHex(str.c_str());
}
static void InterpretNegativeSetting(string name, map<string, string>& mapSettingsRet)
{
// interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set
if (name.find("-no") == 0)
{
std::string positive("-");
positive.append(name.begin()+3, name.end());
if (mapSettingsRet.count(positive) == 0)
{
bool value = !GetBoolArg(name);
mapSettingsRet[positive] = (value ? "1" : "0");
}
}
}
void ParseParameters(int argc, const char* const argv[])
{
mapArgs.clear();
mapMultiArgs.clear();
for (int i = 1; i < argc; i++)
{
std::string str(argv[i]);
std::string strValue;
size_t is_index = str.find('=');
if (is_index != std::string::npos)
{
strValue = str.substr(is_index+1);
str = str.substr(0, is_index);
}
#ifdef WIN32
boost::to_lower(str);
if (boost::algorithm::starts_with(str, "/"))
str = "-" + str.substr(1);
#endif
if (str[0] != '-')
break;
mapArgs[str] = strValue;
mapMultiArgs[str].push_back(strValue);
}
// New 0.6 features:
BOOST_FOREACH(const PAIRTYPE(string,string)& entry, mapArgs)
{
string name = entry.first;
// interpret --foo as -foo (as long as both are not set)
if (name.find("--") == 0)
{
std::string singleDash(name.begin()+1, name.end());
if (mapArgs.count(singleDash) == 0)
mapArgs[singleDash] = entry.second;
name = singleDash;
}
// interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set
InterpretNegativeSetting(name, mapArgs);
}
}
std::string GetArg(const std::string& strArg, const std::string& strDefault)
{
if (mapArgs.count(strArg))
return mapArgs[strArg];
return strDefault;
}
int64 GetArg(const std::string& strArg, int64 nDefault)
{
if (mapArgs.count(strArg))
return atoi64(mapArgs[strArg]);
return nDefault;
}
bool GetBoolArg(const std::string& strArg, bool fDefault)
{
if (mapArgs.count(strArg))
{
if (mapArgs[strArg].empty())
return true;
return (atoi(mapArgs[strArg]) != 0);
}
return fDefault;
}
bool SoftSetArg(const std::string& strArg, const std::string& strValue)
{
if (mapArgs.count(strArg))
return false;
mapArgs[strArg] = strValue;
return true;
}
bool SoftSetBoolArg(const std::string& strArg, bool fValue)
{
if (fValue)
return SoftSetArg(strArg, std::string("1"));
else
return SoftSetArg(strArg, std::string("0"));
}
string EncodeBase64(const unsigned char* pch, size_t len)
{
static const char *pbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
string strRet="";
strRet.reserve((len+2)/3*4);
int mode=0, left=0;
const unsigned char *pchEnd = pch+len;
while (pch<pchEnd)
{
int enc = *(pch++);
switch (mode)
{
case 0: // we have no bits
strRet += pbase64[enc >> 2];
left = (enc & 3) << 4;
mode = 1;
break;
case 1: // we have two bits
strRet += pbase64[left | (enc >> 4)];
left = (enc & 15) << 2;
mode = 2;
break;
case 2: // we have four bits
strRet += pbase64[left | (enc >> 6)];
strRet += pbase64[enc & 63];
mode = 0;
break;
}
}
if (mode)
{
strRet += pbase64[left];
strRet += '=';
if (mode == 1)
strRet += '=';
}
return strRet;
}
string EncodeBase64(const string& str)
{
return EncodeBase64((const unsigned char*)str.c_str(), str.size());
}
vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
{
static const int decode64_table[256] =
{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1,
-1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
if (pfInvalid)
*pfInvalid = false;
vector<unsigned char> vchRet;
vchRet.reserve(strlen(p)*3/4);
int mode = 0;
int left = 0;
while (1)
{
int dec = decode64_table[(unsigned char)*p];
if (dec == -1) break;
p++;
switch (mode)
{
case 0: // we have no bits and get 6
left = dec;
mode = 1;
break;
case 1: // we have 6 bits and keep 4
vchRet.push_back((left<<2) | (dec>>4));
left = dec & 15;
mode = 2;
break;
case 2: // we have 4 bits and get 6, we keep 2
vchRet.push_back((left<<4) | (dec>>2));
left = dec & 3;
mode = 3;
break;
case 3: // we have 2 bits and get 6
vchRet.push_back((left<<6) | dec);
mode = 0;
break;
}
}
if (pfInvalid)
switch (mode)
{
case 0: // 4n base64 characters processed: ok
break;
case 1: // 4n+1 base64 character processed: impossible
*pfInvalid = true;
break;
case 2: // 4n+2 base64 characters processed: require '=='
if (left || p[0] != '=' || p[1] != '=' || decode64_table[(unsigned char)p[2]] != -1)
*pfInvalid = true;
break;
case 3: // 4n+3 base64 characters processed: require '='
if (left || p[0] != '=' || decode64_table[(unsigned char)p[1]] != -1)
*pfInvalid = true;
break;
}
return vchRet;
}
string DecodeBase64(const string& str)
{
vector<unsigned char> vchRet = DecodeBase64(str.c_str());
return string((const char*)&vchRet[0], vchRet.size());
}
string EncodeBase32(const unsigned char* pch, size_t len)
{
static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567";
string strRet="";
strRet.reserve((len+4)/5*8);
int mode=0, left=0;
const unsigned char *pchEnd = pch+len;
while (pch<pchEnd)
{
int enc = *(pch++);
switch (mode)
{
case 0: // we have no bits
strRet += pbase32[enc >> 3];
left = (enc & 7) << 2;
mode = 1;
break;
case 1: // we have three bits
strRet += pbase32[left | (enc >> 6)];
strRet += pbase32[(enc >> 1) & 31];
left = (enc & 1) << 4;
mode = 2;
break;
case 2: // we have one bit
strRet += pbase32[left | (enc >> 4)];
left = (enc & 15) << 1;
mode = 3;
break;
case 3: // we have four bits
strRet += pbase32[left | (enc >> 7)];
strRet += pbase32[(enc >> 2) & 31];
left = (enc & 3) << 3;
mode = 4;
break;
case 4: // we have two bits
strRet += pbase32[left | (enc >> 5)];
strRet += pbase32[enc & 31];
mode = 0;
}
}
static const int nPadding[5] = {0, 6, 4, 3, 1};
if (mode)
{
strRet += pbase32[left];
for (int n=0; n<nPadding[mode]; n++)
strRet += '=';
}
return strRet;
}
string EncodeBase32(const string& str)
{
return EncodeBase32((const unsigned char*)str.c_str(), str.size());
}
vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
{
static const int decode32_table[256] =
{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
if (pfInvalid)
*pfInvalid = false;
vector<unsigned char> vchRet;
vchRet.reserve((strlen(p))*5/8);
int mode = 0;
int left = 0;
while (1)
{
int dec = decode32_table[(unsigned char)*p];
if (dec == -1) break;
p++;
switch (mode)
{
case 0: // we have no bits and get 5
left = dec;
mode = 1;
break;
case 1: // we have 5 bits and keep 2
vchRet.push_back((left<<3) | (dec>>2));
left = dec & 3;
mode = 2;
break;
case 2: // we have 2 bits and keep 7
left = left << 5 | dec;
mode = 3;
break;
case 3: // we have 7 bits and keep 4
vchRet.push_back((left<<1) | (dec>>4));
left = dec & 15;
mode = 4;
break;
case 4: // we have 4 bits, and keep 1
vchRet.push_back((left<<4) | (dec>>1));
left = dec & 1;
mode = 5;
break;
case 5: // we have 1 bit, and keep 6
left = left << 5 | dec;
mode = 6;
break;
case 6: // we have 6 bits, and keep 3
vchRet.push_back((left<<2) | (dec>>3));
left = dec & 7;
mode = 7;
break;
case 7: // we have 3 bits, and keep 0
vchRet.push_back((left<<5) | dec);
mode = 0;
break;
}
}
if (pfInvalid)
switch (mode)
{
case 0: // 8n base32 characters processed: ok
break;
case 1: // 8n+1 base32 characters processed: impossible
case 3: // +3
case 6: // +6
*pfInvalid = true;
break;
case 2: // 8n+2 base32 characters processed: require '======'
if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || p[3] != '=' || p[4] != '=' || p[5] != '=' || decode32_table[(unsigned char)p[6]] != -1)
*pfInvalid = true;
break;
case 4: // 8n+4 base32 characters processed: require '===='
if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || p[3] != '=' || decode32_table[(unsigned char)p[4]] != -1)
*pfInvalid = true;
break;
case 5: // 8n+5 base32 characters processed: require '==='
if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || decode32_table[(unsigned char)p[3]] != -1)
*pfInvalid = true;
break;
case 7: // 8n+7 base32 characters processed: require '='
if (left || p[0] != '=' || decode32_table[(unsigned char)p[1]] != -1)
*pfInvalid = true;
break;
}
return vchRet;
}
string DecodeBase32(const string& str)
{
vector<unsigned char> vchRet = DecodeBase32(str.c_str());
return string((const char*)&vchRet[0], vchRet.size());
}
bool WildcardMatch(const char* psz, const char* mask)
{
loop
{
switch (*mask)
{
case '\0':
return (*psz == '\0');
case '*':
return WildcardMatch(psz, mask+1) || (*psz && WildcardMatch(psz+1, mask));
case '?':
if (*psz == '\0')
return false;
break;
default:
if (*psz != *mask)
return false;
break;
}
psz++;
mask++;
}
}
bool WildcardMatch(const string& str, const string& mask)
{
return WildcardMatch(str.c_str(), mask.c_str());
}
static std::string FormatException(std::exception* pex, const char* pszThread)
{
#ifdef WIN32
char pszModule[MAX_PATH] = "";
GetModuleFileNameA(NULL, pszModule, sizeof(pszModule));
#else
const char* pszModule = "uwucoin";
#endif
if (pex)
return strprintf(
"EXCEPTION: %s \n%s \n%s in %s \n", typeid(*pex).name(), pex->what(), pszModule, pszThread);
else
return strprintf(
"UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread);
}
void LogException(std::exception* pex, const char* pszThread)
{
std::string message = FormatException(pex, pszThread);
printf("\n%s", message.c_str());
}
void PrintException(std::exception* pex, const char* pszThread)
{
std::string message = FormatException(pex, pszThread);
printf("\n\n************************\n%s\n", message.c_str());
fprintf(stderr, "\n\n************************\n%s\n", message.c_str());
strMiscWarning = message;
throw;
}
void PrintExceptionContinue(std::exception* pex, const char* pszThread)
{
std::string message = FormatException(pex, pszThread);
printf("\n\n************************\n%s\n", message.c_str());
fprintf(stderr, "\n\n************************\n%s\n", message.c_str());
strMiscWarning = message;
}
boost::filesystem::path GetDefaultDataDir()
{
namespace fs = boost::filesystem;
// Windows < Vista: C:\Documents and Settings\Username\Application Data\Bitcoin
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Bitcoin
// Mac: ~/Library/Application Support/Bitcoin
// Unix: ~/.bitcoin
#ifdef WIN32
// Windows
return GetSpecialFolderPath(CSIDL_APPDATA) / "Uwucoin";
#else
fs::path pathRet;
char* pszHome = getenv("HOME");
if (pszHome == NULL || strlen(pszHome) == 0)
pathRet = fs::path("/");
else
pathRet = fs::path(pszHome);
#ifdef MAC_OSX
// Mac
pathRet /= "Library/Application Support";
fs::create_directory(pathRet);
return pathRet / "Uwucoin";
#else
// Unix
return pathRet / ".uwucoin";
#endif
#endif
}
const boost::filesystem::path &GetDataDir(bool fNetSpecific)
{
namespace fs = boost::filesystem;
static fs::path pathCached[2];
static CCriticalSection csPathCached;
fs::path &path = pathCached[fNetSpecific];
// This can be called during exceptions by printf, so we cache the
// value so we don't have to do memory allocations after that.
if (fCachedPath[fNetSpecific])
return path;
LOCK(csPathCached);
if (mapArgs.count("-datadir")) {
path = fs::system_complete(mapArgs["-datadir"]);
if (!fs::is_directory(path)) {
path = "";
return path;
}
} else {
path = GetDefaultDataDir();
}
if (fNetSpecific && GetBoolArg("-testnet", false))
path /= "testnet3";
fs::create_directories(path);
fCachedPath[fNetSpecific] = true;
return path;
}
boost::filesystem::path GetConfigFile()
{
boost::filesystem::path pathConfigFile(GetArg("-conf", "uwucoin.conf"));
if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir(false) / pathConfigFile;
return pathConfigFile;
}
void ReadConfigFile(map<string, string>& mapSettingsRet,
map<string, vector<string> >& mapMultiSettingsRet)
{
boost::filesystem::ifstream streamConfig(GetConfigFile());
if (!streamConfig.good())
return; // No bitcoin.conf file is OK
// clear path cache after loading config file
fCachedPath[0] = fCachedPath[1] = false;
set<string> setOptions;
setOptions.insert("*");
for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it)
{
// Don't overwrite existing settings so command line settings override bitcoin.conf
string strKey = string("-") + it->string_key;
if (mapSettingsRet.count(strKey) == 0)
{
mapSettingsRet[strKey] = it->value[0];
// interpret nofoo=1 as foo=0 (and nofoo=0 as foo=1) as long as foo not set)
InterpretNegativeSetting(strKey, mapSettingsRet);
}
mapMultiSettingsRet[strKey].push_back(it->value[0]);
}
}
boost::filesystem::path GetPidFile()
{
boost::filesystem::path pathPidFile(GetArg("-pid", "uwucoind.pid"));
if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile;
return pathPidFile;
}
#ifndef WIN32
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
{
FILE* file = fopen(path.string().c_str(), "w");
if (file)
{
fprintf(file, "%d\n", pid);
fclose(file);
}
}
#endif
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
{
#ifdef WIN32
return MoveFileExA(src.string().c_str(), dest.string().c_str(),
MOVEFILE_REPLACE_EXISTING);
#else
int rc = std::rename(src.string().c_str(), dest.string().c_str());
return (rc == 0);
#endif /* WIN32 */
}
void FileCommit(FILE *fileout)
{
fflush(fileout); // harmless if redundantly called
#ifdef WIN32
_commit(_fileno(fileout));
#else
#if defined(__linux__) || defined(__NetBSD__)
fdatasync(fileno(fileout));
#elif defined(__APPLE__) && defined(F_FULLFSYNC)
fcntl(fileno(fileout), F_FULLFSYNC, 0);
#else
fsync(fileno(fileout));
#endif
#endif
}
int GetFilesize(FILE* file)
{
int nSavePos = ftell(file);
int nFilesize = -1;
if (fseek(file, 0, SEEK_END) == 0)
nFilesize = ftell(file);
fseek(file, nSavePos, SEEK_SET);
return nFilesize;
}
bool TruncateFile(FILE *file, unsigned int length) {
#if defined(WIN32)
return _chsize(_fileno(file), length) == 0;
#else
return ftruncate(fileno(file), length) == 0;
#endif
}
// this function tries to raise the file descriptor limit to the requested number.
// It returns the actual file descriptor limit (which may be more or less than nMinFD)
int RaiseFileDescriptorLimit(int nMinFD) {
#if defined(WIN32)
return 2048;
#else
struct rlimit limitFD;
if (getrlimit(RLIMIT_NOFILE, &limitFD) != -1) {
if (limitFD.rlim_cur < (rlim_t)nMinFD) {
limitFD.rlim_cur = nMinFD;
if (limitFD.rlim_cur > limitFD.rlim_max)
limitFD.rlim_cur = limitFD.rlim_max;
setrlimit(RLIMIT_NOFILE, &limitFD);
getrlimit(RLIMIT_NOFILE, &limitFD);
}
return limitFD.rlim_cur;
}
return nMinFD; // getrlimit failed, assume it's fine
#endif
}
// this function tries to make a particular range of a file allocated (corresponding to disk space)
// it is advisory, and the range specified in the arguments will never contain live data
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) {
#if defined(WIN32)
// Windows-specific version
HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(file));
LARGE_INTEGER nFileSize;
int64 nEndPos = (int64)offset + length;
nFileSize.u.LowPart = nEndPos & 0xFFFFFFFF;
nFileSize.u.HighPart = nEndPos >> 32;
SetFilePointerEx(hFile, nFileSize, 0, FILE_BEGIN);
SetEndOfFile(hFile);
#elif defined(MAC_OSX)
// OSX specific version
fstore_t fst;
fst.fst_flags = F_ALLOCATECONTIG;
fst.fst_posmode = F_PEOFPOSMODE;
fst.fst_offset = 0;
fst.fst_length = (off_t)offset + length;
fst.fst_bytesalloc = 0;
if (fcntl(fileno(file), F_PREALLOCATE, &fst) == -1) {
fst.fst_flags = F_ALLOCATEALL;
fcntl(fileno(file), F_PREALLOCATE, &fst);
}
ftruncate(fileno(file), fst.fst_length);
#elif defined(__linux__)
// Version using posix_fallocate
off_t nEndPos = (off_t)offset + length;
posix_fallocate(fileno(file), 0, nEndPos);
#else
// Fallback version
// TODO: just write one byte per block
static const char buf[65536] = {};
fseek(file, offset, SEEK_SET);
while (length > 0) {
unsigned int now = 65536;
if (length < now)
now = length;
fwrite(buf, 1, now, file); // allowed to fail; this function is advisory anyway
length -= now;
}
#endif
}
void ShrinkDebugFile()
{
// Scroll debug.log if it's getting too big
boost::filesystem::path pathLog = GetDataDir() / "debug.log";
FILE* file = fopen(pathLog.string().c_str(), "r");
if (file && GetFilesize(file) > 10 * 1000000)
{
// Restart the file with some of the end
char pch[200000];
fseek(file, -sizeof(pch), SEEK_END);
int nBytes = fread(pch, 1, sizeof(pch), file);
fclose(file);
file = fopen(pathLog.string().c_str(), "w");
if (file)
{
fwrite(pch, 1, nBytes, file);
fclose(file);
}
}
else if(file != NULL)
fclose(file);
}
//
// "Never go to sea with two chronometers; take one or three."
// Our three time sources are:
// - System clock
// - Median of other nodes clocks
// - The user (asking the user to fix the system clock if the first two disagree)
//
static int64 nMockTime = 0; // For unit testing
int64 GetTime()
{
if (nMockTime) return nMockTime;
return time(NULL);
}
void SetMockTime(int64 nMockTimeIn)
{
nMockTime = nMockTimeIn;
}
static int64 nTimeOffset = 0;
int64 GetTimeOffset()
{
return nTimeOffset;
}
int64 GetAdjustedTime()
{
return GetTime() + GetTimeOffset();
}
void AddTimeData(const CNetAddr& ip, int64 nTime)
{
int64 nOffsetSample = nTime - GetTime();
// Ignore duplicates
static set<CNetAddr> setKnown;
if (!setKnown.insert(ip).second)
return;
// Add data
vTimeOffsets.input(nOffsetSample);
printf("Added time data, samples %d, offset %+"PRI64d" (%+"PRI64d" minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);
if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
{
int64 nMedian = vTimeOffsets.median();
std::vector<int64> vSorted = vTimeOffsets.sorted();
// Only let other nodes change our time by so much
if (abs64(nMedian) < 35 * 60) // Uwucoin: changed maximum adjust to 35 mins to avoid letting peers change our time too much in case of an attack.
{
nTimeOffset = nMedian;
}
else
{
nTimeOffset = 0;
static bool fDone;
if (!fDone)
{
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
bool fMatch = false;
BOOST_FOREACH(int64 nOffset, vSorted)
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
fMatch = true;
if (!fMatch)
{
fDone = true;
string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Uwucoin will not work properly.");
strMiscWarning = strMessage;
printf("*** %s\n", strMessage.c_str());
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
}
}
}
if (fDebug) {
BOOST_FOREACH(int64 n, vSorted)
printf("%+"PRI64d" ", n);
printf("| ");
}
printf("nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60);
}
}
uint32_t insecure_rand_Rz = 11;
uint32_t insecure_rand_Rw = 11;
void seed_insecure_rand(bool fDeterministic)
{
//The seed values have some unlikely fixed points which we avoid.
if(fDeterministic)
{
insecure_rand_Rz = insecure_rand_Rw = 11;
} else {
uint32_t tmp;
do {
RAND_bytes((unsigned char*)&tmp, 4);
} while(tmp == 0 || tmp == 0x9068ffffU);
insecure_rand_Rz = tmp;
do {
RAND_bytes((unsigned char*)&tmp, 4);
} while(tmp == 0 || tmp == 0x464fffffU);
insecure_rand_Rw = tmp;
}
}
string FormatVersion(int nVersion)
{
if (nVersion%100 == 0)
return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100);
else
return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100);
}
string FormatFullVersion()
{
return CLIENT_BUILD;
}
// Format the subversion field according to BIP 14 spec (https://en.bitcoin.it/wiki/BIP_0014)
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
{
std::ostringstream ss;
ss << "/";
ss << name << ":" << FormatVersion(nClientVersion);
if (!comments.empty())
ss << "(" << boost::algorithm::join(comments, "; ") << ")";
ss << "/";
return ss.str();
}
#ifdef WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate)
{
namespace fs = boost::filesystem;
char pszPath[MAX_PATH] = "";
if(SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate))
{
return fs::path(pszPath);
}
printf("SHGetSpecialFolderPathA() failed, could not obtain requested path.\n");
return fs::path("");
}
#endif
boost::filesystem::path GetTempPath() {
#if BOOST_FILESYSTEM_VERSION == 3
return boost::filesystem::temp_directory_path();
#else
// TODO: remove when we don't support filesystem v2 anymore
boost::filesystem::path path;
#ifdef WIN32
char pszPath[MAX_PATH] = "";
if (GetTempPathA(MAX_PATH, pszPath))
path = boost::filesystem::path(pszPath);
#else
path = boost::filesystem::path("/tmp");
#endif
if (path.empty() || !boost::filesystem::is_directory(path)) {
printf("GetTempPath(): failed to find temp path\n");
return boost::filesystem::path("");
}
return path;
#endif
}
void runCommand(std::string strCommand)
{
int nErr = ::system(strCommand.c_str());
if (nErr)
printf("runCommand error: system(%s) returned %d\n", strCommand.c_str(), nErr);
}
void RenameThread(const char* name)
{
#if defined(PR_SET_NAME)
// Only the first 15 characters are used (16 - NUL terminator)
::prctl(PR_SET_NAME, name, 0, 0, 0);
#elif 0 && (defined(__FreeBSD__) || defined(__OpenBSD__))
// TODO: This is currently disabled because it needs to be verified to work
// on FreeBSD or OpenBSD first. When verified the '0 &&' part can be
// removed.
pthread_set_name_np(pthread_self(), name);
#elif defined(MAC_OSX) && defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
// pthread_setname_np is XCode 10.6-and-later
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
pthread_setname_np(name);
#endif
#else
// Prevent warnings for unused parameters...
(void)name;
#endif
}
bool NewThread(void(*pfn)(void*), void* parg)
{
try
{
boost::thread(pfn, parg); // thread detaches when out of scope
} catch(boost::thread_resource_error &e) {
printf("Error creating thread: %s\n", e.what());
return false;
}
return true;
}
|
[
"eshayer@ucdavis.edu"
] |
eshayer@ucdavis.edu
|
3863d7783e96dd742dd10b36bc8b63b7c09fc1d6
|
bb6b3f0b3101cd153db54130469279c2a77c7cde
|
/tests/Mocks/MockIO.h
|
89a7ee45d3f86554c0c1e9ec5b030574d59b5616
|
[] |
no_license
|
RodionShyshkin/ToDoList
|
d1394f5bc41df412d6f0ff53a55cd88102d90766
|
2e1f34080c595fd5a83d9609bfba42866d0e7a0a
|
refs/heads/master
| 2023-01-07T19:20:30.790925
| 2020-10-27T02:00:28
| 2020-10-27T02:00:28
| 279,855,260
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 518
|
h
|
//
// Created by Rodion Shyshkin on 26.10.2020.
//
#ifndef TODOLIST_TESTS_MOCKS_MOCKIO_H_
#define TODOLIST_TESTS_MOCKS_MOCKIO_H_
#include <gmock/gmock.h>
#include <IO/IOInterface.h>
class MockIO : public IOInterface {
public:
MOCK_METHOD(std::string, input, (), (override));
MOCK_METHOD(std::string, inputCommand, (), (override));
MOCK_METHOD(void, output, (const std::string&), (override));
MOCK_METHOD(void, outputWithBreak, (const std::string&), (override));
};
#endif //TODOLIST_TESTS_MOCKS_MOCKIO_H_
|
[
"rodion.shyshkin@teamdev.com"
] |
rodion.shyshkin@teamdev.com
|
621d0db64d22a6000ccfbde6df17cd23e01aa124
|
ea9519970a897170bd6a2e618d258de44f4d48ba
|
/Source/Tanki/PhysicsProjectilew.cpp
|
4e29d9dbaa60636da3e5c6303d2afec14ffeff65
|
[] |
no_license
|
Kotsh/Tanki8
|
494f2094b235221e8e3256bed78f6edc50e107c8
|
4536069b61ab13672012656daeebe0e9255ef14d
|
refs/heads/main
| 2023-08-27T01:54:30.676394
| 2021-11-07T19:26:35
| 2021-11-07T19:26:35
| 425,595,962
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 206
|
cpp
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "PhysicsProjectilew.h"
PhysicsProjectilew::PhysicsProjectilew()
{
}
PhysicsProjectilew::~PhysicsProjectilew()
{
}
|
[
"kotish-fase@mail.ru"
] |
kotish-fase@mail.ru
|
ea32666e1a9a1c3c822b833c4cda00175557beb7
|
9f8837e820e266379a4ca764324cf486fd31d43b
|
/final_thesafe.ino
|
f0e62437cef387f649e09112c00234984044b982
|
[] |
no_license
|
mpaulmichael/InsAndOuts_Michael
|
5f49ed116557743b3aaea8a81a8f7dd2ccb67205
|
4baee36060ef80a2d1429af7d47cdbe5c3451424
|
refs/heads/master
| 2020-03-29T16:33:56.522343
| 2018-12-19T17:09:57
| 2018-12-19T17:09:57
| 150,118,771
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 19,914
|
ino
|
#include <Servo.h>
Servo myservo;
unsigned long time;
int time2;
const int RED = 4;
const int GREEN = 3;
const int BLUE = 2;
const int PhotoPin=A1;
int PhotoValue=0;
const int Knob_sensorPin=A0;
int Knob_sensorValue=0;
int val_knob;
int val_photosensor;
int val3=100;
int state;
int condition;
int stat;
int sta;
int st;
int finalstate;
int comb1;
int comb2;
int comb3;
int comb4;
//int val3=10; //number to unlock the box
void setup() {
// put your setup code here, to run once:
Serial.println(state);
Serial.begin(9600);
myservo.attach(9);
pinMode(RED,OUTPUT);
pinMode(GREEN,OUTPUT);
pinMode(BLUE,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
val_knob=analogRead(A0);
val_photosensor=analogRead(A1);
Serial.print("Knob Value: ");
Serial.println(val_knob);
Serial.print("Photo Value: ");
Serial.println(val_photosensor);
time2=(millis()-time)/1000;
/////////////////////////////////////////////////////////////////////////////////////////
if (val_photosensor<20){
state=1;
digitalWrite(GREEN,LOW);
//Serial.println(state);
}
else{
state=2;
}
/*else if (val_photosensor>20){
state=2;
}*/
///////////////////////////////////////////////////////////////////////////////////////////////
if (state==1){
val3=500;//check servo value first
myservo.write(100);
if (val_knob<10){
digitalWrite(BLUE,HIGH);
delay(100);
digitalWrite(BLUE,LOW);
delay(100);
condition=10;
}
else{
//Serial.print("State: ");
//Serial.println(state);
digitalWrite(RED,HIGH);
}
if (condition==10){
val_knob=analogRead(A0);
val_photosensor=analogRead(A1);
//Serial.print("State: ");
//Serial.println(condition);
digitalWrite(BLUE,HIGH);
delay(100);
digitalWrite(BLUE,LOW);
delay(100);
digitalWrite(RED,LOW);
if ((val_knob<1000) && (val_knob)>900){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<1000) && (val_knob)>900){
delay(1000);
if ((val_knob<1000) && (val_knob)>900){
delay(1000);
if ((val_knob<1000) && (val_knob>900) && (time2==3)){
comb1=1;
stat=100;
}
}
}
}
else if ((val_knob<900) && (val_knob>800)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<900) && (val_knob>800)){
delay(1000);
if ((val_knob<900) && (val_knob>800)){
delay(1000);
if ((val_knob<900) && (val_knob>800) && (time2==3)){
comb1=2;
stat=100;
}
}
}
}
else if ((val_knob<800) && (val_knob>700)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<800) && (val_knob>700)){
delay(1000);
Serial.print(time2);
if ((val_knob<800) && (val_knob>700)){
delay(1000);
if ((val_knob<800) && (val_knob>700) && (time2==3)){
comb1=3;
stat=100;
}
}
}
}
else if ((val_knob<700) && (val_knob>600)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<700) && (val_knob>600)){
delay(1000);
if ((val_knob<700) && (val_knob>600)){
delay(1000);
if ((val_knob<700) && (val_knob>600) && (time2==3)){
comb1=4;
stat=100;
}
}
}
}
else if ((val_knob<600) && (val_knob>500)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<600) && (val_knob>500)){
delay(1000);
if ((val_knob<600) && (val_knob>500)){
delay(1000);
if ((val_knob<600) && (val_knob>500) && (time2==3)){
comb1=5;
stat=100;
}
}
}
}
else if ((val_knob<500) && (val_knob>400)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<500) && (val_knob>400)){
delay(1000);
if ((val_knob<500) && (val_knob>400)){
delay(1000);
if ((val_knob<500) && (val_knob>400) && (time2==3)){
comb1=6;
stat=100;
}
}
}
}
else if ((val_knob<400) && (val_knob>300)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<400) && (val_knob>300)){
delay(1000);
if ((val_knob<400) && (val_knob>300)){
delay(1000);
if ((val_knob<400) && (val_knob>300) && (time2==3)){
comb1=7;
stat=100;
}
}
}
}
else if ((val_knob<300) && (val_knob>200)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<300) && (val_knob>200)){
delay(1000);
if ((val_knob<300) && (val_knob>200)){
delay(1000);
if ((val_knob<300) && (val_knob>200) && (time2==3)){
comb1=8;
stat=100;
}
}
}
}
else if ((val_knob<200) && (val_knob>100)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<200) && (val_knob>100)){
delay(1000);
if ((val_knob<200) && (val_knob>100)){
delay(1000);
if ((val_knob<200) && (val_knob>100) && (time2==3)){
comb1=9;
stat=100;
}
}
}
}
Serial.println(" ");
Serial.print("Comb1: ");
Serial.println(comb1);
}
if (stat==100){
condition=45;
val_knob=analogRead(A0);
val_photosensor=analogRead(A1);
Serial.print("State: ");
Serial.println(stat);
digitalWrite(BLUE,HIGH);
delay(90);
digitalWrite(BLUE,LOW);
delay(90);
digitalWrite(RED,LOW);
if ((val_knob<1000) && (val_knob)>900){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<1000) && (val_knob)>900){
delay(1000);
if ((val_knob<1000) && (val_knob)>900){
delay(1000);
if ((val_knob<1000) && (val_knob>900) && (time2==3)){
comb2=1;
sta=1000;
}
}
}
}
else if ((val_knob<900) && (val_knob>800)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<900) && (val_knob>800)){
delay(1000);
if ((val_knob<900) && (val_knob>800)){
delay(1000);
if ((val_knob<900) && (val_knob>800) && (time2==3)){
comb2=2;
sta=1000;
}
}
}
}
else if ((val_knob<800) && (val_knob>700)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<800) && (val_knob>700)){
delay(1000);
Serial.print(time2);
if ((val_knob<800) && (val_knob>700)){
delay(1000);
if ((val_knob<800) && (val_knob>700) && (time2==3)){
comb2=3;
sta=1000;
}
}
}
}
else if ((val_knob<700) && (val_knob>600)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<700) && (val_knob>600)){
delay(1000);
if ((val_knob<700) && (val_knob>600)){
delay(1000);
if ((val_knob<700) && (val_knob>600) && (time2==3)){
comb2=4;
sta=1000;
}
}
}
}
else if ((val_knob<600) && (val_knob>500)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<600) && (val_knob>500)){
delay(1000);
if ((val_knob<600) && (val_knob>500)){
delay(1000);
if ((val_knob<600) && (val_knob>500) && (time2==3)){
comb2=5;
sta=1000;
}
}
}
}
else if ((val_knob<500) && (val_knob>400)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<500) && (val_knob>400)){
delay(1000);
if ((val_knob<500) && (val_knob>400)){
delay(1000);
if ((val_knob<500) && (val_knob>400) && (time2==3)){
comb2=6;
sta=1000;
}
}
}
}
else if ((val_knob<400) && (val_knob>300)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<400) && (val_knob>300)){
delay(1000);
if ((val_knob<400) && (val_knob>300)){
delay(1000);
if ((val_knob<400) && (val_knob>300) && (time2==3)){
comb2=7;
sta=1000;
}
}
}
}
else if ((val_knob<300) && (val_knob>200)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<300) && (val_knob>200)){
delay(1000);
if ((val_knob<300) && (val_knob>200)){
delay(1000);
if ((val_knob<300) && (val_knob>200) && (time2==3)){
comb2=8;
sta=1000;
}
}
}
}
else if ((val_knob<200) && (val_knob>100)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<200) && (val_knob>100)){
delay(1000);
if ((val_knob<200) && (val_knob>100)){
delay(1000);
if ((val_knob<200) && (val_knob>100) && (time2==3)){
comb2=9;
sta=1000;
}
}
}
}
Serial.println(" ");
Serial.print("Comb1: ");
Serial.println(comb1);
Serial.print("Comb2: ");
Serial.println(comb2);
}
if (sta==1000){
condition=45;
stat=25;
val_knob=analogRead(A0);
val_photosensor=analogRead(A1);
Serial.print("State: ");
Serial.println(sta);
digitalWrite(BLUE,HIGH);
delay(80);
digitalWrite(BLUE,LOW);
delay(80);
digitalWrite(RED,LOW);
if ((val_knob<1000) && (val_knob)>900){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<1000) && (val_knob)>900){
delay(1000);
if ((val_knob<1000) && (val_knob)>900){
delay(1000);
if ((val_knob<1000) && (val_knob>900) && (time2==3)){
comb3=1;
st=10000;
}
}
}
}
else if ((val_knob<900) && (val_knob>800)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<900) && (val_knob>800)){
delay(1000);
if ((val_knob<900) && (val_knob>800)){
delay(1000);
if ((val_knob<900) && (val_knob>800) && (time2==3)){
comb3=2;
st=10000;
}
}
}
}
else if ((val_knob<800) && (val_knob>700)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<800) && (val_knob>700)){
delay(1000);
Serial.print(time2);
if ((val_knob<800) && (val_knob>700)){
delay(1000);
if ((val_knob<800) && (val_knob>700) && (time2==3)){
comb3=3;
st=10000;
}
}
}
}
else if ((val_knob<700) && (val_knob>600)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<700) && (val_knob>600)){
delay(1000);
if ((val_knob<700) && (val_knob>600)){
delay(1000);
if ((val_knob<700) && (val_knob>600) && (time2==3)){
comb3=4;
st=10000;
}
}
}
}
else if ((val_knob<600) && (val_knob>500)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<600) && (val_knob>500)){
delay(1000);
if ((val_knob<600) && (val_knob>500)){
delay(1000);
if ((val_knob<600) && (val_knob>500) && (time2==3)){
comb3=5;
st=10000;
}
}
}
}
else if ((val_knob<500) && (val_knob>400)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<500) && (val_knob>400)){
delay(1000);
if ((val_knob<500) && (val_knob>400)){
delay(1000);
if ((val_knob<500) && (val_knob>400) && (time2==3)){
comb3=6;
st=10000;
}
}
}
}
else if ((val_knob<400) && (val_knob>300)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<400) && (val_knob>300)){
delay(1000);
if ((val_knob<400) && (val_knob>300)){
delay(1000);
if ((val_knob<400) && (val_knob>300) && (time2==3)){
comb3=7;
st=10000;
}
}
}
}
else if ((val_knob<300) && (val_knob>200)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<300) && (val_knob>200)){
delay(1000);
if ((val_knob<300) && (val_knob>200)){
delay(1000);
if ((val_knob<300) && (val_knob>200) && (time2==3)){
comb3=8;
st=10000;
}
}
}
}
else if ((val_knob<200) && (val_knob>100)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<200) && (val_knob>100)){
delay(1000);
if ((val_knob<200) && (val_knob>100)){
delay(1000);
if ((val_knob<200) && (val_knob>100) && (time2==3)){
comb3=9;
st=10000;
}
}
}
}
Serial.println(" ");
Serial.print("Comb1: ");
Serial.println(comb1);
Serial.print("Comb2: ");
Serial.println(comb2);
Serial.print("Comb3: ");
Serial.println(comb3);
}
if (st==10000){
condition=45;
stat=25;
sta=5;
val_knob=analogRead(A0);
val_photosensor=analogRead(A1);
Serial.print("State: ");
Serial.println(st);
digitalWrite(BLUE,HIGH);
delay(80);
digitalWrite(BLUE,LOW);
delay(80);
digitalWrite(RED,LOW);
if ((val_knob<1000) && (val_knob)>900){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<1000) && (val_knob)>900){
delay(1000);
if ((val_knob<1000) && (val_knob)>900){
delay(1000);
if ((val_knob<1000) && (val_knob>900) && (time2==3)){
comb4=1;
finalstate=20;
}
}
}
}
else if ((val_knob<900) && (val_knob>800)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<900) && (val_knob>800)){
delay(1000);
if ((val_knob<900) && (val_knob>800)){
delay(1000);
if ((val_knob<900) && (val_knob>800) && (time2==3)){
comb4=2;
finalstate=20;
}
}
}
}
else if ((val_knob<800) && (val_knob>700)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<800) && (val_knob>700)){
delay(1000);
Serial.print(time2);
if ((val_knob<800) && (val_knob>700)){
delay(1000);
if ((val_knob<800) && (val_knob>700) && (time2==3)){
comb4=3;
finalstate=20;
}
}
}
}
else if ((val_knob<700) && (val_knob>600)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<700) && (val_knob>600)){
delay(1000);
if ((val_knob<700) && (val_knob>600)){
delay(1000);
if ((val_knob<700) && (val_knob>600) && (time2==3)){
comb4=4;
finalstate=20;
}
}
}
}
else if ((val_knob<600) && (val_knob>500)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<600) && (val_knob>500)){
delay(1000);
if ((val_knob<600) && (val_knob>500)){
delay(1000);
if ((val_knob<600) && (val_knob>500) && (time2==3)){
comb4=5;
finalstate=20;
}
}
}
}
else if ((val_knob<500) && (val_knob>400)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<500) && (val_knob>400)){
delay(1000);
if ((val_knob<500) && (val_knob>400)){
delay(1000);
if ((val_knob<500) && (val_knob>400) && (time2==3)){
comb4=6;
finalstate=20;
}
}
}
}
else if ((val_knob<400) && (val_knob>300)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<400) && (val_knob>300)){
delay(1000);
if ((val_knob<400) && (val_knob>300)){
delay(1000);
if ((val_knob<400) && (val_knob>300) && (time2==3)){
comb4=7;
finalstate=20;
}
}
}
}
else if ((val_knob<300) && (val_knob>200)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<300) && (val_knob>200)){
delay(1000);
if ((val_knob<300) && (val_knob>200)){
delay(1000);
if ((val_knob<300) && (val_knob>200) && (time2==3)){
comb4=8;
finalstate=20;
}
}
}
}
else if ((val_knob<200) && (val_knob>100)){
time=millis();
delay(1000);
Serial.print(time2);
if ((val_knob<200) && (val_knob>100)){
delay(1000);
if ((val_knob<200) && (val_knob>100)){
delay(1000);
if ((val_knob<200) && (val_knob>100) && (time2==3)){
comb4=9;
finalstate=20;
}
}
}
}
Serial.println(" ");
Serial.print("Comb1: ");
Serial.println(comb1);
Serial.print("Comb2: ");
Serial.println(comb2);
Serial.print("Comb3: ");
Serial.println(comb3);
Serial.print("Comb4: ");
Serial.println(comb4);
}
if (finalstate==20){
condition=45;
stat=25;
sta=5;
st=0;
Serial.print("State: ");
Serial.println(finalstate);
if ((comb1==7) && (comb2==5) && (comb3==4) && (comb4==9)){
myservo.write(180);
digitalWrite(GREEN,HIGH);
delay(5000);
digitalWrite(GREEN,LOW);
delay(50);
}
else if ((comb1!=7) || (comb2!=5) || (comb3!=4) || (comb4!=9)){
myservo.write(100);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
else if (state==2){
Serial.println(state);
myservo.write(180);
digitalWrite(GREEN,HIGH);
}
////////////////////////////////////////////////////////////////////////////////////////////////
}
|
[
"noreply@github.com"
] |
mpaulmichael.noreply@github.com
|
9cf27ce200b47cbe7680c7363a3c99db5a93e7ab
|
493a4c99ba7d2122bcca2a495b87bf190ece5750
|
/kingdom_defence.cpp
|
9e8d0c811e414739bc71143319cca8217538b5fb
|
[] |
no_license
|
md-qubais/Data_Structures_Algorithms_and_Competitive_Programming
|
9b8d38c05522568bbf4cffa95dc5390a3aaae1cb
|
d7157c27720fa28ead3d4562e423ad719aabd87b
|
refs/heads/main
| 2023-04-02T12:36:34.482803
| 2021-04-05T08:31:14
| 2021-04-05T08:31:14
| 354,769,143
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 815
|
cpp
|
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
#define endl "\n"
using namespace std;
int32_t main(){
#ifndef qubais_judge
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
IOS;
int t;
cin>>t;
while(t--){
int w,h,n;
cin>>w>>h>>n;
vector<int> x(40000),y(40000);
for(int i=0;i<n;i++){
cin>>x[i]>>y[i];
}
sort(x.begin(),x.begin()+n);
sort(y.begin(),y.begin()+n);
//now calculating delta x and delta y
int dx=x[0]-1;
int dy=y[0]-1;
for(int i=1;i<n;i++){
dx=max(dx,x[i]-x[i-1]-1);
dy=max(dy,y[i]-y[i-1]-1);
}
dx=max(dx,w-x[n-1]);
dy=max(dy,h-y[n-1]);
cout<<dx*dy<<endl;
}
return 0;
}
|
[
"shareefhussain733@gmail.com"
] |
shareefhussain733@gmail.com
|
0a0b73415578e950b3ed0dfa2107836ffa412480
|
db79f3eb49039d18aa5897c81add5c5b218bbd3a
|
/src/test/scriptnum_tests.cpp
|
0e2280c5c45c657634c367f4809690fd48d3a3d7
|
[
"MIT"
] |
permissive
|
Imperium-Core-Developpers/imperium
|
44e381fb84c5ec859bad7bc26ad6dfc637d743ff
|
42536a92c27018d304c304f9f6fa39c8042b1183
|
refs/heads/master
| 2020-04-07T07:39:03.174068
| 2018-11-13T03:28:03
| 2018-11-13T03:28:03
| 154,446,008
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,473
|
cpp
|
// Copyright (c) 2012-2018 The Imperium Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <test/scriptnum10.h>
#include <script/script.h>
#include <test/test_imperium.h>
#include <boost/test/unit_test.hpp>
#include <limits.h>
#include <stdint.h>
BOOST_FIXTURE_TEST_SUITE(scriptnum_tests, BasicTestingSetup)
/** A selection of numbers that do not trigger int64_t overflow
* when added/subtracted. */
static const int64_t values[] = { 0, 1, -2, 127, 128, -255, 256, (1LL << 15) - 1, -(1LL << 16), (1LL << 24) - 1, (1LL << 31), 1 - (1LL << 32), 1LL << 40 };
static const int64_t offsets[] = { 1, 0x79, 0x80, 0x81, 0xFF, 0x7FFF, 0x8000, 0xFFFF, 0x10000};
static bool verify(const CScriptNum10& bignum, const CScriptNum& scriptnum)
{
return bignum.getvch() == scriptnum.getvch() && bignum.getint() == scriptnum.getint();
}
static void CheckCreateVch(const int64_t& num)
{
CScriptNum10 bignum(num);
CScriptNum scriptnum(num);
BOOST_CHECK(verify(bignum, scriptnum));
CScriptNum10 bignum2(bignum.getvch(), false);
CScriptNum scriptnum2(scriptnum.getvch(), false);
BOOST_CHECK(verify(bignum2, scriptnum2));
CScriptNum10 bignum3(scriptnum2.getvch(), false);
CScriptNum scriptnum3(bignum2.getvch(), false);
BOOST_CHECK(verify(bignum3, scriptnum3));
}
static void CheckCreateInt(const int64_t& num)
{
CScriptNum10 bignum(num);
CScriptNum scriptnum(num);
BOOST_CHECK(verify(bignum, scriptnum));
BOOST_CHECK(verify(CScriptNum10(bignum.getint()), CScriptNum(scriptnum.getint())));
BOOST_CHECK(verify(CScriptNum10(scriptnum.getint()), CScriptNum(bignum.getint())));
BOOST_CHECK(verify(CScriptNum10(CScriptNum10(scriptnum.getint()).getint()), CScriptNum(CScriptNum(bignum.getint()).getint())));
}
static void CheckAdd(const int64_t& num1, const int64_t& num2)
{
const CScriptNum10 bignum1(num1);
const CScriptNum10 bignum2(num2);
const CScriptNum scriptnum1(num1);
const CScriptNum scriptnum2(num2);
CScriptNum10 bignum3(num1);
CScriptNum10 bignum4(num1);
CScriptNum scriptnum3(num1);
CScriptNum scriptnum4(num1);
// int64_t overflow is undefined.
bool invalid = (((num2 > 0) && (num1 > (std::numeric_limits<int64_t>::max() - num2))) ||
((num2 < 0) && (num1 < (std::numeric_limits<int64_t>::min() - num2))));
if (!invalid)
{
BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + scriptnum2));
BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + num2));
BOOST_CHECK(verify(bignum1 + bignum2, scriptnum2 + num1));
}
}
static void CheckNegate(const int64_t& num)
{
const CScriptNum10 bignum(num);
const CScriptNum scriptnum(num);
// -INT64_MIN is undefined
if (num != std::numeric_limits<int64_t>::min())
BOOST_CHECK(verify(-bignum, -scriptnum));
}
static void CheckSubtract(const int64_t& num1, const int64_t& num2)
{
const CScriptNum10 bignum1(num1);
const CScriptNum10 bignum2(num2);
const CScriptNum scriptnum1(num1);
const CScriptNum scriptnum2(num2);
// int64_t overflow is undefined.
bool invalid = ((num2 > 0 && num1 < std::numeric_limits<int64_t>::min() + num2) ||
(num2 < 0 && num1 > std::numeric_limits<int64_t>::max() + num2));
if (!invalid)
{
BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - scriptnum2));
BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - num2));
}
invalid = ((num1 > 0 && num2 < std::numeric_limits<int64_t>::min() + num1) ||
(num1 < 0 && num2 > std::numeric_limits<int64_t>::max() + num1));
if (!invalid)
{
BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - scriptnum1));
BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - num1));
}
}
static void CheckCompare(const int64_t& num1, const int64_t& num2)
{
const CScriptNum10 bignum1(num1);
const CScriptNum10 bignum2(num2);
const CScriptNum scriptnum1(num1);
const CScriptNum scriptnum2(num2);
BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == scriptnum1));
BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != scriptnum1));
BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < scriptnum1));
BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > scriptnum1));
BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= scriptnum1));
BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= scriptnum1));
BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == num1));
BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != num1));
BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < num1));
BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > num1));
BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= num1));
BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= num1));
BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == scriptnum2));
BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != scriptnum2));
BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < scriptnum2));
BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > scriptnum2));
BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= scriptnum2));
BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= scriptnum2));
BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == num2));
BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != num2));
BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < num2));
BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > num2));
BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= num2));
BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= num2));
}
static void RunCreate(const int64_t& num)
{
CheckCreateInt(num);
CScriptNum scriptnum(num);
if (scriptnum.getvch().size() <= CScriptNum::nDefaultMaxNumSize)
CheckCreateVch(num);
else
{
BOOST_CHECK_THROW (CheckCreateVch(num), scriptnum10_error);
}
}
static void RunOperators(const int64_t& num1, const int64_t& num2)
{
CheckAdd(num1, num2);
CheckSubtract(num1, num2);
CheckNegate(num1);
CheckCompare(num1, num2);
}
BOOST_AUTO_TEST_CASE(creation)
{
for(size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i)
{
for(size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j)
{
RunCreate(values[i]);
RunCreate(values[i] + offsets[j]);
RunCreate(values[i] - offsets[j]);
}
}
}
BOOST_AUTO_TEST_CASE(operators)
{
for(size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i)
{
for(size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j)
{
RunOperators(values[i], values[i]);
RunOperators(values[i], -values[i]);
RunOperators(values[i], values[j]);
RunOperators(values[i], -values[j]);
RunOperators(values[i] + values[j], values[j]);
RunOperators(values[i] + values[j], -values[j]);
RunOperators(values[i] - values[j], values[j]);
RunOperators(values[i] - values[j], -values[j]);
RunOperators(values[i] + values[j], values[i] + values[j]);
RunOperators(values[i] + values[j], values[i] - values[j]);
RunOperators(values[i] - values[j], values[i] + values[j]);
RunOperators(values[i] - values[j], values[i] - values[j]);
}
}
}
BOOST_AUTO_TEST_SUITE_END()
|
[
"imperium.main.dev@gmail.com"
] |
imperium.main.dev@gmail.com
|
62cbd1b532e41adf47c523de20d19e7f982fcfdc
|
39b765fd2d2c17417eba777df5e8db08acf33267
|
/删除重复字符.cpp
|
885d094e0ac9b61ce61c46658525aa099de555ee
|
[] |
no_license
|
aeadod/C_break
|
dc2ef6dc613bbf4e1c43efc3933200d6a16d70c5
|
34ee8b23238d57a35488f8eb96a5267651bcd950
|
refs/heads/master
| 2020-04-05T12:31:32.977126
| 2018-11-18T12:20:50
| 2018-11-18T12:20:50
| 156,874,381
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 289
|
cpp
|
#include<stdio.h>
int main(){
char str[]="aabbcaedddd";
for(int i=0;str[i]!='\0';i++){
for(int j=i+1;str[j]!='\0';j++){
if(str[i]==str[j]){
int k=j+1;
for(;str[k]!='\0';k++){
str[k-1]=str[k];
}
str[k-1]='\0';
j--;
}
}
}
printf("%s",str);
}
|
[
"aeadod@163.com"
] |
aeadod@163.com
|
766fcaa4df438298cc46ca17797875e4fc72e7a3
|
681d0756af04816e6b3aa77a0aa635f47634625e
|
/day01/ex00/main.cpp
|
4d2c9b1054da839d911623472a6ede77eacf4704
|
[] |
no_license
|
vovvoy/cpp_pool
|
a76791dcee57bc090a2ab1fbc064b81a8a25c2ca
|
9dbb9b25b4011d2943bee3245519cd132422d34f
|
refs/heads/main
| 2023-03-24T08:19:33.241705
| 2021-03-16T18:21:56
| 2021-03-16T18:21:56
| 335,119,598
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,149
|
cpp
|
#include "Pony.hpp"
void ponyOnTheHeap(Pony* blabla){
std::cout << "\n\nThis is a new pony on the heap!!!\n";
std::cout << "And here is the some information about her." << std::endl;
std::cout << "codename: " << blabla->getPonyNickname() << std::endl;
std::cout << "age: " << blabla->getPonyAge() << std::endl;
std::cout << "length: " << blabla->getPonyLength() << std::endl;
std::cout << "height: " << blabla->getPonyHeight() << std::endl;
}
void ponyOnTheStack(Pony uh){
std::cout << "\n\nThis is a new pony on the stack!!!\n";
std::cout << "And here is the some information about him." << std::endl;
std::cout << "codename: " << uh.getPonyNickname() << std::endl;
std::cout << "age: " << uh.getPonyAge() << std::endl;
std::cout << "length: " << uh.getPonyLength() << std::endl;
std::cout << "height: " << uh.getPonyHeight() << std::endl << std::endl << std::endl;
}
int main() {
Pony vovvoy = Pony("Ps001", 25, 1.5, 96.7);
Pony* ljerrica = new Pony("Ph001", 10, 1.7, 77.3);
ponyOnTheHeap(ljerrica);
ponyOnTheStack(vovvoy);
delete ljerrica;
return (0);
}
|
[
"ormonbaev.marsel@gmail.com"
] |
ormonbaev.marsel@gmail.com
|
2534e0d118fbbbf7e949061b40d3db8b94939c3a
|
e181eef3a9d74902d45c93d51eda6f984f65a2cf
|
/mm08.cpp
|
9e687020e5df711376c858e6dc7deaec23b67d5e
|
[] |
no_license
|
shigurewg/ITSA-cpp
|
5c7c22083fe3585e11ba268de8fdcd5c2ef6d796
|
563ae57eba86ae34c45c9cfd79120cccef355432
|
refs/heads/master
| 2020-06-03T11:26:31.770236
| 2019-06-13T03:47:08
| 2019-06-13T03:47:08
| 191,549,635
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 133
|
cpp
|
#include<iostream>
using namespace std;
int main(){
int a,b;
while(cin>>a){
cin>>b;
cout<<(a+b)*(a+b)<<endl;
}
return 0;
}
|
[
"46485606+shigurewg@users.noreply.github.com"
] |
46485606+shigurewg@users.noreply.github.com
|
79a5a09693f464c7eb2f354016408d49331a0626
|
438849e8cccfcaf432d6219bcf2561b8492fba76
|
/src/kernel/process.h
|
faa25a7e7f78714f48d0779f456c72a56accfc5d
|
[
"MIT"
] |
permissive
|
tuslm/os-simulator
|
82a6750e4e2f15d757181e3712daa2dfe409bc34
|
e1d1a6952db6f72c4a39873d90419cfe2e9bb22c
|
refs/heads/master
| 2021-08-23T12:16:29.513145
| 2017-12-04T21:49:22
| 2017-12-04T21:49:22
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,161
|
h
|
#pragma once
#include "..\api\api.h"
#include <Windows.h>
#include <mutex>
#include <vector>
const int PCB_SIZE = 256;
//PCB tabulka pro ulozeni zaznamu o procesech
typedef struct process_control_block {
const char *name; //jmeno procesu
int par_pid; //pid rodice --- bude potreba?
const char *path; //aktualni cesta procesu v ktere pracuje
std::thread thread; //vlakno ve kterem se spusti proces - pro ziskani thread ID pouzit .get_id()
std::thread::id thread_id;
std::vector<kiv_os::THandle> descriptors; //descriptory pro in, out, err
}PCB;
// handle pro procesy (podobne jako HandleIO)
void HandleProcess(kiv_os::TRegisters ®s);
//name - jmeno procesu, parent_pid - id rodice, arg - odkaz na strukturu s argumenty pro proces
int createProcess(char *name, kiv_os::TProcess_Startup_Info *arg);
//spusteni procesu v novem vlakne
void runProcess(kiv_os::TEntry_Point func, int pid, char *arg, bool stdinIsConsole);
HRESULT joinProcess(int pid);
void Wait_For(int pid, kiv_os::THandle std_in);
void Wait_For(int miliseconds);
kiv_os::THandle Get_PCB();
//tabulka procesu
extern PCB *process_table[PCB_SIZE];
|
[
"m.tusl@seznam.cz"
] |
m.tusl@seznam.cz
|
5cfabbf50006f9964576bb8e4a733dbf7903c250
|
b33a9177edaaf6bf185ef20bf87d36eada719d4f
|
/qtbase/examples/sql/relationaltablemodel/relationaltablemodel.cpp
|
e764d8cebaf59dc2d57052a70bc259a06d60e4c2
|
[
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-commercial-license",
"LGPL-2.0-or-later",
"LGPL-2.1-only",
"GFDL-1.3-only",
"LicenseRef-scancode-qt-commercial-1.1",
"LGPL-3.0-only",
"LicenseRef-scancode-qt-company-exception-lgpl-2.1",
"GPL-1.0-or-later",
"GPL-3.0-only",
"BSD-3-Clause",
"LGPL-2.1-or-later",
"GPL-2.0-only",
"Qt-LGPL-exception-1.1",
"LicenseRef-scancode-digia-qt-preview",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-generic-exception"
] |
permissive
|
wgnet/wds_qt
|
ab8c093b8c6eead9adf4057d843e00f04915d987
|
8db722fd367d2d0744decf99ac7bafaba8b8a3d3
|
refs/heads/master
| 2021-04-02T11:07:10.181067
| 2020-06-02T10:29:03
| 2020-06-02T10:34:19
| 248,267,925
| 1
| 0
|
Apache-2.0
| 2020-04-30T12:16:53
| 2020-03-18T15:20:38
| null |
UTF-8
|
C++
| false
| false
| 4,111
|
cpp
|
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd 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."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtWidgets>
#include <QtSql>
#include "../connection.h"
void initializeModel(QSqlRelationalTableModel *model)
{
//! [0]
model->setTable("employee");
//! [0]
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
//! [1]
model->setRelation(2, QSqlRelation("city", "id", "name"));
//! [1] //! [2]
model->setRelation(3, QSqlRelation("country", "id", "name"));
//! [2]
//! [3]
model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("Name"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("City"));
model->setHeaderData(3, Qt::Horizontal, QObject::tr("Country"));
//! [3]
model->select();
}
QTableView *createView(const QString &title, QSqlTableModel *model)
{
//! [4]
QTableView *view = new QTableView;
view->setModel(model);
view->setItemDelegate(new QSqlRelationalDelegate(view));
//! [4]
view->setWindowTitle(title);
return view;
}
void createRelationalTables()
{
QSqlQuery query;
query.exec("create table employee(id int primary key, name varchar(20), city int, country int)");
query.exec("insert into employee values(1, 'Espen', 5000, 47)");
query.exec("insert into employee values(2, 'Harald', 80000, 49)");
query.exec("insert into employee values(3, 'Sam', 100, 1)");
query.exec("create table city(id int, name varchar(20))");
query.exec("insert into city values(100, 'San Jose')");
query.exec("insert into city values(5000, 'Oslo')");
query.exec("insert into city values(80000, 'Munich')");
query.exec("create table country(id int, name varchar(20))");
query.exec("insert into country values(1, 'USA')");
query.exec("insert into country values(47, 'Norway')");
query.exec("insert into country values(49, 'Germany')");
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
if (!createConnection())
return 1;
createRelationalTables();
QSqlRelationalTableModel model;
initializeModel(&model);
QTableView *view = createView(QObject::tr("Relational Table Model"), &model);
view->show();
return app.exec();
}
|
[
"p_pavlov@wargaming.net"
] |
p_pavlov@wargaming.net
|
fb2b4a84eb424fc5ecf1075e56b880efdf66cde2
|
2d5100b882aba165f6706f88b23c38977a7825f3
|
/2018-2019/hps/main.cpp
|
c64481f5a2485fd2cedc45bc0c42cef09e123719
|
[] |
no_license
|
anish-lakkapragada/USACO-Solutions
|
ac8b8857e7a66dfacc3561ee5ca61a5f8be2430a
|
74383af923cbdb0c54c8a9cddaa1a0ab8117e816
|
refs/heads/master
| 2023-02-03T04:25:43.432418
| 2020-12-19T07:18:45
| 2020-12-19T07:18:45
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,952
|
cpp
|
//http://usaco.org/index.php?page=viewproblem2&cpid=691
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <array>
#include <map>
#include <queue>
#include <unordered_map>
using namespace std;
vector<string> split(string str, string character){
vector<string> result;
long long s=0;
long long i=0;
while(i<str.length()){
if(str[i]==character[0]||i==str.length()-1){
long long x=i-s;
if(i==str.length()-1){
x++;
}
result.push_back(str.substr(s,x));
s=i+1;
}
i++;
}
return result;
}
vector<vector<int>> getFix(vector<int> moves){
vector<vector<int>> fix;
fix.push_back({0,0,0});
for(int i=0;i<moves.size();i++){
fix.push_back(fix[i]);
fix[i+1][moves[i]]++;
}
for(int i=0;i<fix.size();i++){
for(int k=0;k<fix[i].size();k++){
cout << fix[i][k] << " ";
}
cout << endl;
}
cout << endl;
return fix;
}
int main() {
ofstream fout ("hps.out");
ifstream fin ("hps.in");
vector<string> inputstrings;
string contents;
while(getline(fin,contents)){
inputstrings.push_back(contents);
}
vector<int> moves;
for(int i=1;i<inputstrings.size();i++){
int num=0;
if(inputstrings[i][0]==*"P"){
num=1;
}else if(inputstrings[i][0]==*"S"){
num=2;
}
moves.push_back(num);
}
cout << endl;
vector<vector<int>> prefix=getFix(moves);
reverse(moves.begin(),moves.end());
vector<vector<int>> suffix=getFix(moves);
int ans=0;
for(int i=0;i<=moves.size();i++){
for(int k=0;k<3;k++){
for(int j=0;j<3;j++){
ans=max(ans,prefix[i][k]+suffix[moves.size()-i][j]);
}
}
}
fout << ans << endl;
return 0;
}
|
[
"38841491+KentoNishi@users.noreply.github.com"
] |
38841491+KentoNishi@users.noreply.github.com
|
324fc8c3ffff5c133dcf8401995b48b81ff00859
|
f7d896e5dcdf16338ea2c17f670b2c8129a6069e
|
/msad2023_pri/NumCpp/Functions/fromiter.hpp
|
678d299f5ae58a62fea8c6d3538c0a4f1196e90e
|
[] |
no_license
|
wataniguchi/EV3RT
|
4268b3817ac0037b5ccf52ceddd08f7b9320b9e6
|
330ca40a40b67043ffa77184f833ff1d9b54c306
|
refs/heads/master
| 2023-08-31T00:59:04.391244
| 2023-08-07T10:20:58
| 2023-08-07T10:20:58
| 177,363,579
| 0
| 10
| null | 2023-08-07T10:20:59
| 2019-03-24T02:50:03
|
C++
|
UTF-8
|
C++
| false
| false
| 1,960
|
hpp
|
/// @file
/// @author David Pilger <dpilger26@gmail.com>
/// [GitHub Repository](https://github.com/dpilger26/NumCpp)
///
/// License
/// Copyright 2018-2022 David Pilger
///
/// 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.
///
/// Description
/// Functions for working with NdArrays
///
#pragma once
#include <iterator>
#include <vector>
#include "NumCpp/NdArray.hpp"
namespace nc
{
//============================================================================
// Method Description:
/// Create a new 1-dimensional array from an iterable object.
///
/// NumPy Reference: https://www.numpy.org/devdocs/reference/generated/numpy.fromiter.html
///
/// @param inBegin
/// @param inEnd
/// @return NdArray
///
template<typename dtype, typename Iter>
NdArray<dtype> fromiter(Iter inBegin, Iter inEnd)
{
return NdArray<dtype>(inBegin, inEnd);
}
} // namespace nc
|
[
"wataru@taniguchifamily.com"
] |
wataru@taniguchifamily.com
|
60b6750aeaefad6d162b583256db8bce96d6c023
|
2fb0b014f1f2568ae544fd11d36221813e254a5f
|
/DataStructures/BIndexedTree.cpp
|
e57397f02ce216464bf33c98eba4283d689ec5d0
|
[] |
no_license
|
pradeepgangwar/Programming-Codes
|
2fca44cbc0cc17249f468e2e9053c9a766be5c7d
|
92054408152ef2afdec7ab573f79fcfac5b283e8
|
refs/heads/master
| 2021-05-24T02:14:03.677429
| 2020-05-02T02:07:25
| 2020-05-02T02:07:25
| 82,897,597
| 0
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 827
|
cpp
|
//code to fing sum of array and update the array simultaneoulsy.
#include<bits/stdc++.h>
using namespace std;
int a[100],b[101]={0},n;
void update(int i, int u)
{
int length=0;
while(i<=n)
{
b[i] += u;
length = i&(-i);
i += length;
}
}
int query(int i)
{
int sum = 0;
for(; i>0; i-=i&(-i))
{
sum += b[i];
}
return sum;
}
int main()
{
int x,i,q;
cout<<"Enter the number of elements"<<endl;
cin>>n;
cout<<"Enter: ";
for(i=1;i<=n;i++)
{
cin>>a[i];
update(i,a[i]);
}
while(1)
{
cout<<"1 for sum \n2 for update \n0 for quit\n";
cin>>q;
if(q==1)
{
cout<"Enter the index till which you want the sum: ";
cin>>x;
cout<<query(x);
}
else if(q==2)
{
cout<<"Enter the index separated by the updated value: ";
cin>>i>>x;
update(i,x);
}
else
{
return 0;
}
}
}
|
[
"pradeepgangwar39@gmail.com"
] |
pradeepgangwar39@gmail.com
|
e9661fcc96b3a4d149303822622daf16c4c548de
|
c937cc18c85de45cecdffe540a3d791e627c770a
|
/《深入浅出程序设计竞赛》资料/代码/第6章/6-3.cpp
|
f720e85c78c0f28b28254c6d9c8aa682bcbb8609
|
[] |
no_license
|
duanyiting2018/learn_cPlusPlus
|
5c514c2aa0f2440457b0dce4973f71c880520bc7
|
abf13f1e205be5ea261c35db09dc5d03f58f4bda
|
refs/heads/master
| 2021-12-10T14:45:11.785187
| 2021-08-09T13:31:22
| 2021-08-09T13:31:22
| 171,656,502
| 1
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 637
|
cpp
|
#include<bits/stdc++.h>
using namespace std;
int main(){
char a[110];
int ans[26]={0};//ans[0]到ans[25]分别表示'a'到'z'出现的次数
int l,maxn=0,minn=10000,delta;//len,maxn,minn,maxn-minn
scanf("%s",a);
l=strlen(a);
for(int i=0;i<l;i++){
ans[a[i]-'a']++;
}
for(int i=0;i<26;i++){
if(ans[i]>maxn) maxn=ans[i];
if(ans[i]!=0&&ans[i]<minn) minn=ans[i];
}
delta=maxn-minn;
if(delta==0||delta==1){
cout<<"No Answer"<<endl<<"0"<<endl;
return 0;
}
for(int h=2;h*h<=delta;h++){
if(delta%h==0){
cout<<"No Answer"<<endl<<"0"<<endl;
return 0;
}
}
cout<<"Lucky Word"<<endl<<maxn-minn<<endl;
return 0;
}
|
[
"1036179833@qq.com"
] |
1036179833@qq.com
|
01e2d9914ea7939375d4a9985ed6b6a24ca105b8
|
a608d262e264477f0bceb95a752aba25aca7048d
|
/CarND-Kidnapped-Vehicle-Project-P6/src/main.cpp
|
00e2c5d965c80cbec21f1801f234c0a28817a730
|
[
"MIT"
] |
permissive
|
thejeshk/Udacity_Self_Driving_Car_Nanodegree
|
6b425211345f2cf2cd47746ec7f647a55425abb3
|
f95da84aa02c62815f95dcc7bf723633273eddc4
|
refs/heads/master
| 2022-12-24T17:15:27.326113
| 2020-10-10T06:22:40
| 2020-10-10T06:22:40
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,288
|
cpp
|
#include <math.h>
#include <uWS/uWS.h>
#include <iostream>
#include <string>
#include "json.hpp"
#include "particle_filter.h"
// for convenience
using nlohmann::json;
using std::string;
using std::vector;
// Checks if the SocketIO event has JSON data.
// If there is data the JSON object in string format will be returned,
// else the empty string "" will be returned.
string hasData(string s) {
auto found_null = s.find("null");
auto b1 = s.find_first_of("[");
auto b2 = s.find_first_of("]");
if (found_null != string::npos) {
return "";
} else if (b1 != string::npos && b2 != string::npos) {
return s.substr(b1, b2 - b1 + 1);
}
return "";
}
int main() {
uWS::Hub h;
// Set up parameters here
double delta_t = 0.1; // Time elapsed between measurements [sec]
double sensor_range = 50; // Sensor range [m]
// GPS measurement uncertainty [x [m], y [m], theta [rad]]
double sigma_pos[3] = {0.3, 0.3, 0.01};
// Landmark measurement uncertainty [x [m], y [m]]
double sigma_landmark[2] = {0.3, 0.3};
// Read map data
Map map;
if (!read_map_data("../data/map_data.txt", map)) {
std::cout << "Error: Could not open map file" << std::endl;
return -1;
}
// Create particle filter
ParticleFilter pf;
h.onMessage([&pf, &map, &delta_t, &sensor_range, &sigma_pos, &sigma_landmark](
uWS::WebSocket<uWS::SERVER> ws, char *data, size_t length,
uWS::OpCode opCode) {
// "42" at the start of the message means there's a websocket message event.
// The 4 signifies a websocket message
// The 2 signifies a websocket event
if (length && length > 2 && data[0] == '4' && data[1] == '2') {
auto s = hasData(string(data));
if (s != "") {
auto j = json::parse(s);
string event = j[0].get<string>();
if (event == "telemetry") {
// j[1] is the data JSON object
if (!pf.initialized()) {
// Sense noisy position data from the simulator
double sense_x = std::stod(j[1]["sense_x"].get<string>());
double sense_y = std::stod(j[1]["sense_y"].get<string>());
double sense_theta = std::stod(j[1]["sense_theta"].get<string>());
pf.init(sense_x, sense_y, sense_theta, sigma_pos);
} else {
// Predict the vehicle's next state from previous
// (noiseless control) data.
double previous_velocity =
std::stod(j[1]["previous_velocity"].get<string>());
double previous_yawrate =
std::stod(j[1]["previous_yawrate"].get<string>());
pf.prediction(delta_t, sigma_pos, previous_velocity,
previous_yawrate);
}
// receive noisy observation data from the simulator
// sense_observations in JSON format
// [{obs_x,obs_y},{obs_x,obs_y},...{obs_x,obs_y}]
vector<LandmarkObs> noisy_observations;
string sense_observations_x = j[1]["sense_observations_x"];
string sense_observations_y = j[1]["sense_observations_y"];
vector<float> x_sense;
std::istringstream iss_x(sense_observations_x);
std::copy(std::istream_iterator<float>(iss_x),
std::istream_iterator<float>(),
std::back_inserter(x_sense));
vector<float> y_sense;
std::istringstream iss_y(sense_observations_y);
std::copy(std::istream_iterator<float>(iss_y),
std::istream_iterator<float>(),
std::back_inserter(y_sense));
for (int i = 0; i < x_sense.size(); ++i) {
LandmarkObs obs;
obs.x = x_sense[i];
obs.y = y_sense[i];
noisy_observations.push_back(obs);
}
// Update the weights and resample
pf.updateWeights(sensor_range, sigma_landmark, noisy_observations,
map);
pf.resample();
// Calculate and output the average weighted error of the particle
// filter over all time steps so far.
vector<Particle> particles = pf.particles;
int num_particles = particles.size();
double highest_weight = -1.0;
Particle best_particle;
double weight_sum = 0.0;
for (int i = 0; i < num_particles; ++i) {
if (particles[i].weight > highest_weight) {
highest_weight = particles[i].weight;
best_particle = particles[i];
}
weight_sum += particles[i].weight;
}
std::cout << "highest w " << highest_weight << std::endl;
std::cout << "average w " << weight_sum / num_particles << std::endl;
json msgJson;
msgJson["best_particle_x"] = best_particle.x;
msgJson["best_particle_y"] = best_particle.y;
msgJson["best_particle_theta"] = best_particle.theta;
// Optional message data used for debugging particle's sensing
// and associations
msgJson["best_particle_associations"] =
pf.getAssociations(best_particle);
msgJson["best_particle_sense_x"] =
pf.getSenseCoord(best_particle, "X");
msgJson["best_particle_sense_y"] =
pf.getSenseCoord(best_particle, "Y");
auto msg = "42[\"best_particle\"," + msgJson.dump() + "]";
// std::cout << msg << std::endl;
ws.send(msg.data(), msg.length(), uWS::OpCode::TEXT);
} // end "telemetry" if
} else {
string msg = "42[\"manual\",{}]";
ws.send(msg.data(), msg.length(), uWS::OpCode::TEXT);
}
} // end websocket message if
}); // end h.onMessage
h.onConnection([](uWS::WebSocket<uWS::SERVER> ws, uWS::HttpRequest req) {
std::cout << "Connected!!!" << std::endl;
});
h.onDisconnection([](uWS::WebSocket<uWS::SERVER> ws, int code, char *message,
size_t length) {
ws.close();
std::cout << "Disconnected" << std::endl;
});
int port = 4567;
if (h.listen(port)) {
std::cout << "Listening to port " << port << std::endl;
} else {
std::cerr << "Failed to listen to port" << std::endl;
return -1;
}
h.run();
}
|
[
"rphan@ryerson.ca"
] |
rphan@ryerson.ca
|
6fb0a983617ea1b38f94c67c4c62626accb76728
|
e5935a9b4b7f61c2490e62c8e8ac021c24db4559
|
/directfire_github/trunk/uilib/widgets/fsizespritedelegate.h
|
e3b5fa9f6983ee63c7ac074243ef4ffb2b377fc6
|
[
"MIT"
] |
permissive
|
cubemoon/DirectFire-android
|
93c6aaf04d6f74854957543b83ce6f24722a978a
|
10c757e1be0b25dee951f9ba3a0e1f6d5c04a938
|
refs/heads/master
| 2021-01-24T23:41:04.550917
| 2014-01-13T09:59:51
| 2014-01-13T09:59:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 540
|
h
|
#ifndef _fsizespritedelegate_h_
#define _fsizespritedelegate_h_
#include "cocos2d.h"
using namespace cocos2d;
#include "absfixedsizewidget.h"
#include <string>
using namespace std;
namespace uilib
{
class FSizeSpriteDelegate : public BasFixedSizeWidget
{
public:
FSizeSpriteDelegate(CCSprite *sprite,const CCSize &size = CCSizeMake(0,0));
virtual ~FSizeSpriteDelegate();
virtual void getFixedSize(CCSize &size);
CCSprite *getSprite() { return m_sprite;}
protected:
CCSprite *m_sprite;
CCSize m_size;
};
}
#endif
|
[
"zhwsh00@126.com"
] |
zhwsh00@126.com
|
de3ee5ffa368a53dfdeff1cbd73e302829b1fe17
|
3ea829b5ad3cf1cc9e6eb9b208532cf57b7ba90f
|
/libvpvl/src/engine/cg/Renderer.cc
|
ec5eb34208216119cdc2c5adb1d5e08f764ca572
|
[] |
no_license
|
hkrn/MMDAI
|
2ae70c9be7301e496e9113477d4a5ebdc5dc0a29
|
9ca74bf9f6f979f510f5355d80805f935cc7e610
|
refs/heads/master
| 2021-01-18T21:30:22.057260
| 2016-05-10T16:30:41
| 2016-05-10T16:30:41
| 1,257,502
| 74
| 22
| null | 2013-07-13T21:28:16
| 2011-01-15T12:05:26
|
C++
|
UTF-8
|
C++
| false
| false
| 15,016
|
cc
|
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2009-2011 Nagoya Institute of Technology */
/* Department of Computer Science */
/* 2010-2012 hkrn */
/* */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* - Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* - Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials provided */
/* with the distribution. */
/* - Neither the name of the MMDAI project team 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 <vpvl/vpvl.h>
#include <vpvl/cg/Renderer.h>
#include <vpvl/internal/gl2.h>
namespace vpvl
{
namespace cg
{
class EffectParameters
{
public:
EffectParameters(CGeffect effect) : m_effect(effect) {
m_controlObject = cgGetEffectParameterBySemantic(effect, "CONTROLOBJECT");
m_lightDirection = getParameterBySemanticsAndAnnotation("DIRECTION", "Object", "Camera", false);
m_lightDirection = getParameterBySemanticsAndAnnotation("POSITION", "Object", "Camera", false);
m_lightDirection = getParameterBySemanticsAndAnnotation("DIRECTION", "Object", "Light", false);
m_lightDirection = getParameterBySemanticsAndAnnotation("POSITION", "Object", "Light", false);
m_lightAmbient = getParameterBySemanticsAndAnnotation("AMBIENT", "Object", "Light", false);
m_lightDiffuse = getParameterBySemanticsAndAnnotation("DIFFUSE", "Object", "Light", false);
m_lightSpecular = getParameterBySemanticsAndAnnotation("SPECULAR", "Object", "Light", false);
m_lightEmission = getParameterBySemanticsAndAnnotation("EMISSION", "Object", "Light", false);
m_materialAmbient = getParameterBySemanticsAndAnnotation("AMBIENT", "Object", "Geometry", false);
m_materialDiffuse = getParameterBySemanticsAndAnnotation("DIFFUSE", "Object", "Geometry", false);
m_materialSpecular = getParameterBySemanticsAndAnnotation("SPECULAR", "Object", "Geometry", false);
m_materialEmission = getParameterBySemanticsAndAnnotation("EMISSION", "Object", "Geometry", false);
m_materialShininess = getParameterBySemanticsAndAnnotation("SHININESS", "Object", "Geometry", false);
m_materialSphereMap = cgGetEffectParameterBySemantic(effect, "MATERIALSPHEREMAP");
m_materialTexture = cgGetEffectParameterBySemantic(effect, "MATERIALTEXTURE");
m_opadd = cgCreateEffectParameter(effect, "opadd", CG_BOOL);
m_parthf = cgCreateEffectParameter(effect, "parthf", CG_BOOL);
m_projectionMatrix = cgGetEffectParameterBySemantic(effect, "PROJECTION");
m_spadd = cgCreateEffectParameter(effect, "spadd", CG_BOOL);
m_subsetCount = cgCreateEffectParameter(effect, "SubsetCount", CG_INT);
m_transp = cgCreateEffectParameter(effect, "transp", CG_BOOL);
m_useSphereMap = cgCreateEffectParameter(effect, "use_spheremap", CG_BOOL);
m_useTexture = cgCreateEffectParameter(effect, "use_texture", CG_BOOL);
m_useToon = cgCreateEffectParameter(effect, "use_toon", CG_BOOL);
m_vertexCount = cgCreateEffectParameter(effect, "VertexCount", CG_INT);
m_viewMatrix = getParameterBySemanticsAndAnnotation("VIEW", "Object", "Camera", true);
m_viewport = cgGetEffectParameterBySemantic(effect, "VIEWPORT");
m_viewProjectionMatrix = getParameterBySemanticsAndAnnotation("VIEWPROJECTION", "Object", "Camera", true);
m_worldMatrix = getParameterBySemanticsAndAnnotation("WORLD", "Object", "Camera", true);
m_worldViewMatrix = getParameterBySemanticsAndAnnotation("WORLDVIEW", "Object", "Camera", true);
m_worldViewProjectionMatrix = getParameterBySemanticsAndAnnotation("WORLDVIEWPROJECTION", "Object", "Camera", true);
}
~EffectParameters() {
cgDestroyEffect(m_effect);
m_effect = 0;
}
void setTechniqueAnnotation(CGtechnique technique) {
CGannotation a = cgGetFirstTechniqueAnnotation(technique);
while (a) {
const char *name = cgGetAnnotationName(a);
const char *value;
CGbool boolean;
if (strcmp(name, "Subset") == 0) {
value = cgGetStringAnnotationValue(a);
}
else if (strcmp(name, "MMDPass") == 0) {
value = cgGetStringAnnotationValue(a);
}
else if (strcmp(name, "UseTexture") == 0) {
boolean = getBoolByAnnotation(a);
}
else if (strcmp(name, "UseSphereMap") == 0) {
boolean = getBoolByAnnotation(a);
}
else if (strcmp(name, "UseToon") == 0) {
boolean = getBoolByAnnotation(a);
}
}
}
void setMatrix(const Scene *scene) {
float matrix4x4[16];
scene->getModelViewMatrix(matrix4x4);
setMatrixParameter(m_viewMatrix, matrix4x4);
scene->getProjectionMatrix(matrix4x4);
setMatrixParameter(m_projectionMatrix, matrix4x4);
}
void setLight(const Scene *scene) {
setParameter4fv(m_lightPosition, scene->lightPosition());
}
void setMaterial(const Material *material, const gl2::PMDModelMaterialPrivate &materialPrivate, bool enableToon) {
Color average, ambient, diffuse, specular;
float alpha = material->opacity();
ambient = material->ambient();
ambient.setW(ambient.w() * alpha);
diffuse = material->diffuse();
diffuse.setW(diffuse.w() * alpha);
specular = material->specular();
specular.setW(specular.w() * alpha);
setParameter4fv(m_materialAmbient, ambient);
setParameter4fv(m_materialDiffuse, diffuse);
setParameter4fv(m_materialSpecular, specular);
setParameter1f(m_materialShininess, material->shiness());
cgGLSetTextureParameter(m_materialTexture, materialPrivate.mainTextureID);
cgGLSetParameter1f(m_spadd, material->isMainSphereAdd() || material->isSubSphereAdd());
cgGLSetParameter1f(m_useSphereMap, material->isMainSphereAdd() || material->isMainSphereModulate()
|| material->isSubSphereAdd() || material->isSubSphereModulate());
cgGLSetParameter1f(m_useTexture, materialPrivate.mainTextureID || materialPrivate.subTextureID);
cgGLSetParameter1f(m_useToon, enableToon);
cgGLSetParameter1f(m_parthf, 0);
cgGLSetParameter1f(m_transp, 0);
}
void setViewport(Scene *scene) {
CGparameter p = m_viewport;
float width = scene->width(), height = scene->height();
while (p) {
cgGLSetParameter2f(p, width, height);
p = cgGetNextParameter(p);
}
}
void setVertexCount(int size) {
setParameter1f(m_vertexCount, size);
}
void setSubsetCount(int size) {
setParameter1f(m_subsetCount, size);
}
private:
void setParameter1f(CGparameter p, float value) {
cgGLSetParameter1f(p, value);
}
void setParameter4fv(CGparameter p, const float *value) {
cgGLSetParameter4fv(p, value);
}
void setMatrixParameter(CGparameter p, const float *matrix) {
cgGLSetMatrixParameterfc(p, matrix);
}
CGbool getBoolByAnnotation(CGannotation a) {
int nbools = 0;
const CGbool *bools = cgGetBoolAnnotationValues(a, &nbools);
return nbools == 1 ? bools[0] : CG_FALSE;
}
CGparameter getParameterBySemanticsAndAnnotation(const char *semantics, const char *key, const char *target, bool isDefault) {
CGparameter p = cgGetEffectParameterBySemantic(m_effect, semantics);
CGannotation a = cgGetFirstParameterAnnotation(p);
while (a) {
const char *name = cgGetAnnotationName(a);
const char *value = cgGetStringAnnotationValue(a);
if (strcmp(name, key) == 0 && strcmp(value, target) == 0)
return p;
a = cgGetNextAnnotation(a);
}
return isDefault ? p : 0;
}
CGeffect m_effect;
CGparameter m_worldMatrix;
CGparameter m_viewMatrix;
CGparameter m_projectionMatrix;
CGparameter m_worldViewMatrix;
CGparameter m_viewProjectionMatrix;
CGparameter m_worldViewProjectionMatrix;
CGparameter m_cameraDirection;
CGparameter m_cameraPosition;
CGparameter m_lightDirection;
CGparameter m_lightPosition;
CGparameter m_lightAmbient;
CGparameter m_lightDiffuse;
CGparameter m_lightSpecular;
CGparameter m_lightEmission;
CGparameter m_materialAmbient;
CGparameter m_materialDiffuse;
CGparameter m_materialSpecular;
CGparameter m_materialEmission;
CGparameter m_materialShininess;
CGparameter m_materialTexture;
CGparameter m_materialSphereMap;
CGparameter m_viewport;
CGparameter m_controlObject;
CGparameter m_parthf;
CGparameter m_spadd;
CGparameter m_transp;
CGparameter m_useTexture;
CGparameter m_useSphereMap;
CGparameter m_useToon;
CGparameter m_opadd;
CGparameter m_vertexCount;
CGparameter m_subsetCount;
};
class PMDModelUserData : public gl2::PMDModelUserData
{
public:
PMDModelUserData() : gl2::PMDModelUserData() {}
~PMDModelUserData() {}
EffectParameters *parameters;
};
Renderer::Renderer(IDelegate *delegate, int width, int height, int fps)
: gl2::Renderer(delegate, width, height, fps),
m_context(0)
{
cgGLSetDebugMode(CG_TRUE);
m_context = cgCreateContext();
}
Renderer::~Renderer()
{
cgDestroyContext(m_context);
m_context = 0;
}
void Renderer::uploadModel(PMDModel *model, const std::string &dir)
{
PMDModelUserData *userData = new PMDModelUserData();
Renderer::IDelegate *delegate = static_cast<Renderer::IDelegate *>(m_delegate);
std::string source;
userData->parameters = 0;
if (delegate->loadEffect(model, dir, source)) {
CGeffect effect = cgCreateEffect(m_context, source.c_str(), NULL);
if (effect) {
userData->parameters = new EffectParameters(effect);
}
else {
const char *message = cgGetErrorString(cgGetError());
log0(Renderer::kLogWarning,
"Loading an effect (%s) error: %s",
m_delegate->toUnicode(model->name()).c_str(), message);
}
}
gl2::Renderer::uploadModel0(userData, model, dir);
}
void Renderer::deleteModel(PMDModel *&model)
{
PMDModelUserData *userData = static_cast<PMDModelUserData *>(model->userData());
delete userData->parameters;
userData->parameters = 0;
gl2::Renderer::deleteModel(model);
}
void Renderer::renderModel(const PMDModel *model)
{
PMDModelUserData *userData = static_cast<PMDModelUserData *>(model->userData());
userData->parameters ? renderModel0(userData, model) : gl2::Renderer::renderModel(model);
}
void Renderer::renderModel0(const cg::PMDModelUserData *userData, const PMDModel *model)
{
EffectParameters *p = userData->parameters;
size_t stride = model->strideSize(PMDModel::kVerticesStride), vsize = model->vertices().count();
glBindBuffer(GL_ARRAY_BUFFER, userData->vertexBufferObjects[gl2::kModelVertices]);
glVertexPointer(3, GL_FLOAT, vsize * stride, reinterpret_cast<const GLvoid *>(stride));
stride = model->strideOffset(PMDModel::kNormalsStride);
glNormalPointer(GL_FLOAT, vsize * stride, reinterpret_cast<const GLvoid *>(stride));
glClientActiveTexture(GL_TEXTURE0);
stride = model->strideOffset(PMDModel::kTextureCoordsStride);
glTexCoordPointer(2, GL_FLOAT, vsize * stride, reinterpret_cast<const GLvoid *>(stride));
p->setMatrix(m_scene);
p->setLight(m_scene);
const bool enableToon = model->isToonEnabled();
// toon
if (enableToon) {
stride = model->strideOffset(PMDModel::kToonTextureStride);
glClientActiveTexture(GL_TEXTURE1);
glTexCoordPointer(2, GL_FLOAT, vsize * stride, reinterpret_cast<const GLvoid *>(stride));
}
const MaterialList &materials = model->materials();
const gl2::PMDModelMaterialPrivate *materialPrivates = userData->materials;
const int nmaterials = materials.count();
size_t offset = 0;
p->setViewport(m_scene);
p->setVertexCount(vsize);
p->setSubsetCount(nmaterials);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, userData->vertexBufferObjects[gl2::kModelIndices]);
for (int i = 0; i < nmaterials; i++) {
const Material *material = materials[i];
const gl2::PMDModelMaterialPrivate &materialPrivate = materialPrivates[i];
const int nindices = material->countIndices();
material->opacity() < 1.0f ? glDisable(GL_CULL_FACE) : glEnable(GL_CULL_FACE);
p->setMaterial(material, materialPrivate, enableToon);
glDrawElements(GL_TRIANGLES, nindices, GL_UNSIGNED_SHORT, reinterpret_cast<const GLvoid *>(offset));
offset += (nindices << 1);
}
glEnable(GL_CULL_FACE);
}
}
}
|
[
"hikarin.jp@gmail.com"
] |
hikarin.jp@gmail.com
|
e2b91af040c001e4572912b9413a1df6c2cf3fd3
|
360996d1644bff7b558e46f93eab9cf1bf08a415
|
/es.h
|
046720bbdb8230edc26eac8bdf2e0b3abdcd9b3a
|
[] |
no_license
|
luisfelipehsr/something
|
3e6f3d3cdd8224c4b90cd8211850594bd1404c19
|
2fd3461058b801b8c0815579035803a75299040b
|
refs/heads/master
| 2021-08-22T18:54:58.463266
| 2017-12-01T01:45:10
| 2017-12-01T01:45:10
| 111,011,772
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 406
|
h
|
// guarda
#ifndef _ES_H_INCLUDED_
#define _ES_H_INCLUDED_
#include <string>
void imprime_saida_bnb(std::vector<int> &melhor_solucao, int &custo,
int &lim_inf, int &num_nos_exp);
void imprime_saida_heur(std::vector<int> &melhor_solucao, int &custo);
void recebe_entrada(const std::string arquivo, int &m, int &n,
std::vector<std::vector <int> > &T,
std::vector<int> &salario);
#endif
|
[
"luisfelipehsr@gmail.com"
] |
luisfelipehsr@gmail.com
|
df1a2fbb6f27fed0fea776e1abb6db4d4491bf6a
|
575731c1155e321e7b22d8373ad5876b292b0b2f
|
/examples/native/ios/Pods/boost-for-react-native/boost/math/tools/stats.hpp
|
3935991d7b1815443c8e32c87f14c92baf21ac0a
|
[
"BSL-1.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
Nozbe/zacs
|
802a84ffd47413a1687a573edda519156ca317c7
|
c3d455426bc7dfb83e09fdf20781c2632a205c04
|
refs/heads/master
| 2023-06-12T20:53:31.482746
| 2023-06-07T07:06:49
| 2023-06-07T07:06:49
| 201,777,469
| 432
| 10
|
MIT
| 2023-01-24T13:29:34
| 2019-08-11T14:47:50
|
JavaScript
|
UTF-8
|
C++
| false
| false
| 2,144
|
hpp
|
// (C) Copyright John Maddock 2005-2006.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_MATH_TOOLS_STATS_INCLUDED
#define BOOST_MATH_TOOLS_STATS_INCLUDED
#ifdef _MSC_VER
#pragma once
#endif
#include <boost/config/no_tr1/cmath.hpp>
#include <boost/cstdint.hpp>
#include <boost/math/tools/precision.hpp>
namespace boost{ namespace math{ namespace tools{
template <class T>
class stats
{
public:
stats()
: m_min(tools::max_value<T>()),
m_max(-tools::max_value<T>()),
m_total(0),
m_squared_total(0),
m_count(0)
{}
void add(const T& val)
{
if(val < m_min)
m_min = val;
if(val > m_max)
m_max = val;
m_total += val;
++m_count;
m_squared_total += val*val;
}
T min BOOST_PREVENT_MACRO_SUBSTITUTION()const{ return m_min; }
T max BOOST_PREVENT_MACRO_SUBSTITUTION()const{ return m_max; }
T total()const{ return m_total; }
T mean()const{ return m_total / static_cast<T>(m_count); }
boost::uintmax_t count()const{ return m_count; }
T variance()const
{
BOOST_MATH_STD_USING
T t = m_squared_total - m_total * m_total / m_count;
t /= m_count;
return t;
}
T variance1()const
{
BOOST_MATH_STD_USING
T t = m_squared_total - m_total * m_total / m_count;
t /= (m_count-1);
return t;
}
T rms()const
{
BOOST_MATH_STD_USING
return sqrt(m_squared_total / static_cast<T>(m_count));
}
stats& operator+=(const stats& s)
{
if(s.m_min < m_min)
m_min = s.m_min;
if(s.m_max > m_max)
m_max = s.m_max;
m_total += s.m_total;
m_squared_total += s.m_squared_total;
m_count += s.m_count;
return *this;
}
private:
T m_min, m_max, m_total, m_squared_total;
boost::uintmax_t m_count;
};
} // namespace tools
} // namespace math
} // namespace boost
#endif
|
[
"radexpl@gmail.com"
] |
radexpl@gmail.com
|
47d76ef5523c36ee7fd36e6094a36108b983f64c
|
b0dd7779c225971e71ae12c1093dc75ed9889921
|
/boost/python/object/class_metadata.hpp
|
561160011b848473d4fe75e4bb0a9c07cecc0c78
|
[
"LicenseRef-scancode-warranty-disclaimer",
"BSL-1.0"
] |
permissive
|
blackberry/Boost
|
6e653cd91a7806855a162347a5aeebd2a8c055a2
|
fc90c3fde129c62565c023f091eddc4a7ed9902b
|
refs/heads/1_48_0-gnu
| 2021-01-15T14:31:33.706351
| 2013-06-25T16:02:41
| 2013-06-25T16:02:41
| 2,599,411
| 244
| 154
|
BSL-1.0
| 2018-10-13T18:35:09
| 2011-10-18T14:25:18
|
C++
|
UTF-8
|
C++
| false
| false
| 9,227
|
hpp
|
// Copyright David Abrahams 2004. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef CLASS_METADATA_DWA2004719_HPP
# define CLASS_METADATA_DWA2004719_HPP
# include <boost/python/converter/shared_ptr_from_python.hpp>
# include <boost/python/object/inheritance.hpp>
# include <boost/python/object/class_wrapper.hpp>
# include <boost/python/object/make_instance.hpp>
# include <boost/python/object/value_holder.hpp>
# include <boost/python/object/pointer_holder.hpp>
# include <boost/python/object/make_ptr_instance.hpp>
# include <boost/python/detail/force_instantiate.hpp>
# include <boost/python/detail/not_specified.hpp>
# include <boost/python/has_back_reference.hpp>
# include <boost/python/bases.hpp>
# include <boost/type_traits/add_pointer.hpp>
# include <boost/type_traits/is_convertible.hpp>
# include <boost/type_traits/is_polymorphic.hpp>
# include <boost/mpl/if.hpp>
# include <boost/mpl/eval_if.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/mpl/or.hpp>
# include <boost/mpl/identity.hpp>
# include <boost/mpl/for_each.hpp>
# include <boost/mpl/placeholders.hpp>
# include <boost/mpl/single_view.hpp>
# include <boost/mpl/assert.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/type_traits/is_convertible.hpp>
# include <boost/noncopyable.hpp>
# include <boost/detail/workaround.hpp>
namespace boost { namespace python { namespace objects {
BOOST_PYTHON_DECL
void copy_class_object(type_info const& src, type_info const& dst);
//
// Support for registering base/derived relationships
//
template <class Derived>
struct register_base_of
{
template <class Base>
inline void operator()(Base*) const
{
# if !BOOST_WORKAROUND(BOOST_MSVC, == 1200)
BOOST_MPL_ASSERT_NOT((is_same<Base,Derived>));
# else
BOOST_STATIC_ASSERT(!(is_same<Base,Derived>::value));
# endif
// Register the Base class
register_dynamic_id<Base>();
// Register the up-cast
register_conversion<Derived,Base>(false);
// Register the down-cast, if appropriate.
this->register_downcast((Base*)0, is_polymorphic<Base>());
}
private:
static inline void register_downcast(void*, mpl::false_) {}
template <class Base>
static inline void register_downcast(Base*, mpl::true_)
{
register_conversion<Base, Derived>(true);
}
};
//
// Preamble of register_class. Also used for callback classes, which
// need some registration of their own.
//
template <class T, class Bases>
inline void register_shared_ptr_from_python_and_casts(T*, Bases)
{
// Constructor performs registration
python::detail::force_instantiate(converter::shared_ptr_from_python<T>());
//
// register all up/downcasts here. We're using the alternate
// interface to mpl::for_each to avoid an MSVC 6 bug.
//
register_dynamic_id<T>();
mpl::for_each(register_base_of<T>(), (Bases*)0, (add_pointer<mpl::_>*)0);
}
//
// Helper for choosing the unnamed held_type argument
//
template <class T, class Prev>
struct select_held_type
: mpl::if_<
mpl::or_<
python::detail::specifies_bases<T>
, is_same<T,noncopyable>
>
, Prev
, T
>
{
};
template <
class T // class being wrapped
, class X1 // = detail::not_specified
, class X2 // = detail::not_specified
, class X3 // = detail::not_specified
>
struct class_metadata
{
//
// Calculate the unnamed template arguments
//
// held_type_arg -- not_specified, [a class derived from] T or a
// smart pointer to [a class derived from] T. Preserving
// not_specified allows us to give class_<T,T> a back-reference.
typedef typename select_held_type<
X1
, typename select_held_type<
X2
, typename select_held_type<
X3
, python::detail::not_specified
>::type
>::type
>::type held_type_arg;
// bases
typedef typename python::detail::select_bases<
X1
, typename python::detail::select_bases<
X2
, typename python::detail::select_bases<
X3
, python::bases<>
>::type
>::type
>::type bases;
typedef mpl::or_<
is_same<X1,noncopyable>
, is_same<X2,noncopyable>
, is_same<X3,noncopyable>
> is_noncopyable;
//
// Holder computation.
//
// Compute the actual type that will be held in the Holder.
typedef typename mpl::if_<
is_same<held_type_arg,python::detail::not_specified>, T, held_type_arg
>::type held_type;
// Determine if the object will be held by value
typedef is_convertible<held_type*,T*> use_value_holder;
// Compute the "wrapped type", that is, if held_type is a smart
// pointer, we're talking about the pointee.
typedef typename mpl::eval_if<
use_value_holder
, mpl::identity<held_type>
, pointee<held_type>
>::type wrapped;
// Determine whether to use a "back-reference holder"
typedef mpl::or_<
has_back_reference<T>
, is_same<held_type_arg,T>
, is_base_and_derived<T,wrapped>
> use_back_reference;
// Select the holder.
typedef typename mpl::eval_if<
use_back_reference
, mpl::if_<
use_value_holder
, value_holder_back_reference<T, wrapped>
, pointer_holder_back_reference<held_type,T>
>
, mpl::if_<
use_value_holder
, value_holder<T>
, pointer_holder<held_type,wrapped>
>
>::type holder;
inline static void register_() // Register the runtime metadata.
{
class_metadata::register_aux((T*)0);
}
private:
template <class T2>
inline static void register_aux(python::wrapper<T2>*)
{
typedef typename mpl::not_<is_same<T2,wrapped> >::type use_callback;
class_metadata::register_aux2((T2*)0, use_callback());
}
inline static void register_aux(void*)
{
typedef typename is_base_and_derived<T,wrapped>::type use_callback;
class_metadata::register_aux2((T*)0, use_callback());
}
template <class T2, class Callback>
inline static void register_aux2(T2*, Callback)
{
objects::register_shared_ptr_from_python_and_casts((T2*)0, bases());
class_metadata::maybe_register_callback_class((T2*)0, Callback());
class_metadata::maybe_register_class_to_python((T2*)0, is_noncopyable());
class_metadata::maybe_register_pointer_to_python(
(T2*)0, (use_value_holder*)0, (use_back_reference*)0);
}
//
// Support for converting smart pointers to python
//
inline static void maybe_register_pointer_to_python(...) {}
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
inline static void maybe_register_pointer_to_python(void*,void*,mpl::true_*)
{
objects::copy_class_object(python::type_id<T>(), python::type_id<back_reference<T const &> >());
objects::copy_class_object(python::type_id<T>(), python::type_id<back_reference<T &> >());
}
#endif
template <class T2>
inline static void maybe_register_pointer_to_python(T2*, mpl::false_*, mpl::false_*)
{
python::detail::force_instantiate(
objects::class_value_wrapper<
held_type
, make_ptr_instance<T2, pointer_holder<held_type, T2> >
>()
);
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
// explicit qualification of type_id makes msvc6 happy
objects::copy_class_object(python::type_id<T2>(), python::type_id<held_type>());
#endif
}
//
// Support for registering to-python converters
//
inline static void maybe_register_class_to_python(void*, mpl::true_) {}
template <class T2>
inline static void maybe_register_class_to_python(T2*, mpl::false_)
{
python::detail::force_instantiate(class_cref_wrapper<T2, make_instance<T2, holder> >());
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
// explicit qualification of type_id makes msvc6 happy
objects::copy_class_object(python::type_id<T2>(), python::type_id<held_type>());
#endif
}
//
// Support for registering callback classes
//
inline static void maybe_register_callback_class(void*, mpl::false_) {}
template <class T2>
inline static void maybe_register_callback_class(T2*, mpl::true_)
{
objects::register_shared_ptr_from_python_and_casts(
(wrapped*)0, mpl::single_view<T2>());
// explicit qualification of type_id makes msvc6 happy
objects::copy_class_object(python::type_id<T2>(), python::type_id<wrapped>());
}
};
}}} // namespace boost::python::object
#endif // CLASS_METADATA_DWA2004719_HPP
|
[
"tvaneerd@rim.com"
] |
tvaneerd@rim.com
|
aea6c63820397df10651da9e1a07992f9cb3b862
|
c10516b25dc1b4b3ad73dca1bbd9d4fea25325b7
|
/Ayush Singh Chandel/Question-4.cpp
|
dcb2ef60394ec8786684d50eab14e0386c816659
|
[] |
no_license
|
ayucha7/upes-assignments
|
25165ae3dc6fb5f5ce6586d942fa609722f04a3d
|
0be440c1eb677318c1dfd41ad78eb8d5b8f49817
|
refs/heads/master
| 2021-06-25T23:59:25.353270
| 2017-09-10T11:24:33
| 2017-09-10T11:24:33
| 103,023,230
| 0
| 0
| null | 2017-09-10T11:11:09
| 2017-09-10T11:11:09
| null |
UTF-8
|
C++
| false
| false
| 2,172
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1000000007;
const int MX = 100000;
const int N = MX + 5;
int dem[N], cnt[N], a[N], pw[N][32], lt[N];
inline int add(int a, int b) {
if ((a+=b) >= mod) return a-mod;
else return a;
}
inline int sub(int a, int b) {
if ((a-=b) < 0) return a+mod;
else return a;
}
inline int mul(int a, int b) {
return LL(a) * b % mod;
}
int power(int a, int b) {
int r = 1;
while (b) {
if (b & 1) r = mul(r, a);
a = mul(a, a);
b >>= 1;
}
return r;
}
void solve(int nt) {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", a+i);
cnt[a[i]]++;
}
int ans = 1;
for (int i = MX; i >= 1; i--) {
dem[i] = 0;
int d = cnt[i];
for (int j = i+i; j <= MX; j += i) {
dem[i] -= dem[j];
if (dem[i] < 0) dem[i] += mod-1;
d += cnt[j];
}
dem[i] += lt[d];
if (dem[i] >= mod-1) dem[i] -= mod-1;
int b = dem[i];
int j = 0;
while (b) {
if (b & 1) ans = mul(ans, pw[i][j]);
j++; b >>= 1;
}
}
printf("%d\n", ans);
for (int i = 1; i <= n; i++) cnt[a[i]] = 0;
}
int main() {
lt[0] = 1;
for (int i = 1; i <= MX; i++) {
lt[i] = LL(lt[i-1]) * 2 % (mod-1);
lt[i-1]--;
if (lt[i-1] < 0) lt[i-1] += (mod-1);
pw[i][0] = i;
for (int j = 1; j <= 30; j++) pw[i][j] = mul(pw[i][j-1], pw[i][j-1]);
}
lt[MX]--; if (lt[MX] < 0) lt[MX] += (mod-1);
int ct;
scanf("%d", &ct);
for (int i = 1; i <= ct; i++) {
solve(i);
}
}
|
[
"noreply@github.com"
] |
ayucha7.noreply@github.com
|
0a149e434186e900350911cd3d94e5818a311341
|
d1e091e7f09da02924834ae1e54b01e92c2e4e48
|
/Coursework2/DXEngine/D3DAudio.h
|
3c4ac2b287ea8d61aee0d583271bdd6b59d49c0c
|
[] |
no_license
|
Cerwym/-WIP-DirectX11Multiplayer-Client
|
c75dea3ed176f6655c425433b2ec154654cae20d
|
99867697681c7c1d5323bc59401c5711491f5831
|
refs/heads/master
| 2021-01-21T21:19:07.538368
| 2015-09-22T13:59:37
| 2015-09-22T13:59:37
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,050
|
h
|
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>
#include <dsound.h>
#include <stdio.h>
#include "Defines.h"
class D3DAudio
{
public:
D3DAudio();
D3DAudio(const D3DAudio&){}
~D3DAudio();
bool Init(HWND);
void Cleanup();
// Plays the specified audio file
void PlayFile(char*);
private:
//Todo support for MP3
struct WaveHeaderType
{
char chunkID[4];
unsigned long chunkSize;
char format[4];
char subChunkID[4];
unsigned long subChunkSize;
unsigned short audioFormat;
unsigned short numChannels;
unsigned long sampleRate;
unsigned long bytesPerSecond;
unsigned short blockAlign;
unsigned short bitsPerSample;
char dataChunkID[4];
unsigned long dataSize;
};
bool InitDirectSound(HWND);
bool LoadWaveFile(char*, IDirectSoundBuffer8**);
void ShutdownWaveFile(IDirectSoundBuffer8**);
bool PlayWaveFile();
IDirectSound8* m_DirectSound;
IDirectSoundBuffer* m_primaryBuffer;
//Todo allow multiple sounds
IDirectSoundBuffer8* m_secondaryBuffer1;
HWND m_hwnd;
};
|
[
"cerwym@googlemail.com"
] |
cerwym@googlemail.com
|
4e06782b958e054861fe681679f7d4e05ff95025
|
a40ec7a12e893bf3ff5e913d111c2faaa7ede80f
|
/ws2812b/Led.cpp
|
6f312d7ebb16e6b8a6b72b529587dfea5defe9bd
|
[
"MIT"
] |
permissive
|
galilov/WS2812B-Clock
|
be7feaaecad3a1a926e5f17e635d5c2107c6a182
|
563791894f7758a6d989909f40d79aa278aaa586
|
refs/heads/master
| 2020-05-27T16:53:47.157836
| 2019-06-02T11:58:17
| 2019-06-02T11:58:17
| 188,711,460
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,190
|
cpp
|
//
// Created by Alexander Galilov on 26.05.2019.
// E-Mail: alexander.galilov@gmail.com
#include <unistd.h>
#include <time.h>
#include <stdexcept>
#include <bits/ios_base.h>
#include "Led.h"
using namespace WS2812B;
// See protocol description at https://static.chipdip.ru/lib/554/DOC001554925.pdf or
// https://www.digikey.com/en/datasheets/parallaxinc/parallax-inc-28085-ws2812b-rgb-led-datasheet
#if !USE_SIMPLE_IMPLEMENTATION
// Set bitrate to *about* 5 MHz.
#define SPI_SPEED 5000000
// see constructor code and https://github.com/raspberrypi/linux/issues/2094
double g_realSpiSpeed = 0;
#define LONG_SIGNAL_uS 0.9
#define SHORT_SIGNAL_uS 0.35
#define RESET_SIGNAL_uS 70.0
#define uS_PER_SECOND 1000000.0
#define LONG_SIGNAL_IN_SPI_BITS ((int)(LONG_SIGNAL_uS*g_realSpiSpeed/uS_PER_SECOND))
#define SHORT_SIGNAL_IN_SPI_BITS ((int)(SHORT_SIGNAL_uS*g_realSpiSpeed/uS_PER_SECOND))
#define RESET_SIGNAL_IN_SPI_BITS ((int)(RESET_SIGNAL_uS*g_realSpiSpeed/uS_PER_SECOND))
Led::Led(int spiChannel, int numLeds) :
_spiChannel(spiChannel), _numLeds(numLeds) {
_spi.open(_spiChannel, SPI_SPEED, 0);
// Some magic to fix https://github.com/raspberrypi/linux/issues/2094
if (g_realSpiSpeed == 0) {
const auto bufSize = 16000;
const double blockTransferApproxTime = bufSize * 8.0 / SPI_SPEED;
const auto nIterations = (size_t)(1.0 / blockTransferApproxTime);
std::vector<unsigned char> data;
data.reserve(bufSize);
for(int i = 0; i < bufSize; i++) {
data.push_back(0);
}
::timespec t0, t1;
::clock_gettime(CLOCK_REALTIME, &t0); //CLOCK_PROCESS_CPUTIME_ID does not work :(
for (int i = 0; i < nIterations; i++) {
_spi.write(data);
}
::clock_gettime(CLOCK_REALTIME, &t1);
long long nSecT0 = t0.tv_sec * 1000000000LL + t0.tv_nsec;
long long nSecT1 = t1.tv_sec * 1000000000LL + t1.tv_nsec;
g_realSpiSpeed = nIterations * 8.0 * bufSize * 1000000000L / (nSecT1 - nSecT0);
//printf("g_realSpeed: %f bits per second\n", g_realSpiSpeed);
}
// allocate RGB data
_rgbData.reserve(numLeds);
for (int i = 0; i < numLeds; i++) {
_rgbData.emplace_back(RGB());
}
// allocate SPI buffer
size_t sz = (size_t) ((LONG_SIGNAL_IN_SPI_BITS + SHORT_SIGNAL_IN_SPI_BITS) * 8 * 3 * _numLeds +
RESET_SIGNAL_IN_SPI_BITS) / 8;
_spiData.reserve(sz);
}
void Led::show() {
const size_t startBitIndex = 7;
unsigned char current = 0;
size_t bitIndex = startBitIndex;
for (auto const &srcRGBValue: _rgbData) {
unsigned char grb[] = {srcRGBValue._g, srcRGBValue._r, srcRGBValue._b};
for (auto const &srcValue:grb) {
for (size_t srcBitIndex = 0; srcBitIndex < 8; srcBitIndex++) {
size_t srcBitValue = (srcValue << srcBitIndex) & 0x080U;
int firstSemiWave = srcBitValue != 0 ? LONG_SIGNAL_IN_SPI_BITS : SHORT_SIGNAL_IN_SPI_BITS;
for (size_t i = 0; i < LONG_SIGNAL_IN_SPI_BITS + SHORT_SIGNAL_IN_SPI_BITS; i++) {
unsigned char targetBit = (firstSemiWave-- > 0) ? 1U : 0U;
//bitIndex = 7 - (i % 8);
if (targetBit) {
current |= (1U << bitIndex);
}
if (bitIndex-- == 0) {
bitIndex = startBitIndex;
_spiData.push_back(current);
current = 0;
}
}
}
}
}
if (bitIndex > -1) {
_spiData.push_back(current);
}
for (size_t i = 0; i < RESET_SIGNAL_IN_SPI_BITS / 8; i++) {
_spiData.push_back(0);
}
_spi.write(_spiData);
_spiData.clear();
}
#else
// Simple implementation
// Set SPI bitrate to 3.333 MHz.
#define SPI_SPEED 3333000
// Each PWM bit is projected to 4 SPI bits at 3.333MHz
#define PWM_ZERO 0b1000
#define PWM_ONE 0b1110
#define RESET_SIGNAL_IN_SECONDS 0.000060
#define RESET_SIGNAL_IN_SPI_BYTES ((int)(SPI_SPEED * RESET_SIGNAL_IN_SECONDS)/8.0)
Led::Led(int spiChannel, int numLeds) :
_spiChannel(spiChannel), _numLeds(numLeds) {
_spi.open(_spiChannel, SPI_SPEED, 0);
// allocate RGB data
_rgbData.reserve(numLeds);
for (int i = 0; i < numLeds; i++) {
_rgbData.emplace_back(RGB());
}
// allocate SPI buffer 12 bytes (24 bits PWM) per LED + RESET signal size in bytes
size_t sz = (size_t) (12 * _numLeds + RESET_SIGNAL_IN_SPI_BYTES);
_spiData.reserve(sz);
}
void Led::show() {
for (auto const &srcRGBValue: _rgbData) {
unsigned char grb[] = {srcRGBValue._g, srcRGBValue._r, srcRGBValue._b};
for (auto const &srcValue:grb) {
unsigned char current = 0;
for (size_t srcBitIndex = 0; srcBitIndex < 8; srcBitIndex++) {
size_t srcBitValue = (srcValue << srcBitIndex) & 0x080U;
unsigned char pattern = (srcBitValue != 0 ? PWM_ONE : PWM_ZERO);
if (srcBitIndex % 2 == 0) {
current = pattern << 4;
} else {
current |= pattern;
_spiData.push_back(current);
}
}
}
}
for (size_t i = 0; i < RESET_SIGNAL_IN_SPI_BYTES; i++) {
_spiData.push_back(0);
}
_spi.write(_spiData);
_spiData.clear();
}
#endif
// common part
Led::~Led() {
_spi.close();
}
void Led::clear() {
for (size_t i = 0; i < _rgbData.size(); i++) {
_rgbData[i].clear();
}
}
void Led::setColor(const WS2812B::RGB &color, int ledIndex) {
_checkLedIndexRange(ledIndex);
_rgbData[ledIndex] = color;
}
WS2812B::RGB &Led::getColor(int ledIndex) {
_checkLedIndexRange(ledIndex);
return _rgbData[ledIndex];
}
void Led::_checkLedIndexRange(int ledIndex) {
if (ledIndex < 0) throw std::invalid_argument("ledIndex should be >= 0");
if (ledIndex > _numLeds) throw std::invalid_argument("ledIndex should be < numLeds passed to the constructor");
}
|
[
"alexander.galilov@gmail.com"
] |
alexander.galilov@gmail.com
|
bc845b43f1b4a758a27096d026b82ab3b665b36b
|
f6a76823b3a9370cd96acd31f2a9b5cd87cff925
|
/MyYUVPlayer/MyYUVPlayerView.h
|
837163373c7d22eecc64595af1823cd393d2f856
|
[] |
no_license
|
firefoxking/MyYUVPlayer
|
7ad19f119e5760391ef24029573d4e1089343375
|
60b73bfb85e812b207c1dd1fe35174bb09c02258
|
refs/heads/master
| 2023-01-19T11:19:49.458074
| 2020-11-10T08:12:05
| 2020-11-10T08:12:05
| 311,561,047
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,016
|
h
|
// MyYUVPlayerView.h : CMyYUVPlayerView 类的接口
//
#pragma once
class CMyYUVPlayerView : public CView
{
protected: // 仅从序列化创建
CMyYUVPlayerView();
DECLARE_DYNCREATE(CMyYUVPlayerView)
// 特性
public:
CMyYUVPlayerDoc* GetDocument() const;
// 操作
public:
// 重写
public:
virtual void OnDraw(CDC* pDC); // 重写以绘制该视图
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
// 实现
public:
virtual ~CMyYUVPlayerView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// 生成的消息映射函数
protected:
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // MyYUVPlayerView.cpp 中的调试版本
inline CMyYUVPlayerDoc* CMyYUVPlayerView::GetDocument() const
{ return reinterpret_cast<CMyYUVPlayerDoc*>(m_pDocument); }
#endif
|
[
"漆腺腺@DESKTOP-TJG03EH"
] |
漆腺腺@DESKTOP-TJG03EH
|
504fb68a5519529b6f482229afee2a26facb1ef7
|
409305771cc048a29ddd7e2170feefd3cf3d1ac6
|
/calendar/demos/lec6-string.cpp
|
e440fc28fecc5458cd0ef118ce4e0bc6cdeb7620
|
[] |
no_license
|
wkiri/cs161-website
|
84842a4ec91e21136ba065566ed1fc588a45c810
|
f1190dc8c8468cdfecaf834570a6a9ccdeffbf22
|
refs/heads/master
| 2020-12-03T09:52:42.187475
| 2020-03-13T23:07:20
| 2020-03-13T23:07:20
| 231,273,087
| 0
| 5
| null | 2020-02-06T06:07:54
| 2020-01-01T23:00:04
|
HTML
|
UTF-8
|
C++
| false
| false
| 592
|
cpp
|
/*
* CS 161-020, Lecture 6, Winter 2020
* Example of use of strings
* Author: Kiri Wagstaff
* Date: January 17, 2020
*/
#include <iostream>
#include <string> /* include to allow strings to be used */
using namespace std;
int main()
{
string favorite_color = "red";
/* Query the user */
cout << "What is your favorite color? " << endl;
cin >> favorite_color;
cout << "You like " << favorite_color << endl;
/* You can use \n instead of endl */
cout << "You like " << favorite_color << "\n";
cout << "Longer code" << endl;
cout << "Shorter code\n";
return 0;
}
|
[
"wkiri@yahoo.com"
] |
wkiri@yahoo.com
|
810604c3c3b43cf45f7fecbf5ded8d9cd6768354
|
ea89955e343ced5e705b4a338039e658a4ba67cb
|
/Session14-RaveGun/Interface/PlayerOverlayHealth.h
|
e10180d4b49ce78f1ed4c5c19cee99a02fbda77c
|
[] |
no_license
|
kennethdmiller3/videoventure
|
775ce24ee4aebe3dfc65876a3fc9abb93f29b51d
|
7182b78fde61421c48abc679ef6f2992e740d678
|
refs/heads/master
| 2021-06-03T19:26:26.704306
| 2020-07-25T05:37:02
| 2020-07-25T05:37:02
| 32,195,803
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 515
|
h
|
#pragma once
#include "Overlay.h"
class PlayerOverlayHealth : public Overlay
{
public:
// fill values
float fill;
// drain values
float drain;
float draindelay;
// flash values
struct Flash
{
float left;
float right;
float fade;
};
Flash flash[16];
int flashcount;
// pulse values
float pulsetimer;
public:
PlayerOverlayHealth(unsigned int aPlayerId);
~PlayerOverlayHealth();
void Render(unsigned int aId, float aTime, const Transform2 &aTransform);
};
|
[
"kennethdmiller3@44a3119c-8d4d-0410-be80-6906e8c8b632"
] |
kennethdmiller3@44a3119c-8d4d-0410-be80-6906e8c8b632
|
9da0ce706e4861395a5e3f8d06b2dd560f513187
|
82fb4b3a5bd3c47603ab97144815643ff2e92610
|
/C++/345. Reverse Vowels of a String/solution.h
|
92e7e8021eaf5295f25dc2736f40d0c4c85053da
|
[
"MIT"
] |
permissive
|
wenqf11/LeetCode
|
a0f267f21193c1c9710ba4d570ae39f7467afac8
|
27b464044ecca8933127d1e82fa4973318d7c404
|
refs/heads/master
| 2020-04-18T02:59:01.024339
| 2017-10-10T03:06:28
| 2017-10-10T03:06:28
| 67,712,807
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 679
|
h
|
#pragma once
#include <vector>
#include <queue>
#include <string>
#include <climits>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
class Solution {
public:
string reverseVowels(string s) {
char a[10] = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'} ;
set<char> m(a, a + 10);
int n = s.size();
int i = 0, j = n - 1;
while (i < j) {
while (i < n && m.find(s[i]) == m.end()) ++i;
while (j >= 0 && m.find(s[j]) == m.end()) --j;
if (i <= j ) {
swap(s[i], s[j]);
++i;
--j;
}
}
return s;
}
};
|
[
"qingfu.wen@gmail.com"
] |
qingfu.wen@gmail.com
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.